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