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