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