xref: /OK3568_Linux_fs/buildroot/package/musl/musl.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun################################################################################
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# musl
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun################################################################################
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunMUSL_VERSION = 1.2.2
8*4882a593SmuzhiyunMUSL_SITE = http://www.musl-libc.org/releases
9*4882a593SmuzhiyunMUSL_LICENSE = MIT
10*4882a593SmuzhiyunMUSL_LICENSE_FILES = COPYRIGHT
11*4882a593SmuzhiyunMUSL_CPE_ID_VENDOR = musl-libc
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun# Before musl is configured, we must have the first stage
14*4882a593Smuzhiyun# cross-compiler and the kernel headers
15*4882a593SmuzhiyunMUSL_DEPENDENCIES = host-gcc-initial linux-headers
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun# musl does not provide an implementation for sys/queue.h or sys/cdefs.h.
18*4882a593Smuzhiyun# So, add the musl-compat-headers package that will install those files,
19*4882a593Smuzhiyun# into the staging directory:
20*4882a593Smuzhiyun#   sys/queue.h:  header from NetBSD
21*4882a593Smuzhiyun#   sys/cdefs.h:  minimalist header bundled in Buildroot
22*4882a593SmuzhiyunMUSL_DEPENDENCIES += musl-compat-headers
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun# musl is part of the toolchain so disable the toolchain dependency
25*4882a593SmuzhiyunMUSL_ADD_TOOLCHAIN_DEPENDENCY = NO
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunMUSL_INSTALL_STAGING = YES
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun# Thumb build is broken, build in ARM mode, since all architectures
30*4882a593Smuzhiyun# that support Thumb1 also support ARM.
31*4882a593Smuzhiyunifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
32*4882a593SmuzhiyunMUSL_EXTRA_CFLAGS += -marm
33*4882a593Smuzhiyunendif
34*4882a593Smuzhiyun
35*4882a593Smuzhiyundefine MUSL_CONFIGURE_CMDS
36*4882a593Smuzhiyun	(cd $(@D); \
37*4882a593Smuzhiyun		$(TARGET_CONFIGURE_OPTS) \
38*4882a593Smuzhiyun		CFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS)) $(MUSL_EXTRA_CFLAGS)" \
39*4882a593Smuzhiyun		CPPFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CPPFLAGS))" \
40*4882a593Smuzhiyun		./configure \
41*4882a593Smuzhiyun			--target=$(GNU_TARGET_NAME) \
42*4882a593Smuzhiyun			--host=$(GNU_TARGET_NAME) \
43*4882a593Smuzhiyun			--prefix=/usr \
44*4882a593Smuzhiyun			--libdir=/lib \
45*4882a593Smuzhiyun			--disable-gcc-wrapper \
46*4882a593Smuzhiyun			--enable-static \
47*4882a593Smuzhiyun			$(if $(BR2_STATIC_LIBS),--disable-shared,--enable-shared))
48*4882a593Smuzhiyunendef
49*4882a593Smuzhiyun
50*4882a593Smuzhiyundefine MUSL_BUILD_CMDS
51*4882a593Smuzhiyun	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
52*4882a593Smuzhiyunendef
53*4882a593Smuzhiyun
54*4882a593Smuzhiyundefine MUSL_INSTALL_STAGING_CMDS
55*4882a593Smuzhiyun	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
56*4882a593Smuzhiyun		DESTDIR=$(STAGING_DIR) install-libs install-tools install-headers
57*4882a593Smuzhiyunendef
58*4882a593Smuzhiyun
59*4882a593Smuzhiyundefine MUSL_INSTALL_TARGET_CMDS
60*4882a593Smuzhiyun	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
61*4882a593Smuzhiyun		DESTDIR=$(TARGET_DIR) install-libs
62*4882a593Smuzhiyun	$(RM) $(addprefix $(TARGET_DIR)/lib/,crt1.o crtn.o crti.o rcrt1.o Scrt1.o)
63*4882a593Smuzhiyunendef
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun$(eval $(generic-package))
66