1 # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $
2 # $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.7 2004/07/18 23:40:01 dillon Exp $
9 CLEANFILES= boot boot1 boot1.out boot1.o \
10 boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
15 # A value of 0x80 enables LBA support.
18 BOOT_COMCONSOLE_PORT?= 0x3f8
19 BOOT_COMCONSOLE_SPEED?= 9600
22 .if exists(${.OBJDIR}/../btx)
23 BTX= ${.OBJDIR}/../btx
25 BTX= ${.CURDIR}/../btx
32 # Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
34 # BOOT2_UFS?= UFS2_ONLY
35 #BOOT2_UFS?= UFS1_AND_UFS2
39 # -fno-guess-branch-probability
40 # -mno-align-long-strings
42 CFLAGS= -elf -ffreestanding -Os -fno-builtin -fno-stack-protector \
43 -fomit-frame-pointer \
46 -I${.CURDIR}/../../common \
47 -I${.CURDIR}/../btx/lib -I. \
48 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
49 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
50 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
52 LDFLAGS=-nostdlib -static -N --gc-sections
57 cat boot1 boot2 > boot
60 objcopy -S -O binary boot1.out ${.TARGET}
63 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
66 ${CC} ${CFLAGS} -DFLAGS=${B1FLAGS} ${AFLAGS} \
67 ${.IMPSRC} -o ${.TARGET} -c
69 boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c
70 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC}
71 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
73 ${AS} ${AFLAGS} -o boot2.o boot2.s
76 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
78 printf("#define XREADORG %#x\n", REL1 + x) }' \
79 ORG1=`printf "%d" ${ORG1}` \
80 REL1=`printf "%d" ${REL1}` > boot2.h
82 boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
83 btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
84 -o boot2.ld -P 1 boot2.bin
85 @ls -l boot2.ld | awk '{ x = 7680 - $$5; \
86 print x " bytes available"; if (x < 0) exit 1 }'
87 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
90 dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
93 objcopy -S -O binary boot2.out ${.TARGET}
95 boot2.out: boot2.o sio.o
96 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
97 ${BTX}/lib/crt0.o ${.ALLSRC}
102 ${CC} -DSIOPRT=${BOOT_COMCONSOLE_PORT} -DSIOFMT=${B2SIOFMT} \
103 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
104 ${AFLAGS} ${.IMPSRC} -o ${.TARGET} -c
107 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
108 boot ${DESTDIR}${BINDIR}/boot
109 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
110 boot1 ${DESTDIR}${BINDIR}/boot1
111 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
112 boot2 ${DESTDIR}${BINDIR}/boot2
114 .include <bsd.prog.mk>
116 .if defined(REALLY_AMD64)
119 beforedepend ${OBJS}: machine
122 ln -sf ${.CURDIR}/../../../i386/include machine