1# $FreeBSD$ 2 3.PATH: ${LDRSRC} ${BOOTSRC}/libsa 4 5CFLAGS+=-I${LDRSRC} 6 7SRCS+= boot.c commands.c console.c devopen.c interp.c 8SRCS+= interp_backslash.c interp_parse.c ls.c misc.c 9SRCS+= module.c nvstore.c pnglite.c 10 11CFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite 12 13.PATH: ${SRCTOP}/contrib/pnglite 14CFLAGS.pnglite.c+= -I${SRCTOP}/contrib/pnglite 15CFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 16 17.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" 18SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c 19SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c 20.elif ${MACHINE_CPUARCH} == "aarch64" 21SRCS+= load_elf64.c reloc_elf64.c 22.elif ${MACHINE_CPUARCH} == "arm" 23SRCS+= load_elf32.c reloc_elf32.c 24.elif ${MACHINE_CPUARCH} == "powerpc" 25SRCS+= load_elf32.c reloc_elf32.c 26SRCS+= load_elf64.c reloc_elf64.c 27SRCS+= metadata.c 28.elif ${MACHINE_ARCH:Mmips64*} != "" 29SRCS+= load_elf64.c reloc_elf64.c 30SRCS+= metadata.c 31.elif ${MACHINE} == "mips" 32SRCS+= load_elf32.c reloc_elf32.c 33SRCS+= metadata.c 34.elif ${MACHINE_CPUARCH} == "riscv" 35SRCS+= load_elf64.c reloc_elf64.c 36SRCS+= metadata.c 37.endif 38 39.if ${LOADER_DISK_SUPPORT:Uyes} == "yes" 40CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 41SRCS+= disk.c part.c vdisk.c 42.endif 43 44.if ${LOADER_NET_SUPPORT:Uno} == "yes" 45SRCS+= dev_net.c 46.endif 47 48.if defined(HAVE_BCACHE) 49SRCS+= bcache.c 50.endif 51 52.if defined(MD_IMAGE_SIZE) 53CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE} 54SRCS+= md.c 55.else 56CLEANFILES+= md.o 57.endif 58 59# Machine-independant ISA PnP 60.if defined(HAVE_ISABUS) 61SRCS+= isapnp.c 62.endif 63.if defined(HAVE_PNP) 64SRCS+= pnp.c 65.endif 66 67.if ${LOADER_INTERP} == "lua" 68SRCS+= interp_lua.c 69.include "${BOOTSRC}/lua.mk" 70LDR_INTERP= ${LIBLUA} 71LDR_INTERP32= ${LIBLUA32} 72CFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/modules 73.elif ${LOADER_INTERP} == "4th" 74SRCS+= interp_forth.c 75.include "${BOOTSRC}/ficl.mk" 76LDR_INTERP= ${LIBFICL} 77LDR_INTERP32= ${LIBFICL32} 78.elif ${LOADER_INTERP} == "simp" 79SRCS+= interp_simple.c 80.else 81.error Unknown interpreter ${LOADER_INTERP} 82.endif 83 84.if ${MK_LOADER_VERIEXEC} != "no" 85CFLAGS+= -DLOADER_VERIEXEC -I${SRCTOP}/lib/libsecureboot/h 86.if ${MK_LOADER_VERIEXEC_VECTX} != "no" 87CFLAGS+= -DLOADER_VERIEXEC_VECTX 88.endif 89.endif 90 91.if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} != "no" 92CFLAGS+= -DLOADER_VERIEXEC_PASS_MANIFEST -I${SRCTOP}/lib/libsecureboot/h 93.endif 94 95.if defined(BOOT_PROMPT_123) 96CFLAGS+= -DBOOT_PROMPT_123 97.endif 98 99.if defined(LOADER_INSTALL_SUPPORT) 100SRCS+= install.c 101.endif 102 103# Filesystem support 104.if ${LOADER_CD9660_SUPPORT:Uno} == "yes" 105CFLAGS+= -DLOADER_CD9660_SUPPORT 106.endif 107.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes" 108CFLAGS+= -DLOADER_EXT2FS_SUPPORT 109.endif 110.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes" 111CFLAGS+= -DLOADER_MSDOS_SUPPORT 112.endif 113.if ${LOADER_UFS_SUPPORT:Uyes} == "yes" 114CFLAGS+= -DLOADER_UFS_SUPPORT 115.endif 116 117# Compression 118.if ${LOADER_GZIP_SUPPORT:Uno} == "yes" 119CFLAGS+= -DLOADER_GZIP_SUPPORT 120.endif 121.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes" 122CFLAGS+= -DLOADER_BZIP2_SUPPORT 123.endif 124 125# Network related things 126.if ${LOADER_NET_SUPPORT:Uno} == "yes" 127CFLAGS+= -DLOADER_NET_SUPPORT 128.endif 129.if ${LOADER_NFS_SUPPORT:Uno} == "yes" 130CFLAGS+= -DLOADER_NFS_SUPPORT 131.endif 132.if ${LOADER_TFTP_SUPPORT:Uno} == "yes" 133CFLAGS+= -DLOADER_TFTP_SUPPORT 134.endif 135 136# Partition support 137.if ${LOADER_GPT_SUPPORT:Uyes} == "yes" 138CFLAGS+= -DLOADER_GPT_SUPPORT 139.endif 140.if ${LOADER_MBR_SUPPORT:Uyes} == "yes" 141CFLAGS+= -DLOADER_MBR_SUPPORT 142.endif 143 144.if ${HAVE_ZFS:Uno} == "yes" 145CFLAGS+= -DLOADER_ZFS_SUPPORT 146CFLAGS+= -I${ZFSSRC} 147CFLAGS+= -I${SYSDIR}/cddl/boot/zfs 148CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common 149SRCS+= zfs_cmd.c 150.endif 151 152LIBFICL= ${BOOTOBJ}/ficl/libficl.a 153.if ${MACHINE} == "i386" 154LIBFICL32= ${LIBFICL} 155.else 156LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a 157.endif 158 159LIBLUA= ${BOOTOBJ}/liblua/liblua.a 160.if ${MACHINE} == "i386" 161LIBLUA32= ${LIBLUA} 162.else 163LIBLUA32= ${BOOTOBJ}/liblua32/liblua.a 164.endif 165 166CLEANFILES+= vers.c 167VERSION_FILE?= ${.CURDIR}/version 168.if ${MK_REPRODUCIBLE_BUILD} != no 169REPRO_FLAG= -r 170.endif 171vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE} 172 sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \ 173 ${NEWVERSWHAT} 174 175.if ${MK_LOADER_VERBOSE} != "no" 176CFLAGS+= -DELF_VERBOSE 177.endif 178 179.if !empty(HELP_FILES) 180HELP_FILES+= ${LDRSRC}/help.common 181 182CLEANFILES+= loader.help 183FILES+= loader.help 184 185loader.help: ${HELP_FILES} 186 cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET} 187.endif 188