shithub: scc

Download patch

ref: 3fc33c857e20a88b54d6c44b38d5eda753a98bfb
parent: 07e88b406de00085d3be17943c5f6799a37c67de
author: Quentin Rameau <quinq@fifth.space>
date: Wed Mar 22 09:13:48 EDT 2017

[driver] Use internal library path

And provide a way to configure them via inc/syslibs.h

--- a/Makefile
+++ b/Makefile
@@ -76,4 +76,4 @@
 	rm -f bin/cc* bin/scc
 
 distclean: clean
-	rm -f inc/sysincludes.h
+	rm -f inc/sysincludes.h inc/syslibs.h
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
@@ -7,13 +7,16 @@
 
 all: scc
 
-$(OBJS): ../../inc/cc.h ../../inc/arg.h
+$(OBJS): ../../inc/cc.h ../../inc/arg.h ../../inc/syslibs.h
 
-../../lib/libcc.a:
-	cd ../../lib && $(MAKE) -e
-
 scc: $(OBJS) ../../lib/libcc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJS) ../../lib/libcc.a -o $@
+
+../../inc/syslibs.h: ../../inc/syslibs.def.h
+	cp -f ../../inc/syslibs.def.h ../../inc/syslibs.h
+
+../../lib/libcc.a:
+	cd ../../lib && $(MAKE) -e
 
 clean:
 	rm -f $(OBJS)
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -16,6 +16,7 @@
 
 #include "../../inc/arg.h"
 #include "../../inc/cc.h"
+#include "../../inc/syslibs.h"
 
 enum {
 	CC1,
@@ -118,6 +119,10 @@
 		addarg(tool, "-o");
 		t->outfile = outfile ? outfile : xstrdup("a.out");
 		addarg(tool, t->outfile);
+		for (n = 0; syslibs[n]; ++n) {
+			addarg(tool, "-L");
+			addarg(tool, syslibs[n]);
+		}
 		break;
 	case AS:
 		addarg(tool, "-o");
--- /dev/null
+++ b/inc/syslibs.def.h
@@ -1,0 +1,7 @@
+char *syslibs[] = {
+	PREFIX "/lib/scc/" ,
+	/* configure below your standard sys include paths */
+	PREFIX "/lib/",
+	PREFIX "/local/lib/",
+	NULL
+};