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