Makefile revision 40330
1#	$Id: Makefile,v 1.4 1998/10/14 00:24:16 rnordier Exp $
2
3PROG=		boot2
4NOMAN=
5STRIP=
6BINDIR?=	/boot
7BINMODE=	444
8CLEANFILES+=	boot1 boot1.out boot1.o \
9		boot2.ldr boot2.bin boot2.ld boot2.out boot2.o
10
11M4?=	m4
12
13.if exists(${.OBJDIR}/../btx)
14BTX=	${.OBJDIR}/../btx
15.else
16BTX=	${.CURDIR}/../btx
17.endif
18
19ORG1=	0x7c00
20ORG2=	0x1000
21
22CFLAGS=	-elf -I${.CURDIR}/../btx/lib -I. -fno-builtin \
23	-O2 -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
24	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
25	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
26	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
27
28LDFLAGS=-nostdlib -static -N
29
30all: boot1 boot2
31
32boot1: boot1.out
33	objcopy -S -O binary boot1.out ${.TARGET}
34
35boot1.out: boot1.o
36	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
37
38boot1.o: boot1.m4 boot1.s
39	(cd ${.CURDIR}; ${M4} boot1.m4 boot1.s) | \
40		${AS} ${AFLAGS} -o ${.TARGET}
41
42boot2: boot2.ldr boot2.bin
43	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
44		-o boot2.ld -P 1 boot2.bin
45	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
46		print x " bytes available"; if (x < 0) exit 1 }'
47	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
48
49boot2.ldr:
50	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
51
52boot2.bin: boot2.out
53	objcopy -S -O binary boot2.out ${.TARGET}
54
55boot2.out: boot2.o
56	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
57		${BTX}/lib/crt0.o boot2.o
58
59install:
60	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
61		boot1 ${DESTDIR}${BINDIR}/boot1
62	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
63		boot2 ${DESTDIR}${BINDIR}/boot2
64
65.include <bsd.prog.mk>
66