Makefile.pc98 revision 75082
1178173Simp# Makefile for FreeBSD(98) after: 2178173Simp# 3178173Simp# Makefile.i386 -- with config changes. 4178173Simp# Copyright 1990 W. Jolitz 5178173Simp# from: @(#)Makefile.i386 7.1 5/10/91 6178173Simp# $FreeBSD: head/sys/conf/Makefile.pc98 75082 2001-04-02 08:52:05Z imp $ 7178173Simp# 8178173Simp# Makefile for FreeBSD 9178173Simp# 10178173Simp# This makefile is constructed from a machine description: 11178173Simp# config machineid 12178173Simp# Most changes should be made in the machine description 13178173Simp# /sys/i386/conf/``machineid'' 14178173Simp# after which you should do 15178173Simp# config machineid 16178173Simp# Generic makefile changes should be made in 17178173Simp# /sys/i386/conf/Makefile.i386 18178173Simp# after which config should be rerun for all machines. 19178173Simp# 20178173Simp 21178173Simp# Which version of config(8) is required. 22178173Simp%VERSREQ= 500006 23178173Simp 24178173Simp# Can be overridden by makeoptions or /etc/make.conf 25178173SimpKERNEL_KO?= kernel 26178173SimpKERNEL?= kernel 27178173SimpKODIR?= /boot/${KERNEL} 28178173Simp#STD8X16FONT?= iso 29178173Simp 30178173Simp.if !defined(S) 31178173Simp.if exists(./@/.) 32178173SimpS= ./@ 33178173Simp.else 34178173SimpS= ../.. 35178173Simp.endif 36178173Simp.endif 37178173SimpM= ${MACHINE_ARCH} 38178173Simp 39178173SimpSIZE?= size 40178173SimpOBJCOPY?= objcopy 41178173Simp 42178173SimpCOPTFLAGS?=-O -pipe 43178173Simp.if !defined(NO_CPU_COPTFLAGS) 44178173SimpCOPTFLAGS+= ${_CPUCFLAGS} 45178173Simp.endif 46178173SimpINCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev 47178173Simp# This hack is to allow kernel compiles to succeed on machines w/out srcdist 48178173Simp.if exists($S/../include) 49178173SimpINCLUDES+= -I$S/../include 50178173Simp.else 51178173SimpINCLUDES+= -I/usr/include 52178173Simp.endif 53178173Simp 54178173Simp# This hack lets us use the Intel ACPICA code without spamming a new 55178173Simp# include path into 100+ source files. 56182901SgonzoINCLUDES+= -I$S/contrib/dev/acpica/Subsystem/Include 57178173Simp 58178173SimpCOPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h 59178173SimpCFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 60178173Simp 61178173Simp# XXX LOCORE means "don't declare C stuff" not "for locore.s". 62178173SimpASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 63178173Simp 64178173Simp# Select the correct set of tools. Can't set OBJFORMAT here because it 65178173Simp# doesn't get exported into the environment, and if it were exported 66178173Simp# then it might break building of utilities. 67178173SimpFMT= -elf 68178173SimpCFLAGS+= ${FMT} 69178173Simp 70178173SimpDEFINED_PROF= ${PROF} 71178173Simp.if defined(PROF) 72178173SimpCFLAGS+= -malign-functions=4 73178173Simp.if ${PROFLEVEL} >= 2 74178173SimpIDENT+= -DGPROF4 -DGUPROF 75178173SimpPROF+= -mprofiler-epilogue 76178173Simp.endif 77178173Simp.endif 78178173Simp 79178173Simp# Put configuration-specific C flags last (except for ${PROF}) so that they 80178173Simp# can override the others. 81178173SimpCFLAGS+= ${CONF_CFLAGS} 82178173Simp 83178173SimpNORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 84178173SimpNORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 85178173SimpNORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC} 86178173SimpPROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC} 87178173Simp 88202036SimpNORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \ 89178173Simp ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c 90202036Simp 91178173SimpGEN_CFILES= $S/$M/$M/genassym.c 92178173Simp# setdef0.c and setdef1.c are intentionally 93178173Simp# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 94178173Simp# is generated from all of ${OBJS}. We don't want to have to compile 95178173Simp# everything just to do a make depend. 96SYSTEM_CFILES= param.c vnode_if.c hints.c config.c 97SYSTEM_SFILES= $S/$M/$M/locore.s 98SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 99SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} param.o hints.o config.o \ 100 setdef1.o hack.So 101SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 102 -export-dynamic -dynamic-linker /red/herring \ 103 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 104SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 105 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 106SYSTEM_DEP+= $S/conf/ldscript.$M 107 108%BEFORE_DEPEND 109 110%OBJS 111 112%FILES.c 113 114%FILES.s 115 116%FILES.m 117 118%CLEAN 119 120.PHONY: all modules 121 122all: ${KERNEL_KO} 123 124depend: kernel-depend 125clean: kernel-clean 126cleandepend: kernel-cleandepend 127clobber: kernel-clobber 128tags: kernel-tags 129install: kernel-install 130install.debug: kernel-install.debug 131reinstall: kernel-reinstall 132reinstall.debug: kernel-reinstall.debug 133 134.if !defined(DEBUG) 135FULLKERNEL= ${KERNEL_KO} 136.else 137FULLKERNEL= ${KERNEL_KO}.debug 138${KERNEL_KO}: ${FULLKERNEL} 139 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO} 140.endif 141 142${FULLKERNEL}: ${SYSTEM_DEP} vers.o 143 @rm -f ${.TARGET} 144 @echo linking ${.TARGET} 145 ${SYSTEM_LD} 146 ${SYSTEM_LD_TAIL} 147 148.if !exists(.depend) 149${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 150.endif 151 152.for mfile in ${MFILES} 153${mfile:T:S/.m$/.h/}: ${mfile} 154 perl5 $S/kern/makeobjops.pl -h ${mfile} 155.endfor 156 157kernel-clean: 158 rm -f *.o *.so *.So *.ko *.s eddep errs \ 159 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \ 160 setdef[01].c setdefs.h tags \ 161 vers.c vnode_if.c vnode_if.h \ 162 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 163 ${CLEAN} 164 165kernel-clobber: 166 find . -type f ! -name version -delete 167 168#lint: /tmp param.c 169# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 170# $S/$M/$M/Locore.c ${CFILES} param.c | \ 171# grep -v 'struct/union .* never defined' | \ 172# grep -v 'possible pointer alignment problem' 173 174locore.o: $S/$M/$M/locore.s assym.s 175 ${NORMAL_S} 176 177# This is a hack. BFD "optimizes" away dynamic mode if there are no 178# dynamic references. We could probably do a '-Bforcedynamic' mode like 179# in the a.out ld. For now, this works. 180hack.So: Makefile 181 touch hack.c 182 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So 183 rm -f hack.c 184 185.ORDER: setdefs.h setdef0.c setdef1.c 186 187setdef0.o: setdef0.c setdefs.h 188 ${NORMAL_C} 189 190setdef1.o: setdef1.c setdefs.h 191 ${NORMAL_C} 192 193setdef0.c setdef1.c setdefs.h: Makefile ${OBJS} 194 @perl5 $S/kern/gensetdefs.pl ${OBJS} 195 196# this rule stops ./assym.s in .depend from causing problems 197./assym.s: assym.s 198 199assym.s: $S/kern/genassym.sh genassym.o 200 OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET} 201 202genassym.o: $S/$M/$M/genassym.c 203 rm -f ./machine ; ln -s $S/$M/include ./machine 204 ${CC} -c ${CFLAGS} -elf $S/$M/$M/genassym.c 205 206${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 207 208kernel-depend: 209 rm -f .olddep 210 if [ -f .depend ]; then mv .depend .olddep; fi 211 ${MAKE} _kernel-depend 212 213_kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 214 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 215 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 216 if [ -f .olddep ]; then mv .olddep .depend; fi 217 rm -f .newdep 218 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 219 env MKDEP_CPP="${CC} -E" \ 220 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 221 rm -f .depend 222 mv .newdep .depend 223 224kernel-cleandepend: 225 rm -f .depend 226 227links: 228 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 229 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 230 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 231 sort -u | comm -23 - dontlink | \ 232 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 233 sh makelinks; rm -f dontlink 234 235kernel-tags: 236 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 237 sh $S/conf/systags.sh 238 rm -f tags1 239 sed -e 's, ../, ,' tags > tags1 240 241kernel-install kernel-install.debug: 242.if exists(${DESTDIR}/boot) 243 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 244 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 245 exit 1 ; \ 246 fi 247 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 248 echo "You must activate /boot/device.hints in loader.conf." ; \ 249 exit 1 ; \ 250 fi 251.endif 252 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 253 echo "You must build a kernel first." ; \ 254 exit 1 ; \ 255 fi 256.if exists(${DESTDIR}${KODIR}) 257.if exists(${DESTDIR}${KODIR}.old) 258 @-chflags -R noschg ${DESTDIR}${KODIR}.old 259 -rm -rf ${DESTDIR}${KODIR}.old 260.endif 261 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old 262.endif 263 mkdir -p ${DESTDIR}${KODIR} 264 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 265 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 266 fi 267 install -c -m 555 -o root -g wheel -fschg \ 268 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR} 269 270kernel-reinstall kernel-reinstall.debug: 271 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 272 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \ 273 fi 274 install -c -m 555 -o root -g wheel -fschg \ 275 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR} 276 277.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 278all: modules 279depend: modules-depend 280clean: modules-clean 281cleandepend: modules-cleandepend 282cleandir: modules-cleandir 283clobber: modules-clobber 284tags: modules-tags 285install: modules-install 286install.debug: modules-install.debug 287reinstall: modules-reinstall 288reinstall.debug: modules-reinstall.debug 289.endif 290 291MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 292.if defined(MODULES_OVERRIDE) 293MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 294.endif 295MKMODULESENV+= MACHINE=pc98 296 297modules: 298 @mkdir -p ${.OBJDIR}/modules 299 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 300 env ${MKMODULESENV} ${MAKE} all 301 302modules-depend: 303 @mkdir -p ${.OBJDIR}/modules 304 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 305 env ${MKMODULESENV} ${MAKE} depend 306 307modules-clean: 308 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean 309 310modules-cleandepend: 311 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend 312 313modules-clobber: modules-clean 314 rm -rf ${MKMODULESENV} 315 316modules-cleandir: 317 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir 318 319modules-tags: 320 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags 321 322modules-install modules-install.debug: 323 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 324 325modules-reinstall modules-reinstall.debug: 326 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 327 328config.o: 329 ${NORMAL_C} 330 331param.c: $S/conf/param.c 332 -rm -f param.c 333 cp $S/conf/param.c . 334 335param.o: 336 ${NORMAL_C} 337 338vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 339 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 340 341# XXX strictly, everything depends on Makefile because changes to ${PROF} 342# only appear there, but we don't handle that. 343vers.o: 344 ${NORMAL_C} 345 346hints.o: hints.c 347 ${NORMAL_C} 348 349vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 350 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 351 352vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 353 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 354 355vnode_if.o: 356 ${NORMAL_C} 357 358# Commented out for now pending a better solution. 359# How do we pick up compiler version specific flags?? 360#.if exists($S/../share/mk) 361#.include "$S/../share/mk/bsd.kern.mk" 362#.else 363.include <bsd.kern.mk> 364#.endif 365 366%RULES 367 368# DO NOT DELETE THIS LINE -- make depend uses it 369