summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/cc/cc_tools/Makefile
blob: 49524e7881216087d1a23941390cea464ac8a939 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# $FreeBSD: src/gnu/usr.bin/cc/cc_tools/Makefile,v 1.88.8.1 2009/04/15 03:14:26 kensmith Exp $
# $OpenBSD: Makefile,v 1.2 2009/11/02 09:50:39 jsg Exp $

.include <bsd.own.mk>

.include "../Makefile.inc"

CFLAGS+=	-I.

CFLAGS+=	-g
CFLAGS+=	-DGENERATOR_FILE -DHAVE_CONFIG_H

# Override LIBIBERTY set by Makefile.inc, We use our own for
# build tools.
LIBIBERTY=	/usr/lib/libiberty.a

.PATH:	${GCCDIR} ${GCCLIB}/libiberty

#-----------------------------------------------------------------------
# Determine content of variables used by the target/host config files

#
# The list of headers to go into tm.h
#

TARGET_INC+=	options.h
.if ${TARGET_ARCH} == "amd64"
TARGET_INC+=	i386/biarch64.h
.endif
.if ${TARGET_ARCH} != "arm"
TARGET_INC+=	${GCC_CPU}/${GCC_CPU}.h
.endif
.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
TARGET_INC+=	${GCC_CPU}/unix.h
TARGET_INC+=	${GCC_CPU}/att.h
.endif
TARGET_INC+=	dbxelf.h
TARGET_INC+=	elfos.h
TARGET_INC+=	openbsd.h
TARGET_INC+=	openbsd-libpthread.h
TARGET_INC+=	openbsd-native.h
.if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
.if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
TARGET_INC+=	${GCC_CPU}/sysv4.h
.endif
.endif
.if ${TARGET_ARCH} == "amd64"
TARgET_INC+=	${GCC_CPU}/x86-64.h
TARGET_INC+=	${GCC_CPU}/openbsd64.h
.else
TARGET_INC+=	${GCC_CPU}/openbsdelf.h
.endif
TARGET_INC+=	defaults.h

.for H in ${TARGET_INC}
.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
.if exists($D/$H)
TARGET_INC_FILES+=     $D/$H
.endif
.endfor
.endfor

#
# gtyp includes.
#
srcdir=		${GCCDIR}
CPPLIB_H=	${GCCLIB}/libcpp/include/line-map.h \
		${GCCLIB}/libcpp/include/cpplib.h
