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