shithub: scc

Download patch

ref: ff12c749839ae641f04410734d31b7aaa7589141
parent: 87caed3822ddcada29b05eb19b8319c22378a41e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Aug 19 13:47:16 EDT 2018

Build libraries into lib/

In this way we don't have to use different -L based in the
library that we have to use in the binary.

--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@
 	rm -f config
 
 config:
-	./configure.sh
+	./config.sh
 	touch $@
 
 install: all
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -10,7 +10,7 @@
 
 all: $(BINDIR)/ar
 
-$(BINDIR)/ar: $(OBJ) $(LIBSCC)/libscc.a
+$(BINDIR)/ar: $(OBJ) $(LIBDIR)/libscc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
 
 dep:
--- a/as/Makefile
+++ b/as/Makefile
@@ -11,6 +11,8 @@
 
 all: $(TARGETS)
 
+$(TARGETS): $(LIBDIR)/libscc.a
+
 dep:
 	$(PROJECTDIR)/mkdep.sh
 
--- a/as/target/amd64.mk
+++ b/as/target/amd64.mk
@@ -4,5 +4,5 @@
 target/x86/amd64tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
 	./gentbl.sh -f x86 -c amd64
 
-$(LIBEXEC)/as-amd64: $(AMD64_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-amd64: $(AMD64_OBJ)
 	$(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
 
-$(LIBEXEC)/as-i286: $(I286_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-i286: $(I286_OBJ)
 	$(CC) $(SCC_LDFLAGS) $(I286_OBJ) -lscc -o $@
--- a/as/target/i386.mk
+++ b/as/target/i386.mk
@@ -4,5 +4,5 @@
 target/x86/i386tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
 	./gentbl.sh -f x86 -c i386
 
-$(LIBEXEC)/as-i386: $(I386_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-i386: $(I386_OBJ)
 	$(CC) $(SCC_LDFLAGS) $(I386_OBJ) -lscc -o $@
--- a/as/target/z80.mk
+++ b/as/target/z80.mk
@@ -4,5 +4,5 @@
 target/x80/z80tbl.c: gentbl.awk target/x80/x80.dat target/x80/rules.dat
 	./gentbl.sh -f x80 -c z80
 
-$(LIBEXEC)/as-z80: $(OBJ) $(Z80_OBJ) $(LIBSCC)/libscc.a
+$(LIBEXEC)/as-z80: $(OBJ) $(Z80_OBJ)
 	$(CC) $(SCC_LDFLAGS) $(Z80_OBJ) -lscc -o $@
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -15,6 +15,8 @@
 
 all: $(TARGETS)
 
+$(TARGETS): $(LIBDIR)/libscc.a
+
 dep:
 	$(PROJECTDIR)/mkdep.sh
 
--- a/cc1/target/amd64-sysv/arch.mk
+++ b/cc1/target/amd64-sysv/arch.mk
@@ -1,5 +1,5 @@
 
 OBJ-amd64-sysv= $(OBJ)  target/amd64-sysv/arch.o
 
-$(LIBEXEC)/cc1-amd64-sysv: $(OBJ-amd64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-amd64-sysv: $(OBJ-amd64-sysv)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc1/target/arm64-sysv/arch.mk
+++ b/cc1/target/arm64-sysv/arch.mk
@@ -1,5 +1,5 @@
 
 OBJ-arm64-sysv= $(OBJ)  target/arm64-sysv/arch.o
 
-$(LIBEXEC)/cc1-arm64-sysv: $(OBJ-arm64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-arm64-sysv: $(OBJ-arm64-sysv)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-arm64-sysv) -lscc -o $@
--- a/cc1/target/i386-sysv/arch.mk
+++ b/cc1/target/i386-sysv/arch.mk
@@ -1,5 +1,5 @@
 
 OBJ-i386-sysv= $(OBJ)  target/i386-sysv/arch.o
 
-$(LIBEXEC)/cc1-i386-sysv: $(OBJ-i386-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-i386-sysv: $(OBJ-i386-sysv)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- a/cc1/target/z80-scc/arch.mk
+++ b/cc1/target/z80-scc/arch.mk
@@ -1,5 +1,5 @@
 
 OBJ-z80-scc= $(OBJ) target/z80-scc/arch.o
 
-$(LIBEXEC)/cc1-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc1-z80-scc: $(OBJ-z80-scc)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -13,6 +13,8 @@
 
 all: $(TARGETS)
 
+$(TARGETS): $(LIBDIR)/libscc.a
+
 dep:
 	$(PROJECTDIR)/mkdep.sh
 
--- a/cc2/target/amd64-sysv/target.mk
+++ b/cc2/target/amd64-sysv/target.mk
@@ -5,5 +5,5 @@
         target/amd64-sysv/code.o \
         target/amd64-sysv/types.o
 
-$(LIBEXEC)/cc2-amd64-sysv: $(OBJ-amd64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-amd64-sysv: $(OBJ-amd64-sysv)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc2/target/i386-sysv/target.mk
+++ b/cc2/target/i386-sysv/target.mk
@@ -5,5 +5,5 @@
         target/i386-sysv/code.o \
         target/i386-sysv/types.o
 
-$(LIBEXEC)/cc2-i386-sysv: $(OBJ-i386-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-i386-sysv: $(OBJ-i386-sysv)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- a/cc2/target/qbe_amd64-sysv/target.mk
+++ b/cc2/target/qbe_amd64-sysv/target.mk
@@ -5,5 +5,5 @@
         target/qbe/code.o \
         target/amd64-sysv/types.o
 
-$(LIBEXEC)/cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc -o $@
--- a/cc2/target/z80-scc/target.mk
+++ b/cc2/target/z80-scc/target.mk
@@ -5,5 +5,5 @@
         target/z80-scc/code.o \
         target/z80-scc/types.o
 
-$(LIBEXEC)/cc2-z80-scc: $(OBJ-z80-scc) $(LIBSCC)/libscc.a
+$(LIBEXEC)/cc2-z80-scc: $(OBJ-z80-scc)
 	$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- /dev/null
+++ b/config.sh
@@ -1,0 +1,16 @@
+#!/bin/sh
+
+case `uname` in
+*BSD)
+	sys=BSD
+	;;
+*Plan9)
+	sys=Plan9
+	;;
+*)
+	exit
+	;;
+esac
+
+
+(echo '/^# '$sys'/+;/^###$/- s/^#//'; echo w) | ed -s config.mk
--- a/configure.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-case `uname` in
-*BSD)
-	sys=BSD
-	;;
-*Plan9)
-	sys=Plan9
-	;;
-*)
-	exit
-	;;
-esac
-
-
-(echo '/^# '$sys'/+;/^###$/- s/^#//'; echo w) | ed -s config.mk
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
@@ -23,7 +23,7 @@
 $(BINDIR)/scpp: cpp
 	cp cpp $@
 
-scc: scc.o $(LIBSCC)/libscc.a
+scc: scc.o $(LIBDIR)/libscc.a
 	$(CC) $(SCC_LDFLAGS) scc.o -lscc -o $@
 
 cpp: cpp.sh config.h
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -6,12 +6,12 @@
 include $(LIBCOFF32)/libdep.mk
 
 OBJ = main.o coff32.o obj.o
-LIB = $(LIBSCC)/libscc.a $(LIBCOFF32)/libcoff32.a
-MORELFLAGS = -L$(LIBCOFF32)
+LIB = $(LIBDIR)/libscc.a $(LIBDIR)/libcoff32.a
+TARGET = $(BINDIR)/ld
 
-all: $(BINDIR)/ld
+all: $(TARGET)
 
-$(BINDIR)/ld: $(OBJ) $(LIB)
+$(TARGET): $(OBJ) $(LIB)
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lcoff32 -lscc -o $@
 
 dep:
--- a/lib/coff32/Makefile
+++ b/lib/coff32/Makefile
@@ -5,9 +5,11 @@
 include $(PROJECTDIR)/rules.mk
 include objlst.mk
 
-all: libcoff32.a
+TARGET = $(LIBDIR)/libcoff32.a
 
-libcoff32.a: $(LIBCOFF32-OBJ)
+all: $(TARGET)
+
+$(TARGET): $(LIBCOFF32-OBJ)
 	$(AR) $(ARFLAGS) $@ $?
 	ranlib $@
 
@@ -15,6 +17,6 @@
 	$(PROJECTDIR)/mkdep.sh
 
 clean:
-	rm -f *.o *.a
+	rm -f *.o $(TARGET)
 
 include deps.mk
--- a/lib/coff32/libdep.mk
+++ b/lib/coff32/libdep.mk
@@ -1,4 +1,4 @@
 include $(LIBCOFF32)/objlst.mk
 
-$(LIBCOFF32)/libcoff32.a: $(LIBCOFF32-OBJ)
+$(LIBDIR)/libcoff32.a: $(LIBCOFF32-OBJ)
 	+cd $(LIBCOFF32) && $(MAKE)
--- a/lib/scc/Makefile
+++ b/lib/scc/Makefile
@@ -4,9 +4,11 @@
 include $(PROJECTDIR)/rules.mk
 include objlst.mk
 
-all: libscc.a
+TARGET = $(LIBDIR)/libscc.a
 
-libscc.a: $(LIBSCC-OBJ)
+all: $(TARGET)
+
+$(TARGET): $(LIBSCC-OBJ)
 	$(AR) $(ARFLAGS) $@ $?
 	ranlib $@
 
@@ -14,6 +16,6 @@
 	$(PROJECTDIR)/mkdep.sh
 
 clean:
-	rm -f *.o *.a
+	rm -f *.o $(LIBDIR)/libscc.a
 
 include deps.mk
--- a/lib/scc/libdep.mk
+++ b/lib/scc/libdep.mk
@@ -1,4 +1,4 @@
 include $(LIBSCC)/objlst.mk
 
-$(LIBSCC)/libscc.a: $(LIBSCC-OBJ)
+$(LIBDIR)/libscc.a: $(LIBSCC-OBJ)
 	+@cd $(LIBSCC) && $(MAKE)
--- a/nm/Makefile
+++ b/nm/Makefile
@@ -8,7 +8,7 @@
 
 all: $(BINDIR)/nm
 
-$(BINDIR)/nm: $(OBJ) $(LIBSCC)/libscc.a
+$(BINDIR)/nm: $(OBJ) $(LIBDIR)/libscc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
 
 dep:
--- a/objdump/Makefile
+++ b/objdump/Makefile
@@ -8,7 +8,7 @@
 
 all: $(BINDIR)/objdump
 
-$(BINDIR)/objdump: $(OBJ) $(LIBSCC)/libscc.a
+$(BINDIR)/objdump: $(OBJ) $(LIBDIR)/libscc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
 
 dep:
--- a/rules.mk
+++ b/rules.mk
@@ -2,6 +2,7 @@
 
 BINDIR     = $(PROJECTDIR)/rootdir/bin
 INCDIR     = $(PROJECTDIR)/inc
+LIBDIR     = $(PROJECTDIR)/lib
 LIBEXEC    = $(PROJECTDIR)/rootdir/libexec/scc
 LIBSCC     = $(PROJECTDIR)/lib/scc
 LIBCOFF32  = $(PROJECTDIR)/lib/coff32
@@ -8,7 +9,7 @@
 
 SCC_CFLAGS = $(MORECFLAGS) $(SYSCFLAGS) $(STDCFLAGS) -g $(CFLAGS)
 
-SCC_LDFLAGS = $(MORELFLAGS) -L$(LIBSCC) -g $(LDFLAGS)
+SCC_LDFLAGS = $(MORELFLAGS) -L$(LIBDIR) -g $(LDFLAGS)
 
 # helper macro to run over all the directories
 FORALL = +@set -e ;\