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