]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/boot/i386/zfsboot/Makefile
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / boot / i386 / zfsboot / Makefile
1 # $FreeBSD$
2
3 .PATH:          ${.CURDIR}/../boot2
4
5 FILES=          zfsboot
6
7 NM?=            nm
8
9 # A value of 0x80 enables LBA support.
10 BOOT_BOOT1_FLAGS?=      0x80
11
12 BOOT_COMCONSOLE_PORT?= 0x3f8
13 BOOT_COMCONSOLE_SPEED?= 9600
14 B2SIOFMT?=      0x3
15
16 REL1=   0x700
17 ORG1=   0x7c00
18 ORG2=   0x2000
19
20 CFLAGS= -Os -g \
21         -fno-guess-branch-probability \
22         -fomit-frame-pointer \
23         -fno-unit-at-a-time \
24         -mno-align-long-strings \
25         -mrtd \
26         -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
27         -DBOOT2 \
28         -DFLAGS=${BOOT_BOOT1_FLAGS} \
29         -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
30         -DSIOFMT=${B2SIOFMT} \
31         -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
32         -I${.CURDIR}/../../zfs \
33         -I${.CURDIR}/../../../cddl/boot/zfs \
34         -I${.CURDIR}/../btx/lib -I. \
35         -I${.CURDIR}/../boot2 \
36         -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
37         -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
38         -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
39         -Winline --param max-inline-insns-single=100
40
41 LDFLAGS=-static -N --gc-sections
42
43 # Pick up ../Makefile.inc early.
44 .include <bsd.init.mk>
45
46 CLEANFILES=     zfsboot
47
48 zfsboot: zfsboot1 zfsboot2
49         cat zfsboot1 zfsboot2 > zfsboot
50
51 CLEANFILES+=    zfsboot1 zfsldr.out zfsldr.o
52
53 zfsboot1: zfsldr.out
54         objcopy -S -O binary zfsldr.out ${.TARGET}
55
56 zfsldr.out: zfsldr.o
57         ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
58
59 CLEANFILES+=    zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
60                 zfsboot.o zfsboot.s zfsboot.s.tmp zfsboot.h sio.o
61
62 # We currently allow 32768 bytes for zfsboot - in practice it could be
63 # any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
64
65 BOOT2SIZE=      32768
66
67 zfsboot2: zfsboot.ld
68         @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \
69             echo "$$x bytes available"; test $$x -ge 0
70         dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync
71
72 zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
73         btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
74             -o ${.TARGET} -P 1 zfsboot.bin
75
76 zfsboot.ldr:
77         cp /dev/null ${.TARGET}
78
79 zfsboot.bin: zfsboot.out
80         objcopy -S -O binary zfsboot.out ${.TARGET}
81
82 zfsboot.out: ${BTXCRT} zfsboot.o sio.o
83         ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
84
85 zfsboot.o: zfsboot.s
86
87 SRCS=   zfsboot.c zfsboot.h
88
89 zfsboot.s: zfsboot.c zfsboot.h ${.CURDIR}/../../zfs/zfsimpl.c
90         ${CC} ${CFLAGS} -S -o zfsboot.s.tmp ${.CURDIR}/zfsboot.c
91         sed -e '/align/d' -e '/nop/d' < zfsboot.s.tmp > zfsboot.s
92         rm -f zfsboot.s.tmp
93
94 zfsboot.h: zfsldr.out
95         ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
96             { x = $$1 - ORG1; \
97             printf("#define XREADORG %#x\n", REL1 + x) }' \
98             ORG1=`printf "%d" ${ORG1}` \
99             REL1=`printf "%d" ${REL1}` > ${.TARGET}
100
101 .if ${MACHINE_ARCH} == "amd64"
102 beforedepend zfsboot.s: machine
103 CLEANFILES+=    machine
104 machine:
105         ln -sf ${.CURDIR}/../../../i386/include machine
106 .endif
107
108 .include <bsd.prog.mk>