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