Makefile.arm revision 1.11
1#	$NetBSD: Makefile.arm,v 1.11 2001/11/06 19:52:21 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/<arch>/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/arm/conf/Makefile.arm
13# after which config should be rerun for all machines of that type.
14
15USETOOLS?=	no
16
17.include <bsd.own.mk>
18
19# DEBUG is set to -g if debugging.
20# PROF is set to -pg if profiling.
21
22AR?=	ar
23AS?=	as
24CC?=	cc
25CPP?=	cpp
26LD?=	ld
27LORDER?=lorder
28MKDEP?=	mkdep
29NM?=	nm
30RANLIB?=ranlib
31SIZE?=	size
32STRIP?=	strip
33TSORT?=	tsort -q
34
35COPTS?=	-O2
36
37.if	$S == "../../../.."
38S!=		cd ../../../..; pwd
39.endif
40
41ARM32=		$S/arch/arm32
42ARM=		$S/arch/arm
43THISARM=	$S/arch/${MACHINE}
44
45HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
46INCLUDES=	-I. -I./include -I$S/arch -I$S -nostdinc
47CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
48		-D_KERNEL -D_KERNEL_OPT -D${MACHINE}
49CWARNFLAGS?=	-Werror -Wall -Wcomment -Wpointer-arith
50# XXX Delete -Wuninitialized for now, since the compiler doesn't
51# XXX always get it right.  --thorpej 
52CWARNFLAGS+=	-Wno-uninitialized
53.if (${HAVE_EGCS} != "")
54CWARNFLAGS+=	-Wno-main
55.endif
56CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
57AFLAGS=		-x assembler-with-cpp -D_LOCORE
58
59LOADADDRESS?=	0xF0000000
60LINKENTRY?=	-e start
61LINKFLAGS=	-Ttext ${LOADADDRESS} ${LINKENTRY} ${EXTRA_LINKFLAGS}
62STRIPFLAGS=	-g
63
64.if exists($S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc)
65.include	"$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"
66.endif
67
68%INCLUDES
69
70HOSTED_CC=	${CC}
71HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
72HOSTED_CFLAGS=	${CFLAGS}
73
74### find out what to use for libkern
75KERN_AS=	obj
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 $<
95NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
96NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
97
98HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
99
100%OBJS
101
102%CFILES
103
104%SFILES
105
106# load lines for config "xxx" will be emitted as:
107# xxx: ${SYSTEM_DEP} swapxxx.o
108#	${SYSTEM_LD_HEAD}
109#	${SYSTEM_LD} swapxxx.o
110#	${SYSTEM_LD_TAIL}
111SYSTEM_OBJ=	${SYSTEM_FIRST_OBJ} locore.o \
112		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
113SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
114SYSTEM_LD_HEAD=	rm -f $@
115SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
116		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
117SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
118
119DEBUG?=
120.if ${DEBUG} == "-g"
121LINKFLAGS+=	-X
122SYSTEM_LD_TAIL+=; \
123		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
124		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
125		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
126.else
127#LINKFLAGS+=	-S
128LINKFLAGS+=	-X
129.endif
130
131.if defined(SYSTEM_LD_TAIL_EXTRA)
132SYSTEM_LD_TAIL+=; \
133		${SYSTEM_LD_TAIL_EXTRA}
134.endif
135
136%LOAD
137
138assym.h: $S/kern/genassym.sh ${ARM}/arm32/genassym.cf
139	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
140	    < ${ARM}/arm32/genassym.cf > assym.h.tmp && \
141	mv -f assym.h.tmp assym.h
142
143param.c: $S/conf/param.c
144	rm -f param.c
145	cp $S/conf/param.c .
146
147param.o: param.c Makefile
148	${NORMAL_C}
149
150ioconf.o: ioconf.c
151	${NORMAL_C}
152
153newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
154	sh $S/conf/newvers.sh
155	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
156
157__CLEANKERNEL: .USE
158	@echo "${.TARGET}ing the kernel objects"
159	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
160	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h ${EXTRA_CLEAN}
161
162__CLEANDEPEND: .USE
163	rm -f .depend
164
165clean: __CLEANKERNEL
166
167cleandir distclean: __CLEANKERNEL __CLEANDEPEND
168
169lint:
170	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
171	    ${ARM32}/arm32/Locore.c ${CFILES}  \
172	    ioconf.c param.c | \
173	    grep -v 'static function .* unused'
174
175tags:
176	@echo "see $S/kern/Makefile for tags"
177
178links:
179	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
180	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
181	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
182	  sort -u | comm -23 - dontlink | \
183	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
184	sh makelinks && rm -f dontlink
185
186SRCS=	${ARM}/arm32/locore.S param.c ioconf.c ${CFILES} ${SFILES} \
187	${EXTRA_CFILES} ${EXTRA_SFILES} ${SYSTEM_FIRST_SFILE}
188
189depend: .depend
190.depend: ${SRCS} assym.h param.c
191	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SYSTEM_FIRST_SFILE} \
192	    ${ARM}/arm32/locore.S ${EXTRA_SFILES}
193	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} \
194	    ${EXTRA_CFILES}
195	test -z "${SFILES}" || ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
196	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
197	    ${CPPFLAGS} < ${ARM}/arm32/genassym.cf
198	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
199	@rm -f assym.dep
200
201dependall: depend all
202
203.if !exists(include)
204${OBJS} assym.h .depend: include-dir
205include-dir:
206	@rm -rf include
207	@mkdir -p include/arm
208.if (${S} == "../../../..")
209	@(cd include/arm; ln -s ../../$S/arch/${MACHINE}/include ${MACHINE})
210	@(cd include; ln -s ../$S/arch/arm/include machine)
211.else
212	@ln -s $S/arch/${MACHINE}/include include/arm/${MACHINE}
213	@ln -s $S/arch/arm/include include/machine
214.endif
215.endif
216
217# depend on root or device configuration
218autoconf.o conf.o: Makefile
219 
220# depend on network
221uipc_proto.o: Makefile 
222
223# depend on maxusers
224assym.h: Makefile
225
226# depend on CPU configuration 
227cpufunc.o cpufunc_asm.o: Makefile
228
229# depend on DIAGNOSTIC etc.
230cpuswitch.o fault.o machdep.o: Makefile
231
232.if defined(SYSTEM_FIRST_OBJ)
233${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
234	${NORMAL_S}
235.endif
236
237locore.o: ${ARM}/arm32/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