SYMTAB_H=	${GCCLIB}/libcpp/include/symtab.h
CPP_ID_DATA_H=	${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h
HASHTAB_H=	${GCCLIB}/include/hashtab.h
SPLAY_TREE_H=	${GCCLIB}/include/splay-tree.h
out_file=	${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c
tm_file_list=	${TARGET_INC_FILES}
host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h
GTFILES_SRCDIR=	${srcdir}

# Copied unchanged from gcc/Makefile.in
GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
  $(CPP_ID_DATA_H) $(host_xm_file_list) \
  $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
  $(srcdir)/coverage.c $(srcdir)/rtl.h \
  $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
  $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
  $(srcdir)/ipa-reference.h $(srcdir)/output.h \
  $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/cgraph.h \
  $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
  $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
  $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \
  $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
  $(srcdir)/dojump.c $(srcdir)/tree-profile.c \
  $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
  $(srcdir)/function.c $(srcdir)/except.h \
  $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
  $(srcdir)/profile.c $(srcdir)/regclass.c \
  $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
  $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \
  $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
  $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \
  $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \
  $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \
  $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
  $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
  $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
  $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
  $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
  $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
  $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
  $(srcdir)/tree-ssa-structalias.c \
  $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
  $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \

# The list of frontend directories to look into
GTFILES_LANG_DIR_NAMES=		cp objc

# The list of language specific files for gengtype
.for L in ${GTFILES_LANG_DIR_NAMES} c
.if exists(${GCCDIR}/$L-config-lang.in)
# Source the language config file
L_GTFILES!=	sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
.else
L_GTFILES!=	sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
.endif
.for F in ${L_GTFILES}
GTFILES_FILES+=	$F
GTFILES_LANGS+= $L
.endfor
.endfor
GTFILES+=	${GTFILES_FILES}

#
# Tree definition files.
#
TREE_DEF_FILES=		cp/cp-tree.def objc/objc-tree.def

#
# Option files.
#
OPT_FILES=	c.opt common.opt

.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt)
OPT_FILES+=	${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt
.endif

.if exists(${.CURDIR}/${GCC_CPU}-openbsd.opt)
OPT_FILES+=	${.CURDIR}/${GCC_CPU}-openbsd.opt
.endif

.if ${TARGET_ARCH} == "powerpc"
OPT_FILES+=	${GCCDIR}/config/${GCC_CPU}/sysv4.opt
.endif

.if ${TARGET_ARCH} == "sparc64"
OPT_FILES+=	${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt
.endif

.if exists(${.CURDIR}/openbsd.opt)
OPT_FILES+=	${.CURDIR}/openbsd.opt
.endif

#-----------------------------------------------------------------------
# Build rules for header files and generator tools

# Host config
config.h:
	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
	HEADERS="auto-host.h ansidecl.h" \
	DEFINES="" \
	/bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}

GENSRCS+=	config.h
CLEANFILES+=	cs-config.h

# Build config
bconfig.h:
	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
	HEADERS="auto-host.h ansidecl.h" \
	DEFINES="" \
	/bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
	echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
.endif

GENSRCS+=	bconfig.h
CLEANFILES+=	cs-bconfig.h

# tconfig.h
tconfig.h:
	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
	HEADERS="auto-host.h ansidecl.h" \
	DEFINES="USED_FOR_TARGET" \
	/bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}

GENSRCS+=	tconfig.h
CLEANFILES+=	cs-tconfig.h
# Options
optionlist: ${OPT_FILES}
	awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET}

options.h:	optionlist
	awk -f ${GCCDIR}/opt-functions.awk \
	    -f ${GCCDIR}/opth-gen.awk \
		< ${.ALLSRC} > ${.TARGET}

options.c:	optionlist
	awk -f ${GCCDIR}/opt-functions.awk \
	    -f ${GCCDIR}/optc-gen.awk \
		-v header_name="config.h system.h coretypes.h tm.h" \
		< ${.ALLSRC} > ${.TARGET}
GENONLY+=	optionlist options.h options.c

# Target machine config
tm.h:
	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
	HEADERS="${TARGET_INC}" \
	DEFINES="" \
	/bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
	echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}

# XXX This is an ugly hack to make it search in our old dir too.
	echo '#define GPLUSPLUS_TOOL_INCLUDE_DIR PREFIX"/include/g++/${GCC_TARGET}"' >> ${.TARGET}
.endif

GENSRCS+=	tm.h
CLEANFILES+=	cs-tm.h

# Target machine protos/preds.
tm_p.h:
	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
	HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \
	DEFINES="" \
	/bin/sh ${GCCDIR}/mkconfig.sh tm_p.h

GENSRCS+=	tm_p.h
CLEANFILES+=	cs-tm_p.h

# gencheck
gencheck.h: ${TREE_DEF_FILES}
.for F in ${TREE_DEF_FILES}
	echo "#include \"$F\""					>> ${.TARGET}
.endfor
	touch ${.TARGET}

GENSRCS+=	gencheck.h


# Source header for gtyp generator.
gtyp-gen.h:	${GTFILES}
	echo "/* This file is machine generated.  Do not edit.  */" > ${.TARGET}
	echo "static const char * const srcdir = "		>> ${.TARGET}
	echo "\"$(GTFILES_SRCDIR)\";"				>> ${.TARGET}
	echo "static const char * const lang_files[] = {"	>> ${.TARGET}
