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