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