Makefile.powerpc revision 1.1
1#	$NetBSD: Makefile.powerpc,v 1.1 1996/09/30 16:34:18 ws 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
31
32# source tree is located via $S relative to the compilation directory
33.ifndef	S
34S!=	cd ../../../..; pwd
35.endif
36PPC=	$S/arch/powerpc
37
38INCLUDES=	-I. -I$S/arch -I$S -nostdinc
39CPPFLAGS=	${INCLUDES} ${IDENT} -D_KERNEL \
40		-Dpowerpc
41CWARNFLAGS=	-Werror -Wreturn-type
42CFLAGS=		${DEBUG} ${CWARNFLAGS} -O2 -msoft-float
43AFLAGS=		-D_LOCORE
44LINKFLAGS=	-N -Ttext 100000 -e start
45STRIPFLAGS=	-d
46
47HOSTD_CC=	${CC}
48HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
49HOSTED_CFLAGS=	${CFLAGS}
50
51### find out what to use for libkern
52.include "$S/lib/libkern/Makefile.inc"
53.ifndef PROF
54LIBKERN=	${KERNLIB}
55.else
56LIBKERN=	${KERNLIB_PROF}
57.endif
58
59### find out what to use for libcompat
60.include "$S/compat/common/Makefile.inc"
61.ifndef PROF
62LIBCOMPAT=	${COMPATLIB}
63.else
64LIBCOMPAT=	${COMPATLIB_PROF}
65.endif
66
67# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
68# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
69
70NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
71
72NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
73
74HOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
75
76#.c.o:
77#	${NORMAL_C}
78#
79#.S.o:
80#	${NORMAL_S}
81
82%OBJS
83
84%CFILES
85
86%SFILES
87
88# load lines for config "xxx" will be emitted as:
89# xxx: ${SYSTEM_DEP} swapxxx.o
90#	${SYSTEM_LD_HEAD}
91#	${SYSTEM_LD} swapxxx.o
92#	${SYSTEM_LD_TAIL}
93SYSTEM_OBJ=	locore.o \
94		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
95SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
96SYSTEM_LD_HEAD=	rm -f $@
97SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
98		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
99SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
100
101DEBUG?=
102.if ${DEBUG} == "-g"
103LINKFLAGS+=	-X
104SYSTEM_LD_TAIL+=; \
105		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
106		echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@
107.else
108LINKFLAGS+=	-S
109.endif
110
111%LOAD
112
113assym.h: genassym
114	./genassym > assym.h
115
116genassym: genassym.o
117	${HOSTED_CC} -o $@ genassym.o
118
119genassym.o: ${PPC}/powerpc/genassym.c
120	${HOSTED_C}
121
122param.c: $S/conf/param.c
123	rm -f param.c
124	cp $S/conf/param.c .
125
126param.o: param.c Makefile
127	${NORMAL_C}
128
129ioconf.o: ioconf.c
130	${NORMAL_C}
131
132newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
133	sh $S/conf/newvers.sh
134	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
135
136clean::
137	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
138		[Ee]rrs linterrs makelinks genassym genassym.o assym.h
139
140lint:
141	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB \
142		${PPC}/powerpc/Locore.c ${CFILES} ${PPC}/powerpc/swapgeneric.c \
143		ioconf.c param.c | \
144		grep -v 'static function .* unused'
145
146tags:
147	@echo "see $S/kern/Makefile for tags"
148
149links:
150	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
151	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
152	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
153	  sort -u | comm -23 - dontlink | \
154	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
155	sh makelinks && rm -f dontlink
156
157SRCS=	${PPC}/powerpc/locore.S \
158	param.c ioconf.c ${CFILES} ${SFILES}
159depend:: .depend
160.depend: ${SRCS} assym.h param.c
161	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${PPC}/powerpc/locore.S
162	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
163.if ${SFILES} != ""
164	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
165.endif
166	${MKDEP} -a ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} \
167	    ${PPC}/powerpc/genassym.c
168
169# depend on root or device configuration
170autoconf.o conf.o: Makefile
171
172# depend on network or filesystem configuration
173uipc_proto.o vfs_conf.o: Makefile
174
175# depend on maxusers
176genassym.o machdep.o: Makefile
177
178# depend on CPU configuration
179locore.o machdep.o: Makefile
180
181
182locore.o: ${PPC}/powerpc/locore.S assym.h
183	${NORMAL_S}
184
185%RULES
186