commit d4eae9b

xplshn  ·  2026-08-18 23:39:15 +0000 UTC
parent 1695915
!

Signed-off-by: xplshn <anto@xplshn.com.ar>
2 files changed,  +107, -43
+92, -0
 1@@ -0,0 +1,92 @@
 2+CC       ?= cc -static
 3+CFLAGS   ?= -std=c99 -Wall -Wextra -pedantic
 4+
 5+BACKEND  ?= auto
 6+
 7+CPPFLAGS ?= -Ishared -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
 8+            -DFEATURE_NOFORK=0 -DFEATURE_NOEXEC=0
 9+# NOEXEC cannot be on the bootstrap compile, but it can
10+# be on when one compiles aruu-box with ninqu included
11+
12+NINQU_LIB_SRC =\
13+        shared/libutil/ealloc.c\
14+        shared/libutil/eprintf.c\
15+        shared/libutil/strlcpy.c\
16+        shared/libutil/strlcat.c\
17+        shared/libutil/strtonum.c\
18+        shared/libutil/fshut.c\
19+        shared/libutil/mkdirp.c\
20+        shared/libutil/recurse_dir.c\
21+        shared/libutil/wexec.c
22+
23+NINQU_SRC =\
24+        cmd/dev/ninqu/main.c\
25+        cmd/dev/ninqu/strlist.c\
26+        cmd/dev/ninqu/kv.c\
27+        cmd/dev/ninqu/sexpr.c\
28+        cmd/dev/ninqu/gate.c\
29+        cmd/dev/ninqu/registry.c\
30+        cmd/dev/ninqu/fs.c\
31+        cmd/dev/ninqu/exec.c\
32+        cmd/dev/ninqu/backend.c\
33+        cmd/dev/ninqu/parse.c\
34+        cmd/dev/ninqu/expand.c\
35+        cmd/dev/ninqu/schedule.c\
36+        cmd/dev/ninqu/query.c\
37+        cmd/dev/ninqu/resolve.c\
38+        cmd/dev/ninqu/ninja.c
39+
40+# map make's -j to ninqu's -j flag
41+NINQU ?= cmd/dev/ninqu/ninqu
42+JOBS  ?= $(filter -j%,$(MAKEFLAGS))
43+
44+# rebuilds config.set first so a build.cfg edit is picked up before
45+# ninqu compiles, ninqu also does this lazily on its own via
46+# (set-file), this just avoids the extra shell startup on every run
47+$(NINQU): $(NINQU_SRC) cmd/dev/ninqu/ninqu.h scripts/mk/config.set $(NINQU_LIB_SRC)
48+	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(NINQU_SRC) $(NINQU_LIB_SRC)
49+
50+# FORCE has no rule, thus making any pattern
51+# that depends on it be always outdated
52+.PHONY: FORCE
53+FORCE:
54+
55+# ninqu generates build.ninja if ninja/samu is available and execs that
56+# instead of running its own backend, but you can use make backend=internal
57+# to force the internal one to be used anyways
58+%: $(NINQU) FORCE
59+	$(NINQU) $(JOBS) $@
60+
61+clean: $(NINQU)
62+	$(NINQU) clean
63+	rm -f $(NINQU) build.ninja
64+
65+scripts/mk/config.set: build.cfg scripts/genconfig.sh
66+	sh scripts/genconfig.sh config
67+
68+# stops the % pattern rule above from trying to rebuild these as if
69+# they were stale build targets: GNU make's own implicit "remake my
70+# makefiles" check runs the pattern rule against this file's own
71+# name too, otherwise (and, since a POSIX Makefile can sit right next
72+# to this one, against that name as well)
73+GNUmakefile: ;
74+Makefile: ;
75+ninqu.rules: ;
76+cmd/dev/ninqu/ninqu.h: ;
77+cmd/dev/ninqu/main.c: ;
78+cmd/dev/ninqu/strlist.c: ;
79+cmd/dev/ninqu/kv.c: ;
80+cmd/dev/ninqu/sexpr.c: ;
81+cmd/dev/ninqu/gate.c: ;
82+cmd/dev/ninqu/registry.c: ;
83+cmd/dev/ninqu/fs.c: ;
84+cmd/dev/ninqu/exec.c: ;
85+cmd/dev/ninqu/backend.c: ;
86+cmd/dev/ninqu/parse.c: ;
87+cmd/dev/ninqu/expand.c: ;
88+cmd/dev/ninqu/schedule.c: ;
89+cmd/dev/ninqu/query.c: ;
90+cmd/dev/ninqu/resolve.c: ;
91+cmd/dev/ninqu/ninja.c: ;
92+build.cfg: ;
93+scripts/genconfig.sh: ;
+15, -43
 1@@ -1,12 +1,10 @@
 2-CC       ?= cc -static
 3-CFLAGS   ?= -std=c99 -Wall -Wextra -pedantic
 4+CC       = cc -static
 5+CFLAGS   = -std=c99 -Wall -Wextra -pedantic
 6 
 7 BACKEND  ?= auto
 8 
 9 CPPFLAGS ?= -Ishared -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
