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