fe5d4bf9d0e8eb3fe789a8e58138d73ae64fb5c0
[openwrt/openwrt.git] / toolchain / musl / common.mk
1 #
2 # Copyright (C) 2012-2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/target.mk
9
10 PKG_NAME:=musl
11 PKG_VERSION:=$(call qstrip,$(CONFIG_MUSL_VERSION))
12 PKG_RELEASE=1
13
14 PKG_MD5SUM:=42875e0c111aa1cb9d08663f8d42c799
15
16 PKG_SOURCE_URL:=http://www.musl-libc.org/releases
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
18 LIBC_SO_VERSION:=$(PKG_VERSION)
19 PATCH_DIR:=$(PATH_PREFIX)/patches
20
21 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
22
23 include $(INCLUDE_DIR)/toolchain-build.mk
24 include $(INCLUDE_DIR)/hardening.mk
25
26 # Please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67260
27 ifeq ($(CONFIG_sh3),y)
28 TARGET_CFLAGS+= \
29 -fno-optimize-sibling-calls
30 endif
31
32 MUSL_CONFIGURE:= \
33 $(TARGET_CONFIGURE_OPTS) \
34 CFLAGS="$(TARGET_CFLAGS)" \
35 CROSS_COMPILE="$(TARGET_CROSS)" \
36 $(HOST_BUILD_DIR)/configure \
37 --prefix=/ \
38 --host=$(GNU_HOST_NAME) \
39 --target=$(REAL_GNU_TARGET_NAME) \
40 --disable-gcc-wrapper \
41 --enable-debug
42
43 define Host/Prepare
44 $(call Host/Prepare/Default)
45 $(if $(strip $(QUILT)), \
46 cd $(HOST_BUILD_DIR); \
47 if $(QUILT_CMD) next >/dev/null 2>&1; then \
48 $(QUILT_CMD) push -a; \
49 fi
50 )
51 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
52 endef
53
54 define Host/Configure
55 ( cd $(HOST_BUILD_DIR); rm -f config.cache; \
56 $(MUSL_CONFIGURE) \
57 );
58 endef
59
60 define Host/Clean
61 rm -rf \
62 $(HOST_BUILD_DIR) \
63 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
64 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
65 endef