1# $NetBSD: Makefile.boot,v 1.32 2008/04/05 18:21:34 tsutsui Exp $ 2 3S= ${.CURDIR}/../../../../../ 4 5NOMAN= 6BINDIR= /usr/mdec 7BINMODE= 0444 8PROG?= boot 9NEWVERSWHAT?= "BIOS Boot" 10VERSIONFILE?= ${.CURDIR}/../version 11 12SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c 13SRCS= ${SOURCES} 14.if !make(depend) 15SRCS+= vers.c 16.endif 17 18.include <bsd.own.mk> 19 20STRIPFLAG= # nothing 21 22LIBCRT0= # nothing 23LIBCRTBEGIN= # nothing 24LIBCRTEND= # nothing 25LIBC= # nothing 26 27BINDIR=/usr/mdec 28BINMODE=444 29 30.PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib 31 32LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start 33# CPPFLAGS+= -D__daddr_t=int32_t 34CPPFLAGS+= -I ${.CURDIR}/.. -I ${.CURDIR}/../../lib -I ${S}/lib/libsa 35CPPFLAGS+= -I ${.OBJDIR} 36#CPPFLAGS+= -DDEBUG_MEMSIZE 37 38# Make sure we override any optimization options specified by the user 39COPTS= -Os 40 41.if ${MACHINE} == "amd64" 42LDFLAGS+= -Wl,-m,elf_i386 43AFLAGS+= -m32 44CPUFLAGS= -m32 45LIBKERN_ARCH=i386 46KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 47.else 48.if ${HAVE_GCC} == 3 49CPUFLAGS= -mcpu=i386 50.else 51CPUFLAGS= -march=i386 -mtune=i386 52.endif 53.endif 54 55COPTS+= -ffreestanding 56CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes 57CPPFLAGS+= -nostdinc -D_STANDALONE 58CPPFLAGS+= -I$S 59 60CPPFLAGS+= -DSUPPORT_PS2 61CPPFLAGS+= -DDIRECT_SERIAL 62CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev 63 64CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed 65CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr 66CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap 67 68CPPFLAGS+= -DSUPPORT_CD9660 69CPPFLAGS+= -DSUPPORT_USTARFS 70CPPFLAGS+= -DSUPPORT_DOSFS 71#CPPFLAGS+= -DSUPPORT_EXT2FS 72CPPFLAGS+= -DPASS_BIOSGEOM 73CPPFLAGS+= -DPASS_MEMMAP 74#CPPFLAGS+= -DBOOTPASSWD 75CPPFLAGS+= -DEPIA_HACK 76 77# The biosboot code is linked to 'virtual' address of zero and is 78# loaded at physical address 0x10000. 79# XXX The heap values should be determined from _end. 80SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000 81SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels 82SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS 83 84.if ${HAVE_GCC} == 4 85CPPFLAGS+= -Wno-pointer-sign 86.endif 87 88# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT 89 90I386_STAND_DIR?= $S/arch/i386/stand 91 92CLEANFILES+= machine x86 93 94.if !make(obj) && !make(clean) && !make(cleandir) 95.BEGIN: 96 -rm -f machine && ln -s $S/arch/i386/include machine 97 -rm -f x86 && ln -s $S/arch/x86/include x86 98.ifdef LIBOBJ 99 -rm -f lib && ln -s ${LIBOBJ}/lib lib 100 mkdir -p ${LIBOBJ}/lib 101.endif 102.endif 103 104### find out what to use for libi386 105I386DIR= ${I386_STAND_DIR}/lib 106.include "${I386DIR}/Makefile.inc" 107LIBI386= ${I386LIB} 108 109### find out what to use for libsa 110SA_AS= library 111SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 112.include "${S}/lib/libsa/Makefile.inc" 113LIBSA= ${SALIB} 114 115### find out what to use for libkern 116KERN_AS= library 117.include "${S}/lib/libkern/Makefile.inc" 118LIBKERN= ${KERNLIB} 119 120### find out what to use for libz 121Z_AS= library 122.include "${S}/lib/libz/Makefile.inc" 123LIBZ= ${ZLIB} 124 125 126cleandir distclean: cleanlibdir 127 128cleanlibdir: 129 -rm -rf lib 130 131LIBLIST= ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} ${LIBSA} 132# LIBLIST= ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} 133 134CLEANFILES+= ${PROG}.tmp ${PROG}.map vers.c 135 136vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot 137 ${HOST_SH} ${S}conf/newvers_stand.sh ${VERSIONFILE} x86 ${NEWVERSWHAT} 138 139# Anything that calls 'real_to_prot' must have a %pc < 0x10000. 140# We link the program, find the callers (all in libi386), then 141# explicitely pull in the required objects before any other library code. 142${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot 143 ${_MKTARGET_LINK} 144 bb="$$( ${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \ 145 ${OBJS} ${LIBLIST} | ( \ 146 while read symbol file; do \ 147 [ -z "$$file" ] && continue; \ 148 [ "$$symbol" = real_to_prot ] && break; \ 149 done; \ 150 while \ 151 oifs="$$IFS"; \ 152 IFS='()'; \ 153 set -- $$file; \ 154 IFS="$$oifs"; \ 155 [ -n "$$2" ] && echo "${I386DST}/$$2"; \ 156 read file rest && [ -z "$$rest" ]; \ 157 do :; \ 158 done; \ 159 ) )"; \ 160 ${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,-Ttext,0 \ 161 -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST} 162 ${OBJCOPY} -O binary ${PROG}.tmp ${PROG} 163 rm -f ${PROG}.tmp 164 165.include <bsd.prog.mk> 166