NetBSD/sys/arch/i386/stand/bootxx/Makefile.bootxx
gson d1298fd2a7 If a bootxx program already happened to be a multiple of 512 bytes in
length before padding, the shell command to conditionally pad it to
a multiple of 512 bytes returned a nonzero exit status, causing the
build to fail.
2003-10-15 03:49:57 +00:00

159 lines
3.5 KiB
Makefile

# $NetBSD: Makefile.bootxx,v 1.13 2003/10/15 03:49:57 gson Exp $
S= ${.CURDIR}/../../../../../
NOMAN=
STRIPFLAG=
PROG?= bootxx_${FS}
BINDIR= /usr/mdec
BINMODE= 0444
PRIMARY_LOAD_ADDRESS=0x600
SECONDARY_LOAD_ADDRESS=0x10000
# We ought (need?) to fit into track 0 of a 1.2M floppy.
# This restricts us to 15 sectors (including pbr and label)
BOOTXX_SECTORS?=15
BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
SRCS= pbr.S label.S bootxx.S boot1.c
.include <bsd.own.mk>
LIBCRT0= # nothing
LIBCRTBEGIN= # nothing
LIBCRTEND= # nothing
LIBC= # nothing
BINDIR=/usr/mdec
BINMODE=444
.PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
LDFLAGS+= -N -e start
CPPFLAGS+= -DBOOTXX
# CPPFLAGS+= -D__daddr_t=int32_t
CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
CPPFLAGS+= -DXXfs_open=${FS}_open
CPPFLAGS+= -DXXfs_close=${FS}_close
CPPFLAGS+= -DXXfs_read=${FS}_read
CPPFLAGS+= -DXXfs_stat=${FS}_stat
CPPFLAGS+= -DFS=${FS}
# Make sure we override any optimization options specified by the user
COPTS= -Os
CPPFLAGS+= -DNO_LBA_CHECK
.if ${MACHINE} == "amd64"
LD+= -m elf_i386
AFLAGS+= -m32
COPTS+= -m32
LIBKERN_ARCH=i386
KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
CPPFLAGS+= -DBOOT_ELF64
.else
COPTS+= -mcpu=i386
.endif
COPTS+= -ffreestanding
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
CPPFLAGS+= -nostdinc -D_STANDALONE
CPPFLAGS+= -I$S
CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
-DLIBSA_NO_TWIDDLE \
-DLIBSA_NO_FD_CHECKING \
-DLIBSA_NO_RAW_ACCESS \
-DLIBSA_NO_FS_WRITE \
-DLIBSA_NO_FS_SEEK \
-DLIBSA_USE_MEMCPY \
-DLIBSA_USE_MEMSET \
-DLIBSA_SINGLE_DEVICE=blkdev \
-DLIBKERN_OPTIMISE_SPACE \
-D"blkdevioctl(x,y,z)=EINVAL" \
-D"blkdevclose(f)=0" \
-D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
-DLIBSA_NO_DISKLABEL_MSGS
# -DLIBSA_FS_SINGLECOMPONENT
# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
I386_STAND_DIR?= $S/arch/i386/stand
.if !make(obj) && !make(clean) && !make(cleandir)
.BEGIN: machine x86 lib
.NOPATH: machine x86
.endif
realdepend realall: machine x86 lib
CLEANFILES+= machine x86
machine::
-rm -f $@
ln -s $S/arch/i386/include $@
x86::
-rm -f $@
ln -s $S/arch/x86/include $@
${OBJS}: machine x86 lib
lib:
.ifdef LIBOBJ
-rm -f $@
ln -s ${LIBOBJ}/lib .
[ -d ${LIBOBJ}/lib ] || mkdir ${LIBOBJ}/lib
.else
mkdir lib
.endif
### find out what to use for libi386
I386DIR= ${I386_STAND_DIR}/lib
.include "${I386DIR}/Makefile.inc"
LIBI386= ${I386LIB}
### find out what to use for libsa
SA_AS= library
SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
.include "${S}/lib/libsa/Makefile.inc"
LIBSA= ${SALIB}
### find out what to use for libkern
KERN_AS= library
.include "${S}/lib/libkern/Makefile.inc"
LIBKERN= ${KERNLIB}
cleandir distclean: cleanlibdir
cleanlibdir:
rm -rf lib
LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
CLEANFILES+= ${PROG}.sym ${PROG}.map
${PROG}: ${OBJS} ${LIBLIST}
${LD} -o ${PROG}.sym ${LDFLAGS} -Ttext ${PRIMARY_LOAD_ADDRESS} \
-Map ${PROG}.map -cref ${OBJS} ${LIBLIST}
${OBJCOPY} -O binary ${PROG}.sym ${PROG}
@ sz=$$(ls -ln ${PROG}|tr -s ' '|cut -d' ' -f5); \
if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
rm ${PROG}; \
! :; \
else \
: pad to sector boundary; \
pad=$$(( 512 - ( $$sz & 511 ) )); \
[ $$pad = 512 ] || \
dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
fi
.include <bsd.prog.mk>