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