commit 6f59bc4250f2f8ccd693f5184f1f002561be532c
parent 5403b6a8b32780b34bf2abade344b91f995f5b5d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 23 Oct 2024 17:37:01 +0200
build/cc2: Migrate to a recursive Makefile
This simplifies the management of dependencies.
Diffstat:
14 files changed, 138 insertions(+), 117 deletions(-)
diff --git a/src/cmd/scc-cc/cc2/Makefile b/src/cmd/scc-cc/cc2/Makefile
@@ -1,8 +1,19 @@
.POSIX:
+DIRS =\
+ amd64-sysv\
+ arm64-sysv\
+ i386-sysv\
+ qbe\
+ qbe_amd64-sysv\
+ qbe_arm64-sysv\
+ z80-scc\
+
PROJECTDIR = ../../../..
include $(PROJECTDIR)/scripts/rules.mk
+MORE_LDLIBS = -lscc
+
OBJS =\
main.o\
parser.o\
@@ -19,21 +30,35 @@ TARGET =\
cc2-qbe_arm64-sysv\
cc2-z80-scc\
-all: $(TARGET)
+all:
+ $(MAKE) $(DIRS)
+ $(MAKE) $(TARGET)
+ @cp $(TARGET) $(LIBEXEC)/scc
main.o: error.h
+qbe_amd64-sysv qbe_arm64-sysv: qbe
+qbe_amd64-sysv: amd64-sysv
+qbe_arm64-sysv: arm64-sysv
error.h: cc2.h
rm -f $@;\
trap 'rm -f $$$$.h' EXIT INT QUIT TERM HUP;\
awk -f generror.awk cc2.h > $$$$.h && mv $$$$.h $@
+cc2-amd64-sysv: $(LIBSCC) $(OBJS) amd64-sysv/builtin.o
+ $(CC) $(PROJ_LDFLAGS) $(OBJS) amd64-sysv/builtin.o $(PROJ_LDLIBS) -o $@
+
+cc2-i386-sysv: $(LIBSCC) $(OBJS) i386-sysv/builtin.o
+ $(CC) $(PROJ_LDFLAGS) $(OBJS) i386-sysv/builtin.o $(PROJ_LDLIBS) -o $@
+
+cc2-qbe_amd64-sysv: $(LIBSCC) $(OBJS) qbe_amd64-sysv/builtin.o
+ $(CC) $(PROJ_LDFLAGS) $(OBJS) qbe_amd64-sysv/builtin.o $(PROJ_LDLIBS) -o $@
+
+cc2-qbe_arm64-sysv: $(LIBSCC) $(OBJS) qbe_arm64-sysv/builtin.o
+ $(CC) $(PROJ_LDFLAGS) $(OBJS) qbe_arm64-sysv/builtin.o $(PROJ_LDLIBS) -o $@
+
+cc2-z80-scc: $(LIBSCC) $(OBJS) z80-scc/builtin.o
+ $(CC) $(PROJ_LDFLAGS) $(OBJS) z80-scc/builtin.o $(PROJ_LDLIBS) -o $@
+
clean:
- rm -f target/*/*.o error.h
-
-include amd64-sysv/target.mk
-include i386-sysv/target.mk
-include qbe_amd64-sysv/target.mk
-include qbe_arm64-sysv/target.mk
-include z80-scc/target.mk
-include deps.mk
+ rm -f error.h
diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/Makefile b/src/cmd/scc-cc/cc2/amd64-sysv/Makefile
@@ -0,0 +1,16 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ cgen.o \
+ optm.o \
+ code.o \
+ types.o \
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/target.mk b/src/cmd/scc-cc/cc2/amd64-sysv/target.mk
@@ -1,9 +0,0 @@
-OBJ-amd64-sysv = $(OBJS) \
- amd64-sysv/cgen.o \
- amd64-sysv/optm.o \
- amd64-sysv/code.o \
- amd64-sysv/types.o
-
-cc2-amd64-sysv: $(LIBSCC) $(OBJ-amd64-sysv)
- $(CC) $(PROJ_LDFLAGS) $(OBJ-amd64-sysv) -lscc $(PROJ_LDLIBS) -o $@
- cp $@ $(LIBEXEC)/scc
diff --git a/src/cmd/scc-cc/cc2/arm64-sysv/Makefile b/src/cmd/scc-cc/cc2/arm64-sysv/Makefile
@@ -0,0 +1,13 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ types.o \
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/deps.mk b/src/cmd/scc-cc/cc2/deps.mk
@@ -1,63 +0,0 @@
-#deps
-code.o: $(INCDIR)/bits/scc/scc.h
-code.o: cc2.h
-main.o: $(INCDIR)/bits/scc/arg.h
-main.o: $(INCDIR)/bits/scc/scc.h
-main.o: cc2.h
-main.o: error.h
-node.o: $(INCDIR)/bits/scc/scc.h
-node.o: cc2.h
-optm.o: $(INCDIR)/bits/scc/scc.h
-optm.o: cc2.h
-parser.o: $(INCDIR)/bits/scc/cstd.h
-parser.o: $(INCDIR)/bits/scc/scc.h
-parser.o: cc2.h
-peep.o: $(INCDIR)/bits/scc/scc.h
-peep.o: cc2.h
-symbol.o: $(INCDIR)/bits/scc/scc.h
-symbol.o: cc2.h
-amd64-sysv/cgen.o: $(INCDIR)/bits/scc/scc.h
-amd64-sysv/cgen.o: amd64-sysv/../cc2.h
-amd64-sysv/cgen.o: amd64-sysv/arch.h
-amd64-sysv/code.o: $(INCDIR)/bits/scc/cstd.h
-amd64-sysv/code.o: $(INCDIR)/bits/scc/scc.h
-amd64-sysv/code.o: amd64-sysv/../cc2.h
-amd64-sysv/code.o: amd64-sysv/arch.h
-amd64-sysv/optm.o: $(INCDIR)/bits/scc/scc.h
-amd64-sysv/optm.o: amd64-sysv/../cc2.h
-amd64-sysv/types.o: $(INCDIR)/bits/scc/scc.h
-amd64-sysv/types.o: amd64-sysv/../cc2.h
-arm64-sysv/types.o: $(INCDIR)/bits/scc/scc.h
-arm64-sysv/types.o: arm64-sysv/../cc2.h
-i386-sysv/cgen.o: $(INCDIR)/bits/scc/scc.h
-i386-sysv/cgen.o: i386-sysv/../cc2.h
-i386-sysv/cgen.o: i386-sysv/arch.h
-i386-sysv/code.o: $(INCDIR)/bits/scc/cstd.h
-i386-sysv/code.o: $(INCDIR)/bits/scc/scc.h
-i386-sysv/code.o: i386-sysv/../cc2.h
-i386-sysv/code.o: i386-sysv/arch.h
-i386-sysv/optm.o: $(INCDIR)/bits/scc/scc.h
-i386-sysv/optm.o: i386-sysv/../cc2.h
-i386-sysv/types.o: $(INCDIR)/bits/scc/scc.h
-i386-sysv/types.o: i386-sysv/../cc2.h
-qbe/cgen.o: $(INCDIR)/bits/scc/cstd.h
-qbe/cgen.o: $(INCDIR)/bits/scc/scc.h
-qbe/cgen.o: qbe/../cc2.h
-qbe/cgen.o: qbe/arch.h
-qbe/code.o: $(INCDIR)/bits/scc/cstd.h
-qbe/code.o: $(INCDIR)/bits/scc/scc.h
-qbe/code.o: qbe/../cc2.h
-qbe/code.o: qbe/arch.h
-qbe/optm.o: $(INCDIR)/bits/scc/scc.h
-qbe/optm.o: qbe/../cc2.h
-z80-scc/cgen.o: $(INCDIR)/bits/scc/scc.h
-z80-scc/cgen.o: z80-scc/../cc2.h
-z80-scc/cgen.o: z80-scc/arch.h
-z80-scc/code.o: $(INCDIR)/bits/scc/cstd.h
-z80-scc/code.o: $(INCDIR)/bits/scc/scc.h
-z80-scc/code.o: z80-scc/../cc2.h
-z80-scc/code.o: z80-scc/arch.h
-z80-scc/optm.o: $(INCDIR)/bits/scc/scc.h
-z80-scc/optm.o: z80-scc/../cc2.h
-z80-scc/types.o: $(INCDIR)/bits/scc/scc.h
-z80-scc/types.o: z80-scc/../cc2.h
diff --git a/src/cmd/scc-cc/cc2/i386-sysv/Makefile b/src/cmd/scc-cc/cc2/i386-sysv/Makefile
@@ -0,0 +1,16 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ cgen.o \
+ optm.o \
+ code.o \
+ types.o \
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/i386-sysv/target.mk b/src/cmd/scc-cc/cc2/i386-sysv/target.mk
@@ -1,9 +0,0 @@
-OBJ-i386-sysv = $(OBJS) \
- i386-sysv/cgen.o \
- i386-sysv/optm.o \
- i386-sysv/code.o \
- i386-sysv/types.o
-
-cc2-i386-sysv: $(LIBSCC) $(OBJ-i386-sysv)
- $(CC) $(PROJ_LDFLAGS) $(OBJ-i386-sysv) -lscc $(PROJ_LDLIBS) -o $@
- cp $@ $(LIBEXEC)/scc
diff --git a/src/cmd/scc-cc/cc2/qbe/Makefile b/src/cmd/scc-cc/cc2/qbe/Makefile
@@ -0,0 +1,15 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ cgen.o \
+ optm.o \
+ code.o \
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/qbe_amd64-sysv/Makefile b/src/cmd/scc-cc/cc2/qbe_amd64-sysv/Makefile
@@ -0,0 +1,14 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ ../amd64-sysv/types.o\
+ ../qbe/builtin.o\
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/qbe_amd64-sysv/target.mk b/src/cmd/scc-cc/cc2/qbe_amd64-sysv/target.mk
@@ -1,9 +0,0 @@
-OBJ-qbe_amd64-sysv = $(OBJS) \
- qbe/cgen.o \
- qbe/optm.o \
- qbe/code.o \
- amd64-sysv/types.o
-
-cc2-qbe_amd64-sysv: $(LIBSCC) $(OBJ-qbe_amd64-sysv)
- $(CC) $(PROJ_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc $(PROJ_LDLIBS) -o $@
- cp $@ $(LIBEXEC)/scc
diff --git a/src/cmd/scc-cc/cc2/qbe_arm64-sysv/Makefile b/src/cmd/scc-cc/cc2/qbe_arm64-sysv/Makefile
@@ -0,0 +1,14 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ ../arm64-sysv/types.o\
+ ../qbe/builtin.o\
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/qbe_arm64-sysv/target.mk b/src/cmd/scc-cc/cc2/qbe_arm64-sysv/target.mk
@@ -1,9 +0,0 @@
-OBJ-qbe_arm64-sysv = $(OBJS) \
- qbe/cgen.o \
- qbe/optm.o \
- qbe/code.o \
- arm64-sysv/types.o \
-
-cc2-qbe_arm64-sysv: $(LIBSCC) $(OBJ-qbe_arm64-sysv)
- $(CC) $(PROJ_LDFLAGS) $(OBJ-qbe_arm64-sysv) -lscc $(PROJ_LDLIBS) -o $@
- cp $@ $(LIBEXEC)/scc
diff --git a/src/cmd/scc-cc/cc2/z80-scc/Makefile b/src/cmd/scc-cc/cc2/z80-scc/Makefile
@@ -0,0 +1,16 @@
+.POSIX:
+
+PROJECTDIR = ../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+
+OBJS =\
+ cgen.o \
+ optm.o \
+ code.o \
+ types.o \
+
+all: builtin.o
+
+builtin.o: $(OBJS)
+ $(LD) -r -o $@ $(OBJS)
diff --git a/src/cmd/scc-cc/cc2/z80-scc/target.mk b/src/cmd/scc-cc/cc2/z80-scc/target.mk
@@ -1,9 +0,0 @@
-OBJ-z80-scc = $(OBJS) \
- z80-scc/cgen.o \
- z80-scc/optm.o \
- z80-scc/code.o \
- z80-scc/types.o \
-
-cc2-z80-scc: $(LIBSCC) $(OBJ-z80-scc)
- $(CC) $(PROJ_LDFLAGS) $(OBJ-z80-scc) -lscc $(PROJ_LDLIBS) -o $@
- cp $@ $(LIBEXEC)/scc