Makefile revision 182579
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 182579 2008-08-31 23:38:28Z obrien $ 2 3.include <bsd.own.mk> 4 5CFLAGS+= -I. 6 7.include "../Makefile.inc" 8 9CFLAGS+= -g 10CFLAGS+= -DGENERATOR_FILE -DHAVE_CONFIG_H 11 12# Override LIBIBERTY set by Makefile.inc, We use our own for 13# build tools. 14LIBIBERTY= libiberty.a 15 16.PATH: ${GCCDIR} ${GCCLIB}/libiberty 17 18#----------------------------------------------------------------------- 19# Determine content of variables used by the target/host config files 20 21# 22# The list of headers to go into tm.h 23# 24TARGET_INC+= options.h 25.if ${TARGET_ARCH} == "amd64" 26TARGET_INC+= i386/biarch64.h 27.endif 28.if ${TARGET_ARCH} != "arm" 29TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h 30.endif 31.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64" 32TARGET_INC+= ${GCC_CPU}/unix.h 33TARGET_INC+= ${GCC_CPU}/att.h 34.endif 35TARGET_INC+= dbxelf.h 36TARGET_INC+= elfos.h 37TARGET_INC+= freebsd-native.h 38TARGET_INC+= freebsd-spec.h 39TARGET_INC+= freebsd.h 40.if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64" 41. if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h) 42TARGET_INC+= ${GCC_CPU}/sysv4.h 43. endif 44.endif 45.if ${TARGET_ARCH} == "amd64" 46TARGET_INC+= ${GCC_CPU}/x86-64.h 47.endif 48.if ${TARGET_ARCH} == "arm" 49TARGET_INC+= ${GCC_CPU}/elf.h 50.endif 51.if ${TARGET_ARCH} == "arm" 52TARGET_INC+= ${GCC_CPU}/aout.h 53.endif 54TARGET_INC+= ${GCC_CPU}/freebsd.h 55.if ${TARGET_ARCH} == "amd64" 56TARGET_INC+= ${GCC_CPU}/freebsd64.h 57.endif 58.if ${TARGET_ARCH} == "arm" 59TARGET_INC+= ${GCC_CPU}/arm.h 60.endif 61TARGET_INC+= defaults.h 62 63.for H in ${TARGET_INC} 64.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR} 65.if exists($D/$H) 66TARGET_INC_FILES+= $D/$H 67.endif 68.endfor 69.endfor 70 71# 72# gtyp includes. 73# 74srcdir= ${GCCDIR} 75CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \ 76 ${GCCLIB}/libcpp/include/cpplib.h 77SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h 78CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h 79HASHTAB_H= ${GCCLIB}/include/hashtab.h 80SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h 81out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c 82tm_file_list= ${TARGET_INC_FILES} 83host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h 84GTFILES_SRCDIR= ${srcdir} 85 86# Copied unchanged from gcc/Makefile.in 87GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \ 88 $(CPP_ID_DATA_H) $(host_xm_file_list) \ 89 $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \ 90 $(srcdir)/coverage.c $(srcdir)/rtl.h \ 91 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \ 92 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \ 93 $(srcdir)/ipa-reference.h $(srcdir)/output.h \ 94 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \ 95 $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \ 96 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ 97 $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \ 98 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \ 99 $(srcdir)/dojump.c $(srcdir)/tree-profile.c \ 100 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \ 101 $(srcdir)/function.c $(srcdir)/except.h \ 102 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \ 103 $(srcdir)/profile.c $(srcdir)/regclass.c \ 104 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \ 105 $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \ 106 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \ 107 $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \ 108 $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \ 109 $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \ 110 $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \ 111 $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \ 112 $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \ 113 $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \ 114 $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \ 115 $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \ 116 $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \ 117 $(srcdir)/tree-ssa-structalias.c \ 118 $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \ 119 $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \ 120 121# The list of frontend directories to look into 122GTFILES_LANG_DIR_NAMES= 123 124.if ${MK_CXX} != "no" 125GTFILES_LANG_DIR_NAMES+= cp 126.endif 127 128.if ${MK_OBJC} != "no" 129GTFILES_LANG_DIR_NAMES+= objc 130.endif 131 132# The list of language specific files for gengtype 133.for L in ${GTFILES_LANG_DIR_NAMES} c 134.if exists(${GCCDIR}/$L-config-lang.in) 135# Source the language config file 136L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' 137.else 138L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' 139.endif 140.for F in ${L_GTFILES} 141GTFILES_FILES+= $F 142GTFILES_LANGS+= $L 143.endfor 144.endfor 145GTFILES+= ${GTFILES_FILES} 146 147# 148# Tree definition files. 149# 150TREE_DEF_FILES= 151 152.if ${MK_CXX} != "no" 153TREE_DEF_FILES+= cp/cp-tree.def 154.endif 155 156.if ${MK_OBJC} != "no" 157TREE_DEF_FILES+= objc/objc-tree.def 158.endif 159 160# 161# Option files. 162# 163OPT_FILES= c.opt common.opt 164 165.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt) 166OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt 167.endif 168 169.if exists(${.CURDIR}/${GCC_CPU}-freebsd.opt) 170OPT_FILES+= ${.CURDIR}/${GCC_CPU}-freebsd.opt 171.endif 172 173.if ${TARGET_ARCH} == "powerpc" 174OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/sysv4.opt 175.endif 176 177.if ${TARGET_ARCH} == "sparc64" 178OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt 179.endif 180 181.if exists(${.CURDIR}/freebsd.opt) 182OPT_FILES+= ${.CURDIR}/freebsd.opt 183.endif 184 185#----------------------------------------------------------------------- 186# Build rules for header files and generator tools 187 188# Host config 189config.h: 190 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 191 HEADERS="auto-host.h ansidecl.h" \ 192 DEFINES="" \ 193 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} 194 195GENSRCS+= config.h 196CLEANFILES+= cs-config.h 197 198# Build config 199bconfig.h: 200 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 201 HEADERS="auto-host.h ansidecl.h" \ 202 DEFINES="" \ 203 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} 204.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 205 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 206.endif 207 208GENSRCS+= bconfig.h 209CLEANFILES+= cs-bconfig.h 210 211# tconfig.h 212tconfig.h: 213 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 214 HEADERS="auto-host.h ansidecl.h" \ 215 DEFINES="USED_FOR_TARGET" \ 216 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} 217 218GENSRCS+= tconfig.h 219CLEANFILES+= cs-tconfig.h 220# Options 221optionlist: ${OPT_FILES} 222 LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET} 223 224options.h: optionlist 225 LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \ 226 -f ${GCCDIR}/opth-gen.awk \ 227 < ${.ALLSRC} > ${.TARGET} 228 229options.c: optionlist 230 LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \ 231 -f ${GCCDIR}/optc-gen.awk \ 232 -v header_name="config.h system.h coretypes.h tm.h" \ 233 < ${.ALLSRC} > ${.TARGET} 234GENONLY+= optionlist options.h options.c 235 236# Target machine config 237tm.h: 238 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 239 HEADERS="${TARGET_INC}" \ 240 DEFINES="" \ 241 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} 242.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 243 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 244.endif 245 246GENSRCS+= tm.h 247CLEANFILES+= cs-tm.h 248 249# Target machine protos/preds. 250tm_p.h: 251 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 252 HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \ 253 DEFINES="" \ 254 /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h 255 256GENSRCS+= tm_p.h 257CLEANFILES+= cs-tm_p.h 258 259# gencheck 260gencheck.h: ${TREE_DEF_FILES} 261.for F in ${TREE_DEF_FILES} 262 echo "#include \"$F\"" >> ${.TARGET} 263.endfor 264 touch ${.TARGET} 265 266GENSRCS+= gencheck.h 267 268 269# Source header for gtyp generator. 270gtyp-gen.h: ${GTFILES} 271 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET} 272 echo "static const char * const srcdir = " >> ${.TARGET} 273 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET} 274 echo "static const char * const lang_files[] = {" >> ${.TARGET} 275.for F in ${GTFILES_FILES} 276 echo "\"$F\", " >> ${.TARGET} 277.endfor 278 echo "NULL};" >> ${.TARGET} 279 echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET} 280.for F in ${GTFILES_LANGS} 281 echo "\"$F\", " >> ${.TARGET} 282.endfor 283 echo "NULL};" >> ${.TARGET} 284 echo "static const char * const all_files[] = {" >> ${.TARGET} 285.for F in ${GTFILES} 286 echo "\"$F\", " >> ${.TARGET} 287.endfor 288 echo "NULL};" >> ${.TARGET} 289 echo "static const char * const lang_dir_names[] = {" >> ${.TARGET} 290.for F in c ${GTFILES_LANG_DIR_NAMES} 291 echo "\"$F\", " >> ${.TARGET} 292.endfor 293 echo "NULL};" >> ${.TARGET} 294 295GENSRCS+= gtyp-gen.h 296 297# Version header for gcov 298gcov-iov.h: 299 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET} 300 301GENSRCS+= gcov-iov.h 302 303# Multilib config file 304multilib.h: 305 echo 'static const char *const multilib_raw[] = { \ 306 ". ;", NULL };' > ${.TARGET} 307 echo 'static const char *const multilib_matches_raw[] = { \ 308 NULL };' >> ${.TARGET} 309 echo 'static const char *multilib_extra = "";' >> ${.TARGET} 310 echo 'static const char *multilib_options = "";' >> ${.TARGET} 311 echo 'static const char *const multilib_exclusions_raw[] = { \ 312 NULL };' >> ${.TARGET} 313 314GENSRCS+= multilib.h 315 316configargs.h: 317 echo 'static const char configuration_arguments[] =' > ${.TARGET} 318 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET} 319 echo 'static const char thread_model[] = "posix";' >> ${.TARGET} 320 echo 'static const struct {' >> ${.TARGET} 321 echo ' const char *name, *value;' >> ${.TARGET} 322 echo '} configure_default_options[] = {' >> ${.TARGET} 323 echo ' { "NULL", "NULL" } };' >> ${.TARGET} 324 325GENSRCS+= configargs.h 326 327# Language spec files 328specs.h: 329 echo '#include "cp/lang-specs.h"' > ${.TARGET} 330 echo '#include "objc/lang-specs.h"' >> ${.TARGET} 331 332GENSRCS+= specs.h 333 334gstdint.h: 335 echo '#include "sys/types.h"' > ${.TARGET} 336 echo '#include "sys/stdint.h"' >> ${.TARGET} 337 338GENSRCS+= gstdint.h 339 340# Linked headers 341gthr-default.h: ${GCCDIR}/gthr-posix.h 342 ln -sf ${.ALLSRC} ${.TARGET} 343 344GENSRCS+= gthr-default.h 345 346unwind.h: ${GCCDIR}/unwind-generic.h 347 ln -sf ${.ALLSRC} ${.TARGET} 348 349GENSRCS+= unwind.h 350 351# 352# gtype gunk 353# 354gengtype-lex.c: gengtype-lex.l 355 flex -ogengtype-lex.c ${.ALLSRC} 356 357gengtype-yacc.h: gengtype-yacc.y 358 yacc -d -o gengtype-yacc.c ${.ALLSRC} 359 360gengtype-yacc.c: gengtype-yacc.h 361 362gengtype-yacc+%DIKED.c: gengtype-yacc.c 363 cat ${.ALLSRC} > ${.TARGET} 364 sed -e "s/xmalloc/malloc/g" \ 365 -e "s/xrealloc/realloc/g" \ 366 -e "s/malloc/xmalloc/g" \ 367 -e "s/realloc/xrealloc/g" \ 368 ${.ALLSRC} > ${.TARGET} 369 370GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c 371CLEANFILES+= gengtype-yacc.c 372 373gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \ 374 ${LIBIBERTY} 375 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 376 377gtype-desc.h: gengtype 378 ./gengtype 379 touch ${.TARGET} 380 381gtype-desc.c: gtype-desc.h 382 383GENONLY+= gtype-desc.c gtype-desc.h 384CLEANFILES+= gt-*.h gtype-*.h 385 386# 387# Generator tools. 388# 389.for F in check checksum genrtl modes 390gen$F: gen$F.o errors.o ${LIBIBERTY} 391 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 392.endfor 393 394.for F in attr attrtab automata codes conditions config constants emit \ 395 extract flags opinit output peep preds recog 396gen$F: gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \ 397 gensupport.o print-rtl.o errors.o ${LIBIBERTY} 398 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm 399.endfor 400 401gencondmd: gencondmd.o 402 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 403 404# 405# Generated .md files. 406# 407insn-conditions.md: gencondmd 408 ./gencondmd > ${.TARGET} 409GENSRCS+= insn-conditions.md 410 411# 412# Generated header files. 413# 414 415.for F in constants 416insn-$F.h: gen$F ${MD_FILE} 417 ./gen$F ${MD_FILE} > ${.TARGET} 418GENSRCS+= insn-$F.h 419.endfor 420 421.for F in attr codes config flags 422insn-$F.h: gen$F ${MD_FILE} insn-conditions.md 423 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} 424GENSRCS+= insn-$F.h 425.endfor 426 427# Header files with irregular names. 428genrtl.h: gengenrtl 429 ./gengenrtl -h > ${.TARGET} 430GENSRCS+= genrtl.h 431 432tm-preds.h: genpreds 433 ./genpreds -h ${MD_FILE} > ${.TARGET} 434GENSRCS+= tm-preds.h 435 436tm-constrs.h: genpreds 437 ./genpreds -c ${MD_FILE} > ${.TARGET} 438GENSRCS+= tm-constrs.h 439 440tree-check.h: gencheck 441 ./gencheck > ${.TARGET} 442GENSRCS+= tree-check.h 443 444insn-modes.h: genmodes 445 ./genmodes -h > ${.TARGET} 446GENSRCS+= insn-modes.h 447 448# 449# Generated source files. 450# 451.for F in attrtab automata emit extract opinit output peep preds recog 452insn-$F.c: gen$F ${MD_FILE} insn-conditions.md 453 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} 454GENONLY+= insn-$F.c 455.endfor 456 457.for F in conditions 458insn-$F.c: gen$F ${MD_FILE} 459 ./gen$F ${MD_FILE} > ${.TARGET} 460GENSRCS+= insn-$F.c 461.endfor 462 463# Source files with irregular names. 464insn-modes.c: genmodes 465 ./genmodes > ${.TARGET} 466GENONLY+= insn-modes.c 467 468min-insn-modes.c: genmodes 469 ./genmodes -m > ${.TARGET} 470GENSRCS+= min-insn-modes.c 471 472genrtl.c: gengenrtl 473 ./gengenrtl > ${.TARGET} 474GENONLY+= genrtl.c 475 476gencondmd.c: genconditions ${MD_FILE} 477 ./genconditions ${MD_FILE} > ${.TARGET} 478GENSRCS+= gencondmd.c 479 480#----------------------------------------------------------------------- 481# Build tools. 482 483GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \ 484 genconditions gencondmd genconfig genconstants genemit \ 485 genextract genflags gengenrtl gengtype genmodes genopinit \ 486 genoutput genpeep genpreds genrecog 487 488all: ${GNTOOLS} ${GENSRCS} ${GENONLY} 489beforedepend: ${GENONLY} 490 491# 492#----------------------------------------------------------------------- 493# Build 'pocket' libiberty exclusively for build tools use. 494 495LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ 496 dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \ 497 hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \ 498 partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \ 499 xmalloc.c xmemdup.c xstrdup.c xstrerror.c 500LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g} 501 502.for _src in ${LIBIBERTY_SRCS} 503${_src:R:S/$/.o/}: ${_src} 504 ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC} 505.endfor 506 507${LIBIBERTY}: ${LIBIBERTY_OBJS} 508 @rm -f ${.TARGET} 509 @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` 510 ${RANLIB} ${.TARGET} 511CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS} 512 513 514#----------------------------------------------------------------------- 515# Fixups. 516 517# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't 518# define PROG because we have multiple programs. 519# 520SRCS= errors.c genattr.c genattrtab.c \ 521 genautomata.c gencheck.c genchecksum.c gencodes.c \ 522 genconditions.c genconfig.c genconstants.c genemit.c \ 523 genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \ 524 genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \ 525 gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \ 526 vec.c 527 528SRCS+= ${GENSRCS} 529OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 530GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g} 531CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS} 532 533#----------------------------------------------------------------------- 534# Manual dependencies. 535.if !exists(${DEPENDFILE}) 536.include "Makefile.dep" 537.endif 538 539.include <bsd.prog.mk> 540# DO NOT DELETE 541