7 .include "../Makefile.inc"
10 CFLAGS+= -DGENERATOR_FILE -DHAVE_CONFIG_H
12 # Override LIBIBERTY set by Makefile.inc, We use our own for
14 LIBIBERTY= libiberty.a
16 .PATH: ${GCCDIR} ${GCCLIB}/libiberty
18 #-----------------------------------------------------------------------
19 # Determine content of variables used by the target/host config files
22 # The list of headers to go into tm.h
24 TARGET_INC+= options.h
25 .if ${TARGET_ARCH} == "amd64"
26 TARGET_INC+= i386/biarch64.h
28 .if ${TARGET_ARCH} != "arm"
29 TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h
31 .if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
32 TARGET_INC+= ${GCC_CPU}/unix.h
33 TARGET_INC+= ${GCC_CPU}/att.h
36 TARGET_INC+= elfos-undef.h
38 TARGET_INC+= freebsd-native.h
39 TARGET_INC+= freebsd-spec.h
40 TARGET_INC+= freebsd.h
41 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
42 . if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
43 TARGET_INC+= ${GCC_CPU}/sysv4.h
46 .if ${TARGET_ARCH} == "amd64"
47 TARGET_INC+= ${GCC_CPU}/x86-64.h
49 .if ${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "mips"
50 TARGET_INC+= ${GCC_CPU}/elf.h
52 .if ${TARGET_ARCH} == "arm"
53 TARGET_INC+= ${GCC_CPU}/aout.h
55 TARGET_INC+= ${GCC_CPU}/freebsd.h
56 .if ${TARGET_ARCH} == "amd64"
57 TARGET_INC+= ${GCC_CPU}/freebsd64.h
59 .if ${TARGET_ARCH} == "arm"
60 TARGET_INC+= ${GCC_CPU}/arm.h
62 TARGET_INC+= defaults.h
64 .for H in ${TARGET_INC}
65 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
67 TARGET_INC_FILES+= $D/$H
76 CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \
77 ${GCCLIB}/libcpp/include/cpplib.h
78 SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h
79 CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h
80 HASHTAB_H= ${GCCLIB}/include/hashtab.h
81 SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h
82 out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c
83 tm_file_list= ${TARGET_INC_FILES}
84 host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h
85 GTFILES_SRCDIR= ${srcdir}
87 # Copied unchanged from gcc/Makefile.in
88 GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
89 $(CPP_ID_DATA_H) $(host_xm_file_list) \
90 $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
91 $(srcdir)/coverage.c $(srcdir)/rtl.h \
92 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
93 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
94 $(srcdir)/ipa-reference.h $(srcdir)/output.h \
95 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \
96 $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
97 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
98 $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \
99 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
100 $(srcdir)/dojump.c $(srcdir)/tree-profile.c \
101 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
102 $(srcdir)/function.c $(srcdir)/except.h \
103 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
104 $(srcdir)/profile.c $(srcdir)/regclass.c \
105 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
106 $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \
107 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
108 $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \
109 $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \
110 $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \
111 $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
112 $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
113 $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
114 $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
115 $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
116 $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
117 $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
118 $(srcdir)/tree-ssa-structalias.c \
119 $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
120 $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \
122 # The list of frontend directories to look into
123 GTFILES_LANG_DIR_NAMES=
125 .if ${MK_CXX} != "no"
126 GTFILES_LANG_DIR_NAMES+= cp
129 .if ${MK_OBJC} != "no"
130 GTFILES_LANG_DIR_NAMES+= objc
133 # The list of language specific files for gengtype
134 .for L in ${GTFILES_LANG_DIR_NAMES} c
135 .if exists(${GCCDIR}/$L-config-lang.in)
136 # Source the language config file
137 L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
139 L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
141 .for F in ${L_GTFILES}
146 GTFILES+= ${GTFILES_FILES}
149 # Tree definition files.
153 .if ${MK_CXX} != "no"
154 TREE_DEF_FILES+= cp/cp-tree.def
157 .if ${MK_OBJC} != "no"
158 TREE_DEF_FILES+= objc/objc-tree.def
164 OPT_FILES= c.opt common.opt
166 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt)
167 OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt
170 .if exists(${.CURDIR}/${GCC_CPU}-freebsd.opt)
171 OPT_FILES+= ${.CURDIR}/${GCC_CPU}-freebsd.opt
174 .if ${TARGET_ARCH} == "powerpc"
175 OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/sysv4.opt
178 .if ${TARGET_ARCH} == "sparc64"
179 OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt
182 .if exists(${.CURDIR}/freebsd.opt)
183 OPT_FILES+= ${.CURDIR}/freebsd.opt
186 #-----------------------------------------------------------------------
187 # Build rules for header files and generator tools
191 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
192 HEADERS="auto-host.h ansidecl.h" \
194 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
197 CLEANFILES+= cs-config.h
201 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
202 HEADERS="auto-host.h ansidecl.h" \
204 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
205 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
206 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
210 CLEANFILES+= cs-bconfig.h
214 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
215 HEADERS="auto-host.h ansidecl.h" \
216 DEFINES="USED_FOR_TARGET" \
217 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
220 CLEANFILES+= cs-tconfig.h
222 optionlist: ${OPT_FILES}
223 LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET}
225 options.h: optionlist
226 LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \
227 -f ${GCCDIR}/opth-gen.awk \
228 < ${.ALLSRC} > ${.TARGET}
230 options.c: optionlist
231 LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \
232 -f ${GCCDIR}/optc-gen.awk \
233 -v header_name="config.h system.h coretypes.h tm.h" \
234 < ${.ALLSRC} > ${.TARGET}
235 GENONLY+= optionlist options.h options.c
237 # Target machine config
239 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
240 HEADERS="${TARGET_INC}" \
242 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
243 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
244 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
250 # Target machine protos/preds.
252 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
253 HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \
255 /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h
258 CLEANFILES+= cs-tm_p.h
261 gencheck.h: ${TREE_DEF_FILES}
262 .for F in ${TREE_DEF_FILES}
263 echo "#include \"$F\"" >> ${.TARGET}
270 # Source header for gtyp generator.
271 gtyp-gen.h: ${GTFILES}
272 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET}
273 echo "static const char * const srcdir = " >> ${.TARGET}
274 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET}
275 echo "static const char * const lang_files[] = {" >> ${.TARGET}
276 .for F in ${GTFILES_FILES}
277 echo "\"$F\", " >> ${.TARGET}
279 echo "NULL};" >> ${.TARGET}
280 echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET}
281 .for F in ${GTFILES_LANGS}
282 echo "\"$F\", " >> ${.TARGET}
284 echo "NULL};" >> ${.TARGET}
285 echo "static const char * const all_files[] = {" >> ${.TARGET}
287 echo "\"$F\", " >> ${.TARGET}
289 echo "NULL};" >> ${.TARGET}
290 echo "static const char * const lang_dir_names[] = {" >> ${.TARGET}
291 .for F in c ${GTFILES_LANG_DIR_NAMES}
292 echo "\"$F\", " >> ${.TARGET}
294 echo "NULL};" >> ${.TARGET}
298 # Version header for gcov
300 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET}
304 # Multilib config file
306 echo 'static const char *const multilib_raw[] = { \
307 ". ;", NULL };' > ${.TARGET}
308 echo 'static const char *const multilib_matches_raw[] = { \
309 NULL };' >> ${.TARGET}
310 echo 'static const char *multilib_extra = "";' >> ${.TARGET}
311 echo 'static const char *multilib_options = "";' >> ${.TARGET}
312 echo 'static const char *const multilib_exclusions_raw[] = { \
313 NULL };' >> ${.TARGET}
318 echo 'static const char configuration_arguments[] =' > ${.TARGET}
319 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET}
320 echo 'static const char thread_model[] = "posix";' >> ${.TARGET}
321 echo 'static const struct {' >> ${.TARGET}
322 echo ' const char *name, *value;' >> ${.TARGET}
323 echo '} configure_default_options[] = {' >> ${.TARGET}
324 echo ' { "NULL", "NULL" } };' >> ${.TARGET}
326 GENSRCS+= configargs.h
328 # Language spec files
330 echo '#include "cp/lang-specs.h"' > ${.TARGET}
331 echo '#include "objc/lang-specs.h"' >> ${.TARGET}
336 echo '#include "sys/types.h"' > ${.TARGET}
337 echo '#include "sys/stdint.h"' >> ${.TARGET}
342 gthr-default.h: ${GCCDIR}/gthr-posix.h
343 ln -sf ${.ALLSRC} ${.TARGET}
345 GENSRCS+= gthr-default.h
347 unwind.h: ${GCCDIR}/unwind-generic.h
348 ln -sf ${.ALLSRC} ${.TARGET}
355 gengtype-lex.c: gengtype-lex.l
356 flex -ogengtype-lex.c ${.ALLSRC}
358 gengtype-yacc.h: gengtype-yacc.y
359 yacc -d -o gengtype-yacc.c ${.ALLSRC}
361 gengtype-yacc.c: gengtype-yacc.h
363 gengtype-yacc+%DIKED.c: gengtype-yacc.c
364 cat ${.ALLSRC} > ${.TARGET}
365 sed -e "s/xmalloc/malloc/g" \
366 -e "s/xrealloc/realloc/g" \
367 -e "s/malloc/xmalloc/g" \
368 -e "s/realloc/xrealloc/g" \
369 ${.ALLSRC} > ${.TARGET}
371 GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c
372 CLEANFILES+= gengtype-yacc.c
374 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \
376 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
378 gtype-desc.h: gengtype
382 gtype-desc.c: gtype-desc.h
384 GENONLY+= gtype-desc.c gtype-desc.h
385 CLEANFILES+= gt-*.h gtype-*.h
390 .for F in check checksum genrtl modes
391 gen$F: gen$F.o errors.o ${LIBIBERTY}
392 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
395 .for F in attr attrtab automata codes conditions config constants emit \
396 extract flags opinit output peep preds recog
397 gen$F: gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \
398 gensupport.o print-rtl.o errors.o ${LIBIBERTY}
399 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
402 gencondmd: gencondmd.o
403 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
406 # Generated .md files.
408 insn-conditions.md: gencondmd
409 ./gencondmd > ${.TARGET}
410 GENSRCS+= insn-conditions.md
413 # Generated header files.
417 insn-$F.h: gen$F ${MD_FILE}
418 ./gen$F ${MD_FILE} > ${.TARGET}
422 .for F in attr codes config flags
423 insn-$F.h: gen$F ${MD_FILE} insn-conditions.md
424 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
428 # Header files with irregular names.
430 ./gengenrtl -h > ${.TARGET}
434 ./genpreds -h ${MD_FILE} > ${.TARGET}
437 tm-constrs.h: genpreds
438 ./genpreds -c ${MD_FILE} > ${.TARGET}
439 GENSRCS+= tm-constrs.h
441 tree-check.h: gencheck
442 ./gencheck > ${.TARGET}
443 GENSRCS+= tree-check.h
445 insn-modes.h: genmodes
446 ./genmodes -h > ${.TARGET}
447 GENSRCS+= insn-modes.h
450 # Generated source files.
452 .for F in attrtab automata emit extract opinit output peep preds recog
453 insn-$F.c: gen$F ${MD_FILE} insn-conditions.md
454 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
459 insn-$F.c: gen$F ${MD_FILE}
460 ./gen$F ${MD_FILE} > ${.TARGET}
464 # Source files with irregular names.
465 insn-modes.c: genmodes
466 ./genmodes > ${.TARGET}
467 GENONLY+= insn-modes.c
469 min-insn-modes.c: genmodes
470 ./genmodes -m > ${.TARGET}
471 GENSRCS+= min-insn-modes.c
474 ./gengenrtl > ${.TARGET}
477 gencondmd.c: genconditions ${MD_FILE}
478 ./genconditions ${MD_FILE} > ${.TARGET}
479 GENSRCS+= gencondmd.c
481 #-----------------------------------------------------------------------
484 GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \
485 genconditions gencondmd genconfig genconstants genemit \
486 genextract genflags gengenrtl gengtype genmodes genopinit \
487 genoutput genpeep genpreds genrecog
489 all: ${GNTOOLS} ${GENSRCS} ${GENONLY}
490 beforedepend: ${GENONLY}
493 #-----------------------------------------------------------------------
494 # Build 'pocket' libiberty exclusively for build tools use.
496 LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \
497 dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \
498 hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \
499 partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \
500 xmalloc.c xmemdup.c xstrdup.c xstrerror.c
501 LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g}
503 .for _src in ${LIBIBERTY_SRCS}
504 ${_src:R:S/$/.o/}: ${_src}
505 ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC}
508 ${LIBIBERTY}: ${LIBIBERTY_OBJS}
510 @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q`
512 CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS}
515 #-----------------------------------------------------------------------
518 # Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't
519 # define PROG because we have multiple programs.
521 SRCS= errors.c genattr.c genattrtab.c \
522 genautomata.c gencheck.c genchecksum.c gencodes.c \
523 genconditions.c genconfig.c genconstants.c genemit.c \
524 genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \
525 genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \
526 gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \
530 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
531 GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g}
532 CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS}
534 #-----------------------------------------------------------------------
535 # Manual dependencies.
536 .if !exists(${DEPENDFILE})
537 .include "Makefile.dep"
540 .include <bsd.prog.mk>