Makefile.pc98 revision 48319
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# $Id: Makefile.pc98,v 1.64 1999/05/10 09:00:29 kato Exp $ 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= 400016 23 24# Can be overridden by makeoptions or /etc/make.conf 25KERNEL?= kernel 26KERNFORMAT?= elf 27#STD8X16FONT?= iso 28 29.if exists(./@/.) 30S= ./@ 31.else 32S= ../.. 33.endif 34PC98= ${S}/pc98 35I386= ${S}/i386 36 37COPTFLAGS?=-O 38INCLUDES= -nostdinc -I- -I. -I$S 39# This hack is to allow kernel compiles to succeed on machines w/out srcdist 40.if exists($S/../include) 41INCLUDES+= -I$S/../include 42.else 43INCLUDES+= -I/usr/include 44.endif 45COPTS= ${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h 46CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 47 48# XXX LOCORE means "don't declare C stuff" not "for locore.s". 49ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 50 51# Use the default object format for genassym, etc. 52GEN_CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} -UKERNEL 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 genassym, etc. 57.if ${KERNFORMAT} == "elf" 58CFLAGS+= -elf 59.else 60CFLAGS+= -aout 61.endif 62 63LOAD_ADDRESS?= C0100000 64DEFINED_PROF= ${PROF} 65.if defined(PROF) 66CFLAGS+= -malign-functions=4 67.if ${PROFLEVEL} >= 2 68IDENT+= -DGPROF4 -DGUPROF 69PROF+= -mprofiler-epilogue 70.endif 71.endif 72 73NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $< 74NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} $< 75NORMAL_S= ${CC} -c ${ASM_CFLAGS} $< 76DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $< 77DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} $< 78DRIVER_S= ${CC} -c -x ${ASM_CFLAGS} $< 79PROFILE_C= ${CC} -c ${CFLAGS} $< 80 81GEN_CFILES= ${I386}/i386/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= ioconf.c param.c vnode_if.c config.c 87SYSTEM_SFILES= ${I386}/i386/locore.s 88SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} 89.if ${CFLAGS:M-g} == "" 90SYMORDER_EXCLUDE=-x symbols.exclude 91.endif 92 93.if ${KERNFORMAT} == aout || ${KERNFORMAT} == aoutkld 94SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o 95SYSTEM_LD= @${LD} -aout -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 96SYSTEM_LD_TAIL= @echo rearranging symbols; \ 97 symorder -m ${SYMORDER_EXCLUDE} symbols.sort ${.TARGET}; \ 98 size -aout ${.TARGET} ; chmod 755 ${.TARGET} 99.endif 100 101.if ${KERNFORMAT} == elf 102SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \ 103 setdef1.o hack.So 104SYSTEM_LD= @${LD} -elf -Bdynamic -T $S/i386/conf/kernel.script \ 105 -export-dynamic -dynamic-linker /red/herring \ 106 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 107SYSTEM_LD_TAIL= @size -elf ${.TARGET} ; chmod 755 ${.TARGET} 108SYSTEM_DEP+= $S/i386/conf/kernel.script 109.endif 110 111%BEFORE_DEPEND 112 113%OBJS 114 115%CFILES 116 117%SFILES 118 119%MFILES 120 121%CLEAN 122 123all: ${KERNEL} 124 125.if !defined(DEBUG) 126FULLKERNEL= ${KERNEL} 127.else 128FULLKERNEL= ${KERNEL}.debug 129${KERNEL}: ${FULLKERNEL} 130.if ${KERNFORMAT} == "elf" 131 objcopy --strip-debug ${FULLKERNEL} ${KERNEL} 132.else 133 cp ${FULLKERNEL} ${KERNEL} 134 strip -d ${KERNEL} 135.endif 136.endif 137 138${FULLKERNEL}: ${BEFORE_DEPEND} ${SYSTEM_DEP} vers.o 139 @rm -f ${.TARGET} 140 @echo linking ${.TARGET} 141 ${SYSTEM_LD} 142 ${SYSTEM_LD_TAIL} 143 144.if !exists(.depend) 145${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} 146.endif 147 148clean: 149 rm -f *.o *.so *.So *.ko *.s eddep errs genassym gensetdefs \ 150 ${KERNEL} ${FULLKERNEL} linterrs makelinks param.c \ 151 setdef[01].c setdefs.h symbols.exclude symbols.sort tags \ 152 vers.c vnode_if.c vnode_if.h ${CLEAN} 153 154#lint: /tmp param.c 155# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \ 156# ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \ 157# grep -v 'struct/union .* never defined' | \ 158# grep -v 'possible pointer alignment problem' 159 160symbols.exclude: 161 echo "gcc2_compiled." >symbols.exclude 162 echo "___gnu_compiled_c" >>symbols.exclude 163 164symbols.sort: ${I386}/i386/symbols.raw 165 grep -v '^#' ${I386}/i386/symbols.raw \ 166 | sed 's/^ //' | sort -u > symbols.sort 167 168locore.o: ${I386}/i386/locore.s assym.s 169 ${NORMAL_S} 170 171.if ${KERNFORMAT} == elf 172# This is a hack. BFD "optimizes" away dynamic mode if there are no 173# dynamic references. We could probably do a '-Bforcedynamic' mode like 174# in the a.out ld. For now, this works. 175hack.So: Makefile 176 touch hack.c 177 ${CC} -elf -shared -nostdlib hack.c -o hack.So 178 rm -f hack.c 179.endif 180 181.ORDER: setdefs.h setdef0.c setdef1.c 182 183setdef0.o: setdef0.c setdefs.h 184 ${NORMAL_C} 185 186setdef1.o: setdef1.c setdefs.h 187 ${NORMAL_C} 188 189setdef0.c setdef1.c setdefs.h: ${OBJS} 190 @gensetdefs ${OBJS} 191 192# this rule stops ./assym.s in .depend from causing problems 193./assym.s: assym.s 194 195assym.s: genassym 196 ./genassym >assym.s 197 198genassym.o: ${I386}/i386/genassym.c 199 rm -f ./machine ; ln -s ${I386}/include ./machine 200 ${CC} -c ${GEN_CFLAGS} ${I386}/i386/genassym.c 201 202genassym: genassym.o 203 ${CC} ${GEN_CFLAGS} genassym.o -o ${.TARGET} 204 205${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 206 207# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical. 208depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} 209 rm -f .newdep 210 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} 211 mkdep -a -f .newdep ${GEN_CFLAGS} ${GEN_CFILES} 212 env MKDEP_CPP="${CC} -E" \ 213 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 214 rm -f .depend 215 mv -f .newdep .depend 216 217cleandepend: 218 rm -f .depend 219 220links: 221 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 222 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 223 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 224 sort -u | comm -23 - dontlink | \ 225 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 226 sh makelinks && rm -f dontlink 227 228tags: 229 @echo "see $S/kern/Makefile for tags" 230 231install install.debug: 232 @if [ ! -f ${KERNEL}${.TARGET:S/install//} ] ; then \ 233 echo "You must first build a kernel first." ; \ 234 exit 1 ; \ 235 fi 236.if exists(${DESTDIR}/${KERNEL}) 237 -chflags noschg ${DESTDIR}/${KERNEL} 238 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old 239.endif 240 PATH=$${PATH}:/sbin:/usr/sbin; \ 241 if [ `sysctl -n kern.bootfile` = ${DESTDIR}/${KERNEL} ] ; then \ 242 sysctl -w kern.bootfile=${DESTDIR}/${KERNEL}.old ; \ 243 if [ -f /var/db/kvm_${KERNEL}.db ] ; then \ 244 mv -f /var/db/kvm_${KERNEL}.db /var/db/kvm_${KERNEL}.old.db ; \ 245 fi \ 246 fi 247 install -c -m 555 -o root -g wheel -fschg \ 248 ${KERNEL}${.TARGET:S/install//} ${DESTDIR}/${KERNEL} 249 250reinstall reinstall.debug: 251 install -c -m 555 -o root -g wheel -fschg \ 252 ${KERNEL}${.TARGET:S/reinstall//} ${DESTDIR}/${KERNEL} 253 254config.o: 255 ${NORMAL_C} 256 257ioconf.o: 258 ${NORMAL_C} 259 260param.c: $S/conf/param.c 261 -rm -f param.c 262 cp $S/conf/param.c . 263 264param.o: 265 ${NORMAL_C} 266 267vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 268 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 269 270# XXX strictly, everything depends on Makefile because changes to ${PROF} 271# only appear there, but we don't handle that. 272vers.o: 273 ${NORMAL_C} 274 275.ORDER: vnode_if.c vnode_if.h 276vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src 277 sh $S/kern/vnode_if.sh $S/kern/vnode_if.src 278 279vnode_if.o: 280 ${NORMAL_C} 281 282.if exists($S/../share/mk) 283.include "$S/../share/mk/bsd.kern.mk" 284.else 285.include <bsd.kern.mk> 286.endif 287 288%RULES 289 290# DO NOT DELETE THIS LINE -- make depend uses it 291