Makefile.pc98 revision 73018
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 73018 2001-02-25 07:51:19Z 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= 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 @perl5 $S/kern/gensetdefs.pl ${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 OBJFORMAT=elf 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} -elf $S/$M/$M/genassym.c 198 199${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 200 201kernel-depend: 202 rm -f .depend 203 ${MAKE} _kernel-depend 204 205_kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 206 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 207 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 208 rm -f .newdep 209 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 210 env MKDEP_CPP="${CC} -E" \ 211 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 212 rm -f .depend 213 mv -f .newdep .depend 214 215kernel-cleandepend: 216 rm -f .depend 217 218links: 219 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 220 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 221 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 222 sort -u | comm -23 - dontlink | \ 223 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 224 sh makelinks; rm -f dontlink 225 226kernel-tags: 227 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 228 sh $S/conf/systags.sh 229 rm -f tags1 230 sed -e 's, ../, ,' tags > tags1 231 232kernel-install kernel-install.debug: 233.if exists(${DESTDIR}/boot) 234 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 235 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 236 exit 1 ; \ 237 fi 238 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 239 echo "You must activate /boot/device.hints in loader.conf." ; \ 240 exit 1 ; \ 241 fi 242.endif 243 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 244 echo "You must build a kernel first." ; \ 245 exit 1 ; \ 246 fi 247.if exists(${DESTDIR}${KODIR}) 248.if exists(${DESTDIR}${KODIR}.old) 249 @-chflags -R noschg ${DESTDIR}${KODIR}.old 250 -rm -rf ${DESTDIR}${KODIR}.old 251.endif 252 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old 253.endif 254 mkdir -p ${DESTDIR}${KODIR} 255 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 256 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 257 fi 258 install -c -m 555 -o root -g wheel -fschg \ 259 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR} 260 261kernel-reinstall kernel-reinstall.debug: 262 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 263 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 264 fi 265 install -c -m 555 -o root -g wheel -fschg \ 266 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR} 267 268.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 269all: modules 270depend: modules-depend 271clean: modules-clean 272cleandepend: modules-cleandepend 273cleandir: modules-cleandir 274tags: modules-tags 275install: modules-install 276install.debug: modules-install.debug 277reinstall: modules-reinstall 278reinstall.debug: modules-reinstall.debug 279.endif 280 281MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 282MKMODULESENV+= MACHINE=pc98 283 284modules: 285 @mkdir -p ${.OBJDIR}/modules 286 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 287 env ${MKMODULESENV} ${MAKE} all 288 289modules-depend: 290 @mkdir -p ${.OBJDIR}/modules 291 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 292 env ${MKMODULESENV} ${MAKE} depend 293 294modules-clean: 295 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean 296 297modules-cleandepend: 298 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend 299 300modules-cleandir: 301 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir 302 303modules-tags: 304 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags 305 306modules-install modules-install.debug: 307 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 308 309modules-reinstall modules-reinstall.debug: 310 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 311 312config.o: 313 ${NORMAL_C} 314 315param.c: $S/conf/param.c 316 -rm -f param.c 317 cp $S/conf/param.c . 318 319param.o: 320 ${NORMAL_C} 321 322vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 323 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 324 325# XXX strictly, everything depends on Makefile because changes to ${PROF} 326# only appear there, but we don't handle that. 327vers.o: 328 ${NORMAL_C} 329 330hints.o: hints.c 331 ${NORMAL_C} 332 333vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 334 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 335 336vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 337 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 338 339vnode_if.o: 340 ${NORMAL_C} 341 342# Commented out for now pending a better solution. 343# How do we pick up compiler version specific flags?? 344#.if exists($S/../share/mk) 345#.include "$S/../share/mk/bsd.kern.mk" 346#.else 347.include <bsd.kern.mk> 348#.endif 349 350%RULES 351 352# DO NOT DELETE THIS LINE -- make depend uses it 353