Makefile.mvme68k revision 1.49
1#	$NetBSD: Makefile.mvme68k,v 1.49 2000/11/20 19:35:28 scw 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/mvme68k/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/mvme68k/conf/Makefile.mvme68k
13# after which config should be rerun for all machines of that type.
14#
15# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
16#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
17#
18# -DTRACE	compile in kernel tracing hooks
19# -DQUOTA	compile in file system quotas
20
21# DEBUG is set to -g if debugging.
22# PROF is set to -pg if profiling.
23
24AR?=	ar
25AS?=	as
26CC?=	cc
27CPP?=	cpp
28LD?=	ld
29LORDER?=lorder
30MKDEP?=	mkdep
31NM?=	nm
32RANLIB?=ranlib
33SIZE?=	size
34STRIP?=	strip
35TSORT?=	tsort -q
36
37COPTS?=	-O2
38
39# source tree is located via $S relative to the compilation directory
40.ifndef S
41S!=	cd ../../../..; pwd
42.endif
43MVME68K=$S/arch/mvme68k
44
45# Override CPP defaults entirely, so cross-compilation works.
46# Keep -nostdinc before all -I flags, similar for -undef ...
47HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
48INCLUDES=	-nostdinc -I. -I$S/arch -I$S
49CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Dmvme68k
50.if empty(IDENT:M-DMVME172) && empty(IDENT:M-DMVME177)
51.if empty(IDENT:M-DMVME147)
52CMACHFLAGS=	-m68040
53.else
54CMACHFLAGS=	-m68030
55.endif
56.else
57.if empty(IDENT:M-DMVME147) && empty(IDENT:M-DMVME162) && empty(IDENT:M-DMVME167)
58CMACHFLAGS=	-m68060 -Wa,-m68030 -Wa,-m68851
59.else
60CMACHFLAGS=	-m68020-60 -Wa,-m68030 -Wa,-m68851
61.endif
62.endif
63CWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
64		-Wpointer-arith
65# XXX Delete -Wuninitialized for now, since the compiler doesn't
66# XXX always get it right.  --thorpej 
67CWARNFLAGS+=	-Wno-uninitialized
68.if (${HAVE_EGCS} != "")
69CWARNFLAGS+=	-Wno-main
70.endif
71CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} ${CMACHFLAGS} -msoft-float
72AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
73LINKFLAGS=	-n -Ttext 8000 -e start
74STRIPFLAGS=	-g
75
76%INCLUDES
77
78HOSTED_CC=	${CC}
79HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
80HOSTED_CFLAGS=	${CFLAGS}
81
82### find out what to use for libkern
83KERN_AS=	obj
84.include "$S/lib/libkern/Makefile.inc"
85.ifndef PROF
86LIBKERN=	${KERNLIB}
87.else
88LIBKERN=	${KERNLIB_PROF}
89.endif
90
91### find out what to use for libcompat
92.include "$S/compat/common/Makefile.inc"
93.ifndef PROF
94LIBCOMPAT=	${COMPATLIB}
95.else
96LIBCOMPAT=	${COMPATLIB_PROF}
97.endif
98
99### for the Motorola 68040 Floating Point Software Product
100.include "$S/arch/m68k/fpsp/Makefile.inc"
101
102### for the Motorola 68060 Software Support Package
103.include "$S/arch/m68k/060sp/Makefile.inc"
104
105# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
106# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
107
108NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
109NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
110NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
111
112HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
113
114%OBJS
115
116%CFILES
117
118%SFILES
119
120# load lines for config "xxx" will be emitted as:
121# xxx: ${SYSTEM_DEP} swapxxx.o
122#	${SYSTEM_LD_HEAD}
123#	${SYSTEM_LD} swapxxx.o
124#	${SYSTEM_LD_TAIL}
125SYSTEM_OBJ=	locore.o ${FPSP} \
126		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
127SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
128SYSTEM_LD_HEAD=	@rm -f $@
129SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
130		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
131SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
132
133DEBUG?=
134.if ${DEBUG} == "-g"
135LINKFLAGS+=	-X
136SYSTEM_LD_TAIL+=; \
137		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
138		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
139		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
140.else
141LINKFLAGS+=	-S
142.endif
143
144%LOAD
145
146assym.h: $S/kern/genassym.sh ${MVME68K}/mvme68k/genassym.cf
147	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
148	    < ${MVME68K}/mvme68k/genassym.cf > assym.h.tmp && \
149	mv -f assym.h.tmp assym.h
150
151param.c: $S/conf/param.c
152	rm -f param.c
153	cp $S/conf/param.c .
154
155param.o: param.c Makefile
156	${NORMAL_C}
157
158ioconf.o: ioconf.c
159	${NORMAL_C}
160
161newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
162	sh $S/conf/newvers.sh
163	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
164
165__CLEANKERNEL: .USE
166	@echo "${.TARGET}ing the kernel objects"
167	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
168	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
169
170__CLEANDEPEND: .USE
171	rm -f .depend
172
173clean: __CLEANKERNEL
174
175cleandir distclean: __CLEANKERNEL __CLEANDEPEND
176
177lint:
178	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
179	    ${CFILES} ioconf.c param.c | \
180	    grep -v 'static function .* unused'
181
182tags:
183	@echo "see $S/kern/Makefile for tags"
184
185links:
186	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
187	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
188	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
189	  sort -u | comm -23 - dontlink | \
190	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
191	sh makelinks && rm -f dontlink
192
193SRCS=	${MVME68K}/mvme68k/locore.s \
194	param.c ioconf.c ${CFILES} ${SFILES}
195depend: .depend
196.depend: ${SRCS} assym.h param.c
197	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${MVME68K}/mvme68k/locore.s
198	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
199	-if test -n "${SFILES}"; then \
200		${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}; \
201	fi
202	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
203	  ${CPPFLAGS} < ${MVME68K}/mvme68k/genassym.cf
204	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
205	@rm -f assym.dep
206
207dependall: depend all
208
209
210# depend on root or device configuration
211autoconf.o conf.o: Makefile
212 
213# depend on network or filesystem configuration 
214uipc_proto.o vfs_conf.o: Makefile 
215
216# depend on maxusers
217machdep.o: Makefile
218
219# depend on CPU configuration 
220locore.o pmap.o sys_machdep.o trap.o: Makefile
221
222
223locore.o: ${MVME68K}/mvme68k/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