1# $FreeBSD$
2#
3# This is logic for common headers shared inside of gnu/lib.  It used to
4# live in gnu/usr.bin/cc/cc_tools/Makefile.
5
6.if !defined(TARGET_CPUARCH) || !defined(GCC_CPU)
7.error ${.CURDIR}: Must include gnu/usr.bin/cc/Makefile.tgt first.
8.endif
9
10#
11# The list of headers to go into tm.h
12#
13TARGET_INC+=	options.h
14.if ${TARGET_CPUARCH} == "amd64"
15TARGET_INC+=	i386/biarch64.h
16.endif
17.if ${TARGET_CPUARCH} != "arm"
18TARGET_INC+=	${GCC_CPU}/${GCC_CPU}.h
19.endif
20.if ${TARGET_CPUARCH} == "i386" || ${TARGET_CPUARCH} == "amd64"
21TARGET_INC+=	${GCC_CPU}/unix.h
22TARGET_INC+=	${GCC_CPU}/att.h
23.endif
24TARGET_INC+=	dbxelf.h
25TARGET_INC+=	elfos-undef.h
26TARGET_INC+=	elfos.h
27TARGET_INC+=	freebsd-native.h
28TARGET_INC+=	freebsd-spec.h
29TARGET_INC+=	freebsd.h
30.if ${TARGET_CPUARCH} != "i386" && ${TARGET_CPUARCH} != "amd64"
31. if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
32TARGET_INC+=	${GCC_CPU}/sysv4.h
33. endif
34.endif
35.if ${TARGET_CPUARCH} == "amd64"
36TARGET_INC+=	${GCC_CPU}/x86-64.h
37.endif
38.if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "mips"
39TARGET_INC+=	${GCC_CPU}/elf.h
40.endif
41.if ${TARGET_CPUARCH} == "arm"
42TARGET_INC+=	${GCC_CPU}/aout.h
43TARGET_INC+=	${GCC_CPU}/bpabi.h
44.endif
45.if ${TARGET_ARCH} == "powerpc64"
46TARGET_INC+=	${GCC_CPU}/biarch64.h
47TARGET_INC+=    ${GCC_CPU}/default64.h
48.endif
49.if ${TARGET_ARCH} == "powerpcspe" 	 
50TARGET_INC+=    ${GCC_CPU}/freebsdspe.h 	 
51TARGET_INC+=    ${GCC_CPU}/e500-double.h 	 
52.endif
53TARGET_INC+=	${GCC_CPU}/freebsd.h
54.if ${TARGET_CPUARCH} == "amd64"
55TARGET_INC+=	${GCC_CPU}/freebsd64.h
56.endif
57.if ${TARGET_CPUARCH} == "arm"
58TARGET_INC+=	${GCC_CPU}/arm.h
59.endif
60TARGET_INC+=	defaults.h
61
62#
63# Option files.
64#
65OPT_FILES=	c.opt common.opt
66
67.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt)
68OPT_FILES+=	${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt
69.endif
70
71.if exists(${.CURDIR}/${GCC_CPU}-freebsd.opt)
72OPT_FILES+=	${.CURDIR}/${GCC_CPU}-freebsd.opt
73.endif
74
75.if ${TARGET_CPUARCH} == "powerpc"
76OPT_FILES+=	${GCCDIR}/config/${GCC_CPU}/sysv4.opt
77.endif
78
79.if ${TARGET_CPUARCH} == "sparc64"
80OPT_FILES+=	${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt
81.endif
82
83.if exists(${.CURDIR}/freebsd.opt)
84OPT_FILES+=	${.CURDIR}/freebsd.opt
85.endif
86
87
88# Options
89optionlist: ${OPT_FILES}
90	LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET}
91
92options.h:	optionlist
93	LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \
94	    -f ${GCCDIR}/opth-gen.awk \
95		< ${.ALLSRC} > ${.TARGET}
96
97options.c:	optionlist
98	LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \
99	    -f ${GCCDIR}/optc-gen.awk \
100		-v header_name="config.h system.h coretypes.h tm.h" \
101		< ${.ALLSRC} > ${.TARGET}
102
103# Target machine config
104tm.h:
105	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
106	HEADERS="${TARGET_INC}" \
107	DEFINES="" \
108	/bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
109.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
110	echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
111.endif
112
113# tconfig.h
114tconfig.h:
115	TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
116	HEADERS="auto-host.h ansidecl.h" \
117	DEFINES="USED_FOR_TARGET" \
118	/bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
119
120# Version header for gcov
121gcov-iov.h:
122	echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET}
123
124# Linked headers
125gthr-default.h: ${GCCDIR}/gthr-posix.h .NOMETA
126	ln -sf ${.ALLSRC} ${.TARGET}
127
128.if ${TARGET_CPUARCH} == "arm"
129unwind.h: ${GCCDIR}/config/arm/unwind-arm.h
130.else
131unwind.h: ${GCCDIR}/unwind-generic.h
132.endif
133
134unwind.h: .NOMETA
135	ln -sf ${.ALLSRC} ${.TARGET}
136
137