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