Makefile revision 116891
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 116891 2003-06-26 20:34:08Z peter $
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		${GCCDIR}/../libiberty
19
20CFLAGS+=	-static -DGENERATOR_FILE
21
22#-----------------------------------------------------------------------
23# insn-* gunk
24
25.for F in attr codes config flags
26insn-$F.h: gen$F ${MD_FILE}
27	./gen$F ${MD_FILE} > insn-$F.h
28GENSRCS+=	insn-$F.h
29.endfor
30
31GENSRCS+=	gen-time-stamp
32gen-time-stamp: genattrtab genemit genextract genopinit genoutput genpeep genrecog
33	touch ${.TARGET}
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 errors.o gensupport.o        ggc-none.o hashtab.o read-rtl.o
39	${CC} ${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 print-rtl.o obstack.o bitmap.o errors.o gensupport.o        ggc-none.o hashtab.o read-rtl.o
49	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
50
51GENSRCS+=	gen$F.c
52CLEANFILES+=	gen$F
53.endfor
54
55SRCS+=		bitmap.c errors.c gensupport.c        ggc-none.c hashtab.c obstack.c print-rtl.c regclass.c rtl.c rtlanal.c read-rtl.c
56
57.for F in check genrtl preds
58build-tools: gen$F
59
60gen$F: gen$F.o
61	${CC} ${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.c
70	./gengenrtl -h > genrtl.h
71
72GENSRCS+=	genrtl.c genrtl.h
73
74#-----------------------------------------------------------------------
75# Common parser stuff.
76
77tree-check.h: gencheck
78	./gencheck > ${.TARGET}
79GENSRCS+=	tree-check.h
80
81#-----------------------------------------------------------------------
82# Predicates stuff.
83
84tm-preds.h: genpreds
85	./genpreds > ${.TARGET}
86GENSRCS+=	tm-preds.h
87
88#-----------------------------------------------------------------------
89# the host/target compiler config.
90
91COMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h \
92		tm_p.h configargs.h safe-ctype.h
93GENSRCS+=	${COMMONHDRS} gencheck.h
94
95MFILE?=	${.CURDIR}/Makefile
96${COMMONHDRS}: ${MFILE}
97
98configargs.h:
99	echo 'static const char configuration_arguments[] ='	> ${.TARGET}
100	echo '	"FreeBSD/${TARGET_ARCH} system compiler";'		>> ${.TARGET}
101	echo 'static const char thread_model[] = "posix";'	>> ${.TARGET}
102
103hconfig.h:
104	echo '#include "auto-host.h"'			> ${.TARGET}
105	echo '#include <tconfig.h>'			>> ${.TARGET}
106
107gencheck.h:
108	echo '#include "cp/cp-tree.def"'		> ${.TARGET}
109	echo '#include "objc/objc-tree.def"'		>> ${.TARGET}
110
111multilib.h:
112	echo 'static const char *const multilib_raw[] = { \
113	    "aout maout;", "elf !maout;", NULL };'	> ${.TARGET}
114	echo 'static const char *const multilib_matches_raw[] = { \
115	    "maout maout;", "melf melf;", NULL };'	>> ${.TARGET}
116	echo 'static const char *multilib_extra = "";'	>> ${.TARGET}
117	echo 'static const char *multilib_options = "";'>> ${.TARGET}
118	echo 'static const char *const multilib_exclusions_raw[] = { \
119	    NULL };'					>> ${.TARGET}
120
121options.h:
122	echo '#include "cp/lang-options.h"'		> ${.TARGET}
123	echo '#include "f/lang-options.h"'		>> ${.TARGET}
124	echo '#include "objc/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
131config.h:
132	echo '#include <hconfig.h>'			> ${.TARGET}
133	echo '#ifndef GENERATOR_FILE'			>> ${.TARGET}
134	echo '#include "insn-codes.h"'			>> ${.TARGET}
135	echo '#include "insn-flags.h"'			>> ${.TARGET}
136	echo '#endif'					>> ${.TARGET}
137
138tconfig.h:
139	echo 'struct rtx_def;'				> ${.TARGET}
140	echo 'typedef struct rtx_def *rtx;'		>> ${.TARGET}
141	echo 'struct rtvec_def;'			>> ${.TARGET}
142	echo 'typedef struct rtvec_def *rtvec;'		>> ${.TARGET}
143	echo 'union tree_node;'				>> ${.TARGET}
144	echo 'typedef union tree_node *tree;'		>> ${.TARGET}
145	echo ''						>> ${.TARGET}
146.if ${TARGET_ARCH} == "amd64"
147	echo '#include "i386/biarch64.h"'		>> ${.TARGET}
148.endif
149.if ${TARGET_ARCH} == "ia64"
150	echo '#define TARGET_CPU_DEFAULT (MASK_GNU_AS|MASK_GNU_LD)' >>${.TARGET}
151.endif
152	echo '#include "ansidecl.h"'			>> ${.TARGET}
153	echo '#include "${GCC_CPU}/${GCC_CPU}.h"'	>> ${.TARGET}
154.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
155	echo '#include "${GCC_CPU}/att.h"'		>> ${.TARGET}
156.endif
157.if ${TARGET_ARCH} != "alpha"
158	echo '#include "dbxelf.h"'			>> ${.TARGET}
159	echo '#include "elfos.h"'			>> ${.TARGET}
160.endif
161	echo '#include <freebsd-native.h>'		>> ${.TARGET}
162	echo '#include "freebsd-spec.h"'		>> ${.TARGET}
163	echo '#include "freebsd.h"'			>> ${.TARGET}
164.if ${TARGET_ARCH} == "alpha"
165	echo '#include "${GCC_CPU}/elf.h"'		>> ${.TARGET}
166.endif
167.if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
168.if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
169	echo '#include "${GCC_CPU}/sysv4.h"'		>> ${.TARGET}
170.endif
171.endif
172	echo '#include "${GCC_CPU}/freebsd.h"'		>> ${.TARGET}
173.if ${TARGET_ARCH} == "amd64"
174	echo '#include "${GCC_CPU}/x86-64.h"' 		>> ${.TARGET}
175	echo '#include "${GCC_CPU}/freebsd64.h"'	>> ${.TARGET}
176.endif
177	echo '#include "defaults.h"'			>> ${.TARGET}
178	echo '#ifndef POSIX'				>> ${.TARGET}
179	echo '# define POSIX'				>> ${.TARGET}
180	echo '#endif'					>> ${.TARGET}
181.if ${TARGET_ARCH} != "ia64"
182	echo '#define CONFIG_SJLJ_EXCEPTIONS 0'		>> ${.TARGET}
183.endif
184
185tm_p.h:
186	echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"'	>> ${.TARGET}
187	echo '#include "tm-preds.h"'				>> ${.TARGET}
188
189safe-ctype.h: Makefile
190	echo '#include <ctype.h>'				> ${.TARGET}
191.for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \
192    ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL
193	echo '#define ${Z}	${Z:L}'				>> ${.TARGET}
194.endfor
195	echo "#define ISIDST(x)		\
196		((x) == '_' || isalpha(x))"			>> ${.TARGET}
197	echo "#define ISIDNUM(x)	\
198		(isdigit(x) || ISIDST(x))"			>> ${.TARGET}
199	echo "#define IS_VSPACE(x)	\
200		((x) == '\n' || (x) == '\r')"			>> ${.TARGET}
201	echo "#define IS_NVSPACE(x)	\
202		(!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))"	>> ${.TARGET}
203	echo "#define IS_SPACE_OR_NUL(x)	\
204		(isspace(x) || (x) == '\0')"			>> ${.TARGET}
205
206#-----------------------------------------------------------------------
207# General things.
208
209SRCS+=		${GENSRCS}
210CLEANFILES+=	${GENSRCS}
211
212all: ${SRCS}
213
214.include <bsd.prog.mk>
215
216#-----------------------------------------------------------------------
217# Fixups.
218
219# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
220# define PROG because we have multiple programs.
221#
222OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
223
224.if !exists(${DEPENDFILE})
225# Fudge pre-dependfile dependencies of objects in much the same way as
226# bsd.prog.mk would do if we defined PROG.  There are complications to
227# avoid circular dependencies.  First, only make most objects depend on
228# all headers.  Filter out the objects that would cause problems (i.e.,
229# objects that will be used to create programs that will generate headers).
230#
231${OBJS:Nbitmap.o:Nerrors.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Ngenpreds.o:Ngensupport.o:Nggc-none.o:Nhashtab.o:Nobstack.o:Nprint-rtl.o:Nread-rtl.o:Nrtl.o}: ${SRCS:M*.h}
232
233# Force these to be made absolustly first w/-j
234${OBJS}: ${COMMONHDRS}
235
236# Next, make each of the problematic objects depend on only most headers.
237# Filter out the headers that would cause problems (and a few more when it
238# is inconvenient to filter precisely).
239#
240bitmap.o genattr.o gencodes.o genconfig.o genflags.o gensupport.o obstack.o print-rtl.o \
241    read-rtl.o rtl.o: ${SRCS:M*.h:Ninsn-*.h}
242gencheck.o: gencheck.h ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
243gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
244genpreds.o: ${COMMONHDRS}
245.endif
246