.for F in ${GTFILES_FILES}
	echo "\"$F\", "						>> ${.TARGET}
.endfor
	echo "NULL};"						>> ${.TARGET}
	echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET}
.for F in ${GTFILES_LANGS}
	echo "\"$F\", "						>> ${.TARGET}
.endfor
	echo "NULL};"						>> ${.TARGET}
	echo "static const char * const all_files[] = {"	>> ${.TARGET}
.for F in ${GTFILES}
	echo "\"$F\", "						>> ${.TARGET}
.endfor
	echo "NULL};"						>> ${.TARGET}
	echo "static const char * const lang_dir_names[] = {"	>> ${.TARGET}
.for F in c ${GTFILES_LANG_DIR_NAMES}
	echo "\"$F\", "						>> ${.TARGET}
.endfor
	echo "NULL};"						>> ${.TARGET}

GENSRCS+=	gtyp-gen.h

# Version header for gcov
gcov-iov.h:
	echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET}

GENSRCS+=	gcov-iov.h

# Multilib config file
multilib.h:
	echo 'static const char *const multilib_raw[] = { \
	    ". ;", NULL };'					> ${.TARGET}
	echo 'static const char *const multilib_matches_raw[] = { \
	    NULL };'						>> ${.TARGET}
	echo 'static const char *multilib_extra = "";'		>> ${.TARGET}
	echo 'static const char *multilib_options = "";'	>> ${.TARGET}
	echo 'static const char *const multilib_exclusions_raw[] = { \
	    NULL };'						>> ${.TARGET}

GENSRCS+=	multilib.h

configargs.h:
	echo 'static const char configuration_arguments[] ='	> ${.TARGET}
	echo '	"OpenBSD/${TARGET_ARCH} system compiler";'	>> ${.TARGET}
	echo 'static const char thread_model[] = "posix";'	>> ${.TARGET}
	echo 'static const struct {'				>> ${.TARGET}
	echo '	const char *name, *value;'			>> ${.TARGET}
	echo '} configure_default_options[] = {'		>> ${.TARGET}
	echo '	{ "NULL", "NULL" } };'				>> ${.TARGET}

GENSRCS+=	configargs.h

# Language spec files
specs.h:
	echo '#include "cp/lang-specs.h"'			> ${.TARGET}
	echo '#include "objc/lang-specs.h"'			>> ${.TARGET}

GENSRCS+=	specs.h

gstdint.h:
	echo '#include "sys/types.h"'				> ${.TARGET}
	echo '#include "sys/stdint.h"'				>> ${.TARGET}

GENSRCS+=	gstdint.h

# Linked headers
gthr-default.h: ${GCCDIR}/gthr-posix.h
	ln -sf ${.ALLSRC} ${.TARGET}

GENSRCS+=	gthr-default.h

unwind.h: ${GCCDIR}/unwind-generic.h
	ln -sf ${.ALLSRC} ${.TARGET}

GENSRCS+=	unwind.h

#
# gtype gunk
#
gengtype-lex.c:	gengtype-lex.l
	flex -ogengtype-lex.c ${.ALLSRC}

gengtype-yacc.h: gengtype-yacc.y
	yacc -d -o gengtype-yacc.c ${.ALLSRC}

gengtype-yacc.c: gengtype-yacc.h

gengtype-yacc+%DIKED.c: gengtype-yacc.c
	cat    ${.ALLSRC} > ${.TARGET}
	sed -e "s/xmalloc/malloc/g" \
	    -e "s/xrealloc/realloc/g" \
	    -e "s/malloc/xmalloc/g" \
	    -e "s/realloc/xrealloc/g" \
	    ${.ALLSRC} > ${.TARGET}

GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c
CLEANFILES+= gengtype-yacc.c

gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \
	  ${LIBIBERTY}
	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}

gtype-desc.h:	gengtype
	./gengtype
	touch ${.TARGET}

gtype-desc.c:	gtype-desc.h

