shithub: scc

Download patch

ref: c35d0fcec7b67eca019e90ff3fae9b0eca1c193c
parent: ce27aafc50fc22d1040d550a4105b53cf35d1bf2
author: Quentin Rameau <[email protected]>
date: Wed Mar 22 05:59:02 EDT 2017

[crt] Add crt to (un)install target

--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
 
 include config.mk
 
-DIRS  = lib cc1 cc2 driver/$(DRIVER) libc/src
+DIRS  = lib cc1 cc2 crt driver/$(DRIVER) libc/src
 
 all: scc-driver
 	for i in $(ARCHS); \
@@ -17,13 +17,19 @@
 	ln -f driver/$(DRIVER)/scc bin/scc
 
 $(ARCHS):
-	pwd=$$PWD ;\
+	pwd=$$PWD; \
 	for i in cc1 cc2; \
 	do \
 		cd $$i; \
 		ARCH=$@ $(MAKE) -e $$i-$@ || exit; \
-		cd $$pwd ;\
+		cd $$pwd; \
 	done
+	cd crt; \
+	for i in $(SYSS); \
+	do \
+		ARCH=$@ SYS=$$i $(MAKE) -e || exit; \
+	done; \
+	cd $$pwd;
 	ln -f cc1/cc1-$@ bin/
 	ln -f cc2/cc2-$@ bin/
 
@@ -39,9 +45,11 @@
 	mkdir -p $(DESTDIR)/$(PREFIX)/libexec/scc/
 	mkdir -p $(DESTDIR)/$(PREFIX)/bin/
 	mkdir -p $(DESTDIR)/$(PREFIX)/include/scc/
+	mkdir -p $(DESTDIR)/$(PREFIX)/lib/scc/
 	cp -f bin/cc?-* $(DESTDIR)/$(PREFIX)/libexec/scc/
 	cp -f bin/cpp.sh $(DESTDIR)/$(PREFIX)/bin/scpp
 	cp -f bin/scc $(DESTDIR)/$(PREFIX)/bin/
+	cp -f crt/crt-*.o $(DESTDIR)/$(PREFIX)/lib/scc/
 	cp -fr libc/include/* $(DESTDIR)/$(PREFIX)/include/scc/
 	find $(DESTDIR)/$(PREFIX)/include/scc/ -type f | xargs chmod 644
 	cd $(DESTDIR)/$(PREFIX)/libexec/scc/ && chmod 755 cc* && strip cc*
@@ -50,6 +58,7 @@
 uninstall:
 	rm -rf $(DESTDIR)/$(PREFIX)/include/scc/
 	rm -rf $(DESTDIR)/$(PREFIX)/libexec/scc/
+	rm -rf $(DESTDIR)/$(PREFIX)/lib/scc/
 	rm -f $(DESTDIR)/$(PREFIX)/bin/scc
 	rm -f $(DESTDIR)/$(PREFIX)/bin/scpp
 
--- a/config.mk
+++ b/config.mk
@@ -3,6 +3,7 @@
 
 ## Customize below to fit your system
 ARCHS = z80 i386-sysv amd64-sysv qbe
+SYSS = linux openbsd
 # default architecure used in nested makefiles
 ARCH = qbe
 SYS = linux
--- /dev/null
+++ b/crt/Makefile
@@ -1,0 +1,11 @@
+.POSIX:
+
+include ../config.mk
+
+all: crt-$(ARCH)-$(SYS).o
+
+crt-$(ARCH)-$(SYS).o: $(ARCH)-$(SYS)/crt.o
+	ln -f $(ARCH)-$(SYS)/crt.o $@
+
+clean:
+	rm -f */crt.o crt-*.o