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