Makefile.sun3 revision 1.48
1#	$NetBSD: Makefile.sun3,v 1.48 1996/08/10 06:10:07 mycroft 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
24CC?=	cc
25LD?=	ld
26MKDEP?=	mkdep
27STRIP?=	strip -d
28TOUCH?=	touch -f -c
29
30# source tree is located via $S relative to the compilation directory
31S!=	cd ../../../..; pwd
32SUN3=	$S/arch/sun3
33
34# Override CPP defaults entirely, so cross-compilation works.
35INCLUDES=	-I. -I$S/arch -I$S -nostdinc
36XDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
37CPPFLAGS=	${INCLUDES} ${IDENT} -D_KERNEL -Dmc68020 -Dsun3 ${XDEFS}
38CWARNFLAGS= 	-Werror # -Wall -Wstrict-prototypes -Wmissing-prototypes
39CFLAGS= 	${DEBUG} ${CWARNFLAGS} -O2 -msoft-float
40AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
41LINKFLAGS=	-N -Ttext 0E004000 -e start
42
43### find out what to use for libkern
44.include "$S/lib/libkern/Makefile.inc"
45.ifndef PROF
46LIBKERN=	${KERNLIB}
47.else
48LIBKERN=	${KERNLIB_PROF}
49.endif
50
51### find out what to use for libcompat
52.include "$S/compat/common/Makefile.inc"
53.ifndef PROF
54LIBCOMPAT=	${COMPATLIB}
55.else
56LIBCOMPAT=	${COMPATLIB_PROF}
57.endif
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=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
71NORMAL_S_C=	${CC} ${AFLAGS} ${CPPFLAGS} ${PARAM} -c $<
72
73HOSTED_C_C=	${NORMAL_C_C:S/^-pg$//:S/^-p$//:S/^-nostdinc$//}
74
75%OBJS
76
77%CFILES
78
79%SFILES
80
81# load lines for config "xxx" will be emitted as:
82# xxx: ${SYSTEM_DEP} swapxxx.o
83#	${SYSTEM_LD_HEAD}
84#	${SYSTEM_LD} swapxxx.o
85#	${SYSTEM_LD_TAIL}
86SYSTEM_OBJ=	locore.o \
87		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
88SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
89SYSTEM_LD_HEAD=	@rm -f $@
90SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
91		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
92SYSTEM_LD_TAIL=	@size $@; chmod 755 $@
93
94DEBUG?=
95.if ${DEBUG} == "-g"
96LINKFLAGS+=	-X
97SYSTEM_LD_TAIL+=; \
98		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
99		echo ${STRIP} $@; ${STRIP} $@
100.else
101LINKFLAGS+=	-S
102.endif
103
104%LOAD
105
106assym.h: genassym
107	./genassym >assym.h
108
109genassym: genassym.o
110	${CC} -o $@ genassym.o
111
112genassym.o: ${SUN3}/sun3/genassym.c
113	${HOSTED_C_C}
114
115param.c: $S/conf/param.c
116	rm -f param.c
117	cp $S/conf/param.c .
118
119param.o: param.c Makefile
120	${NORMAL_C_C}
121
122ioconf.o: ioconf.c
123	${NORMAL_C}
124
125newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
126	sh $S/conf/newvers.sh
127	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
128
129
130clean::
131	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
132	    [Ee]rrs linterrs makelinks genassym genassym.o assym.h
133
134lint:
135	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} ${PARAM} -UKGDB \
136	    ${SUN3}/sun3/Locore.c ${CFILES} ${SUN3}/sun3/swapgeneric.c \
137	    ioconf.c param.c | \
138	    grep -v 'static function .* unused'
139
140tags:
141	@echo "see $S/kern/Makefile for tags"
142
143links:
144	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
145	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
146	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
147	  sort -u | comm -23 - dontlink | \
148	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
149	sh makelinks && rm -f dontlink
150
151SRCS=	${SUN3}/sun3/locore.s \
152	param.c ioconf.c ${CFILES} ${SFILES}
153depend:: .depend
154.depend: ${SRCS} assym.h param.c
155	${MKDEP} ${AFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
156	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} ${PARAM} ${SUN3}/sun3/genassym.c
157
158# XXX - see below
159#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
160#	${MKDEP} -a ${APPFLAGS} ${SFILES}
161#
162# For cross-compilation, the "gcc -M" mkdep script is convenient,
163# but that does not correctly make rules from *.s files.  The
164# easiest compromise is to just list those dependencies here.
165locore.o: assym.h machine/trap.h m68k/trap.h
166copy.o:   assym.h $S/sys/errno.h
167
168
169# depend on root or device configuration
170autoconf.o conf.o: Makefile
171 
172# depend on network or filesystem configuration 
173uipc_proto.o vfs_conf.o: Makefile 
174
175# depend on maxusers
176genassym.o machdep.o: Makefile
177
178# depend on CPU configuration 
179db_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
180
181
182locore.o: ${SUN3}/sun3/locore.s assym.h
183	${NORMAL_S}
184
185%RULES
186