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