-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
118 lines (95 loc) · 2.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# makefile for native and cross z80 compiler
#
# embedded tests are for incremental development
#
# this following is only to get an idea of size
# the idea eventual is that it is both cross and native.
#
# we self-generate some of the files to keep things consistent
#
DEFINES= -DLEXTEST -DDEBUG
DEFINES= -DDEBUG
DEBUG= -ggdb3 -O0
CC = gcc
#CC = sdcc
ifeq ($(CC),sdcc)
CFLAGS = -mz80 --fomit-frame-pointer
LD = sdldz80
LDFLAGS= -l /usr/share/sdcc/lib/z80/z80.lib -m -w -i -y
endif
ifeq ($(CC),gcc)
CFLAGS = $(DEBUG) $(DEFINES) -Wno-implicit-function-declaration
LDFLAGS= $(DEBUG) -o
LD= gcc
endif
CC1OBJECTS = cc1.o error.o lex.o io.o macro.o kw.o util.o tokenlist.o unixlib.o \
expr.o parse.o type.o
HEADERS = ccc.h error.h
GENERATED = enumlist.h tokenlist.c error.h debug.h debugtags.c
BINS = enumcheck cc1 cc2 maketokens
TESTS=tests/*.c
#TESTS=tests/glom.c
#VERBOSE=-v 3
all: cc1
lextest: lex.o lextest.o kw.o io.o macro.o util.o error.o tokenlist.o
cc -g -o lextest tokenlist.o lextest.o lex.o kw.o io.o macro.o util.o error.o
cc1: $(CC1OBJECTS)
$(LD) $(LDFLAGS) cc1 $(CC1OBJECTS)
$(CC1OBJECTS): $(HEADERS)
.PHONY: test tests
test: cc1 runtest.sh
./runtest.sh $(VERBOSE) $(TESTS)
tests: cc1 runtest.sh
./runtest.sh $(VERBOSE)
#
# process the ccc.h file, extracting the enum tags for the tokens
#
enumlist.h: ccc.h Makefile
tr ',' '\n' < token.h | \
sed -e '/\/\*/d' -e 's/=.*$$//' | \
awk '/enum / { t=1;next } /;$$/ {t=0} {if (t) print}' | \
tr -d '[:blank:]' | \
awk '/[A-Z]+/ {printf("check(%s);\n", $$1);}' >enumlist.h
#
# generate token names from the enumlist.h file
#
tokenlist.c: enumlist.h maketokens
./maketokens >tokenlist.c
maketokens: maketokens.c token.h enumlist.h
cc -o maketokens maketokens.c
#
# generate the debug.h file from the shell script makedebug.sh
# which grunges through all the c sources looking for VERBOSE(tag)
#
debug.h debugtags.c: ./makedebug.sh
./makedebug.sh
#
# process the errorcodes file, which generates error.h, containing the
# error codes and corresponding error strings
#
error.h: errorcodes ./makeerror.awk
awk -f ./makeerror.awk < errorcodes > error.h
enumcheck: enumlist.h enumcheck.c
cc -o enumcheck enumcheck.c
./enumcheck
regen:
rm -f $(GENERATED)
make $(GENERATED)
tags:
ctags *.c
clean:
rm -f $(CC1OBJECTS) $(GENERATED) tests/*.i \
*.asm *.lst *.sym *.map *.cdb *.ihx
clobber: clean
rm -f $(BINS) tags
cc1.o: debugtags.c
parse.o: parse.c
type.o: type.c
main.o: main.c
io.o: io.c
macro.o: macro.c
kw.o: kw.c
error.o: error.c
util.o: util.c
tokenlist.o: tokenlist.c