1*4882a593Smuzhiyun################################################################################ 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# syslinux to make target msdos/iso9660 filesystems bootable 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun################################################################################ 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunSYSLINUX_VERSION = 6.03 8*4882a593SmuzhiyunSYSLINUX_SOURCE = syslinux-$(SYSLINUX_VERSION).tar.xz 9*4882a593SmuzhiyunSYSLINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/boot/syslinux 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunSYSLINUX_LICENSE = GPL-2.0+ 12*4882a593SmuzhiyunSYSLINUX_LICENSE_FILES = COPYING 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunSYSLINUX_INSTALL_IMAGES = YES 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun# host-util-linux needed to provide libuuid when building host tools 17*4882a593SmuzhiyunSYSLINUX_DEPENDENCIES = \ 18*4882a593Smuzhiyun host-nasm \ 19*4882a593Smuzhiyun host-python3 \ 20*4882a593Smuzhiyun host-upx \ 21*4882a593Smuzhiyun host-util-linux \ 22*4882a593Smuzhiyun util-linux 23*4882a593Smuzhiyun 24*4882a593Smuzhiyunifeq ($(BR2_TARGET_SYSLINUX_LEGACY_BIOS),y) 25*4882a593SmuzhiyunSYSLINUX_TARGET += bios 26*4882a593Smuzhiyunendif 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun# The syslinux build system must be forced to use Buildroot's gnu-efi 29*4882a593Smuzhiyun# package by setting EFIINC, LIBDIR and LIBEFI. Otherwise, it uses its 30*4882a593Smuzhiyun# own copy of gnu-efi included in syslinux's sources since 6.03 31*4882a593Smuzhiyun# release. 32*4882a593Smuzhiyunifeq ($(BR2_TARGET_SYSLINUX_EFI),y) 33*4882a593Smuzhiyunifeq ($(BR2_ARCH_IS_64),y) 34*4882a593SmuzhiyunSYSLINUX_EFI_BITS = efi64 35*4882a593Smuzhiyunelse 36*4882a593SmuzhiyunSYSLINUX_EFI_BITS = efi32 37*4882a593Smuzhiyunendif # 64-bit 38*4882a593SmuzhiyunSYSLINUX_DEPENDENCIES += gnu-efi 39*4882a593SmuzhiyunSYSLINUX_TARGET += $(SYSLINUX_EFI_BITS) 40*4882a593SmuzhiyunSYSLINUX_EFI_ARGS = \ 41*4882a593Smuzhiyun EFIINC=$(STAGING_DIR)/usr/include/efi \ 42*4882a593Smuzhiyun LIBDIR=$(STAGING_DIR)/usr/lib \ 43*4882a593Smuzhiyun LIBEFI=$(STAGING_DIR)/usr/lib/libefi.a 44*4882a593Smuzhiyunendif # EFI 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun# The syslinux tarball comes with pre-compiled binaries. 47*4882a593Smuzhiyun# Since timestamps might not be in the correct order, a rebuild is 48*4882a593Smuzhiyun# not always triggered for all the different images. 49*4882a593Smuzhiyun# Cleanup the mess even before we attempt a build, so we indeed 50*4882a593Smuzhiyun# build everything from source. 51*4882a593Smuzhiyundefine SYSLINUX_CLEANUP 52*4882a593Smuzhiyun rm -rf $(@D)/bios $(@D)/efi32 $(@D)/efi64 53*4882a593Smuzhiyunendef 54*4882a593SmuzhiyunSYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun# syslinux build system has no convenient way to pass CFLAGS, 57*4882a593Smuzhiyun# and the internal zlib should take precedence so -I shouldn't 58*4882a593Smuzhiyun# be used. 59*4882a593Smuzhiyundefine SYSLINUX_BUILD_CMDS 60*4882a593Smuzhiyun $(TARGET_MAKE_ENV) $(MAKE1) \ 61*4882a593Smuzhiyun CC="$(TARGET_CC)" \ 62*4882a593Smuzhiyun LD="$(TARGET_LD)" \ 63*4882a593Smuzhiyun OBJCOPY="$(TARGET_OBJCOPY)" \ 64*4882a593Smuzhiyun AS="$(TARGET_AS)" \ 65*4882a593Smuzhiyun NASM="$(HOST_DIR)/bin/nasm" \ 66*4882a593Smuzhiyun CC_FOR_BUILD="$(HOSTCC)" \ 67*4882a593Smuzhiyun CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \ 68*4882a593Smuzhiyun LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \ 69*4882a593Smuzhiyun PYTHON=$(HOST_DIR)/bin/python3 \ 70*4882a593Smuzhiyun $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET) 71*4882a593Smuzhiyunendef 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun# While the actual bootloader is compiled for the target, several 74*4882a593Smuzhiyun# utilities for installing the bootloader are meant for the host. 75*4882a593Smuzhiyun# Repeat the target, otherwise syslinux will try to build everything 76*4882a593Smuzhiyun# Repeat LD (and CC) as it happens that some binaries are linked at 77*4882a593Smuzhiyun# install-time. 78*4882a593Smuzhiyundefine SYSLINUX_INSTALL_TARGET_CMDS 79*4882a593Smuzhiyun $(TARGET_MAKE_ENV) $(MAKE1) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \ 80*4882a593Smuzhiyun CC="$(TARGET_CC)" \ 81*4882a593Smuzhiyun LD="$(TARGET_LD)" \ 82*4882a593Smuzhiyun -C $(@D) $(SYSLINUX_TARGET) install 83*4882a593Smuzhiyunendef 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun# That 'syslinux' binary is an installer actually built for the target. 86*4882a593Smuzhiyun# However, buildroot makes no usage of it, so better delete it than have it 87*4882a593Smuzhiyun# installed at the wrong place 88*4882a593Smuzhiyundefine SYSLINUX_POST_INSTALL_CLEANUP 89*4882a593Smuzhiyun rm -rf $(HOST_DIR)/bin/syslinux 90*4882a593Smuzhiyunendef 91*4882a593SmuzhiyunSYSLINUX_POST_INSTALL_TARGET_HOOKS += SYSLINUX_POST_INSTALL_CLEANUP 92*4882a593Smuzhiyun 93*4882a593SmuzhiyunSYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_ISOLINUX) += bios/core/isolinux.bin 94*4882a593SmuzhiyunSYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_PXELINUX) += bios/core/pxelinux.bin 95*4882a593SmuzhiyunSYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_MBR) += bios/mbr/mbr.bin 96*4882a593SmuzhiyunSYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_EFI) += $(SYSLINUX_EFI_BITS)/efi/syslinux.efi 97*4882a593Smuzhiyun 98*4882a593SmuzhiyunSYSLINUX_C32 = $(call qstrip,$(BR2_TARGET_SYSLINUX_C32)) 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun# We install the c32 modules from the host-installed tree, where they 101*4882a593Smuzhiyun# are all neatly installed in a single location, while they are 102*4882a593Smuzhiyun# scattered around everywhere in the build tree. 103*4882a593Smuzhiyundefine SYSLINUX_INSTALL_IMAGES_CMDS 104*4882a593Smuzhiyun for i in $(SYSLINUX_IMAGES-y); do \ 105*4882a593Smuzhiyun $(INSTALL) -D -m 0755 $(@D)/$$i $(BINARIES_DIR)/syslinux/$${i##*/}; \ 106*4882a593Smuzhiyun done 107*4882a593Smuzhiyun for i in $(SYSLINUX_C32); do \ 108*4882a593Smuzhiyun $(INSTALL) -D -m 0755 $(HOST_DIR)/share/syslinux/$${i} \ 109*4882a593Smuzhiyun $(BINARIES_DIR)/syslinux/$${i}; \ 110*4882a593Smuzhiyun done 111*4882a593Smuzhiyunendef 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun$(eval $(generic-package)) 114