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.140 1999/03/01 09:54:51 dt 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= 300009 21 22KERNFORMAT?= elf 23 24STD8X16FONT?= iso 25 26.if exists(./@/.) 27S= ./@ 28.else 29S= ../.. 30.endif 31I386= ${S}/i386 32 33COPTFLAGS?=-O 34INCLUDES= -nostdinc -I- -I. -I$S 35# This hack is to allow kernel compiles to succeed on machines w/out srcdist 36.if exists($S/../include) 37INCLUDES+= -I$S/../include 38.else 39INCLUDES+= -I/usr/include 40.endif 41COPTS= ${INCLUDES} ${IDENT} -DKERNEL -DVM_STACK -include opt_global.h 42CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 43 44# XXX LOCORE means "don't declare C stuff" not "for locore.s". 45ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 46 47# Use the default object format for genassym, etc. 48GEN_CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 49 50# Select the correct set of tools. Can't set OBJFORMAT here because it 51# doesn't get exported into the environment, and if it were exported 52# then it might break building of genassym, etc. 53.if ${KERNFORMAT} == "elf" 54CFLAGS+= -elf 55.else 56CFLAGS+= -aout 57.endif 58 59LOAD_ADDRESS?= C0100000 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 69NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $< 70NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} $< 71NORMAL_S= ${CC} -c ${ASM_CFLAGS} $< 72DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $< 73DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} $< 74DRIVER_S= ${CC} -c -x ${ASM_CFLAGS} $< 75PROFILE_C= ${CC} -c ${CFLAGS} $< 76 77GEN_CFILES= ${I386}/i386/genassym.c 78# setdef0.c and setdef1.c are intentionally 79# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 80# is generated from all of ${OBJS}. We don't want to have to compile 81# everything just to do a make depend. 82SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c 83SYSTEM_SFILES= ${I386}/i386/locore.s 84SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} 85.if ${CFLAGS:M-g} == "" 86SYMORDER_EXCLUDE=-x symbols.exclude 87.endif 88SYSTEM_LD_HEAD= @echo loading ${.TARGET}; rm -f ${.TARGET} 89.if ${KERNFORMAT} == aout || ${KERNFORMAT} == aoutkld 90SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o 91SYSTEM_LD= @${LD} -aout -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 92SYSTEM_LD_TAIL= @echo rearranging symbols; \ 93 symorder -m ${SYMORDER_EXCLUDE} symbols.sort ${.TARGET}; \ 94 size -aout ${.TARGET} ; chmod 755 ${.TARGET} 95.endif 96.if ${KERNFORMAT} == elf 97SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \ 98 setdef1.o hack.So 99SYSTEM_LD= @${LD} -elf -Bdynamic -T $S/i386/conf/kernel.script \ 100 -export-dynamic -dynamic-linker /red/herring \ 101 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 102SYSTEM_LD_TAIL= @size -elf ${.TARGET} ; chmod 755 ${.TARGET} 103SYSTEM_DEP+= $S/i386/conf/kernel.script 104.endif 105 106%BEFORE_DEPEND 107 108%OBJS 109 110%CFILES 111 112%SFILES 113 114%MFILES 115 116%LOAD 117 118%CLEAN 119 120.if !exists(.depend) 121${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} 122.endif 123 124clean: 125 rm -f *.o *.so *.So *.ko *.s eddep errs genassym gensetdefs \ 126 kernel linterrs makelinks param.c setdef[01].c setdefs.h \ 127 symbols.exclude symbols.sort tags \ 128 vers.c vnode_if.c vnode_if.h ${CLEAN} 129 130#lint: /tmp param.c 131# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 132# ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \ 133# grep -v 'struct/union .* never defined' | \ 134# grep -v 'possible pointer alignment problem' 135 136symbols.exclude: 137 echo "gcc2_compiled." >symbols.exclude 138 echo "___gnu_compiled_c" >>symbols.exclude 139 140symbols.sort: ${I386}/i386/symbols.raw 141 grep -v '^#' ${I386}/i386/symbols.raw \ 142 | sed 's/^ //' | sort -u > symbols.sort 143 144locore.o: ${I386}/i386/locore.s assym.s 145 ${NORMAL_S} 146 147.if ${KERNFORMAT} == elf 148# This is a hack. BFD "optimizes" away dynamic mode if there are no 149# dynamic references. We could probably do a '-Bforcedynamic' mode like 150# in the a.out ld. For now, this works. 151hack.So: Makefile 152 touch hack.c 153 ${CC} -elf -shared -nostdlib hack.c -o hack.So 154 rm -f hack.c 155.endif 156 157.ORDER: setdefs.h setdef0.c setdef1.c 158 159setdef0.o: setdef0.c setdefs.h 160 ${NORMAL_C} 161 162setdef1.o: setdef1.c setdefs.h 163 ${NORMAL_C} 164 165setdef0.c setdef1.c setdefs.h: ${OBJS} 166 @echo generating linker set emulation glue for ELF 167 @gensetdefs ${OBJS} 168 169# this rule stops ./assym.s in .depend from causing problems 170./assym.s: assym.s 171 172assym.s: genassym 173 ./genassym >assym.s 174 175genassym.o: ${I386}/i386/genassym.c 176 ${CC} -c ${GEN_CFLAGS} ${I386}/i386/genassym.c 177 178genassym: genassym.o 179 ${CC} ${GEN_CFLAGS} genassym.o -o ${.TARGET} 180 181${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 182 183# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical. 184depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} 185 rm -f .newdep 186 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} 187 mkdep -a -f .newdep ${GEN_CFLAGS} ${GEN_CFILES} 188 env MKDEP_CPP="${CC} -E" \ 189 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 190 rm -f .depend 191 mv -f .newdep .depend 192 193cleandepend: 194 rm -f .depend 195 196links: 197 egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \ 198 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 199 echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 200 sort -u | comm -23 - dontlink | \ 201 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 202 sh makelinks && rm -f dontlink 203 204tags: 205 @echo "see $S/kern/Makefile for tags" 206 207install: 208 @if [ ! -f kernel ] ; then \ 209 echo "You must first build your kernel before trying to install." ; \ 210 exit 1 ; \ 211 fi 212.if ${KERNFORMAT} == "elf" && !defined(FORCE) 213 @if [ -f /kernel -a "`file /kernel 2>/dev/null | grep ELF`" = "" ]; then \ 214 echo "WARNING: You are about to install an ELF kernel for the first time!" ; \ 215 echo "Please be sure you have upgraded your bootblocks and/or /boot/loader so" ; \ 216 echo "that you can boot it. Old bootblocks WILL NOT WORK! Please read:" ; \ 217 echo "http://www.freebsd.org/~peter/elfday.html for information." ; \ 218 echo "If you are satisfied you can boot an ELF kernel, type: make -DFORCE install" ; \ 219 exit 1 ; \ 220 fi 221.endif 222.if exists(${DESTDIR}/kernel) 223 -chflags noschg ${DESTDIR}/kernel 224 mv ${DESTDIR}/kernel ${DESTDIR}/kernel.old 225.endif 226 PATH=$${PATH}:/sbin:/usr/sbin; \ 227 if [ `sysctl -n kern.bootfile` = ${DESTDIR}/kernel ] ; then \ 228 sysctl -w kern.bootfile=${DESTDIR}/kernel.old ; \ 229 if [ -f /var/db/kvm_kernel.db ] ; then \ 230 mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \ 231 fi \ 232 fi 233 install -c -m 555 -o root -g wheel -fschg kernel ${DESTDIR}/ 234 235config.o: 236 ${NORMAL_C} 237 238ioconf.o: 239 ${NORMAL_C} 240 241param.c: $S/conf/param.c 242 -rm -f param.c 243 cp $S/conf/param.c . 244 245param.o: 246 ${NORMAL_C} 247 248vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 249 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 250 251# XXX strictly, everything depends on Makefile because changes to ${PROF} 252# only appear there, but we don't handle that. 253vers.o: 254 ${NORMAL_C} 255 256.ORDER: vnode_if.c vnode_if.h 257vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src 258 sh $S/kern/vnode_if.sh $S/kern/vnode_if.src 259 260vnode_if.o: 261 ${NORMAL_C} 262 263.if exists($S/../share/mk) 264.include "$S/../share/mk/bsd.kern.mk" 265.else 266.include <bsd.kern.mk> 267.endif 268 269%RULES 270 271# DO NOT DELETE THIS LINE -- make depend uses it 272