Makefile revision 40314
199005Sobrien#	$Id: Makefile,v 1.2 1998/10/13 18:29:18 rnordier Exp $
299005Sobrien
399005SobrienM4?=	m4
499005Sobrien
599005Sobrien.if exists(${.OBJDIR}/../btx)
699005SobrienBTX=	${.OBJDIR}/../btx
799005Sobrien.else
899005SobrienBTX=	${.CURDIR}/../btx
999005Sobrien.endif
1099005Sobrien
1199005SobrienORG1=	0x7c00
1299005SobrienORG2=	0x1000
1399005Sobrien
1499005SobrienCFLAGS=	-elf -I${BTX}/lib -I. -fno-builtin \
1599005Sobrien	-O2 -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
1699005Sobrien	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
1799005Sobrien	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
1899005Sobrien	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
1999005Sobrien
2099005SobrienLDFLAGS=-nostdlib -static -N
2199005Sobrien
22130803Smarcelall: boot1 boot2
23
24boot1: boot1.out
25	objcopy -S -O binary boot1.out ${.TARGET}
26
27boot1.out: boot1.o
28	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
29
30boot1.o: boot1.m4 boot1.s
31	${M4} boot1.m4 boot1.s | ${AS} ${AFLAGS} -o ${.TARGET}
32
33boot2: boot2.ldr boot2.bin
34	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
35		-o boot2.ld -P 1 boot2.bin
36	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
37		print x " bytes available"; if (x < 0) exit 1 }'
38	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
39
40boot2.ldr:
41	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
42
43boot2.bin: boot2.out
44	objcopy -S -O binary boot2.out ${.TARGET}
45
46boot2.out: boot2.o
47	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
48		${BTX}/lib/crt0.o boot2.o
49
50clean:
51	rm -f boot1 boot1.out boot1.o boot2 boot2.ldr boot2.bin \
52		boot2.ld boot2.out boot2.o
53