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