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.133 1999/01/07 06:52:41 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= 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 -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?= F0100000 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 ${I386}/i386/gensetdefs.c 78# ${I386}/i386/setdef0.c and ${I386}/i386/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}: ${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 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 157setdef0.o: ${I386}/i386/setdef0.c setdefs.h 158 ${NORMAL_C} 159 160setdef1.o: ${I386}/i386/setdef1.c setdefs.h 161 ${NORMAL_C} 162 163setdefs.h: gensetdefs ${OBJS} 164 ./gensetdefs ${OBJS} >setdefs.h 165 166gensetdefs: gensetdefs.o 167 ${CC} ${GEN_CFLAGS} gensetdefs.o -o ${.TARGET} 168 169gensetdefs.o: ${I386}/i386/gensetdefs.c 170 ${CC} -c ${GEN_CFLAGS} ${I386}/i386/gensetdefs.c 171 172# this rule stops ./assym.s in .depend from causing problems 173./assym.s: assym.s 174 175assym.s: genassym 176 ./genassym >assym.s 177 178genassym.o: ${I386}/i386/genassym.c 179 ${CC} -c ${GEN_CFLAGS} ${I386}/i386/genassym.c 180 181genassym: genassym.o 182 ${CC} ${GEN_CFLAGS} genassym.o -o ${.TARGET} 183 184${SYSTEM_OBJS} genassym.o gensetdefs.o vers.o: opt_global.h 185 186# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical. 187depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} 188 rm -f .newdep 189 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} 190 mkdep -a -f .newdep ${GEN_CFLAGS} ${GEN_CFILES} 191 env MKDEP_CPP="${CC} -E" \ 192 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 193 rm -f .depend 194 mv -f .newdep .depend 195 196cleandepend: 197 rm -f .depend 198 199links: 200 egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \ 201 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 202 echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 203 sort -u | comm -23 - dontlink | \ 204 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 205 sh makelinks && rm -f dontlink 206 207tags: 208 @echo "see $S/kern/Makefile for tags" 209 210install: 211 @if [ ! -f kernel ] ; then \ 212 echo "You must first build your kernel before trying to install." ; \ 213 exit 1 ; \ 214 fi 215.if ${KERNFORMAT} == "elf" && !defined(FORCE) 216 @if [ -f /kernel -a "`file /kernel 2>/dev/null | grep ELF`" = "" ]; then \ 217 echo "WARNING: You are about to install an ELF kernel for the first time!" ; \ 218 echo "Please be sure you have upgraded your bootblocks and/or /boot/loader so" ; \ 219 echo "that you can boot it. Old bootblocks WILL NOT WORK! Please read:" ; \ 220 echo "http://www.freebsd.org/~peter/elfday.html for information." ; \ 221 echo "If you are satisfied you can boot an ELF kernel, type: make -DFORCE install" ; \ 222 exit 1 ; \ 223 fi 224.endif 225.if exists(${DESTDIR}/kernel) 226 chflags noschg ${DESTDIR}/kernel 227 mv ${DESTDIR}/kernel ${DESTDIR}/kernel.old 228.endif 229 PATH=$${PATH}:/sbin:/usr/sbin; \ 230 if [ `sysctl -n kern.bootfile` = ${DESTDIR}/kernel ] ; then \ 231 sysctl -w kern.bootfile=${DESTDIR}/kernel.old ; \ 232 if [ -f /var/db/kvm_kernel.db ] ; then \ 233 mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \ 234 fi \ 235 fi 236 install -c -m 555 -o root -g wheel -fschg kernel ${DESTDIR}/ 237 238config.o: 239 ${NORMAL_C} 240 241ioconf.o: 242 ${NORMAL_C} 243 244param.c: $S/conf/param.c 245 -rm -f param.c 246 cp $S/conf/param.c . 247 248param.o: 249 ${NORMAL_C} 250 251vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 252 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 253 254# XXX strictly, everything depends on Makefile because changes to ${PROF} 255# only appear there, but we don't handle that. 256vers.o: 257 ${NORMAL_C} 258 259.ORDER: vnode_if.c vnode_if.h 260vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src 261 sh $S/kern/vnode_if.sh $S/kern/vnode_if.src 262 263vnode_if.o: 264 ${NORMAL_C} 265 266.if exists($S/../share/mk) 267.include "$S/../share/mk/bsd.kern.mk" 268.else 269.include <bsd.kern.mk> 270.endif 271 272%RULES 273 274# DO NOT DELETE THIS LINE -- make depend uses it 275