Makefile.i386 revision 1.118
1# $NetBSD: Makefile.i386,v 1.118 2001/10/26 06:45:37 jmc Exp $ 2 3# Makefile for NetBSD 4# 5# This makefile is constructed from a machine description: 6# config machineid 7# Most changes should be made in the machine description 8# /sys/arch/i386/conf/``machineid'' 9# after which you should do 10# config machineid 11# Machine generic makefile changes should be made in 12# /sys/arch/i386/conf/Makefile.i386 13# after which config should be rerun for all machines of that type. 14 15MACHINE_ARCH=i386 16USETOOLS?= no 17 18.include <bsd.own.mk> 19 20# DEBUG is set to -g if debugging. 21# PROF is set to -pg if profiling. 22 23AR?= ar 24AS?= as 25CC?= cc 26CPP?= cpp 27LD?= ld 28LORDER?=lorder 29MKDEP?= mkdep 30NM?= nm 31RANLIB?=ranlib 32SIZE?= size 33STRIP?= strip 34TSORT?= tsort -q 35 36COPTS?= -O2 37 38# source tree is located via $S relative to the compilation directory 39.ifndef S 40S!= cd ../../../..; pwd 41.endif 42I386= $S/arch/i386 43 44HAVE_EGCS!= ${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 45INCLUDES= -I. -I$S/arch -I$S -nostdinc 46CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Di386 47CWARNFLAGS?= -Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \ 48 -Wpointer-arith 49# XXX Delete -Wuninitialized for now, since the compiler doesn't 50# XXX always get it right. --thorpej 51CWARNFLAGS+= -Wno-uninitialized 52.if (${HAVE_EGCS} != "") 53CWARNFLAGS+= -Wno-main 54.endif 55CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} 56AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE 57 58TEXTADDR?= c0100000 59LINKFLAGS= -Ttext ${TEXTADDR} -e start 60 61.if (${OBJECT_FMT} == "ELF") 62KERN_LDSCRIPT?= kern.ldscript 63LINKFLAGS+= -T ${I386}/conf/${KERN_LDSCRIPT} 64.else 65LINKFLAGS+= -z 66.endif 67 68STRIPFLAGS= -g 69 70%INCLUDES 71 72### find out what to use for libkern 73KERN_AS= obj 74.include "$S/lib/libkern/Makefile.inc" 75.ifndef PROF 76LIBKERN= ${KERNLIB} 77.else 78LIBKERN= ${KERNLIB_PROF} 79.endif 80 81### find out what to use for libcompat 82.include "$S/compat/common/Makefile.inc" 83.ifndef PROF 84LIBCOMPAT= ${COMPATLIB} 85.else 86LIBCOMPAT= ${COMPATLIB_PROF} 87.endif 88 89# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or 90# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). 91 92NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 93NOPROF_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 94NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 95 96%OBJS 97 98%CFILES 99 100%SFILES 101 102# load lines for config "xxx" will be emitted as: 103# xxx: ${SYSTEM_DEP} swapxxx.o 104# ${SYSTEM_LD_HEAD} 105# ${SYSTEM_LD} swapxxx.o 106# ${SYSTEM_LD_TAIL} 107SYSTEM_OBJ= locore.o \ 108 param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN} 109SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 110SYSTEM_LD_HEAD= rm -f $@ 111SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ 112 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 113SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 114 115DEBUG?= 116.if ${DEBUG} == "-g" 117LINKFLAGS+= -X 118SYSTEM_LD_TAIL+=; \ 119 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \ 120 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 121 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 122.else 123LINKFLAGS+= -X 124.endif 125 126%LOAD 127 128assym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf 129 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 130 < ${I386}/i386/genassym.cf > assym.h.tmp && \ 131 mv -f assym.h.tmp assym.h 132 133param.c: $S/conf/param.c 134 rm -f param.c 135 cp $S/conf/param.c . 136 137param.o: param.c Makefile 138 ${NORMAL_C} 139 140ioconf.o: ioconf.c 141 ${NORMAL_C} 142 143newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 144 sh $S/conf/newvers.sh 145 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 146 147 148__CLEANKERNEL: .USE 149 @echo "${.TARGET}ing the kernel objects" 150 rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \ 151 [Ee]rrs linterrs makelinks assym.h.tmp assym.h 152 153__CLEANDEPEND: .USE 154 rm -f .depend 155 156clean: __CLEANKERNEL 157 158cleandir distclean: __CLEANKERNEL __CLEANDEPEND 159 160ALLSFILES= ${I386}/i386/locore.s ${SFILES} 161LINTSTUBS= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g} 162 163.for _sfile in ${ALLSFILES} 164LintStub_${_sfile:T:R}.c: ${_sfile} assym.h 165 ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \ 166 awk -f $S/kern/genlintstub.awk >${.TARGET} 167.endfor 168 169lint: ${CFILES} ${LINTSTUBS} ioconf.c param.c 170 @lint -bceghnxzF ${CPPFLAGS} -UKGDB \ 171 ${CFILES} ${LINTSTUBS} ioconf.c param.c 172 173tags: 174 @echo "see $S/kern/Makefile for tags" 175 176links: 177 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 178 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 179 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 180 sort -u | comm -23 - dontlink | \ 181 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 182 sh makelinks && rm -f dontlink 183 184SRCS= ${I386}/i386/locore.s \ 185 param.c ioconf.c ${CFILES} ${SFILES} 186depend: .depend 187.depend: ${SRCS} assym.h param.c 188 ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s 189 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 190 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 191 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \ 192 ${CPPFLAGS} < ${I386}/i386/genassym.cf 193 @sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend 194 @rm -f assym.dep 195 196dependall: depend all 197 198 199# depend on root or device configuration 200autoconf.o conf.o: Makefile 201 202# depend on network or filesystem configuration 203uipc_proto.o vfs_conf.o: Makefile 204 205# depend on maxusers 206machdep.o: Makefile 207 208# depend on CPU configuration 209locore.o machdep.o: Makefile 210 211locore.o: ${I386}/i386/locore.s assym.h 212 ${NORMAL_S} 213 214apmcall.o in_cksum.o pnpbioscall.o: assym.h 215 216freebsd_sigcode.o ibcs2_sigcode.o linux_sigcode.o svr4_sigcode.o: assym.h 217 218# The install target can be redefined by putting a 219# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 220MACHINE_NAME!= uname -n 221install: install-kernel-${MACHINE_NAME} 222.if !target(install-kernel-${MACHINE_NAME}}) 223install-kernel-${MACHINE_NAME}: 224 rm -f /onetbsd 225 ln /netbsd /onetbsd 226 cp netbsd /nnetbsd 227 mv /nnetbsd /netbsd 228.endif 229 230%RULES 231