scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 643e8a40e46be15008645eecbeac019d7796552b
parent d69b942c0f484c8677cf8b8b2acfe8b190d6fc5f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  1 Jun 2022 12:58:29 +0200

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.

Diffstat:
MMakefile | 5+++--
Mscripts/rules.mk | 2++
Msrc/cmd/cc/posix/Makefile | 1+
Msrc/cmd/cc/posix/cc.c | 5++++-
Msrc/cmd/cc/posix/scc.sh | 6++++++
5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -10,12 +10,11 @@ DIRS =\ 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: @@ -90,6 +89,8 @@ install-arm64: arm64 uninstall-arm64: $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm64 $(ROOT) +############################################################# + toolchain: src libc: src/libc libcrt: src/libcrt diff --git 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 diff --git a/src/cmd/cc/posix/Makefile b/src/cmd/cc/posix/Makefile @@ -30,6 +30,7 @@ config.h: echo '#define ARCH "$(ARCH)"';\ echo '#define SYS "$(SYS)"';\ echo '#define ABI "$(ABI)"';\ + echo '#define LIBPREFIX "$(LIBPREFIX)"';\ echo '#define FORMAT "$(FORMAT)"') > $$$$.h && mv $$$$.h $@ clean: diff --git a/src/cmd/cc/posix/cc.c b/src/cmd/cc/posix/cc.c @@ -62,7 +62,8 @@ static struct tool { 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 @@ main(int argc, char *argv[]) format = FORMAT; if (!(prefix = getenv("SCCPREFIX"))) prefix = PREFIX; + if (!(libprefix = getenv("SCCLIBPREFIX"))) + libprefix = LIBPREFIX; ARGBEGIN { case 'D': diff --git a/src/cmd/cc/posix/scc.sh b/src/cmd/cc/posix/scc.sh @@ -6,6 +6,12 @@ then export SCCPREFIX fi +if test -z $SCCLIBPREFIX +then + SCCLIBPREFIX=`dirname $0`/.. + export SCCLIBPREFIX +fi + case $0 in *cpp) exec $SCCPREFIX/bin/scc-cc -E $@