Initial import from FreeBSD RELENG_4:
[dragonfly.git] / gnu / usr.bin / cc / cc_tools / Makefile
1 # $FreeBSD: src/gnu/usr.bin/cc/cc_tools/Makefile,v 1.48.2.6 2002/06/20 23:13:31 obrien Exp $
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 # ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
11 # Prevent mkdep from using it, so that we don't have to give rules for
12 # aliases of generated headers.
13
14 CFLAGS+=        -I.
15 CFLAGS+=        -static
16
17 .include "../Makefile.inc"
18
19 .PATH: ${GCCDIR} ${GCCDIR}/cp
20
21 #-----------------------------------------------------------------------
22 # insn-* gunk
23
24 .for F in attr codes config flags
25 insn-$F.h: gen$F ${MD_FILE}
26         ./gen$F ${MD_FILE} > insn-$F.h
27 GENSRCS+=       insn-$F.h
28 .endfor
29
30 GENSRCS+=       gen-time-stamp
31 gen-time-stamp: genattrtab genemit genextract genopinit genoutput genpeep genrecog
32         touch ${.TARGET}
33
34 .for F in attr codes config emit extract flags opinit output peep recog
35 build-tools: gen$F
36
37 gen$F: gen$F.o rtl.o print-rtl.o obstack.o bitmap.o
38         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
39
40 GENSRCS+=       gen$F.c
41 CLEANFILES+=    gen$F
42 .endfor
43
44 .for F in attrtab
45 build-tools: gen$F
46
47 gen$F: gen$F.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
48         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
49
50 GENSRCS+=       gen$F.c
51 CLEANFILES+=    gen$F
52 .endfor
53
54 SRCS+=          bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c
55
56 .for F in check genrtl
57 build-tools: gen$F
58
59 gen$F: gen$F.o
60         ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
61
62 GENSRCS+=       gen$F.c
63 CLEANFILES+=    gen$F
64 .endfor
65
66 .ORDER: genrtl.c genrtl.h
67 genrtl.c genrtl.h: gengenrtl
68         ./gengenrtl genrtl.h genrtl.c
69
70 GENSRCS+=       genrtl.c genrtl.h
71
72 #-----------------------------------------------------------------------
73 # C hash codes
74 c-gperf.h: c-parse.gperf
75         gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
76             ${GCCDIR}/c-parse.gperf > ${.TARGET}
77 GENSRCS+=       c-gperf.h
78
79 #-----------------------------------------------------------------------
80 # C++ hash codes
81 gxx-hash.h: gxx.gperf
82         gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
83             ${GCCDIR}/cp/gxx.gperf >gxx-hash.h
84 GENSRCS+=       gxx-hash.h
85
86 # make a link the the Cygnus used name for now -- hopes are they will change it
87 hash.h: gxx-hash.h
88         ln -sf ${.ALLSRC} ${.TARGET}
89 GENSRCS+=       hash.h
90
91 #-----------------------------------------------------------------------
92 # Common parser stuff.
93
94 tree-check.h: gencheck
95         ./gencheck > ${.TARGET}
96 GENSRCS+=       tree-check.h
97
98 #-----------------------------------------------------------------------
99 # the host/target compiler config.
100
101 COMMONHDRS=     config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
102 GENSRCS+=       ${COMMONHDRS} gencheck.h
103
104 config.h hconfig.h:
105         echo '#include "auto-host.h"'                           > ${.TARGET}
106         echo '#include "gansidecl.h"'                           >> ${.TARGET}
107         echo '#include "${TARGET_ARCH}/xm-${TARGET_ARCH}.h"'    >> ${.TARGET}
108         echo '#include "hwint.h"'                               >> ${.TARGET}
109
110 gencheck.h:
111         echo '#include "cp/cp-tree.def"'                > ${.TARGET}
112         echo '#include "objc/objc-tree.def"'            >> ${.TARGET}
113
114 multilib.h:
115         echo 'static char *multilib_raw[] = { \
116             "aout maout;", "elf !maout;", NULL };'      > ${.TARGET}
117         echo 'static char *multilib_matches_raw[] = { \
118             "maout maout;", "melf melf;", NULL };'      >> ${.TARGET}
119         echo 'static char *multilib_extra = "";'        >> ${.TARGET}
120
121 options.h:
122         echo '#include "cp/lang-options.h"'             > ${.TARGET}
123         echo '#include "f/lang-options.h"'              >> ${.TARGET}
124
125 specs.h:
126         echo '#include "cp/lang-specs.h"'               > ${.TARGET}
127         echo '#include "f/lang-specs.h"'                >> ${.TARGET}
128         echo '#include "objc/lang-specs.h"'             >> ${.TARGET}
129
130 tconfig.h:
131         echo '#include "gansidecl.h"'                           > ${.TARGET}
132         echo '#include "${TARGET_ARCH}/xm-${TARGET_ARCH}.h"'    >> ${.TARGET}
133
134 # KEEP THIS IN SYNC with src/gcc/lib/libgcc/Makefile !!
135 tm.h:
136         echo '#include "${TARGET_ARCH}/${TARGET_ARCH}.h"'       > ${.TARGET}
137 .if ${TARGET_ARCH} == "i386"
138         echo '#include "${TARGET_ARCH}/att.h"'                  >> ${.TARGET}
139 .endif
140         echo '#include <freebsd.h>'                             >> ${.TARGET}
141         echo '#include "dbxelf.h"'                              >> ${.TARGET}
142 .if exists(${GCCDIR}/config/${TARGET_ARCH}/elf.h)
143         echo '#include "${TARGET_ARCH}/elf.h"'                  >> ${.TARGET}
144 .endif
145         echo '#include "${TARGET_ARCH}/freebsd.h"'              >> ${.TARGET}
146 .if ${TARGET_ARCH} == "i386"
147         echo '#include "${TARGET_ARCH}/perform.h"'              >> ${.TARGET}
148 .endif
149         echo '#include <freebsd-native.h>'                      >> ${.TARGET}
150
151 #-----------------------------------------------------------------------
152 # General things.
153
154 SRCS+=          ${GENSRCS}
155 CLEANFILES+=    ${GENSRCS}
156
157 all: ${SRCS}
158
159 build-tools: depend
160
161 .include <bsd.prog.mk>
162
163 #-----------------------------------------------------------------------
164 # Fixups.
165
166 # Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
167 # define PROG because we have multiple programs.
168 #
169 OBJS+=          ${SRCS:N*.h:R:S/$/.o/g}
170
171 .if !exists(${DEPENDFILE})
172 # Fudge pre-dependfile dependencies of objects in much the same way as
173 # bsd.prog.mk would do if we defined PROG.  There are complications to
174 # avoid circular dependencies.  First, only make most objects depend on
175 # all headers.  Filter out the objects that would cause problems (i.e.,
176 # objects that will be used to create programs that will generate headers).
177 #
178 ${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nprint-rtl.o:Nrtl.o}: ${SRCS:M*.h}
179
180 # Next, make each of the problematic objects depend on only most headers.
181 # Filter out the headers that would cause problems (and a few more when it
182 # is inconvenient to filter precisely).
183 #
184 bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o print-rtl.o \
185     rtl.o: ${SRCS:M*.h:Ninsn-*.h}
186 gencheck.o: gencheck.h ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
187 gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
188 .endif