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