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= 400018 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 36 37COPTFLAGS?=-O 38INCLUDES= -nostdinc -I- -I. -I$S 39# This hack is to allow kernel compiles to succeed on machines w/out srcdist 40.if exists($S/../include) 41INCLUDES+= -I$S/../include 42.else 43INCLUDES+= -I/usr/include 44.endif 45COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h 46CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 47 48# XXX LOCORE means "don't declare C stuff" not "for locore.s". 49ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 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 utilities. 54FMT= -elf 55CFLAGS+= ${FMT} 56 57LOAD_ADDRESS?= C0100000 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 76GEN_CFILES= $S/$M/$M/genassym.c 77# setdef0.c and setdef1.c are intentionally 78# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 79# is generated from all of ${OBJS}. We don't want to have to compile 80# everything just to do a make depend. 81SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c 82SYSTEM_SFILES= $S/$M/$M/locore.s 83SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 84SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \ 85 setdef1.o hack.So 86SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 87 -export-dynamic -dynamic-linker /red/herring \ 88 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 89SYSTEM_LD_TAIL= @${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 90SYSTEM_DEP+= $S/conf/ldscript.$M 91 92%BEFORE_DEPEND 93 94%OBJS 95 96%CFILES 97 98%SFILES 99 100%MFILES 101 102%CLEAN 103 104all: ${KERNEL} 105 106.if !defined(DEBUG) 107FULLKERNEL= ${KERNEL} 108.else 109FULLKERNEL= ${KERNEL}.debug 110${KERNEL}: ${FULLKERNEL} 111 objcopy --strip-debug ${FULLKERNEL} ${KERNEL} 112.endif 113 114${FULLKERNEL}: ${SYSTEM_DEP} vers.o 115 @rm -f ${.TARGET} 116 @echo linking ${.TARGET} 117 ${SYSTEM_LD} 118 ${SYSTEM_LD_TAIL} 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 \ 126 ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \ 127 setdef[01].c setdefs.h tags \ 128 vers.c vnode_if.c vnode_if.h ${CLEAN} 129 130#lint: /tmp param.c 131# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 132# $S/$M/$M/Locore.c ${CFILES} ioconf.c param.c | \ 133# grep -v 'struct/union .* never defined' | \ 134# grep -v 'possible pointer alignment problem' 135 136locore.o: $S/$M/$M/locore.s assym.s 137 ${NORMAL_S} 138 139# This is a hack. BFD "optimizes" away dynamic mode if there are no 140# dynamic references. We could probably do a '-Bforcedynamic' mode like 141# in the a.out ld. For now, this works. 142hack.So: Makefile 143 touch hack.c 144 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So 145 rm -f hack.c 146 147.ORDER: setdefs.h setdef0.c setdef1.c 148 149setdef0.o: setdef0.c setdefs.h 150 ${NORMAL_C} 151 152setdef1.o: setdef1.c setdefs.h 153 ${NORMAL_C} 154 155setdef0.c setdef1.c setdefs.h: ${OBJS} 156 @gensetdefs ${OBJS} 157 158# this rule stops ./assym.s in .depend from causing problems 159./assym.s: assym.s 160 161assym.s: genassym.o 162 genassym genassym.o >assym.s 163 164genassym.o: $S/$M/$M/genassym.c 165 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c 166 167${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 168 169depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 170 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} ${SYSTEM_SFILES} 171 rm -f .newdep 172 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 173 env MKDEP_CPP="${CC} -E" \ 174 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 175 rm -f .depend 176 mv -f .newdep .depend 177 178cleandepend: 179 rm -f .depend 180 181links: 182 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 183 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 184 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 185 sort -u | comm -23 - dontlink | \ 186 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 187 sh makelinks && rm -f dontlink 188 189tags: 190 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 191 sh $S/conf/systags.sh 192 rm -f tags1 193 sed -e 's, ../, ,' tags > tags1 194 195install install.debug: 196 @if [ ! -f ${KERNEL}${.TARGET:S/install//} ] ; then \ 197 echo "You must build a kernel first." ; \ 198 exit 1 ; \ 199 fi 200.if exists(${DESTDIR}/${KERNEL}) 201 -chflags noschg ${DESTDIR}/${KERNEL} 202 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old 203.endif 204 install -c -m 555 -o root -g wheel -fschg \ 205 ${KERNEL}${.TARGET:S/install//} ${DESTDIR}/${KERNEL} 206 207reinstall reinstall.debug: 208 install -c -m 555 -o root -g wheel -fschg \ 209 ${KERNEL}${.TARGET:S/reinstall//} ${DESTDIR}/${KERNEL} 210 211config.o: 212 ${NORMAL_C} 213 214ioconf.o: 215 ${NORMAL_C} 216 217param.c: $S/conf/param.c 218 -rm -f param.c 219 cp $S/conf/param.c . 220 221param.o: 222 ${NORMAL_C} 223 224vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 225 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 226 227# XXX strictly, everything depends on Makefile because changes to ${PROF} 228# only appear there, but we don't handle that. 229vers.o: 230 ${NORMAL_C} 231 232vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 233 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 234 235vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 236 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 237 238vnode_if.o: 239 ${NORMAL_C} 240 241# Commented out for now pending a better solution. 242# How do we pick up compiler version specific flags?? 243#.if exists($S/../share/mk) 244#.include "$S/../share/mk/bsd.kern.mk" 245#.else 246.include <bsd.kern.mk> 247#.endif 248 249%RULES 250 251# DO NOT DELETE THIS LINE -- make depend uses it 252