]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - gnu/usr.bin/cc/cc_tools/Makefile
MFV r348585: 9683 Allow bypassing devid in vdev_disk_open()
[FreeBSD/FreeBSD.git] / gnu / usr.bin / cc / cc_tools / Makefile
1 # $FreeBSD$
2
3 .include <src.opts.mk>
4
5 CFLAGS+=        -I.
6
7 .include "../Makefile.inc"
8 # Some of the logic needed in here is defined in Makefile.hdrs as it is shared
9 # with gnu/lib.
10 .include "Makefile.hdrs"
11
12 CFLAGS+=        -g
13 CFLAGS+=        -DGENERATOR_FILE -DHAVE_CONFIG_H
14
15 # Override LIBIBERTY set by Makefile.inc, We use our own for
16 # build tools.
17 LIBIBERTY=      libiberty.a
18
19 .PATH:  ${GCCDIR} ${GCCLIB}/libiberty
20
21 #-----------------------------------------------------------------------
22 # Determine content of variables used by the target/host config files
23
24 #
25 # The list of headers to go into tm.h
26 #
27 .for H in ${TARGET_INC}
28 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
29 .if exists($D/$H)
30 TARGET_INC_FILES+=     $D/$H
31 .endif
32 .endfor
33 .endfor
34
35 #
36 # gtyp includes.
37 #
38 srcdir=         ${GCCDIR}
39 CPPLIB_H=       ${GCCLIB}/libcpp/include/line-map.h \
40                 ${GCCLIB}/libcpp/include/cpplib.h
41 SYMTAB_H=       ${GCCLIB}/libcpp/include/symtab.h
42 CPP_ID_DATA_H=  ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h
43 HASHTAB_H=      ${GCCLIB}/include/hashtab.h
44 SPLAY_TREE_H=   ${GCCLIB}/include/splay-tree.h
45 out_file=       ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c
46 tm_file_list=   ${TARGET_INC_FILES}
47 host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h
48 GTFILES_SRCDIR= ${srcdir}
49
50 # Copied unchanged from gcc/Makefile.in
51 GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
52   $(CPP_ID_DATA_H) $(host_xm_file_list) \
53   $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
54   $(srcdir)/coverage.c $(srcdir)/rtl.h \
55   $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
56   $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
57   $(srcdir)/ipa-reference.h $(srcdir)/output.h \
58   $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/cgraph.h \
59   $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
60   $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
61   $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \
62   $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
63   $(srcdir)/dojump.c $(srcdir)/tree-profile.c \
64   $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
65   $(srcdir)/function.c $(srcdir)/except.h \
66   $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
67   $(srcdir)/profile.c $(srcdir)/regclass.c \
68   $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
69   $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \
70   $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
71   $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \
72   $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \
73   $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \
74   $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
75   $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
76   $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
77   $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
78   $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
79   $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
80   $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
81   $(srcdir)/tree-ssa-structalias.c \
82   $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
83   $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \
84
85 # The list of frontend directories to look into
86 GTFILES_LANG_DIR_NAMES=
87
88 .if ${MK_CXX} != "no"
89 GTFILES_LANG_DIR_NAMES+=        cp
90 .endif
91
92 # The list of language specific files for gengtype
93 .for L in ${GTFILES_LANG_DIR_NAMES} c
94 .if exists(${GCCDIR}/$L-config-lang.in)
95 # Source the language config file
96 L_GTFILES!=     sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
97 .else
98 L_GTFILES!=     sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
99 .endif
100 .for F in ${L_GTFILES}
101 GTFILES_FILES+= $F
102 GTFILES_LANGS+= $L
103 .endfor
104 .endfor
105 GTFILES+=       ${GTFILES_FILES}
106
107 #
108 # Tree definition files.
109 #
110 TREE_DEF_FILES=
111
112 .if ${MK_CXX} != "no"
113 TREE_DEF_FILES+=        cp/cp-tree.def
114 .endif
115
116 #-----------------------------------------------------------------------
117 # Build rules for header files and generator tools
118
119 # Host config
120 config.h:
121         TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
122         HEADERS="auto-host.h ansidecl.h" \
123         DEFINES="" \
124         /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
125
126 GENSRCS+=       config.h
127 CLEANFILES+=    cs-config.h
128
129 # Build config
130 bconfig.h:
131         TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
132         HEADERS="auto-host.h ansidecl.h" \
133         DEFINES="" \
134         /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
135 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
136         echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
137 .endif
138
139 GENSRCS+=       bconfig.h
140 CLEANFILES+=    cs-bconfig.h
141
142 # tconfig.h
143 GENSRCS+=       tconfig.h
144 CLEANFILES+=    cs-tconfig.h
145
146 # Options
147 GENONLY+=       optionlist options.h options.c
148
149 # Target machine config
150 GENSRCS+=       tm.h
151 CLEANFILES+=    cs-tm.h
152
153 # Target machine protos/preds.
154 tm_p.h:
155         TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
156         HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \
157         DEFINES="" \
158         /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h
159
160 GENSRCS+=       tm_p.h
161 CLEANFILES+=    cs-tm_p.h
162
163 # gencheck
164 gencheck.h: ${TREE_DEF_FILES}
165 .for F in ${TREE_DEF_FILES}
166         echo "#include \"$F\""                                  >> ${.TARGET}
167 .endfor
168         touch ${.TARGET}
169
170 GENSRCS+=       gencheck.h
171
172
173 # Source header for gtyp generator.
174 gtyp-gen.h:     ${GTFILES}
175         echo "/* This file is machine generated.  Do not edit.  */" > ${.TARGET}
176         echo "static const char * const srcdir = "              >> ${.TARGET}
177         echo "\"$(GTFILES_SRCDIR)\";"                           >> ${.TARGET}
178         echo "static const char * const lang_files[] = {"       >> ${.TARGET}
179 .for F in ${GTFILES_FILES}
180         echo "\"$F\", "                                         >> ${.TARGET}
181 .endfor
182         echo "NULL};"                                           >> ${.TARGET}
183         echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET}
184 .for F in ${GTFILES_LANGS}
185         echo "\"$F\", "                                         >> ${.TARGET}
186 .endfor
187         echo "NULL};"                                           >> ${.TARGET}
188         echo "static const char * const all_files[] = {"        >> ${.TARGET}
189 .for F in ${GTFILES}
190         echo "\"$F\", "                                         >> ${.TARGET}
191 .endfor
192         echo "NULL};"                                           >> ${.TARGET}
193         echo "static const char * const lang_dir_names[] = {"   >> ${.TARGET}
194 .for F in c ${GTFILES_LANG_DIR_NAMES}
195         echo "\"$F\", "                                         >> ${.TARGET}
196 .endfor
197         echo "NULL};"                                           >> ${.TARGET}
198
199 GENSRCS+=       gtyp-gen.h
200
201 # Version header for gcov
202 GENSRCS+=       gcov-iov.h
203
204 # Multilib config file
205 multilib.h:
206 .if ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH} == "amd64"
207         echo 'static const char *const multilib_raw[] = { \
208             ". !m64 !m32;", \
209             "64:../lib m64 !m32;", \
210             "32:../lib32 !m64 m32;", NULL };'                   > ${.TARGET}
211         echo 'static const char *multilib_options = "m64/m32";' >> ${.TARGET}
212         echo 'static const char *const multilib_matches_raw[] = { \
213             "m64 m64;", "m32 m32;", NULL };'                    >> ${.TARGET}
214 .else
215         echo 'static const char *const multilib_raw[] = { \
216             ". ;", NULL };'                                     > ${.TARGET}
217         echo 'static const char *multilib_options = "";'        >> ${.TARGET}
218         echo 'static const char *const multilib_matches_raw[] = { \
219             NULL };'                                            >> ${.TARGET}
220 .endif
221         echo 'static const char *multilib_extra = "";'          >> ${.TARGET}
222         echo 'static const char *const multilib_exclusions_raw[] = { \
223             NULL };'                                            >> ${.TARGET}
224
225 GENSRCS+=       multilib.h
226
227 configargs.h:
228         echo 'static const char configuration_arguments[] ='    > ${.TARGET}
229         echo '  "FreeBSD/${TARGET_ARCH} system compiler";'      >> ${.TARGET}
230         echo 'static const char thread_model[] = "posix";'      >> ${.TARGET}
231         echo 'static const struct {'                            >> ${.TARGET}
232         echo '  const char *name, *value;'                      >> ${.TARGET}
233         echo '} configure_default_options[] = {'                >> ${.TARGET}
234         echo '  { "NULL", "NULL" } };'                          >> ${.TARGET}
235
236 GENSRCS+=       configargs.h
237
238 # Language spec files
239 specs.h:
240         echo '#include "cp/lang-specs.h"'                       > ${.TARGET}
241
242 GENSRCS+=       specs.h
243
244 gstdint.h:
245         echo '#include "sys/types.h"'                           > ${.TARGET}
246         echo '#include "sys/stdint.h"'                          >> ${.TARGET}
247
248 GENSRCS+=       gstdint.h
249
250 # Linked headers
251 GENSRCS+=       gthr-default.h
252
253 GENSRCS+=       unwind.h
254
255 #
256 # gtype gunk
257 #
258 gengtype-lex.c: gengtype-lex.l
259         flex -ogengtype-lex.c ${.ALLSRC}
260
261 gengtype-yacc.h: gengtype-yacc.y
262         yacc -d -o gengtype-yacc.c ${.ALLSRC}
263
264 gengtype-yacc.c: gengtype-yacc.h .NOMETA
265
266 gengtype-yacc+%DIKED.c: gengtype-yacc.c
267         cat    ${.ALLSRC} > ${.TARGET}
268         sed -e "s/xmalloc/malloc/g" \
269             -e "s/xrealloc/realloc/g" \
270             -e "s/malloc/xmalloc/g" \
271             -e "s/realloc/xrealloc/g" \
272             ${.ALLSRC} > ${.TARGET}
273
274 GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c
275 CLEANFILES+= gengtype-yacc.c
276
277 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \
278           ${LIBIBERTY}
279         ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
280
281 gtype-desc.h:   gengtype
282         ${BTOOLSPATH:U.}/gengtype
283         touch ${.TARGET}
284
285 gtype-desc.c:   gtype-desc.h
286
287 GENONLY+=       gtype-desc.c gtype-desc.h
288 CLEANFILES+=    gt-*.h gtype-*.h
289
290 #
291 # Generator tools.
292 #
293 .for F in check checksum genrtl modes
294 gen$F:  gen$F.o errors.o ${LIBIBERTY}
295         ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
296 .endfor
297
298 .for F in attr attrtab automata codes conditions config constants emit \
299         extract flags  opinit output peep preds recog
300 gen$F:  gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \
301         gensupport.o print-rtl.o errors.o ${LIBIBERTY}
302         ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
303 .endfor
304
305 gencondmd:      gencondmd.o
306         ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
307
308 #
309 # Generated .md files.
310 #
311 insn-conditions.md:     gencondmd
312         ${BTOOLSPATH:U.}/gencondmd > ${.TARGET}
313 GENSRCS+=       insn-conditions.md
314
315 #
316 # Generated header files.
317 #
318
319 .for F in constants
320 insn-$F.h:      gen$F ${MD_FILE}
321         ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET}
322 GENSRCS+=       insn-$F.h
323 .endfor
324
325 .for F in attr codes config flags
326 insn-$F.h:      gen$F ${MD_FILE} insn-conditions.md
327         ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
328 GENSRCS+=       insn-$F.h
329 .endfor
330
331 # Header files with irregular names.
332 genrtl.h:       gengenrtl
333         ${BTOOLSPATH:U.}/gengenrtl -h > ${.TARGET}
334 GENSRCS+=       genrtl.h
335
336 tm-preds.h:     genpreds
337         ${BTOOLSPATH:U.}/genpreds -h ${MD_FILE} > ${.TARGET}
338 GENSRCS+=       tm-preds.h
339
340 tm-constrs.h:   genpreds
341         ${BTOOLSPATH:U.}/genpreds -c ${MD_FILE} > ${.TARGET}
342 GENSRCS+=       tm-constrs.h
343
344 tree-check.h:   gencheck
345         ${BTOOLSPATH:U.}/gencheck > ${.TARGET}
346 GENSRCS+=       tree-check.h
347
348 insn-modes.h:   genmodes
349         ${BTOOLSPATH:U.}/genmodes -h > ${.TARGET}
350 GENSRCS+=       insn-modes.h
351
352 #
353 # Generated source files.
354 #
355 .for F in attrtab automata emit extract opinit output peep preds recog
356 insn-$F.c:      gen$F ${MD_FILE} insn-conditions.md
357         ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
358 GENONLY+=       insn-$F.c
359 .endfor
360
361 .for F in conditions
362 insn-$F.c:      gen$F ${MD_FILE}
363         ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET}
364 GENSRCS+=       insn-$F.c
365 .endfor
366
367 # Source files with irregular names.
368 insn-modes.c:   genmodes
369         ${BTOOLSPATH:U.}/genmodes > ${.TARGET}
370 GENONLY+=       insn-modes.c
371
372 min-insn-modes.c:       genmodes
373         ${BTOOLSPATH:U.}/genmodes -m > ${.TARGET}
374 GENSRCS+=       min-insn-modes.c
375
376 genrtl.c:       gengenrtl
377         ${BTOOLSPATH:U.}/gengenrtl > ${.TARGET}
378 GENONLY+=       genrtl.c
379
380 gencondmd.c:    genconditions ${MD_FILE}
381         ${BTOOLSPATH:U.}/genconditions ${MD_FILE} > ${.TARGET}
382 GENSRCS+=       gencondmd.c
383
384 #-----------------------------------------------------------------------
385 # Build tools.
386
387 GNTOOLS+=       genattr genattrtab genautomata gencodes gencheck genchecksum \
388                 genconditions gencondmd genconfig genconstants genemit \
389                 genextract genflags gengenrtl gengtype genmodes genopinit \
390                 genoutput genpeep genpreds genrecog
391
392 ${GNTOOLS:C,$,.o,} ${GNTOOLS}: ${BUILD_TOOLS_META}
393 all: ${GNTOOLS} ${GENSRCS} ${GENONLY}
394 build-tools: all
395 beforedepend: ${GENONLY}
396
397 #
398 #-----------------------------------------------------------------------
399 # Build 'pocket' libiberty exclusively for build tools use.
400
401 LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \
402         dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \
403         hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \
404         partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \
405         xmalloc.c xmemdup.c xstrdup.c xstrerror.c
406 LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g}
407
408 .for _src in ${LIBIBERTY_SRCS}
409 ${_src:R:S/$/.o/}: ${_src} ${BUILD_TOOLS_META}
410         ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC}
411 .endfor
412
413 ${LIBIBERTY}: ${LIBIBERTY_OBJS} ${BUILD_TOOLS_META}
414         @rm -f ${.TARGET}
415         @${AR} ${ARFLAGS} ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q`
416         ${RANLIB} ${.TARGET}
417 CLEANFILES+=    ${LIBIBERTY} ${LIBIBERTY_OBJS}
418
419
420 #-----------------------------------------------------------------------
421 # Fixups.
422
423 # Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
424 # define PROG because we have multiple programs.
425 #
426 SRCS=           errors.c genattr.c genattrtab.c \
427                 genautomata.c gencheck.c genchecksum.c gencodes.c \
428                 genconditions.c genconfig.c genconstants.c genemit.c \
429                 genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \
430                 genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \
431                 gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \
432                 vec.c
433
434 SRCS+=          ${GENSRCS}
435 OBJS+=          ${SRCS:N*.h:R:S/$/.o/g}
436 GENOBJS+=       ${GENSRCS:N*.h:R:S/$/.o/g}
437 ${OBJS} ${GENOBJS}: ${BUILD_TOOLS_META}
438 CLEANFILES+=    ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS}
439
440 #-----------------------------------------------------------------------
441 # Manual dependencies.
442 .include  "Makefile.dep"
443
444 .include <bsd.prog.mk>
445 # DO NOT DELETE