Makefile revision 41008
1279377Simp#	$Id: Makefile,v 1.9 1998/11/05 20:52:25 rnordier Exp $
2279377Simp
3279377SimpPROG=		boot2
4279377SimpNOMAN=
5279377SimpSTRIP=
6279377SimpBINDIR?=	/boot
7279377SimpBINMODE=	444
8279377SimpCLEANFILES+=	boot1 boot1.out boot1.o \
9279377Simp		boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
10279377Simp		sio.o
11279377Simp
12279377SimpM4?=	m4
13279377Simp
14279377SimpB2SIOPRT?=	0x3f8
15279377SimpB2SIOFMT?=	0x3
16279377SimpB2SIODIV?=	0xc
17279377Simp
18279377Simp.if exists(${.OBJDIR}/../btx)
19279377SimpBTX=	${.OBJDIR}/../btx
20279377Simp.else
21279377SimpBTX=	${.CURDIR}/../btx
22279377Simp.endif
23279377Simp
24279377SimpORG1=	0x7c00
25279377SimpORG2=	0x1000
26279377Simp
27279377SimpCFLAGS=	-elf -I${.CURDIR}/../btx/lib -I. -fno-builtin \
28279377Simp	-O2 -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
29279377Simp	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
30279377Simp	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
31279377Simp	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
32279377Simp
33279377SimpLDFLAGS=-nostdlib -static -N
34279377Simp
35279377Simpall: boot1 boot2
36279377Simp
37279377Simpboot1: boot1.out
38279377Simp	objcopy -S -O binary boot1.out ${.TARGET}
39279377Simp
40279377Simpboot1.out: boot1.o
41279377Simp	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
42279377Simp
43279377Simpboot1.o: boot1.m4 boot1.s
44279377Simp	(cd ${.CURDIR}; ${M4} boot1.m4 boot1.s) | \
45279377Simp		${AS} ${AFLAGS} -o ${.TARGET}
46279377Simp
47279377Simpboot2: boot2.ldr boot2.bin
48279377Simp	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
49279377Simp		-o boot2.ld -P 1 boot2.bin
50279377Simp	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
51279377Simp		print x " bytes available"; if (x < 0) exit 1 }'
52279377Simp	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
53279377Simp
54279377Simpboot2.ldr:
55279377Simp	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
56279377Simp
57279377Simpboot2.bin: boot2.out
58279377Simp	objcopy -S -O binary boot2.out ${.TARGET}
59279377Simp
60279377Simpboot2.out: boot2.o sio.o
61279377Simp	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
62279377Simp		${BTX}/lib/crt0.o boot2.o sio.o
63279377Simp
64279377Simpsio.o: sio.s
65279377Simp	(cd ${.CURDIR}; ${M4} -DSIOPRT=${B2SIOPRT} \
66279377Simp		-DSIOFMT=${B2SIOFMT} -DSIODIV=${B2SIODIV} sio.s) | \
67279377Simp		${AS} ${AFLAGS} -o ${.TARGET}
68279377Simp
69279377Simpinstall:
70279377Simp	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
71279377Simp		boot1 ${DESTDIR}${BINDIR}/boot1
72279377Simp	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
73279377Simp		boot2 ${DESTDIR}${BINDIR}/boot2
74279377Simp
75279377Simp.include <bsd.prog.mk>
76279377Simp