Makefile.sun3 revision 1.80
1# $NetBSD: Makefile.sun3,v 1.80 2000/02/01 05:25:48 tsutsui 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/sun3/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/sun3/conf/Makefile.sun3
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
21# DEBUG is set to -g if debugging.
22# PROF is set to -pg if profiling.
23
24# XXX - Make cross-build work...
25MACHINE_ARCH=m68k
26MACHINE=sun3
27
28AR?=	ar
29AS?=	as
30CC?=	cc
31CPP?=	cpp
32LD?=	ld
33LORDER?=lorder
34MKDEP?=	mkdep
35NM?=	nm
36RANLIB?=ranlib
37SIZE?=	size
38STRIP?=	strip
39TSORT?=	tsort -q
40
41COPTS?=	-O2 -fno-defer-pop
42
43# source tree is located via $S relative to the compilation directory
44.ifndef S
45S!=	cd ../../../..; pwd
46.endif
47SUN3=	$S/arch/sun3
48
49.if ${MACHTYPE} == "sun3x"
50TEXTADDR=F8004000
51.else
52TEXTADDR=0E004000
53.endif
54
55# Override CPP defaults entirely, so cross-compilation works.
56# Keep -nostdinc before all -I flags, similar for -undef ...
57HAVE_GCC28!=	${CC} --version | egrep "^(2\.8|egcs)" ; echo 
58INCLUDES=	-nostdinc -I. -I$S/arch -I$S
59XDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
60DEFINES=	-D_KERNEL -Dsun3
61CPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
62# Make it easy to override this on the command line...
63CWARNFLAGS?= 	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
64		-Wpointer-arith
65.if (${HAVE_GCC28} != "")
66CWARNFLAGS+=	-Wno-main
67.endif
68CFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
69# No, we may NOT assume that the compiler does -x whatever...
70APPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
71AFLAGS=
72LINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
73STRIPFLAGS=	-g
74
75%INCLUDES
76
77### find out what to use for libkern
78KERN_AS=	obj
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 NORMAL_${SUFFIX} where SUFFIX is
95# 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 $<
99
100# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
101# This needs an intermediate file.  The original file is always
102# safe in some far away directory, so just use the base name.
103NORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
104		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
105
106# These comments help identify sections in the generated Makefile.
107# OBJS, CFILES, SFILES follow:
108
109%OBJS
110
111%CFILES
112
113%SFILES
114
115# OBJS, CFILES, SFILES done.
116
117# load lines for config "xxx" will be emitted as:
118# xxx: ${SYSTEM_DEP} swapxxx.o
119#	${SYSTEM_LD_HEAD}
120#	${SYSTEM_LD} swapxxx.o
121#	${SYSTEM_LD_TAIL}
122SYSTEM_OBJ=	locore.o \
123		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
124SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
125SYSTEM_LD_HEAD=	@rm -f $@
126SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
127		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
128SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
129
130DEBUG?=
131.if ${DEBUG} == "-g"
132LINKFLAGS+=	-X
133SYSTEM_LD_TAIL+=; \
134		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
135		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
136		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
137.else
138LINKFLAGS+=	-S
139.endif
140
141# LOAD+
142
143%LOAD
144
145# LOAD-
146
147# Use awk to cross-build assym.h from the genassym.s file.
148assym.h: genassym.o $S/kern/genassym.awk
149	awk -f $S/kern/genassym.awk < genassym.s > assym.h.tmp
150	mv -f assym.h.tmp $@
151
152# The above rule lists genassym.o as a prerequisite so that the
153# generated .depend rule is effective, even though we actually
154# use genassym.s instead.   This always creates both.
155genassym.o: ${SUN3}/${MACHTYPE}/genassym.c
156	${CC} ${CPPFLAGS} -S $<
157	${CC} -c $*.s
158
159param.c: $S/conf/param.c
160	rm -f param.c
161	cp $S/conf/param.c .
162
163param.o: param.c Makefile
164	${NORMAL_C}
165
166ioconf.o: ioconf.c
167	${NORMAL_C}
168
169newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
170	sh $S/conf/newvers.sh
171	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
172
173__CLEANKERNEL: .USE
174	@echo "${.TARGET}ing the kernel objects"
175	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
176	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
177
178__CLEANDEPEND: .USE
179	rm -f .depend
180
181clean: __CLEANKERNEL
182
183cleandir distclean: __CLEANKERNEL __CLEANDEPEND
184
185lint:
186	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
187	    ${CFILES} ioconf.c param.c | \
188	    grep -v 'static function .* unused'
189
190tags:
191	@echo "see $S/kern/Makefile for tags"
192
193links:
194	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
195	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
196	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
197	  sort -u | comm -23 - dontlink | \
198	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
199	sh makelinks && rm -f dontlink
200
201SRCS=	${SUN3}/${MACHTYPE}/locore.s \
202	param.c ioconf.c ${CFILES} ${SFILES}
203
204depend: .depend
205.depend: ${SRCS} assym.h param.c
206	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
207	${MKDEP} -a ${CPPFLAGS} ${SUN3}/${MACHTYPE}/genassym.c
208
209dependall: depend all
210
211
212# XXX - see below
213#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
214#	${MKDEP} -a ${APPFLAGS} ${SFILES}
215#
216# For cross-compilation, the "gcc -M" mkdep script is convenient,
217# but that does not correctly make rules from *.s files.  The
218# easiest work-around is to just list those dependencies here.
219locore.o:   assym.h m68k/asm.h m68k/trap.h
220copy.o:     assym.h m68k/asm.h $S/sys/errno.h
221bcopy.o:    assym.h m68k/asm.h
222copypage.o: assym.h m68k/asm.h
223
224# depend on root or device configuration
225conf.o: Makefile
226 
227# depend on network or filesystem configuration 
228uipc_proto.o vfs_conf.o: Makefile 
229
230# depend on maxusers
231machdep.o: Makefile
232
233# depend on CPU configuration 
234db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
235
236# depends on KGDBDEV, KGDBRATE
237kgdb_stub.o: Makefile
238
239# depends on DDB, etc.
240stub.o: Makefile
241
242locore.o: ${SUN3}/${MACHTYPE}/locore.s
243	${NORMAL_S}
244
245# Generated rules follow:
246
247%RULES
248