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