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