Makefile.bootxx revision 1.8
1# $NetBSD: Makefile.bootxx,v 1.8 2003/08/30 18:25:07 fvdl 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" 52LD+= -m elf_i386 53AFLAGS+= -m32 54COPTS+= -m32 55LIBKERN_ARCH=i386 56KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 57CPPFLAGS+= -DBOOT_ELF64 58.else 59COPTS+= -mcpu=i386 60.endif 61 62COPTS+= -ffreestanding 63CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes 64CPPFLAGS+= -nostdinc -D_STANDALONE 65CPPFLAGS+= -I$S 66 67CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \ 68 -DLIBSA_NO_TWIDDLE \ 69 -DLIBSA_NO_FD_CHECKING \ 70 -DLIBSA_NO_RAW_ACCESS \ 71 -DLIBSA_NO_FS_WRITE \ 72 -DLIBSA_NO_FS_SEEK \ 73 -DLIBSA_USE_MEMCPY \ 74 -DLIBSA_USE_MEMSET \ 75 -DLIBSA_SINGLE_DEVICE=blkdev \ 76 -DLIBKERN_OPTIMISE_SPACE \ 77 -D"blkdevioctl(x,y,z)=EINVAL" \ 78 -D"blkdevclose(f)=0" \ 79 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \ 80 -DLIBSA_NO_DISKLABEL_MSGS 81 82# -DLIBSA_FS_SINGLECOMPONENT 83 84# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT 85 86I386_STAND_DIR?= $S/arch/i386/stand 87 88.if !make(obj) && !make(clean) && !make(cleandir) 89.BEGIN: machine x86 90.NOPATH: machine x86 91.endif 92 93realdepend realall: machine x86 94CLEANFILES+= machine x86 95 96machine:: 97 -rm -f $@ 98 ln -s $S/arch/i386/include $@ 99 100x86:: 101 -rm -f $@ 102 ln -s $S/arch/x86/include $@ 103 104${OBJS}: machine x86 105 106### find out what to use for libi386 107I386DIR= ${I386_STAND_DIR}/lib 108I386DST= ${.OBJDIR}/../lib/i386 109.include "${I386DIR}/Makefile.inc" 110LIBI386= ${I386LIB} 111 112### find out what to use for libsa 113SA_AS= library 114SADST= ${.OBJDIR}/../lib/libsa 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 121KERNDST= ${.OBJDIR}/../lib/libkern 122.include "${S}/lib/libkern/Makefile.inc" 123LIBKERN= ${KERNLIB} 124 125 126cleandir distclean: cleanlibdir 127 128cleanlibdir: 129 rm -rf lib 130 131LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} 132 133CLEANFILES+= ${PROG}.sym ${PROG}.map 134 135${PROG}: ${OBJS} ${LIBLIST} 136 ${LD} -o ${PROG}.sym ${LDFLAGS} -Ttext ${PRIMARY_LOAD_ADDRESS} \ 137 -Map ${PROG}.map -cref ${OBJS} ${LIBLIST} 138 ${OBJCOPY} -O binary ${PROG}.sym ${PROG} 139 @ sz=$$(ls -ln ${PROG}|tr -s ' '|cut -d' ' -f5); \ 140 if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \ 141 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \ 142 rm ${PROG}; \ 143 ! :; \ 144 else \ 145 : pad to sector boundary; \ 146 pad=$$(( 512 - ( $$sz & 511 ) )); \ 147 [ $$pad != 512 ] && \ 148 dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \ 149 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \ 150 fi 151 152.include <bsd.prog.mk> 153