commit 8db691ec62143bac4b0f6522b5fa63a6895045a3
parent 6218a27302cdb6c8a0d8f565b9218ea7aa895edb
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 24 Oct 2024 21:55:31 +0200
build: Add make dep target
This target is used to generate makefiles based in the Makefiles
but including the inclusion dependencies.
Diffstat:
5 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -33,3 +33,4 @@ dirs
/src/cmd/scc-ld/scc-ld
/src/cmd/scc-make/scc-make
/config.mk
+makefile
diff --git a/Makefile b/Makefile
@@ -1,6 +1,6 @@
.POSIX:
-all tests install uninstall: check_config FORCE
+all dep tests install uninstall: check_config FORCE
+@$(MAKE) -f main.mk $@
check_config: FORCE
diff --git a/README b/README
@@ -109,6 +109,13 @@ The main targets of the Makefile are:
for all the available configurations based in the host
architecture.
+ - dep:
+ Generate inclusion dependencies, very useful while
+ modifying the code. Beware that it creates files with
+ the name `makefile` and changes to `Makefile` files
+ are not reflected in the build proces until a `make distclean`
+ or a `make dep` is executed again.
+
- config:
Generate config.mk and the headers `include/bits/scc/sys.h`,
`include/bits/scc/std.h` and `include/bits/scc/config.h`.
diff --git a/scripts/mkdep b/scripts/mkdep
@@ -2,11 +2,12 @@
set -e
-echo '#deps' > deps.mk
+tmp=$$.tmp
+trap "rm -f $tmp" EXIT INT TERM HUP
-cat <<EOF | ed -s deps.mk
-a
-$(for i in `find . -name '*.c'`
+(cat Makefile
+printf "\n#deps\n"
+for i in `find . -name '*.c'`
do
file=`basename $i | sed 's/\.c$/.o/'`
dir=`dirname $i`
@@ -16,10 +17,8 @@ do
s@\"\(.*\)\"@$dir/$file: $dir/\1@p
s@<\(scc/.*\)>@$dir/$file: \$(INCDIR)/bits/\1@p
}" $i
-done | LC_ALL=C sort -s)
-.
-g@^\./@ s///
-g@ \./@ s// /
-g/^$/d
-w
-EOF
+done |
+sed -e 's@^\./@@' -e 's@ \./@ @g' |
+LC_ALL=C sort -s) > $tmp
+
+mv $tmp makefile
diff --git a/scripts/rules.mk b/scripts/rules.mk
@@ -204,7 +204,6 @@ dep: inc-dep
@set -e; \
for i in $(DIRS); \
do \
- test $$i = qbe && continue;\
test $$i = tests && continue;\
cd $$i; \
$(MAKE) $@; \