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