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