hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
################################################################################
#
# musl
#
################################################################################
 
MUSL_VERSION = 1.2.2
MUSL_SITE = http://www.musl-libc.org/releases
MUSL_LICENSE = MIT
MUSL_LICENSE_FILES = COPYRIGHT
MUSL_CPE_ID_VENDOR = musl-libc
 
# Before musl is configured, we must have the first stage
# cross-compiler and the kernel headers
MUSL_DEPENDENCIES = host-gcc-initial linux-headers
 
# musl does not provide an implementation for sys/queue.h or sys/cdefs.h.
# So, add the musl-compat-headers package that will install those files,
# into the staging directory:
#   sys/queue.h:  header from NetBSD
#   sys/cdefs.h:  minimalist header bundled in Buildroot
MUSL_DEPENDENCIES += musl-compat-headers
 
# musl is part of the toolchain so disable the toolchain dependency
MUSL_ADD_TOOLCHAIN_DEPENDENCY = NO
 
MUSL_INSTALL_STAGING = YES
 
# musl does not build with LTO, so explicitly disable it
# when using a compiler that may have support for LTO
ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
MUSL_EXTRA_CFLAGS += -fno-lto
endif
 
# Thumb build is broken, build in ARM mode, since all architectures
# that support Thumb1 also support ARM.
ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
MUSL_EXTRA_CFLAGS += -marm
endif
 
define MUSL_CONFIGURE_CMDS
   (cd $(@D); \
       $(TARGET_CONFIGURE_OPTS) \
       CFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS)) $(MUSL_EXTRA_CFLAGS)" \
       CPPFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CPPFLAGS))" \
       ./configure \
           --target=$(GNU_TARGET_NAME) \
           --host=$(GNU_TARGET_NAME) \
           --prefix=/usr \
           --libdir=/lib \
           --disable-gcc-wrapper \
           --enable-static \
           $(if $(BR2_STATIC_LIBS),--disable-shared,--enable-shared))
endef
 
define MUSL_BUILD_CMDS
   $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
endef
 
define MUSL_INSTALL_STAGING_CMDS
   $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
       DESTDIR=$(STAGING_DIR) install-libs install-tools install-headers
endef
 
define MUSL_INSTALL_TARGET_CMDS
   $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
       DESTDIR=$(TARGET_DIR) install-libs
   $(RM) $(addprefix $(TARGET_DIR)/lib/,crt1.o crtn.o crti.o rcrt1.o Scrt1.o)
endef
 
$(eval $(generic-package))