]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - boot/syslinux/syslinux.mk
syslinux: build with the target toolchain
[coffee/buildroot.git] / boot / syslinux / syslinux.mk
1 ################################################################################
2 #
3 # syslinux to make target msdos/iso9660 filesystems bootable
4 #
5 ################################################################################
6
7 SYSLINUX_VERSION = 6.03
8 SYSLINUX_SOURCE = syslinux-$(SYSLINUX_VERSION).tar.xz
9 SYSLINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/boot/syslinux
10
11 SYSLINUX_LICENSE = GPL-2.0+
12 SYSLINUX_LICENSE_FILES = COPYING
13
14 SYSLINUX_INSTALL_IMAGES = YES
15
16 SYSLINUX_DEPENDENCIES = host-nasm host-upx util-linux
17
18 ifeq ($(BR2_TARGET_SYSLINUX_LEGACY_BIOS),y)
19 SYSLINUX_TARGET += bios
20 endif
21
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
40 # The syslinux tarball comes with pre-compiled binaries.
41 # Since timestamps might not be in the correct order, a rebuild is
42 # not always triggered for all the different images.
43 # Cleanup the mess even before we attempt a build, so we indeed
44 # build everything from source.
45 define SYSLINUX_CLEANUP
46         rm -rf $(@D)/bios $(@D)/efi32 $(@D)/efi64
47 endef
48 SYSLINUX_POST_PATCH_HOOKS += SYSLINUX_CLEANUP
49
50 # syslinux build system has no convenient way to pass CFLAGS,
51 # and the internal zlib should take precedence so -I shouldn't
52 # be used.
53 define SYSLINUX_BUILD_CMDS
54         $(TARGET_MAKE_ENV) $(MAKE1) \
55                 CC="$(TARGET_CC)" \
56                 LD="$(TARGET_LD)" \
57                 NASM="$(HOST_DIR)/usr/bin/nasm" \
58                 CC_FOR_BUILD="$(HOSTCC)" \
59                 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
60                 LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \
61             $(SYSLINUX_EFI_ARGS) -C $(@D) $(SYSLINUX_TARGET)
62 endef
63
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
76 # That 'syslinux' binary is an installer actually built for the target.
77 # However, buildroot makes no usage of it, so better delete it than have it
78 # installed at the wrong place
79 define SYSLINUX_POST_INSTALL_CLEANUP
80         rm -rf $(HOST_DIR)/usr/bin/syslinux
81 endef
82 SYSLINUX_POST_INSTALL_TARGET_HOOKS += SYSLINUX_POST_INSTALL_CLEANUP
83
84 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_ISOLINUX) += bios/core/isolinux.bin
85 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_PXELINUX) += bios/core/pxelinux.bin
86 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_MBR) += bios/mbr/mbr.bin
87 SYSLINUX_IMAGES-$(BR2_TARGET_SYSLINUX_EFI) += $(SYSLINUX_EFI_BITS)/efi/syslinux.efi
88
89 SYSLINUX_C32 = $(call qstrip,$(BR2_TARGET_SYSLINUX_C32))
90
91 # We install the c32 modules from the host-installed tree, where they
92 # are all neatly installed in a single location, while they are
93 # scattered around everywhere in the build tree.
94 define SYSLINUX_INSTALL_IMAGES_CMDS
95         for i in $(SYSLINUX_IMAGES-y); do \
96                 $(INSTALL) -D -m 0755 $(@D)/$$i $(BINARIES_DIR)/syslinux/$${i##*/}; \
97         done
98         for i in $(SYSLINUX_C32); do \
99                 $(INSTALL) -D -m 0755 $(HOST_DIR)/usr/share/syslinux/$${i} \
100                         $(BINARIES_DIR)/syslinux/$${i}; \
101         done
102 endef
103
104 $(eval $(generic-package))