xref: /netbsd-src/sys/arch/powerpc/conf/Makefile.powerpc (revision 8a8f936f250a330d54f8a24ed0e92aadf9743a7b)
1#	$NetBSD: Makefile.powerpc,v 1.15 2001/08/26 10:59:26 simonb 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.if exists(${THISPPC}/conf/Makefile.${TARGET_MACHINE}.inc)
65.include "${THISPPC}/conf/Makefile.${TARGET_MACHINE}.inc"
66.endif
67
68%INCLUDES
69
70### find out what to use for libkern
71.include "$S/lib/libkern/Makefile.inc"
72.ifndef PROF
73LIBKERN=	${KERNLIB}
74.else
75LIBKERN=	${KERNLIB_PROF}
76.endif
77
78### find out what to use for libcompat
79.include "$S/compat/common/Makefile.inc"
80.ifndef PROF
81LIBCOMPAT=	${COMPATLIB}
82.else
83LIBCOMPAT=	${COMPATLIB_PROF}
84.endif
85
86# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
87# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
88
89NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
90NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
91NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
92
93%OBJS
94
95%CFILES
96
97%SFILES
98
99# load lines for config "xxx" will be emitted as:
100# xxx: ${SYSTEM_DEP} swapxxx.o
101#	${SYSTEM_LD_HEAD}
102#	${SYSTEM_LD} swapxxx.o
103#	${SYSTEM_LD_TAIL}
104SYSTEM_OBJ=	locore.o \
105		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
106SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
107SYSTEM_LD_HEAD=	rm -f $@
108SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
109		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
110SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
111
112DEBUG?=
113.if ${DEBUG} == "-g"
114LINKFLAGS+=	-X
115SYSTEM_LD_TAIL+=; \
116		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
117		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
118		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
119.else
120LINKFLAGS+=	-S
121.endif
122.if defined(NEED_SREC)
123SYSTEM_LD_TAIL+=; \
124		${OBJCOPY} -v -O srec $@ $@.srec
125.endif
126
127%LOAD
128
129assym.h: $S/kern/genassym.sh ${THISPPC}/${TARGET_MACHINE}/genassym.cf
130	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
131	    < ${THISPPC}/${TARGET_MACHINE}/genassym.cf > assym.h.tmp && \
132	mv -f assym.h.tmp assym.h
133
134param.c: $S/conf/param.c
135	rm -f param.c
136	cp $S/conf/param.c .
137
138param.o: param.c Makefile
139	${NORMAL_C}
140
141ioconf.o: ioconf.c
142	${NORMAL_C}
143
144newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
145	sh $S/conf/newvers.sh
146	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
147
148__CLEANKERNEL: .USE
149	@echo "${.TARGET}ing the kernel objects"
150	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
151	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
152
153__CLEANDEPEND: .USE
154	rm -f .depend
155
156clean: __CLEANKERNEL
157
158cleandir distclean: __CLEANKERNEL __CLEANDEPEND
159
160lint:
161	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
162	    ${THISPPC}/${TARGET_MACHINE}/Locore.c ${CFILES} \
163	    ioconf.c param.c | \
164	    grep -v 'static function .* unused'
165
166tags:
167	@echo "see $S/kern/Makefile for tags"
168
169links:
170	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
171	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
172	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
173	  sort -u | comm -23 - dontlink | \
174	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
175	sh makelinks && rm -f dontlink
176
177SRCS=	${THISPPC}/${TARGET_MACHINE}/locore.S \
178	param.c ioconf.c ${CFILES} ${SFILES}
179depend: .depend
180.depend: ${SRCS} assym.h param.c
181	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISPPC}/${TARGET_MACHINE}/locore.S
182	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
183.if ${SFILES} != ""
184	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
185.endif
186	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
187	  ${CPPFLAGS} < ${THISPPC}/${TARGET_MACHINE}/genassym.cf
188	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
189	@rm -f assym.dep
190
191dependall: depend all
192
193# depend on root or device configuration
194autoconf.o conf.o: Makefile
195
196# depend on network or filesystem configuration
197uipc_proto.o vfs_conf.o: Makefile
198
199# depend on maxusers
200machdep.o: Makefile
201
202# depend on CPU configuration
203locore.o machdep.o: Makefile
204
205locore.o: ${THISPPC}/${TARGET_MACHINE}/locore.S assym.h
206	${NORMAL_S}
207
208# The install target can be redefined by putting a
209# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
210MACHINE_NAME!=  uname -n
211install: install-kernel-${MACHINE_NAME}
212.if !target(install-kernel-${MACHINE_NAME}})
213install-kernel-${MACHINE_NAME}:
214	rm -f /onetbsd
215	ln /netbsd /onetbsd
216	cp netbsd /nnetbsd
217	mv /nnetbsd /netbsd
218.endif
219
220%RULES
221