Makefile.pc98 revision 65091
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 65091 2000-08-25 19:30:03Z 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= 500003 23 24# Can be overridden by makeoptions or /etc/make.conf 25KERNEL?= kernel 26#STD8X16FONT?= iso 27 28.if !defined(S) 29.if exists(./@/.) 30S= ./@ 31.else 32S= ../.. 33.endif 34.endif 35M= ${MACHINE_ARCH} 36 37SIZE?= size 38OBJCOPY?= objcopy 39 40COPTFLAGS?=-O 41INCLUDES= -nostdinc -I- -I. -I$S 42# This hack is to allow kernel compiles to succeed on machines w/out srcdist 43.if exists($S/../include) 44INCLUDES+= -I$S/../include 45.else 46INCLUDES+= -I/usr/include 47.endif 48COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h 49CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 50 51# XXX LOCORE means "don't declare C stuff" not "for locore.s". 52ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 53 54# Select the correct set of tools. Can't set OBJFORMAT here because it 55# doesn't get exported into the environment, and if it were exported 56# then it might break building of utilities. 57FMT= -elf 58CFLAGS+= ${FMT} 59 60DEFINED_PROF= ${PROF} 61.if defined(PROF) 62CFLAGS+= -malign-functions=4 63.if ${PROFLEVEL} >= 2 64IDENT+= -DGPROF4 -DGUPROF 65PROF+= -mprofiler-epilogue 66.endif 67.endif 68 69# Put configuration-specific C flags last (except for ${PROF}) so that they 70# can override the others. 71CFLAGS+= ${CONF_CFLAGS} 72 73NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 74NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 75NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC} 76PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC} 77 78NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \ 79 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c 80 81GEN_CFILES= $S/$M/$M/genassym.c 82# setdef0.c and setdef1.c are intentionally 83# omitted from SYSTEM_CFILES. They include setdefs.h, a header which 84# is generated from all of ${OBJS}. We don't want to have to compile 85# everything just to do a make depend. 86SYSTEM_CFILES= param.c vnode_if.c hints.c config.c 87SYSTEM_SFILES= $S/$M/$M/locore.s 88SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 89SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} param.o hints.o config.o \ 90 setdef1.o hack.So 91SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 92 -export-dynamic -dynamic-linker /red/herring \ 93 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 94SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 95 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 96SYSTEM_DEP+= $S/conf/ldscript.$M 97 98%BEFORE_DEPEND 99 100%OBJS 101 102%CFILES 103 104%SFILES 105 106%MFILES 107 108%CLEAN 109 110.PHONY: all modules 111 112all: ${KERNEL} 113 114depend: kernel-depend 115clean: kernel-clean 116cleandepend: kernel-cleandepend 117tags: kernel-tags 118install install.debug: kernel-install 119reinstall reinstall.debug: kernel-reinstall 120 121.if !defined(DEBUG) 122FULLKERNEL= ${KERNEL} 123.else 124FULLKERNEL= ${KERNEL}.debug 125${KERNEL}: ${FULLKERNEL} 126 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL} 127.endif 128 129${FULLKERNEL}: ${SYSTEM_DEP} vers.o 130 @rm -f ${.TARGET} 131 @echo linking ${.TARGET} 132 ${SYSTEM_LD} 133 ${SYSTEM_LD_TAIL} 134 135.if !exists(.depend) 136${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 137.endif 138 139.for mfile in ${MFILES} 140${mfile:T:S/.m$/.h/}: ${mfile} 141 perl5 $S/kern/makeobjops.pl -h ${mfile} 142.endfor 143 144kernel-clean: 145 rm -f *.o *.so *.So *.ko *.s eddep errs \ 146 ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \ 147 setdef[01].c setdefs.h tags \ 148 vers.c vnode_if.c vnode_if.h \ 149 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 150 ${CLEAN} 151 152#lint: /tmp param.c 153# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 154# $S/$M/$M/Locore.c ${CFILES} param.c | \ 155# grep -v 'struct/union .* never defined' | \ 156# grep -v 'possible pointer alignment problem' 157 158locore.o: $S/$M/$M/locore.s assym.s 159 ${NORMAL_S} 160 161# This is a hack. BFD "optimizes" away dynamic mode if there are no 162# dynamic references. We could probably do a '-Bforcedynamic' mode like 163# in the a.out ld. For now, this works. 164hack.So: Makefile 165 touch hack.c 166 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So 167 rm -f hack.c 168 169.ORDER: setdefs.h setdef0.c setdef1.c 170 171setdef0.o: setdef0.c setdefs.h 172 ${NORMAL_C} 173 174setdef1.o: setdef1.c setdefs.h 175 ${NORMAL_C} 176 177setdef0.c setdef1.c setdefs.h: Makefile ${OBJS} 178 @gensetdefs ${OBJS} 179 180# this rule stops ./assym.s in .depend from causing problems 181./assym.s: assym.s 182 183assym.s: $S/kern/genassym.sh genassym.o 184 sh $S/kern/genassym.sh genassym.o > ${.TARGET} 185 186genassym.o: $S/$M/$M/genassym.c 187 rm -f ./machine ; ln -s $S/$M/include ./machine 188 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c 189 190${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 191 192kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 193 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 194 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 195 rm -f .newdep 196 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 197 env MKDEP_CPP="${CC} -E" \ 198 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 199 rm -f .depend 200 mv -f .newdep .depend 201 202kernel-cleandepend: 203 rm -f .depend 204 205links: 206 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 207 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 208 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 209 sort -u | comm -23 - dontlink | \ 210 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 211 sh makelinks && rm -f dontlink 212 213kernel-tags: 214 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 215 sh $S/conf/systags.sh 216 rm -f tags1 217 sed -e 's, ../, ,' tags > tags1 218 219kernel-install kernel-install.debug: 220 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 221 echo "You must set up a /boot/device.hints file first." ; \ 222 exit 1 ; \ 223 fi 224 @if [ x"`grep device.hints /boot/defaults/loader.conf /boot/loader.conf`" = "x" ]; then \ 225 echo "You must activate /boot/device.hints in loader.conf." ; \ 226 exit 1 ; \ 227 fi 228 @if [ ! -f ${KERNEL}${.TARGET:S/kernel-install//} ] ; then \ 229 echo "You must build a kernel first." ; \ 230 exit 1 ; \ 231 fi 232.if exists(${DESTDIR}/${KERNEL}) 233 -chflags noschg ${DESTDIR}/${KERNEL} 234 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old 235.endif 236 install -c -m 555 -o root -g wheel -fschg \ 237 ${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL} 238 239kernel-reinstall kernel-reinstall.debug: 240 install -c -m 555 -o root -g wheel -fschg \ 241 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL} 242 243.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 244all: modules 245depend: modules-depend 246clean: modules-clean 247cleandepend: modules-cleandepend 248cleandir: modules-cleandir 249tags: modules-tags 250install install.debug: modules-install 251reinstall reinstall.debug: modules-reinstall 252.endif 253 254modules: 255 @mkdir -p ${.OBJDIR}/modules 256 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} obj all 257 258modules-depend: 259 @mkdir -p ${.OBJDIR}/modules 260 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} obj depend 261 262modules-clean: 263 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} clean 264 265modules-cleandepend: 266 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} cleandepend 267 268modules-cleandir: 269 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} cleandir 270 271modules-tags: 272 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} tags 273 274modules-install modules-install.debug: 275.if !defined(NO_MODULES_OLD) 276 if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \ 277 mkdir -p ${DESTDIR}/modules.old; \ 278 cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \ 279 fi; 280.endif 281 mkdir -p ${DESTDIR}/modules 282 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} install 283 284modules-reinstall modules-reinstall.debug: 285 cd $S/modules && env MAKEOBJDIRPREFIX=${.OBJDIR}/modules ${MAKE} install 286 287config.o: 288 ${NORMAL_C} 289 290param.c: $S/conf/param.c 291 -rm -f param.c 292 cp $S/conf/param.c . 293 294param.o: 295 ${NORMAL_C} 296 297vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 298 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 299 300# XXX strictly, everything depends on Makefile because changes to ${PROF} 301# only appear there, but we don't handle that. 302vers.o: 303 ${NORMAL_C} 304 305hints.o: hints.c 306 ${NORMAL_C} 307 308vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 309 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 310 311vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 312 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 313 314vnode_if.o: 315 ${NORMAL_C} 316 317# Commented out for now pending a better solution. 318# How do we pick up compiler version specific flags?? 319#.if exists($S/../share/mk) 320#.include "$S/../share/mk/bsd.kern.mk" 321#.else 322.include <bsd.kern.mk> 323#.endif 324 325%RULES 326 327# DO NOT DELETE THIS LINE -- make depend uses it 328