986f372a6eb0b5d6dde243d5ecc9c31e761199a2
[openwrt/staging/yousong.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:=48be0777e32f374d387e9cf85e36ec4d
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 ifeq ($(CONFIG_MUSL_ENABLE_DEBUG),y)
44 MUSL_CONFIGURE+= \
45 --enable-debug
46 endif
47
48 define Host/Prepare
49 $(call Host/Prepare/Default)
50 $(if $(strip $(QUILT)), \
51 cd $(HOST_BUILD_DIR); \
52 if $(QUILT_CMD) next >/dev/null 2>&1; then \
53 $(QUILT_CMD) push -a; \
54 fi
55 )
56 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
57 endef
58
59 define Host/Configure
60 ( cd $(HOST_BUILD_DIR); rm -f config.cache; \
61 $(MUSL_CONFIGURE) \
62 );
63 endef
64
65 define Host/Clean
66 rm -rf \
67 $(HOST_BUILD_DIR) \
68 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
69 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
70 endef