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