summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/cc/cc_tools/Makefile
blob: 91eba61a73bfb8131531c19d12b08ea48cce88da (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
# $FreeBSD$

#
# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
# is such a !@#!*#% nightmare because of how it reprograms the dependencies,
# suffix rules, SRCS, etc.  It's easiest to cheat by using bsd.prog.mk and
# SRCS to get dependencies.
#

# ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
# Prevent mkdep from using it, so that we don't have to give rules for
# aliases of generated headers.

CFLAGS+=	-I.

.include "../Makefile.inc"

.PATH: ${GCCDIR} ${GCCDIR}/cp

#-----------------------------------------------------------------------
# insn-* gunk

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

.for F in attrtab emit extract opinit output peep recog
insn-$F.c: gen$F ${MD_FILE}
	./gen$F ${MD_FILE} > insn-$F.c
GENSRCS+=	insn-$F.c
.endfor

.for F in attr codes config emit extract flags opinit output peep recog
build-tools: gen$F

gen$F: gen$F.o rtl.o obstack.o print-rtl.o bitmap.o
	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}

GENSRCS+=	gen$F.c
CLEANFILES+=	gen$F
.endfor

.for F in attrtab
build-tools: gen$F

gen$F: gen$F.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}

GENSRCS+=	gen$F.c
CLEANFILES+=	gen$F
.endfor

SRCS+=		bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c

.for F in check genrtl
build-tools: gen$F

gen$F: gen$F.o
	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}

GENSRCS+=	gen$F.c
CLEANFILES+=	gen$F
.endfor

.ORDER: genrtl.c genrtl.h
genrtl.c genrtl.h: gengenrtl
	./gengenrtl genrtl.h genrtl.c

GENSRCS+=	genrtl.c genrtl.h

#-----------------------------------------------------------------------
# C hash codes
c-gperf.h: c-parse.gperf
	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
	    ${GCCDIR}/c-parse.gperf > ${.TARGET}
GENSRCS+=	c-gperf.h

#-----------------------------------------------------------------------
# C++ hash codes
gxx-hash.h: gxx.gperf
	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
	    ${GCCDIR}/cp/gxx.gperf >gxx-hash.h
GENSRCS+=	gxx-hash.h

# make a link the the Cygnus used name for now -- hopes are they will change it
hash.h: gxx-hash.h
	ln -sf ${.ALLSRC} ${.TARGET}
GENSRCS+=	hash.h

#-----------------------------------------------------------------------
# Common parser stuff.

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

#-----------------------------------------------------------------------
# the host/target compiler config.

COMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
GENSRCS+=	${COMMONHDRS} gencheck.h

config.h hconfig.h:
	echo '#include "auto-host.h"'			> ${.TARGET}
	echo '#include "gansidecl.h"'			>> ${.TARGET}
	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}
	echo '#include "hwint.h"'			>> ${.TARGET}

gencheck.h:
	echo '#include "cp/cp-tree.def"'		> ${.TARGET}
	echo '#include "objc/objc-tree.def"'		>> ${.TARGET}

multilib.h:
	echo 'static char *multilib_raw[] = { \
	    "aout maout;", "elf !maout;", NULL };'	> ${.TARGET}
	echo 'static char *multilib_matches_raw[] = { \
	    "maout maout;", "melf melf;", NULL };'	>> ${.TARGET}
	echo 'static char *multilib_extra = "";'	>> ${.TARGET}

options.h:
	echo '#include "cp/lang-options.h"'		> ${.TARGET}
	echo '#include "f/lang-options.h"'		>> ${.TARGET}

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

tconfig.h:
	echo '#include "gansidecl.h"'			> ${.TARGET}
	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}

#	KEEP THIS IN SYNC with src/gcc/lib/libgcc/Makefile !!
tm.h:
	echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"'	> ${.TARGET}
.if ${GCC_ARCH} == "i386"
	echo '#include "${GCC_ARCH}/att.h"'		>> ${.TARGET}
.endif
	echo '#include <freebsd.h>'			>> ${.TARGET}
	echo '#include "${GCC_ARCH}/freebsd.h"'		>> ${.TARGET}
.if ${GCC_ARCH} == "i386"
	echo '#include "${GCC_ARCH}/perform.h"'		>> ${.TARGET}
.endif
	echo '#include <freebsd-native.h>'		>> ${.TARGET}

#-----------------------------------------------------------------------
# General things.

SRCS+=		${GENSRCS}
CLEANFILES+=	${GENSRCS}

all: ${SRCS}

.include <bsd.prog.mk>

#-----------------------------------------------------------------------
# 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.
#
OBJS+=		${SRCS:N*.h:R:S/$/.o/g}

.if !exists(${DEPENDFILE})
# Fudge pre-dependfile dependencies of objects in much the same way as
# bsd.prog.mk would do if we defined PROG.  There are complications to
# avoid circular dependencies.  First, only make most objects depend on
# all headers.  Filter out the objects that would cause problems (i.e.,
# objects that will be used to create programs that will generate headers).
#
${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}

# Next, make each of the problematic objects depend on only most headers.
# Filter out the headers that would cause problems (and a few more when it
# is inconvenient to filter precisely).
#
bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o print-rtl.o \
    rtl.o: ${SRCS:M*.h:Ninsn-*.h}
gencheck.o: gencheck.h ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
.endif
OpenPOWER on IntegriCloud