Makefile revision 132751
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 132751 2004-07-28 05:27:21Z kan $ 2 3# 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. 8# 9 10# 11# ../Makefile.inc will put an absolute path to our objdir in CFLAGS. 12# Prevent mkdep from using it, so that we don't have to give rules for 13# aliases of generated headers. 14# 15CFLAGS+= -I. 16 17.include "../Makefile.inc" 18 19.PATH: ${GCCDIR} ${GCCDIR}/f 20 21CFLAGS+= -DGENERATOR_FILE 22 23# 24#----------------------------------------------------------------------- 25# Build 'pocket' libiberty exclusively for build tools use. 26 27LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ 28 dyn-string.c errors.c fibheap.c \ 29 getpwd.c getruntime.c hashtab.c hex.c lbasename.c make-temp-file.c \ 30 md5.c obstack.c partition.c pexecute.c physmem.c splay-tree.c xexit.c \ 31 xmalloc.c xmemdup.c xstrdup.c xstrerror.c xexit.c 32LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g} 33 34SRCS+= ${LIBIBERTY_SRCS} 35 36LIBIBERTY=libiberty.a 37${LIBIBERTY}: ${LIBIBERTY_OBJS} 38 @rm -f ${.TARGET} 39 @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` 40 ${RANLIB} ${.TARGET} 41CLEANFILES+= ${LIBIBERTY} 42 43# 44#----------------------------------------------------------------------- 45# options 46OPTION_FILES=${GCCDIR}/f/lang.opt ${GCCDIR}/c.opt ${GCCDIR}/common.opt 47 48.ORDER: options.h options.c 49options.h options.c: opts.sh ${OPTION_FILES} 50 /bin/sh ${GCCDIR}/opts.sh mv options.c options.h ${OPTION_FILES} 51 52 53GENSRCS+= options.c options.h 54CLEANFILES+= options.c options.h 55 56#----------------------------------------------------------------------- 57# insn-* gunk 58 59.for F in attr codes config flags constants 60insn-$F.h: gen$F ${MD_FILE} 61 ./gen$F ${MD_FILE} > insn-$F.h 62GENSRCS+= insn-$F.h 63.endfor 64 65.for F in conditions 66insn-$F.c: gen$F ${MD_FILE} 67 ./gen$F ${MD_FILE} > insn-$F.c 68GENSRCS+= insn-$F.c 69.endfor 70 71GENSRCS+= gen-time-stamp 72gen-time-stamp: genattr genattrtab genconditions genconstants genemit \ 73 genextract gengtype genopinit genoutput genpeep genrecog 74 touch ${.TARGET} 75 76.for F in attr codes config emit extract flags opinit output peep recog 77build-tools: gen$F 78 79gen$F: gen$F.o rtl.o print-rtl.o bitmap.o gensupport.o ggc-none.o \ 80 read-rtl.o insn-conditions.o min-insn-modes.o ${LIBIBERTY} 81 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 82 83GENSRCS+= gen$F.c 84CLEANFILES+= gen$F 85.endfor 86 87# 88# genattrtab needs more complex build rule 89# 90build-tools: genattrtab 91 92genattrtab : genattrtab.o rtl.o print-rtl.o bitmap.o gensupport.o ggc-none.o \ 93 read-rtl.o insn-conditions.o genautomata.o varray.o min-insn-modes.o \ 94 ${LIBIBERTY} 95 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm 96 97GENSRCS+= genattrtab.c 98CLEANFILES+= genattrtab 99 100# 101# genconstants and genconditions cannot depend on insn-conditions.o 102# they should be liked with dummy-conditions.o stubs instead 103# 104.for F in constants conditions 105build-tools: gen$F 106 107gen$F: gen$F.o rtl.o bitmap.o gensupport.o ggc-none.o read-rtl.o dummy-conditions.o min-insn-modes.o ${LIBIBERTY} 108 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 109 110GENSRCS+= gen$F.c 111CLEANFILES+= gen$F 112.endfor 113 114.for F in modes check genrtl preds 115build-tools: gen$F 116 117gen$F: gen$F.o ${LIBIBERTY} 118 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 119 120GENSRCS+= gen$F.c 121CLEANFILES+= gen$F 122.endfor 123 124.ORDER: genrtl.c genrtl.h 125genrtl.c genrtl.h: gengenrtl 126 ./gengenrtl > genrtl.c 127 ./gengenrtl -h > genrtl.h 128 129GENSRCS+= genrtl.c genrtl.h 130 131SRCS+= bitmap.c concat.c dummy-conditions.c genautomata.c \ 132 gensupport.c getruntime.c ggc-none.c hashtab.c \ 133 obstack.c physmem.c print-rtl.c read-rtl.c rtl.c varray.c xmemdup.c 134 135#----------------------------------------------------------------------- 136# insn modes stuff. 137 138.ORDER: insn-modes.c insn-modes.h 139insn-modes.h: genmodes 140 ./genmodes -h > insn-modes.h 141 142insn-modes.c: genmodes 143 ./genmodes > insn-modes.c 144 145min-insn-modes.c: genmodes 146 ./genmodes -m > min-insn-modes.c 147 148GENSRCS+= insn-modes.c min-insn-modes.c insn-modes.h 149 150#----------------------------------------------------------------------- 151# Common parser stuff. 152 153tree-check.h: gencheck 154 ./gencheck > ${.TARGET} 155GENSRCS+= tree-check.h 156 157#----------------------------------------------------------------------- 158# Predicates stuff. 159 160tm-preds.h: genpreds 161 ./genpreds > ${.TARGET} 162GENSRCS+= tm-preds.h 163 164#----------------------------------------------------------------------- 165# Gengtype 166 167gengtype-lex.c : gengtype-lex.l 168 ${LEX} -t ${.ALLSRC} | \ 169 sed 's/^\(char msg\[\];\)/yyconst \1/' > ${.TARGET} 170 171.ORDER: gengtype-yacc.c gengtype-yacc.h 172gengtype-yacc.c gengtype-yacc.h: gengtype-yacc.y 173 ${YACC} -d -o gengtype-yacc.c ${.ALLSRC} 174 175GENSRCS+= gengtype-yacc+%DIKED.c gengtype-yacc.h gengtype-lex.c 176CLEANFILES+= gengtype-yacc.c 177 178gengtype-yacc+%DIKED.c: gengtype-yacc.c 179 cat ${.ALLSRC} > ${.TARGET} 180 sed -e "s/xmalloc/malloc/g" \ 181 -e "s/xrealloc/realloc/g" \ 182 -e "s/malloc/xmalloc/g" \ 183 -e "s/realloc/xrealloc/g" \ 184 ${.ALLSRC} > ${.TARGET} 185 186gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o ${LIBIBERTY} 187 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 188 189GENSRCS+= gengtype.c 190CLEANFILES+= gengtype 191 192gengtype-lex.o: gengtype-yacc.h 193 194.ORDER: gtype-desc.c gtype-desc.h 195gtype-desc.c gtype-desc.h: gtype-time-stamp 196 @true 197 198GENSRCS+= gtype-time-stamp 199gtype-time-stamp: gengtype ${GTFILES} 200 ./gengtype 201 touch ${.TARGET} 202 203GENSRCS+= gtype-desc.c gtype-desc.h 204CLEANFILES+= gt-*.h gtype-*.h 205 206# 207#----------------------------------------------------------------------- 208# Fortran build tools 209 210.if !defined(NO_FORTRAN) 211gen-time-stamp: fini 212build-tools: fini 213fini: fini.o ${LIBIBERTY} 214 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 215SRCS+= fini.c 216CLEANFILES+= fini 217.endif 218 219#----------------------------------------------------------------------- 220# Determine content of variables used by the target/host config files 221 222# 223# The list of headers to go into tm.h 224# 225.if ${TARGET_ARCH} == "amd64" 226TARGET_INC= i386/biarch64.h 227.endif 228TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h 229.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64" 230TARGET_INC+= ${GCC_CPU}/unix.h 231TARGET_INC+= ${GCC_CPU}/att.h 232.endif 233.if ${TARGET_ARCH} != "alpha" 234TARGET_INC+= dbxelf.h 235TARGET_INC+= elfos.h 236.endif 237TARGET_INC+= freebsd-native.h 238TARGET_INC+= freebsd-spec.h 239TARGET_INC+= freebsd.h 240.if ${TARGET_ARCH} == "alpha" 241TARGET_INC+= ${GCC_CPU}/elf.h 242.endif 243.if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64" 244.if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h) 245TARGET_INC+= ${GCC_CPU}/sysv4.h 246.endif 247.endif 248TARGET_INC+= ${GCC_CPU}/freebsd.h 249.if ${TARGET_ARCH} == "amd64" 250TARGET_INC+= ${GCC_CPU}/x86-64.h 251TARGET_INC+= ${GCC_CPU}/freebsd64.h 252TARGET_INC+= freebsd64-fix.h 253.endif 254.if ${TARGET_ARCH} == "powepc" 255TARGET_INC+= altivec-defs.h 256.endif 257TARGET_INC+= defaults.h 258 259# 260# Use TARGET_INC as a template and build a list of target specific 261# include files for gengtype to scan 262# 263GCONFIG_H= ${.CURDIR}/auto-host.h 264 265.for H in ${TARGET_INC} 266.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR} 267.if exists($D/$H) 268GCONFIG_H+= $D/$H 269.endif 270.endfor 271.endfor 272 273# 274# Define some variables to make blocks copied from Makefile.in happy 275# 276srcdir= ${GCCDIR} 277HASHTAB_H= ${GCCDIR}/hashtab.h 278SPLAY_TREE_H= ${GCCDIR}/splay-tree.h 279out_file= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.c 280GTFILES_SRCDIR= ${GCCDIR} 281 282# 283# Copied unchanged from gcc/Makefile.in 284# 285GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h $(srcdir)/cpplib.h \ 286 $(GCONFIG_H) $(HASHTAB_H) $(SPLAY_TREE_H) \ 287 $(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \ 288 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \ 289 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h \ 290 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \ 291 $(srcdir)/c-common.h $(srcdir)/c-tree.h \ 292 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ 293 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \ 294 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \ 295 $(srcdir)/fold-const.c $(srcdir)/function.c \ 296 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \ 297 $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \ 298 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c $(srcdir)/langhooks.c \ 299 $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \ 300 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c $(out_file) 301 302# 303# Build a list of frontend directories to look into 304# 305GTFILES_LANG_DIR_NAMES= 306 307.if !defined(NO_CXX) 308GTFILES_LANG_DIR_NAMES+= cp 309.endif 310 311.if !defined(NO_OBJC) 312GTFILES_LANG_DIR_NAMES+= objc 313.endif 314 315.if !defined(NO_FORTRAN) 316GTFILES_LANG_DIR_NAMES+= f 317.endif 318 319# 320# Build a list of language specific files for gengtype 321# 322.for L in ${GTFILES_LANG_DIR_NAMES} c 323.if exists(${GCCDIR}/$L-config-lang.in) 324# Source the language config file 325L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' 326.else 327L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' 328.endif 329.for F in ${L_GTFILES} 330GTFILES_FILES+= $F 331GTFILES_LANGS+= $L 332.endfor 333.endfor 334GTFILES+= ${GTFILES_FILES} 335 336#----------------------------------------------------------------------- 337# the host/target compiler config. 338 339COMMONHDRS= bconfig.h config.h configargs.h gencheck.h multilib.h \ 340 specs.h safe-ctype.h tconfig.h tm.h tm_p.h gcov-iov.h \ 341 gtyp-gen.h 342GENSRCS+= ${COMMONHDRS} 343 344MFILE?= ${.CURDIR}/Makefile 345${COMMONHDRS}: ${MFILE} 346 347configargs.h: 348 echo 'static const char configuration_arguments[] =' > ${.TARGET} 349 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET} 350 echo 'static const char thread_model[] = "posix";' >> ${.TARGET} 351 echo 'static const struct {' >> ${.TARGET} 352 echo ' const char *name, *value;' >> ${.TARGET} 353 echo '} configure_default_options[] = {' >> ${.TARGET} 354 echo ' { "NULL", "NULL" } };' >> ${.TARGET} 355 356tconfig.h: 357 echo '#ifndef GCC_TCONFIG_H' > ${.TARGET} 358 echo '#define GCC_TCONFIG_H' >> ${.TARGET} 359 echo '#ifdef IN_GCC' >> ${.TARGET} 360 echo '# include "ansidecl.h"' >> ${.TARGET} 361 echo '#endif' >> ${.TARGET} 362 echo '#define USED_FOR_TARGET' >> ${.TARGET} 363 echo '#endif /* GCC_TCONFIG_H */' >> ${.TARGET} 364 365bconfig.h: 366 echo '#ifndef GCC_BCONFIG_H' > ${.TARGET} 367 echo '#define GCC_BCONFIG_H' >> ${.TARGET} 368 echo '#include "auto-host.h"' >> ${.TARGET} 369.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 370 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 371.endif 372 echo '#ifdef IN_GCC' >> ${.TARGET} 373 echo '# include "ansidecl.h"' >> ${.TARGET} 374 echo '#endif' >> ${.TARGET} 375 echo '#endif /* GCC_BCONFIG_H */' >> ${.TARGET} 376 377gencheck.h: 378 echo '#include "cp/cp-tree.def"' > ${.TARGET} 379 echo '#include "objc/objc-tree.def"' >> ${.TARGET} 380 381multilib.h: 382 echo 'static const char *const multilib_raw[] = { \ 383 "aout maout;", "elf !maout;", NULL };' > ${.TARGET} 384 echo 'static const char *const multilib_matches_raw[] = { \ 385 "maout maout;", "melf melf;", NULL };' >> ${.TARGET} 386 echo 'static const char *multilib_extra = "";' >> ${.TARGET} 387 echo 'static const char *multilib_options = "";'>> ${.TARGET} 388 echo 'static const char *const multilib_exclusions_raw[] = { \ 389 NULL };' >> ${.TARGET} 390 391specs.h: 392 echo '#include "cp/lang-specs.h"' > ${.TARGET} 393 echo '#include "f/lang-specs.h"' >> ${.TARGET} 394 echo '#include "objc/lang-specs.h"' >> ${.TARGET} 395 396config.h: bconfig.h 397 echo '#include <bconfig.h>' > ${.TARGET} 398 399tm.h: 400 echo '#ifndef GCC_TM_H' > ${.TARGET} 401 echo '#define GCC_TM_H' >> ${.TARGET} 402.if defined(TARGET_CPU_DEFAULT) 403 echo "#define TARGET_CPU_DEFAULT (${TARGET_CPU_DEFAULT})" >> ${.TARGET} 404.endif 405 echo '#ifdef IN_GCC' >> ${.TARGET} 406.for H in ${TARGET_INC} 407 echo '#include "$H"' >> ${.TARGET} 408.endfor 409 echo '#if !defined GENERATOR_FILE && !defined USED_FOR_TARGET' >> ${.TARGET} 410 echo '# include "insn-constants.h"' >> ${.TARGET} 411 echo '# include "insn-flags.h"' >> ${.TARGET} 412 echo '#endif' >> ${.TARGET} 413 echo '#endif' >> ${.TARGET} 414.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 415 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 416.endif 417 echo '#endif /* GCC_TM_H */' >> ${.TARGET} 418 419tm_p.h: 420 echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"' >> ${.TARGET} 421 echo '#include "tm-preds.h"' >> ${.TARGET} 422 423safe-ctype.h: 424 echo '#include <ctype.h>' > ${.TARGET} 425.for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \ 426 ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL 427 echo '#define ${Z} ${Z:L}' >> ${.TARGET} 428.endfor 429 echo "#define ISIDST(x) \ 430 ((x) == '_' || isalpha(x))" >> ${.TARGET} 431 echo "#define ISIDNUM(x) \ 432 (isdigit(x) || ISIDST(x))" >> ${.TARGET} 433 echo "#define IS_VSPACE(x) \ 434 ((x) == '\n' || (x) == '\r')" >> ${.TARGET} 435 echo "#define IS_NVSPACE(x) \ 436 (!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))" >> ${.TARGET} 437 echo "#define IS_SPACE_OR_NUL(x) \ 438 (isspace(x) || (x) == '\0')" >> ${.TARGET} 439 440gtyp-gen.h: 441 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET} 442 echo "static const char *srcdir = " >> ${.TARGET} 443 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET} 444 echo "static const char *lang_files[] = {" >> ${.TARGET} 445.for F in ${GTFILES_FILES} 446 echo "\"$F\", " >> ${.TARGET} 447.endfor 448 echo "NULL};" >> ${.TARGET} 449 echo "static const char *langs_for_lang_files[] = {" >> ${.TARGET} 450.for F in ${GTFILES_LANGS} 451 echo "\"$F\", " >> ${.TARGET} 452.endfor 453 echo "NULL};" >> ${.TARGET} 454 echo "static const char *all_files[] = {" >> ${.TARGET} 455.for F in ${GTFILES} 456 echo "\"$F\", " >> ${.TARGET} 457.endfor 458 echo "NULL};" >> ${.TARGET} 459 echo "static const char *lang_dir_names[] = { \"c\", " >> ${.TARGET} 460.for F in ${GTFILES_LANG_DIR_NAMES} 461 echo "\"$F\", " >> ${.TARGET} 462.endfor 463 echo "NULL};" >> ${.TARGET} 464 465gcov-iov.h: 466 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x33303470)" >> ${.TARGET} 467 468#----------------------------------------------------------------------- 469# General things. 470 471SRCS+= ${GENSRCS} 472CLEANFILES+= ${GENSRCS} 473 474all: ${SRCS} 475build-tools: ${SRCS} 476 477.include <bsd.prog.mk> 478 479#----------------------------------------------------------------------- 480# Fixups. 481 482# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't 483# define PROG because we have multiple programs. 484# 485OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 486CLEANFILES+= ${OBJS} 487 488.if !exists(${DEPENDFILE}) 489# Fudge pre-dependfile dependencies of objects in much the same way as 490# bsd.prog.mk would do if we defined PROG. 491 492${OBJS}: ${COMMONHDRS} 493 494dummy-conditions.o: 495gencheck.o: 496genmodes.o: 497 498genpreds.o: insn-modes.h 499genconstants.o: insn-modes.h genrtl.h 500gengtype.o: insn-modes.h genrtl.h gtyp-gen.h 501rtl.o: insn-modes.h gtype-desc.h genrtl.h 502bitmap.o: insn-modes.h gtype-desc.h genrtl.h 503ggc-none.o: gtype-desc.h 504gensupport.o: insn-modes.h genrtl.h 505varray.o: gtype-desc.h 506genautomata.o: insn-modes.h genrtl.h 507genconditions.o: insn-modes.h genrtl.h 508gencodes.o: insn-modes.h genrtl.h 509genconfig.o: insn-modes.h genrtl.h 510print-rtl.o: insn-modes.h genrtl.h tm-preds.h tree-check.h 511read-rtl.o: insn-modes.h genrtl.h 512genattr.o: insn-modes.h genrtl.h 513genemit.o: insn-modes.h genrtl.h 514genflags.o: insn-modes.h genrtl.h 515genopinit.o: insn-modes.h genrtl.h 516genoutput.o: insn-modes.h genrtl.h 517genpeep.o: insn-modes.h genrtl.h 518genrecog.o: insn-modes.h genrtl.h 519genextract.o: genrtl.h insn-config.h 520genattrtab.o: insn-modes.h gtype-desc.h genrtl.h 521genrtl.o: insn-modes.h genrtl.h gtype-desc.h 522 523insn-conditions.o: insn-constants.h tm-preds.h 524insn-modes.o: insn-modes.h 525min-insn-modes.o: insn-modes.h 526gtype-desc.o: insn-modes.h insn-config.h insn-codes.h tree-check.h 527 528.endif 529