Makefile.powerpc revision 1.19
1#	$NetBSD: Makefile.powerpc,v 1.19 2001/10/26 06:45:39 jmc 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/powerpc/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/powerpc/conf/Makefile.powerpc
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
21MACHINE_ARCH=powerpc
22USETOOLS?=	no
23
24.include <bsd.own.mk>
25
26# DEBUG is set to -g if debugging.
27# PROF is set to -pg if profiling.
28
29AR?=		ar
30AS?=		as
31CC?=		cc
32CPP?=		cpp
33LD?=		ld
34LORDER?=	lorder
35MKDEP?=		mkdep
36NM?=		nm
37OBJCOPY?=	objcopy
38OBJDUMP?=	objdump
39RANLIB?=	ranlib
40SIZE?=		size
41STRIP?=		strip
42TSORT?=		tsort -q
43
44COPTS?=		-O2
45TEXTADDR?=	0x100000
46
47# source tree is located via $S relative to the compilation directory
48.ifndef S
49S!=		cd ../../../..; pwd
50.endif
51THISPPC=	$S/arch/${MACHINE}
52POWERPC=	$S/arch/powerpc
53
54INCLUDES=	-I. -I$S/arch -I$S -nostdinc
55CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
56		-D_KERNEL -D_KERNEL_OPT -D${MACHINE}
57CWARNFLAGS?=	-Werror -Wall -Wreturn-type -Wpointer-arith -Wno-main \
58		-Wmissing-prototypes -Wstrict-prototypes
59# XXX Delete -Wuninitialized for now, since the compiler doesn't
60# XXX always get it right.  --thorpej
61CWARNFLAGS+=	-Wno-uninitialized
62CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float ${CCPUOPTS}
63AFLAGS=		-D_LOCORE ${AOPTS}
64LINKFLAGS=	-N -Ttext ${TEXTADDR} -e __start
65STRIPFLAGS=	--strip-debug
66
67.if exists(${THISPPC}/conf/Makefile.${MACHINE}.inc)
68.include "${THISPPC}/conf/Makefile.${MACHINE}.inc"
69.endif
70
71%INCLUDES
72
73### find out what to use for libkern
74.include "$S/lib/libkern/Makefile.inc"
75.ifndef PROF
76LIBKERN=	${KERNLIB}
77.else
78LIBKERN=	${KERNLIB_PROF}
79.endif
80
81### find out what to use for libcompat
82.include "$S/compat/common/Makefile.inc"
83.ifndef PROF
84LIBCOMPAT=	${COMPATLIB}
85.else
86LIBCOMPAT=	${COMPATLIB_PROF}
87.endif
88
89# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
90# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
91
92NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
93NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
94NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
95
96%OBJS
97
98%CFILES
99
100%SFILES
101
102# load lines for config "xxx" will be emitted as:
103# xxx: ${SYSTEM_DEP} swapxxx.o
104#	${SYSTEM_LD_HEAD}
105#	${SYSTEM_LD} swapxxx.o
106#	${SYSTEM_LD_TAIL}
107SYSTEM_OBJ=	locore.o \
108		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
109SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
110SYSTEM_LD_HEAD=	rm -f $@
111SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
112		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
113SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
114
115DEBUG?=
116.if ${DEBUG} == "-g"
117LINKFLAGS+=	-X
118SYSTEM_LD_TAIL+=; \
119		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
120		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
121		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
122.else
123LINKFLAGS+=	-S
124.endif
125.if defined(NEED_SREC)
126SYSTEM_LD_TAIL+=; \
127		${OBJCOPY} -v -O srec $@ $@.srec
128.endif
129
130%LOAD
131
132assym.h: $S/kern/genassym.sh ${THISPPC}/${MACHINE}/genassym.cf
133	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
134	    < ${THISPPC}/${MACHINE}/genassym.cf > assym.h.tmp && \
135	mv -f assym.h.tmp assym.h
136
137param.c: $S/conf/param.c
138	rm -f param.c
139	cp $S/conf/param.c .
140
141param.o: param.c Makefile
142	${NORMAL_C}
143
144ioconf.o: ioconf.c
145	${NORMAL_C}
146
147newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
148	sh $S/conf/newvers.sh
149	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
150
151__CLEANKERNEL: .USE
152	@echo "${.TARGET}ing the kernel objects"
153	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
154	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
155
156__CLEANDEPEND: .USE
157	rm -f .depend
158
159clean: __CLEANKERNEL
160
161cleandir distclean: __CLEANKERNEL __CLEANDEPEND
162
163lint:
164	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
165	    ${THISPPC}/${MACHINE}/Locore.c ${CFILES} \
166	    ioconf.c param.c | \
167	    grep -v 'static function .* unused'
168
169tags:
170	@echo "see $S/kern/Makefile for tags"
171
172links:
173	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
174	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
175	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
176	  sort -u | comm -23 - dontlink | \
177	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
178	sh makelinks && rm -f dontlink
179
180SRCS=	${THISPPC}/${MACHINE}/locore.S \
181	param.c ioconf.c ${CFILES} ${SFILES}
182depend: .depend
183.depend: ${SRCS} assym.h param.c
184	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISPPC}/${MACHINE}/locore.S
185	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
186.if ${SFILES} != ""
187	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
188.endif
189	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
190	  ${CPPFLAGS} < ${THISPPC}/${MACHINE}/genassym.cf
191	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
192	@rm -f assym.dep
193
194dependall: depend all
195
196# depend on root or device configuration
197autoconf.o conf.o: Makefile
198
199# depend on network or filesystem configuration
200uipc_proto.o vfs_conf.o: Makefile
201
202# depend on maxusers
203machdep.o: Makefile
204
205# depend on CPU configuration
206locore.o machdep.o: Makefile
207
208locore.o: ${THISPPC}/${MACHINE}/locore.S assym.h
209	${NORMAL_S}
210
211# The install target can be redefined by putting a
212# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
213MACHINE_NAME!=  uname -n
214install: install-kernel-${MACHINE_NAME}
215.if !target(install-kernel-${MACHINE_NAME}})
216install-kernel-${MACHINE_NAME}:
217	rm -f /onetbsd
218	ln /netbsd /onetbsd
219	cp netbsd /nnetbsd
220	mv /nnetbsd /netbsd
221.endif
222
223%RULES
224