syslinux.mk 3.6 KB

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