Makefile revision 52648
152419Sjulian# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 52648 1999-10-30 08:08:29Z obrien $ 252419Sjulian 352419Sjulian# 452419Sjulian# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk 552419Sjulian# is such a !@#!*#% nightmare because of how it reprograms the dependencies, 652419Sjulian# suffix rules, SRCS, etc. It's easiest to cheat by using bsd.prog.mk and 752419Sjulian# SRCS to get dependencies. 852419Sjulian# 952419Sjulian 1052419Sjulian# ../Makefile.inc will put an absolute path to our objdir in CFLAGS. 1152419Sjulian# Prevent mkdep from using it, so that we don't have to give rules for 1252419Sjulian# aliases of generated headers. 1352419Sjulian 1452419SjulianCFLAGS+= -I. 1552419Sjulian 1652419Sjulian.include "../Makefile.inc" 1752419Sjulian 1852419Sjulian.PATH: ${GCCDIR} ${GCCDIR}/cp 1952419Sjulian 2052419SjulianCFLAGS+= -I${GCCDIR}/objc 2152419Sjulian 2252419Sjulian#----------------------------------------------------------------------- 2352419Sjulian# insn-* gunk 2452419Sjulian 2552419Sjulian.for i in attr codes config flags 2652419Sjulianinsn-$i.h: gen$i ${MD_FILE} 2752419Sjulian ./gen$i ${MD_FILE} > insn-$i.h 2852419SjulianGENSRCS+= insn-$i.h 2952419Sjulian.endfor 3052419Sjulian 3152419Sjulian.for i in attrtab emit extract opinit output peep recog 3252419Sjulianinsn-$i.c: gen$i ${MD_FILE} 3352419Sjulian ./gen$i ${MD_FILE} > insn-$i.c 3452419SjulianGENSRCS+= insn-$i.c 3552419Sjulian.endfor 3652419Sjulian 3752419Sjulian.for i in attr codes config emit extract flags opinit output peep recog 3852419Sjulianbuild-tools: gen$i 3952419Sjulian 4052419Sjuliangen$i: gen$i.o rtl.o obstack.o bitmap.o 4152419Sjulian ${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 4252419Sjulian 4352419SjulianGENSRCS+= gen$i.c 4452419SjulianCLEANFILES+= gen$i 4552419Sjulian.endfor 4652419Sjulian 4752419Sjulian.for i in attrtab 4852419Sjulianbuild-tools: gen$i 4952419Sjulian 5052419Sjuliangen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o 5152419Sjulian ${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 5252419Sjulian 5352419SjulianGENSRCS+= gen$i.c 5452419SjulianCLEANFILES+= gen$i 5552419Sjulian.endfor 56 57SRCS+= bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c 58 59.for i in check genrtl 60build-tools: gen$i 61 62gen$i: gen$i.o 63 ${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 64 65GENSRCS+= gen$i.c 66CLEANFILES+= gen$i 67.endfor 68 69.ORDER: genrtl.c genrtl.h 70genrtl.c genrtl.h: gengenrtl 71 ./gengenrtl genrtl.h genrtl.c 72 73GENSRCS+= genrtl.c genrtl.h 74 75#----------------------------------------------------------------------- 76# C hash codes 77c-gperf.h: c-parse.gperf 78 gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \ 79 ${GCCDIR}/c-parse.gperf > ${.TARGET} 80GENSRCS+= c-gperf.h 81 82#----------------------------------------------------------------------- 83# C++ hash codes 84gxx-hash.h: gxx.gperf 85 gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \ 86 ${GCCDIR}/cp/gxx.gperf >gxx-hash.h 87GENSRCS+= gxx-hash.h 88 89# make a link the the Cygnus used name for now -- hopes are they will change it 90hash.h: gxx-hash.h 91 ln -sf ${.ALLSRC} ${.TARGET} 92GENSRCS+= hash.h 93 94#----------------------------------------------------------------------- 95# Common parser stuff. 96 97tree-check.h: gencheck 98 ./gencheck > ${.TARGET} 99GENSRCS+= tree-check.h 100 101#----------------------------------------------------------------------- 102# C parser 103.ORDER: c-parse.c c-parse.h 104c-parse.c c-parse.h: c-parse.in 105 sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \ 106 -e "/^ifc$$/d" -e "/^end ifc$$/d" \ 107 ${GCCDIR}/c-parse.in > c-parse.y 108 ${YACC} -d -o c-parse.c c-parse.y 109 mv c-parse.y c-parse.y.out 110 111GENSRCS+= c-parse.c c-parse.h 112CLEANFILES+= c-parse.y c-parse.y.out # insurance 113 114#----------------------------------------------------------------------- 115# objc parser 116.ORDER: objc-parse.c objc-parse.h 117objc-parse.c objc-parse.h: c-parse.in 118 sed -e "/^ifc$$/,/^end ifc$$/d" \ 119 -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \ 120 ${GCCDIR}/c-parse.in > objc-parse.y 121 ${YACC} -d -o objc-parse.c objc-parse.y 122 mv objc-parse.y objc-parse.y.out 123 124GENSRCS+= objc-parse.c objc-parse.h 125CLEANFILES+= objc-parse.y objc-parse.y.out # insurance 126 127#----------------------------------------------------------------------- 128# C++ parser done in its own makefile 129#----------------------------------------------------------------------- 130# CPP parser done in its own makefile 131#----------------------------------------------------------------------- 132# the host/target compiler config. 133 134COMMONHDRS= config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h 135GENSRCS+= ${COMMONHDRS} 136 137config.h hconfig.h: 138 echo '#include "auto-host.h"' > ${.TARGET} 139 echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"' >> ${.TARGET} 140 141multilib.h: 142 echo 'static char *multilib_raw[] = { \ 143 "aout maout;", "elf !maout;", NULL };' > ${.TARGET} 144 echo 'static char *multilib_matches_raw[] = { \ 145 "maout maout;", "melf melf;", NULL };' >> ${.TARGET} 146 echo 'static char *multilib_extra = "";' >> ${.TARGET} 147 148options.h: 149 echo '#include "cp/lang-options.h"' > ${.TARGET} 150 echo '#include "f/lang-options.h"' >> ${.TARGET} 151 152specs.h: 153 echo '#include "cp/lang-specs.h"' > ${.TARGET} 154 echo '#include "f/lang-specs.h"' >> ${.TARGET} 155 156tconfig.h: 157 echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"' > ${.TARGET} 158 159tm.h: 160 echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"' > ${.TARGET} 161.if ${GCC_ARCH} == "i386" 162 echo '#include "${GCC_ARCH}/att.h"' >> ${.TARGET} 163 echo '#include "svr4.h"' >> ${.TARGET} 164.endif 165 echo '#include "${GCC_ARCH}/freebsd.h"' >> ${.TARGET} 166.if ${GCC_ARCH} == "i386" 167 echo '#include "${GCC_ARCH}/perform.h"' >> ${.TARGET} 168.endif 169 echo '#include <freebsd-native.h>' >> ${.TARGET} 170 171#----------------------------------------------------------------------- 172# General things. 173 174SRCS+= ${GENSRCS} 175CLEANFILES+= ${GENSRCS} 176 177all: ${SRCS} 178 179.include <bsd.prog.mk> 180 181#----------------------------------------------------------------------- 182# Fixups. 183 184# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't 185# define PROG because we have multiple programs. 186# 187OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 188 189.if !exists(${DEPENDFILE}) 190# Fudge pre-dependfile dependencies of objects in much the same way as 191# bsd.prog.mk would do if we defined PROG. There are complications to 192# avoid circular dependencies. First, only make most objects depend on 193# all headers. Filter out the objects that would cause problems (i.e., 194# objects that will be used to create programs that will generate headers). 195# 196${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nrtl.o}: ${SRCS:M*.h} 197 198# Next, make each of the problematic objects depend on only most headers. 199# Filter out the headers that would cause problems (and a few more when it 200# is inconvenient to filter precisely). 201# 202bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o rtl.o: \ 203 ${SRCS:M*.h:Ninsn-*.h} 204gencheck.o: ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h} 205gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h} 206.endif 207