aboutsummaryrefslogtreecommitdiff
path: root/ninja.m4
diff options
context:
space:
mode:
Diffstat (limited to 'ninja.m4')
-rw-r--r--ninja.m433
1 files changed, 17 insertions, 16 deletions
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