shithub: scc

Download patch

ref: e1bc6c3a19ded30fb1affa8dceaeec7d5c0a0951
parent: 0717542bba2021b87f92ab99fbd1851618e17da5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Oct 31 05:01:59 EDT 2021

build/posix: Move scc.sh to cc/posix

The current implementation of scc is a shell script that only
can be executed in POSIX systems, so it makes sense to move it
to that directory. The shell script is also modified to support
external SCCPREFIX.

--- a/src/cmd/Makefile
+++ b/src/cmd/Makefile
@@ -18,7 +18,6 @@
 	$(BINDIR)/scc-objdump\
 	$(BINDIR)/scc-objcopy\
 	$(BINDIR)/scc-addr2line\
-	$(BINDIR)/scc\
 	$(LIBEXEC)/scc/qbe\
 
 all: $(TARGET) $(DIRS)
@@ -33,10 +32,6 @@
 
 $(LIBEXEC)/scc/qbe: qbe/obj/qbe
 	cp qbe/obj/qbe $@
-
-$(BINDIR)/scc: scc.sh
-	cp scc.sh $@
-	chmod +x $@
 
 $(BINDIR)/scc-nm: nm.o $(LIBMACH) $(LIBSCC)
 	$(CC) $(PROJ_LDFLAGS) nm.o -lmach -lscc -o $@
--- a/src/cmd/cc/posix/Makefile
+++ b/src/cmd/cc/posix/Makefile
@@ -12,7 +12,10 @@
 	i386-sysv-linux-elf\
 	amd64-sysv-openbsd-elf\
 
-TARGETS = $(BINDIR)/scc-cc $(BINDIR)/scc-cpp
+TARGETS =\
+	$(BINDIR)/scc-cc\
+	$(BINDIR)/scc-cpp\
+	$(BINDIR)/scc\
 
 all: $(TARGETS)
 
@@ -19,12 +22,13 @@
 $(BINDIR)/scc-cc: $(LIBSCC) cc.o
 	$(CC) $(PROJ_LDFLAGS) cc.o -lscc -o $@
 
-$(BINDIR)/scc-cpp: cpp.sh
-	trap "rm -f $$$$.sh" 0 2 3;\
-	rm -f $@ ;\
-	sed "s%@PREFIX@%$(PREFIX)%" < cpp.sh > $$$$.sh && \
-	chmod +x $$$$.sh && \
-	mv $$$$.sh $@
+$(BINDIR)/scc-cpp: scc.sh
+	cp scc.sh $@
+	chmod +x $@
+
+$(BINDIR)/scc: scc.sh
+	cp scc.sh $@
+	chmod +x $@
 
 config.h:
 	PREFIX=$(PREFIX) ./mkconf $(SYSLST)
--- a/src/cmd/cc/posix/cpp.sh
+++ /dev/null
@@ -1,4 +1,0 @@
-#!/bin/sh
-
-SCCPREFIX=${SCCPREFIX:-@PREFIX@}
-${SCCPREFIX}/bin/cc -E $@
--- /dev/null
+++ b/src/cmd/cc/posix/scc.sh
@@ -1,0 +1,16 @@
+#!/bin/sh
+
+if test -z $SCCPREFIX
+then
+	SCCPREFIX=`dirname $0`/..
+	export SCCPREFIX
+fi
+
+case $0 in
+*cpp)
+	exec $SCCPREFIX/bin/scc-cc -E $@
+	;;
+*scc)
+	exec $SCCPREFIX/bin/scc-cc $@
+	;;
+esac
--- a/src/cmd/scc.sh
+++ /dev/null
@@ -1,8 +1,0 @@
-#!/bin/sh
-
-root=`dirname $0`/..
-SCCPREFIX=$root
-
-export SCCPREFIX
-
-exec $root/bin/scc-cc $@