Makefile.pc98 revision 65561
1# Makefile for FreeBSD(98) after: 2# 3# Makefile.i386 -- with config changes. 4# Copyright 1990 W. Jolitz 5# from: @(#)Makefile.i386 7.1 5/10/91 6# $FreeBSD: head/sys/conf/Makefile.pc98 65561 2000-09-07 05:50:07Z obrien $ 7# 8# Makefile for FreeBSD 9# 10# This makefile is constructed from a machine description: 11# config machineid 12# Most changes should be made in the machine description 13# /sys/i386/conf/``machineid'' 14# after which you should do 15# config machineid 16# Generic makefile changes should be made in 17# /sys/i386/conf/Makefile.i386 18# after which config should be rerun for all machines. 19# 20 21# Which version of config(8) is required. 22%VERSREQ= 500003 23 24# Can be overridden by makeoptions or /etc/make.conf 25KERNEL_KO?= kernel.ko 26KERNEL?= kernel 27KODIR?= /boot/${KERNEL} 28#STD8X16FONT?= iso 29 30.if !defined(S) 31.if exists(./@/.) 32S= ./@ 33.else 34S= ../.. 35.endif 36.endif 37M= ${MACHINE_ARCH} 38 39SIZE?= size 40OBJCOPY?= objcopy 41 42COPTFLAGS?=-O 43INCLUDES= -nostdinc -I- -I. -I$S 44# This hack is to allow kernel compiles to succeed on machines w/out srcdist 45.if exists($S/../include) 46INCLUDES+= -I$S/../include 47.else 48INCLUDES+= -I/usr/include 49.endif 50COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h 51CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 52 53# XXX LOCORE means "don't declare C stuff" not "for locore.s". 54ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 55 56# Select the correct set of tools. Can't set OBJFORMAT here because it 57# doesn't get exported into the environment, and if it were exported 58# then it might break building of utilities. 59FMT= -elf 60CFLAGS+= ${FMT} 61 62DEFINED_PROF= ${PROF} 63.if defined(PROF) 64CFLAGS+= -malign-functions=4 65.if ${PROFLEVEL} >= 2 66IDENT+= -DGPROF4 -DGUPROF 67PROF+= -mprofiler-epilogue 68.endif 69.endif 70 71# Put configuration-specific C flags last (except for ${PROF}) so that they 72# can override the others. 73CFLAGS+= ${CONF_CFLAGS} 74 75NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 76NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 77NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC} 78PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC} 79 80NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \ 81 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c 82 83GEN_CFILES= $S/$M/$M/genassym.c 84# setdef0.c and setdef1.c are intentionally 85# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 86# is generated from all of ${OBJS}. We don't want to have to compile 87# everything just to do a make depend. 88SYSTEM_CFILES= param.c vnode_if.c hints.c config.c 89SYSTEM_SFILES= $S/$M/$M/locore.s 90SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 91SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} param.o hints.o config.o \ 92 setdef1.o hack.So 93SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 94 -export-dynamic -dynamic-linker /red/herring \ 95 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 96SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 97 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 98SYSTEM_DEP+= $S/conf/ldscript.$M 99 100%BEFORE_DEPEND 101 102%OBJS 103 104%CFILES 105 106%SFILES 107 108%MFILES 109 110%CLEAN 111 112.PHONY: all modules 113 114all: ${KERNEL_KO} 115 116depend: kernel-depend 117clean: kernel-clean 118cleandepend: kernel-cleandepend 119tags: kernel-tags 120install install.debug: kernel-install 121reinstall reinstall.debug: kernel-reinstall 122 123.if !defined(DEBUG) 124FULLKERNEL= ${KERNEL_KO} 125.else 126FULLKERNEL= ${KERNEL_KO}.debug 127${KERNEL_KO}: ${FULLKERNEL} 128 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO} 129.endif 130 131${FULLKERNEL}: ${SYSTEM_DEP} vers.o 132 @rm -f ${.TARGET} 133 @echo linking ${.TARGET} 134 ${SYSTEM_LD} 135 ${SYSTEM_LD_TAIL} 136 137.if !exists(.depend) 138${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 139.endif 140 141.for mfile in ${MFILES} 142${mfile:T:S/.m$/.h/}: ${mfile} 143 perl5 $S/kern/makeobjops.pl -h ${mfile} 144.endfor 145 146kernel-clean: 147 rm -f *.o *.so *.So *.ko *.s eddep errs \ 148 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \ 149 setdef[01].c setdefs.h tags \ 150 vers.c vnode_if.c vnode_if.h \ 151 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 152 ${CLEAN} 153 154#lint: /tmp param.c 155# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 156# $S/$M/$M/Locore.c ${CFILES} param.c | \ 157# grep -v 'struct/union .* never defined' | \ 158# grep -v 'possible pointer alignment problem' 159 160locore.o: $S/$M/$M/locore.s assym.s 161 ${NORMAL_S} 162 163# This is a hack. BFD "optimizes" away dynamic mode if there are no 164# dynamic references. We could probably do a '-Bforcedynamic' mode like 165# in the a.out ld. For now, this works. 166hack.So: Makefile 167 touch hack.c 168 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So 169 rm -f hack.c 170 171.ORDER: setdefs.h setdef0.c setdef1.c 172 173setdef0.o: setdef0.c setdefs.h 174 ${NORMAL_C} 175 176setdef1.o: setdef1.c setdefs.h 177 ${NORMAL_C} 178 179setdef0.c setdef1.c setdefs.h: Makefile ${OBJS} 180 @gensetdefs ${OBJS} 181 182# this rule stops ./assym.s in .depend from causing problems 183./assym.s: assym.s 184 185assym.s: $S/kern/genassym.sh genassym.o 186 sh $S/kern/genassym.sh genassym.o > ${.TARGET} 187 188genassym.o: $S/$M/$M/genassym.c 189 rm -f ./machine ; ln -s $S/$M/include ./machine 190 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c 191 192${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 193 194kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 195 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 196 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 197 rm -f .newdep 198 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 199 env MKDEP_CPP="${CC} -E" \ 200 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 201 rm -f .depend 202 mv -f .newdep .depend 203 204kernel-cleandepend: 205 rm -f .depend 206 207links: 208 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 209 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 210 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 211 sort -u | comm -23 - dontlink | \ 212 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 213 sh makelinks && rm -f dontlink 214 215kernel-tags: 216 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 217 sh $S/conf/systags.sh 218 rm -f tags1 219 sed -e 's, ../, ,' tags > tags1 220 221kernel-install kernel-install.debug: 222.if exists(${DESTDIR}/boot) 223 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 224 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 225 exit 1 ; \ 226 fi 227 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 228 echo "You must activate /boot/device.hints in loader.conf." ; \ 229 exit 1 ; \ 230 fi 231.endif 232 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 233 echo "You must build a kernel first." ; \ 234 exit 1 ; \ 235 fi 236.if exists(${DESTDIR}${KODIR}) 237.if exists(${DESTDIR}${KODIR}.old) 238 @-chflags -R noschg ${DESTDIR}${KODIR}.old 239 -rm -rf ${DESTDIR}${KODIR}.old 240.endif 241 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old 242.endif 243 mkdir -p ${DESTDIR}${KODIR} 244 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 245 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 246 fi 247 install -c -m 555 -o root -g wheel -fschg \ 248 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR} 249 250kernel-reinstall kernel-reinstall.debug: 251 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 252 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 253 fi 254 install -c -m 555 -o root -g wheel -fschg \ 255 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL} 256 257.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 258all: modules 259depend: modules-depend 260clean: modules-clean 261cleandepend: modules-cleandepend 262cleandir: modules-cleandir 263tags: modules-tags 264install install.debug: modules-install 265reinstall reinstall.debug: modules-reinstall 266.endif 267 268MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${DESTDIR}${KODIR} 269 270modules: 271 @mkdir -p ${.OBJDIR}/modules 272 cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all 273 274modules-depend: 275 @mkdir -p ${.OBJDIR}/modules 276 cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend 277 278modules-clean: 279 cd $S/modules && env ${MKMODULESENV} ${MAKE} clean 280 281modules-cleandepend: 282 cd $S/modules && env ${MKMODULESENV} ${MAKE} cleandepend 283 284modules-cleandir: 285 cd $S/modules && env ${MKMODULESENV} ${MAKE} cleandir 286 287modules-tags: 288 cd $S/modules && env ${MKMODULESENV} ${MAKE} tags 289 290modules-install modules-install.debug: 291 cd $S/modules && env ${MKMODULESENV} ${MAKE} install 292 293modules-reinstall modules-reinstall.debug: 294 cd $S/modules && env ${MKMODULESENV} ${MAKE} install 295 296config.o: 297 ${NORMAL_C} 298 299param.c: $S/conf/param.c 300 -rm -f param.c 301 cp $S/conf/param.c . 302 303param.o: 304 ${NORMAL_C} 305 306vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 307 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 308 309# XXX strictly, everything depends on Makefile because changes to ${PROF} 310# only appear there, but we don't handle that. 311vers.o: 312 ${NORMAL_C} 313 314hints.o: hints.c 315 ${NORMAL_C} 316 317vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 318 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 319 320vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 321 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 322 323vnode_if.o: 324 ${NORMAL_C} 325 326# Commented out for now pending a better solution. 327# How do we pick up compiler version specific flags?? 328#.if exists($S/../share/mk) 329#.include "$S/../share/mk/bsd.kern.mk" 330#.else 331.include <bsd.kern.mk> 332#.endif 333 334%RULES 335 336# DO NOT DELETE THIS LINE -- make depend uses it 337