GENONLY+=	gtype-desc.c gtype-desc.h
CLEANFILES+=	gt-*.h gtype-*.h

#
# Generator tools.
#
.for F in check checksum genrtl modes
gen$F:	gen$F.o errors.o ${LIBIBERTY}
	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
.endfor

.for F in attr attrtab automata codes conditions config constants emit \
	extract flags  opinit output peep preds recog
gen$F:	gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \
	gensupport.o print-rtl.o errors.o ${LIBIBERTY}
	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
.endfor

gencondmd:	gencondmd.o
	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}

#
# Generated .md files.
#
insn-conditions.md:	gencondmd
	./gencondmd > ${.TARGET}
GENSRCS+=	insn-conditions.md

#
# Generated header files.
#

.for F in constants
insn-$F.h:	gen$F ${MD_FILE}
	./gen$F ${MD_FILE} > ${.TARGET}
GENSRCS+=	insn-$F.h
.endfor

.for F in attr codes config flags
insn-$F.h:	gen$F ${MD_FILE} insn-conditions.md
	./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
GENSRCS+=	insn-$F.h
.endfor

# Header files with irregular names.
genrtl.h:	gengenrtl
	./gengenrtl -h > ${.TARGET}
GENSRCS+=	genrtl.h

tm-preds.h:	genpreds
	./genpreds -h ${MD_FILE} > ${.TARGET}
GENSRCS+=	tm-preds.h

tm-constrs.h:	genpreds
	./genpreds -c ${MD_FILE} > ${.TARGET}
GENSRCS+=	tm-constrs.h

tree-check.h:	gencheck
	./gencheck > ${.TARGET}
GENSRCS+=	tree-check.h

insn-modes.h:	genmodes
	./genmodes -h > ${.TARGET}
GENSRCS+=	insn-modes.h

#
# Generated source files.
#
.for F in attrtab automata emit extract opinit output peep preds recog
insn-$F.c:	gen$F ${MD_FILE} insn-conditions.md
	./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
GENONLY+=	insn-$F.c
.endfor

.for F in conditions
insn-$F.c:	gen$F ${MD_FILE}
	./gen$F ${MD_FILE} > ${.TARGET}
GENSRCS+=	insn-$F.c
.endfor

# Source files with irregular names.
insn-modes.c:	genmodes
	./genmodes > ${.TARGET}
GENONLY+=	insn-modes.c

min-insn-modes.c:	genmodes
	./genmodes -m > ${.TARGET}
GENSRCS+=	min-insn-modes.c

genrtl.c:	gengenrtl
	./gengenrtl > ${.TARGET}
GENONLY+=	genrtl.c

gencondmd.c:	genconditions ${MD_FILE}
	./genconditions ${MD_FILE} > ${.TARGET}
GENSRCS+=	gencondmd.c

#-----------------------------------------------------------------------
# Build tools.

GNTOOLS+=	genattr genattrtab genautomata gencodes gencheck genchecksum \
		genconditions gencondmd genconfig genconstants genemit \
		genextract genflags gengenrtl gengtype genmodes genopinit \
		genoutput genpeep genpreds genrecog

all: ${GNTOOLS} ${GENSRCS} ${GENONLY}
beforedepend: ${GENONLY}

#-----------------------------------------------------------------------
# Fixups.

# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
# define PROG because we have multiple programs.
#
SRCS=		errors.c genattr.c genattrtab.c \
		genautomata.c gencheck.c genchecksum.c gencodes.c \
		genconditions.c genconfig.c genconstants.c genemit.c \
		genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \
		genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \
		gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \
		vec.c

SRCS+=		${GENSRCS}
OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
GENOBJS+=	${GENSRCS:N*.h:R:S/$/.o/g}
CLEANFILES+=	${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS}

#-----------------------------------------------------------------------
# Manual dependencies.
.if !exists(${DEPENDFILE})
.include  "Makefile.dep"
.endif

.include <bsd.prog.mk>
# DO NOT DELETE