Makefile.acorn32 revision 1.8
1#	$NetBSD: Makefile.acorn32,v 1.8 2001/11/27 00:16:00 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/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
62GENASSYM_EXTRAS+= ${ACORN32}/acorn32/genassym.cf
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}
107.ifdef MONITOR
108SYSTEM_OBJ=	locore.o modedefs.o \
109		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
110.else
111SYSTEM_OBJ=	locore.o \
112		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
113.endif
114SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
115SYSTEM_LD_HEAD=	rm -f $@
116SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
117		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
118SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
119
120DEBUG?=
121.if ${DEBUG} == "-g"
122LINKFLAGS+=	-X
123SYSTEM_LD_TAIL+=; \
124		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
125		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
126		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
127.else
128#LINKFLAGS+=	-S
129LINKFLAGS+=	-x
130.endif
131
132%LOAD
133
134assym.h: $S/kern/genassym.sh ${ARM}/arm32/genassym.cf
135	cat ${ARM}/arm32/genassym.cf ${GENASSYM_EXTRAS} | \
136	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
137	    > assym.h.tmp && \
138	mv -f assym.h.tmp assym.h
139
140param.c: $S/conf/param.c
141	rm -f param.c
142	cp $S/conf/param.c .
143
144param.o: param.c Makefile
145	${NORMAL_C}
146
147ioconf.o: ioconf.c
148	${NORMAL_C}
149
150newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
151	sh $S/conf/newvers.sh
152	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
153
154__CLEANKERNEL: .USE
155	@echo "${.TARGET}ing the kernel objects"
156	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
157	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h modedefs.c
158
159__CLEANDEPEND: .USE
160	rm -f .depend
161
162clean: __CLEANKERNEL
163
164cleandir distclean: __CLEANKERNEL __CLEANDEPEND
165
166lint:
167	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
168	    ${ARM}/arm32/Locore.c ${CFILES}  \
169	    ioconf.c param.c | \
170	    grep -v 'static function .* unused'
171
172tags:
173	@echo "see $S/kern/Makefile for tags"
174
175links:
176	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
177	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
178	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
179	  sort -u | comm -23 - dontlink | \
180	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
181	sh makelinks && rm -f dontlink
182
183SRCS=	${ARM}/arm32/locore.S param.c ioconf.c ${CFILES} ${SFILES}
184.ifdef MONITOR
185SRCS+=	modedefs.c
186.endif
187depend: .depend
188.depend: ${SRCS} assym.h param.c
189	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${ARM}/arm32/locore.S
190	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
191	test -z "${SFILES}" || ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
192	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
193	    ${CPPFLAGS} < ${ARM}/arm32/genassym.cf
194	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
195	@rm -f assym.dep
196.ifdef MONITOR
197	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} modedefs.c
198.endif
199
200dependall: depend all
201
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
219locore.o: ${ARM}/arm32/locore.S assym.h
220	${NORMAL_S}
221
222modedefs.c: ${ARM}/iomd/makemodes.awk ${ACORN32}/conf/monitors/${MONITOR} Makefile
223	awk -f ${ARM}/iomd/makemodes.awk ${ACORN32}/conf/monitors/${MONITOR} ${MODES} >modedefs.c
224
225modedefs.o: modedefs.c
226	${NORMAL_C}
227
228# The install target can be redefined by putting a
229# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
230MACHINE_NAME!=  uname -n
231install: install-kernel-${MACHINE_NAME}
232.if !target(install-kernel-${MACHINE_NAME}})
233install-kernel-${MACHINE_NAME}:
234	rm -f /onetbsd
235	ln /netbsd /onetbsd
236	cp netbsd /nnetbsd
237	mv /nnetbsd /netbsd
238.endif
239
240%RULES
241