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