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