1 # Makefile.alpha -- with config changes.
2 # Copyright 1990 W. Jolitz
3 # from: @(#)Makefile.alpha 7.1 5/10/91
8 # This makefile is constructed from a machine description:
10 # Most changes should be made in the machine description
11 # /sys/alpha/conf/``machineid''
12 # after which you should do
14 # Generic makefile changes should be made in
15 # /sys/alpha/conf/Makefile.alpha
16 # after which config should be rerun for all machines.
19 # Which version of config(8) is required.
22 # Can be overridden by makeoptions or /etc/make.conf
25 KODIR?= /boot/${KERNEL}
41 .if !defined(NO_CPU_COPTFLAGS)
42 COPTFLAGS+= ${_CPUCFLAGS}
44 INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
45 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
46 .if exists($S/../include)
47 INCLUDES+= -I$S/../include
49 INCLUDES+= -I/usr/include
51 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
52 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
54 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
55 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
57 # Select the correct set of tools. Can't set OBJFORMAT here because it
58 # doesn't get exported into the environment, and if it were exported
59 # then it might break building of utilities.
65 CFLAGS+= -malign-functions=4
67 IDENT+= -DGPROF4 -DGUPROF
68 PROF+= -mprofiler-epilogue
72 # Put configuration-specific C flags last (except for ${PROF}) so that they
73 # can override the others.
74 CFLAGS+= ${CONF_CFLAGS}
76 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
77 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
78 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
79 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
81 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
82 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
84 GEN_CFILES= $S/$M/$M/genassym.c
85 # setdef0.c and setdef1.c are intentionally
86 # omitted from SYSTEM_CFILES. They include setdefs.h, a header which
87 # is generated from all of ${OBJS}. We don't want to have to compile
88 # everything just to do a make depend.
89 SYSTEM_CFILES= param.c vnode_if.c hints.c config.c
90 SYSTEM_SFILES= $S/$M/$M/locore.s
91 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
92 SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} param.o hints.o config.o \
94 SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
96 -export-dynamic -dynamic-linker /red/herring \
97 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
98 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
99 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
100 SYSTEM_DEP+= $S/conf/ldscript.$M
117 depend: kernel-depend
119 cleandepend: kernel-cleandepend
120 clobber: kernel-clobber
122 install: kernel-install
123 install.debug: kernel-install.debug
124 reinstall: kernel-reinstall
125 reinstall.debug: kernel-reinstall.debug
128 FULLKERNEL= ${KERNEL_KO}
130 FULLKERNEL= ${KERNEL_KO}.debug
131 ${KERNEL_KO}: ${FULLKERNEL}
132 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
135 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
137 @echo linking ${.TARGET}
142 ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
145 .for mfile in ${MFILES}
146 ${mfile:T:S/.m$/.h/}: ${mfile}
147 perl5 $S/kern/makeobjops.pl -h ${mfile}
151 rm -f *.o *.so *.So *.ko *.s eddep errs \
152 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \
153 setdef[01].c setdefs.h tags \
154 vers.c vnode_if.c vnode_if.h \
155 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
159 find . -type f ! -name version -delete
162 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
163 # $S/$M/$M/Locore.c ${CFILES} param.c | \
164 # grep -v 'struct/union .* never defined' | \
165 # grep -v 'possible pointer alignment problem'
167 locore.o: $S/$M/$M/locore.s assym.s
170 # This is a hack. BFD "optimizes" away dynamic mode if there are no
171 # dynamic references. We could probably do a '-Bforcedynamic' mode like
172 # in the a.out ld. For now, this works.
175 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
178 .ORDER: setdefs.h setdef0.c setdef1.c
180 setdef0.o: setdef0.c setdefs.h
183 setdef1.o: setdef1.c setdefs.h
186 setdef0.c setdef1.c setdefs.h: Makefile ${OBJS}
187 @perl5 $S/kern/gensetdefs.pl ${OBJS}
189 # this rule stops ./assym.s in .depend from causing problems
192 assym.s: $S/kern/genassym.sh genassym.o
193 OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET}
195 genassym.o: $S/$M/$M/genassym.c
196 ${CC} -c ${CFLAGS} -elf $S/$M/$M/genassym.c
198 SYSTEM_OBJS+= __divqu.o __divq.o __divlu.o __divl.o
199 SYSTEM_OBJS+= __remqu.o __remq.o __remlu.o __reml.o
200 CLEAN+= __divqu.S __divq.S __divlu.S __divl.S
201 CLEAN+= __remqu.S __remq.S __remlu.S __reml.S
203 __divqu.S: $S/$M/$M/divrem.m4
204 @echo 'building ${.TARGET} from ${.ALLSRC}'
205 @(echo "define(NAME,\`__divqu')define(OP,\`div')define(S,\`false')"; \
206 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
208 __divq.S: $S/$M/$M/divrem.m4
209 @echo 'building ${.TARGET} from ${.ALLSRC}'
210 @(echo "define(NAME,\`__divq')define(OP,\`div')define(S,\`true')"; \
211 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
213 __divlu.S: $S/$M/$M/divrem.m4
214 @echo 'building ${.TARGET} from ${.ALLSRC}'
215 @(echo "define(NAME,\`__divlu')define(OP,\`div')define(S,\`false')"; \
216 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
218 __divl.S: $S/$M/$M/divrem.m4
219 @echo 'building ${.TARGET} from ${.ALLSRC}'
220 @(echo "define(NAME,\`__divl')define(OP,\`div')define(S,\`true')"; \
221 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
223 __remqu.S: $S/$M/$M/divrem.m4
224 @echo 'building ${.TARGET} from ${.ALLSRC}'
225 @(echo "define(NAME,\`__remqu')define(OP,\`rem')define(S,\`false')"; \
226 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
228 __remq.S: $S/$M/$M/divrem.m4
229 @echo 'building ${.TARGET} from ${.ALLSRC}'
230 @(echo "define(NAME,\`__remq')define(OP,\`rem')define(S,\`true')"; \
231 echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
233 __remlu.S: $S/$M/$M/divrem.m4
234 @echo 'building ${.TARGET} from ${.ALLSRC}'
235 @(echo "define(NAME,\`__remlu')define(OP,\`rem')define(S,\`false')"; \
236 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
238 __reml.S: $S/$M/$M/divrem.m4
239 @echo 'building ${.TARGET} from ${.ALLSRC}'
240 @(echo "define(NAME,\`__reml')define(OP,\`rem')define(S,\`true')"; \
241 echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET}
243 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
247 ${MAKE} _kernel-depend
249 _kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
250 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
251 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
253 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
254 env MKDEP_CPP="${CC} -E" \
255 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
257 mv -f .newdep .depend
263 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
264 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
265 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
266 sort -u | comm -23 - dontlink | \
267 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
268 sh makelinks; rm -f dontlink
271 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
272 sh $S/conf/systags.sh
274 sed -e 's, ../, ,' tags > tags1
276 kernel-install kernel-install.debug:
277 .if exists(${DESTDIR}/boot)
278 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
279 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
282 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
283 echo "You must activate /boot/device.hints in loader.conf." ; \
287 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
288 echo "You must build a kernel first." ; \
291 .if exists(${DESTDIR}${KODIR})
292 .if exists(${DESTDIR}${KODIR}.old)
293 @-chflags -R noschg ${DESTDIR}${KODIR}.old
294 -rm -rf ${DESTDIR}${KODIR}.old
296 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
298 mkdir -p ${DESTDIR}${KODIR}
299 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
300 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
302 install -c -m 555 -o root -g wheel -fschg \
303 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
305 kernel-reinstall kernel-reinstall.debug:
306 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
307 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
309 install -c -m 555 -o root -g wheel -fschg \
310 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
312 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
314 depend: modules-depend
316 cleandepend: modules-cleandepend
317 cleandir: modules-cleandir
318 clobber: modules-clobber
320 install: modules-install
321 install.debug: modules-install.debug
322 reinstall: modules-reinstall
323 reinstall.debug: modules-reinstall.debug
326 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
329 @mkdir -p ${.OBJDIR}/modules
330 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
331 env ${MKMODULESENV} ${MAKE} all
334 @mkdir -p ${.OBJDIR}/modules
335 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
336 env ${MKMODULESENV} ${MAKE} depend
339 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
342 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
344 modules-clobber: modules-clean
345 rm -rf ${MKMODULESENV}
348 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
351 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
353 modules-install modules-install.debug:
354 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
356 modules-reinstall modules-reinstall.debug:
357 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
362 param.c: $S/conf/param.c
369 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
370 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
372 # XXX strictly, everything depends on Makefile because changes to ${PROF}
373 # only appear there, but we don't handle that.
380 vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
381 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
383 vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
384 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
389 .if exists($S/../share/mk)
390 .include "$S/../share/mk/bsd.kern.mk"
392 .include <bsd.kern.mk>
397 # DO NOT DELETE THIS LINE -- make depend uses it