Makefile.sun3 revision 1.46
1#	$NetBSD: Makefile.sun3,v 1.46 1996/06/20 03:47:27 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
24AS?=	as
25CC?=	cc
26CPP?=	cpp
27LD?=	ld
28MKDEP?=	mkdep
29STRIP?=	strip -d
30TOUCH?=	touch -f -c
31
32# source tree is located via $S relative to the compilation directory
33S=	../../../..
34SUN3=	../..
35
36# Override CPP defaults entirely, so cross-compilation works.
37INCLUDES=	-nostdinc -I. -I$S/arch -I$S
38XDEFS= 		-undef -D__NetBSD__ -Dm68k -Dmc68000
39DEFINES=	-D_KERNEL -Dmc68020 -Dsun3
40CPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT}
41# Make it easy to override this on the command line...
42WFLAGS= 	-Werror # -Wall -Wstrict-prototypes -Wmissing-prototypes
43CFLAGS= 	${DEBUG} -O2 -msoft-float ${WFLAGS}
44APPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
45LINKFLAGS=	-N -Ttext 0E004000 -e start
46
47# What to use for libkern: (see ../compile/libkern)
48# Note, this can be shared by all kernel configs.
49.ifndef PROF
50LIBKERN=	../libkern/libkern.o
51.else
52LIBKERN=	../libkern/libkern.po
53.endif
54
55# What to use for libcompat:
56# Would like to share this too, but it's config dependent.
57LIBCOMPAT=	libcompat.a
58
59# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
60# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix,
61# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
62# is marked as config-dependent.
63
64NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
65NORMAL_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
66
67DRIVER_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
68DRIVER_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
69
70NORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
71		${AS} -o $@ $*.s ; rm $*.s
72NORMAL_S_C=	${CPP} ${APPFLAGS} ${PARAM} $< > $*.s ;\
73		${AS} -o $@ $*.s ; rm $*.s
74
75# OBJS, CFILES, SFILES follow:
76
77%OBJS
78
79%CFILES
80
81%SFILES
82
83# OBJS, CFILES, SFILES done.
84
85# load lines for config "xxx" will be emitted as:
86# xxx: ${SYSTEM_DEP} swapxxx.o
87#	${SYSTEM_LD_HEAD}
88#	${SYSTEM_LD} swapxxx.o
89#	${SYSTEM_LD_TAIL}
90SYSTEM_OBJ=	locore.o \
91		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
92SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
93SYSTEM_LD_HEAD=	@rm -f $@
94SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
95		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
96SYSTEM_LD_TAIL=	@size $@; chmod 755 $@
97
98DEBUG?=
99.if ${DEBUG} == "-g"
100LINKFLAGS+=	-X
101SYSTEM_LD_TAIL+=; \
102		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
103		echo ${STRIP} $@; ${STRIP} $@
104.else
105LINKFLAGS+=	-S
106.endif
107
108# LOAD+
109
110%LOAD
111
112# LOAD-
113
114.include "../libcompat/Makefile.inc"
115
116${LIBKERN} : .NOTMAIN .FORCE
117	@echo "making sure libkern is up-to-date..."
118	@(cd ../libkern ; ${MAKE})
119
120.FORCE:
121
122assym.h: genassym
123	./genassym >assym.h
124
125genassym: genassym.o
126	${CC} -o $@ genassym.o
127
128genassym.o: ${SUN3}/sun3/genassym.c
129	${NORMAL_C_C}
130
131param.c: $S/conf/param.c
132	rm -f param.c
133	cp $S/conf/param.c .
134
135param.o: param.c Makefile
136	${NORMAL_C_C}
137
138ioconf.o: ioconf.c
139	${NORMAL_C}
140
141newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
142	sh $S/conf/newvers.sh
143	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
144
145
146clean::
147	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
148	    [Ee]rrs linterrs makelinks genassym genassym.o assym.h
149
150lint:
151	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} ${PARAM} -UKGDB \
152	    ${SUN3}/sun3/Locore.c ${CFILES} ${SUN3}/sun3/swapgeneric.c \
153	    ioconf.c param.c | \
154	    grep -v 'static function .* unused'
155
156tags:
157	@echo "see $S/kern/Makefile for tags"
158
159links:
160	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
161	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
162	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
163	  sort -u | comm -23 - dontlink | \
164	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
165	sh makelinks && rm -f dontlink
166
167SRCS=	${SUN3}/sun3/locore.s \
168	param.c ioconf.c ${CFILES} ${SFILES}
169
170depend:: .depend
171.depend: ${SRCS} assym.h param.c ${COMPAT_DEPENDS}
172	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
173	${MKDEP} -a ${CPPFLAGS} ${PARAM} ${SUN3}/sun3/genassym.c
174	${MKDEP} -a ${CPPFLAGS} ${COMPAT_DEPENDS}
175
176# XXX - see below
177#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
178#	${MKDEP} -a ${APPFLAGS} ${SFILES}
179#
180# For cross-compilation, the "gcc -M" mkdep script is convenient,
181# but that does not correctly make rules from *.s files.  The
182# easiest compromise is to just list those dependencies here.
183locore.o: assym.h machine/trap.h m68k/trap.h
184copy.o:   assym.h $S/sys/errno.h
185
186# depend on root or device configuration
187autoconf.o conf.o: Makefile
188 
189# depend on network or filesystem configuration 
190uipc_proto.o vfs_conf.o: Makefile 
191
192# depend on maxusers
193genassym.o machdep.o: Makefile
194
195# depend on CPU configuration 
196db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
197
198locore.o: ${SUN3}/sun3/locore.s
199	${NORMAL_S}
200
201# Rules follow
202
203%RULES
204