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