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