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