comparison Makefile @ 314:a3e277c58df9 ccdev

Checkpoint parser development for lwcc Beginning of lemon based parser for C including all the infrastructure for calling the lemon generated parser. This requires a translation layer from the preprocessor token numbers to the lemon parser token numbers due to the fact that lemon wants to control the token numbers. Eventually when the lemon parser gets replaced with a hand crafted recursive descent parser, this translation will no longer be required. However, in the interest of getting things working sooner rather than later, using something like lemon is beneficial.
author William Astle <lost@l-w.ca>
date Sun, 17 Nov 2013 11:59:36 -0700
parents 41118fb0a8f2
children 5b8871fd7503
comparison
equal deleted inserted replaced
313:73b2bfa17ab0 314:a3e277c58df9
106 lwcc_cpp_srcs := cpp-main.c 106 lwcc_cpp_srcs := cpp-main.c
107 lwcc_cpp_srcs := $(addprefix lwcc/,$(lwcc_cpp_srcs)) 107 lwcc_cpp_srcs := $(addprefix lwcc/,$(lwcc_cpp_srcs))
108 lwcc_cpp_objs := $(lwcc_cpp_srcs:.c=.o) 108 lwcc_cpp_objs := $(lwcc_cpp_srcs:.c=.o)
109 lwcc_cpp_deps := $(lwcc_cpp_srcs:.c=.d) 109 lwcc_cpp_deps := $(lwcc_cpp_srcs:.c=.d)
110 110
111 lwcc_cc_srcs := cc-main.c tree.c parse.c 111 # parse_c.c needs to be first here
112 lwcc_cc_srcs := parse_c.c cc-main.c tree.c parse.c token_names.c
112 lwcc_cc_srcs := $(addprefix lwcc/,$(lwcc_cc_srcs)) 113 lwcc_cc_srcs := $(addprefix lwcc/,$(lwcc_cc_srcs))
113 lwcc_cc_objs := $(lwcc_cc_srcs:.c=.o) 114 lwcc_cc_objs := $(lwcc_cc_srcs:.c=.o)
114 lwcc_cc_deps := $(lwcc_cc_srcs:.c=.d) 115 lwcc_cc_deps := $(lwcc_cc_srcs:.c=.d)
115 116
116 lwcc_cpplib_srcs := cpp.c lex.c token.c preproc.c symbol.c 117 lwcc_cpplib_srcs := cpp.c lex.c token.c preproc.c symbol.c
177 178
178 -include $(alldeps) 179 -include $(alldeps)
179 180
180 extra_clean := $(extra_clean) *~ */*~ 181 extra_clean := $(extra_clean) *~ */*~
181 182
183 lwcc/parse_c.c lwcc/parse_c.h: lwcc/parse_c.y
184 rm -f lwcc/parse_c.h lwcc/parse_c.c
185 lemon -q lwcc/parse_c.y
186
187 lwcc/token_names.c: lwcc/parse_c.h
188 echo "char *ptoken_names[] = {" > $@
189 echo '"TOKEN_NONE",' >> $@
190 cat lwcc/parse_c.h | sed -e 's/#define \(.*\) .*$$/"\1",/g' -e 's/ //g' >> $@
191 echo '"" };' >> $@
192
193
182 %.o: %.c 194 %.o: %.c
183 @echo "Building dependencies for $@" 195 @echo "Building dependencies for $@"
184 @$(CC) -MM $(CPPFLAGS) -o $*.d $< 196 @$(CC) -MM -MG $(CPPFLAGS) -o $*.d $<
185 @mv -f $*.d $*.d.tmp 197 @mv -f $*.d $*.d.tmp
186 @sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d 198 @sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d
187 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d 199 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
188 @rm -f $*.d.tmp 200 @rm -f $*.d.tmp
189 @echo Building $@ 201 @echo Building $@