Makefile.sparc64 revision 1.30
1# 	$NetBSD: Makefile.sparc64,v 1.30 2000/08/02 22:24:38 eeh 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# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
16#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
17#
18# -DTRACE	compile in kernel tracing hooks
19# -DQUOTA	compile in file system quotas
20
21# DEBUG is set to -g if debugging.
22# PROF is set to -pg if profiling.
23
24.if defined(MAKECONF) && exists(${MAKECONF})
25.include "${MAKECONF}"
26.elif exists(/etc/mk.conf)
27.include "/etc/mk.conf"
28.endif
29
30CC?=	cc
31.if exists(/usr/ccs/bin/ld)
32LD?=	/usr/ccs/bin/ld #Need to use Solaris ld to use the solaris loader
33.endif
34MKDEP?=	mkdep
35STRIP?=strip
36SIZE?=	size
37COPTS?= 	-O2
38#### Stuff for cross compiling
39NM?=nm
40LORDER?=lorder
41TSORT?=tsort
42
43
44# deal with Solaris vs. NetBSD build environments for now ..
45OS!=uname -s
46.if (${OS} == "NetBSD")
47USE_GENASSYM?=	no
48.else
49USE_GENASSYM?=	no
50AWK=nawk
51.endif
52
53.if exists(/usr/ccs/bin/ld)
54SVR4=-U__SVR4 -U__svr4__ -D__NetBSD__
55.else
56SVR4=
57.endif
58
59# source tree is located via $S relative to the compilation directory
60.ifndef S
61S!=	cd ../../../..; pwd
62.endif
63SPARC64=	$S/arch/sparc64
64
65INCLUDES=	-I. -I$S/arch -I$S -nostdinc
66CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL ${SVR4}
67CWARNFLAGS=	-Wimplicit -Wunused -Wswitch -Wcomment -Wtrigraphs -Wchar-subscripts -Wparentheses -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
68#CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes
69CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -Wa,-Av9a -mno-fpu
70.if defined(PROF)
71# We need to run the compiler in medlow memory model.
72CFLAGS += -mcmodel=medlow
73.endif
74AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-Av9a
75LINKFLAGS=	-Ttext f1000000 -Tdata f1400000 -e start
76#LINKFLAGS=	-N -Ttext f1000000 -e start
77STRIPFLAGS=	-g
78
79%INCLUDES
80
81### find out what to use for libkern
82# KERN_AS=	obj	# bcopy, bzero, memcpy, memset, etc. are in locore.s
83.include "$S/lib/libkern/Makefile.inc"
84.ifndef PROF
85LIBKERN=	${KERNLIB}
86.else
87LIBKERN=	${KERNLIB_PROF}
88.endif
89
90### find out what to use for libcompat
91.include "$S/compat/common/Makefile.inc"
92.ifndef PROF
93LIBCOMPAT=	${COMPATLIB}
94.else
95LIBCOMPAT=	${COMPATLIB_PROF}
96.endif
97
98# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
99# HOSTED, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
100
101NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
102NOOPT_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -O0 -c $<
103NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
104
105%OBJS
106
107%CFILES
108
109%SFILES
110
111# load lines for config "xxx" will be emitted as:
112# xxx: ${SYSTEM_DEP} swapxxx.o
113#	${SYSTEM_LD_HEAD}
114#	${SYSTEM_LD} swapxxx.o
115#	${SYSTEM_LD_TAIL}
116SYSTEM_OBJ=	locore.o \
117		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
118SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
119SYSTEM_LD_HEAD=	rm -f $@
120SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
121		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
122SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
123
124DEBUG?=
125.if ${DEBUG} == "-g"
126LINKFLAGS+=	-X
127SYSTEM_LD_TAIL+=; \
128		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
129		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
130		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
131.else
132LINKFLAGS+=	-S
133.endif
134
135%LOAD
136
137.if ${USE_GENASSYM} == "no"
138assym.h: $S/kern/genassym.sh ${SPARC64}/sparc64/genassym.cf
139	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
140	    < ${SPARC64}/sparc64/genassym.cf > assym.h.tmp && \
141	mv -f assym.h.tmp assym.h
142.else
143HOSTED_CC=	${CC}
144HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
145HOSTED_CFLAGS=	${CFLAGS}
146
147HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
148
149assym.h: genassym
150	./genassym >assym.h
151
152genassym: genassym.o
153	${CC} -o $@ genassym.o
154
155genassym.o: ${SPARC64}/sparc64/genassym.c
156	${HOSTED_C}
157.endif
158
159param.c: $S/conf/param.c
160	rm -f param.c
161	cp $S/conf/param.c .
162
163param.o: param.c Makefile
164	${NORMAL_C}
165
166ioconf.o: ioconf.c
167	${NORMAL_C}
168
169newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
170	sh $S/conf/newvers.sh
171	${CC} ${COPTS} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
172
173
174__CLEANKERNEL: .USE
175	@echo "${.TARGET}ing the kernel objects"
176	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
177	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
178
179__CLEANDEPEND: .USE
180	rm -f .depend
181
182clean: __CLEANKERNEL
183
184cleandir distclean: __CLEANKERNEL __CLEANDEPEND
185
186lint:
187	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
188	    ${SPARC64}/sparc64/Locore.c ${CFILES} \
189	    ioconf.c param.c | \
190	    grep -v 'static function .* unused'
191
192tags:
193	@echo "see $S/kern/Makefile for tags"
194
195links:
196	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
197	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
198	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
199	  sort -u | comm -23 - dontlink | \
200	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
201	sh makelinks && rm -f dontlink
202
203SRCS=	${SPARC64}/sparc64/locore.s \
204	param.c ioconf.c ${CFILES} ${SFILES}
205depend: .depend
206.depend: ${SRCS} assym.h param.c
207	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SPARC64}/sparc64/locore.s
208	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
209.if (${SFILES} != "")
210	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
211.endif
212	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${COPTS} ${CFLAGS} \
213	  ${CPPFLAGS} < ${SPARC64}/sparc64/genassym.cf
214	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
215	@rm -f assym.dep
216
217dependall: depend all
218
219
220# depend on root or device configuration
221autoconf.o conf.o: Makefile
222
223# depend on network or filesystem configuration 
224uipc_proto.o vfs_conf.o: Makefile 
225
226# depend on maxusers
227machdep.o: Makefile
228
229# depend on CPU configuration 
230bwtwo.o cgsix.o cgthree.o cgtwo.o cons.o dma.o esp.o fb.o if_ie.o: Makefile
231ms.c obio.o zs.c autoconf.o clock.o cpu.o disksubr.o locore.o: Makefile
232machdep.o mem.o openprom.o pmap.o vm_machdep.o: Makefile
233
234
235locore.o: ${SPARC64}/sparc64/locore.s assym.h
236	${NORMAL_S}
237
238# The install target can be redefined by putting a
239# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
240MACHINE_NAME!=  uname -n
241install: install-kernel-${MACHINE_NAME}
242.if !target(install-kernel-${MACHINE_NAME}})
243install-kernel-${MACHINE_NAME}:
244	rm -f /onetbsd
245	ln /netbsd /onetbsd
246	cp netbsd /nnetbsd
247	mv /nnetbsd /netbsd
248.endif
249
250%RULES
251