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