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