commit ea14f43f632314180f07be87d37417631142848f
parent 2b8000f1ebd07fd68ee0e3c32737d97bcd1687fb
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Mon, 30 Sep 2024 03:02:04 +0200
implement a ninja build system
Diffstat:
13 files changed, 300 insertions(+), 0 deletions(-)
diff --git a/build.ninja b/build.ninja
@@ -0,0 +1,18 @@
+# used by ninja's build artefacts, but this is longer than DST
+# to write, hence I'll keep using the shortcut.
+builddir = ./build
+
+# build.ninja
+include conf.ninja
+
+subninja src/librunit.ninja
+subninja src/runsv.ninja
+subninja src/chpst.ninja
+subninja src/sv.ninja
+subninja src/chkshsgr.ninja
+subninja src/utmpset.ninja
+subninja src/runsvchdir.ninja
+subninja src/svlogd.ninja
+subninja src/runit.ninja
+subninja src/runit-init.ninja
+subninja src/runsvdir.ninja
diff --git a/conf.ninja b/conf.ninja
@@ -0,0 +1,32 @@
+# conf.ninja
+ninja_required_version = 1.8
+
+CXX = $${CXX:-"g++"}
+CC = $${CC:-"gcc"}
+LD = $${LD:-"ld"}
+AR = $${AR:-"ar"}
+
+CXXFLAGS = $${CXXFLAGS:-""}
+CCFLAGS = $${CCFLAGS:-""}
+#LDFLAGS = $${LDFLAGS:-""}
+#ARFLAGS = $${ARFLAGS:-""}
+
+rule cc
+ description = compiling $in toward $out
+ depfile = $out.d
+ deps = gcc
+ command = $CC $CCFLAGS -MD -MF $out.d -c $in -o $out
+
+rule cxx
+ description = compiling $in toward $out
+ depfile = $out.d
+ deps = gcc
+ command = $CXX $CXXFLAGS -MD -MF $out.d -c $in -o $out
+
+rule ld
+ description = building $in to $out
+ command = $CC $LDFLAGS $in -o $out
+
+rule ar
+ description = building $in to $out
+ command = $AR rc $ARFLAGS $out $in
diff --git a/src/chkshsgr.ninja b/src/chkshsgr.ninja
@@ -0,0 +1,10 @@
+PROJECT = chkshsgr
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/chpst.ninja b/src/chpst.ninja
@@ -0,0 +1,10 @@
+PROJECT = chpst
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/librunit.ninja b/src/librunit.ninja
@@ -0,0 +1,150 @@
+PROJECT = librunit
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/fifo.c.o: cc $SRC/fifo.c
+build $DST/prot.c.o: cc $SRC/prot.c
+build $DST/uidgid.c.o: cc $SRC/uidgid.c
+build $DST/pathexec_env.c.o: cc $SRC/pathexec_env.c
+build $DST/pathexec_run.c.o: cc $SRC/pathexec_run.c
+build $DST/ndelay_on.c.o: cc $SRC/ndelay_on.c
+build $DST/ndelay_off.c.o: cc $SRC/ndelay_off.c
+build $DST/pmatch.c.o: cc $SRC/pmatch.c
+build $DST/coe.c.o: cc $SRC/coe.c
+build $DST/iopause.c.o: cc $SRC/iopause.c
+build $DST/byte_diff.c.o: cc $SRC/byte_diff.c
+build $DST/byte_chr.c.o: cc $SRC/byte_chr.c
+build $DST/byte_copy.c.o: cc $SRC/byte_copy.c
+build $DST/byte_cr.c.o: cc $SRC/byte_cr.c
+build $DST/str_start.c.o: cc $SRC/str_start.c
+build $DST/str_diff.c.o: cc $SRC/str_diff.c
+build $DST/str_len.c.o: cc $SRC/str_len.c
+build $DST/str_chr.c.o: cc $SRC/str_chr.c
+build $DST/strerr_die.c.o: cc $SRC/strerr_die.c
+build $DST/strerr_sys.c.o: cc $SRC/strerr_sys.c
+build $DST/openreadclose.c.o: cc $SRC/openreadclose.c
+build $DST/readclose.c.o: cc $SRC/readclose.c
+build $DST/open_append.c.o: cc $SRC/open_append.c
+build $DST/open_trunc.c.o: cc $SRC/open_trunc.c
+build $DST/open_read.c.o: cc $SRC/open_read.c
+build $DST/open_write.c.o: cc $SRC/open_write.c
+build $DST/error_str.c.o: cc $SRC/error_str.c
+build $DST/error.c.o: cc $SRC/error.c
+build $DST/wait_pid.c.o: cc $SRC/wait_pid.c
+build $DST/wait_nohang.c.o: cc $SRC/wait_nohang.c
+build $DST/buffer.c.o: cc $SRC/buffer.c
+build $DST/buffer_get.c.o: cc $SRC/buffer_get.c
+build $DST/buffer_put.c.o: cc $SRC/buffer_put.c
+build $DST/buffer_write.c.o: cc $SRC/buffer_write.c
+build $DST/buffer_1.c.o: cc $SRC/buffer_1.c
+build $DST/buffer_2.c.o: cc $SRC/buffer_2.c
+build $DST/fmt_uint.c.o: cc $SRC/fmt_uint.c
+build $DST/fmt_uint0.c.o: cc $SRC/fmt_uint0.c
+build $DST/fmt_ulong.c.o: cc $SRC/fmt_ulong.c
+build $DST/fmt_ptime.c.o: cc $SRC/fmt_ptime.c
+build $DST/scan_ulong.c.o: cc $SRC/scan_ulong.c
+build $DST/env.c.o: cc $SRC/env.c
+build $DST/tai_pack.c.o: cc $SRC/tai_pack.c
+build $DST/tai_unpack.c.o: cc $SRC/tai_unpack.c
+build $DST/taia_pack.c.o: cc $SRC/taia_pack.c
+build $DST/taia_add.c.o: cc $SRC/taia_add.c
+build $DST/taia_less.c.o: cc $SRC/taia_less.c
+build $DST/taia_now.c.o: cc $SRC/taia_now.c
+build $DST/taia_approx.c.o: cc $SRC/taia_approx.c
+build $DST/taia_sub.c.o: cc $SRC/taia_sub.c
+build $DST/taia_frac.c.o: cc $SRC/taia_frac.c
+build $DST/taia_uint.c.o: cc $SRC/taia_uint.c
+build $DST/subgetopt.c.o: cc $SRC/subgetopt.c
+build $DST/sgetopt.c.o: cc $SRC/sgetopt.c
+build $DST/alloc.c.o: cc $SRC/alloc.c
+build $DST/alloc_re.c.o: cc $SRC/alloc_re.c
+build $DST/stralloc_opyb.c.o: cc $SRC/stralloc_opyb.c
+build $DST/stralloc_eady.c.o: cc $SRC/stralloc_eady.c
+build $DST/stralloc_pend.c.o: cc $SRC/stralloc_pend.c
+build $DST/stralloc_opys.c.o: cc $SRC/stralloc_opys.c
+build $DST/stralloc_cat.c.o: cc $SRC/stralloc_cat.c
+build $DST/stralloc_cats.c.o: cc $SRC/stralloc_cats.c
+build $DST/stralloc_catb.c.o: cc $SRC/stralloc_catb.c
+build $DST/sig.c.o: cc $SRC/sig.c
+build $DST/sig_block.c.o: cc $SRC/sig_block.c
+build $DST/sig_catch.c.o: cc $SRC/sig_catch.c
+build $DST/sig_pause.c.o: cc $SRC/sig_pause.c
+build $DST/fd_move.c.o: cc $SRC/fd_move.c
+build $DST/fd_copy.c.o: cc $SRC/fd_copy.c
+build $DST/lock_exnb.c.o: cc $SRC/lock_exnb.c
+build $DST/lock_ex.c.o: cc $SRC/lock_ex.c
+
+build $DST/../$PROJECT.a: ar $
+ $DST/fifo.c.o $
+ $DST/prot.c.o $
+ $DST/uidgid.c.o $
+ $DST/pathexec_env.c.o $
+ $DST/pathexec_run.c.o $
+ $DST/lock_exnb.c.o $
+ $DST/lock_ex.c.o $
+ $DST/ndelay_on.c.o $
+ $DST/ndelay_off.c.o $
+ $DST/pmatch.c.o $
+ $DST/coe.c.o $
+ $DST/iopause.c.o $
+ $DST/readclose.c.o $
+ $DST/openreadclose.c.o $
+ $DST/open_append.c.o $
+ $DST/open_trunc.c.o $
+ $DST/open_read.c.o $
+ $DST/error_str.c.o $
+ $DST/error.c.o $
+ $DST/str_diff.c.o $
+ $DST/str_len.c.o $
+ $DST/str_chr.c.o $
+ $DST/str_start.c.o $
+ $DST/strerr_die.c.o $
+ $DST/strerr_sys.c.o $
+ $DST/wait_pid.c.o $
+ $DST/wait_nohang.c.o $
+ $DST/open_write.c.o $
+ $DST/buffer.c.o $
+ $DST/buffer_get.c.o $
+ $DST/buffer_put.c.o $
+ $DST/buffer_write.c.o $
+ $DST/buffer_1.c.o $
+ $DST/buffer_2.c.o $
+ $DST/fmt_uint.c.o $
+ $DST/fmt_uint0.c.o $
+ $DST/fmt_ulong.c.o $
+ $DST/fmt_ptime.c.o $
+ $DST/env.c.o $
+ $DST/byte_diff.c.o $
+ $DST/byte_chr.c.o $
+ $DST/byte_copy.c.o $
+ $DST/byte_cr.c.o $
+ $DST/scan_ulong.c.o $
+ $DST/tai_pack.c.o $
+ $DST/tai_unpack.c.o $
+ $DST/taia_pack.c.o $
+ $DST/taia_add.c.o $
+ $DST/taia_now.c.o $
+ $DST/taia_approx.c.o $
+ $DST/taia_sub.c.o $
+ $DST/taia_frac.c.o $
+ $DST/taia_less.c.o $
+ $DST/taia_uint.c.o $
+ $DST/subgetopt.c.o $
+ $DST/sgetopt.c.o $
+ $DST/alloc.c.o $
+ $DST/alloc_re.c.o $
+ $DST/stralloc_opys.c.o $
+ $DST/stralloc_opyb.c.o $
+ $DST/stralloc_eady.c.o $
+ $DST/stralloc_cat.c.o $
+ $DST/stralloc_cats.c.o $
+ $DST/stralloc_catb.c.o $
+ $DST/stralloc_pend.c.o $
+ $DST/stralloc_eady.c.o $
+ $DST/sig.c.o $
+ $DST/sig_block.c.o $
+ $DST/sig_catch.c.o $
+ $DST/sig_pause.c.o $
+ $DST/fd_move.c.o $
+ $DST/fd_copy.c.o $
+
diff --git a/src/runit-init.ninja b/src/runit-init.ninja
@@ -0,0 +1,10 @@
+PROJECT = runit-init
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/runit.ninja b/src/runit.ninja
@@ -0,0 +1,10 @@
+PROJECT = runit
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/runsv.ninja b/src/runsv.ninja
@@ -0,0 +1,10 @@
+PROJECT = runsv
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/runsvchdir.ninja b/src/runsvchdir.ninja
@@ -0,0 +1,10 @@
+PROJECT = runsvchdir
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/runsvdir.ninja b/src/runsvdir.ninja
@@ -0,0 +1,10 @@
+PROJECT = runsvdir
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/sv.ninja b/src/sv.ninja
@@ -0,0 +1,10 @@
+PROJECT = sv
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/svlogd.ninja b/src/svlogd.ninja
@@ -0,0 +1,10 @@
+PROJECT = svlogd
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+
diff --git a/src/utmpset.ninja b/src/utmpset.ninja
@@ -0,0 +1,10 @@
+PROJECT = utmpset
+SRC = ./src/
+DST = ./build/$PROJECT/src/
+
+build $DST/$PROJECT.c.o: cc $SRC/$PROJECT.c
+
+build $DST/../$PROJECT: ld $
+ $DST/$PROJECT.c.o $
+ ./build/librunit/librunit.a $
+