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