1# Makefile.i386 -- with config changes. 2# Copyright 1990 W. Jolitz 3# from: @(#)Makefile.i386 7.1 5/10/91 4# $Id: Makefile.i386,v 1.157 1999/07/02 04:00:01 jkh 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/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= 400016 21 22# Can be overridden by makeoptions or /etc/make.conf 23KERNEL?= kernel 24KERNFORMAT?= elf 25STD8X16FONT?= iso 26 27.if exists(./@/.) 28S= ./@ 29.else 30S= ../.. 31.endif 32I386= ${S}/i386 33 34COPTFLAGS?=-O 35INCLUDES= -nostdinc -I- -I. -I$S 36# This hack is to allow kernel compiles to succeed on machines w/out srcdist 37.if exists($S/../include) 38INCLUDES+= -I$S/../include 39.else 40INCLUDES+= -I/usr/include 41.endif 42COPTS= ${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h 43CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 44 45# XXX LOCORE means "don't declare C stuff" not "for locore.s". 46ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 47 48# Use the default object format for genassym, etc. 49GEN_CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} -UKERNEL 50 51# Select the correct set of tools. Can't set OBJFORMAT here because it 52# doesn't get exported into the environment, and if it were exported 53# then it might break building of genassym, etc. 54.if ${KERNFORMAT} == "elf" 55CFLAGS+= -elf 56.else 57CFLAGS+= -aout 58.endif 59 60LOAD_ADDRESS?= C0100000 61DEFINED_PROF= ${PROF} 62.if defined(PROF) 63CFLAGS+= -malign-functions=4 64.if ${PROFLEVEL} >= 2 65IDENT+= -DGPROF4 -DGUPROF 66PROF+= -mprofiler-epilogue 67.endif 68.endif 69 70NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $< 71NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} $< 72NORMAL_S= ${CC} -c ${ASM_CFLAGS} $< 73PROFILE_C= ${CC} -c ${CFLAGS} $< 74 75GEN_CFILES= ${I386}/i386/genassym.c 76# setdef0.c and setdef1.c are intentionally 77# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 78# is generated from all of ${OBJS}. We don't want to have to compile 79# everything just to do a make depend. 80SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c 81SYSTEM_SFILES= ${I386}/i386/locore.s 82SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} 83.if ${CFLAGS:M-g} == "" 84SYMORDER_EXCLUDE=-x symbols.exclude 85.endif 86 87.if ${KERNFORMAT} == aout || ${KERNFORMAT} == aoutkld 88SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o 89SYSTEM_LD= @${LD} -aout -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 90SYSTEM_LD_TAIL= @echo rearranging symbols; \ 91 symorder -m ${SYMORDER_EXCLUDE} symbols.sort ${.TARGET}; \ 92 size -aout ${.TARGET} ; chmod 755 ${.TARGET} 93.endif 94 95.if ${KERNFORMAT} == elf 96SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \ 97 setdef1.o hack.So 98SYSTEM_LD= @${LD} -elf -Bdynamic -T $S/i386/conf/kernel.script \ 99 -export-dynamic -dynamic-linker /red/herring \ 100 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 101SYSTEM_LD_TAIL= @size -elf ${.TARGET} ; chmod 755 ${.TARGET} 102SYSTEM_DEP+= $S/i386/conf/kernel.script 103.endif 104 105%BEFORE_DEPEND 106 107%OBJS 108 109%CFILES 110 111%SFILES 112 113%MFILES 114 115%CLEAN 116 117all: ${KERNEL} 118 119.if !defined(DEBUG) 120FULLKERNEL= ${KERNEL} 121.else 122FULLKERNEL= ${KERNEL}.debug 123${KERNEL}: ${FULLKERNEL} 124.if ${KERNFORMAT} == "elf" 125 objcopy --strip-debug ${FULLKERNEL} ${KERNEL} 126.else 127 cp ${FULLKERNEL} ${KERNEL} 128 strip -d ${KERNEL} 129.endif 130.endif 131 132${FULLKERNEL}: ${BEFORE_DEPEND} ${SYSTEM_DEP} vers.o 133 @rm -f ${.TARGET} 134 @echo linking ${.TARGET} 135 ${SYSTEM_LD} 136 ${SYSTEM_LD_TAIL} 137 138.if !exists(.depend) 139${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} 140.endif 141 142clean: 143 rm -f *.o *.so *.So *.ko *.s eddep errs genassym gensetdefs \ 144 ${KERNEL} ${FULLKERNEL} linterrs makelinks param.c \ 145 setdef[01].c setdefs.h symbols.exclude symbols.sort tags \ 146 vers.c vnode_if.c vnode_if.h ${CLEAN} 147 148#lint: /tmp param.c 149# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 150# ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \ 151# grep -v 'struct/union .* never defined' | \ 152# grep -v 'possible pointer alignment problem' 153 154symbols.exclude: 155 echo "gcc2_compiled." >symbols.exclude 156 echo "___gnu_compiled_c" >>symbols.exclude 157 158symbols.sort: ${I386}/i386/symbols.raw 159 grep -v '^#' ${I386}/i386/symbols.raw \ 160 | sed 's/^ //' | sort -u > symbols.sort 161 162locore.o: ${I386}/i386/locore.s assym.s 163 ${NORMAL_S} 164 165.if ${KERNFORMAT} == elf 166# This is a hack. BFD "optimizes" away dynamic mode if there are no 167# dynamic references. We could probably do a '-Bforcedynamic' mode like 168# in the a.out ld. For now, this works. 169hack.So: Makefile 170 touch hack.c 171 ${CC} -elf -shared -nostdlib hack.c -o hack.So 172 rm -f hack.c 173.endif 174 175.ORDER: setdefs.h setdef0.c setdef1.c 176 177setdef0.o: setdef0.c setdefs.h 178 ${NORMAL_C} 179 180setdef1.o: setdef1.c setdefs.h 181 ${NORMAL_C} 182 183setdef0.c setdef1.c setdefs.h: ${OBJS} 184 @gensetdefs ${OBJS} 185 186# this rule stops ./assym.s in .depend from causing problems 187./assym.s: assym.s 188 189assym.s: genassym 190 ./genassym >assym.s 191 192genassym.o: ${I386}/i386/genassym.c 193 ${CC} -c ${GEN_CFLAGS} ${I386}/i386/genassym.c 194 195genassym: genassym.o 196 ${CC} ${GEN_CFLAGS} genassym.o -o ${.TARGET} 197 198${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 199 200depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} 201 rm -f .newdep 202 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} 203 mkdep -a -f .newdep ${GEN_CFLAGS} ${GEN_CFILES} 204 env MKDEP_CPP="${CC} -E" \ 205 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 206 rm -f .depend 207 mv -f .newdep .depend 208 209cleandepend: 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 220tags: 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 226install install.debug: 227 @if [ ! -f ${KERNEL}${.TARGET:S/install//} ] ; then \ 228 echo "You must first build a kernel first." ; \ 229 exit 1 ; \ 230 fi 231.if exists(${DESTDIR}/${KERNEL}) 232 -chflags noschg ${DESTDIR}/${KERNEL} 233 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old 234.endif 235 PATH=$${PATH}:/sbin:/usr/sbin; \ 236 if [ `sysctl -n kern.bootfile` = ${DESTDIR}/${KERNEL} ] ; then \ 237 sysctl -w kern.bootfile=${DESTDIR}/${KERNEL}.old ; \ 238 if [ -f /var/db/kvm_${KERNEL}.db ] ; then \ 239 mv -f /var/db/kvm_${KERNEL}.db /var/db/kvm_${KERNEL}.old.db ; \ 240 fi \ 241 fi 242 install -c -m 555 -o root -g wheel -fschg \ 243 ${KERNEL}${.TARGET:S/install//} ${DESTDIR}/${KERNEL} 244 245reinstall reinstall.debug: 246 install -c -m 555 -o root -g wheel -fschg \ 247 ${KERNEL}${.TARGET:S/reinstall//} ${DESTDIR}/${KERNEL} 248 249config.o: 250 ${NORMAL_C} 251 252ioconf.o: 253 ${NORMAL_C} 254 255param.c: $S/conf/param.c 256 -rm -f param.c 257 cp $S/conf/param.c . 258 259param.o: 260 ${NORMAL_C} 261 262vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 263 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 264 265# XXX strictly, everything depends on Makefile because changes to ${PROF} 266# only appear there, but we don't handle that. 267vers.o: 268 ${NORMAL_C} 269 270.ORDER: vnode_if.c vnode_if.h 271vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src 272 sh $S/kern/vnode_if.sh $S/kern/vnode_if.src 273 274vnode_if.o: 275 ${NORMAL_C} 276 277.if exists($S/../share/mk) 278.include "$S/../share/mk/bsd.kern.mk" 279.else 280.include <bsd.kern.mk> 281.endif 282 283%RULES 284 285# DO NOT DELETE THIS LINE -- make depend uses it 286