From 844b90ec6b79be309d0bd3d08df36b78d48eee90 Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 7 Apr 2025 02:39:58 +0300 Subject: refactor install things --- ninja.m4 | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'ninja.m4') diff --git a/ninja.m4 b/ninja.m4 index b6f8d7d..7d6c058 100644 --- a/ninja.m4 +++ b/ninja.m4 @@ -1,5 +1,4 @@ divert(-1) - changequote([,]) define([getenv], [ @@ -8,21 +7,17 @@ define([getenv], [ ifelse($2, , [undefine([$1])], [define([$1], [$2])]) ])]) -dnl For installing -getenv([PREFIX], [./testprefix]) -getenv([INCLUDEDIR], [PREFIX/include]) -getenv([LIBDIR], [PREFIX/lib]) - +# global vars getenv([PROD]) divert(0) +# building + cflags = ifdef([PROD], [], [-Wall -Wextra -g]) -std=c99 -D_DEFAULT_SOURCE bin = build m4flags = -# building - rule cc command = gcc $cflags $in -o $out rule obj @@ -46,25 +41,30 @@ build $bin/libmsgpack.so: cc $bin/msgpack.o # installing +divert(-1) +getenv([PREFIX], [installdir]) +getenv([LIBDIR], [PREFIX/lib]) +getenv([INCLUDEDIR], [PREFIX/include]) +divert(0) -# TODO: make copying better and abstract this somehow -pattern = -dir = rule cpy_to_dir - command = cp $$(/bin/ls $pattern 2> /dev/null) $dir 2> /dev/null + command = cp $$(command ls $pattern 2> /dev/null) $dir build force: phony -build $bin/files.dd: m4 scanbuild.m4 | force +build $bin/files.dd: m4 builtfiles.dd.m4 | force m4flags = -D BIN=$bin -D [LIBDIR]=LIBDIR -D [INCLUDEDIR]=INCLUDEDIR + description = Generate dynamic dependency from the built files build libs: cpy_to_dir || $bin/files.dd dir = LIBDIR - pattern = $bin/*.{so,a} + pattern = $bin/*.a $bin/*.so dyndep = $bin/files.dd + description = Install library files to 'LIBDIR' build includes: cpy_to_dir || $bin/files.dd dir = INCLUDEDIR pattern = $bin/*.h dyndep = $bin/files.dd + description = Install header files to 'INCLUDEDIR' # testing @@ -93,8 +93,9 @@ default ifdef([PROD], [static], [test]) rule regen command = m4 ninja.m4 > build.ninja - generator=1 - + generator = 1 + description = Regen build.ninja + build build.ninja: regen ninja.m4 build configure: regen -- cgit v1.2.3