0b451e5aae1d2313f3a9b6ca82d787007f7e667d
[dragonfly.git] / gnu / usr.bin / cc3 / cc_tools / Makefile
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 $
3
4 #
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.
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
15 CFLAGS+=        -I. -I${.CURDIR}/../config 
16 CFLAGS+=        -static -DGENERATOR_FILE
17
18 .include "../Makefile.inc"
19
20 .PATH: ${GCCDIR} ${GCCDIR}/gcc ${GCCDIR}/libiberty
21
22 #-----------------------------------------------------------------------
23 # insn-* gunk
24
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
28 GENSRCS+=       insn-$F.h
29 .endfor
30
31 .for F in conditions
32 insn-$F.c: gen$F ${MD_FILE}
33         ./gen$F ${MD_FILE} > insn-$F.c
34 GENSRCS+=       insn-$F.c
35 .endfor
36
37 GENSRCS+=       gen-time-stamp
38 gen-time-stamp: genattr genattrtab genconditions genconstants genemit \
39                 genextract gengtype genopinit genoutput genpeep genrecog
40         touch ${.TARGET}
41
42 .for F in attr codes config emit extract flags opinit output peep recog
43 build-tools: gen$F
44
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 \
47         xmalloc.o xexit.o
48         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
49
50 GENSRCS+=       gen$F.c
51 CLEANFILES+=    gen$F
52 .endfor
53
54 #
55 # genattrtab needs more complex build rule
56 #
57 build-tools: genattrtab
58
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 \
62         xmalloc.o xexit.o
63         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
64
65 GENSRCS+=       genattrtab.c
66 CLEANFILES+=    genattrtab
67
68 #
69 # genconstants and genconditions cannot depend on insn-conditions.o
70 # they should be liked with dummy-conditions.o stubs instead
71 #
72 .for F in constants conditions
73 build-tools: gen$F
74
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 \
77        xmalloc.o xexit.o
78         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
79
80 GENSRCS+=       gen$F.c
81 CLEANFILES+=    gen$F
82 .endfor
83
84 .for F in check genrtl preds
85 build-tools: gen$F
86
87 gen$F: gen$F.o
88         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
89
90 GENSRCS+=       gen$F.c
91 CLEANFILES+=    gen$F
92 .endfor
93
94 .ORDER: genrtl.c genrtl.h
95 genrtl.c genrtl.h: gengenrtl
96         ./gengenrtl > genrtl.c
97         ./gengenrtl -h > genrtl.h
98
99 GENSRCS+=       genrtl.c genrtl.h
100
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 \
104         xmalloc.c xexit.c
105
106 #-----------------------------------------------------------------------
107 # Common parser stuff.
108
109 tree-check.h: gencheck
110         ./gencheck > ${.TARGET}
111 GENSRCS+=       tree-check.h
112
113 #-----------------------------------------------------------------------
114 # Predicates stuff.
115
116 tm-preds.h: genpreds
117         ./genpreds > ${.TARGET}
118 GENSRCS+=       tm-preds.h
119
120 #-----------------------------------------------------------------------
121 # Gengtype 
122
123 gengtype-lex.c : gengtype-lex.l
124         ${LEX} -t  ${.ALLSRC} | \
125         sed 's/^\(char msg\[\];\)/yyconst \1/' > ${.TARGET}
126
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}
130
131 GENSRCS+=       gengtype-yacc+%DIKED.c gengtype-yacc.h gengtype-lex.c
132 CLEANFILES+=    gengtype-yacc.c
133
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}
141
142 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o xmemdup.o xmalloc.o xexit.o
143         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
144
145 GENSRCS+=       gengtype.c
146 CLEANFILES+=    gengtype
147
148 gengtype-lex.o: gengtype-yacc.h
149
150 .ORDER: gtype-desc.c gtype-desc.h
151 gtype-desc.c gtype-desc.h: gtype-time-stamp
152         @true
153
154 GENSRCS+=       gtype-time-stamp
155 gtype-time-stamp: gengtype ${GTFILES}
156         ./gengtype
157         touch ${.TARGET}
158
159 GENSRCS+=       gtype-desc.c gtype-desc.h
160 CLEANFILES+=    gt-*.h gtype-*.h
161
162 #-----------------------------------------------------------------------
163 # Determine content of variables used by the target/host config files
164
165 #
166 # The list of headers to go into tconfig.h
167 #
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
173 .endif
174 .if ${TARGET_ARCH} != "alpha"
175 TARGET_INC+=    dbxelf.h
176 TARGET_INC+=    elfos.h
177 .endif
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
183 .endif
184 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
185 .if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
186 TARGET_INC+=    ${GCC_CPU}/sysv4.h
187 .endif
188 .endif
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
193 .endif
194 TARGET_INC+=    defaults.h
195
196 #
197 # Use TARGET_INC as a template and build a list of target specific
198 # include files for gengtype to scan
199 #
200 GCONFIG_H=      ${.OBJDIR}/tconfig.h ${.CURDIR}/auto-host.h
201
202 .for H in ${TARGET_INC}
203 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
204 .if exists($D/$H)
205 GCONFIG_H+=     $D/$H
206 .endif
207 .endfor
208 .endfor
209
210 #
211 # Define some variables to make blocks copied from Makefile.in happy
212 #
213 srcdir=         ${GCCDIR}/gcc
214 out_file=       ${GCCDIR}/gcc/config/${GCC_CPU}/${GCC_CPU}.c
215 GTFILES_SRCDIR= ${GCCDIR}/gcc
216
217 #
218 # Copied unchanged from gcc/Makefile.in
219 #
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 \
227   $(srcdir)/cselib.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 \
235   $(srcdir)/optabs.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 \
240   $(out_file)
241
242 #
243 # Build a list of frontend directories to look into
244 #
245 # These paths are very sensitive and used in the gengtype program.
246 #
247 GTFILES_LANG_DIR_NAMES=
248
249 .if !defined(NO_CXX)
250 GTFILES_LANG_DIR_NAMES+=        cp
251 .endif
252
253 .if !defined(NO_OBJC)
254 GTFILES_LANG_DIR_NAMES+=        objc
255 .endif
256
257 .if !defined(NO_FORTRAN)
258 GTFILES_LANG_DIR_NAMES+=        f
259 .endif
260
261 #
262 # Build a list of language specific files for gengtype
263 #
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'
268 .else
269 $L_GTFILES!=    sh -c '. ${GCCDIR}/gcc/$L/config-lang.in; echo $$gtfiles'
270 .endif
271 GTFILES+=       ${$L_GTFILES}
272 .for F in ${$L_GTFILES}
273 GTFILES_FILES+= $F
274 GTFILES_LANGS+= $L
275 .endfor
276 .endfor
277
278 #-----------------------------------------------------------------------
279 # the host/target compiler config.
280
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
284
285 MFILE?= ${.CURDIR}/Makefile
286 ${COMMONHDRS}: ${MFILE}
287
288 configargs.h:
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}
292
293 hconfig.h:
294         echo '#include "auto-host.h"'                   > ${.TARGET}
295         echo '#include <tconfig.h>'                     >> ${.TARGET}
296
297 gencheck.h:
298         echo '#include "cp/cp-tree.def"'                > ${.TARGET}
299         echo '#include "objc/objc-tree.def"'            >> ${.TARGET}
300
301 multilib.h:
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}
310
311 options.h:
312         echo '#include "cp/lang-options.h"'             > ${.TARGET}
313         echo '#include "f/lang-options.h"'              >> ${.TARGET}
314         echo '#include "objc/lang-options.h"'           >> ${.TARGET}
315
316 specs.h:
317         echo '#include "cp/lang-specs.h"'               > ${.TARGET}
318         echo '#include "f/lang-specs.h"'                >> ${.TARGET}
319         echo '#include "objc/lang-specs.h"'             >> ${.TARGET}
320
321 config.h:
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}
327
328 tconfig.h:
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}
341 .endif
342 .if ${TARGET_ARCH} == "ia64"
343         echo '#define TARGET_CPU_DEFAULT (MASK_GNU_AS|MASK_GNU_LD)' >>${.TARGET}
344 .endif
345 .for H in ${TARGET_INC}
346         echo '#include "$H"'                            >> ${.TARGET}
347 .endfor
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}
354 .endif
355
356 tm_p.h:
357         echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"'        >> ${.TARGET}
358         echo '#include "tm-preds.h"'                            >> ${.TARGET}
359
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}
365 .endfor
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}
376
377 gtyp-gen.h:
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}
384 .endfor
385         echo "NULL};"                                           >> ${.TARGET}
386         echo "static const char *langs_for_lang_files[] = {"    >> ${.TARGET}
387 .for F in ${GTFILES_LANGS}
388         echo "\"$F\", "                                         >> ${.TARGET}
389 .endfor
390         echo "NULL};"                                           >> ${.TARGET}
391         echo "static const char *all_files[] = {"               >> ${.TARGET}
392 .for F in ${GTFILES}
393         echo "\"$F\", "                                         >> ${.TARGET}
394 .endfor
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}
399 .endfor
400         echo "NULL};"                                           >> ${.TARGET}
401         echo "#define   xexit exit"                             >> ${.TARGET}
402
403
404 #-----------------------------------------------------------------------
405 # General things.
406
407 SRCS+=          ${GENSRCS}
408 CLEANFILES+=    ${GENSRCS}
409
410 all: ${SRCS}
411
412 .include <bsd.prog.mk>
413
414 #-----------------------------------------------------------------------
415 # Fixups.
416
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.
419 #
420 OBJS+=          ${SRCS:N*.h:R:S/$/.o/g}
421 CLEANFILES+=    ${OBJS}
422
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).
429 #
430 ${OBJS}: ${SRCS:M*.h:Ngtype-desc.h:Ngenrtl.h:Ntree-check.h:Ntm-preds.h:Ninsn-*.h}
431
432 ${OBJS:Ngencheck.o:Ngengenrtl.o:Ngenpreds.o}: tree-check.h tm-preds.h genrtl.h
433
434 ${OBJS:Ngengtype*.o:Nxmemdup.o:Ngengenrtl.o:Ngencheck.o:Ngenpreds.o:Nxmalloc.o:Nxexit.o}: gtype-desc.h
435
436 genextract.o: insn-config.h
437
438 insn-conditions.o: insn-constants.h
439
440 .endif