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