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