]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/boot/i386/zfsboot/Makefile
MFC r260334:
[FreeBSD/stable/9.git] / sys / boot / i386 / zfsboot / Makefile
1 # $FreeBSD$
2
3 .PATH:          ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
4
5 FILES=          zfsboot
6
7 NM?=            nm
8
9 BOOT_COMCONSOLE_PORT?= 0x3f8
10 BOOT_COMCONSOLE_SPEED?= 9600
11 B2SIOFMT?=      0x3
12
13 REL1=   0x700
14 ORG1=   0x7c00
15 ORG2=   0x2000
16
17 CFLAGS= -DBOOTPROG=\"zfsboot\" \
18         -O1 \
19         -DBOOT2 \
20         -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
21         -DSIOFMT=${B2SIOFMT} \
22         -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
23         -I${.CURDIR}/../../common \
24         -I${.CURDIR}/../common \
25         -I${.CURDIR}/../../zfs \
26         -I${.CURDIR}/../../../cddl/boot/zfs \
27         -I${.CURDIR}/../btx/lib -I. \
28         -I${.CURDIR}/../boot2 \
29         -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
30         -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
31         -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
32         -Winline
33
34 CFLAGS.gcc+=    --param max-inline-insns-single=100
35
36 LD_FLAGS=-static -N --gc-sections
37
38 # Pick up ../Makefile.inc early.
39 .include <bsd.init.mk>
40
41 CLEANFILES=     zfsboot
42
43 zfsboot: zfsboot1 zfsboot2
44         cat zfsboot1 zfsboot2 > zfsboot
45
46 CLEANFILES+=    zfsboot1 zfsldr.out zfsldr.o
47
48 zfsboot1: zfsldr.out
49         objcopy -S -O binary zfsldr.out ${.TARGET}
50
51 zfsldr.out: zfsldr.o
52         ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
53
54 CLEANFILES+=    zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
55                 zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o
56
57 # We currently allow 65536 bytes for zfsboot - in practice it could be
58 # any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
59
60 BOOT2SIZE=      65536
61
62 zfsboot2: zfsboot.ld
63         @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \
64             echo "$$x bytes available"; test $$x -ge 0
65         dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync
66
67 zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
68         btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
69             -o ${.TARGET} -P 1 zfsboot.bin
70
71 zfsboot.ldr:
72         cp /dev/null ${.TARGET}
73
74 zfsboot.bin: zfsboot.out
75         objcopy -S -O binary zfsboot.out ${.TARGET}
76
77 zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o
78         ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
79
80 SRCS=   zfsboot.c
81
82 .if ${MACHINE_CPUARCH} == "amd64"
83 beforedepend zfsboot.o: machine
84 CLEANFILES+=    machine
85 machine:
86         ln -sf ${.CURDIR}/../../../i386/include machine
87 .endif
88
89 .include <bsd.prog.mk>
90
91 # XXX: clang integrated-as doesn't grok .codeNN directives yet
92 CFLAGS.zfsldr.S=        ${CLANG_NO_IAS}
93 CFLAGS+=                ${CFLAGS.${.IMPSRC:T}}