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