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