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