Makefile revision 40269
140269Srnordier#	$Id:$
240269Srnordier
340269SrnordierM4?=	m4
440269Srnordier
540269Srnordier.if exists(${.OBJDIR}/../btx)
640269SrnordierBTX=	${.OBJDIR}/../btx
740269Srnordier.else
840269SrnordierBTX=	${.CURDIR}/../btx
940269Srnordier.endif
1040269Srnordier
1140269SrnordierORG1=	0x7c00
1240269SrnordierORG2=	0x1000
1340269Srnordier
1440269SrnordierCFLAGS=	-elf -I${BTX}/lib -I. -fno-builtin \
1540269Srnordier	-O2 -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
1640269Srnordier	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
1740269Srnordier	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
1840269Srnordier	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
1940269Srnordier
2040269SrnordierLDFLAGS=-nostdlib -static -N
2140269Srnordier
2240269Srnordierall: boot1 boot2
2340269Srnordier
2440269Srnordierboot1: boot1.out
2540269Srnordier	/usr/libexec/elf/objcopy -S -O binary boot1.out ${.TARGET}
2640269Srnordier
2740269Srnordierboot1.out: boot1.o
2840269Srnordier	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
2940269Srnordier
3040269Srnordierboot1.o: boot1.m4 boot1.s
3140269Srnordier	${M4} boot1.m4 boot1.s | ${AS} ${AFLAGS} -o ${.TARGET}
3240269Srnordier
3340269Srnordierboot2: boot2.ldr boot2.bin
3440269Srnordier	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
3540269Srnordier		-o ${.TARGET} -P 1 boot2.bin
3640269Srnordier	@ls -l boot2 | awk '{ x = 7680 - $$5; print x " bytes free"; \
3740269Srnordier		if (x < 0) exit 1 }'
3840269Srnordier
3940269Srnordierboot2.ldr:
4040269Srnordier	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
4140269Srnordier
4240269Srnordierboot2.bin: boot2.out
4340269Srnordier	/usr/libexec/elf/objcopy -S -O binary boot2.out ${.TARGET}
4440269Srnordier
4540269Srnordierboot2.out: boot2.o
4640269Srnordier	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
4740269Srnordier		${BTX}/lib/crt0.o boot2.o
4840269Srnordier
4940269Srnordierclean:
5040269Srnordier	rm -f boot1 boot1.out boot1.o boot2 boot2.ldr boot2.bin \
5140269Srnordier		boot2.out boot2.o
52