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