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