xref: /freebsd/stand/i386/loader/Makefile (revision 315ee00f)
1
2HAVE_ZFS=		${MK_LOADER_ZFS}
3
4LOADER_NET_SUPPORT?=	yes
5LOADER_NFS_SUPPORT?=	yes
6LOADER_TFTP_SUPPORT?=	yes
7LOADER_CD9660_SUPPORT?=	yes
8LOADER_EXT2FS_SUPPORT?=	yes
9LOADER_MSDOS_SUPPORT?=	yes
10LOADER_UFS_SUPPORT?=	yes
11LOADER_GZIP_SUPPORT?=	yes
12LOADER_BZIP2_SUPPORT?=	yes
13
14.include <bsd.init.mk>
15
16LOADER?=	loader_${LOADER_INTERP}
17PROG=		${LOADER}.sym
18INTERNALPROG=
19NEWVERSWHAT?=	"bootstrap loader" x86
20VERSION_FILE=	${.CURDIR}/../loader/version
21#
22# There's 640k - 40k maximum space, less however much memory the BIOS uses.  A
23# non-random survey suggests that 20k-25k is a good value for 'most' machines.
24# We also need to subtract maximum stack usage (20-25k).
25#
26# So 640k - 40k - 25k - 25k = 550k = 563,200 bytes, but use 550,000 below for
27# some extra buffer for more complex setups and/or wider BIOS lomem variation.
28#
29# Some systems use more stack or have BIOS reserve more RAM (or both), and will
30# need to set this lower in /etc/src.conf if the above buffer is too small.
31#
32# sudo dd if=/dev/mem bs=1 iseek=0x413 count=2 | hd -d
33#
34# will tell you how many kiB of lomem are available.
35#
36LOADERSIZE?=	550000		# Largest known safe size for loader.bin
37
38.PATH:		${BOOTSRC}/i386/loader
39
40# architecture-specific loader code
41SRCS=		main.c conf.c vers.c chain.c gfx_fb.c 8x16.c
42
43CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386
44CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
45CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
46CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
47CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
48
49# Include bcache code.
50HAVE_BCACHE=	yes
51
52# Enable PnP and ISA-PnP code.
53HAVE_PNP=	yes
54HAVE_ISABUS=	yes
55
56.if ${MK_LOADER_ZFS} == "yes"
57CFLAGS.main.c+=	-I${SYSDIR}/contrib/openzfs/include
58CFLAGS.main.c+=	-I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
59.endif
60
61.if exists(${.CURDIR}/help.i386)
62HELP_FILES=	${.CURDIR}/help.i386
63.endif
64HELP_FILENAME=	loader.help.bios
65
66# Always add MI sources
67.include	"${BOOTSRC}/loader.mk"
68
69CLEANFILES+=	${LOADER} ${LOADER}.bin 8x16.c
70
71ORG=		0x0
72
73CFLAGS+=	-Wall
74LDFLAGS+=	-static ${LDFLAGS_ORG} -Wl,--gc-sections
75.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 130000
76# lld 13 and higher default to garbage collecting start/stop symbols,
77# completely ruining our linker sets. For now, work around it by
78# disabling this un-feature.
79LDFLAGS+=	-Wl,-z,nostart-stop-gc
80.endif
81
82# i386 standalone support library
83LIBI386=	${BOOTOBJ}/i386/libi386/libi386.a
84CFLAGS+=	-I${BOOTSRC}/i386
85
86# Debug me!
87#CFLAGS+=	-g
88#LDFLAGS+=	-g
89
908x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf
91	vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC}
92
93
94${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
95	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
96		-b ${BTXKERN} ${LOADER}.bin
97
98${LOADER}.bin: ${LOADER}.sym
99	${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC}
100	@set -- `ls -l ${.TARGET}` ; x=$$((${LOADERSIZE}-$$5)); \
101	    echo "$$x bytes available"; test $$x -ge 0
102
103.if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
104LINKS+=		${BINDIR}/${LOADER} ${BINDIR}/zfsloader
105.endif
106.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
107LINKS+=		${BINDIR}/${LOADER} ${BINDIR}/loader
108.endif
109FILES+=	${LOADER}
110FILESMODE_${LOADER}= ${BINMODE} -b
111
112# Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the
113# startup code is located at the start of the loader and will jump
114# there. Although btx is more flexible than this, the emulated boot2 environment
115# that pxeldr provides has none of that flexibility assumes an entry point of
116# 0. In addition, pxeldr and cdboot assume that it is loading an a.out file.
117#
118# We must add it to the LDFLAGS instead of the OBJS because the former won't try
119# to clean it. When it is in OBJS, this cleaning can lead to races where
120# btxcrt.o is rebuilt, but boot2 isn't, leading to errors at installation time.
121# LDFLAGS does not have this baggage and will be included first in the list of
122# files.
123LDFLAGS+=	${BTXCRT}
124
125DPADD=	${LDR_INTERP32} ${LIBI386} ${LIBSA32}
126LDADD=	${LDR_INTERP32} ${LIBI386} ${LIBSA32}
127
128.if ${MACHINE_CPUARCH} == "amd64"
129CFLAGS+=	-DLOADER_PREFER_AMD64
130.endif
131
132.include <bsd.prog.mk>
133