]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/boot/i386/boot2/Makefile
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / boot / i386 / boot2 / Makefile
1 # $FreeBSD$
2
3 .include <bsd.own.mk>
4
5 FILES=          boot boot1 boot2
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 # Decide level of UFS support.
21 BOOT2_UFS?=     UFS1_AND_UFS2
22 #BOOT2_UFS?=    UFS2_ONLY
23 #BOOT2_UFS?=    UFS1_ONLY
24
25 CFLAGS= -Os \
26         -fomit-frame-pointer \
27         -mrtd \
28         -mregparm=3 \
29         -DUSE_XREAD \
30         -D${BOOT2_UFS} \
31         -DFLAGS=${BOOT_BOOT1_FLAGS} \
32         -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
33         -DSIOFMT=${B2SIOFMT} \
34         -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
35         -I${.CURDIR}/../../common \
36         -I${.CURDIR}/../btx/lib -I. \
37         -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
38         -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
39         -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
40         -Winline \
41         ${CLANG_OPT_SMALL}
42
43 CFLAGS.gcc+=    -fno-guess-branch-probability \
44                 -fno-unit-at-a-time \
45                 --param max-inline-insns-single=100
46 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
47 CFLAGS.gcc+=   -mno-align-long-strings
48 .endif
49
50 LD_FLAGS=-static -N --gc-sections
51
52 # Pick up ../Makefile.inc early.
53 .include <bsd.init.mk>
54
55 CLEANFILES=     boot
56
57 boot: boot1 boot2
58         cat boot1 boot2 > boot
59
60 CLEANFILES+=    boot1 boot1.out boot1.o
61
62 boot1: boot1.out
63         ${OBJCOPY} -S -O binary boot1.out ${.TARGET}
64
65 boot1.out: boot1.o
66         ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
67
68 CLEANFILES+=    boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
69                 boot2.s boot2.s.tmp boot2.h sio.o
70
71 boot2: boot2.ld
72         @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
73             echo "$$x bytes available"; test $$x -ge 0
74         dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
75
76 boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
77         btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
78             -o ${.TARGET} -P 1 boot2.bin
79
80 boot2.ldr:
81         dd if=/dev/zero of=${.TARGET} bs=512 count=1
82
83 boot2.bin: boot2.out
84         ${OBJCOPY} -S -O binary boot2.out ${.TARGET}
85
86 boot2.out: ${BTXCRT} boot2.o sio.o
87         ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
88
89 boot2.o: boot2.s
90         ${CC} ${ACFLAGS} -c boot2.s
91
92 SRCS=   boot2.c boot2.h
93
94 boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
95         ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
96         sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
97         rm -f boot2.s.tmp
98
99 boot2.h: boot1.out
100         ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
101             { x = $$1 - ORG1; \
102             printf("#define XREADORG %#x\n", REL1 + x) }' \
103             ORG1=`printf "%d" ${ORG1}` \
104             REL1=`printf "%d" ${REL1}` > ${.TARGET}
105
106 .if ${MACHINE_CPUARCH} == "amd64"
107 beforedepend boot2.s: machine
108 CLEANFILES+=    machine
109 machine:
110         ln -sf ${.CURDIR}/../../../i386/include machine
111 .endif
112
113 .include <bsd.prog.mk>
114
115 # XXX: clang integrated-as doesn't grok .codeNN directives yet
116 CFLAGS.boot1.S=         ${CLANG_NO_IAS}
117 CFLAGS+=                ${CFLAGS.${.IMPSRC:T}}