toolchain: Add glibc 2.22
[openwrt/openwrt.git] / toolchain / glibc / common.mk
1 #
2 # Copyright (C) 2006-2011 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
9 PKG_NAME:=glibc
10 PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION))
11 PKG_REVISION:=$(call qstrip,$(CONFIG_GLIBC_REVISION))
12
13 PKG_SOURCE_PROTO:=git
14 PKG_SOURCE_URL:=git://sourceware.org/git/glibc.git
15 PKG_SOURCE_VERSION:=$(PKG_REVISION)
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REVISION)
17 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
18
19 GLIBC_PATH:=
20 ifneq ($(CONFIG_EGLIBC_VERSION_2_19),)
21 GLIBC_PATH:=libc/
22 PKG_SOURCE_PROTO:=svn
23 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
24 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_19
25 endif
26
27 PATCH_DIR:=$(PATH_PREFIX)/patches/$(PKG_VERSION)
28
29 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
30 CUR_BUILD_DIR:=$(HOST_BUILD_DIR)-$(VARIANT)
31
32 include $(INCLUDE_DIR)/toolchain-build.mk
33
34 HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
35 HOST_STAMP_CONFIGURED:=$(CUR_BUILD_DIR)/.configured
36 HOST_STAMP_BUILT:=$(CUR_BUILD_DIR)/.built
37 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_$(VARIANT)_installed
38
39 ifeq ($(ARCH),mips64)
40 ifdef CONFIG_MIPS64_ABI_N64
41 TARGET_CFLAGS += -mabi=64
42 endif
43 ifdef CONFIG_MIPS64_ABI_N32
44 TARGET_CFLAGS += -mabi=n32
45 endif
46 ifdef CONFIG_MIPS64_ABI_O32
47 TARGET_CFLAGS += -mabi=32
48 endif
49 endif
50
51 GLIBC_CONFIGURE:= \
52 BUILD_CC="$(HOSTCC)" \
53 $(TARGET_CONFIGURE_OPTS) \
54 CFLAGS="$(TARGET_CFLAGS)" \
55 libc_cv_slibdir="/lib" \
56 use_ldconfig=no \
57 $(HOST_BUILD_DIR)/$(GLIBC_PATH)configure \
58 --prefix= \
59 --build=$(GNU_HOST_NAME) \
60 --host=$(REAL_GNU_TARGET_NAME) \
61 --with-headers=$(TOOLCHAIN_DIR)/include \
62 --disable-profile \
63 --disable-werror \
64 --without-gd \
65 --without-cvs \
66 --enable-add-ons \
67 --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp
68
69 export libc_cv_ssp=no
70 export ac_cv_header_cpuid_h=yes
71 export HOST_CFLAGS := $(HOST_CFLAGS) -idirafter $(CURDIR)/$(PATH_PREFIX)/include
72
73 define Host/SetToolchainInfo
74 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
75 ifneq ($(CONFIG_GLIBC_VERSION_2_21),)
76 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
77 else
78 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
79 endif
80 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
81 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
82 endef
83
84 define Host/Configure
85 [ -f $(HOST_BUILD_DIR)/.autoconf ] || { \
86 cd $(HOST_BUILD_DIR)/$(GLIBC_PATH); \
87 autoconf --force && \
88 touch $(HOST_BUILD_DIR)/.autoconf; \
89 }
90 mkdir -p $(CUR_BUILD_DIR)
91 grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(CUR_BUILD_DIR)/option-groups.config
92 ( cd $(CUR_BUILD_DIR); rm -f config.cache; \
93 $(GLIBC_CONFIGURE) \
94 );
95 endef
96
97 define Host/Prepare
98 $(call Host/Prepare/Default)
99 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
100 ifeq ($(CONFIG_GLIBC_VERSION_2_21)$(CONFIG_GLIBC_VERSION_2_22),)
101 $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
102 endif
103 endef
104
105 define Host/Clean
106 rm -rf $(CUR_BUILD_DIR)* \
107 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
108 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
109 endef