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