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