Makefile.pc98 revision 60322
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 60322 2000-05-10 13:57:22Z nyan $ 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= 400018 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 112.if !defined(DEBUG) 113FULLKERNEL= ${KERNEL} 114.else 115FULLKERNEL= ${KERNEL}.debug 116${KERNEL}: ${FULLKERNEL} 117 objcopy --strip-debug ${FULLKERNEL} ${KERNEL} 118.endif 119 120${FULLKERNEL}: ${SYSTEM_DEP} vers.o 121 @rm -f ${.TARGET} 122 @echo linking ${.TARGET} 123 ${SYSTEM_LD} 124 ${SYSTEM_LD_TAIL} 125 126.if !defined(NO_MODULES) && exists(${.CURDIR}/../../modules) 127all: modules 128 129modules: 130 @mkdir -p ${.CURDIR}/modules 131 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} obj 132 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} all 133.endif 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 144clean: 145 rm -f *.o *.so *.So *.ko *.s eddep errs genassym \ 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.if !defined(NO_MODULES) && exists(${.CURDIR}/../../modules) 152 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} clean 153.endif 154 155#lint: /tmp param.c 156# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 157# $S/$M/$M/Locore.c ${CFILES} ioconf.c param.c | \ 158# grep -v 'struct/union .* never defined' | \ 159# grep -v 'possible pointer alignment problem' 160 161locore.o: $S/$M/$M/locore.s assym.s 162 ${NORMAL_S} 163 164# This is a hack. BFD "optimizes" away dynamic mode if there are no 165# dynamic references. We could probably do a '-Bforcedynamic' mode like 166# in the a.out ld. For now, this works. 167hack.So: Makefile 168 touch hack.c 169 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So 170 rm -f hack.c 171 172.ORDER: setdefs.h setdef0.c setdef1.c 173 174setdef0.o: setdef0.c setdefs.h 175 ${NORMAL_C} 176 177setdef1.o: setdef1.c setdefs.h 178 ${NORMAL_C} 179 180setdef0.c setdef1.c setdefs.h: ${OBJS} param.o 181 @gensetdefs ${OBJS} param.o 182 183# this rule stops ./assym.s in .depend from causing problems 184./assym.s: assym.s 185 186assym.s: genassym.o 187 genassym genassym.o >assym.s 188 189genassym.o: $S/$M/$M/genassym.c 190 rm -f ./machine ; ln -s $S/$M/include ./machine 191 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c 192 193${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 194 195depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \ 196 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 197 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 198 rm -f .newdep 199 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 200 env MKDEP_CPP="${CC} -E" \ 201 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 202 rm -f .depend 203 mv -f .newdep .depend 204.if !defined(NO_MODULES) && exists(${.CURDIR}/../../modules) 205 @mkdir -p ${.CURDIR}/modules 206 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} obj 207 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} depend 208.endif 209 210cleandepend: 211 rm -f .depend 212.if !defined(NO_MODULES) && exists(${.CURDIR}/../../modules) 213 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} cleandepend 214.endif 215 216links: 217 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 218 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 219 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 220 sort -u | comm -23 - dontlink | \ 221 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 222 sh makelinks && rm -f dontlink 223 224tags: 225 @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 226 sh $S/conf/systags.sh 227 rm -f tags1 228 sed -e 's, ../, ,' tags > tags1 229 230install install.debug: 231 @if [ ! -f ${KERNEL}${.TARGET:S/install//} ] ; then \ 232 echo "You must build a kernel first." ; \ 233 exit 1 ; \ 234 fi 235.if exists(${DESTDIR}/${KERNEL}) 236 -chflags noschg ${DESTDIR}/${KERNEL} 237 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old 238.endif 239 install -c -m 555 -o root -g wheel -fschg \ 240 ${KERNEL}${.TARGET:S/install//} ${DESTDIR}/${KERNEL} 241.if !defined(NO_MODULES) && exists(${.CURDIR}/../../modules) 242 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} install 243.endif 244 245reinstall reinstall.debug: 246 install -c -m 555 -o root -g wheel -fschg \ 247 ${KERNEL}${.TARGET:S/reinstall//} ${DESTDIR}/${KERNEL} 248.if !defined(NO_MODULES) && exists(${.CURDIR}/../../modules) 249 cd ${.CURDIR}/../../modules && env MAKEOBJDIRPREFIX=${.CURDIR}/modules ${MAKE} install 250.endif 251 252config.o: 253 ${NORMAL_C} 254 255ioconf.o: 256 ${NORMAL_C} 257 258param.c: $S/conf/param.c 259 -rm -f param.c 260 cp $S/conf/param.c . 261 262param.o: 263 ${NORMAL_C} 264 265vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 266 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 267 268# XXX strictly, everything depends on Makefile because changes to ${PROF} 269# only appear there, but we don't handle that. 270vers.o: 271 ${NORMAL_C} 272 273vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 274 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 275 276vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 277 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 278 279vnode_if.o: 280 ${NORMAL_C} 281 282# Commented out for now pending a better solution. 283# How do we pick up compiler version specific flags?? 284#.if exists($S/../share/mk) 285#.include "$S/../share/mk/bsd.kern.mk" 286#.else 287.include <bsd.kern.mk> 288#.endif 289 290%RULES 291 292# DO NOT DELETE THIS LINE -- make depend uses it 293