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