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