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