Makefile.arm revision 1.9
1#	$NetBSD: Makefile.arm,v 1.9 2001/10/23 18:57:32 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
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.if	$S == "../../../.."
36S!=		cd ../../../..; pwd
37.endif
38
39ARM32=		$S/arch/arm32
40ARM=		$S/arch/arm
41THISARM=	$S/arch/${MACHINE}
42
43HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
44INCLUDES=	-I. -I./include -I$S/arch -I$S -nostdinc
45CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
46		-D_KERNEL -D_KERNEL_OPT -D${MACHINE}
47CWARNFLAGS?=	-Werror -Wall -Wcomment -Wpointer-arith
48# XXX Delete -Wuninitialized for now, since the compiler doesn't
49# XXX always get it right.  --thorpej 
50CWARNFLAGS+=	-Wno-uninitialized
51.if (${HAVE_EGCS} != "")
52CWARNFLAGS+=	-Wno-main
53.endif
54CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
55AFLAGS=		-x assembler-with-cpp -D_LOCORE
56
57LOADADDRESS?=	0xF0000000
58LINKENTRY?=	-e start
59LINKFLAGS=	-Ttext ${LOADADDRESS} ${LINKENTRY} ${EXTRA_LINKFLAGS}
60STRIPFLAGS=	-g
61
62.if exists($S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc)
63.include	"$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"
64.endif
65
66%INCLUDES
67
68HOSTED_CC=	${CC}
69HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
70HOSTED_CFLAGS=	${CFLAGS}
71
72### find out what to use for libkern
73KERN_AS=	obj
74.include "$S/lib/libkern/Makefile.inc"
75.ifndef PROF
76LIBKERN=	${KERNLIB}
77.else
78LIBKERN=	${KERNLIB_PROF}
79.endif
80
81### find out what to use for libcompat
82.include "$S/compat/common/Makefile.inc"
83.ifndef PROF
84LIBCOMPAT=	${COMPATLIB}
85.else
86LIBCOMPAT=	${COMPATLIB_PROF}
87.endif
88
89# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
90# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
91
92NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
93NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
94NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
95
96HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_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=	${SYSTEM_FIRST_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
125#LINKFLAGS+=	-S
126LINKFLAGS+=	-X
127.endif
128
129%LOAD
130
131assym.h: $S/kern/genassym.sh ${ARM}/arm32/genassym.cf
132	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
133	    < ${ARM}/arm32/genassym.cf > assym.h.tmp && \
134	mv -f assym.h.tmp assym.h
135
136param.c: $S/conf/param.c
137	rm -f param.c
138	cp $S/conf/param.c .
139
140param.o: param.c Makefile
141	${NORMAL_C}
142
143ioconf.o: ioconf.c
144	${NORMAL_C}
145
146newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
147	sh $S/conf/newvers.sh
148	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
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 ${EXTRA_CLEAN}
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	    ${ARM32}/arm32/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=	${ARM}/arm32/locore.S param.c ioconf.c ${CFILES} ${SFILES} \
180	${EXTRA_CFILES} ${EXTRA_SFILES} ${SYSTEM_FIRST_SFILE}
181
182depend: .depend
183.depend: ${SRCS} assym.h param.c
184	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SYSTEM_FIRST_SFILE} \
185	    ${ARM}/arm32/locore.S ${EXTRA_SFILES}
186	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} \
187	    ${EXTRA_CFILES}
188	test -z "${SFILES}" || ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
189	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
190	    ${CPPFLAGS} < ${ARM}/arm32/genassym.cf
191	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
192	@rm -f assym.dep
193
194dependall: depend all
195
196.if !exists(include)
197${OBJS} assym.h .depend: include-dir
198include-dir:
199	@rm -rf include
200	@mkdir -p include/arm
201.if (${S} == "../../../..")
202	@(cd include/arm; ln -s ../../$S/arch/${MACHINE}/include ${MACHINE})
203	@(cd include; ln -s ../$S/arch/arm/include machine)
204.else
205	@ln -s $S/arch/${MACHINE}/include include/arm/${MACHINE}
206	@ln -s $S/arch/arm/include include/machine
207.endif
208.endif
209
210# depend on root or device configuration
211autoconf.o conf.o: Makefile
212 
213# depend on network
214uipc_proto.o: Makefile 
215
216# depend on maxusers
217assym.h: Makefile
218
219# depend on CPU configuration 
220cpufunc.o cpufunc_asm.o: Makefile
221
222# depend on DIAGNOSTIC etc.
223cpuswitch.o fault.o machdep.o: Makefile
224
225.if defined(SYSTEM_FIRST_OBJ)
226${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
227	${NORMAL_S}
228.endif
229
230locore.o: ${ARM}/arm32/locore.S assym.h
231	${NORMAL_S}
232
233# The install target can be redefined by putting a
234# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
235MACHINE_NAME!=  uname -n
236install: install-kernel-${MACHINE_NAME}
237.if !target(install-kernel-${MACHINE_NAME}})
238install-kernel-${MACHINE_NAME}:
239	rm -f /onetbsd
240	ln /netbsd /onetbsd
241	cp netbsd /nnetbsd
242	mv /nnetbsd /netbsd
243.endif
244
245%RULES
246