1# $NetBSD: Makefile.bootxx,v 1.6 2003/07/25 21:16:01 dsl Exp $ 2 3S= ${.CURDIR}/../../../../../ 4 5NOMAN= 6STRIPFLAG= 7PROG= bootxx_${FS} 8BINDIR= /usr/mdec 9BINMODE= 0444 10 11PRIMARY_LOAD_ADDRESS=0x600 12SECONDARY_LOAD_ADDRESS=0x10000 13 14# We ought (need?) to fit into track 0 of a 1.2M floppy. 15# This restricts us to 15 sectors (including pbr and label) 16BOOTXX_SECTORS?=15 17BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 )) 18 19SRCS= pbr.S label.S bootxx.S boot1.c 20 21.include <bsd.own.mk> 22 23LIBCRT0= # nothing 24LIBCRTBEGIN= # nothing 25LIBCRTEND= # nothing 26LIBC= # nothing 27 28BINDIR=/usr/mdec 29BINMODE=444 30 31.PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib 32 33LDFLAGS+= -N -e start 34CPPFLAGS+= -DBOOTXX 35# CPPFLAGS+= -D__daddr_t=int32_t 36CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR} 37CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS} 38CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS} 39CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS} 40# Magic number also known by usr.sbin/installboot/arch/i386.c 41CPPFLAGS+= -DX86_BOOT_MAGIC_1="('x' << 24 | 0x86b << 12 | 'm' << 4 | 1)" 42CPPFLAGS+= -DXXfs_open=${FS}_open 43CPPFLAGS+= -DXXfs_close=${FS}_close 44CPPFLAGS+= -DXXfs_read=${FS}_read 45CPPFLAGS+= -DXXfs_stat=${FS}_stat 46CPPFLAGS+= -DFS=${FS} 47 48# Make sure we override any optimization options specified by the user 49COPTS= -Os 50 51.if ${MACHINE} == "amd64" 52LDFLAGS+= -m elf_i386 53AFLAGS+= -m32 54COPTS+= -m32 55LIBKERN_ARCH=i386 56KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 57.else 58COPTS+= -mcpu=i386 59.endif 60 61COPTS+= -ffreestanding 62CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes 63CPPFLAGS+= -nostdinc -D_STANDALONE 64CPPFLAGS+= -I$S 65 66CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \ 67 -DLIBSA_NO_TWIDDLE \ 68 -DLIBSA_NO_FD_CHECKING \ 69 -DLIBSA_NO_RAW_ACCESS \ 70 -DLIBSA_NO_FS_WRITE \ 71 -DLIBSA_NO_FS_SEEK \ 72 -DLIBSA_USE_MEMCPY \ 73 -DLIBSA_USE_MEMSET \ 74 -DLIBSA_SINGLE_DEVICE=blkdev \ 75 -DLIBKERN_OPTIMISE_SPACE \ 76 -D"blkdevioctl(x,y,z)=EINVAL" \ 77 -D"blkdevclose(f)=0" \ 78 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \ 79 -DLIBSA_NO_DISKLABEL_MSGS 80 81# -DLIBSA_FS_SINGLECOMPONENT 82 83# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT 84 85I386_STAND_DIR?= $S/arch/i386/stand 86 87.if !make(obj) && !make(clean) && !make(cleandir) 88.BEGIN: machine x86 89.NOPATH: machine x86 90.endif 91 92realdepend realall: machine x86 93CLEANFILES+= machine x86 94 95machine:: 96 -rm -f $@ 97 ln -s $S/arch/i386/include $@ 98 99x86:: 100 -rm -f $@ 101 ln -s $S/arch/x86/include $@ 102 103${OBJS}: machine x86 104 105### find out what to use for libi386 106I386DIR= ${I386_STAND_DIR}/lib 107I386DST= ${.OBJDIR}/../lib/i386 108.include "${I386DIR}/Makefile.inc" 109LIBI386= ${I386LIB} 110 111### find out what to use for libsa 112SA_AS= library 113SADST= ${.OBJDIR}/../lib/libsa 114SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 115.include "${S}/lib/libsa/Makefile.inc" 116LIBSA= ${SALIB} 117 118### find out what to use for libkern 119KERN_AS= library 120KERNDST= ${.OBJDIR}/../lib/libkern 121.include "${S}/lib/libkern/Makefile.inc" 122LIBKERN= ${KERNLIB} 123 124 125cleandir distclean: cleanlibdir 126 127cleanlibdir: 128 rm -rf lib 129 130LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} 131 132CLEANFILES+= ${PROG}.sym ${PROG}.map 133 134${PROG}: ${OBJS} ${LIBLIST} 135 ${LD} -o ${PROG}.sym ${LDFLAGS} -Ttext ${PRIMARY_LOAD_ADDRESS} \ 136 -Map ${PROG}.map -cref ${OBJS} ${LIBLIST} 137 ${OBJCOPY} -O binary ${PROG}.sym ${PROG} 138 @ sz=$$(ls -ln ${PROG}|tr -s ' '|cut -d' ' -f5); \ 139 if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \ 140 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \ 141 rm ${PROG}; \ 142 ! :; \ 143 else \ 144 : pad to sector boundary; \ 145 pad=$$(( 512 - ( $$sz & 511 ) )); \ 146 [ $$pad != 512 ] && \ 147 dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \ 148 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \ 149 fi 150 151.include <bsd.prog.mk> 152