Makefile.pc98 revision 70332
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 70332 2000-12-24 13:29:58Z 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= 500005 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 install.debug: kernel-install 126reinstall reinstall.debug: kernel-reinstall 127 128.if !defined(DEBUG) 129FULLKERNEL= ${KERNEL_KO} 130.else 131FULLKERNEL= ${KERNEL_KO}.debug 132${KERNEL_KO}: ${FULLKERNEL} 133 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO} 134.endif 135 136${FULLKERNEL}: ${SYSTEM_DEP} vers.o 137 @rm -f ${.TARGET} 138 @echo linking ${.TARGET} 139 ${SYSTEM_LD} 140 ${SYSTEM_LD_TAIL} 141 142.if !exists(.depend) 143${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 144.endif 145 146.for mfile in ${MFILES} 147${mfile:T:S/.m$/.h/}: ${mfile} 148 perl5 $S/kern/makeobjops.pl -h ${mfile} 149.endfor 150 151kernel-clean: 152 rm -f *.o *.so *.So *.ko *.s eddep errs \ 153 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \ 154 setdef[01].c setdefs.h tags \ 155 vers.c vnode_if.c vnode_if.h \ 156 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 157 ${CLEAN} 158 159#lint: /tmp param.c 160# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 161# $S/$M/$M/Locore.c ${CFILES} param.c | \ 162# grep -v 'struct/union .* never defined' | \ 163# grep -v 'possible pointer alignment problem' 164 165locore.o: $S/$M/$M/locore.s assym.s 166 ${NORMAL_S} 167 168# This is a hack. BFD "optimizes" away dynamic mode if there are no 169# dynamic references. We could probably do a '-Bforcedynamic' mode like 170# in the a.out ld. For now, this works. 171hack.So: Makefile 172 touch hack.c 173 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So 174 rm -f hack.c 175 176.ORDER: setdefs.h setdef0.c setdef1.c 177 178setdef0.o: setdef0.c setdefs.h 179 ${NORMAL_C} 180 181setdef1.o: setdef1.c setdefs.h 182 ${NORMAL_C} 183 184setdef0.c setdef1.c setdefs.h: Makefile ${OBJS} 185 @gensetdefs ${OBJS} 186 187# this rule stops ./assym.s in .depend from causing problems 188./assym.s: assym.s 189 190assym.s: $S/kern/genassym.sh genassym.o 191 sh $S/kern/genassym.sh genassym.o > ${.TARGET} 192 193genassym.o: $S/$M/$M/genassym.c 194 rm -f ./machine ; ln -s $S/$M/include ./machine 195 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c 196 197${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 198 199kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 200 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 201 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 202 rm -f .newdep 203 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 204 env MKDEP_CPP="${CC} -E" \ 205 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 206 rm -f .depend 207 mv -f .newdep .depend 208 209kernel-cleandepend: 210 rm -f .depend 211 212links: 213 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 214 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 215 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 216 sort -u | comm -23 - dontlink | \ 217 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 218 sh makelinks; rm -f dontlink 219 220kernel-tags: 221 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 222 sh $S/conf/systags.sh 223 rm -f tags1 224 sed -e 's, ../, ,' tags > tags1 225 226kernel-install kernel-install.debug: 227.if exists(${DESTDIR}/boot) 228 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 229 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 230 exit 1 ; \ 231 fi 232 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 233 echo "You must activate /boot/device.hints in loader.conf." ; \ 234 exit 1 ; \ 235 fi 236.endif 237 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 238 echo "You must build a kernel first." ; \ 239 exit 1 ; \ 240 fi 241.if exists(${DESTDIR}${KODIR}) 242.if exists(${DESTDIR}${KODIR}.old) 243 @-chflags -R noschg ${DESTDIR}${KODIR}.old 244 -rm -rf ${DESTDIR}${KODIR}.old 245.endif 246 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old 247.endif 248 mkdir -p ${DESTDIR}${KODIR} 249 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 250 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 251 fi 252 install -c -m 555 -o root -g wheel -fschg \ 253 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR} 254 255kernel-reinstall kernel-reinstall.debug: 256 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 257 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 258 fi 259 install -c -m 555 -o root -g wheel -fschg \ 260 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR} 261 262.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 263all: modules 264depend: modules-depend 265clean: modules-clean 266cleandepend: modules-cleandepend 267cleandir: modules-cleandir 268tags: modules-tags 269install install.debug: modules-install 270reinstall reinstall.debug: modules-reinstall 271.endif 272 273MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 274MKMODULESENV+= MACHINE=pc98 275 276modules: 277 @mkdir -p ${.OBJDIR}/modules 278 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 279 env ${MKMODULESENV} ${MAKE} all 280 281modules-depend: 282 @mkdir -p ${.OBJDIR}/modules 283 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 284 env ${MKMODULESENV} ${MAKE} depend 285 286modules-clean: 287 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean 288 289modules-cleandepend: 290 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend 291 292modules-cleandir: 293 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir 294 295modules-tags: 296 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags 297 298modules-install modules-install.debug: 299 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 300 301modules-reinstall modules-reinstall.debug: 302 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 303 304config.o: 305 ${NORMAL_C} 306 307param.c: $S/conf/param.c 308 -rm -f param.c 309 cp $S/conf/param.c . 310 311param.o: 312 ${NORMAL_C} 313 314vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 315 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 316 317# XXX strictly, everything depends on Makefile because changes to ${PROF} 318# only appear there, but we don't handle that. 319vers.o: 320 ${NORMAL_C} 321 322hints.o: hints.c 323 ${NORMAL_C} 324 325vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 326 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 327 328vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 329 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 330 331vnode_if.o: 332 ${NORMAL_C} 333 334# Commented out for now pending a better solution. 335# How do we pick up compiler version specific flags?? 336#.if exists($S/../share/mk) 337#.include "$S/../share/mk/bsd.kern.mk" 338#.else 339.include <bsd.kern.mk> 340#.endif 341 342%RULES 343 344# DO NOT DELETE THIS LINE -- make depend uses it 345