syslinux.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. # Install in a temporary location that eases final install into
  52. # images/ (see corresponding command, below).
  53. # Repeat the target, otherwise syslinux will try to build everything
  54. # Repeat LD (and CC) as it happens that some binaries are linked at
  55. # install-time.
  56. define SYSLINUX_BUILD_CMDS
  57. $(TARGET_MAKE_ENV) $(MAKE1) \
  58. ASCIIDOC_OK=-1 \
  59. A2X_XML_OK=-1 \
  60. CC="$(TARGET_CC)" \
  61. LD="$(TARGET_LD)" \
  62. OBJCOPY="$(TARGET_OBJCOPY)" \
  63. AS="$(TARGET_AS)" \
  64. NASM="$(HOST_DIR)/bin/nasm" \
  65. CC_FOR_BUILD="$(HOSTCC)" \
  66. CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
  67. LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
  68. PYTHON=$(HOST_DIR)/bin/python3 \
  69. $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
  70. $(TARGET_MAKE_ENV) $(MAKE1) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(@D)/br-root.temp \
  71. CC="$(TARGET_CC)" \
  72. LD="$(TARGET_LD)" \
  73. -C $(@D) $(SYSLINUX_TARGET) install
  74. endef
  75. # While the actual bootloader is compiled for the target, several
  76. # utilities for installing the bootloader are meant for the host.
  77. # Repeat the target, otherwise syslinux will try to build everything
  78. # Repeat LD (and CC) as it happens that some binaries are linked at
  79. # install-time.
  80. # Don't use the temporarily-installed br-root.temp: HOST_DIR may be setup
  81. # differently (merged usr, merged bin...)
  82. define SYSLINUX_INSTALL_TARGET_CMDS
  83. $(TARGET_MAKE_ENV) $(MAKE1) $(SYSLINUX_EFI_ARGS) INSTALLROOT=$(HOST_DIR) \
  84. CC="$(TARGET_CC)" \
  85. LD="$(TARGET_LD)" \
  86. -C $(@D) $(SYSLINUX_TARGET) install
  87. endef
  88. # That 'syslinux' binary is an installer actually built for the target.
  89. # However, buildroot makes no usage of it, so better delete it than have it
  90. # installed at the wrong place
  91. define SYSLINUX_POST_INSTALL_CLEANUP
  92. rm -rf $(HOST_DIR)/bin/syslinux
  93. endef
  94. SYSLINUX_POST_INSTALL_TARGET_HOOKS += SYSLINUX_POST_INSTALL_CLEANUP
  95. SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_ISOLINUX) += bios/core/isolinux.bin
  96. SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_PXELINUX) += bios/core/pxelinux.bin
  97. SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_LPXELINUX) += bios/core/lpxelinux.bin
  98. SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_MBR) += bios/mbr/mbr.bin
  99. SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_EFI) += $(SYSLINUX_EFI_BITS)/efi/syslinux.efi
  100. SYSLINUX_C32 = $(call qstrip,$(BR2_TARGET_SYSLINUX_C32))
  101. # We install the c32 modules from the temporarily installed tree, where
  102. # they are all neatly installed in a single location, while they are
  103. # scattered around everywhere in the build tree.
  104. define SYSLINUX_INSTALL_IMAGES_CMDS
  105. for i in $(SYSLINUX_IMAGES-y); do \
  106. $(INSTALL) -D -m 0755 $(@D)/$$i $(BINARIES_DIR)/syslinux/$${i##*/}; \
  107. done
  108. for i in $(SYSLINUX_C32); do \
  109. $(INSTALL) -D -m 0755 $(@D)/br-root.temp/usr/share/syslinux/$${i} \
  110. $(BINARIES_DIR)/syslinux/$${i}; \
  111. done
  112. endef
  113. $(eval $(generic-package))