1 # $FreeBSD: src/gnu/usr.bin/cc/cc_tools/Makefile,v 1.73 2004/01/15 10:07:59 ru Exp $
2 # $DragonFly: src/gnu/usr.bin/cc3/cc_tools/Attic/Makefile,v 1.5 2004/02/03 03:47:11 dillon Exp $
5 # This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
6 # is such a !@#!*#% nightmare because of how it reprograms the dependencies,
7 # suffix rules, SRCS, etc. It's easiest to cheat by using bsd.prog.mk and
8 # SRCS to get dependencies.
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.
15 CFLAGS+= -I. -I${.CURDIR}/../config
16 CFLAGS+= -static -DGENERATOR_FILE
18 .include "../Makefile.inc"
20 .PATH: ${GCCDIR} ${GCCDIR}/gcc ${GCCDIR}/libiberty
22 #-----------------------------------------------------------------------
25 .for F in attr codes config flags constants
26 insn-$F.h: gen$F ${MD_FILE}
27 ./gen$F ${MD_FILE} > insn-$F.h
32 insn-$F.c: gen$F ${MD_FILE}
33 ./gen$F ${MD_FILE} > insn-$F.c
37 GENSRCS+= gen-time-stamp
38 gen-time-stamp: genattr genattrtab genconditions genconstants genemit \
39 genextract gengtype genopinit genoutput genpeep genrecog
42 .for F in attr codes config emit extract flags opinit output peep recog
45 gen$F: gen$F.o rtl.o obstack.o print-rtl.o bitmap.o errors.o gensupport.o \
46 ggc-none.o hashtab.o read-rtl.o concat.o insn-conditions.o \
48 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
55 # genattrtab needs more complex build rule
57 build-tools: genattrtab
59 genattrtab : genattrtab.o rtl.o obstack.o print-rtl.o bitmap.o errors.o \
60 gensupport.o ggc-none.o hashtab.o read-rtl.o concat.o \
61 insn-conditions.o genautomata.o varray.o getruntime.o \
63 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
65 GENSRCS+= genattrtab.c
66 CLEANFILES+= genattrtab
69 # genconstants and genconditions cannot depend on insn-conditions.o
70 # they should be liked with dummy-conditions.o stubs instead
72 .for F in constants conditions
75 gen$F: gen$F.o rtl.o obstack.o bitmap.o errors.o gensupport.o \
76 ggc-none.o hashtab.o read-rtl.o concat.o dummy-conditions.o \
78 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
84 .for F in check genrtl preds
88 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
94 .ORDER: genrtl.c genrtl.h
95 genrtl.c genrtl.h: gengenrtl
96 ./gengenrtl > genrtl.c
97 ./gengenrtl -h > genrtl.h
99 GENSRCS+= genrtl.c genrtl.h
101 SRCS+= bitmap.c concat.c dummy-conditions.c errors.c genautomata.c \
102 gensupport.c getruntime.c ggc-none.c hashtab.c \
103 obstack.c physmem.c print-rtl.c read-rtl.c rtl.c varray.c xmemdup.c \
106 #-----------------------------------------------------------------------
107 # Common parser stuff.
109 tree-check.h: gencheck
110 ./gencheck > ${.TARGET}
111 GENSRCS+= tree-check.h
113 #-----------------------------------------------------------------------
117 ./genpreds > ${.TARGET}
120 #-----------------------------------------------------------------------
123 gengtype-lex.c : gengtype-lex.l
124 ${LEX} -t ${.ALLSRC} | \
125 sed 's/^\(char msg\[\];\)/yyconst \1/' > ${.TARGET}
127 .ORDER: gengtype-yacc.c gengtype-yacc.h
128 gengtype-yacc.c gengtype-yacc.h: gengtype-yacc.y
129 ${YACC} -d -o gengtype-yacc.c ${.ALLSRC}
131 GENSRCS+= gengtype-yacc+%DIKED.c gengtype-yacc.h gengtype-lex.c
132 CLEANFILES+= gengtype-yacc.c
134 gengtype-yacc+%DIKED.c: gengtype-yacc.c
135 cat ${.ALLSRC} > ${.TARGET}
136 sed -e "s/xmalloc/malloc/g" \
137 -e "s/xrealloc/realloc/g" \
138 -e "s/malloc/xmalloc/g" \
139 -e "s/realloc/xrealloc/g" \
140 ${.ALLSRC} > ${.TARGET}
142 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o xmemdup.o xmalloc.o xexit.o
143 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
146 CLEANFILES+= gengtype
148 gengtype-lex.o: gengtype-yacc.h
150 .ORDER: gtype-desc.c gtype-desc.h
151 gtype-desc.c gtype-desc.h: gtype-time-stamp
154 GENSRCS+= gtype-time-stamp
155 gtype-time-stamp: gengtype ${GTFILES}
159 GENSRCS+= gtype-desc.c gtype-desc.h
160 CLEANFILES+= gt-*.h gtype-*.h
162 #-----------------------------------------------------------------------
163 # Determine content of variables used by the target/host config files
166 # The list of headers to go into tconfig.h
168 TARGET_INC= ansidecl.h
169 TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h
170 .if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
171 TARGET_INC+= ${GCC_CPU}/unix.h
172 TARGET_INC+= ${GCC_CPU}/att.h
174 .if ${TARGET_ARCH} != "alpha"
175 TARGET_INC+= dbxelf.h
178 TARGET_INC+= dragonfly-native.h
179 TARGET_INC+= dragonfly-spec.h
180 TARGET_INC+= dragonfly.h
181 .if ${TARGET_ARCH} == "alpha"
182 TARGET_INC+= ${GCC_CPU}/elf.h
184 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
185 .if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
186 TARGET_INC+= ${GCC_CPU}/sysv4.h
189 TARGET_INC+= ${GCC_CPU}/dragonfly.h
190 .if ${TARGET_ARCH} == "amd64"
191 TARGET_INC+= ${GCC_CPU}/x86-64.h
192 TARGET_INC+= ${GCC_CPU}/dragonfly64.h
194 TARGET_INC+= defaults.h
197 # Use TARGET_INC as a template and build a list of target specific
198 # include files for gengtype to scan
200 GCONFIG_H= ${.OBJDIR}/tconfig.h ${.CURDIR}/auto-host.h
202 .for H in ${TARGET_INC}
203 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
211 # Define some variables to make blocks copied from Makefile.in happy
213 srcdir= ${GCCDIR}/gcc
214 out_file= ${GCCDIR}/gcc/config/${GCC_CPU}/${GCC_CPU}.c
215 GTFILES_SRCDIR= ${GCCDIR}/gcc
218 # Copied unchanged from gcc/Makefile.in
220 GTFILES = $(GCONFIG_H) $(srcdir)/location.h \
221 $(GCCDIR)/include/hashtab.h \
222 $(srcdir)/bitmap.h $(srcdir)/function.h \
223 $(srcdir)/rtl.h $(srcdir)/optabs.h \
224 $(srcdir)/tree.h $(srcdir)/libfuncs.h \
225 $(srcdir)/hashtable.h $(srcdir)/real.h \
226 $(srcdir)/varray.h $(srcdir)/ssa.h $(srcdir)/insn-addr.h \
228 $(srcdir)/c-common.h $(srcdir)/c-tree.h \
229 $(srcdir)/basic-block.h \
230 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c \
231 $(srcdir)/dwarf2out.c $(srcdir)/emit-rtl.c \
232 $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
233 $(srcdir)/fold-const.c $(srcdir)/function.c \
234 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c \
236 $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \
237 $(srcdir)/reg-stack.c \
238 $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
239 $(srcdir)/tree.c $(srcdir)/varasm.c \
243 # Build a list of frontend directories to look into
245 # These paths are very sensitive and used in the gengtype program.
247 GTFILES_LANG_DIR_NAMES=
250 GTFILES_LANG_DIR_NAMES+= cp
253 .if !defined(NO_OBJC)
254 GTFILES_LANG_DIR_NAMES+= objc
257 .if !defined(NO_FORTRAN)
258 GTFILES_LANG_DIR_NAMES+= f
262 # Build a list of language specific files for gengtype
264 .for L in ${GTFILES_LANG_DIR_NAMES} c
265 .if exists(${GCCDIR}/gcc/$L-config-lang.in)
266 # Source the language config file
267 $L_GTFILES!= sh -c '. ${GCCDIR}/gcc/$L-config-lang.in; echo $$gtfiles'
269 $L_GTFILES!= sh -c '. ${GCCDIR}/gcc/$L/config-lang.in; echo $$gtfiles'
271 GTFILES+= ${$L_GTFILES}
272 .for F in ${$L_GTFILES}
278 #-----------------------------------------------------------------------
279 # the host/target compiler config.
281 COMMONHDRS= config.h hconfig.h multilib.h options.h specs.h tconfig.h \
282 tm_p.h configargs.h safe-ctype.h
283 GENSRCS+= ${COMMONHDRS} gencheck.h gtyp-gen.h
285 MFILE?= ${.CURDIR}/Makefile
286 ${COMMONHDRS}: ${MFILE}
289 echo 'static const char configuration_arguments[] =' > ${.TARGET}
290 echo ' "DragonFly/${TARGET_ARCH} system compiler";' >> ${.TARGET}
291 echo 'static const char thread_model[] = "posix";' >> ${.TARGET}
294 echo '#include "auto-host.h"' > ${.TARGET}
295 echo '#include <tconfig.h>' >> ${.TARGET}
298 echo '#include "cp/cp-tree.def"' > ${.TARGET}
299 echo '#include "objc/objc-tree.def"' >> ${.TARGET}
302 echo 'static const char *const multilib_raw[] = { \
303 "aout maout;", "elf !maout;", NULL };' > ${.TARGET}
304 echo 'static const char *const multilib_matches_raw[] = { \
305 "maout maout;", "melf melf;", NULL };' >> ${.TARGET}
306 echo 'static const char *multilib_extra = "";' >> ${.TARGET}
307 echo 'static const char *multilib_options = "";'>> ${.TARGET}
308 echo 'static const char *const multilib_exclusions_raw[] = { \
309 NULL };' >> ${.TARGET}
312 echo '#include "cp/lang-options.h"' > ${.TARGET}
313 echo '#include "f/lang-options.h"' >> ${.TARGET}
314 echo '#include "objc/lang-options.h"' >> ${.TARGET}
317 echo '#include "cp/lang-specs.h"' > ${.TARGET}
318 echo '#include "f/lang-specs.h"' >> ${.TARGET}
319 echo '#include "objc/lang-specs.h"' >> ${.TARGET}
322 echo '#include <hconfig.h>' > ${.TARGET}
323 echo '#ifndef GENERATOR_FILE' >> ${.TARGET}
324 echo '#include "insn-constants.h"' >> ${.TARGET}
325 echo '#include "insn-flags.h"' >> ${.TARGET}
326 echo '#endif' >> ${.TARGET}
329 echo 'struct rtx_def;' > ${.TARGET}
330 echo 'typedef struct rtx_def *rtx;' >> ${.TARGET}
331 echo 'struct rtvec_def;' >> ${.TARGET}
332 echo 'typedef struct rtvec_def *rtvec;' >> ${.TARGET}
333 echo 'union tree_node;' >> ${.TARGET}
334 echo 'typedef union tree_node *tree;' >> ${.TARGET}
335 echo '#ifndef GTY' >> ${.TARGET}
336 echo '# define GTY(x)' >> ${.TARGET}
337 echo '#endif' >> ${.TARGET}
338 echo '' >> ${.TARGET}
339 .if ${TARGET_ARCH} == "amd64"
340 echo '#include "i386/biarch64.h"' >> ${.TARGET}
342 .if ${TARGET_ARCH} == "ia64"
343 echo '#define TARGET_CPU_DEFAULT (MASK_GNU_AS|MASK_GNU_LD)' >>${.TARGET}
345 .for H in ${TARGET_INC}
346 echo '#include "$H"' >> ${.TARGET}
348 echo '#ifndef POSIX' >> ${.TARGET}
349 echo '# define POSIX' >> ${.TARGET}
350 echo '#endif' >> ${.TARGET}
351 .if exists(${GCCDIR}/gcc/config/${GCC_CPU}/${GCC_CPU}-modes.def)
352 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
353 echo '#define EXTRA_CC_MODES 1' >> ${.TARGET}
357 echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"' >> ${.TARGET}
358 echo '#include "tm-preds.h"' >> ${.TARGET}
360 safe-ctype.h: Makefile
361 echo '#include <ctype.h>' > ${.TARGET}
362 .for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \
363 ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL
364 echo '#define ${Z} ${Z:L}' >> ${.TARGET}
366 echo "#define ISIDST(x) \
367 ((x) == '_' || isalpha(x))" >> ${.TARGET}
368 echo "#define ISIDNUM(x) \
369 (isdigit(x) || ISIDST(x))" >> ${.TARGET}
370 echo "#define IS_VSPACE(x) \
371 ((x) == '\n' || (x) == '\r')" >> ${.TARGET}
372 echo "#define IS_NVSPACE(x) \
373 (!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))" >> ${.TARGET}
374 echo "#define IS_SPACE_OR_NUL(x) \
375 (isspace(x) || (x) == '\0')" >> ${.TARGET}
378 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET}
379 echo "static const char *srcdir = " >> ${.TARGET}
380 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET}
381 echo "static const char *lang_files[] = {" >> ${.TARGET}
382 .for F in ${GTFILES_FILES}
383 echo "\"$F\", " >> ${.TARGET}
385 echo "NULL};" >> ${.TARGET}
386 echo "static const char *langs_for_lang_files[] = {" >> ${.TARGET}
387 .for F in ${GTFILES_LANGS}
388 echo "\"$F\", " >> ${.TARGET}
390 echo "NULL};" >> ${.TARGET}
391 echo "static const char *all_files[] = {" >> ${.TARGET}
393 echo "\"$F\", " >> ${.TARGET}
395 echo "NULL};" >> ${.TARGET}
396 echo "static const char *lang_dir_names[] = { \"c\", " >> ${.TARGET}
397 .for F in ${GTFILES_LANG_DIR_NAMES}
398 echo "\"$F\", " >> ${.TARGET}
400 echo "NULL};" >> ${.TARGET}
401 echo "#define xexit exit" >> ${.TARGET}
404 #-----------------------------------------------------------------------
408 CLEANFILES+= ${GENSRCS}
412 .include <bsd.prog.mk>
414 #-----------------------------------------------------------------------
417 # Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't
418 # define PROG because we have multiple programs.
420 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
423 .if !exists(${DEPENDFILE})
424 # Fudge pre-dependfile dependencies of objects in much the same way as
425 # bsd.prog.mk would do if we defined PROG. There are complications to
426 # avoid circular dependencies. First, only make most objects depend on
427 # all headers. Filter out the objects that would cause problems (i.e.,
428 # objects that will be used to create programs that will generate headers).
430 ${OBJS}: ${SRCS:M*.h:Ngtype-desc.h:Ngenrtl.h:Ntree-check.h:Ntm-preds.h:Ninsn-*.h}
432 ${OBJS:Ngencheck.o:Ngengenrtl.o:Ngenpreds.o}: tree-check.h tm-preds.h genrtl.h
434 ${OBJS:Ngengtype*.o:Nxmemdup.o:Ngengenrtl.o:Ngencheck.o:Ngenpreds.o:Nxmalloc.o:Nxexit.o}: gtype-desc.h
436 genextract.o: insn-config.h
438 insn-conditions.o: insn-constants.h