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