Makefile.pc98 revision 65512
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 65512 2000-09-06 09:27:25Z 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 [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 223 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 224 exit 1 ; \ 225 fi 226 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 227 echo "You must activate /boot/device.hints in loader.conf." ; \ 228 exit 1 ; \ 229 fi 230 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 231 echo "You must build a kernel first." ; \ 232 exit 1 ; \ 233 fi 234.if exists(${DESTDIR}/${KODIR}) 235.if exists(${DESTDIR}/${KODIR}.old) 236 @-chflags -R noschg ${DESTDIR}/${KODIR}.old 237 -rm -rf ${DESTDIR}/${KODIR}.old 238.endif 239 mv ${DESTDIR}/${KODIR} ${DESTDIR}/${KODIR}.old 240.endif 241 mkdir -p ${DESTDIR}/${KODIR} 242 @if [ -f ${DESTDIR}/${KODIR}/${KERNEL_KO} ] ; then \ 243 chflags noschg ${DESTDIR}/${KODIR}/${KERNEL_KO} ; \ 244 fi 245 install -c -m 555 -o root -g wheel -fschg \ 246 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}/${KODIR} 247 248kernel-reinstall kernel-reinstall.debug: 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}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL} 254 255.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 256all: modules 257depend: modules-depend 258clean: modules-clean 259cleandepend: modules-cleandepend 260cleandir: modules-cleandir 261tags: modules-tags 262install install.debug: modules-install 263reinstall reinstall.debug: modules-reinstall 264.endif 265 266MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${DESTDIR}/${KODIR} 267 268modules: 269 @mkdir -p ${.OBJDIR}/modules 270 cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all 271 272modules-depend: 273 @mkdir -p ${.OBJDIR}/modules 274 cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend 275 276modules-clean: 277 cd $S/modules && env ${MKMODULESENV} ${MAKE} clean 278 279modules-cleandepend: 280 cd $S/modules && env ${MKMODULESENV} ${MAKE} cleandepend 281 282modules-cleandir: 283 cd $S/modules && env ${MKMODULESENV} ${MAKE} cleandir 284 285modules-tags: 286 cd $S/modules && env ${MKMODULESENV} ${MAKE} tags 287 288modules-install modules-install.debug: 289 cd $S/modules && env ${MKMODULESENV} ${MAKE} install 290 291modules-reinstall modules-reinstall.debug: 292 cd $S/modules && env ${MKMODULESENV} ${MAKE} install 293 294config.o: 295 ${NORMAL_C} 296 297param.c: $S/conf/param.c 298 -rm -f param.c 299 cp $S/conf/param.c . 300 301param.o: 302 ${NORMAL_C} 303 304vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 305 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 306 307# XXX strictly, everything depends on Makefile because changes to ${PROF} 308# only appear there, but we don't handle that. 309vers.o: 310 ${NORMAL_C} 311 312hints.o: hints.c 313 ${NORMAL_C} 314 315vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 316 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 317 318vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 319 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 320 321vnode_if.o: 322 ${NORMAL_C} 323 324# Commented out for now pending a better solution. 325# How do we pick up compiler version specific flags?? 326#.if exists($S/../share/mk) 327#.include "$S/../share/mk/bsd.kern.mk" 328#.else 329.include <bsd.kern.mk> 330#.endif 331 332%RULES 333 334# DO NOT DELETE THIS LINE -- make depend uses it 335