diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 34fe86ead994..409a6537df33 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -130,6 +130,7 @@ __DEFAULT_YES_OPTIONS = \ LIBTHR \ LLVM_COV \ LOADER_GELI \ + LOADER_LUA \ LOADER_OFW \ LOADER_UBOOT \ LOCALES \ @@ -197,7 +198,6 @@ __DEFAULT_NO_OPTIONS = \ LIBSOFT \ LOADER_FIREWIRE \ LOADER_FORCE_LE \ - LOADER_LUA \ NAND \ OFED_EXTRA \ OPENLDAP \ diff --git a/stand/defs.mk b/stand/defs.mk index 13314812bc85..2f8d97ae0f2c 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -146,6 +146,18 @@ CFLAGS+= -mlittle-endian .endif .endif +# +# Have a sensible default +# +.if ${MK_FORTH} == "yes" +LOADER_DEFAULT_INTERP?=4th +.elif ${MK_LOADER_LUA} == "yes" +LOADER_DEFAULT_INTERP?=lua +.else +LOADER_DEFAULT_INTERP?=simp +.endif +LOADER_INTERP?=${LOADER_DEFAULT_INTERP} + # Make sure we use the machine link we're about to create CFLAGS+=-I. diff --git a/stand/efi/Makefile b/stand/efi/Makefile index 4f8dc6549662..0772609a7255 100644 --- a/stand/efi/Makefile +++ b/stand/efi/Makefile @@ -9,7 +9,10 @@ NO_OBJ=t .if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 SUBDIR.${MK_FDT}+= fdt -SUBDIR.yes+= libefi loader boot1 +SUBDIR.yes+= libefi boot1 +SUBDIR.${MK_FORTH}+= loader_4th +SUBDIR.${MK_LOADER_LUA}+= loader_lua +SUBDIR.yes+= loader_simp .endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index ecd8acc0cf6b..77f9d598dbc8 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -8,7 +8,8 @@ LOADER_EXT2FS_SUPPORT?= no .include -PROG= loader.sym +LOADER?= loader_${LOADER_INTERP} +PROG= ${LOADER}.sym INTERNALPROG= WARNS?= 3 @@ -24,6 +25,7 @@ SRCS= autoload.c \ smbios.c \ vers.c +CFLAGS+= -I${.CURDIR}/../loader .if ${MK_ZFS} != "no" CFLAGS+= -I${ZFSSRC} CFLAGS+= -DEFI_ZFS_BOOT @@ -41,10 +43,11 @@ CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized # warnings for now. CWARNFLAGS.main.c+= -Wno-format -.PATH: ${.CURDIR}/arch/${MACHINE} -# For smbios.c +.PATH: ${.CURDIR}/../loader +.PATH: ${.CURDIR}/../loader/arch/${MACHINE} +# For smbios.c XXX need to abstract properly .PATH: ${BOOTSRC}/i386/libi386 -.include "${.CURDIR}/arch/${MACHINE}/Makefile.inc" +.include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc" CFLAGS+= -I${.CURDIR} CFLAGS+= -I${.CURDIR}/arch/${MACHINE} @@ -78,20 +81,21 @@ HAVE_BCACHE= yes CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE} .endif +NEWVERSWHAT= "EFI loader" ${MACHINE} +VERSION_FILE= ${.CURDIR}/../loader/version + # Always add MI sources .include "${BOOTSRC}/loader.mk" -FILES+= loader.efi -FILESMODE_loader.efi= ${BINMODE} +FILES+= ${LOADER}.efi +FILESMODE_${LOADER}.efi= ${BINMODE} -LDSCRIPT= ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE} +LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared CLEANFILES+= loader.efi -NEWVERSWHAT= "EFI loader" ${MACHINE} - -loader.efi: ${PROG} +${LOADER}.efi: ${PROG} if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ diff --git a/stand/efi/loader_4th/Makefile b/stand/efi/loader_4th/Makefile new file mode 100644 index 000000000000..3659f7efe673 --- /dev/null +++ b/stand/efi/loader_4th/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +LOADER_INTERP=4th + +.include "../loader/Makefile" + diff --git a/stand/efi/loader_lua/Makefile b/stand/efi/loader_lua/Makefile new file mode 100644 index 000000000000..3a4268440cf6 --- /dev/null +++ b/stand/efi/loader_lua/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +LOADER_INTERP=lua + +.include "../loader/Makefile" + diff --git a/stand/efi/loader_simp/Makefile b/stand/efi/loader_simp/Makefile new file mode 100644 index 000000000000..0c27d5673941 --- /dev/null +++ b/stand/efi/loader_simp/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +LOADER_INTERP=simp + +.include "../loader/Makefile" + diff --git a/stand/i386/Makefile b/stand/i386/Makefile index 36d0f7a1b097..36eba8b1bd59 100644 --- a/stand/i386/Makefile +++ b/stand/i386/Makefile @@ -9,7 +9,9 @@ SUBDIR.yes= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \ SUBDIR.${MK_LOADER_FIREWIRE}+= libfirewire -SUBDIR.yes+= loader +SUBDIR.${MK_FORTH}+= loader_4th +SUBDIR.${MK_LOADER_LUA}+= loader_lua +SUBDIR.yes+= loader_simp # special boot programs, 'self-extracting boot2+loader' SUBDIR.yes+= pxeldr diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index 040641361838..97a5d65145c7 100644 --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -14,7 +14,7 @@ LOADER_BZIP2_SUPPORT?= yes .include -LOADER?= loader +LOADER?= loader_${LOADER_INTERP} PROG= ${LOADER}.sym INTERNALPROG= NEWVERSWHAT?= "bootstrap loader" x86 @@ -64,11 +64,13 @@ ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} ${LOADER}.bin: ${LOADER}.sym strip -R .comment -R .note -o ${.TARGET} ${.ALLSRC} -.if ${MK_ZFS} == "yes" -LINKS= ${BINDIR}/${LOADER} ${BINDIR}/zfs${LOADER} +.if ${MK_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} +LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/zfsloader +.endif +.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} +LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/loader .endif FILES+= ${LOADER} -# XXX INSTALLFLAGS_loader= -b FILESMODE_${LOADER}= ${BINMODE} -b # XXX crt0.o needs to be first for pxeboot(8) to work diff --git a/stand/i386/loader_4th/Makefile b/stand/i386/loader_4th/Makefile new file mode 100644 index 000000000000..3659f7efe673 --- /dev/null +++ b/stand/i386/loader_4th/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +LOADER_INTERP=4th + +.include "../loader/Makefile" + diff --git a/stand/i386/loader_lua/Makefile b/stand/i386/loader_lua/Makefile new file mode 100644 index 000000000000..3a4268440cf6 --- /dev/null +++ b/stand/i386/loader_lua/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +LOADER_INTERP=lua + +.include "../loader/Makefile" + diff --git a/stand/i386/loader_simp/Makefile b/stand/i386/loader_simp/Makefile new file mode 100644 index 000000000000..0c27d5673941 --- /dev/null +++ b/stand/i386/loader_simp/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +LOADER_INTERP=simp + +.include "../loader/Makefile" + diff --git a/stand/i386/pxeldr/Makefile b/stand/i386/pxeldr/Makefile index 819283cf8a2a..b0c9fbe0ee04 100644 --- a/stand/i386/pxeldr/Makefile +++ b/stand/i386/pxeldr/Makefile @@ -24,7 +24,8 @@ CFLAGS+=-DALWAYS_SERIAL CFLAGS+=-I${BOOTSRC}/i386/common -LOADERBIN= ${BOOTOBJ}/i386/loader/loader.bin +L=${LOADER_DEFAULT_INTERP} +LOADERBIN= ${BOOTOBJ}/i386/loader_${L}/loader_${L}.bin CLEANFILES+= ${BOOT}.tmp diff --git a/stand/loader.mk b/stand/loader.mk index beac0028f150..f0d6859764ea 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -57,19 +57,20 @@ SRCS+= isapnp.c SRCS+= pnp.c .endif -# Forth interpreter -.if ${MK_LOADER_LUA} != "no" +.if ${LOADER_INTERP} == "lua" SRCS+= interp_lua.c .include "${BOOTSRC}/lua.mk" LDR_INTERP= ${LIBLUA} LDR_INTERP32= ${LIBLUA32} -.elif ${MK_FORTH} != "no" +.elif ${LOADER_INTERP} == "4th" SRCS+= interp_forth.c .include "${BOOTSRC}/ficl.mk" LDR_INTERP= ${LIBFICL} LDR_INTERP32= ${LIBFICL32} -.else +.elif ${LOADER_INTERP} == "simp" SRCS+= interp_simple.c +.else +.error Unknown interpreter ${LOADER_INTERP} .endif .if defined(BOOT_PROMPT_123)