shithub: scc

Download patch

ref: 58a6c79cc36af196485e291e0d5599f351653a21
parent: c6d99ef3b76340791a0e68a8521277599cd1b690
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jul 20 04:07:12 EDT 2015

Improve error.h target in cc2/Makefile

This target is generated using a redirection, so a trap
alike rule is needed in order to ensure that the generated
file is correct.

LIB variable is also removed and direct library path is
used instead.

--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -2,8 +2,6 @@
 
 OBJS = main.o parser.o cgen.o code.o optm.o peep.o
 
-LIBS = -lcc
-
 all: cc2
 
 .POSIX:
@@ -12,10 +10,11 @@
 main.o: error.h
 
 error.h: cc2.h
-	awk -f generror cc2.h > $@
-			
+	rm -f $@; trap 'rm -f $$$$.h' EXIT INT QUIT
+	awk -f generror cc2.h > $$$$.h && mv $$$$.h $@
+
 cc2: $(OBJS) ../lib/libcc.a
-	$(CC) -L../lib $(LDFLAGS) $(OBJS) $(LIBS) -o $@
+	$(CC) $(LDFLAGS) $(OBJS) ../lib/libcc.a -o $@
 
 clean:
 	rm -f $(OBJS)