Makefile.sparc64 revision 1.39
1# 	$NetBSD: Makefile.sparc64,v 1.39 2001/10/21 19:46:16 thorpej Exp $
2
3# Makefile for NetBSD
4#
5# This makefile is constructed from a machine description:
6#	config machineid
7# Most changes should be made in the machine description
8#	/sys/arch/sparc64/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/sparc64/conf/Makefile.sparc64
13# after which config should be rerun for all machines of that type.
14
15.include <bsd.own.mk>
16
17# DEBUG is set to -g if debugging.
18# PROF is set to -pg if profiling.
19
20AR?=	ar
21AS?=	as
22CC?=	cc
23CPP?=	cpp
24LD?=	ld
25LORDER?=lorder
26MKDEP?=	mkdep
27NM?=	nm
28RANLIB?=ranlib
29SIZE?=	size
30STRIP?=	strip
31TSORT?=	tsort -q
32
33COPTS?= 	-O2
34
35# source tree is located via $S relative to the compilation directory
36.ifndef S
37S!=	cd ../../../..; pwd
38.endif
39SPARC64=	$S/arch/sparc64
40
41INCLUDES=	-I. -I$S/arch -I$S -nostdinc
42CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dsparc64
43CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
44		-Wpointer-arith
45# XXX Delete -Wuninitialized for now, since the compiler doesn't
46# XXX always get it right.  --thorpej
47CWARNFLAGS+=	-Wno-uninitialized
48CWARNFLAGS+=	-Wno-main
49CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -Wa,-Av9a -mno-fpu
50.if defined(PROF)
51# We need to run the compiler in medlow memory model.
52CFLAGS += -mcmodel=medlow
53.endif
54AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-Av9a
55
56#
57# Gotta find a way to make kernel base tuneable.
58#
59
60LINKFLAGS=	-Ttext 01000000 -Tdata 01800000 -e start
61#LINKFLAGS=	-Ttext f1000000 -Tdata f1400000 -e start
62
63LINKFLAGS+=	-n -T ${SPARC64}/conf/${KERN_LDSCRIPT}
64.if ${MACHINE_ARCH} == "sparc64"
65KERN_LDSCRIPT?= kern.ldscript
66.else
67KERN_LDSCRIPT?= kern32.ldscript
68.endif
69
70STRIPFLAGS=	-g
71
72%INCLUDES
73
74### find out what to use for libkern
75# KERN_AS=	obj	# bcopy, bzero, memcpy, memset, etc. are in locore.s
76.include "$S/lib/libkern/Makefile.inc"
77.ifndef PROF
78LIBKERN=	${KERNLIB}
79.else
80LIBKERN=	${KERNLIB_PROF}
81.endif
82
83### find out what to use for libcompat
84.include "$S/compat/common/Makefile.inc"
85.ifndef PROF
86LIBCOMPAT=	${COMPATLIB}
87.else
88LIBCOMPAT=	${COMPATLIB_PROF}
89.endif
90
91# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
92# HOSTED, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
93
94NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
95NOOPT_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -O0 -c $<
96NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
97
98%OBJS
99
100%CFILES
101
102%SFILES
103
104# load lines for config "xxx" will be emitted as:
105# xxx: ${SYSTEM_DEP} swapxxx.o
106#	${SYSTEM_LD_HEAD}
107#	${SYSTEM_LD} swapxxx.o
108#	${SYSTEM_LD_TAIL}
109SYSTEM_OBJ=	locore.o \
110		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
111SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
112SYSTEM_LD_HEAD=	rm -f $@
113SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
114		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
115SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
116
117DEBUG?=
118.if ${DEBUG} == "-g"
119LINKFLAGS+=	-X
120SYSTEM_LD_TAIL+=; \
121		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
122		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
123		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
124.else
125LINKFLAGS+=	-S
126.endif
127
128%LOAD
129
130assym.h: $S/kern/genassym.sh ${SPARC64}/sparc64/genassym.cf
131	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
132	    < ${SPARC64}/sparc64/genassym.cf > assym.h.tmp && \
133	mv -f assym.h.tmp assym.h
134
135param.c: $S/conf/param.c
136	rm -f param.c
137	cp $S/conf/param.c .
138
139param.o: param.c Makefile
140	${NORMAL_C}
141
142ioconf.o: ioconf.c
143	${NORMAL_C}
144
145newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
146	sh $S/conf/newvers.sh
147	${CC} ${COPTS} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
148
149
150__CLEANKERNEL: .USE
151	@echo "${.TARGET}ing the kernel objects"
152	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
153	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
154
155__CLEANDEPEND: .USE
156	rm -f .depend
157
158clean: __CLEANKERNEL
159
160cleandir distclean: __CLEANKERNEL __CLEANDEPEND
161
162lint:
163	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
164	    ${SPARC64}/sparc64/Locore.c ${CFILES} \
165	    ioconf.c param.c | \
166	    grep -v 'static function .* unused'
167
168tags:
169	@echo "see $S/kern/Makefile for tags"
170
171links:
172	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
173	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
174	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
175	  sort -u | comm -23 - dontlink | \
176	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
177	sh makelinks && rm -f dontlink
178
179SRCS=	${SPARC64}/sparc64/locore.s \
180	param.c ioconf.c ${CFILES} ${SFILES}
181depend: .depend
182.depend: ${SRCS} assym.h param.c
183	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SPARC64}/sparc64/locore.s
184	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
185.if (${SFILES} != "")
186	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
187.endif
188	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${COPTS} ${CFLAGS} \
189	  ${CPPFLAGS} < ${SPARC64}/sparc64/genassym.cf
190	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
191	@rm -f assym.dep
192
193dependall: depend all
194
195
196# depend on root or device configuration
197autoconf.o conf.o: Makefile
198
199# depend on network or filesystem configuration 
200uipc_proto.o vfs_conf.o: Makefile 
201
202# depend on maxusers
203machdep.o: Makefile
204
205# depend on CPU configuration 
206bwtwo.o cgsix.o cgthree.o cgtwo.o cons.o dma.o esp.o fb.o if_ie.o: Makefile
207ms.c obio.o zs.c autoconf.o clock.o cpu.o disksubr.o locore.o: Makefile
208machdep.o mem.o openprom.o pmap.o vm_machdep.o: Makefile
209
210
211locore.o: ${SPARC64}/sparc64/locore.s assym.h
212	${NORMAL_S}
213
214# The install target can be redefined by putting a
215# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
216MACHINE_NAME!=  uname -n
217install: install-kernel-${MACHINE_NAME}
218.if !target(install-kernel-${MACHINE_NAME}})
219install-kernel-${MACHINE_NAME}:
220	rm -f /onetbsd
221	ln /netbsd /onetbsd
222	cp netbsd /nnetbsd
223	mv /nnetbsd /netbsd
224.endif
225
226%RULES
227