From ef6cc4207f3b044c1dcb453f03e2aa97b09d1e6a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 9 Sep 2023 15:44:31 +0100 Subject: [PATCH] cpp: quick clean up The cpp pass seems to be working now with the front end hacks. It does need some adjustment for line number behaviour it seems. --- Applications/cpp/Makefile | 45 -------------------------------- Applications/cpp/Makefile.8085 | 1 + Applications/cpp/Makefile.common | 29 ++++++++++++++++++++ Applications/cpp/cc.h | 7 ----- Applications/cpp/cpp.c | 11 +------- Applications/cpp/fuzix-cpp.pkg | 2 +- Applications/cpp/main.c | 20 +------------- 7 files changed, 33 insertions(+), 82 deletions(-) delete mode 100644 Applications/cpp/Makefile create mode 100644 Applications/cpp/Makefile.8085 create mode 100644 Applications/cpp/Makefile.common diff --git a/Applications/cpp/Makefile b/Applications/cpp/Makefile deleted file mode 100644 index 4ecc7f790b..0000000000 --- a/Applications/cpp/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -PLATFORM = 6809 -CC = m6809-unknown-gcc -ASM = m6809-unknown-as -AR = m6809-unknown-ar -LINKER = m6809-unknown-ld -CFLAGS = -I../../Library/include -I../../Library/include/6809 -Wall -pedantic -fno-strict-aliasing -COPT = -Os -LINKER_OPT = --oformat=raw -L../../Library/libs -lc6809 -LIBGCCDIR = $(dir $(shell $(CC) -print-libgcc-file-name)) -LINKER_OPT += -L$(LIBGCCDIR) -lgcc -Map=cpp.map -LINKER_OPT += --script=../util/$(TARGET).link -ASM_OPT = -o -CRT0 = ../../Library/libs/crt0_6809.o - -OBJS = cpp.o hash.o main.o token1.o token2.o - -all: cpp - -cpp: main.o cpp.o hash.o token1.o token2.o - $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $(OBJS) - -.c.o: - $(CC) $(CFLAGS) $(COPT) -c $< - -clean realclean: - rm -f cpp main.o cpp.o hash.o token1.o token2.o tmp.h *~ - -maintclean: realclean - rm -f token1.h token2.h - -main.o: cc.h -cpp.o: cc.h -hash.o: cc.h -tree.o: cc.h - -token1.o: token1.h -token2.o: token2.h - -token1.h: token1.tok - gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h - mv tmp.h token1.h - -token2.h: token2.tok - gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h - mv tmp.h token2.h diff --git a/Applications/cpp/Makefile.8085 b/Applications/cpp/Makefile.8085 new file mode 100644 index 0000000000..a1afdf7fe9 --- /dev/null +++ b/Applications/cpp/Makefile.8085 @@ -0,0 +1 @@ +include Makefile.common diff --git a/Applications/cpp/Makefile.common b/Applications/cpp/Makefile.common new file mode 100644 index 0000000000..ed1a8669b3 --- /dev/null +++ b/Applications/cpp/Makefile.common @@ -0,0 +1,29 @@ +include $(FUZIX_ROOT)/Target/rules.$(USERCPU) + +SRC = cpp.c hash.c main.c token1.c token2.c + +.SUFFIXES: .c .o + +OBJ = $(SRC:.c=.o) + +all: cpp + +.c.o: + $(CC) $(CFLAGS) $(CCOPTS) -c $< + +cpp: $(OBJ) + $(LINKER) $(CRT0) $^ -o $@ $(LINKER_OPT) $(LINKER_TAIL) + +clean: + rm -f *.o $(APPS) $(APPSNS) $(SRCS:.c=) core *~ *.asm *.lst *.sym *.map *.noi *.lk *.ihx *.tmp *.bin size.report + +rmbak: + rm -f *~ core + +main.o: cc.h +cpp.o: cc.h +hash.o: cc.h +tree.o: cc.h + +token1.o: token1.h +token2.o: token2.h diff --git a/Applications/cpp/cc.h b/Applications/cpp/cc.h index 9c298e71c6..d9463dc4ef 100644 --- a/Applications/cpp/cc.h +++ b/Applications/cpp/cc.h @@ -1,11 +1,4 @@ - -#ifndef P -#if __STDC__ #define P(x) x -#else -#define P(x) () -#endif -#endif extern void cfatal P((char*)); extern void cerror P((char*)); diff --git a/Applications/cpp/cpp.c b/Applications/cpp/cpp.c index 3dd2e58cd1..7fb860b986 100644 --- a/Applications/cpp/cpp.c +++ b/Applications/cpp/cpp.c @@ -1,11 +1,6 @@ - #include #include -#ifdef __STDC__ #include -#else -#include -#endif #include "cc.h" #define CPP_DEBUG 0 /* LOTS of junk to stderr. */ @@ -52,11 +47,7 @@ FILE * curfile; char * c_fname; int c_lineno = 0; -#ifdef __BCC__ typedef long int_type; /* Used for preprocessor expressions */ -#else -typedef int int_type; /* Used for preprocessor expressions */ -#endif static int curtok = 0; /* Used for preprocessor expressions */ static int fi_count = 0; @@ -1239,7 +1230,7 @@ static int_type get_exp_value(void) return sign<0 ? -value: value; } -void gen_substrings(char *macname, char *data_str, int arg_count, int is_vararg) +static void gen_substrings(char *macname, char *data_str, int arg_count, int is_vararg) { char * mac_text = 0; struct arg_store *arg_list; diff --git a/Applications/cpp/fuzix-cpp.pkg b/Applications/cpp/fuzix-cpp.pkg index 73a6b314c6..8e95171fc2 100644 --- a/Applications/cpp/fuzix-cpp.pkg +++ b/Applications/cpp/fuzix-cpp.pkg @@ -1,4 +1,4 @@ package ccp if-file cpp -f 0644 /usr/bin/cpp cpp +f 0755 /usr/bin/cpp cpp diff --git a/Applications/cpp/main.c b/Applications/cpp/main.c index 848d55e716..0b0f8d1f60 100644 --- a/Applications/cpp/main.c +++ b/Applications/cpp/main.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { int ar, i; char * p; -static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; +static char Usage[] = "Usage: cpp -E -Dxxx -Uxxx -Ixxx infile -o outfile"; #ifdef LC_CTYPE setlocale(LC_CTYPE, ""); @@ -56,22 +56,6 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; case 'A': dialect = DI_ANSI; break; case 'K': dialect = DI_KNR; break; - /* Some options for describing the code generator. */ - case '0': define_macro("__BCC__"); - define_macro("__AS386_16__"); - define_macro("__8086__"); - break; - case '3': define_macro("__BCC__"); - define_macro("__AS386_32__"); - define_macro("__i386__"); - break; - case 'c': define_macro("__CALLER_SAVES__"); - break; - case 'f': define_macro("__FIRST_ARG_IN_AX__"); - break; - case 'O': define_macro("__OPTIMISED__"); - break; - case 'C': /* Keep comments. */ cwarn("-C not implemented"); break; @@ -136,7 +120,6 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; if (!curfile) cfatal(Usage); -#if 0 /* Define date and time macros. */ if (dialect != DI_KNR) { time_t now; @@ -152,7 +135,6 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; sprintf(buf, "__DATE__=\"%.3s %.2s %.4s\"", timep + 4, timep + 8, timep + 20); define_macro(buf); } -#endif if (outfile) ofd = fopen(outfile, "w"); else ofd = stdout;