scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 6658e6edcecad1c26e6b0cfcd06ad08992481356
parent 2401a9b700aa6dff9aa786f4d17a7dcd48e933b9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 25 Jan 2016 10:43:25 +0100

Make Makefiles more user friendly

CFLAGS and LDFLAGS are user variables. If we use a new set of defined flags
we allow to the user to modify the behaviour of the Makefile using
environment variables.

Diffstat:
Mcc1/Makefile | 3+--
Mcc2/Makefile | 2+-
Mconfig.mk | 15++++++++++-----
3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/cc1/Makefile b/cc1/Makefile @@ -10,7 +10,7 @@ all: cc1 $(OBJS) : cc1.h ../inc/cc.h ../inc/sizes.h arch/$(ARCH)/arch.h cc1: $(OBJS) ../lib/libcc.a - $(CC) $(LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ + $(CC) $(SLDFLAGS) $(LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ cpp: cc1 ln -f cc1 cpp @@ -21,4 +21,3 @@ test: clean: rm -f $(OBJS) rm -f cc1 cpp - diff --git a/cc2/Makefile b/cc2/Makefile @@ -16,7 +16,7 @@ error.h: cc2.h awk -f generror cc2.h > $$$$.h && mv $$$$.h $@ cc2: $(OBJS) ../lib/libcc.a - $(CC) $(LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ + $(CC) $(SLDFLAGS) $(LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ clean: rm -f $(OBJS) diff --git a/config.mk b/config.mk @@ -10,10 +10,15 @@ PREFIX = $(HOME) MANPREFIX = ${PREFIX}/share/man # if your system is not POSIX maybe you want to use cc or gcc -CC = c99 -LD = $(CC) -AR = ar +# CC = c99 +# AR = ar # for Plan9 add -D_SUSV2_SOURCE -DNBOOL -CFLAGS = -DNDEBUG -Iarch/$(ARCH) -DPREFIX=\""$(PREFIX)"\" -LDFLAGS = -s +SCFLAGS = -DNDEBUG -Iarch/$(ARCH) -DPREFIX=\""$(PREFIX)"\" +SLDFLAGS = -s + +.c.o: + $(CC) $(SCFLAGS) $(CFLAGS) -o $@ -c $< + +.c: + $(CC) $(SCFLAGS) $(CFLAGS) -o $@ $<