Makefile.mips revision 1.17
1#	$NetBSD: Makefile.mips,v 1.17 2001/10/05 05:03:27 simonb 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/<machine>/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/mips/conf/Makefile.mips
13# after which config should be rerun for all machines of that type.
14
15.include <bsd.own.mk>
16
17# DEBUG is set to -g if debugging.
18# PROF is set to -pg if profiling.
19
20AR?=		${CROSSDIR}ar
21AS?=		${CROSSDIR}as
22CC?=		${CROSSDIR}cc
23CPP?=		cpp
24LD?=		${CROSSDIR}ld
25LORDER?=	lorder
26MKDEP?=		mkdep
27NM?=		${CROSSDIR}nm
28RANLIB?=	${CROSSDIR}ranlib
29SIZE?=		${CROSSDIR}size
30STRIP?=		${CROSSDIR}strip
31TSORT?=		${CROSSDIR}tsort -q
32OBJCOPY?=	${CROSSDIR}objcopy
33
34DEFCOPTS?=	-O2
35COPTS?=		${DEFCOPTS}
36
37DEFGP?=		-G 0
38TEXTADDR?=	${DEFTEXTADDR}
39
40# source tree is located via $S relative to the compilation directory
41.ifndef S
42S=	../../../..
43.endif
44THISMIPS=	$S/arch/${TARGET_MACHINE}
45MIPS=		$S/arch/mips
46
47HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
48INCLUDES=	-I. -I$S/arch -I$S -nostdinc
49CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT \
50		-D${TARGET_MACHINE}
51CWARNFLAGS?=	-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes \
52		-Wpointer-arith
53# XXX Delete -Wuninitialized for now, since the compiler doesn't
54# XXX always get it right.  --thorpej
55CWARNFLAGS+=	-Wno-uninitialized
56.if (${HAVE_EGCS} != "")
57CWARNFLAGS+=	-Wno-main
58.endif
59GP?=		${DEFGP}
60CFLAGS=		${ENDIAN} ${DEBUG} ${COPTS} ${CWARNFLAGS} ${GP} \
61		-mno-abicalls -mno-half-pic
62AFLAGS=		${ENDIAN} -x assembler-with-cpp -traditional-cpp -D_LOCORE
63LD+=		${ENDIAN}
64LINKFLAGS+=	-Ttext ${TEXTADDR} -e start ${GP} -T ${MIPS}/conf/kern.ldscript
65.if (${ENDIAN} == "-EB")
66LINKFLAGS+=	--oformat elf32-bigmips
67.else
68LINKFLAGS+=	--oformat elf32-littlemips
69.endif
70STRIPFLAGS=	-g -X -x
71
72.if exists(${THISMIPS}/conf/Makefile.${TARGET_MACHINE}.inc)
73.include "${THISMIPS}/conf/Makefile.${TARGET_MACHINE}.inc"
74.endif
75
76%INCLUDES
77
78### find out what to use for libkern
79.include "$S/lib/libkern/Makefile.inc"
80.ifndef PROF
81LIBKERN=	${KERNLIB}
82.else
83LIBKERN=	${KERNLIB_PROF}
84.endif
85
86### find out what to use for libcompat
87.include "$S/compat/common/Makefile.inc"
88.ifndef PROF
89LIBCOMPAT=	${COMPATLIB}
90.else
91LIBCOMPAT=	${COMPATLIB_PROF}
92.endif
93
94# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
95# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
96
97NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
98NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
99NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
100
101%OBJS
102
103%CFILES
104
105%SFILES
106
107# load lines for config "xxx" will be emitted as:
108# xxx: ${SYSTEM_DEP} swapxxx.o
109#	${SYSTEM_LD_HEAD}
110#	${SYSTEM_LD} swapxxx.o
111#	${SYSTEM_LD_TAIL}
112SYSTEM_OBJ=	locore.o locore_machdep.o
113.if !empty(IDENT:M-DMIPS1)
114SYSTEM_OBJ+=	locore_mips1.o
115.endif
116.if !empty(IDENT:M-DMIPS3)
117SYSTEM_OBJ+=	locore_mips3.o
118.endif
119.if empty(IDENT:M-DNOFPU)
120SYSTEM_OBJ+=	fp.o
121.endif
122SYSTEM_OBJ+=	param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
123SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
124SYSTEM_LD_HEAD?=@rm -f $@
125SYSTEM_LD?=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \
126		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
127SYSTEM_LD_TAIL?= \
128		@${SIZE} $@; chmod 755 $@
129
130DEBUG?=
131.if ${DEBUG} == "-g"
132LINKFLAGS+=	-X
133.ifdef DEBUG_SYSTEM_LD_TAIL
134SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL}
135.else
136SYSTEM_LD_TAIL+=; \
137		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
138		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
139		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
140.endif
141.else
142LINKFLAGS+=	-x
143.endif
144
145.ifdef POST_STRIP_SYSTEM_LD_TAIL
146SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL}
147.endif
148
149%LOAD
150
151assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf
152	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
153	  < ${MIPS}/mips/genassym.cf > assym.h.tmp && \
154	mv -f assym.h.tmp assym.h
155
156
157param.c: $S/conf/param.c
158	rm -f param.c
159	cp $S/conf/param.c .
160
161param.o: param.c Makefile
162	${NORMAL_C}
163
164ioconf.o: ioconf.c
165	${NORMAL_C}
166
167newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
168	sh $S/conf/newvers.sh
169	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
170
171__CLEANKERNEL: .USE
172	@echo "${.TARGET}ing the kernel objects"
173	rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \
174	  [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h
175
176__CLEANDEPEND: .USE
177	rm -f .depend
178
179clean: __CLEANKERNEL
180
181cleandir distclean: __CLEANKERNEL __CLEANDEPEND
182
183lint:
184	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
185	  ${MIPS}/mips/Locore.c ${CFILES} \
186	  ioconf.c param.c | \
187	  grep -v 'static function .* unused'
188
189tags:
190	@echo "see $S/kern/Makefile for tags"
191
192links:
193	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
194	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
195	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
196	  sort -u | comm -23 - dontlink | \
197	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
198	sh makelinks && rm -f dontlink
199
200.if !empty(IDENT:M-DMIPS1)
201SFILES+=${MIPS}/mips/locore_mips1.S
202.endif
203.if !empty(IDENT:M-DMIPS3)
204SFILES+=${MIPS}/mips/locore_mips3.S
205.endif
206.if empty(IDENT:M-DNOFPU)
207SFILES+=${MIPS}/mips/fp.S
208.endif
209SFILES+=${MIPS}/mips/locore.S \
210	${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S
211SRCS=	param.c ioconf.c ${CFILES} ${SFILES}
212
213depend: .depend
214.depend: ${SRCS} assym.h param.c
215	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
216	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
217	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
218	  ${CPPFLAGS} < ${MIPS}/mips/genassym.cf
219	@sed -e 's/.*\.o:.*\.c /assym.h: /' < assym.dep >> .depend
220	@rm -f assym.dep
221
222dependall: depend all
223
224
225# depend on root or device configuration
226autoconf.o conf.o: Makefile
227
228# depend on network or filesystem configuration
229uipc_proto.o vfs_conf.o: Makefile
230
231# depend on maxusers
232machdep.o: Makefile
233
234# depend on CPU configuration
235machdep.o mainbus.o trap.o: Makefile
236
237# depend on System V IPC/shmem options
238mips_machdep.o pmap.o: Makefile
239
240locore.o: ${MIPS}/mips/locore.S assym.h
241	${NORMAL_S}
242
243locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h
244	${NORMAL_S}
245
246locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h
247	${NORMAL_S}
248
249.if empty(IDENT:M-DNOFPU)
250fp.o: ${MIPS}/mips/fp.S assym.h
251	${NORMAL_S}
252.endif
253
254locore_machdep.o: ${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S assym.h
255	${NORMAL_S}
256
257# The install target can be redefined by putting a
258# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
259MACHINE_NAME!=  uname -n
260install: install-kernel-${MACHINE_NAME}
261.if !target(install-kernel-${MACHINE_NAME}})
262install-kernel-${MACHINE_NAME}:
263	rm -f /onetbsd
264	ln /netbsd /onetbsd
265	cp netbsd /nnetbsd
266	mv /nnetbsd /netbsd
267.endif
268
269%RULES
270