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