shithub: scc

Download patch

ref: 643e8a40e46be15008645eecbeac019d7796552b
parent: d69b942c0f484c8677cf8b8b2acfe8b190d6fc5f
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Jun 1 08:58:29 EDT 2022

driver/posix: Add support for LIBPREFIX

LIBPREFIX is intended to let users to change the location
of the libc used without changing the location of the
libexec directory.

--- a/Makefile
+++ b/Makefile
@@ -10,12 +10,11 @@
 PROJECTDIR = .
 include $(PROJECTDIR)/scripts/rules.mk
 
-PREFIX = /usr/local
 ROOT = $(DESTDIR)$(PREFIX)
 NODEP = 1
 
 all:
-	+@PREFIX=$(PREFIX) $(MAKE) `$(SCRIPTDIR)/config -c` toolchain
+	+@$(MAKE) `$(SCRIPTDIR)/config -c` toolchain
 	+@$(MAKE) `$(SCRIPTDIR)/config` `uname -m`
 
 install:
@@ -89,6 +88,8 @@
 
 uninstall-arm64:
 	$(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm64 $(ROOT)
+
+#############################################################
 
 toolchain: src
 libc: src/libc
--- a/scripts/rules.mk
+++ b/scripts/rules.mk
@@ -2,6 +2,8 @@
 all:
 
 # Define default configuration variables
+PREFIX = /usr/local
+LIBPREFIX = $(PREFIX)
 CONF = amd64-linux
 TOOL = unix
 HOST = posix
--- a/src/cmd/cc/posix/Makefile
+++ b/src/cmd/cc/posix/Makefile
@@ -30,6 +30,7 @@
 	 echo '#define ARCH "$(ARCH)"';\
 	 echo '#define SYS  "$(SYS)"';\
 	 echo '#define ABI  "$(ABI)"';\
+	 echo '#define LIBPREFIX "$(LIBPREFIX)"';\
 	 echo '#define FORMAT "$(FORMAT)"') > $$$$.h && mv $$$$.h $@
 
 clean:
--- a/src/cmd/cc/posix/cc.c
+++ b/src/cmd/cc/posix/cc.c
@@ -62,7 +62,8 @@
 
 char *argv0;
 static char *arch, *sys, *abi, *format;
-static char *prefix, *objfile, *outfile;
+static char *objfile, *outfile;
+static char *prefix, *libprefix;
 static char *tmpdir;
 static size_t tmpdirln;
 static struct items objtmp, objout, linkargs;
@@ -517,6 +518,8 @@
 		format = FORMAT;
 	if (!(prefix = getenv("SCCPREFIX")))
 		prefix = PREFIX;
+	if (!(libprefix = getenv("SCCLIBPREFIX")))
+		libprefix = LIBPREFIX;
 
 	ARGBEGIN {
 	case 'D':
--- a/src/cmd/cc/posix/scc.sh
+++ b/src/cmd/cc/posix/scc.sh
@@ -6,6 +6,12 @@
 	export SCCPREFIX
 fi
 
+if test -z $SCCLIBPREFIX
+then
+	SCCLIBPREFIX=`dirname $0`/..
+	export SCCLIBPREFIX
+fi
+
 case $0 in
 *cpp)
 	exec $SCCPREFIX/bin/scc-cc -E $@