Makefile.powerpc revision 1.6
1#	$NetBSD: Makefile.powerpc,v 1.6 1997/04/16 23:26:06 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#
21.SUFFIXES:	.S .c .o
22
23# DEBUG is set to -g if debugging.
24# PROF is set to -pg if profiling.
25
26CC?=	cc
27LD?=	ld
28MKDEP?=	mkdep
29STRIP?=	strip
30SIZE?=	size
31COPTS?= 	-O2
32
33# source tree is located via $S relative to the compilation directory
34.ifndef	S
35S!=	cd ../../../..; pwd
36.endif
37PPC=	$S/arch/powerpc
38
39INCLUDES=	-I. -I$S/arch -I$S -nostdinc
40CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
41		-Dpowerpc
42CWARNFLAGS=	-Werror -Wreturn-type
43CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float
44AFLAGS=		-D_LOCORE
45LINKFLAGS=	-N -Ttext 100000 -e __start
46STRIPFLAGS=	--strip-debug
47
48### find out what to use for libkern
49.include "$S/lib/libkern/Makefile.inc"
50.ifndef PROF
51LIBKERN=	${KERNLIB}
52.else
53LIBKERN=	${KERNLIB_PROF}
54.endif
55
56### find out what to use for libcompat
57.include "$S/compat/common/Makefile.inc"
58.ifndef PROF
59LIBCOMPAT=	${COMPATLIB}
60.else
61LIBCOMPAT=	${COMPATLIB_PROF}
62.endif
63
64# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
65# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
66
67NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
68
69NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
70
71#.c.o:
72#	${NORMAL_C}
73#
74#.S.o:
75#	${NORMAL_S}
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 \
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
108assym.h: $S/kern/genassym.sh ${PPC}/hp300/genassym.cf
109	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
110	    < ${PPC}/hp300/genassym.cf > assym.h.tmp && \
111	mv -f assym.h.tmp assym.h
112
113param.c: $S/conf/param.c
114	rm -f param.c
115	cp $S/conf/param.c .
116
117param.o: param.c Makefile
118	${NORMAL_C}
119
120ioconf.o: ioconf.c
121	${NORMAL_C}
122
123newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
124	sh $S/conf/newvers.sh
125	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
126
127clean: cleankernel
128cleankernel:
129	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
130		[Ee]rrs linterrs makelinks assym.h
131
132lint:
133	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
134		${PPC}/powerpc/Locore.c ${CFILES} \
135		ioconf.c param.c | \
136		grep -v 'static function .* unused'
137
138tags:
139	@echo "see $S/kern/Makefile for tags"
140
141links:
142	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
143	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
144	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
145	  sort -u | comm -23 - dontlink | \
146	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
147	sh makelinks && rm -f dontlink
148
149SRCS=	${PPC}/powerpc/locore.S \
150	param.c ioconf.c ${CFILES} ${SFILES}
151depend: .depend
152.depend: ${SRCS} assym.h param.c
153	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${PPC}/powerpc/locore.S
154	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
155.if ${SFILES} != ""
156	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
157.endif
158
159# depend on root or device configuration
160autoconf.o conf.o: Makefile
161
162# depend on network or filesystem configuration
163uipc_proto.o vfs_conf.o: Makefile
164
165# depend on maxusers
166machdep.o: Makefile
167
168# depend on CPU configuration
169locore.o machdep.o: Makefile
170
171
172locore.o: ${PPC}/powerpc/locore.S assym.h
173	${NORMAL_S}
174
175%RULES
176