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