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
26 AR?= ar
27 AS?= as
28 CC?= cc
29 CPP?= cpp
30 LD?= ld
31 LORDER?= lorder
32 MKDEP?= mkdep
33 NM?= nm
34 OBJCOPY?= objcopy
35 OBJDUMP?= objdump
36 RANLIB?= ranlib
37 SIZE?= size
38 STRIP?= strip
39 TSORT?= tsort -q
40
41 COPTS?= -O2
42 TEXTADDR?= 0x100000
43
44 # source tree is located via $S relative to the compilation directory
45 .ifndef S
46 S!= cd ../../../..; pwd
47 .endif
48 THISPPC= $S/arch/${TARGET_MACHINE}
49 POWERPC= $S/arch/powerpc
50
51 INCLUDES= -I. -I$S/arch -I$S -nostdinc
52 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} \
53 -D_KERNEL -D_KERNEL_OPT -D${TARGET_MACHINE}
54 CWARNFLAGS?= -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
58 CWARNFLAGS+= -Wno-uninitialized
59 CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float ${CCPUOPTS}
60 AFLAGS= -D_LOCORE ${AOPTS}
61 LINKFLAGS= -N -Ttext ${TEXTADDR} -e __start
62 STRIPFLAGS= --strip-debug
63
64 %INCLUDES
65
66 ### find out what to use for libkern
67 .include "$S/lib/libkern/Makefile.inc"
68 .ifndef PROF
69 LIBKERN= ${KERNLIB}
70 .else
71 LIBKERN= ${KERNLIB_PROF}
72 .endif
73
74 ### find out what to use for libcompat
75 .include "$S/compat/common/Makefile.inc"
76 .ifndef PROF
77 LIBCOMPAT= ${COMPATLIB}
78 .else
79 LIBCOMPAT= ${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
85 NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
86 NOPROF_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $<
87 NORMAL_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}
100 SYSTEM_OBJ= locore.o \
101 param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
102 SYSTEM_DEP= Makefile ${SYSTEM_OBJ}
103 SYSTEM_LD_HEAD= rm -f $@
104 SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
105 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
106 SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@
107
108 DEBUG?=
109 .if ${DEBUG} == "-g"
110 LINKFLAGS+= -X
111 SYSTEM_LD_TAIL+=; \
112 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
113 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
114 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
115 .else
116 LINKFLAGS+= -S
117 .endif
118 .if defined(NEED_SREC)
119 SYSTEM_LD_TAIL+=; \
120 ${OBJCOPY} -v -O srec $@ $@.srec
121 .endif
122
123 %LOAD
124
125 assym.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
130 param.c: $S/conf/param.c
131 rm -f param.c
132 cp $S/conf/param.c .
133
134 param.o: param.c Makefile
135 ${NORMAL_C}
136
137 ioconf.o: ioconf.c
138 ${NORMAL_C}
139
140 newvers: ${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
152 clean: __CLEANKERNEL
153
154 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
155
156 lint:
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
162 tags:
163 @echo "see $S/kern/Makefile for tags"
164
165 links:
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
173 SRCS= ${THISPPC}/${TARGET_MACHINE}/locore.S \
174 param.c ioconf.c ${CFILES} ${SFILES}
175 depend: .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
187 dependall: depend all
188
189 # depend on root or device configuration
190 autoconf.o conf.o: Makefile
191
192 # depend on network or filesystem configuration
193 uipc_proto.o vfs_conf.o: Makefile
194
195 # depend on maxusers
196 machdep.o: Makefile
197
198 # depend on CPU configuration
199 locore.o machdep.o: Makefile
200
201 locore.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
206 MACHINE_NAME!= uname -n
207 install: install-kernel-${MACHINE_NAME}
208 .if !target(install-kernel-${MACHINE_NAME}})
209 install-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