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