1# $OpenBSD: Makefile,v 1.10 2016/07/30 03:25:48 guenther Exp $ 2 3MAN= xxboot.8 4 5.if ${MACHINE} == "landisk" 6PROG= xxboot 7SRCS= pbr.S xxboot.S boot1.c 8LDFLAGS=-nostdlib -Ttext 0x8c201000 -N -x -Bstatic -e start -nopie -znorelro 9 10INSTALL_STRIP= 11 12XXBOOT_SECTORS?= 15 13XXBOOT_MAXSIZE?= (( ${XXBOOT_SECTORS} * 512 )) 14 15CPPFLAGS+=-D_STANDALONE 16CPPFLAGS+=-nostdinc -I${.OBJDIR} -I${.CURDIR}/.. -I${.CURDIR}/../../../.. 17CPPFLAGS+=-DLOADADDRESS=0x8ff00000 -DXXBOOT_SECTORS=${XXBOOT_SECTORS} 18CFLAGS+=-m4-nofpu -fno-pie 19AFLAGS+= -fno-pie 20 21OBJCOPY?=objcopy 22 23S= ${.CURDIR}/../../../.. 24SAREL= 25.include "${S}/lib/libsa/Makefile.inc" 26DPADD+= $(SALIB) 27LDADD+= $(SALIB) 28 29.PATH: ${S}/lib/libkern/arch/sh ${S}/lib/libkern 30SRCS+= strlen.c 31SRCS+= ashrdi3.c sdivsi3.S udivsi3.S 32 33${PROG}: ${OBJS} ${DPADD} 34 ${LD} -o ${PROG}.sym ${LDFLAGS} \ 35 -Map ${PROG}.map -cref ${OBJS} ${LDADD} 36 ${OBJCOPY} -O binary ${PROG}.sym ${PROG} 37 @ sz=$$(ls -ln ${PROG} | tr -s ' ' | cut -d' ' -f5); \ 38 if [ "$$sz" -gt "$$${XXBOOT_MAXSIZE}" ]; then \ 39 echo "### ${PROG} size $$sz is larger than ${XXBOOT_MAXSIZE}" >&2 \ 40 rm -f ${PROG}; \ 41 ! :; \ 42 else \ 43 : pad to sector boundary; \ 44 pad=$$(( 512 - ( $$sz & 511 ) )); \ 45 [ $$pad = 512 ] || \ 46 dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \ 47 echo "${PROG} size $$sz, $$((${XXBOOT_MAXSIZE} - $$sz)) free"; \ 48 fi 49.else 50NOPROG= 51.endif 52 53 54.include <bsd.prog.mk> 55