Makefile.sun3 revision 1.61
1#	$NetBSD: Makefile.sun3,v 1.61 1997/09/30 23:04:28 christos 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__CLEANKERNEL: .USE
150	@echo "${.TARGET}ing the kernel objects"
151	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
152	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
153
154__CLEANDEPEND: .USE
155	rm -f .depend
156
157clean: __CLEANKERNEL
158
159cleandir: __CLEANKERNEL __CLEANDEPEND
160
161lint:
162	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
163	    ${CFILES} ioconf.c param.c | \
164	    grep -v 'static function .* unused'
165
166tags:
167	@echo "see $S/kern/Makefile for tags"
168
169links:
170	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
171	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
172	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
173	  sort -u | comm -23 - dontlink | \
174	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
175	sh makelinks && rm -f dontlink
176
177SRCS=	${SUN3}/sun3/locore.s \
178	param.c ioconf.c ${CFILES} ${SFILES}
179
180depend: .depend
181.depend: ${SRCS} assym.h param.c
182	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
183	${MKDEP} -a ${CPPFLAGS} ${SUN3}/sun3/genassym.c
184
185# XXX - see below
186#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
187#	${MKDEP} -a ${APPFLAGS} ${SFILES}
188#
189# For cross-compilation, the "gcc -M" mkdep script is convenient,
190# but that does not correctly make rules from *.s files.  The
191# easiest work-around is to just list those dependencies here.
192locore.o:   assym.h m68k/asm.h m68k/trap.h
193copy.o:     assym.h m68k/asm.h $S/sys/errno.h
194bcopy.o:    assym.h m68k/asm.h
195copypage.o: assym.h m68k/asm.h
196
197# depend on root or device configuration
198conf.o: Makefile
199 
200# depend on network or filesystem configuration 
201uipc_proto.o vfs_conf.o: Makefile 
202
203# depend on maxusers
204machdep.o: Makefile
205
206# depend on CPU configuration 
207db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
208
209# depends on KGDBDEV, KGDBRATE
210kgdb_stub.o: Makefile
211
212locore.o: ${SUN3}/sun3/locore.s
213	${NORMAL_S}
214
215# Generated rules follow:
216
217%RULES
218