summaryrefslogtreecommitdiff
path: root/sys/arch/landisk/stand/xxboot/Makefile
blob: c0b34aba72f31d5453484e849fc11b728046e026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#	$OpenBSD: Makefile,v 1.3 2006/11/08 20:03:32 drahn Exp $

MAN=	xxboot.8

.if ${MACHINE} == "landisk"
PROG=	xxboot
LINKS=	${BINDIR}/xxboot ${BINDIR}/sdboot 
LINKS+=	${BINDIR}/xxboot ${BINDIR}/wdboot 
SRCS=	pbr.S xxboot.S boot1.c
LDFLAGS=-nostdlib -Ttext 0x8c201000 -N -x -Bstatic -e start

INSTALL_STRIP=

XXBOOT_SECTORS?= 15
XXBOOT_MAXSIZE?= (( ${XXBOOT_SECTORS} * 512 ))

CPPFLAGS+=-D_STANDALONE
CPPFLAGS+=-nostdinc -I${.OBJDIR} -I${.CURDIR}/.. -I${.CURDIR}/../../../..
CPPFLAGS+=-DLOADADDRESS=0x8ff00000 -DXXBOOT_SECTORS=${XXBOOT_SECTORS}
CFLAGS+=-m4-nofpu

OBJCOPY?=objcopy

S=	${.CURDIR}/../../../..
SAREL=
.include "${S}/lib/libsa/Makefile.inc"
DPADD+= $(SALIB)
LDADD+= $(SALIB)

KERN_AS?=	library
.include "${S}/lib/libkern/Makefile.inc"
DPADD+= $(KERNLIB)
LDADD+= $(KERNLIB)

LIBGCC!=${CC} -print-libgcc-file-name
LDADD+= $(LIBGCC)

${PROG}: ${OBJS} ${DPADD}
	${LD} -o ${PROG}.sym ${LDFLAGS} \
		-Map ${PROG}.map -cref ${OBJS} ${LDADD}
	${OBJCOPY} -O binary ${PROG}.sym ${PROG}
	@ sz=$$(ls -ln ${PROG} | tr -s ' ' | cut -d' ' -f5); \
	if [ "$$sz" -gt "$$${XXBOOT_MAXSIZE}" ]; then \
		echo "### ${PROG} size $$sz is larger than ${XXBOOT_MAXSIZE}" >&2 \
		rm -f ${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, $$((${XXBOOT_MAXSIZE} - $$sz)) free"; \
	fi
.else
NOPROG=
.endif


.include <bsd.prog.mk>