]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - stand/i386/boot2/Makefile
MFV 331702:
[FreeBSD/FreeBSD.git] / stand / i386 / boot2 / Makefile
1 # $FreeBSD$
2
3 .include <bsd.init.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+=-fomit-frame-pointer \
26         -mrtd \
27         -mregparm=3 \
28         -D${BOOT2_UFS} \
29         -DFLAGS=${BOOT_BOOT1_FLAGS} \
30         -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
31         -DSIOFMT=${B2SIOFMT} \
32         -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
33         -I${LDRSRC} \
34         -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
35         -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
36         -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
37         -Winline
38
39 CFLAGS.gcc+=    -Os \
40                 -fno-asynchronous-unwind-tables \
41                 --param max-inline-insns-single=100
42 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
43 CFLAGS.gcc+=   -mno-align-long-strings
44 .endif
45
46 CFLAGS.clang+=  -Oz ${CLANG_OPT_SMALL}
47
48 LD_FLAGS+=${LD_FLAGS_BIN}
49
50 CLEANFILES+=    boot
51
52 boot: boot1 boot2
53         cat boot1 boot2 > boot
54
55 CLEANFILES+=    boot1 boot1.out boot1.o
56
57 boot1: boot1.out
58         ${OBJCOPY} -S -O binary boot1.out ${.TARGET}
59
60 boot1.out: boot1.o
61         ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
62
63 CLEANFILES+=    boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
64                 boot2.h sio.o
65
66 BOOT2SIZE=      7680
67
68 boot2: boot2.ld
69         @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
70             echo "$$x bytes available"; test $$x -ge 0
71         ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync
72
73 boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
74         btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
75             -o ${.TARGET} -P 1 boot2.bin
76
77 boot2.ldr:
78         ${DD} if=/dev/zero of=${.TARGET} bs=512 count=1
79
80 boot2.bin: boot2.out
81         ${OBJCOPY} -S -O binary boot2.out ${.TARGET}
82
83 boot2.out: ${BTXCRT} boot2.o sio.o
84         ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
85
86 SRCS=   boot2.c boot2.h
87
88 boot2.h: boot1.out
89         ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
90             { x = $$1 - ORG1; \
91             printf("#define XREADORG %#x\n", REL1 + x) }' \
92             ORG1=`printf "%d" ${ORG1}` \
93             REL1=`printf "%d" ${REL1}` > ${.TARGET}
94
95 .include <bsd.prog.mk>
96
97 # XXX: clang integrated-as doesn't grok .codeNN directives yet
98 CFLAGS.boot1.S=         ${CLANG_NO_IAS}