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