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