Makefile.sparc64 revision 1.41 1 # $NetBSD: Makefile.sparc64,v 1.41 2001/10/24 19:12:18 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/sparc64/conf/``machineid''
9 # after which you should do
10 # config machineid
11 # Machine generic makefile changes should be made in
12 # /sys/arch/sparc64/conf/Makefile.sparc64
13 # after which config should be rerun for all machines of that type.
14
15 # Default to 32-bit. Set the MACHINE_ARCH accordingly, using either
16 # the 32-bit or 64-bit toolchain.
17 LP64?= no
18 .if ${LP64} == "yes"
19 MACHINE_ARCH=sparc64
20 .else
21 MACHINE_ARCH=sparc
22 .endif
23
24 .include <bsd.own.mk>
25
26 # DEBUG is set to -g if debugging.
27 # PROF is set to -pg if profiling.
28
29 AR?= ar
30 AS?= as
31 CC?= cc
32 CPP?= cpp
33 LD?= ld
34 LORDER?=lorder
35 MKDEP?= mkdep
36 NM?= nm
37 RANLIB?=ranlib
38 SIZE?= size
39 STRIP?= strip
40 TSORT?= tsort -q
41
42 COPTS?= -O2
43
44 # source tree is located via $S relative to the compilation directory
45 .ifndef S
46 S!= cd ../../../..; pwd
47 .endif
48 SPARC64= $S/arch/sparc64
49
50 INCLUDES= -I. -I$S/arch -I$S -nostdinc
51 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dsparc64
52 CWARNFLAGS= -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
53 -Wpointer-arith
54 # XXX Delete -Wuninitialized for now, since the compiler doesn't
55 # XXX always get it right. --thorpej
56 CWARNFLAGS+= -Wno-uninitialized
57 CWARNFLAGS+= -Wno-main
58 .if ${LP64} == "yes"
59 CPPFLAGS+= -D_LP64
60 .endif
61
62 CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} -Wa,-Av9a -mno-fpu
63 .if defined(PROF)
64 # We need to run the compiler in medlow memory model.
65 CFLAGS+= -mcmodel=medlow
66 .endif
67 AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-Av9a
68
69 #
70 # Gotta find a way to make kernel base tuneable.
71 #
72
73 LINKFLAGS= -Ttext 01000000 -Tdata 01800000 -e start
74 #LINKFLAGS= -Ttext f1000000 -Tdata f1400000 -e start
75
76 LINKFLAGS+= -n -T ${SPARC64}/conf/${KERN_LDSCRIPT}
77 .if ${LP64} == "yes"
78 KERN_LDSCRIPT?= kern.ldscript
79 .else
80 KERN_LDSCRIPT?= kern32.ldscript
81 .endif
82
83 STRIPFLAGS= -g
84
85 %INCLUDES
86
87 ### find out what to use for libkern
88 # KERN_AS= obj # bcopy, bzero, memcpy, memset, etc. are in locore.s
89 .include "$S/lib/libkern/Makefile.inc"
90 .ifndef PROF
91 LIBKERN= ${KERNLIB}
92 .else
93 LIBKERN= ${KERNLIB_PROF}
94 .endif
95
96 ### find out what to use for libcompat
97 .include "$S/compat/common/Makefile.inc"
98 .ifndef PROF
99 LIBCOMPAT= ${COMPATLIB}
100 .else
101 LIBCOMPAT= ${COMPATLIB_PROF}
102 .endif
103
104 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
105 # HOSTED, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
106
107 NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
108 NOOPT_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -O0 -c $<
109 NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
110
111 %OBJS
112
113 %CFILES
114
115 %SFILES
116
117 # load lines for config "xxx" will be emitted as:
118 # xxx: ${SYSTEM_DEP} swapxxx.o
119 # ${SYSTEM_LD_HEAD}
120 # ${SYSTEM_LD} swapxxx.o
121 # ${SYSTEM_LD_TAIL}
122 SYSTEM_OBJ= locore.o \
123 param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
124 SYSTEM_DEP= Makefile ${SYSTEM_OBJ}
125 SYSTEM_LD_HEAD= rm -f $@
126 SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
127 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
128 SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@
129
130 DEBUG?=
131 .if ${DEBUG} == "-g"
132 LINKFLAGS+= -X
133 SYSTEM_LD_TAIL+=; \
134 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
135 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
136 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
137 .else
138 LINKFLAGS+= -S
139 .endif
140
141 %LOAD
142
143 assym.h: $S/kern/genassym.sh ${SPARC64}/sparc64/genassym.cf
144 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
145 < ${SPARC64}/sparc64/genassym.cf > assym.h.tmp && \
146 mv -f assym.h.tmp assym.h
147
148 param.c: $S/conf/param.c
149 rm -f param.c
150 cp $S/conf/param.c .
151
152 param.o: param.c Makefile
153 ${NORMAL_C}
154
155 ioconf.o: ioconf.c
156 ${NORMAL_C}
157
158 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
159 sh $S/conf/newvers.sh
160 ${CC} ${COPTS} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
161
162
163 __CLEANKERNEL: .USE
164 @echo "${.TARGET}ing the kernel objects"
165 rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
166 [Ee]rrs linterrs makelinks assym.h.tmp assym.h
167
168 __CLEANDEPEND: .USE
169 rm -f .depend
170
171 clean: __CLEANKERNEL
172
173 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
174
175 lint:
176 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
177 ${SPARC64}/sparc64/Locore.c ${CFILES} \
178 ioconf.c param.c | \
179 grep -v 'static function .* unused'
180
181 tags:
182 @echo "see $S/kern/Makefile for tags"
183
184 links:
185 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
186 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
187 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
188 sort -u | comm -23 - dontlink | \
189 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
190 sh makelinks && rm -f dontlink
191
192 SRCS= ${SPARC64}/sparc64/locore.s \
193 param.c ioconf.c ${CFILES} ${SFILES}
194 depend: .depend
195 .depend: ${SRCS} assym.h param.c
196 ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SPARC64}/sparc64/locore.s
197 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
198 .if (${SFILES} != "")
199 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
200 .endif
201 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${COPTS} ${CFLAGS} \
202 ${CPPFLAGS} < ${SPARC64}/sparc64/genassym.cf
203 @sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
204 @rm -f assym.dep
205
206 dependall: depend all
207
208
209 # depend on root or device configuration
210 autoconf.o conf.o: Makefile
211
212 # depend on network or filesystem configuration
213 uipc_proto.o vfs_conf.o: Makefile
214
215 # depend on maxusers
216 machdep.o: Makefile
217
218 # depend on CPU configuration
219 bwtwo.o cgsix.o cgthree.o cgtwo.o cons.o dma.o esp.o fb.o if_ie.o: Makefile
220 ms.c obio.o zs.c autoconf.o clock.o cpu.o disksubr.o locore.o: Makefile
221 machdep.o mem.o openprom.o pmap.o vm_machdep.o: Makefile
222
223
224 locore.o: ${SPARC64}/sparc64/locore.s assym.h
225 ${NORMAL_S}
226
227 # The install target can be redefined by putting a
228 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
229 MACHINE_NAME!= uname -n
230 install: install-kernel-${MACHINE_NAME}
231 .if !target(install-kernel-${MACHINE_NAME}})
232 install-kernel-${MACHINE_NAME}:
233 rm -f /onetbsd
234 ln /netbsd /onetbsd
235 cp netbsd /nnetbsd
236 mv /nnetbsd /netbsd
237 .endif
238
239 %RULES
240