ref: 87caed3822ddcada29b05eb19b8319c22378a41e
parent: 7f832c62c90bc9660709b4a7171c28a418abfd03
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Aug 19 09:23:38 EDT 2018
Build binaries directly in the target directory Avoid the 2 steps, build and copy, because it doesn't make sense. In case of being needed, developers can use synlinks or shell scripts to access the binaries.
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -10,10 +10,7 @@
all: $(BINDIR)/ar
-$(BINDIR)/ar: ar-$(DRIVER)
- cp ar-$(DRIVER) $@
-
-ar-$(DRIVER): $(OBJ) $(LIBSCC)/libscc.a
+$(BINDIR)/ar: $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
dep:
@@ -20,6 +17,6 @@
$(PROJECTDIR)/mkdep.sh
clean:
- rm -f ar-* *.o $(DRIVER)/*.o $(BINDIR)/ar
+ rm -f *.o $(DRIVER)/*.o $(BINDIR)/ar
include deps.mk
--- a/as/target/amd64.mk
+++ b/as/target/amd64.mk
@@ -1,11 +1,8 @@
-$(LIBEXEC)/as-amd64: as-amd64
- cp as-amd64 $@
-
AMD64_OBJ = $(OBJ) target/x86/amd64tbl.o target/x86/amd64.o target/x86/ins.o
target/x86/amd64tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c amd64
-as-amd64: $(AMD64_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-amd64: $(AMD64_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(AMD64_OBJ) -lscc -o $@
--- a/as/target/i286.mk
+++ b/as/target/i286.mk
@@ -1,11 +1,8 @@
-$(LIBEXEC)/as-i286: as-i286
- cp as-i286 $@
-
I286_OBJ = $(OBJ) target/x86/i286tbl.o target/x86/i286.o target/x86/ins.o
target/x86/i286tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c i286
-as-i286: $(I286_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-i286: $(I286_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(I286_OBJ) -lscc -o $@
--- a/as/target/i386.mk
+++ b/as/target/i386.mk
@@ -1,11 +1,8 @@
-$(LIBEXEC)/as-i386: as-i386
- cp as-i386 $@
-
I386_OBJ = $(OBJ) target/x86/i386tbl.o target/x86/i386.o target/x86/ins.o
target/x86/i386tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c i386
-as-i386: $(I386_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-i386: $(I386_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(I386_OBJ) -lscc -o $@
--- a/as/target/z80.mk
+++ b/as/target/z80.mk
@@ -1,11 +1,8 @@
-$(LIBEXEC)/as-z80: as-z80
- cp as-z80 $@
-
Z80_OBJ = $(OBJ) target/x80/z80tbl.o target/x80/z80.o target/x80/ins.o
target/x80/z80tbl.c: gentbl.awk target/x80/x80.dat target/x80/rules.dat
./gentbl.sh -f x80 -c z80
-as-z80: $(OBJ) $(Z80_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-z80: $(OBJ) $(Z80_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(Z80_OBJ) -lscc -o $@
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -21,7 +21,6 @@
clean:
rm -f *.o
rm -f target/*/*.o
- rm -f cc1-*
rm -f $(TARGETS)
include target/amd64-sysv/arch.mk
--- a/cc1/target/amd64-sysv/arch.mk
+++ b/cc1/target/amd64-sysv/arch.mk
@@ -1,8 +1,5 @@
-$(LIBEXEC)/cc1-amd64-sysv: cc1-amd64-sysv
- cp cc1-amd64-sysv $@
-
OBJ-amd64-sysv= $(OBJ) target/amd64-sysv/arch.o
-cc1-amd64-sysv: $(OBJ-amd64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-amd64-sysv: $(OBJ-amd64-sysv) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc1/target/arm64-sysv/arch.mk
+++ b/cc1/target/arm64-sysv/arch.mk
@@ -1,8 +1,5 @@
-$(LIBEXEC)/cc1-arm64-sysv: cc1-arm64-sysv
- cp cc1-arm64-sysv $@
-
OBJ-arm64-sysv= $(OBJ) target/arm64-sysv/arch.o
-cc1-arm64-sysv: $(OBJ-arm64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-arm64-sysv: $(OBJ-arm64-sysv) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-arm64-sysv) -lscc -o $@
--- a/cc1/target/i386-sysv/arch.mk
+++ b/cc1/target/i386-sysv/arch.mk
@@ -1,8 +1,5 @@
-$(LIBEXEC)/cc1-i386-sysv: cc1-i386-sysv
- cp cc1-i386-sysv $@
-
OBJ-i386-sysv= $(OBJ) target/i386-sysv/arch.o
-cc1-i386-sysv: $(OBJ-i386-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-i386-sysv: $(OBJ-i386-sysv) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- a/cc1/target/z80-scc/arch.mk
+++ b/cc1/target/z80-scc/arch.mk
@@ -1,8 +1,5 @@
-$(LIBEXEC)/cc1-z80-scc: cc1-z80-scc
- cp cc1-z80-scc $@
-
OBJ-z80-scc= $(OBJ) target/z80-scc/arch.o
-cc1-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -21,9 +21,8 @@
awk -f generror.awk cc2.h > $$$$.h && mv $$$$.h $@
clean:
- rm -f *.o
+ rm -f *.o error.h
rm -f target/*/*.o
- rm -f cc2-* error.h
rm -f $(TARGETS)
include target/amd64-sysv/target.mk
--- a/cc2/deps.mk
+++ b/cc2/deps.mk
@@ -1,4 +1,8 @@
parser.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+target/amd64-sysv/code.o: $(INCDIR)/$(STD)/cstd.h
+target/i386-sysv/code.o: $(INCDIR)/$(STD)/cstd.h
+target/qbe/cgen.o: $(INCDIR)/$(STD)/cstd.h
+target/z80-scc/code.o: $(INCDIR)/$(STD)/cstd.h
#deps
code.o: ../inc/scc.h
--- a/cc2/target/amd64-sysv/target.mk
+++ b/cc2/target/amd64-sysv/target.mk
@@ -1,9 +1,4 @@
-$(LIBEXEC)/cc2-amd64-sysv: cc2-amd64-sysv
- cp cc2-amd64-sysv $@
-
-target/amd64-sysv/code.o: $(INCDIR)/$(STD)/cstd.h
-
OBJ-amd64-sysv = $(OBJ) \
target/amd64-sysv/cgen.o \
target/amd64-sysv/optm.o \
@@ -10,5 +5,5 @@
target/amd64-sysv/code.o \
target/amd64-sysv/types.o
-cc2-amd64-sysv: $(OBJ-amd64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-amd64-sysv: $(OBJ-amd64-sysv) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc2/target/i386-sysv/target.mk
+++ b/cc2/target/i386-sysv/target.mk
@@ -1,9 +1,4 @@
-$(LIBEXEC)/cc2-i386-sysv: cc2-i386-sysv
- cp cc2-i386-sysv $@
-
-target/i386-sysv/code.o: $(INCDIR)/$(STD)/cstd.h
-
OBJ-i386-sysv = $(OBJ) \
target/i386-sysv/cgen.o \
target/i386-sysv/optm.o \
@@ -10,5 +5,5 @@
target/i386-sysv/code.o \
target/i386-sysv/types.o
-cc2-i386-sysv: $(OBJ-i386-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-i386-sysv: $(OBJ-i386-sysv) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- a/cc2/target/qbe_amd64-sysv/target.mk
+++ b/cc2/target/qbe_amd64-sysv/target.mk
@@ -1,9 +1,4 @@
-$(LIBEXEC)/cc2-qbe_amd64-sysv: cc2-qbe_amd64-sysv
- cp cc2-qbe_amd64-sysv $@
-
-target/qbe/cgen.o: $(INCDIR)/$(STD)/cstd.h
-
OBJ-qbe_amd64-sysv = $(OBJ) \
target/qbe/cgen.o \
target/qbe/optm.o \
@@ -10,5 +5,5 @@
target/qbe/code.o \
target/amd64-sysv/types.o
-cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc -o $@
--- a/cc2/target/z80-scc/target.mk
+++ b/cc2/target/z80-scc/target.mk
@@ -1,9 +1,4 @@
-$(LIBEXEC)/cc2-z80-scc: cc2-z80-scc
- cp cc2-z80-scc $@
-
-target/z80-scc/code.o: $(INCDIR)/$(STD)/cstd.h
-
OBJ-z80-scc = $(OBJ) \
target/z80-scc/cgen.o \
target/z80-scc/optm.o \
@@ -10,5 +5,5 @@
target/z80-scc/code.o \
target/z80-scc/types.o
-cc2-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -11,10 +11,7 @@
all: $(BINDIR)/ld
-$(BINDIR)/ld: ld
- cp ld $@
-
-ld: $(OBJ) $(LIB)
+$(BINDIR)/ld: $(OBJ) $(LIB)
$(CC) $(SCC_LDFLAGS) $(OBJ) -lcoff32 -lscc -o $@
dep:
@@ -21,6 +18,6 @@
$(PROJECTDIR)/mkdep.sh
clean:
- rm -f $(BINDIR)/ld ld *.o
+ rm -f $(BINDIR)/ld *.o
include deps.mk
--- a/nm/Makefile
+++ b/nm/Makefile
@@ -8,10 +8,7 @@
all: $(BINDIR)/nm
-$(BINDIR)/nm: nm
- cp nm $(PROJECTDIR)/rootdir/bin/nm
-
-nm: $(OBJ) $(LIBSCC)/libscc.a
+$(BINDIR)/nm: $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
dep:
@@ -18,7 +15,7 @@
$(PROJECTDIR)/mkdep.sh
clean:
- rm -f $(BINDIR)/nm nm *.o
+ rm -f $(BINDIR)/nm *.o
distclean: clean
--- a/objdump/Makefile
+++ b/objdump/Makefile
@@ -8,10 +8,7 @@
all: $(BINDIR)/objdump
-$(BINDIR)/objdump: objdump
- cp objdump $@
-
-objdump: $(OBJ) $(LIBSCC)/libscc.a
+$(BINDIR)/objdump: $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
dep:
@@ -18,6 +15,6 @@
$(PROJECTDIR)/mkdep.sh
clean:
- rm -f $(BINDIR)/objdump objdump *.o
+ rm -f $(BINDIR)/objdump *.o
include deps.mk