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