Makefile.news68k revision 1.12
1#	$NetBSD: Makefile.news68k,v 1.12 2001/11/20 12:56:34 lukem 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/news68k/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/news68k/conf/Makefile.news68k
13# after which config should be rerun for all machines of that type.
14
15MACHINE_ARCH=m68k
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
40#S!=	cd ../../../..; pwd
41S=	../../../..
42.endif
43NEWS68K=$S/arch/news68k
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 -Dnews68k
48CWARNFLAGS?=	-Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
49		-Wall -Werror
50# XXX Delete -Wuninitialized for now, since the compiler doesn't
51# XXX always get it right.  --thorpej
52CWARNFLAGS+=	-Wno-uninitialized
53.if (${HAVE_EGCS} != "")
54CWARNFLAGS+=	-Wno-main
55.endif
56CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float
57AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
58LINKFLAGS=	-n -Ttext 0 -e start
59STRIPFLAGS=	-g
60
61%INCLUDES
62
63HOSTED_CC=	${CC}
64HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
65HOSTED_CFLAGS=	${CFLAGS}
66
67### find out what to use for libkern
68KERN_AS=	obj
69.include "$S/lib/libkern/Makefile.inc"
70.ifndef PROF
71LIBKERN=	${KERNLIB}
72.else
73LIBKERN=	${KERNLIB_PROF}
74.endif
75
76### find out what to use for libcompat
77.include "$S/compat/common/Makefile.inc"
78.ifndef PROF
79LIBCOMPAT=	${COMPATLIB}
80.else
81LIBCOMPAT=	${COMPATLIB_PROF}
82.endif
83
84# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
85# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
86
87NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
88NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
89NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
90
91HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
92
93%OBJS
94
95%CFILES
96
97%SFILES
98
99# load lines for config "xxx" will be emitted as:
100# xxx: ${SYSTEM_DEP} swapxxx.o
101#	${SYSTEM_LD_HEAD}
102#	${SYSTEM_LD} swapxxx.o
103#	${SYSTEM_LD_TAIL}
104SYSTEM_OBJ=	locore.o ${FPSP}
105SYSTEM_OBJ+=	param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
106SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
107SYSTEM_LD_HEAD=	@rm -f $@
108SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \
109		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
110SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
111
112DEBUG?=
113.if ${DEBUG} == "-g"
114LINKFLAGS+=	-X
115SYSTEM_LD_TAIL+=; \
116		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
117		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
118		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
119.else
120LINKFLAGS+=	-S
121.endif
122
123%LOAD
124
125assym.h: $S/kern/genassym.sh ${NEWS68K}/news68k/genassym.cf
126	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
127	    < ${NEWS68K}/news68k/genassym.cf > assym.h.tmp && \
128	mv -f assym.h.tmp assym.h
129
130
131param.c: $S/conf/param.c
132	rm -f param.c
133	cp $S/conf/param.c .
134
135param.o: param.c Makefile
136	${NORMAL_C}
137
138ioconf.o: ioconf.c
139	${NORMAL_C}
140
141newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
142	sh $S/conf/newvers.sh
143	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
144
145__CLEANKERNEL: .USE
146	@echo "${.TARGET}ing the kernel objects"
147	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
148	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
149
150__CLEANDEPEND: .USE
151	rm -f .depend
152
153clean: __CLEANKERNEL
154
155cleandir distclean: __CLEANKERNEL __CLEANDEPEND
156
157lint:
158	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
159	    ${CFILES} ioconf.c param.c | \
160	    grep -v 'static function .* unused'
161
162tags:
163	@echo "see $S/kern/Makefile for tags"
164
165links:
166	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
167	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
168	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
169	  sort -u | comm -23 - dontlink | \
170	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
171	sh makelinks && rm -f dontlink
172
173SRCS=	${NEWS68K}/news68k/locore.s \
174	param.c ioconf.c ${CFILES} ${SFILES}
175depend: .depend
176.depend: ${SRCS} assym.h param.c
177	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${NEWS68K}/news68k/locore.s
178	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
179.if ${SFILES} != ""
180	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
181.endif
182	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
183	  ${CPPFLAGS} < ${NEWS68K}/news68k/genassym.cf
184	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
185	@rm -f assym.dep
186
187dependall: depend all
188
189
190# depend on root or device configuration
191autoconf.o conf.o: Makefile
192
193# depend on network or filesystem configuration
194uipc_proto.o vfs_conf.o: Makefile
195
196# depend on maxusers
197machdep.o: Makefile
198
199# depend on CPU configuration
200machdep.o mainbus.o trap.o: Makefile
201
202
203locore.o: ${NEWS68K}/news68k/locore.s assym.h
204	${NORMAL_S}
205
206# The install target can be redefined by putting a
207# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
208MACHINE_NAME!=  uname -n
209install: install-kernel-${MACHINE_NAME}
210.if !target(install-kernel-${MACHINE_NAME}})
211install-kernel-${MACHINE_NAME}:
212	rm -f /onetbsd
213	ln /netbsd /onetbsd
214	cp netbsd /nnetbsd
215	mv /nnetbsd /netbsd
216.endif
217
218%RULES
219