shithub: scc

Download patch

ref: 2bc536749ffaedde7fa8307e7bdac88b68d21452
parent: 7aca4703205556836e7207154398d71a2c32b259
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Feb 24 06:05:34 EST 2015

Imcrement portability

We want to be able to compile this program in a native plan9
environment, and take advantage of the toolchain of this
system. This is a first step, because plan9 lacks stdbool
and it also lacks stdint.

--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -2,8 +2,6 @@
 OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \
 	code.o stmt.o
 
-CPPFLAGS =
-LDFLAGS = -L../lib
 LIBS = -lcc
 
 all: cc1
@@ -11,7 +9,7 @@
 $(OBJS) : cc1.h ../inc/cc.h ../inc/sizes.h
 
 cc1: $(OBJS) ../lib/libcc.a
-	$(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $@
+	$(CC) -L../lib $(LDFLAGS) $(OBJS) $(LIBS) -o $@
 
 clean:
 	rm -f $(OBJS)
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -1,5 +1,5 @@
 
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -1,4 +1,4 @@
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -1,5 +1,5 @@
 
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -1,8 +1,6 @@
 
 OBJS = main.o parser.o cgen.o code.o optm.o
 
-CPPFLAGS =
-LDFLAGS = -L../lib
 LIBS = -lcc
 
 all: cc2
@@ -14,7 +12,7 @@
 	./generror cc2.h > $@
 			
 cc2: $(OBJS) ../lib/libcc.a
-	$(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $@
+	$(CC) -L../lib $(LDFLAGS) $(OBJS) $(LIBS) -o $@
 
 clean:
 	rm -f $(OBJS)
--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -1,7 +1,7 @@
 
 #include <assert.h>
 #include <stdarg.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdlib.h>
 
 #include "../inc/cc.h"
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -1,8 +1,7 @@
 
 #include <stdarg.h>
-#include <stdbool.h>
 #include <stddef.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdio.h>
 
 #include "../inc/cc.h"
--- a/cc2/main.c
+++ b/cc2/main.c
@@ -1,6 +1,6 @@
 
 #include <stdarg.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 
--- a/cc2/optm.c
+++ b/cc2/optm.c
@@ -1,6 +1,6 @@
 
 #include <stddef.h>
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "../inc/cc.h"
 #include "cc2.h"
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -1,6 +1,6 @@
 
 #include <errno.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
--- a/inc/cc.h
+++ b/inc/cc.h
@@ -3,7 +3,11 @@
 #define CC_H_
 
 #ifndef __bool_true_and_false_defined
+#ifdef NBOOL
+typedef unsigned bool;
+#else
 #include <stdbool.h>
+#endif
 #endif
 
 #define TINT short