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