commit 18515e04304b802ce0ee6465a8baed77be2188ec
parent 60bf8059f0407bcb238e494abacea39316b08820
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 5 Jan 2022 14:23:33 +0100
scc: Use CONF as default configuration
The driver was using the first element of SYSLST as default configuration
which is not very intuitive if you want to use scc as a system compiler.
This change makes CONF the default configuration and it adds auto detection
in the all target. In case of needing a different default it can be obtained
compiling scc with:
make CONF=xxxxx toolchain
Diffstat:
12 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/Makefile b/Makefile
@@ -15,7 +15,7 @@ ROOT = $(DESTDIR)$(PREFIX)
NODEP = 1
all:
- +@PREFIX=$(PREFIX) $(MAKE) `$(SCRIPTDIR)/config` toolchain
+ +@PREFIX=$(PREFIX) $(MAKE) `$(SCRIPTDIR)/config -c` toolchain
+@$(MAKE) `$(SCRIPTDIR)/config` `uname -m`
install:
@@ -90,11 +90,16 @@ install-arm64: arm64
uninstall-arm64:
$(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm64 $(ROOT)
-toolchain: dirs src
-libc: dirs src/libc
-libcrt: dirs src/libcrt
-src: include/scc/scc
+toolchain: src
+libc: src/libc
+libcrt: src/libcrt
+
tests: all
+src: include/scc/scc
+
+src: dirs
+src/libc: dirs
+src/libcrt: dirs
dirs: $(SCRIPTDIR)/libc-dirs
xargs mkdir -p < $(SCRIPTDIR)/libc-dirs
diff --git a/scripts/build/conf/amd64-darwin.mk b/scripts/build/conf/amd64-darwin.mk
@@ -1,4 +1,5 @@
ARCH = amd64
SYS = darwin
ABI = amd64-darwin
+FORMAT = elf
O = 6d
diff --git a/scripts/build/conf/amd64-dragonfly.mk b/scripts/build/conf/amd64-dragonfly.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/amd64-posix.mk
SYS = dragonfly
+FORMAT = elf
diff --git a/scripts/build/conf/amd64-linux.mk b/scripts/build/conf/amd64-linux.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/amd64-posix.mk
SYS = linux
+FORMAT = elf
diff --git a/scripts/build/conf/amd64-netbsd.mk b/scripts/build/conf/amd64-netbsd.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/amd64-posix.mk
SYS = netbsd
+FORMAT = elf
diff --git a/scripts/build/conf/amd64-openbsd.mk b/scripts/build/conf/amd64-openbsd.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/amd64-posix.mk
SYS = openbsd
+FORMAT = elf
diff --git a/scripts/build/conf/arm32-linux.mk b/scripts/build/conf/arm32-linux.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/arm32-posix.mk
SYS = linux
+FORMAT = elf
diff --git a/scripts/build/conf/arm64-linux.mk b/scripts/build/conf/arm64-linux.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/arm64-posix.mk
SYS = linux
+FORMAT = elf
diff --git a/scripts/build/conf/ppc32-linux.mk b/scripts/build/conf/ppc32-linux.mk
@@ -1,3 +1,4 @@
include $(BUILDDIR)/conf/ppc32-posix.mk
SYS = linux
+FORMAT = elf
diff --git a/scripts/config b/scripts/config
@@ -18,3 +18,27 @@ Plan9)
echo HOST=plan9
;;
esac
+
+
+for i
+do
+ case $1 in
+ -c)
+
+ mach=`uname -m`
+
+ case $mach in
+ amd64|x86_64)
+ mach=amd64
+ ;;
+ esac
+
+ sys=`uname -s | tr 'A-Z' 'a-z'`
+ echo CONF=$mach-$sys
+ ;;
+ *)
+ echo usage: config [-c] >&2
+ exit 1
+ ;;
+ esac
+done
diff --git a/src/cmd/cc/posix/Makefile b/src/cmd/cc/posix/Makefile
@@ -3,8 +3,10 @@
PROJECTDIR = ../../../..
include $(PROJECTDIR)/scripts/rules.mk
-# SYSLST is a list of backend-arch-abi-sys. First
-# element of the list becomes the default target
+# SYSLST is a list of arch-abi-sys-format.
+# By default the driver uses the configuration
+# inhered from the environment, that in a normal
+# build is derived from the host configuration.
SYSLST =\
amd64-sysv-linux-elf\
@@ -31,7 +33,14 @@ $(BINDIR)/scc: scc.sh
chmod +x $@
config.h:
- PREFIX=$(PREFIX) ./mkconf $(SYSLST)
+ set -e;\
+ rm -f $@;\
+ trap "rm -f $$$$.h" EXIT QUIT HUP TERM;\
+ (echo '#define PREFIX "$(PREFIX)"';\
+ echo '#define ARCH "$(ARCH)"';\
+ echo '#define SYS "$(SYS)"';\
+ echo '#define ABI "$(ABI)"';\
+ echo '#define FORMAT "$(FORMAT)"') > $$$$.h && mv $$$$.h $@
clean:
rm -f scc scpp *.o
diff --git a/src/cmd/cc/posix/mkconf b/src/cmd/cc/posix/mkconf
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f config.h
-trap "rm -f $$.h" 0 2 3
-
-echo $@ |
-(IFS='- ' read arch abi sys format r
-echo \#define PREFIX \"${PREFIX-$HOME}\"
-echo \#define ARCH \"$arch\"
-echo \#define SYS \"$sys\"
-echo \#define ABI \"$abi\"
-echo \#define FORMAT \"$format\") > $$.h && mv $$.h config.h