Makefile.vax revision 1.61
1#	$NetBSD: Makefile.vax,v 1.61 2001/10/23 19:26:47 thorpej 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/vax/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/vax/conf/Makefile.vax
13# after which config should be rerun for all machines of that type.
14
15MACHINE_ARCH=vax
16
17# DEBUG is set to -g if debugging.
18# PROF is set to -pg if profiling.
19
20AR?=	ar
21AS?=	as
22CC?=	cc
23CPP?=	cpp
24LD?=	ld
25LORDER?=lorder
26MKDEP?=	mkdep
27NM?=	nm
28RANLIB?=ranlib
29SIZE?=	size
30STRIP?=	strip
31TSORT?=	tsort -q
32
33COPTS?= -O2
34
35# source tree is located via $S relative to the compilation directory
36.ifndef S
37S!=	cd ../../../..; pwd
38.endif
39VAX=	$S/arch/vax
40
41HAVE_EGCS!=	${CC} --version | egrep "^(2\.8|2\.9[0-4]|egcs)" ; echo 
42INCLUDES=	-I. -I$S/arch -I$S -nostdinc
43CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT \
44		-D_VAX_INLINE_
45CWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
46		-Wpointer-arith -Wno-main
47# XXX Delete -Wuninitialized for now, since the compiler doesn't
48# XXX always get it right.  --thorpej 
49CWARNFLAGS+=	-Wno-uninitialized
50CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
51.if (${HAVE_EGCS} != "")
52CFLAGS+=	-mno-pic
53.endif
54AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
55LINKFLAGS=	-N -Ttext 80000000 -e start
56STRIPFLAGS=	-g
57
58%INCLUDES
59
60HOSTED_CC=	${CC}
61HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
62HOSTED_CFLAGS=	${CFLAGS}
63
64### find out what to use for libkern
65KERN_AS=	obj
66.include "$S/lib/libkern/Makefile.inc"
67.ifndef PROF
68LIBKERN=	${KERNLIB}
69.else
70LIBKERN=        ${KERNLIB_PROF}
71.endif
72
73### find out what to use for libcompat
74.include "$S/compat/common/Makefile.inc"
75.ifndef PROF
76LIBCOMPAT=      ${COMPATLIB}
77.else
78LIBCOMPAT=      ${COMPATLIB_PROF}
79.endif
80
81# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
82# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
83
84NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
85NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
86NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
87
88HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
89
90%OBJS
91
92%CFILES
93
94%SFILES
95
96# load lines for config "xxx" will be emitted as:
97# xxx: ${SYSTEM_DEP} swapxxx.o
98#	${SYSTEM_LD_HEAD}
99#	${SYSTEM_LD} swapxxx.o
100#	${SYSTEM_LD_TAIL}
101SYSTEM_OBJ=	intvec.o subr.o \
102		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
103SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
104SYSTEM_LD_HEAD=	@rm -f $@
105SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
106		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
107SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
108
109DEBUG?=
110.if ${DEBUG} == "-g"
111LINKFLAGS+=	-X
112SYSTEM_LD_TAIL+=; \
113		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
114		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
115		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
116.else
117LINKFLAGS+=	-S
118.endif
119
120%LOAD
121
122assym.h: $S/kern/genassym.sh ${VAX}/vax/genassym.cf
123	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
124	    < ${VAX}/vax/genassym.cf > assym.h.tmp && \
125	    mv -f assym.h.tmp assym.h
126
127param.c: $S/conf/param.c
128	rm -f param.c
129	cp $S/conf/param.c .
130
131param.o: param.c Makefile
132	${NORMAL_C}
133
134ioconf.o: ioconf.c
135	${NORMAL_C}
136
137newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
138	sh $S/conf/newvers.sh
139	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
140
141__CLEANKERNEL: .USE
142	@echo "${.TARGET}ing the kernel objects"
143	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
144	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
145
146__CLEANDEPEND: .USE
147	rm -f .depend
148
149clean: __CLEANKERNEL
150
151cleandir distclean: __CLEANKERNEL __CLEANDEPEND
152
153lint:
154	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
155	    ${VAX}/vax/Locore.c ${CFILES} \
156	    ioconf.c param.c | \
157	    grep -v 'static function .* unused'
158
159tags:
160	@echo "see $S/kern/Makefile for tags"
161
162links:
163	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
164	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
165	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
166	  sort -u | comm -23 - dontlink | \
167	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
168	sh makelinks && rm -f dontlink
169
170SRCS=	${VAX}/vax/intvec.s ${VAX}/vax/subr.s \
171	param.c ioconf.c ${CFILES} ${SFILES}
172depend: .depend
173.depend: ${SRCS} assym.h param.c
174	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${VAX}/vax/intvec.s ${VAX}/vax/subr.s
175	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
176	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
177	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
178	  ${CPPFLAGS} < ${VAX}/vax/genassym.cf
179	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
180	@rm -f assym.dep
181
182dependall: depend all
183
184
185# depend on root or device configuration
186autoconf.o conf.o: Makefile
187 
188# depend on network or filesystem configuration 
189uipc_proto.o vfs_conf.o: Makefile 
190
191# depend on maxusers
192machdep.o: Makefile
193
194# depend on CPU configuration 
195tmscp.o ts.o uba.o uda.o autoconf.o clock.o conf.o emulate.o intvec.o: Makefile
196machdep.o sbi.o subr.o: Makefile
197
198
199intvec.o: ${VAX}/vax/intvec.s assym.h
200	${NORMAL_S}
201
202subr.o: ${VAX}/vax/subr.s assym.h
203	${NORMAL_S}
204
205# The install target can be redefined by putting a
206# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
207MACHINE_NAME!=  uname -n
208install: install-kernel-${MACHINE_NAME}
209.if !target(install-kernel-${MACHINE_NAME}})
210install-kernel-${MACHINE_NAME}:
211	rm -f /onetbsd
212	ln /netbsd /onetbsd
213	cp netbsd /nnetbsd
214	mv /nnetbsd /netbsd
215.endif
216
217%RULES
218