ref: 965aa5892485f352eb054408f435f44c24aaf456
parent: 446dc0208959152bad0bb3ed1cb5f037d247d805
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Aug 16 04:13:51 EDT 2018
Use LIBSCC instead of LIBDIR LIBDIR forces to have only one library in the project, but having LIBSCC makes easier to work with diffrent libraries. This patch is also used to modify some small bits that simplify the makefiles.
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o $(DRIVER)/driver.o
MOREFLAGS = -I$(DRIVER)
@@ -10,17 +10,12 @@
all: ar-$(DRIVER)
cp ar-$(DRIVER) $(PROJECTDIR)/rootdir/bin/ar
-ar-$(DRIVER): $(OBJ) $(LIBDIR)/libscc.a
+ar-$(DRIVER): $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/ar.h
-
-$(DRIVER)/driver.o: $(DRIVER)/driver.h
-
-main.o: $(DRIVER)/driver.h
-
dep:
+ $(PROJECTDIR)/mkdep.sh
clean:
rm -f ar-* *.o $(DRIVER)/*.o
-distclean: clean
+include deps.mk
--- /dev/null
+++ b/ar/deps.mk
@@ -1,0 +1,7 @@
+main.o: $(DRIVER)/driver.h
+
+#deps
+main.o: ./../inc/ar.h
+main.o: ./../inc/arg.h
+main.o: ./../inc/scc.h
+posix/driver.o: ./posix/driver.h
--- a/as/Makefile
+++ b/as/Makefile
@@ -2,10 +2,10 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o symbol.o ins.o parser.o expr.o myro.o
-MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(AS_CFLAGS)
+MOREFLAGS = -I$(INCDIR)/$(STD) $(AS_CFLAGS)
all: as-amd64 as-i386 as-i286 as-z80
cp as-* $(PROJECTDIR)/rootdir/bin
@@ -13,7 +13,6 @@
dep:
$(PROJECTDIR)/mkdep.sh
-distclean: clean
clean:
rm -f *.o target/*/*.o
rm -f target/*/*tbl.c
--- a/as/target/amd64.mk
+++ b/as/target/amd64.mk
@@ -3,5 +3,5 @@
target/x86/amd64tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c amd64
-as-amd64: $(AMD64_OBJ) $(LIBDIR)/libscc.a
+as-amd64: $(AMD64_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(AMD64_OBJ) -lscc -o $@
--- a/as/target/i286.mk
+++ b/as/target/i286.mk
@@ -4,5 +4,5 @@
target/x86/i286tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c i286
-as-i286: $(I286_OBJ) $(LIBDIR)/libscc.a
+as-i286: $(I286_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(I286_OBJ) -lscc -o $@
--- a/as/target/i386.mk
+++ b/as/target/i386.mk
@@ -3,5 +3,5 @@
target/x86/i386tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c i386
-as-i386: $(I386_OBJ) $(LIBDIR)/libscc.a
+as-i386: $(I386_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(I386_OBJ) -lscc -o $@
--- a/as/target/z80.mk
+++ b/as/target/z80.mk
@@ -3,5 +3,5 @@
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) $(LIBDIR)/libscc.a
+as-z80: $(OBJ) $(Z80_OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(Z80_OBJ) -lscc -o $@
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -3,9 +3,9 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
-MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC1_CFLAGS)
+MOREFLAGS = -I$(INCDIR)/$(STD) $(CC1_CFLAGS)
OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \
code.o stmt.o cpp.o fold.o init.o builtin.o
@@ -20,8 +20,6 @@
rm -f *.o
rm -f target/*/*.o
rm -f cc1-*
-
-distclean: clean
include target/amd64-sysv/arch.mk
include target/arm64-sysv/arch.mk
--- a/cc1/target/amd64-sysv/arch.mk
+++ b/cc1/target/amd64-sysv/arch.mk
@@ -2,5 +2,5 @@
OBJ-amd64-sysv= $(OBJ) target/amd64-sysv/arch.o
-cc1-amd64-sysv: $(OBJ-amd64-sysv) $(LIBDIR)/libscc.a
+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
@@ -2,5 +2,5 @@
OBJ-arm64-sysv= $(OBJ) target/arm64-sysv/arch.o
-cc1-arm64-sysv: $(OBJ-arm64-sysv) $(LIBDIR)/libscc.a
+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
@@ -3,5 +3,5 @@
OBJ-i386-sysv= $(OBJ) target/i386-sysv/arch.o
-cc1-i386-sysv: $(OBJ-i386-sysv) $(LIBDIR)/libscc.a
+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
@@ -3,5 +3,5 @@
OBJ-z80-scc= $(OBJ) target/z80-scc/arch.o
-cc1-z80-scc: $(OBJ-z80-scc) $(LIBDIR)/libscc.a
+cc1-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC2_CFLAGS)
@@ -24,8 +24,6 @@
rm -f *.o
rm -f target/*/*.o
rm -f cc2-* error.h
-
-distclean: clean
include target/amd64-sysv/target.mk
include target/i386-sysv/target.mk
--- a/cc2/target/amd64-sysv/target.mk
+++ b/cc2/target/amd64-sysv/target.mk
@@ -1,6 +1,6 @@
all: cc2-amd64-sysv
-target/amd64-sysv/code.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+target/amd64-sysv/code.o: $(INCDIR)/$(STD)/cstd.h
OBJ-amd64-sysv = $(OBJ) \
target/amd64-sysv/cgen.o \
@@ -8,5 +8,5 @@
target/amd64-sysv/code.o \
target/amd64-sysv/types.o
-cc2-amd64-sysv: $(OBJ-amd64-sysv) $(LIBDIR)/libscc.a
+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,6 +1,6 @@
all: cc2-i386-sysv
-target/i386-sysv/code.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+target/i386-sysv/code.o: $(INCDIR)/$(STD)/cstd.h
OBJ-i386-sysv = $(OBJ) \
target/i386-sysv/cgen.o \
@@ -8,5 +8,5 @@
target/i386-sysv/code.o \
target/i386-sysv/types.o
-cc2-i386-sysv: $(OBJ-i386-sysv) $(LIBDIR)/libscc.a
+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,6 +1,6 @@
all: cc2-qbe_amd64-sysv
-target/qbe/cgen.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+target/qbe/cgen.o: $(INCDIR)/$(STD)/cstd.h
OBJ-qbe_amd64-sysv = $(OBJ) \
target/qbe/cgen.o \
@@ -8,5 +8,5 @@
target/qbe/code.o \
target/amd64-sysv/types.o
-cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv) $(LIBDIR)/libscc.a
+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,6 +1,6 @@
all: cc2-z80-scc
-target/z80-scc/code.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+target/z80-scc/code.o: $(INCDIR)/$(STD)/cstd.h
OBJ-z80-scc = $(OBJ) \
target/z80-scc/cgen.o \
@@ -8,5 +8,5 @@
target/z80-scc/code.o \
target/z80-scc/types.o
-cc2-z80-scc: $(OBJ-z80-scc) $(LIBDIR)/libscc.a
+cc2-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
@@ -39,6 +39,6 @@
rm -f scc
rm -f scpp
-distclean: clean
+distclean:
rm -f config.h
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o coff32.o obj.o
@@ -9,7 +9,7 @@
all: ld
cp ld $(PROJECTDIR)/rootdir/bin
-ld: $(OBJ) $(LIBDIR)/libscc.a
+ld: $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
dep:
@@ -17,7 +17,5 @@
clean:
rm -f ld *.o
-
-distclean: clean
include deps.mk
--- a/ld/coff32.c
+++ b/ld/coff32.c
@@ -491,7 +491,7 @@
/* TODO: run over all the files */
- if (fflush(fp) != EOF) {
+ if (fflush(fp) == EOF) {
perror("ld: error writing output file");
exit(EXIT_FAILURE);
}
--- a/lib/scc/Makefile
+++ b/lib/scc/Makefile
@@ -1,17 +1,17 @@
-.POSIX:
+
PROJECTDIR = ../..
-LIBDIR = .
+LIBSCC = .
include $(PROJECTDIR)/rules.mk
include objlst.mk
all: libscc.a
-$(LIB-OBJ): $(PROJECTDIR)/inc/scc.h
-$(LIBDIR)/wmyro.o: $(PROJECTDIR)/inc/myro.h
-$(LIBDIR)/rmyro.o: $(PROJECTDIR)/inc/myro.h
+$(LIBSCC-OBJ): $(INCDIR)/scc.h
+$(LIBSCC)/wmyro.o: $(INCDIR)/myro.h
+$(LIBSCC)/rmyro.o: $(INCDIR)/myro.h
-libscc.a: $(LIB-OBJ)
+libscc.a: $(LIBSCC-OBJ)
$(AR) $(ARFLAGS) $@ $?
ranlib $@
@@ -19,5 +19,3 @@
clean:
rm -f *.o *.a
-
-distclean: clean
--- a/lib/scc/libdep.mk
+++ b/lib/scc/libdep.mk
@@ -1,4 +1,4 @@
-include $(LIBDIR)/objlst.mk
+include $(LIBSCC)/objlst.mk
-$(LIBDIR)/libscc.a: $(LIB-OBJ)
- +cd $(LIBDIR) && $(MAKE)
+$(LIBSCC)/libscc.a: $(LIBSCC-OBJ)
+ +cd $(LIBSCC) && $(MAKE)
--- a/lib/scc/objlst.mk
+++ b/lib/scc/objlst.mk
@@ -1,16 +1,16 @@
-LIB-OBJ = $(LIBDIR)/debug.o \
- $(LIBDIR)/die.o \
- $(LIBDIR)/newitem.o \
- $(LIBDIR)/xcalloc.o \
- $(LIBDIR)/xmalloc.o \
- $(LIBDIR)/xrealloc.o \
- $(LIBDIR)/xstrdup.o \
- $(LIBDIR)/alloc.o \
- $(LIBDIR)/casecmp.o \
- $(LIBDIR)/lunpack.o \
- $(LIBDIR)/lpack.o \
- $(LIBDIR)/bunpack.o \
- $(LIBDIR)/bpack.o \
- $(LIBDIR)/wmyro.o \
- $(LIBDIR)/rmyro.o \
+LIBSCC-OBJ = $(LIBSCC)/debug.o \
+ $(LIBSCC)/die.o \
+ $(LIBSCC)/newitem.o \
+ $(LIBSCC)/xcalloc.o \
+ $(LIBSCC)/xmalloc.o \
+ $(LIBSCC)/xrealloc.o \
+ $(LIBSCC)/xstrdup.o \
+ $(LIBSCC)/alloc.o \
+ $(LIBSCC)/casecmp.o \
+ $(LIBSCC)/lunpack.o \
+ $(LIBSCC)/lpack.o \
+ $(LIBSCC)/bunpack.o \
+ $(LIBSCC)/bpack.o \
+ $(LIBSCC)/wmyro.o \
+ $(LIBSCC)/rmyro.o \
--- a/nm/Makefile
+++ b/nm/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o coff32.o formats.o
@@ -9,7 +9,7 @@
all: nm
cp nm $(PROJECTDIR)/rootdir/bin/nm
-nm: $(OBJ) $(LIBDIR)/libscc.a
+nm: $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
dep:
--- a/objdump/Makefile
+++ b/objdump/Makefile
@@ -2,7 +2,7 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o
@@ -9,13 +9,13 @@
all: objdump
cp objdump $(PROJECTDIR)/rootdir/bin
-objdump: $(OBJ) $(LIBDIR)/libscc.a
+objdump: $(OBJ) $(LIBSCC)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/myro.h $(PROJECTDIR)/inc/arg.h
-
dep:
+ $(PROJECTDIR)/mkdep.sh
+
clean:
rm -f objdump *.o
-distclean: clean
+include deps.mk
--- /dev/null
+++ b/objdump/deps.mk
@@ -1,0 +1,4 @@
+#deps
+main.o: ./../inc/arg.h
+main.o: ./../inc/myro.h
+main.o: ./../inc/scc.h
--- a/rules.mk
+++ b/rules.mk
@@ -1,7 +1,7 @@
include $(PROJECTDIR)/config.mk
INCDIR = $(PROJECTDIR)/inc/
-LIBDIR = $(PROJECTDIR)/lib/scc
+LIBSCC = $(PROJECTDIR)/lib/scc
SCC_CFLAGS = $(MOREFLAGS) \
$(SYSCFLAGS) \
@@ -8,7 +8,7 @@
-g \
$(CFLAGS)
-SCC_LDFLAGS = -L$(LIBDIR) -g $(LDFLAGS)
+SCC_LDFLAGS = -L$(LIBSCC) -g $(LDFLAGS)
# helper macro to run over all the directories
FORALL = +@set -e ;\
@@ -37,3 +37,7 @@
$(PROJECTDIR)/rootdir/libexec/scc:
mkdir -p $(PROJECTDIR)/rootdir/libexec/scc
+
+distclean: clean
+
+dep:
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -7,6 +7,3 @@
all clean:
$(FORALL)
-
-distclean: clean
-dep: