aboutsummaryrefslogtreecommitdiff
path: root/stand/i386/loader/Makefile
blob: dcae7bd67a149dd8b2d19672446778efdec23180 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# $FreeBSD$

HAVE_ZFS=		${MK_LOADER_ZFS}

LOADER_NET_SUPPORT?=	yes
LOADER_NFS_SUPPORT?=	yes
LOADER_TFTP_SUPPORT?=	yes
LOADER_CD9660_SUPPORT?=	yes
LOADER_EXT2FS_SUPPORT?=	yes
LOADER_MSDOS_SUPPORT?=	yes
LOADER_UFS_SUPPORT?=	yes
LOADER_GZIP_SUPPORT?=	yes
LOADER_BZIP2_SUPPORT?=	yes

.include <bsd.init.mk>

LOADER?=	loader_${LOADER_INTERP}
PROG=		${LOADER}.sym
INTERNALPROG=
NEWVERSWHAT?=	"bootstrap loader" x86
VERSION_FILE=	${.CURDIR}/../loader/version

.PATH:		${BOOTSRC}/i386/loader

# architecture-specific loader code
SRCS=		main.c conf.c vers.c chain.c gfx_fb.c 8x16.c

CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386
CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib

# Include bcache code.
HAVE_BCACHE=	yes

# Enable PnP and ISA-PnP code.
HAVE_PNP=	yes
HAVE_ISABUS=	yes

.if ${MK_LOADER_FIREWIRE} == "yes"
CFLAGS+=	-DLOADER_FIREWIRE_SUPPORT
LIBFIREWIRE=	${BOOTOBJ}/i386/libfirewire/libfirewire.a
.endif

.if ${MK_LOADER_ZFS} == "yes"
CFLAGS.main.c+=	-I${SYSDIR}/contrib/openzfs/include
CFLAGS.main.c+=	-I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
.endif

.if exists(${.CURDIR}/help.i386)
HELP_FILES=	${.CURDIR}/help.i386
.endif

# Always add MI sources
.include	"${BOOTSRC}/loader.mk"

CLEANFILES+=	${LOADER} ${LOADER}.bin 8x16.c

ORG=		0x0

CFLAGS+=	-Wall
LDFLAGS+=	-static ${LDFLAGS_ORG} -Wl,--gc-sections

# i386 standalone support library
LIBI386=	${BOOTOBJ}/i386/libi386/libi386.a
CFLAGS+=	-I${BOOTSRC}/i386

# Debug me!
#CFLAGS+=	-g
#LDFLAGS+=	-g

8x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf
	vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC}

${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
		-b ${BTXKERN} ${LOADER}.bin

${LOADER}.bin: ${LOADER}.sym
	${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC}

.if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
LINKS+=		${BINDIR}/${LOADER} ${BINDIR}/zfsloader
.endif
.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
LINKS+=		${BINDIR}/${LOADER} ${BINDIR}/loader
.endif
FILES+=	${LOADER}
FILESMODE_${LOADER}= ${BINMODE} -b

# Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the
# startup code is located at the start of the loader and will jump
# there. Although btx is more flexible than this, the emulated boot2 environment
# that pxeloader provides has none of that flexibility because it lacks access
# to the a.out/elf headers and assumes an entry point of 0.
#
# We must add it to the LDFLAGS instead of the OBJS becauce the former won't try
# to clean it. When it is in OBJS, this cleaning can lead to races where
# btxcrt.o is rebuilt, but boot2 isn't, leading to errors at installation time.
# LDFLAGS does not have this baggage and will be included first in the list of
# files.
LDFLAGS+=	${BTXCRT}

DPADD=	${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32}
LDADD=	${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32}

.if ${MACHINE_CPUARCH} == "amd64"
CFLAGS+=	-DLOADER_PREFER_AMD64
.endif

.include <bsd.prog.mk>