syslinux.mk 3.8 KB

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