Makefile revision 48919
11558Srgrimes#	$Id: Makefile,v 1.12 1999/04/05 07:24:51 rnordier Exp $
21558Srgrimes
31558SrgrimesPROG=		boot2
41558SrgrimesNOMAN=
51558SrgrimesSTRIP=
61558SrgrimesBINDIR?=	/boot
71558SrgrimesBINMODE=	444
81558SrgrimesCLEANFILES+=	boot1 boot1.out boot1.o \
91558Srgrimes		boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
101558Srgrimes		sio.o
111558Srgrimes
121558SrgrimesM4?=	m4
131558Srgrimes
141558Srgrimes# A value of 0x80 enables LBA support.
151558SrgrimesB1FLAGS=	0
161558Srgrimes
171558SrgrimesBOOT_COMCONSOLE_PORT?= 0x3f8
181558SrgrimesBOOT_COMCONSOLE_SPEED?= 9600
191558SrgrimesB2SIOFMT?=	0x3
201558Srgrimes
211558Srgrimes.if exists(${.OBJDIR}/../btx)
221558SrgrimesBTX=	${.OBJDIR}/../btx
231558Srgrimes.else
241558SrgrimesBTX=	${.CURDIR}/../btx
251558Srgrimes.endif
261558Srgrimes
271558SrgrimesORG1=	0x7c00
281558SrgrimesORG2=	0x1000
291558Srgrimes
301558SrgrimesCFLAGS=	-elf -I${.CURDIR}/../btx/lib -I. -fno-builtin \
3136997Scharnier	-Os -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
3223672Speter	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
3336997Scharnier	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
3436997Scharnier	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
3550476Speter
361558SrgrimesLDFLAGS=-nostdlib -static -N
371558Srgrimes
381558Srgrimesall: boot1 boot2
391558Srgrimes
401558Srgrimesboot1: boot1.out
411558Srgrimes	objcopy -S -O binary boot1.out ${.TARGET}
421558Srgrimes
4323672Speterboot1.out: boot1.o
441558Srgrimes	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
451558Srgrimes
461558Srgrimesboot1.o: boot1.m4 boot1.s
471558Srgrimes	(cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
4899562Siedowse		${AS} ${AFLAGS} -o ${.TARGET}
4999562Siedowse
50103949Smikeboot2: boot2.ldr boot2.bin
511558Srgrimes	btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
5299562Siedowse		-o boot2.ld -P 1 boot2.bin
531558Srgrimes	@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
5499562Siedowse		print x " bytes available"; if (x < 0) exit 1 }'
551558Srgrimes	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
561558Srgrimes
571558Srgrimesboot2.ldr:
581558Srgrimes	dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
5998542Smckusick
6098542Smckusickboot2.bin: boot2.out
6198542Smckusick	objcopy -S -O binary boot2.out ${.TARGET}
6298542Smckusick
6398542Smckusickboot2.out: boot2.o sio.o
6498542Smckusick	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
6598542Smckusick		${BTX}/lib/crt0.o boot2.o sio.o
66132762Skan
67132762Skansio.o: sio.s
68132762Skan	(cd ${.CURDIR}; ${M4} -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
69132762Skan		-DSIOFMT=${B2SIOFMT} \
70132762Skan		-DSIOSPD=${BOOT_COMCONSOLE_SPEED} sio.s) | \
71132762Skan		${AS} ${AFLAGS} -o ${.TARGET}
7298542Smckusick
731558Srgrimesinstall:
741558Srgrimes	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
751558Srgrimes		boot1 ${DESTDIR}${BINDIR}/boot1
7698542Smckusick	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
77157660Sdwmalone		boot2 ${DESTDIR}${BINDIR}/boot2
78167011Smckusick
79167011Smckusick.include <bsd.prog.mk>
80167011Smckusick