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.151 1999/05/09 18:57:02 peter 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} 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} $< 73DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $< 74DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} $< 75DRIVER_S= ${CC} -c -x ${ASM_CFLAGS} $< 76PROFILE_C= ${CC} -c ${CFLAGS} $< 77 78GEN_CFILES= ${I386}/i386/genassym.c 79# setdef0.c and setdef1.c are intentionally 80# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 81# is generated from all of ${OBJS}. We don't want to have to compile 82# everything just to do a make depend. 83SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c 84SYSTEM_SFILES= ${I386}/i386/locore.s 85SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} 86.if ${CFLAGS:M-g} == "" 87SYMORDER_EXCLUDE=-x symbols.exclude 88.endif 89 90.if ${KERNFORMAT} == aout || ${KERNFORMAT} == aoutkld 91SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o 92SYSTEM_LD= @${LD} -aout -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 93SYSTEM_LD_TAIL= @echo rearranging symbols; \ 94 symorder -m ${SYMORDER_EXCLUDE} symbols.sort ${.TARGET}; \ 95 size -aout ${.TARGET} ; chmod 755 ${.TARGET} 96.endif 97 98.if ${KERNFORMAT} == elf 99SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \ 100 setdef1.o hack.So 101SYSTEM_LD= @${LD} -elf -Bdynamic -T $S/i386/conf/kernel.script \ 102 -export-dynamic -dynamic-linker /red/herring \ 103 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 104SYSTEM_LD_TAIL= @size -elf ${.TARGET} ; chmod 755 ${.TARGET} 105SYSTEM_DEP+= $S/i386/conf/kernel.script 106.endif 107 108%BEFORE_DEPEND 109 110%OBJS 111 112%CFILES 113 114%SFILES 115 116%MFILES 117 118%CLEAN 119 120all: ${KERNEL} 121 122.if !defined(DEBUG) 123FULLKERNEL= ${KERNEL} 124.else 125FULLKERNEL= ${KERNEL}.debug 126${KERNEL}: ${FULLKERNEL} 127.if ${KERNFORMAT} == "elf" 128 objcopy --strip-debug ${FULLKERNEL} ${KERNEL} 129.else 130 cp ${FULLKERNEL} ${KERNEL} 131 strip -d ${KERNEL} 132.endif 133.endif 134 135${FULLKERNEL}: ${SYSTEM_DEP} vers.o 136 @rm -f ${.TARGET} 137 @echo linking ${.TARGET} 138 ${SYSTEM_LD} 139 ${SYSTEM_LD_TAIL} 140 141.if !exists(.depend) 142${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} 143.endif 144 145clean: 146 rm -f *.o *.so *.So *.ko *.s eddep errs genassym gensetdefs \ 147 ${KERNEL} ${FULLKERNEL} linterrs makelinks param.c \ 148 setdef[01].c setdefs.h symbols.exclude symbols.sort tags \ 149 vers.c vnode_if.c vnode_if.h ${CLEAN} 150 151#lint: /tmp param.c 152# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 153# ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \ 154# grep -v 'struct/union .* never defined' | \ 155# grep -v 'possible pointer alignment problem' 156 157symbols.exclude: 158 echo "gcc2_compiled." >symbols.exclude 159 echo "___gnu_compiled_c" >>symbols.exclude 160 161symbols.sort: ${I386}/i386/symbols.raw 162 grep -v '^#' ${I386}/i386/symbols.raw \ 163 | sed 's/^ //' | sort -u > symbols.sort 164 165locore.o: ${I386}/i386/locore.s assym.s 166 ${NORMAL_S} 167 168.if ${KERNFORMAT} == elf 169# This is a hack. BFD "optimizes" away dynamic mode if there are no 170# dynamic references. We could probably do a '-Bforcedynamic' mode like 171# in the a.out ld. For now, this works. 172hack.So: Makefile 173 touch hack.c 174 ${CC} -elf -shared -nostdlib hack.c -o hack.So 175 rm -f hack.c 176.endif 177 178.ORDER: setdefs.h setdef0.c setdef1.c 179 180setdef0.o: setdef0.c setdefs.h 181 ${NORMAL_C} 182 183setdef1.o: setdef1.c setdefs.h 184 ${NORMAL_C} 185 186setdef0.c setdef1.c setdefs.h: ${OBJS} 187 @gensetdefs ${OBJS} 188 189# this rule stops ./assym.s in .depend from causing problems 190./assym.s: assym.s 191 192assym.s: genassym 193 ./genassym >assym.s 194 195genassym.o: ${I386}/i386/genassym.c 196 ${CC} -c ${GEN_CFLAGS} ${I386}/i386/genassym.c 197 198genassym: genassym.o 199 ${CC} ${GEN_CFLAGS} genassym.o -o ${.TARGET} 200 201${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 202 203# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical. 204depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} 205 rm -f .newdep 206 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} 207 mkdep -a -f .newdep ${GEN_CFLAGS} ${GEN_CFILES} 208 env MKDEP_CPP="${CC} -E" \ 209 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 210 rm -f .depend 211 mv -f .newdep .depend 212 213cleandepend: 214 rm -f .depend 215 216links: 217 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 218 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 219 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 220 sort -u | comm -23 - dontlink | \ 221 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 222 sh makelinks && rm -f dontlink 223 224tags: 225 @echo "see $S/kern/Makefile for tags" 226 227install install.debug: 228 @if [ ! -f ${KERNEL}${.TARGET:S/install//} ] ; then \ 229 echo "You must first build a kernel first." ; \ 230 exit 1 ; \ 231 fi 232.if exists(${DESTDIR}/${KERNEL}) 233 -chflags noschg ${DESTDIR}/${KERNEL} 234 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old 235.endif 236 PATH=$${PATH}:/sbin:/usr/sbin; \ 237 if [ `sysctl -n kern.bootfile` = ${DESTDIR}/${KERNEL} ] ; then \ 238 sysctl -w kern.bootfile=${DESTDIR}/${KERNEL}.old ; \ 239 if [ -f /var/db/kvm_${KERNEL}.db ] ; then \ 240 mv -f /var/db/kvm_${KERNEL}.db /var/db/kvm_${KERNEL}.old.db ; \ 241 fi \ 242 fi 243 install -c -m 555 -o root -g wheel -fschg \ 244 ${KERNEL}${.TARGET:S/install//} ${DESTDIR}/${KERNEL} 245 246reinstall reinstall.debug: 247 install -c -m 555 -o root -g wheel -fschg \ 248 ${KERNEL}${.TARGET:S/reinstall//} ${DESTDIR}/${KERNEL} 249 250config.o: 251 ${NORMAL_C} 252 253ioconf.o: 254 ${NORMAL_C} 255 256param.c: $S/conf/param.c 257 -rm -f param.c 258 cp $S/conf/param.c . 259 260param.o: 261 ${NORMAL_C} 262 263vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 264 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 265 266# XXX strictly, everything depends on Makefile because changes to ${PROF} 267# only appear there, but we don't handle that. 268vers.o: 269 ${NORMAL_C} 270 271.ORDER: vnode_if.c vnode_if.h 272vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src 273 sh $S/kern/vnode_if.sh $S/kern/vnode_if.src 274 275vnode_if.o: 276 ${NORMAL_C} 277 278.if exists($S/../share/mk) 279.include "$S/../share/mk/bsd.kern.mk" 280.else 281.include <bsd.kern.mk> 282.endif 283 284%RULES 285 286# DO NOT DELETE THIS LINE -- make depend uses it 287