Makefile.sun3 revision 1.66
1#	$NetBSD: Makefile.sun3,v 1.66 1997/11/12 23:12:32 thorpej 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# Override CPP defaults entirely, so cross-compilation works.
50# Keep -nostdinc before all -I flags, similar for -undef ...
51INCLUDES=	-nostdinc -I. -I$S/arch -I$S
52XDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
53DEFINES=	-D_KERNEL -Dmc68020 -Dsun3
54CPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
55# Make it easy to override this on the command line...
56CWARNFLAGS= 	-Wall -Wstrict-prototypes # -Wmissing-prototypes -Werror
57CFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
58# No, we may NOT assume that the compiler does -x whatever...
59APPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
60AFLAGS= 	-m68020
61LINKFLAGS=	-N -Ttext 0E004000 -e start
62STRIPFLAGS=	-d
63
64### find out what to use for libkern
65.include "$S/lib/libkern/Makefile.inc"
66.ifndef PROF
67LIBKERN=	${KERNLIB}
68.else
69LIBKERN=	${KERNLIB_PROF}
70.endif
71
72### find out what to use for libcompat
73.include "$S/compat/common/Makefile.inc"
74.ifndef PROF
75LIBCOMPAT=	${COMPATLIB}
76.else
77LIBCOMPAT=	${COMPATLIB_PROF}
78.endif
79
80# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
81# the file suffix, capitalized (e.g. C for a .c file).
82
83NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
84
85# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
86# This needs an intermediate file.  The original file is always
87# safe in some far away directory, so just use the base name.
88NORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
89		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
90
91# These comments help identify sections in the generated Makefile.
92# OBJS, CFILES, SFILES follow:
93
94%OBJS
95
96%CFILES
97
98%SFILES
99
100# OBJS, CFILES, SFILES done.
101
102# load lines for config "xxx" will be emitted as:
103# xxx: ${SYSTEM_DEP} swapxxx.o
104#	${SYSTEM_LD_HEAD}
105#	${SYSTEM_LD} swapxxx.o
106#	${SYSTEM_LD_TAIL}
107SYSTEM_OBJ=	locore.o \
108		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
109SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
110SYSTEM_LD_HEAD=	@rm -f $@
111SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
112		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
113SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
114
115DEBUG?=
116.if ${DEBUG} == "-g"
117LINKFLAGS+=	-X
118SYSTEM_LD_TAIL+=; \
119		mv -f $@ $@.gdb; cp -p $@.gdb $@; \
120		${STRIP} ${STRIPFLAGS} $@
121.else
122LINKFLAGS+=	-S
123.endif
124
125# LOAD+
126
127%LOAD
128
129# LOAD-
130
131# Use awk to cross-build assym.h from the genassym.s file.
132assym.h: genassym.o $S/kern/genassym.awk
133	awk -f $S/kern/genassym.awk < genassym.s > assym.h.tmp
134	mv -f assym.h.tmp $@
135
136# The above rule lists genassym.o as a prerequisite so that the
137# generated .depend rule is effective, even though we actually
138# use genassym.s instead.   This always creates both.
139genassym.o: ${SUN3}/sun3/genassym.c
140	${CC} ${CPPFLAGS} -S $<
141	${CC} -c $*.s
142
143param.c: $S/conf/param.c
144	rm -f param.c
145	cp $S/conf/param.c .
146
147param.o: param.c Makefile
148	${NORMAL_C}
149
150ioconf.o: ioconf.c
151	${NORMAL_C}
152
153newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
154	sh $S/conf/newvers.sh
155	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
156
157__CLEANKERNEL: .USE
158	@echo "${.TARGET}ing the kernel objects"
159	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
160	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
161
162__CLEANDEPEND: .USE
163	rm -f .depend
164
165clean: __CLEANKERNEL
166
167cleandir: __CLEANKERNEL __CLEANDEPEND
168
169lint:
170	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
171	    ${CFILES} ioconf.c param.c | \
172	    grep -v 'static function .* unused'
173
174tags:
175	@echo "see $S/kern/Makefile for tags"
176
177links:
178	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
179	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
180	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
181	  sort -u | comm -23 - dontlink | \
182	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
183	sh makelinks && rm -f dontlink
184
185SRCS=	${SUN3}/sun3/locore.s \
186	param.c ioconf.c ${CFILES} ${SFILES}
187
188depend: .depend
189.depend: ${SRCS} assym.h param.c
190	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
191	${MKDEP} -a ${CPPFLAGS} ${SUN3}/sun3/genassym.c
192
193# XXX - see below
194#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
195#	${MKDEP} -a ${APPFLAGS} ${SFILES}
196#
197# For cross-compilation, the "gcc -M" mkdep script is convenient,
198# but that does not correctly make rules from *.s files.  The
199# easiest work-around is to just list those dependencies here.
200locore.o:   assym.h m68k/asm.h m68k/trap.h
201copy.o:     assym.h m68k/asm.h $S/sys/errno.h
202bcopy.o:    assym.h m68k/asm.h
203copypage.o: assym.h m68k/asm.h
204
205# depend on root or device configuration
206conf.o: Makefile
207 
208# depend on network or filesystem configuration 
209uipc_proto.o vfs_conf.o: Makefile 
210
211# depend on maxusers
212machdep.o: Makefile
213
214# depend on CPU configuration 
215db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
216
217# depends on KGDBDEV, KGDBRATE
218kgdb_stub.o: Makefile
219
220# depends on DDB, etc.
221stub.o: Makefile
222
223locore.o: ${SUN3}/sun3/locore.s
224	${NORMAL_S}
225
226# Generated rules follow:
227
228%RULES
229