Makefile.sun3 revision 1.83
1# $NetBSD: Makefile.sun3,v 1.83 2000/12/07 17:51:06 jdolecek 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_EGCS!=	${CC} --version | egrep "^(2\.[89]|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# XXX Delete -Wuninitialized for now, since the compiler doesn't
66# XXX always get it right.  --thorpej 
67CWARNFLAGS+=	-Wno-uninitialized
68.if (${HAVE_EGCS} != "")
69CWARNFLAGS+=	-Wno-main
70.endif
71CFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
72# No, we may NOT assume that the compiler does -x whatever...
73APPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
74AFLAGS=
75LINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
76STRIPFLAGS=	-g
77
78%INCLUDES
79
80### find out what to use for libkern
81KERN_AS=	obj
82.include "$S/lib/libkern/Makefile.inc"
83.ifndef PROF
84LIBKERN=	${KERNLIB}
85.else
86LIBKERN=	${KERNLIB_PROF}
87.endif
88
89### find out what to use for libcompat
90.include "$S/compat/common/Makefile.inc"
91.ifndef PROF
92LIBCOMPAT=	${COMPATLIB}
93.else
94LIBCOMPAT=	${COMPATLIB_PROF}
95.endif
96
97# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
98# the file suffix, capitalized (e.g. C for a .c file).
99
100NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
101NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
102
103# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
104# This needs an intermediate file.  The original file is always
105# safe in some far away directory, so just use the base name.
106NORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
107		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
108
109# These comments help identify sections in the generated Makefile.
110# OBJS, CFILES, SFILES follow:
111
112%OBJS
113
114%CFILES
115
116%SFILES
117
118# OBJS, CFILES, SFILES done.
119
120# load lines for config "xxx" will be emitted as:
121# xxx: ${SYSTEM_DEP} swapxxx.o
122#	${SYSTEM_LD_HEAD}
123#	${SYSTEM_LD} swapxxx.o
124#	${SYSTEM_LD_TAIL}
125SYSTEM_OBJ=	locore.o \
126		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
127SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
128SYSTEM_LD_HEAD=	@rm -f $@
129SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
130		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
131SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
132
133DEBUG?=
134.if ${DEBUG} == "-g"
135LINKFLAGS+=	-X
136SYSTEM_LD_TAIL+=; \
137		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
138		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
139		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
140.else
141LINKFLAGS+=	-S
142.endif
143
144# LOAD+
145
146%LOAD
147
148# LOAD-
149
150assym.h: $S/kern/genassym.sh ${SUN3}/${MACHTYPE}/genassym.cf
151	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
152	    < ${SUN3}/${MACHTYPE}/genassym.cf > assym.h.tmp && \
153	mv -f assym.h.tmp assym.h
154
155param.c: $S/conf/param.c
156	rm -f param.c
157	cp $S/conf/param.c .
158
159param.o: param.c Makefile
160	${NORMAL_C}
161
162ioconf.o: ioconf.c
163	${NORMAL_C}
164
165newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
166	sh $S/conf/newvers.sh
167	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
168
169__CLEANKERNEL: .USE
170	@echo "${.TARGET}ing the kernel objects"
171	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
172	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
173
174__CLEANDEPEND: .USE
175	rm -f .depend
176
177clean: __CLEANKERNEL
178
179cleandir distclean: __CLEANKERNEL __CLEANDEPEND
180
181lint:
182	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
183	    ${CFILES} ioconf.c param.c | \
184	    grep -v 'static function .* unused'
185
186tags:
187	@echo "see $S/kern/Makefile for tags"
188
189links:
190	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
191	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
192	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
193	  sort -u | comm -23 - dontlink | \
194	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
195	sh makelinks && rm -f dontlink
196
197SRCS=	${SUN3}/${MACHTYPE}/locore.s \
198	param.c ioconf.c ${CFILES} ${SFILES}
199
200depend: .depend
201.depend: ${SRCS} assym.h param.c
202	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
203	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
204	  ${CPPFLAGS} < ${SUN3}/${MACHTYPE}/genassym.cf
205	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
206	@rm -f assym.dep
207
208dependall: depend all
209
210
211# XXX - see below
212#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
213#	${MKDEP} -a ${APPFLAGS} ${SFILES}
214#
215# For cross-compilation, the "gcc -M" mkdep script is convenient,
216# but that does not correctly make rules from *.s files.  The
217# easiest work-around is to just list those dependencies here.
218locore.o:   assym.h m68k/asm.h m68k/trap.h
219copy.o:     assym.h m68k/asm.h $S/sys/errno.h
220bcopy.o:    assym.h m68k/asm.h
221copypage.o: assym.h m68k/asm.h
222
223# depend on root or device configuration
224conf.o: Makefile
225 
226# depend on network or filesystem configuration 
227uipc_proto.o vfs_conf.o: Makefile 
228
229# depend on maxusers
230machdep.o: Makefile
231
232# depend on CPU configuration 
233db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
234
235# depends on KGDBDEV, KGDBRATE
236kgdb_stub.o: Makefile
237
238# depends on DDB, etc.
239stub.o: Makefile
240
241locore.o: ${SUN3}/${MACHTYPE}/locore.s
242	${NORMAL_S}
243
244# Generated rules follow:
245
246# The install target can be redefined by putting a
247# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
248MACHINE_NAME!=  uname -n
249install: install-kernel-${MACHINE_NAME}
250.if !target(install-kernel-${MACHINE_NAME}})
251install-kernel-${MACHINE_NAME}:
252	rm -f /onetbsd
253	ln /netbsd /onetbsd
254	cp netbsd /nnetbsd
255	mv /nnetbsd /netbsd
256.endif
257
258%RULES
259