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