10             -DFEATURE_NOFORK=0 -DFEATURE_NOEXEC=0
11-# NOEXEC cannot be on the bootstrap compile, but it can
12-# be on when one compiles aruu-box with ninqu included
13 
14 NINQU_LIB_SRC =\
15         shared/libutil/ealloc.c\
16@@ -36,53 +34,27 @@ NINQU_SRC =\
17         cmd/dev/ninqu/resolve.c\
18         cmd/dev/ninqu/ninja.c
19 
20-# map make's -j to ninqu's -j flag
21 NINQU ?= cmd/dev/ninqu/ninqu
22-JOBS  ?= $(filter -j%,$(MAKEFLAGS))
23+# no $(filter -j%,$(MAKEFLAGS)) equivalent here (GNUmakefile's own
24+# trick): pass ninqu's own parallelism directly, "make JOBS=-j8 box"
25+JOBS ?=
26+
27+# every real goal ninqu.rules exposes, listed once instead of
28+# GNUmakefile's own "%: FORCE" catch-all. a new top-level group needs
29+# a matching name added here too
30+.PHONY: all default clean box dev man install install-base uninstall \
31+        remove fmt fmt-all lib posix linux net xsi pseudo extra codegen
32 
33-# rebuilds config.set first so a build.cfg edit is picked up before
34-# ninqu compiles, ninqu also does this lazily on its own via
35-# (set-file), this just avoids the extra shell startup on every run
36 $(NINQU): $(NINQU_SRC) cmd/dev/ninqu/ninqu.h scripts/mk/config.set $(NINQU_LIB_SRC)
37 	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(NINQU_SRC) $(NINQU_LIB_SRC)
38 
39-# FORCE has no rule, thus making any pattern
40-# that depends on it be always outdated
41-.PHONY: FORCE
42-FORCE:
43+scripts/mk/config.set: build.cfg scripts/genconfig.sh
44+	sh scripts/genconfig.sh config
45 
46-# ninqu generates build.ninja if ninja/samu is available and execs that
47-# instead of running its own backend, but you can use make backend=internal
48-# to force the internal one to be used anyways
49-%: $(NINQU) FORCE
50+all default box dev man install install-base uninstall remove \
51+fmt fmt-all lib posix linux net xsi pseudo extra codegen: $(NINQU)
52 	$(NINQU) $(JOBS) $@
53 
54 clean: $(NINQU)
55 	$(NINQU) clean
56 	rm -f $(NINQU) build.ninja
57-
58-scripts/mk/config.set: build.cfg scripts/genconfig.sh
59-	sh scripts/genconfig.sh config
60-
61-# stops the % pattern rule above from trying to rebuild these as if
62-# they were stale build targets
63-Makefile: ;
64-ninqu.rules: ;
65-cmd/dev/ninqu/ninqu.h: ;
66-cmd/dev/ninqu/main.c: ;
67-cmd/dev/ninqu/strlist.c: ;
68-cmd/dev/ninqu/kv.c: ;
69-cmd/dev/ninqu/sexpr.c: ;
70-cmd/dev/ninqu/gate.c: ;
71-cmd/dev/ninqu/registry.c: ;
72-cmd/dev/ninqu/fs.c: ;
73-cmd/dev/ninqu/exec.c: ;
74-cmd/dev/ninqu/backend.c: ;
75-cmd/dev/ninqu/parse.c: ;
76-cmd/dev/ninqu/expand.c: ;
77-cmd/dev/ninqu/schedule.c: ;
78-cmd/dev/ninqu/query.c: ;
79-cmd/dev/ninqu/resolve.c: ;
80-cmd/dev/ninqu/ninja.c: ;
81-build.cfg: ;
82-scripts/genconfig.sh: ;