1 # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $
2 # $DragonFly: src/sys/boot/i386/boot2/Makefile,v 1.17 2006/08/12 07:42:26 swildner Exp $
9 CLEANFILES
= boot boot1 boot1.out boot1.o \
10 boot2.ldr boot2.bin boot2.
ld boot2.out boot2.o boot2.h \
19 # A value of 0x80 enables LBA support.
22 BOOT_COMCONSOLE_PORT?
= 0x3f8
23 BOOT_COMCONSOLE_SPEED?
= 9600
26 .if exists
(${.OBJDIR
}/..
/btx
)
27 BTX
= ${.OBJDIR
}/..
/btx
29 BTX
= ${.CURDIR
}/..
/btx
32 # These origins are taken from bootasm.h.
34 REL1
= `${.OBJDIR}/bootasmdef.nx BOOT1_ORIGIN`
35 REL1D
= `${.OBJDIR}/bootasmdef.nx -d BOOT1_ORIGIN`
36 ORG1
= `${.OBJDIR}/bootasmdef.nx MEM_BIOS_LADDR`
37 ORG1D
= `${.OBJDIR}/bootasmdef.nx -d MEM_BIOS_LADDR`
39 # WARNING! The ORG2 calculation is the origin of boot2.bin relative to
40 # the start of the BTX *USER* address space, not the start of physical
43 ORG2
= `${.OBJDIR}/bootasmdef.nx BOOT2_VORIGIN`
45 # Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
47 # BOOT2_UFS?= UFS2_ONLY
48 #BOOT2_UFS?= UFS1_AND_UFS2
52 # -fno-guess-branch-probability
53 # -mno-align-long-strings
54 CFLAGS
= -elf
-ffreestanding
-Os
-fno-builtin \
55 -fomit-frame-pointer \
57 -I
${.CURDIR
}/..
/..
/common \
58 -I
${.CURDIR
}/..
/btx
/lib
-I. \
59 -Wall
-Waggregate-return
-Wbad-function-cast
-Wcast-align \
60 -Wmissing-declarations
-Wmissing-prototypes
-Wnested-externs \
61 -Wpointer-arith
-Wshadow
-Wstrict-prototypes
-Wwrite-strings \
64 # Unfortunately, unit-at-a-time creates issues as yet
65 # not tracked down, in boot2, so we have to turn it off. Note that
66 # the problem has been narrowed down to the 'boot2' code. The /boot/loader
67 # doesn't seem to have a problem.
69 CFLAGS
+= -fno-unit-at-a-time
71 # Disable propolice on gcc that supports it
72 .if
${CCVER} == "gcc34"
73 CFLAGS
+= -fno-stack-protector
76 LDFLAGS
=-nostdlib
-static
-N
--gc-sections
81 cat boot1 boot2
> boot
84 objcopy
-S
-O binary boot1.out
${.TARGET
}
86 boot1.out
: boot1.o bootasmdef.nx
87 ${LD} ${LDFLAGS} -e start
-Ttext
${ORG1} -o
${.TARGET
} boot1.o
90 ${CC} ${CFLAGS} -DFLAGS
=${B1FLAGS} ${AFLAGS} \
91 ${.IMPSRC
} -o
${.TARGET
} -c
93 boot2.o
: boot2.c
${.CURDIR
}/..
/..
/common
/ufsread.c
94 ${CC} ${CFLAGS} -S
-o boot2.s.tmp
${.IMPSRC
}
95 sed
-e
'/align/d' -e
'/nop/d' < boot2.s.tmp
> boot2.s
97 ${AS} ${AFLAGS} -o boot2.o boot2.s
99 boot2.h
: boot1.out bootasmdef.nx
100 @echo
"NOTE: boot2 using xread from boot1 at ${REL1}"
101 ${NM} -t d
${.ALLSRC
} | awk
'/([0-9])+ T xread/ \
103 printf("#define XREADORG %#x\n", REL1 + x) }' \
104 ORG1
=${ORG1D} REL1
=${REL1D} > boot2.h
106 boot2
: boot2.ldr boot2.bin
${BTX}/btx
/btx
107 btxld
-v
-E
${ORG2} -f bin
-b
${BTX}/btx
/btx
-l boot2.ldr \
108 -o boot2.
ld -P
1 boot2.bin
109 @stat boot2.
ld | awk
'{ x = 7680 - $$8; \
110 print x " bytes available"; if (x < 0) exit 1 }'
111 dd if
=boot2.
ld of
=${.TARGET
} obs
=7680 conv
=osync
2>/dev
/null
114 dd if
=/dev
/zero of
=${.TARGET
} bs
=512 count
=1 2>/dev
/null
117 objcopy
-S
-O binary boot2.out
${.TARGET
}
119 boot2.out
: boot2.o sio.o
120 ${LD} ${LDFLAGS} -Ttext
${ORG2} -o
${.TARGET
} \
121 ${BTX}/lib
/crt0.o
${.ALLSRC
}
126 ${CC} -DSIOPRT
=${BOOT_COMCONSOLE_PORT} -DSIOFMT
=${B2SIOFMT} \
127 -DSIOSPD
=${BOOT_COMCONSOLE_SPEED} ${AFLAGS} \
128 ${.IMPSRC
} -o
${.TARGET
} -c
131 ${INSTALL} -o
${BINOWN} -g
${BINGRP} -m
${BINMODE} \
132 boot
${DESTDIR}${BINDIR}/boot
133 ${INSTALL} -o
${BINOWN} -g
${BINGRP} -m
${BINMODE} \
134 boot1
${DESTDIR}${BINDIR}/boot1
135 ${INSTALL} -o
${BINOWN} -g
${BINGRP} -m
${BINMODE} \
136 boot2
${DESTDIR}${BINDIR}/boot2
138 .
include <bsd.prog.mk
>
140 .if defined
(REALLY_AMD64
)
143 beforedepend
${OBJS}: machine
146 ${LN} -sf
${.CURDIR
}/..
/..
/..
/i386
/include machine
151 CLEANFILES
+= bootasmdef.nx