Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / conf / Makefile.alpha
CommitLineData
984263bc
MD
1# Makefile.alpha -- with config changes.
2# Copyright 1990 W. Jolitz
3# from: @(#)Makefile.alpha 7.1 5/10/91
4# $FreeBSD: src/sys/conf/Makefile.alpha,v 1.47.2.15 2002/11/18 11:26:49 ru Exp $
5#
6# Makefile for FreeBSD
7#
8# This makefile is constructed from a machine description:
9# config machineid
10# Most changes should be made in the machine description
11# /sys/alpha/conf/``machineid''
12# after which you should do
13# config machineid
14# Generic makefile changes should be made in
15# /sys/conf/Makefile.alpha
16# after which config should be rerun for all machines.
17#
18
19# Which version of config(8) is required.
20%VERSREQ= 400019
21
22# Can be overridden by makeoptions or /etc/make.conf
23KERNEL?= kernel
24STD8X16FONT?= iso
25
26.if !defined(S)
27.if exists(./@/.)
28S= ./@
29.else
30S= ../..
31.endif
32.endif
33M= ${MACHINE_ARCH}
34
35SIZE?= size
36OBJCOPY?= objcopy
37
38COPTFLAGS?=-O -pipe
39.if !defined(NO_CPU_COPTFLAGS)
40COPTFLAGS+= ${_CPUCFLAGS}
41.endif
42INCLUDES= -nostdinc -I- -I. -I$S
43# This hack is to allow kernel compiles to succeed on machines w/out srcdist
44.if exists($S/../include)
45INCLUDES+= -I$S/../include
46.else
47INCLUDES+= -I/usr/include
48.endif
49
50# This hack lets us use the ipfilter code without spamming a new
51# include path into 100+ source files.
52INCLUDES+= -I$S/contrib/ipfilter
53
54COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
55CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
56
57# XXX LOCORE means "don't declare C stuff" not "for locore.s".
58ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
59
60DEFINED_PROF= ${PROF}
61.if defined(PROF)
62CFLAGS+= -malign-functions=4
63.if ${PROFLEVEL} >= 2
64IDENT+= -DGPROF4 -DGUPROF
65PROF+= -mprofiler-epilogue
66.endif
67.endif
68
69# Put configuration-specific C flags last (except for ${PROF}) so that they
70# can override the others.
71CFLAGS+= ${CONF_CFLAGS}
72
73NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
74NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
75NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
76PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
77
78GEN_CFILES= $S/$M/$M/genassym.c
79# setdef0.c and setdef1.c are intentionally
80# omitted from SYSTEM_CFILES. They include setdefs.h, a header which
81# is generated from all of ${OBJS}. We don't want to have to compile
82# everything just to do a make depend.
83SYSTEM_CFILES= ioconf.c vnode_if.c config.c
84SYSTEM_SFILES= $S/$M/$M/locore.s
85SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
86SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o config.o \
87 setdef1.o hack.So
88SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
89 -e locorestart \
90 -export-dynamic -dynamic-linker /red/herring \
91 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
92SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
93 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
94SYSTEM_DEP+= $S/conf/ldscript.$M
95
96%BEFORE_DEPEND
97
98%OBJS
99
100%CFILES
101
102%SFILES
103
104%MFILES
105
106%CLEAN
107
108.PHONY: all modules
109all: ${KERNEL}
110
111depend: kernel-depend
112clean: kernel-clean
113cleandepend: kernel-cleandepend
114tags: kernel-tags
115install install.debug: kernel-install
116reinstall reinstall.debug: kernel-reinstall
117
118.if !defined(DEBUG)
119FULLKERNEL= ${KERNEL}
120.else
121FULLKERNEL= ${KERNEL}.debug
122${KERNEL}: ${FULLKERNEL}
123 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}
124.endif
125
126${FULLKERNEL}: ${SYSTEM_DEP} vers.o
127 @rm -f ${.TARGET}
128 @echo linking ${.TARGET}
129 ${SYSTEM_LD}
130 ${SYSTEM_LD_TAIL}
131
132.if !exists(.depend)
133${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h}
134.endif
135
136kernel-clean:
137 rm -f *.o *.so *.So *.ko *.s eddep errs \
138 ${FULLKERNEL} ${KERNEL} linterrs makelinks \
139 setdef[01].c setdefs.h tags \
140 vers.c vnode_if.c vnode_if.h ${CLEAN}
141
142#lint: /tmp
143# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
144# $S/$M/$M/Locore.c ${CFILES} ioconf.c | \
145# grep -v 'struct/union .* never defined' | \
146# grep -v 'possible pointer alignment problem'
147
148locore.o: $S/$M/$M/locore.s assym.s
149 ${NORMAL_S}
150
151# This is a hack. BFD "optimizes" away dynamic mode if there are no
152# dynamic references. We could probably do a '-Bforcedynamic' mode like
153# in the a.out ld. For now, this works.
154hack.So: Makefile
155 touch hack.c
156 ${CC} -shared -nostdlib hack.c -o hack.So
157 rm -f hack.c
158
159.ORDER: setdefs.h setdef0.c setdef1.c
160
161setdef0.o: setdef0.c setdefs.h
162 ${NORMAL_C}
163
164setdef1.o: setdef1.c setdefs.h
165 ${NORMAL_C}
166
167setdef0.c setdef1.c setdefs.h: ${OBJS}
168 @gensetdefs ${OBJS}
169
170# this rule stops ./assym.s in .depend from causing problems
171./assym.s: assym.s
172
173assym.s: $S/kern/genassym.sh genassym.o
174 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
175
176genassym.o: $S/$M/$M/genassym.c
177 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
178
179SYSTEM_OBJS+= __divqu.o __divq.o __divlu.o __divl.o
180SYSTEM_OBJS+= __remqu.o __remq.o __remlu.o __reml.o
181CLEAN+= __divqu.S __divq.S __divlu.S __divl.S
182CLEAN+= __remqu.S __remq.S __remlu.S __reml.S
183
184__divqu.S: $S/$M/$M/divrem.m4
185 @echo 'building ${.TARGET} from ${.ALLSRC}'
186 @(echo "define(NAME,\`__divqu')define(OP,\`div')define(S,\`false')"; \
187 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
188
189__divq.S: $S/$M/$M/divrem.m4
190 @echo 'building ${.TARGET} from ${.ALLSRC}'
191 @(echo "define(NAME,\`__divq')define(OP,\`div')define(S,\`true')"; \
192 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
193
194__divlu.S: $S/$M/$M/divrem.m4
195 @echo 'building ${.TARGET} from ${.ALLSRC}'
196 @(echo "define(NAME,\`__divlu')define(OP,\`div')define(S,\`false')"; \
197 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
198
199__divl.S: $S/$M/$M/divrem.m4
200 @echo 'building ${.TARGET} from ${.ALLSRC}'
201 @(echo "define(NAME,\`__divl')define(OP,\`div')define(S,\`true')"; \
202 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
203
204__remqu.S: $S/$M/$M/divrem.m4
205 @echo 'building ${.TARGET} from ${.ALLSRC}'
206 @(echo "define(NAME,\`__remqu')define(OP,\`rem')define(S,\`false')"; \
207 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
208
209__remq.S: $S/$M/$M/divrem.m4
210 @echo 'building ${.TARGET} from ${.ALLSRC}'
211 @(echo "define(NAME,\`__remq')define(OP,\`rem')define(S,\`true')"; \
212 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
213
214__remlu.S: $S/$M/$M/divrem.m4
215 @echo 'building ${.TARGET} from ${.ALLSRC}'
216 @(echo "define(NAME,\`__remlu')define(OP,\`rem')define(S,\`false')"; \
217 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
218
219__reml.S: $S/$M/$M/divrem.m4
220 @echo 'building ${.TARGET} from ${.ALLSRC}'
221 @(echo "define(NAME,\`__reml')define(OP,\`rem')define(S,\`true')"; \
222 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
223
224${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
225
226kernel-depend: assym.s vnode_if.h ${BEFORE_DEPEND} \
227 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} ${SYSTEM_SFILES}
228 rm -f .newdep
229 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
230 env MKDEP_CPP="${CC} -E" \
231 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
232 rm -f .depend
233 mv -f .newdep .depend
234
235kernel-cleandepend:
236 rm -f .depend
237
238links:
239 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
240 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
241 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
242 sort -u | comm -23 - dontlink | \
243 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
244 sh makelinks && rm -f dontlink
245
246kernel-tags:
247 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
248 sh $S/conf/systags.sh
249 rm -f tags1
250 sed -e 's, ../, ,' tags > tags1
251
252kernel-install kernel-install.debug:
253 @if [ ! -f ${KERNEL}${.TARGET:S/kernel-install//} ] ; then \
254 echo "You must build a kernel first." ; \
255 exit 1 ; \
256 fi
257.if exists(${DESTDIR}/${KERNEL})
258 -chflags noschg ${DESTDIR}/${KERNEL}
259 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
260.endif
261 ${INSTALL} -m 555 -o root -g wheel -fschg \
262 ${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
263
264kernel-reinstall kernel-reinstall.debug:
265 ${INSTALL} -m 555 -o root -g wheel -fschg \
266 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
267
268.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
269all: modules
270depend: modules-depend
271clean: modules-clean
272cleandepend: modules-cleandepend
273cleandir: modules-cleandir
274tags: modules-tags
275install install.debug: modules-install
276reinstall reinstall.debug: modules-reinstall
277.endif
278
279MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules
280.if defined(MODULES_OVERRIDE)
281MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
282.endif
283.if defined(DEBUG)
284MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
285.endif
286
287modules:
288 @mkdir -p ${.OBJDIR}/modules
289 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
290 env ${MKMODULESENV} ${MAKE} all
291
292modules-depend:
293 @mkdir -p ${.OBJDIR}/modules
294 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
295 env ${MKMODULESENV} ${MAKE} depend
296
297modules-clean:
298 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
299
300modules-cleandepend:
301 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
302
303modules-clobber: modules-clean
304 rm -rf ${MKMODULESENV}
305
306modules-cleandir:
307 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
308
309modules-tags:
310 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
311
312modules-install modules-install.debug:
313.if !defined(NO_MODULES_OLD)
314 if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
315 mkdir -p ${DESTDIR}/modules.old; \
316 cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \
317 fi;
318.endif
319 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
320
321modules-reinstall modules-reinstall.debug:
322 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
323
324config.o:
325 ${NORMAL_C}
326
327ioconf.o:
328 ${NORMAL_C}
329
330vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
331 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
332
333# XXX strictly, everything depends on Makefile because changes to ${PROF}
334# only appear there, but we don't handle that.
335vers.o:
336 ${NORMAL_C}
337
338vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
339 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
340
341vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
342 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
343
344vnode_if.o:
345 ${NORMAL_C}
346
347.if exists($S/../share/mk)
348.include "$S/../share/mk/bsd.kern.mk"
349.else
350.include <bsd.kern.mk>
351.endif
352
353%RULES
354
355# DO NOT DELETE THIS LINE -- make depend uses it