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