Makefile.sun3 revision 1.72
1# $NetBSD: Makefile.sun3,v 1.72 1998/12/13 19:19:38 kleink 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 -Dmc68020 -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.if (${HAVE_GCC28} != "")
65CWARNFLAGS+=	-Wno-main
66.endif
67CFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
68# No, we may NOT assume that the compiler does -x whatever...
69APPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
70AFLAGS=
71LINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
72STRIPFLAGS=	-d
73
74### find out what to use for libkern
75KERN_AS=	obj
76.include "$S/lib/libkern/Makefile.inc"
77.ifndef PROF
78LIBKERN=	${KERNLIB}
79.else
80LIBKERN=	${KERNLIB_PROF}
81.endif
82
83### find out what to use for libcompat
84.include "$S/compat/common/Makefile.inc"
85.ifndef PROF
86LIBCOMPAT=	${COMPATLIB}
87.else
88LIBCOMPAT=	${COMPATLIB_PROF}
89.endif
90
91# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
92# the file suffix, capitalized (e.g. C for a .c file).
93
94NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
95NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
96
97# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
98# This needs an intermediate file.  The original file is always
99# safe in some far away directory, so just use the base name.
100NORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
101		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
102
103# These comments help identify sections in the generated Makefile.
104# OBJS, CFILES, SFILES follow:
105
106%OBJS
107
108%CFILES
109
110%SFILES
111
112# OBJS, CFILES, SFILES done.
113
114# load lines for config "xxx" will be emitted as:
115# xxx: ${SYSTEM_DEP} swapxxx.o
116#	${SYSTEM_LD_HEAD}
117#	${SYSTEM_LD} swapxxx.o
118#	${SYSTEM_LD_TAIL}
119SYSTEM_OBJ=	locore.o \
120		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
121SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
122SYSTEM_LD_HEAD=	@rm -f $@
123SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
124		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
125SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
126
127DEBUG?=
128.if ${DEBUG} == "-g"
129LINKFLAGS+=	-X
130SYSTEM_LD_TAIL+=; \
131		mv -f $@ $@.gdb; cp -p $@.gdb $@; \
132		${STRIP} ${STRIPFLAGS} $@
133.else
134LINKFLAGS+=	-S
135.endif
136
137# LOAD+
138
139%LOAD
140
141# LOAD-
142
143# Use awk to cross-build assym.h from the genassym.s file.
144assym.h: genassym.o $S/kern/genassym.awk
145	awk -f $S/kern/genassym.awk < genassym.s > assym.h.tmp
146	mv -f assym.h.tmp $@
147
148# The above rule lists genassym.o as a prerequisite so that the
149# generated .depend rule is effective, even though we actually
150# use genassym.s instead.   This always creates both.
151genassym.o: ${SUN3}/${MACHTYPE}/genassym.c
152	${CC} ${CPPFLAGS} -S $<
153	${CC} -c $*.s
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	${MKDEP} -a ${CPPFLAGS} ${SUN3}/${MACHTYPE}/genassym.c
204
205# XXX - see below
206#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
207#	${MKDEP} -a ${APPFLAGS} ${SFILES}
208#
209# For cross-compilation, the "gcc -M" mkdep script is convenient,
210# but that does not correctly make rules from *.s files.  The
211# easiest work-around is to just list those dependencies here.
212locore.o:   assym.h m68k/asm.h m68k/trap.h
213copy.o:     assym.h m68k/asm.h $S/sys/errno.h
214bcopy.o:    assym.h m68k/asm.h
215copypage.o: assym.h m68k/asm.h
216
217# depend on root or device configuration
218conf.o: Makefile
219 
220# depend on network or filesystem configuration 
221uipc_proto.o vfs_conf.o: Makefile 
222
223# depend on maxusers
224machdep.o: Makefile
225
226# depend on CPU configuration 
227db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
228
229# depends on KGDBDEV, KGDBRATE
230kgdb_stub.o: Makefile
231
232# depends on DDB, etc.
233stub.o: Makefile
234
235locore.o: ${SUN3}/${MACHTYPE}/locore.s
236	${NORMAL_S}
237
238# Generated rules follow:
239
240%RULES
241