Makefile.sun3 revision 1.75
1# $NetBSD: Makefile.sun3,v 1.75 1999/07/09 09:53:00 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/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=	-d
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		mv -f $@ $@.gdb; cp -p $@.gdb $@; \
135		${STRIP} ${STRIPFLAGS} $@
136.else
137LINKFLAGS+=	-S
138.endif
139
140# LOAD+
141
142%LOAD
143
144# LOAD-
145
146# Use awk to cross-build assym.h from the genassym.s file.
147assym.h: genassym.o $S/kern/genassym.awk
148	awk -f $S/kern/genassym.awk < genassym.s > assym.h.tmp
149	mv -f assym.h.tmp $@
150
151# The above rule lists genassym.o as a prerequisite so that the
152# generated .depend rule is effective, even though we actually
153# use genassym.s instead.   This always creates both.
154genassym.o: ${SUN3}/${MACHTYPE}/genassym.c
155	${CC} ${CPPFLAGS} -S $<
156	${CC} -c $*.s
157
158param.c: $S/conf/param.c
159	rm -f param.c
160	cp $S/conf/param.c .
161
162param.o: param.c Makefile
163	${NORMAL_C}
164
165ioconf.o: ioconf.c
166	${NORMAL_C}
167
168newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
169	sh $S/conf/newvers.sh
170	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
171
172__CLEANKERNEL: .USE
173	@echo "${.TARGET}ing the kernel objects"
174	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
175	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
176
177__CLEANDEPEND: .USE
178	rm -f .depend
179
180clean: __CLEANKERNEL
181
182cleandir distclean: __CLEANKERNEL __CLEANDEPEND
183
184lint:
185	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
186	    ${CFILES} ioconf.c param.c | \
187	    grep -v 'static function .* unused'
188
189tags:
190	@echo "see $S/kern/Makefile for tags"
191
192links:
193	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
194	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
195	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
196	  sort -u | comm -23 - dontlink | \
197	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
198	sh makelinks && rm -f dontlink
199
200SRCS=	${SUN3}/${MACHTYPE}/locore.s \
201	param.c ioconf.c ${CFILES} ${SFILES}
202
203depend: .depend
204.depend: ${SRCS} assym.h param.c
205	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
206	${MKDEP} -a ${CPPFLAGS} ${SUN3}/${MACHTYPE}/genassym.c
207
208# XXX - see below
209#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
210#	${MKDEP} -a ${APPFLAGS} ${SFILES}
211#
212# For cross-compilation, the "gcc -M" mkdep script is convenient,
213# but that does not correctly make rules from *.s files.  The
214# easiest work-around is to just list those dependencies here.
215locore.o:   assym.h m68k/asm.h m68k/trap.h
216copy.o:     assym.h m68k/asm.h $S/sys/errno.h
217bcopy.o:    assym.h m68k/asm.h
218copypage.o: assym.h m68k/asm.h
219
220# depend on root or device configuration
221conf.o: Makefile
222 
223# depend on network or filesystem configuration 
224uipc_proto.o vfs_conf.o: Makefile 
225
226# depend on maxusers
227machdep.o: Makefile
228
229# depend on CPU configuration 
230db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
231
232# depends on KGDBDEV, KGDBRATE
233kgdb_stub.o: Makefile
234
235# depends on DDB, etc.
236stub.o: Makefile
237
238locore.o: ${SUN3}/${MACHTYPE}/locore.s
239	${NORMAL_S}
240
241# Generated rules follow:
242
243%RULES
244