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_CPUARCH} == "amd64"
26 TARGET_INC+= i386/biarch64.h
28 .if ${TARGET_CPUARCH} != "arm"
29 TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h
31 .if ${TARGET_CPUARCH} == "i386" || ${TARGET_CPUARCH} == "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_CPUARCH} != "i386" && ${TARGET_CPUARCH} != "amd64"
42 . if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
43 TARGET_INC+= ${GCC_CPU}/sysv4.h
46 .if ${TARGET_CPUARCH} == "amd64"
47 TARGET_INC+= ${GCC_CPU}/x86-64.h
49 .if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "mips"
50 TARGET_INC+= ${GCC_CPU}/elf.h
52 .if ${TARGET_CPUARCH} == "arm"
53 TARGET_INC+= ${GCC_CPU}/aout.h
54 TARGET_INC+= ${GCC_CPU}/bpabi.h
56 .if ${TARGET_ARCH} == "powerpc64"
57 TARGET_INC+= ${GCC_CPU}/biarch64.h
58 TARGET_INC+= ${GCC_CPU}/default64.h
60 TARGET_INC+= ${GCC_CPU}/freebsd.h
61 .if ${TARGET_CPUARCH} == "amd64"
62 TARGET_INC+= ${GCC_CPU}/freebsd64.h
64 .if ${TARGET_CPUARCH} == "arm"
65 TARGET_INC+= ${GCC_CPU}/arm.h
67 TARGET_INC+= defaults.h
69 .for H in ${TARGET_INC}
70 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
72 TARGET_INC_FILES+= $D/$H
81 CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \
82 ${GCCLIB}/libcpp/include/cpplib.h
83 SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h
84 CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h
85 HASHTAB_H= ${GCCLIB}/include/hashtab.h
86 SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h
87 out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c
88 tm_file_list= ${TARGET_INC_FILES}
89 host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h
90 GTFILES_SRCDIR= ${srcdir}
92 # Copied unchanged from gcc/Makefile.in
93 GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
94 $(CPP_ID_DATA_H) $(host_xm_file_list) \
95 $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
96 $(srcdir)/coverage.c $(srcdir)/rtl.h \
97 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
98 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
99 $(srcdir)/ipa-reference.h $(srcdir)/output.h \
100 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \
101 $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
102 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
103 $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \
104 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
105 $(srcdir)/dojump.c $(srcdir)/tree-profile.c \
106 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
107 $(srcdir)/function.c $(srcdir)/except.h \
108 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
109 $(srcdir)/profile.c $(srcdir)/regclass.c \
110 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
111 $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \
112 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
113 $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \
114 $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \
115 $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \
116 $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
117 $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
118 $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
119 $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
120 $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
121 $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
122 $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
123 $(srcdir)/tree-ssa-structalias.c \
124 $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
125 $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \
127 # The list of frontend directories to look into
128 GTFILES_LANG_DIR_NAMES=
130 .if ${MK_CXX} != "no"
131 GTFILES_LANG_DIR_NAMES+= cp
134 # The list of language specific files for gengtype
135 .for L in ${GTFILES_LANG_DIR_NAMES} c
136 .if exists(${GCCDIR}/$L-config-lang.in)
137 # Source the language config file
138 L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
140 L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
142 .for F in ${L_GTFILES}
147 GTFILES+= ${GTFILES_FILES}
150 # Tree definition files.
154 .if ${MK_CXX} != "no"
155 TREE_DEF_FILES+= cp/cp-tree.def
161 OPT_FILES= c.opt common.opt
163 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt)
164 OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt
167 .if exists(${.CURDIR}/${GCC_CPU}-freebsd.opt)
168 OPT_FILES+= ${.CURDIR}/${GCC_CPU}-freebsd.opt
171 .if ${TARGET_CPUARCH} == "powerpc"
172 OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/sysv4.opt
175 .if ${TARGET_CPUARCH} == "sparc64"
176 OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt
179 .if exists(${.CURDIR}/freebsd.opt)
180 OPT_FILES+= ${.CURDIR}/freebsd.opt
183 #-----------------------------------------------------------------------
184 # Build rules for header files and generator tools
188 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
189 HEADERS="auto-host.h ansidecl.h" \
191 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
194 CLEANFILES+= cs-config.h
198 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
199 HEADERS="auto-host.h ansidecl.h" \
201 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
202 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
203 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
207 CLEANFILES+= cs-bconfig.h
211 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
212 HEADERS="auto-host.h ansidecl.h" \
213 DEFINES="USED_FOR_TARGET" \
214 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
217 CLEANFILES+= cs-tconfig.h
220 optionlist: ${OPT_FILES}
221 LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET}
223 options.h: optionlist
224 LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \
225 -f ${GCCDIR}/opth-gen.awk \
226 < ${.ALLSRC} > ${.TARGET}
228 options.c: optionlist
229 LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \
230 -f ${GCCDIR}/optc-gen.awk \
231 -v header_name="config.h system.h coretypes.h tm.h" \
232 < ${.ALLSRC} > ${.TARGET}
233 GENONLY+= optionlist options.h options.c
235 # Target machine config
237 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
238 HEADERS="${TARGET_INC}" \
240 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
241 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
242 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
248 # Target machine protos/preds.
250 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
251 HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \
253 /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h
256 CLEANFILES+= cs-tm_p.h
259 gencheck.h: ${TREE_DEF_FILES}
260 .for F in ${TREE_DEF_FILES}
261 echo "#include \"$F\"" >> ${.TARGET}
268 # Source header for gtyp generator.
269 gtyp-gen.h: ${GTFILES}
270 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET}
271 echo "static const char * const srcdir = " >> ${.TARGET}
272 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET}
273 echo "static const char * const lang_files[] = {" >> ${.TARGET}
274 .for F in ${GTFILES_FILES}
275 echo "\"$F\", " >> ${.TARGET}
277 echo "NULL};" >> ${.TARGET}
278 echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET}
279 .for F in ${GTFILES_LANGS}
280 echo "\"$F\", " >> ${.TARGET}
282 echo "NULL};" >> ${.TARGET}
283 echo "static const char * const all_files[] = {" >> ${.TARGET}
285 echo "\"$F\", " >> ${.TARGET}
287 echo "NULL};" >> ${.TARGET}
288 echo "static const char * const lang_dir_names[] = {" >> ${.TARGET}
289 .for F in c ${GTFILES_LANG_DIR_NAMES}
290 echo "\"$F\", " >> ${.TARGET}
292 echo "NULL};" >> ${.TARGET}
296 # Version header for gcov
298 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET}
302 # Multilib config file
304 .if ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH} == "amd64"
305 echo 'static const char *const multilib_raw[] = { \
307 "64:../lib m64 !m32;", \
308 "32:../lib32 !m64 m32;", NULL };' > ${.TARGET}
309 echo 'static const char *multilib_options = "m64/m32";' >> ${.TARGET}
310 echo 'static const char *const multilib_matches_raw[] = { \
311 "m64 m64;", "m32 m32;", NULL };' >> ${.TARGET}
313 echo 'static const char *const multilib_raw[] = { \
314 ". ;", NULL };' > ${.TARGET}
315 echo 'static const char *multilib_options = "";' >> ${.TARGET}
316 echo 'static const char *const multilib_matches_raw[] = { \
317 NULL };' >> ${.TARGET}
319 echo 'static const char *multilib_extra = "";' >> ${.TARGET}
320 echo 'static const char *const multilib_exclusions_raw[] = { \
321 NULL };' >> ${.TARGET}
326 echo 'static const char configuration_arguments[] =' > ${.TARGET}
327 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET}
328 echo 'static const char thread_model[] = "posix";' >> ${.TARGET}
329 echo 'static const struct {' >> ${.TARGET}
330 echo ' const char *name, *value;' >> ${.TARGET}
331 echo '} configure_default_options[] = {' >> ${.TARGET}
332 echo ' { "NULL", "NULL" } };' >> ${.TARGET}
334 GENSRCS+= configargs.h
336 # Language spec files
338 echo '#include "cp/lang-specs.h"' > ${.TARGET}
343 echo '#include "sys/types.h"' > ${.TARGET}
344 echo '#include "sys/stdint.h"' >> ${.TARGET}
349 gthr-default.h: ${GCCDIR}/gthr-posix.h .NOMETA
350 ln -sf ${.ALLSRC} ${.TARGET}
352 GENSRCS+= gthr-default.h
354 .if ${TARGET_CPUARCH} == "arm"
355 unwind.h: ${GCCDIR}/config/arm/unwind-arm.h
357 unwind.h: ${GCCDIR}/unwind-generic.h
361 ln -sf ${.ALLSRC} ${.TARGET}
368 gengtype-lex.c: gengtype-lex.l
369 flex -ogengtype-lex.c ${.ALLSRC}
371 gengtype-yacc.h: gengtype-yacc.y
372 yacc -d -o gengtype-yacc.c ${.ALLSRC}
374 gengtype-yacc.c: gengtype-yacc.h
376 gengtype-yacc+%DIKED.c: gengtype-yacc.c
377 cat ${.ALLSRC} > ${.TARGET}
378 sed -e "s/xmalloc/malloc/g" \
379 -e "s/xrealloc/realloc/g" \
380 -e "s/malloc/xmalloc/g" \
381 -e "s/realloc/xrealloc/g" \
382 ${.ALLSRC} > ${.TARGET}
384 GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c
385 CLEANFILES+= gengtype-yacc.c
387 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \
389 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
391 gtype-desc.h: gengtype
395 gtype-desc.c: gtype-desc.h
397 GENONLY+= gtype-desc.c gtype-desc.h
398 CLEANFILES+= gt-*.h gtype-*.h
403 .for F in check checksum genrtl modes
404 gen$F: gen$F.o errors.o ${LIBIBERTY}
405 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
408 .for F in attr attrtab automata codes conditions config constants emit \
409 extract flags opinit output peep preds recog
410 gen$F: gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \
411 gensupport.o print-rtl.o errors.o ${LIBIBERTY}
412 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
415 gencondmd: gencondmd.o
416 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
419 # Generated .md files.
421 insn-conditions.md: gencondmd
422 ./gencondmd > ${.TARGET}
423 GENSRCS+= insn-conditions.md
426 # Generated header files.
430 insn-$F.h: gen$F ${MD_FILE}
431 ./gen$F ${MD_FILE} > ${.TARGET}
435 .for F in attr codes config flags
436 insn-$F.h: gen$F ${MD_FILE} insn-conditions.md
437 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
441 # Header files with irregular names.
443 ./gengenrtl -h > ${.TARGET}
447 ./genpreds -h ${MD_FILE} > ${.TARGET}
450 tm-constrs.h: genpreds
451 ./genpreds -c ${MD_FILE} > ${.TARGET}
452 GENSRCS+= tm-constrs.h
454 tree-check.h: gencheck
455 ./gencheck > ${.TARGET}
456 GENSRCS+= tree-check.h
458 insn-modes.h: genmodes
459 ./genmodes -h > ${.TARGET}
460 GENSRCS+= insn-modes.h
463 # Generated source files.
465 .for F in attrtab automata emit extract opinit output peep preds recog
466 insn-$F.c: gen$F ${MD_FILE} insn-conditions.md
467 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
472 insn-$F.c: gen$F ${MD_FILE}
473 ./gen$F ${MD_FILE} > ${.TARGET}
477 # Source files with irregular names.
478 insn-modes.c: genmodes
479 ./genmodes > ${.TARGET}
480 GENONLY+= insn-modes.c
482 min-insn-modes.c: genmodes
483 ./genmodes -m > ${.TARGET}
484 GENSRCS+= min-insn-modes.c
487 ./gengenrtl > ${.TARGET}
490 gencondmd.c: genconditions ${MD_FILE}
491 ./genconditions ${MD_FILE} > ${.TARGET}
492 GENSRCS+= gencondmd.c
494 #-----------------------------------------------------------------------
497 GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \
498 genconditions gencondmd genconfig genconstants genemit \
499 genextract genflags gengenrtl gengtype genmodes genopinit \
500 genoutput genpeep genpreds genrecog
502 all: ${GNTOOLS} ${GENSRCS} ${GENONLY}
503 beforedepend: ${GENONLY}
506 #-----------------------------------------------------------------------
507 # Build 'pocket' libiberty exclusively for build tools use.
509 LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \
510 dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \
511 hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \
512 partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \
513 xmalloc.c xmemdup.c xstrdup.c xstrerror.c
514 LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g}
516 .for _src in ${LIBIBERTY_SRCS}
517 ${_src:R:S/$/.o/}: ${_src}
518 ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC}
521 ${LIBIBERTY}: ${LIBIBERTY_OBJS}
523 @${AR} ${ARFLAGS} ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q`
525 CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS}
528 #-----------------------------------------------------------------------
531 # Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't
532 # define PROG because we have multiple programs.
534 SRCS= errors.c genattr.c genattrtab.c \
535 genautomata.c gencheck.c genchecksum.c gencodes.c \
536 genconditions.c genconfig.c genconstants.c genemit.c \
537 genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \
538 genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \
539 gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \
543 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
544 GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g}
545 CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS}
547 #-----------------------------------------------------------------------
548 # Manual dependencies.
549 .if !exists(${DEPENDFILE})
550 .include "Makefile.dep"
553 .include <bsd.prog.mk>