Makefile revision 80751
150477Speter# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 80751 2001-07-31 19:50:09Z jhb $
240269Srnordier
340326SrnordierPROG=		boot2
440326SrnordierNOMAN=
540326SrnordierSTRIP=
640326SrnordierBINDIR?=	/boot
740326SrnordierBINMODE=	444
840326SrnordierCLEANFILES+=	boot1 boot1.out boot1.o \
980751Sjhb		boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
1040404Srnordier		sio.o
1140326Srnordier
1280751SjhbNM?=		nm
1380751Sjhb
1448919Srnordier# A value of 0x80 enables LBA support.
1562138SjhbB1FLAGS=	0x80
1648919Srnordier
1742480SrnordierBOOT_COMCONSOLE_PORT?= 0x3f8
1842480SrnordierBOOT_COMCONSOLE_SPEED?= 9600
1940541SrnordierB2SIOFMT?=	0x3
2040541Srnordier
2140269Srnordier.if exists(${.OBJDIR}/../btx)
2240269SrnordierBTX=	${.OBJDIR}/../btx
2340269Srnordier.else
2440269SrnordierBTX=	${.CURDIR}/../btx
2540269Srnordier.endif
2640269Srnordier
2740269SrnordierORG1=	0x7c00
2840269SrnordierORG2=	0x1000
2940269Srnordier
3053134SobrienCFLAGS=	-elf -I${.CURDIR}/../btx/lib -I. \
3153174Sobrien	-Os -fno-builtin -fforce-addr -fdata-sections \
3253134Sobrien	-malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
3353174Sobrien	-mpreferred-stack-boundary=2 \
3440269Srnordier	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
3540269Srnordier	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
3640269Srnordier	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
3740269Srnordier
3840269SrnordierLDFLAGS=-nostdlib -static -N
3940269Srnordier
4040269Srnordierall: boot1 boot2
4140269Srnordier
4240269Srnordierboot1: boot1.out
4340308Srnordier	objcopy -S -O binary boot1.out ${.TARGET}
4440269Srnordier
4540269Srnordierboot1.out: boot1.o
4640269Srnordier	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
4740269Srnordier
4860821Sjhbboot1.o: boot1.s
4960821Sjhb	${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET}
5040269Srnordier
5180751Sjhbboot2.h: boot1.out
5280751Sjhb	${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
5380751Sjhb	 	{ x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \
5480751Sjhb	 	ORG1=`printf "%d" ${ORG1}` > boot2.h
5580751Sjhb
5659150Sjhbboot2: boot2.ldr boot2.bin ${BTX}/btx/btx
5740269Srnordier	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
5840314Srnordier		-o boot2.ld -P 1 boot2.bin
5940314Srnordier	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
6040314Srnordier		print x " bytes available"; if (x < 0) exit 1 }'
6140314Srnordier	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
6240269Srnordier
6340269Srnordierboot2.ldr:
6440269Srnordier	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
6540269Srnordier
6640269Srnordierboot2.bin: boot2.out
6740308Srnordier	objcopy -S -O binary boot2.out ${.TARGET}
6840269Srnordier
6940404Srnordierboot2.out: boot2.o sio.o
7040269Srnordier	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
7140404Srnordier		${BTX}/lib/crt0.o boot2.o sio.o
7240269Srnordier
7380751Sjhbboot2.o: boot2.h
7480751Sjhb
7540404Srnordiersio.o: sio.s
7660821Sjhb	${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
7760821Sjhb		--defsym SIOFMT=${B2SIOFMT} \
7860821Sjhb		--defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
7960821Sjhb		${.IMPSRC} -o ${.TARGET}
8040404Srnordier
8140326Srnordierinstall:
8240326Srnordier	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
8340326Srnordier		boot1 ${DESTDIR}${BINDIR}/boot1
8440326Srnordier	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
8540326Srnordier		boot2 ${DESTDIR}${BINDIR}/boot2
8640326Srnordier
8740326Srnordier.include <bsd.prog.mk>
88