4 # This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
5 # is such a !@#!*#% nightmare because of how it reprograms the dependencies,
6 # suffix rules, SRCS, etc. It's easiest to cheat by using bsd.prog.mk and
7 # SRCS to get dependencies.
10 # ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
11 # Prevent mkdep from using it, so that we don't have to give rules for
12 # aliases of generated headers.
14 CFLAGS+= -I. -static -DGENERATOR_FILE
16 .include "../Makefile.inc"
20 #-----------------------------------------------------------------------
23 .for F in attr codes config flags constants
24 insn-$F.h: gen$F ${MD_FILE}
25 ./gen$F ${MD_FILE} > insn-$F.h
30 insn-$F.c: gen$F ${MD_FILE}
31 ./gen$F ${MD_FILE} > insn-$F.c
35 GENSRCS+= gen-time-stamp
36 gen-time-stamp: genattr genattrtab genconditions genconstants genemit \
37 genextract gengtype genopinit genoutput genpeep genrecog
40 .for F in attr codes config emit extract flags opinit output peep recog
43 gen$F: gen$F.o rtl.o obstack.o print-rtl.o bitmap.o errors.o gensupport.o \
44 ggc-none.o hashtab.o read-rtl.o concat.o insn-conditions.o
45 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
52 # genattrtab needs more complex build rule
54 build-tools: genattrtab
56 genattrtab : genattrtab.o rtl.o obstack.o print-rtl.o bitmap.o errors.o \
57 gensupport.o ggc-none.o hashtab.o read-rtl.o concat.o \
58 insn-conditions.o genautomata.o varray.o getruntime.o
59 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
61 GENSRCS+= genattrtab.c
62 CLEANFILES+= genattrtab
65 # genconstants and genconditions cannot depend on insn-conditions.o
66 # they should be liked with dummy-conditions.o stubs instead
68 .for F in constants conditions
71 gen$F: gen$F.o rtl.o obstack.o bitmap.o errors.o gensupport.o \
72 ggc-none.o hashtab.o read-rtl.o concat.o dummy-conditions.o
73 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
79 .for F in check genrtl preds
83 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
89 .ORDER: genrtl.c genrtl.h
90 genrtl.c genrtl.h: gengenrtl
91 ./gengenrtl > genrtl.c
92 ./gengenrtl -h > genrtl.h
94 GENSRCS+= genrtl.c genrtl.h
96 SRCS+= bitmap.c concat.c dummy-conditions.c errors.c genautomata.c \
97 gensupport.c getruntime.c ggc-none.c hashtab.c \
98 obstack.c physmem.c print-rtl.c read-rtl.c rtl.c varray.c xmemdup.c
100 #-----------------------------------------------------------------------
101 # Common parser stuff.
103 tree-check.h: gencheck
104 ./gencheck > ${.TARGET}
105 GENSRCS+= tree-check.h
107 #-----------------------------------------------------------------------
111 ./genpreds > ${.TARGET}
114 #-----------------------------------------------------------------------
117 gengtype-lex.c : gengtype-lex.l
118 ${LEX} -t ${.ALLSRC} | \
119 sed 's/^\(char msg\[\];\)/yyconst \1/' > ${.TARGET}
121 .ORDER: gengtype-yacc.c gengtype-yacc.h
122 gengtype-yacc.c gengtype-yacc.h: gengtype-yacc.y
123 ${YACC} -d -o gengtype-yacc.c ${.ALLSRC}
125 GENSRCS+= gengtype-yacc+%DIKED.c gengtype-yacc.h gengtype-lex.c
126 CLEANFILES+= gengtype-yacc.c
128 gengtype-yacc+%DIKED.c: gengtype-yacc.c
129 cat ${.ALLSRC} > ${.TARGET}
130 sed -e "s/xmalloc/malloc/g" \
131 -e "s/xrealloc/realloc/g" \
132 -e "s/malloc/xmalloc/g" \
133 -e "s/realloc/xrealloc/g" \
134 ${.ALLSRC} > ${.TARGET}
136 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o xmemdup.o
137 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
140 CLEANFILES+= gengtype
142 gengtype-lex.o: gengtype-yacc.h
144 .ORDER: gtype-desc.c gtype-desc.h
145 gtype-desc.c gtype-desc.h: gtype-time-stamp
148 GENSRCS+= gtype-time-stamp
149 gtype-time-stamp: gengtype ${GTFILES}
153 GENSRCS+= gtype-desc.c gtype-desc.h
154 CLEANFILES+= gt-*.h gtype-*.h
156 #-----------------------------------------------------------------------
157 # Determine content of variables used by the target/host config files
160 # The list of headers to go into tconfig.h
162 TARGET_INC= ansidecl.h
163 TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h
164 .if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
165 TARGET_INC+= ${GCC_CPU}/unix.h
166 TARGET_INC+= ${GCC_CPU}/att.h
168 .if ${TARGET_ARCH} != "alpha"
169 TARGET_INC+= dbxelf.h
172 TARGET_INC+= freebsd-native.h
173 TARGET_INC+= freebsd-spec.h
174 TARGET_INC+= freebsd.h
175 .if ${TARGET_ARCH} == "alpha"
176 TARGET_INC+= ${GCC_CPU}/elf.h
178 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
179 .if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
180 TARGET_INC+= ${GCC_CPU}/sysv4.h
183 TARGET_INC+= ${GCC_CPU}/freebsd.h
184 .if ${TARGET_ARCH} == "amd64"
185 TARGET_INC+= ${GCC_CPU}/x86-64.h
186 TARGET_INC+= ${GCC_CPU}/freebsd64.h
188 TARGET_INC+= defaults.h
191 # Use TARGET_INC as a template and build a list of target specific
192 # include files for gengtype to scan
194 GCONFIG_H= ${.OBJDIR}/tconfig.h ${.CURDIR}/auto-host.h
196 .for H in ${TARGET_INC}
197 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
205 # Define some variables to make blocks copied from Makefile.in happy
208 HASHTAB_H= ${GCCDIR}/hashtab.h
209 out_file= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.c
210 GTFILES_SRCDIR= ${GCCDIR}
213 # Copied unchanged from gcc/Makefile.in
215 GTFILES = $(GCONFIG_H) $(srcdir)/location.h \
217 $(srcdir)/bitmap.h $(srcdir)/function.h $(srcdir)/rtl.h $(srcdir)/optabs.h \
218 $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h $(srcdir)/real.h \
219 $(srcdir)/varray.h $(srcdir)/ssa.h $(srcdir)/insn-addr.h $(srcdir)/cselib.h \
220 $(srcdir)/c-common.h $(srcdir)/c-tree.h \
221 $(srcdir)/basic-block.h \
222 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c \
223 $(srcdir)/dwarf2out.c $(srcdir)/emit-rtl.c \
224 $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
225 $(srcdir)/fold-const.c $(srcdir)/function.c \
226 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
227 $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \
228 $(srcdir)/reg-stack.c \
229 $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
230 $(srcdir)/tree.c $(srcdir)/varasm.c \
234 # Build a list of frontend directories to look into
236 GTFILES_LANG_DIR_NAMES=
239 GTFILES_LANG_DIR_NAMES+= cp
242 .if !defined(NO_OBJC)
243 GTFILES_LANG_DIR_NAMES+= objc
246 .if !defined(NO_FORTRAN)
247 GTFILES_LANG_DIR_NAMES+= f
251 # Build a list of language specific files for gengtype
253 .for L in ${GTFILES_LANG_DIR_NAMES} c
254 .if exists(${GCCDIR}/$L-config-lang.in)
255 # Source the language config file
256 L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
258 L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
260 .for F in ${L_GTFILES}
265 GTFILES+= ${GTFILES_FILES}
267 #-----------------------------------------------------------------------
268 # the host/target compiler config.
270 COMMONHDRS= config.h hconfig.h multilib.h options.h specs.h tconfig.h \
271 tm_p.h configargs.h safe-ctype.h
272 GENSRCS+= ${COMMONHDRS} gencheck.h gtyp-gen.h
274 MFILE?= ${.CURDIR}/Makefile
275 ${COMMONHDRS}: ${MFILE}
278 echo 'static const char configuration_arguments[] =' > ${.TARGET}
279 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET}
280 echo 'static const char thread_model[] = "posix";' >> ${.TARGET}
283 echo '#include "auto-host.h"' > ${.TARGET}
284 echo '#include <tconfig.h>' >> ${.TARGET}
287 echo '#include "cp/cp-tree.def"' > ${.TARGET}
288 echo '#include "objc/objc-tree.def"' >> ${.TARGET}
291 echo 'static const char *const multilib_raw[] = { \
292 "aout maout;", "elf !maout;", NULL };' > ${.TARGET}
293 echo 'static const char *const multilib_matches_raw[] = { \
294 "maout maout;", "melf melf;", NULL };' >> ${.TARGET}
295 echo 'static const char *multilib_extra = "";' >> ${.TARGET}
296 echo 'static const char *multilib_options = "";'>> ${.TARGET}
297 echo 'static const char *const multilib_exclusions_raw[] = { \
298 NULL };' >> ${.TARGET}
301 echo '#include "cp/lang-options.h"' > ${.TARGET}
302 echo '#include "f/lang-options.h"' >> ${.TARGET}
303 echo '#include "objc/lang-options.h"' >> ${.TARGET}
306 echo '#include "cp/lang-specs.h"' > ${.TARGET}
307 echo '#include "f/lang-specs.h"' >> ${.TARGET}
308 echo '#include "objc/lang-specs.h"' >> ${.TARGET}
311 echo '#include <hconfig.h>' > ${.TARGET}
312 echo '#ifndef GENERATOR_FILE' >> ${.TARGET}
313 echo '#include "insn-constants.h"' >> ${.TARGET}
314 echo '#include "insn-flags.h"' >> ${.TARGET}
315 echo '#endif' >> ${.TARGET}
318 echo 'struct rtx_def;' > ${.TARGET}
319 echo 'typedef struct rtx_def *rtx;' >> ${.TARGET}
320 echo 'struct rtvec_def;' >> ${.TARGET}
321 echo 'typedef struct rtvec_def *rtvec;' >> ${.TARGET}
322 echo 'union tree_node;' >> ${.TARGET}
323 echo 'typedef union tree_node *tree;' >> ${.TARGET}
324 echo '#ifndef GTY' >> ${.TARGET}
325 echo '# define GTY(x)' >> ${.TARGET}
326 echo '#endif' >> ${.TARGET}
327 echo '' >> ${.TARGET}
328 .if ${TARGET_ARCH} == "amd64"
329 echo '#include "i386/biarch64.h"' >> ${.TARGET}
331 .if ${TARGET_ARCH} == "ia64"
332 echo '#define TARGET_CPU_DEFAULT (MASK_GNU_AS|MASK_GNU_LD)' >>${.TARGET}
334 .for H in ${TARGET_INC}
335 echo '#include "$H"' >> ${.TARGET}
337 echo '#ifndef POSIX' >> ${.TARGET}
338 echo '# define POSIX' >> ${.TARGET}
339 echo '#endif' >> ${.TARGET}
340 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
341 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
342 echo '#define EXTRA_CC_MODES 1' >> ${.TARGET}
346 echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"' >> ${.TARGET}
347 echo '#include "tm-preds.h"' >> ${.TARGET}
349 safe-ctype.h: Makefile
350 echo '#include <ctype.h>' > ${.TARGET}
351 .for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \
352 ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL
353 echo '#define ${Z} ${Z:L}' >> ${.TARGET}
355 echo "#define ISIDST(x) \
356 ((x) == '_' || isalpha(x))" >> ${.TARGET}
357 echo "#define ISIDNUM(x) \
358 (isdigit(x) || ISIDST(x))" >> ${.TARGET}
359 echo "#define IS_VSPACE(x) \
360 ((x) == '\n' || (x) == '\r')" >> ${.TARGET}
361 echo "#define IS_NVSPACE(x) \
362 (!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))" >> ${.TARGET}
363 echo "#define IS_SPACE_OR_NUL(x) \
364 (isspace(x) || (x) == '\0')" >> ${.TARGET}
367 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET}
368 echo "static const char *srcdir = " >> ${.TARGET}
369 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET}
370 echo "static const char *lang_files[] = {" >> ${.TARGET}
371 .for F in ${GTFILES_FILES}
372 echo "\"$F\", " >> ${.TARGET}
374 echo "NULL};" >> ${.TARGET}
375 echo "static const char *langs_for_lang_files[] = {" >> ${.TARGET}
376 .for F in ${GTFILES_LANGS}
377 echo "\"$F\", " >> ${.TARGET}
379 echo "NULL};" >> ${.TARGET}
380 echo "static const char *all_files[] = {" >> ${.TARGET}
382 echo "\"$F\", " >> ${.TARGET}
384 echo "NULL};" >> ${.TARGET}
385 echo "static const char *lang_dir_names[] = { \"c\", " >> ${.TARGET}
386 .for F in ${GTFILES_LANG_DIR_NAMES}
387 echo "\"$F\", " >> ${.TARGET}
389 echo "NULL};" >> ${.TARGET}
390 echo "#define xexit exit" >> ${.TARGET}
393 #-----------------------------------------------------------------------
397 CLEANFILES+= ${GENSRCS}
401 .include <bsd.prog.mk>
403 #-----------------------------------------------------------------------
406 # Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't
407 # define PROG because we have multiple programs.
409 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
412 .if !exists(${DEPENDFILE})
413 # Fudge pre-dependfile dependencies of objects in much the same way as
414 # bsd.prog.mk would do if we defined PROG. There are complications to
415 # avoid circular dependencies. First, only make most objects depend on
416 # all headers. Filter out the objects that would cause problems (i.e.,
417 # objects that will be used to create programs that will generate headers).
419 ${OBJS}: ${SRCS:M*.h:Ngtype-desc.h:Ngenrtl.h:Ntree-check.h:Ntm-preds.h:Ninsn-*.h}
421 ${OBJS:Ngencheck.o:Ngengenrtl.o:Ngenpreds.o}: tree-check.h tm-preds.h genrtl.h
423 ${OBJS:Ngengtype*.o:Nxmemdup.o:Ngengenrtl.o:Ngencheck.o:Ngenpreds.o}: gtype-desc.h
425 genextract.o: insn-config.h
427 insn-conditions.o: insn-constants.h