xref: /freebsd/stand/i386/loader/Makefile (revision 994297b01b98816bea1abf45ae4bac1bc69ee7a0)
1# $FreeBSD$
2
3HAVE_ZFS=		${MK_LOADER_ZFS}
4
5LOADER_NET_SUPPORT?=	yes
6LOADER_NFS_SUPPORT?=	yes
7LOADER_TFTP_SUPPORT?=	yes
8LOADER_CD9660_SUPPORT?=	yes
9LOADER_EXT2FS_SUPPORT?=	yes
10LOADER_MSDOS_SUPPORT?=	yes
11LOADER_UFS_SUPPORT?=	yes
12LOADER_GZIP_SUPPORT?=	yes
13LOADER_BZIP2_SUPPORT?=	yes
14
15.include <bsd.init.mk>
16
17LOADER?=	loader_${LOADER_INTERP}
18PROG=		${LOADER}.sym
19INTERNALPROG=
20NEWVERSWHAT?=	"bootstrap loader" x86
21VERSION_FILE=	${.CURDIR}/../loader/version
22
23.PATH:		${BOOTSRC}/i386/loader
24
25# architecture-specific loader code
26SRCS=		main.c conf.c vers.c chain.c gfx_fb.c 8x16.c
27
28CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386
29CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
30CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
31CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
32CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
33
34# Include bcache code.
35HAVE_BCACHE=	yes
36
37# Enable PnP and ISA-PnP code.
38HAVE_PNP=	yes
39HAVE_ISABUS=	yes
40
41.if ${MK_LOADER_FIREWIRE} == "yes"
42CFLAGS+=	-DLOADER_FIREWIRE_SUPPORT
43LIBFIREWIRE=	${BOOTOBJ}/i386/libfirewire/libfirewire.a
44.endif
45
46.if ${MK_LOADER_ZFS} == "yes"
47CFLAGS.main.c+=	-I${SYSDIR}/contrib/openzfs/include
48CFLAGS.main.c+=	-I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
49.endif
50
51.if exists(${.CURDIR}/help.i386)
52HELP_FILES=	${.CURDIR}/help.i386
53.endif
54
55# Always add MI sources
56.include	"${BOOTSRC}/loader.mk"
57
58CLEANFILES+=	${LOADER} ${LOADER}.bin 8x16.c
59
60ORG=		0x0
61
62CFLAGS+=	-Wall
63LDFLAGS+=	-static ${LDFLAGS_ORG} -Wl,--gc-sections
64.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 130000
65# lld 13 and higher default to garbage collecting start/stop symbols,
66# completely ruining our linker sets. For now, work around it by
67# disabling this un-feature.
68LDFLAGS+=	-Wl,-z,nostart-stop-gc
69.endif
70
71# i386 standalone support library
72LIBI386=	${BOOTOBJ}/i386/libi386/libi386.a
73CFLAGS+=	-I${BOOTSRC}/i386
74
75# Debug me!
76#CFLAGS+=	-g
77#LDFLAGS+=	-g
78
798x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf
80	vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC}
81
82${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
83	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
84		-b ${BTXKERN} ${LOADER}.bin
85
86${LOADER}.bin: ${LOADER}.sym
87	${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC}
88
89.if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
90LINKS+=		${BINDIR}/${LOADER} ${BINDIR}/zfsloader
91.endif
92.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
93LINKS+=		${BINDIR}/${LOADER} ${BINDIR}/loader
94.endif
95FILES+=	${LOADER}
96FILESMODE_${LOADER}= ${BINMODE} -b
97
98# Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the
99# startup code is located at the start of the loader and will jump
100# there. Although btx is more flexible than this, the emulated boot2 environment
101# that pxeloader provides has none of that flexibility because it lacks access
102# to the a.out/elf headers and assumes an entry point of 0.
103#
104# We must add it to the LDFLAGS instead of the OBJS because the former won't try
105# to clean it. When it is in OBJS, this cleaning can lead to races where
106# btxcrt.o is rebuilt, but boot2 isn't, leading to errors at installation time.
107# LDFLAGS does not have this baggage and will be included first in the list of
108# files.
109LDFLAGS+=	${BTXCRT}
110
111DPADD=	${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32}
112LDADD=	${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32}
113
114.if ${MACHINE_CPUARCH} == "amd64"
115CFLAGS+=	-DLOADER_PREFER_AMD64
116.endif
117
118.include <bsd.prog.mk>
119