Makefile.alpha revision 1.52
1# $NetBSD: Makefile.alpha,v 1.52 1999/07/09 09:52:55 mrg 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 cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
107		echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@
108.else
109LINKFLAGS+=	-S
110.endif
111
112%LOAD
113
114# Use awk to cross-build assym.h from the genassym.s file.
115assym.h: genassym.o $S/kern/genassym.awk
116	awk -f $S/kern/genassym.awk < genassym.s > $@
117
118# The above rule lists genassym.o as a prerequisite so that the
119# generated .depend rule is effective, even though we actually
120# use genassym.s instead.   This always creates both.
121genassym.o: ${ALPHA}/alpha/genassym.c
122	${CC} ${CPPFLAGS} -S $<
123	${CC} -c $*.s
124
125param.c: $S/conf/param.c
126	rm -f param.c
127	cp $S/conf/param.c .
128
129param.o: param.c Makefile
130	${NORMAL_C}
131
132ioconf.o: ioconf.c
133	${NORMAL_C}
134
135newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
136	sh $S/conf/newvers.sh
137	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
138
139
140__CLEANKERNEL: .USE
141	@echo "${.TARGET}ing the kernel objects"
142	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
143	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
144
145__CLEANDEPEND: .USE
146	rm -f .depend
147
148clean: __CLEANKERNEL
149
150cleandir distclean: __CLEANKERNEL __CLEANDEPEND
151
152lint:
153	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
154	    ${ALPHA}/alpha/Locore.c ${CFILES} \
155	    ioconf.c param.c | \
156	    grep -v 'static function .* unused'
157
158tags:
159	@echo "see $S/kern/Makefile for tags"
160
161links:
162	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
163	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
164	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
165	  sort -u | comm -23 - dontlink | \
166	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
167	sh makelinks && rm -f dontlink
168
169SRCS=	${ALPHA}/alpha/locore.s ${ALPHA}/alpha/transfer.s \
170	param.c ioconf.c ${CFILES} ${SFILES}
171depend: .depend
172.depend: ${SRCS} assym.h param.c
173	${MKDEP} -x assembler-with-cpp ${AFLAGS} ${CPPFLAGS} \
174	    ${ALPHA}/alpha/locore.s
175	${MKDEP} -a -x assembler-with-cpp ${AFLAGS} ${CPPFLAGS} \
176	    ${ALPHA}/alpha/transfer.s
177	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
178	test -z "${SFILES}" || \
179	${MKDEP} -a -x assembler-with-cpp ${AFLAGS} ${CPPFLAGS} ${SFILES}
180	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} ${ALPHA}/alpha/genassym.c
181
182
183# depend on root or device configuration
184autoconf.o conf.o: Makefile
185 
186# depend on network or filesystem configuration 
187uipc_proto.o vfs_conf.o: Makefile 
188
189# depend on maxusers
190genassym.o machdep.o: Makefile
191
192# depend on CPU configuration 
193clock.o machdep.o apecs.o cia.o lca.o ioasic.o scc.o icasic.o: Makefile
194
195locore.o: ${ALPHA}/alpha/locore.s assym.h
196	${NORMAL_S}
197
198transfer.o: ${ALPHA}/alpha/transfer.s
199	${NORMAL_S}
200
201%RULES
202