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