Makefile.sun2 revision 1.10
1# $NetBSD: Makefile.sun2,v 1.10 2001/11/30 15:54:33 fredette 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/sun2/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/sun2/conf/Makefile.sun2
13# after which config should be rerun for all machines of that type.
14#
15# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
16#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
17#
18# -DTRACE	compile in kernel tracing hooks
19# -DQUOTA	compile in file system quotas
20
21MACHINE_ARCH=m68000
22USETOOLS?=	no
23
24.include <bsd.own.mk>
25
26# DEBUG is set to -g if debugging.
27# PROF is set to -pg if profiling.
28
29AR?=	ar
30AS?=	as
31CC?=	cc
32CPP?=	cpp
33LD?=	ld
34LORDER?=lorder
35MKDEP?=	mkdep
36NM?=	nm
37RANLIB?=ranlib
38SIZE?=	size
39STRIP?=	strip
40TSORT?=	tsort -q
41
42COPTS?=	-O2 -fno-defer-pop
43
44# source tree is located via $S relative to the compilation directory
45.ifndef S
46S!=	cd ../../../..; pwd
47.endif
48SUN2=	$S/arch/sun2
49
50TEXTADDR=00006000
51
52# Override CPP defaults entirely, so cross-compilation works.
53# Keep -nostdinc before all -I flags, similar for -undef ...
54HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
55INCLUDES=	-nostdinc -I. -I$S/arch -I$S
56XDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000 -D__ELF__ -D__SVR4_ABI__
57DEFINES=	-D_KERNEL -D_KERNEL_OPT -Dsun2
58CPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
59# Make it easy to override this on the command line...
60CWARNFLAGS?= 	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
61		-Wpointer-arith
62# XXX Delete -Wuninitialized for now, since the compiler doesn't
63# XXX always get it right.  --thorpej
64CWARNFLAGS+=	-Wno-uninitialized
65.if (${HAVE_EGCS} != "")
66CWARNFLAGS+=	-Wno-main
67.endif
68CFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
69APPFLAGS=	-x assembler-with-cpp -P -traditional ${CPPFLAGS} -D_LOCORE
70AFLAGS=
71LINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
72STRIPFLAGS=	-g
73
74%INCLUDES
75
76### find out what to use for libkern
77KERN_AS=	obj
78# XXX lib/libkern/arch/m68k/Makefile.inc needs to know that
79# XXX our MACHINE_ARCH is m68000, and not m68k.  --fredette
80KERNMISCMAKEFLAGS=	MACHINE_ARCH=${MACHINE_ARCH}
81.include "$S/lib/libkern/Makefile.inc"
82.ifndef PROF
83LIBKERN=	${KERNLIB}
84.else
85LIBKERN=	${KERNLIB_PROF}
86.endif
87
88### find out what to use for libcompat
89.include "$S/compat/common/Makefile.inc"
90.ifndef PROF
91LIBCOMPAT=	${COMPATLIB}
92.else
93LIBCOMPAT=	${COMPATLIB_PROF}
94.endif
95
96# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
97# the file suffix, capitalized (e.g. C for a .c file).
98
99NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
100NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
101
102# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
103# This needs an intermediate file.  The original file is always
104# safe in some far away directory, so just use the base name.
105NORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
106		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
107
108# These comments help identify sections in the generated Makefile.
109# OBJS, CFILES, SFILES follow:
110
111%OBJS
112
113%CFILES
114
115%SFILES
116
117# OBJS, CFILES, SFILES done.
118
119# load lines for config "xxx" will be emitted as:
120# xxx: ${SYSTEM_DEP} swapxxx.o
121#	${SYSTEM_LD_HEAD}
122#	${SYSTEM_LD} swapxxx.o
123#	${SYSTEM_LD_TAIL}
124SYSTEM_OBJ=	locore.o \
125		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
126SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
127SYSTEM_LD_HEAD=	@rm -f $@
128SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
129		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
130SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
131
132DEBUG?=
133.if ${DEBUG} == "-g"
134LINKFLAGS+=	-X
135SYSTEM_LD_TAIL+=; \
136		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
137		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
138		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
139.else
140LINKFLAGS+=	-S
141.endif
142
143# LOAD+
144
145%LOAD
146
147# LOAD-
148
149assym.h: $S/kern/genassym.sh ${SUN2}/sun2/genassym.cf
150	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
151	    < ${SUN2}/sun2/genassym.cf > assym.h.tmp && \
152	mv -f assym.h.tmp assym.h
153
154param.c: $S/conf/param.c
155	rm -f param.c
156	cp $S/conf/param.c .
157
158param.o: param.c Makefile
159	${NORMAL_C}
160
161ioconf.o: ioconf.c
162	${NORMAL_C}
163
164newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
165	sh $S/conf/newvers.sh
166	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
167
168__CLEANKERNEL: .USE
169	@echo "${.TARGET}ing the kernel objects"
170	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
171	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
172
173__CLEANDEPEND: .USE
174	rm -f .depend
175
176clean: __CLEANKERNEL
177
178cleandir distclean: __CLEANKERNEL __CLEANDEPEND
179
180lint:
181	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
182	    ${CFILES} ioconf.c param.c | \
183	    grep -v 'static function .* unused'
184
185tags:
186	@echo "see $S/kern/Makefile for tags"
187
188links:
189	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
190	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
191	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
192	  sort -u | comm -23 - dontlink | \
193	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
194	sh makelinks && rm -f dontlink
195
196SRCS=	${SUN2}/sun2/locore.s \
197	param.c ioconf.c ${CFILES} ${SFILES}
198
199depend: .depend
200.depend: ${SRCS} assym.h param.c
201	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
202	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
203	  ${CPPFLAGS} < ${SUN2}/sun2/genassym.cf
204	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
205	@rm -f assym.dep
206
207dependall: depend all
208
209
210# XXX - see below
211#	${MKDEP} -a ${APPFLAGS} ${SUN2}/sun2/locore.s
212#	${MKDEP} -a ${APPFLAGS} ${SFILES}
213#
214# For cross-compilation, the "gcc -M" mkdep script is convenient,
215# but that does not correctly make rules from *.s files.  The
216# easiest work-around is to just list those dependencies here.
217locore.o:   assym.h m68k/asm.h m68k/trap.h
218copy.o:     assym.h m68k/asm.h $S/sys/errno.h
219bcopy.o:    assym.h m68k/asm.h
220copypage.o: assym.h m68k/asm.h
221
222# depend on root or device configuration
223conf.o: Makefile
224
225# depend on network or filesystem configuration
226uipc_proto.o vfs_conf.o: Makefile
227
228# depend on maxusers
229machdep.o: Makefile
230
231# depend on CPU configuration
232db_machdep.o dvma.o machdep.o pmap.o sun2_startup.o vm_machdep.o: Makefile
233
234# depends on DDB, etc.
235stub.o: Makefile
236
237locore.o: ${SUN2}/sun2/locore.s
238	${NORMAL_S}
239
240# Generated rules follow:
241
242# The install target can be redefined by putting a
243# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
244MACHINE_NAME!=  uname -n
245install: install-kernel-${MACHINE_NAME}
246.if !target(install-kernel-${MACHINE_NAME}})
247install-kernel-${MACHINE_NAME}:
248	rm -f /onetbsd
249	ln /netbsd /onetbsd
250	cp netbsd /nnetbsd
251	mv /nnetbsd /netbsd
252.endif
253
254%RULES
255