shithub: scc

Download patch

ref: 6658e6edcecad1c26e6b0cfcd06ad08992481356
parent: 2401a9b700aa6dff9aa786f4d17a7dcd48e933b9
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Jan 25 05:43:25 EST 2016

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.

--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -10,7 +10,7 @@
 $(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 @@
 clean:
 	rm -f $(OBJS)
 	rm -f cc1 cpp
-
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -16,7 +16,7 @@
 	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)
--- a/config.mk
+++ b/config.mk
@@ -10,10 +10,15 @@
 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 $@ $<