2 # Copyright (C) 2006-2009 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
10 PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION))
12 ifeq ($(PKG_VERSION),2.14)
13 PKG_MD5SUM:=1588cc22e796c296223744895ebc4cef
16 PKG_SOURCE_URL:=@GNU/glibc
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
19 PATCH_DIR:=./patches/$(PKG_VERSION)
21 include $(INCLUDE_DIR)/toolchain-build.mk
23 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.glibc_built
24 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_installed
26 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
27 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
31 ifneq ($(CONFIG_GLIBC_PORTS),)
33 define Host/Prepare/ports
34 ln -snf ../glibc-ports $(HOST_BUILD_DIR)/ports
38 # XXX: {e,}glibc does not build w/ -Os
39 # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
40 GLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
43 BUILD_CC="$(HOSTCC)" \
44 $(TARGET_CONFIGURE_OPTS) \
45 CFLAGS="$(GLIBC_CFLAGS)" \
46 libc_cv_forced_unwind=yes \
47 libc_cv_c_cleanup=yes \
49 libc_cv_slibdir="/lib" \
50 $(HOST_BUILD_DIR)/configure \
52 --build=$(GNU_HOST_NAME) \
53 --host=$(REAL_GNU_TARGET_NAME) \
54 --with-headers="$(TOOLCHAIN_DIR)/include" \
55 $(if $(CONFIG_mips64)$(CONFIG_mips64el), --enable-kernel="2.6.0") \
58 --enable-add-ons="$(GLIBC_ADD_ONS)" \
62 ifeq ($(CONFIG_SOFT_FLOAT),)
70 GLIBC_CONFIGURE_STAGE1:= \
72 --disable-sanity-checks \
73 --enable-hacker-mode \
75 GLIBC_CONFIGURE_STAGE2:= \
81 define Host/SetToolchainInfo
82 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
83 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
84 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
85 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
88 define Stage1/Configure
89 mkdir -p $(HOST_BUILD_DIR1)
90 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
91 $(GLIBC_CONFIGURE_STAGE1) \
99 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
100 CFLAGS="-DBOOTSTRAP_GCC" \
101 cross-compiling=yes \
102 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
104 [ -f $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/include/bits/stdio_lim.h ] || \
105 $(CP) $(HOST_BUILD_DIR1)/bits/stdio_lim.h \
106 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/include/bits/stdio_lim.h
107 [ -f $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/include/gnu/stubs.h ] || \
108 touch $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/include/gnu/stubs.h
111 define Stage2/Configure
112 mkdir -p $(HOST_BUILD_DIR2)
113 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
114 $(GLIBC_CONFIGURE_STAGE2) \
118 define Stage2/Compile
119 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
122 define Stage2/Install
123 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
124 install_root="$(TOOLCHAIN_DIR)" \
126 ( cd $(TOOLCHAIN_DIR) ; \
127 for d in lib usr/lib ; do \
128 for f in libc.so libpthread.so libgcc_s.so ; do \
129 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
130 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
138 $(call Host/SetToolchainInfo)
139 $(call Host/Prepare/Default)
140 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
141 $(call Host/Prepare/ports)
142 $(call Stage1/Configure)
143 $(call Stage1/Compile)
144 $(call Stage1/Install)
147 define Host/Configure
151 $(call Stage2/Configure)
152 $(call Stage2/Compile)
153 $(call Stage2/Install)
164 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
165 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
168 $(eval $(call HostBuild))