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