commit 49fa8cec5a252cbf835af351f86175ad0a7d2e0a
parent db0fb021818f369c16fe70bc252fad5461247ef6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 23 Oct 2024 13:53:54 +0200
build: Add helper config target for musl
Setting correctly the musl libc configuration is not easy, and
having a target that simplifies the process helps to casual users.
This commits also adds some examples in the documentation about
how to use this new target.
Diffstat:
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -13,6 +13,13 @@ config: FORCE
./scripts/config
$(MAKE) -f main.mk config
+config-musl: config FORCE
+ gcc -v 2>&1 |\
+ sed -En '/COLLECT_LTO_WRAPPER=/ s/.*=(.*)\/lto-wrapper/\1/p' |\
+ (read path; \
+ printf "g/define GCCLIBPATH/ s@.*@#define GCCLIBPATH \"$$path\"@\nw\n") |\
+ ed -s include/bits/scc/sys.h
+
clean: FORCE
touch config.mk
$(MAKE) -f main.mk clean
diff --git a/README b/README
@@ -205,6 +205,23 @@ environment variable SCCLIBPREFIX must be set:
$ SCCLIBPREFIX=/usr/local/musl scc hello.c
+Be sure that you modified `include/bits/scc/sys.h` to accomodate it to
+your system, specially the macro `GCCLIBPATH` that is heavily system
+dependent. In order to simplify this process the top level Makefile
+has a helper target `config-musl` that uses the gcc output to set it
+correctly:
+
+ $ make LIBPREFIX=/usr/local/musl LIBPROFILE=musl config-musl
+ $ make
+ $ LIBPREFIX=/usr/local/musl scc hello.c
+
+or
+
+ $ make LIBPREFIX=/usr/local/musl LIBPROFILE=musl config-musl
+ $ make
+ $ make install
+ $ scc-cc hello.c
+
Deviations from standard C
===========================
This compiler aims to be fully compatible with the C99 standard, but
diff --git a/include/bits/scc/Makefile b/include/bits/scc/Makefile
@@ -7,7 +7,7 @@ NODEP = 1
all: config.h sys.h cstd.h
-cstd.h:
+cstd.h: FORCE
cp cstd-$(STD).h $@
config.h: FORCE
@@ -20,7 +20,7 @@ config.h: FORCE
echo '#define LIBPREFIX "$(LIBPREFIX)"';\
echo '#define FORMAT "$(FORMAT)"') > $$$$.h && mv $$$$.h $@
-sys.h:
+sys.h: FORCE
rm -f $@;\
trap "rm -f $$$$.tmp" INT QUIT TERM HUP;\
sed -e 's/%NOPIE%/"$(NOPIE_LDFLAGS)",/' \