Makefile.ia64 revision 78161
1# Makefile.ia64 -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: src/sys/conf/Makefile.alpha,v 1.76
4# $FreeBSD: head/sys/conf/Makefile.ia64 78161 2001-06-13 10:58:39Z peter $
5#
6# Makefile for FreeBSD
7#
8# This makefile is constructed from a machine description:
9#	config machineid
10# Most changes should be made in the machine description
11#	/sys/ia64/conf/``machineid''
12# after which you should do
13#	 config machineid
14# after which config should be rerun for all machines.
15#
16
17# The Linux cross tools don't understand -fformat-extensions
18CWARNFLAGS=	-Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
19		-Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
20		-ansi
21CC=		ia64-unknown-linux-gcc -D__FreeBSD__ -U__linux__
22LD=		ia64-unknown-linux-ld
23NM=		ia64-unknown-linux-nm
24SIZE=		ia64-unknown-linux-size
25OBJCOPY=	ia64-unknown-linux-objcopy
26OBJDUMP=	ia64-unknown-linux-objdump
27MACHINE_ARCH=	ia64
28
29# Which version of config(8) is required.
30%VERSREQ=	500006
31
32# Can be overridden by makeoptions or /etc/make.conf
33KERNEL_KO?=	kernel
34KERNEL?=	kernel
35KODIR?=		/boot/${KERNEL}
36STD8X16FONT?=	iso
37
38.if !defined(S)
39.if exists(./@/.)
40S=	./@
41.else
42S=	../..
43.endif
44.endif
45M=	${MACHINE_ARCH}
46
47SIZE?=		size
48OBJCOPY?=	objcopy
49
50COPTFLAGS?=-O -pipe
51.if !defined(NO_CPU_COPTFLAGS)
52COPTFLAGS+= ${_CPUCFLAGS}
53.endif
54INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
55
56# This hack lets us use the Intel ACPICA code without spamming a new 
57# include path into 100+ source files.
58INCLUDES+= -I$S/contrib/dev/acpica
59
60# ... and the same for ipfilter
61INCLUDES+= -I$S/contrib/ipfilter
62
63# This hack is to allow kernel compiles to succeed on machines w/out srcdist
64.if exists($S/../include)
65INCLUDES+= -I$S/../include
66.else
67INCLUDES+= -I/usr/include
68.endif
69
70COPTS=	${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
71CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
72
73# XXX LOCORE means "don't declare C stuff" not "for locore.s".
74ASM_CFLAGS= -x assembler-with-cpp -Wa,-x -DLOCORE ${CFLAGS}
75
76# Select the correct set of tools. Can't set OBJFORMAT here because it
77# doesn't get exported into the environment, and if it were exported
78# then it might break building of utilities.
79#FMT=		-elf
80CFLAGS+=	${FMT}
81
82DEFINED_PROF=	${PROF}
83.if defined(PROF)
84CFLAGS+=	-malign-functions=4
85.if ${PROFLEVEL} >= 2
86IDENT+=	-DGPROF4 -DGUPROF
87PROF+=	-mprofiler-epilogue
88.endif
89.endif
90
91# Put configuration-specific C flags last (except for ${PROF}) so that they
92# can override the others.
93CFLAGS+=	${CONF_CFLAGS}
94
95NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
96NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
97NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
98PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
99
100NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
101	  ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
102
103GEN_CFILES= $S/$M/$M/genassym.c
104SYSTEM_CFILES= param.c vnode_if.c hints.c config.c
105SYSTEM_SFILES= $S/$M/$M/locore.s
106SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
107SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} param.o hints.o config.o \
108	# hack.So ski can't cope with dynamic relocs
109SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
110	-e locorestart \
111	-export-dynamic -dynamic-linker /red/herring \
112	-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
113SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
114	${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
115SYSTEM_DEP+= $S/conf/ldscript.$M
116
117%BEFORE_DEPEND
118
119%OBJS
120
121%FILES.c
122
123%FILES.s
124
125%FILES.m
126
127%CLEAN
128
129.PHONY:	all modules
130all: ${KERNEL_KO}
131
132depend: kernel-depend
133clean:  kernel-clean
134cleandepend:  kernel-cleandepend
135clobber: kernel-clobber
136tags:  kernel-tags
137install: kernel-install
138install.debug: kernel-install.debug
139reinstall: kernel-reinstall
140reinstall.debug: kernel-reinstall.debug
141
142.if !defined(DEBUG)
143FULLKERNEL=	${KERNEL_KO}
144.else
145FULLKERNEL=	${KERNEL_KO}.debug
146${KERNEL_KO}: ${FULLKERNEL}
147	${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
148.endif
149
150${FULLKERNEL}: ${SYSTEM_DEP} vers.o
151	@rm -f ${.TARGET}
152	@echo linking ${.TARGET}
153	${SYSTEM_LD}
154	${SYSTEM_LD_TAIL}
155
156.if !exists(.depend)
157${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
158.endif
159
160.for mfile in ${MFILES}
161${mfile:T:S/.m$/.h/}: ${mfile}
162	perl5 $S/kern/makeobjops.pl -h ${mfile}
163.endfor
164
165kernel-clean:
166	rm -f *.o *.so *.So *.ko *.s eddep errs \
167	      ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \
168	      setdef[01].c setdefs.h tags \
169	      vers.c vnode_if.c vnode_if.h \
170	      ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
171	      ${CLEAN}
172
173kernel-clobber:
174	find . -type f ! -name version -delete
175
176locore.o: $S/$M/$M/locore.s assym.s
177	${NORMAL_S}
178
179# This is a hack.  BFD "optimizes" away dynamic mode if there are no
180# dynamic references.  We could probably do a '-Bforcedynamic' mode like
181# in the a.out ld.  For now, this works.
182hack.So: Makefile
183	touch hack.c
184	${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
185	rm -f hack.c
186
187# this rule stops ./assym.s in .depend from causing problems
188./assym.s: assym.s
189
190assym.s: $S/kern/genassym.sh genassym.o
191	NM=${NM} sh $S/kern/genassym.sh genassym.o > ${.TARGET}
192
193genassym.o: $S/$M/$M/genassym.c
194	${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
195
196${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
197
198kernel-depend:
199	rm -f .olddep
200	if [ -f .depend ]; then mv .depend .olddep; fi
201	${MAKE} _kernel-depend
202
203_kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
204	    ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
205	    ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
206	if [ -f .olddep ]; then mv .olddep .depend; fi
207	rm -f .newdep
208	CC="${CC}" mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
209	env MKDEP_CPP="${CC} -E" \
210	    mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
211	rm -f .depend
212	mv .newdep .depend
213
214kernel-cleandepend:
215	rm -f .depend
216
217links:
218	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
219	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
220	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
221	  sort -u | comm -23 - dontlink | \
222	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
223	sh makelinks; rm -f dontlink
224
225kernel-tags:
226	@[ -f .depend ] || { echo "you must make depend first"; exit 1; }
227	sh $S/conf/systags.sh
228	rm -f tags1
229	sed -e 's,      ../,    ,' tags > tags1
230
231kernel-install kernel-install.debug:
232.if exists(${DESTDIR}/boot)
233	@if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
234		echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
235		exit 1 ; \
236	fi
237	@if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
238		echo "You must activate /boot/device.hints in loader.conf." ; \
239		exit 1 ; \
240	fi
241.endif
242	@if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
243		echo "You must build a kernel first." ; \
244		exit 1 ; \
245	fi
246.if exists(${DESTDIR}${KODIR})
247.if exists(${DESTDIR}${KODIR}.old)
248	@-chflags -R noschg ${DESTDIR}${KODIR}.old
249	-rm -rf ${DESTDIR}${KODIR}.old
250.endif
251	mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
252.endif
253	mkdir -p ${DESTDIR}${KODIR}
254	install -c -m 555 -o root -g wheel \
255		${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
256
257kernel-reinstall kernel-reinstall.debug:
258	@-chflags -R noschg ${DESTDIR}${KODIR}
259	install -c -m 555 -o root -g wheel \
260		${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
261
262.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
263all:	modules
264depend: modules-depend
265clean:  modules-clean
266cleandepend:  modules-cleandepend
267cleandir:  modules-cleandir
268clobber:  modules-clobber
269tags:  modules-tags
270install: modules-install
271install.debug: modules-install.debug
272reinstall: modules-reinstall
273reinstall.debug: modules-reinstall.debug
274.endif
275
276MKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
277.if defined(MODULES_OVERRIDE)
278MKMODULESENV+=	MODULES_OVERRIDE="${MODULES_OVERRIDE}"
279.endif
280
281modules:
282	@mkdir -p ${.OBJDIR}/modules
283	cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
284	    env ${MKMODULESENV} ${MAKE} all
285
286modules-depend:
287	@mkdir -p ${.OBJDIR}/modules
288	cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
289	    env ${MKMODULESENV} ${MAKE} depend
290
291modules-clean:
292	cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
293
294modules-cleandepend:
295	cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
296
297modules-clobber:	modules-clean
298	rm -rf ${MKMODULESENV}
299
300modules-cleandir:
301	cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
302
303modules-tags:
304	cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
305
306modules-install modules-install.debug:
307	cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
308
309modules-reinstall modules-reinstall.debug:
310	cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
311
312config.o:
313	${NORMAL_C}
314
315param.c: $S/conf/param.c
316	-rm -f param.c
317	cp $S/conf/param.c .
318
319param.o:
320	${NORMAL_C}
321
322vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
323	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
324
325# XXX strictly, everything depends on Makefile because changes to ${PROF}
326# only appear there, but we don't handle that.
327vers.o:
328	${NORMAL_C}
329
330hints.o:	hints.c
331	${NORMAL_C}
332
333vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
334	perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
335
336vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
337	perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
338
339vnode_if.o:
340	${NORMAL_C}
341
342.include <bsd.kern.mk>
343
344%RULES
345
346# DO NOT DELETE THIS LINE -- make depend uses it
347