glibc: remove all previous (ancient) versions, add 2.14 (partially based on a patch...
[openwrt/staging/lynxis/omap.git] / toolchain / glibc / Makefile
1 #
2 # Copyright (C) 2006-2009 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.14)
13 PKG_MD5SUM:=1588cc22e796c296223744895ebc4cef
14 endif
15
16 PKG_SOURCE_URL:=@GNU/glibc
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
18
19 PATCH_DIR:=./patches/$(PKG_VERSION)
20
21 include $(INCLUDE_DIR)/toolchain-build.mk
22
23 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.glibc_built
24 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_installed
25
26 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
27 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
28
29 GLIBC_ADD_ONS+=nptl,
30
31 ifneq ($(CONFIG_GLIBC_PORTS),)
32 GLIBC_ADD_ONS+=ports,
33 define Host/Prepare/ports
34 ln -snf ../glibc-ports $(HOST_BUILD_DIR)/ports
35 endef
36 endif
37
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))
41
42 GLIBC_CONFIGURE:= \
43 BUILD_CC="$(HOSTCC)" \
44 $(TARGET_CONFIGURE_OPTS) \
45 CFLAGS="$(GLIBC_CFLAGS)" \
46 libc_cv_forced_unwind=yes \
47 libc_cv_c_cleanup=yes \
48 libc_cv_386_tls=yes \
49 libc_cv_slibdir="/lib" \
50 $(HOST_BUILD_DIR)/configure \
51 --prefix= \
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") \
56 --disable-debug \
57 --disable-profile \
58 --enable-add-ons="$(GLIBC_ADD_ONS)" \
59 --without-gd \
60 --without-cvs \
61
62 ifeq ($(CONFIG_SOFT_FLOAT),)
63 GLIBC_CONFIGURE+= \
64 --with-fp
65 else
66 GLIBC_CONFIGURE+= \
67 --without-fp
68 endif
69
70 GLIBC_CONFIGURE_STAGE1:= \
71 $(GLIBC_CONFIGURE) \
72 --disable-sanity-checks \
73 --enable-hacker-mode \
74
75 GLIBC_CONFIGURE_STAGE2:= \
76 $(GLIBC_CONFIGURE) \
77
78 GLIBC_MAKE:= \
79 $(MAKE) \
80
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
86 endef
87
88 define Stage1/Configure
89 mkdir -p $(HOST_BUILD_DIR1)
90 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
91 $(GLIBC_CONFIGURE_STAGE1) \
92 );
93 endef
94
95 define Stage1/Compile
96 endef
97
98 define Stage1/Install
99 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
100 CFLAGS="-DBOOTSTRAP_GCC" \
101 cross-compiling=yes \
102 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
103 install-headers
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
109 endef
110
111 define Stage2/Configure
112 mkdir -p $(HOST_BUILD_DIR2)
113 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
114 $(GLIBC_CONFIGURE_STAGE2) \
115 );
116 endef
117
118 define Stage2/Compile
119 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
120 endef
121
122 define Stage2/Install
123 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
124 install_root="$(TOOLCHAIN_DIR)" \
125 install
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 ; \
131 fi \
132 done \
133 done \
134 )
135 endef
136
137 define Host/Prepare
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)
145 endef
146
147 define Host/Configure
148 endef
149
150 define Host/Compile
151 $(call Stage2/Configure)
152 $(call Stage2/Compile)
153 $(call Stage2/Install)
154 endef
155
156 define Host/Install
157 endef
158
159 define Host/Clean
160 rm -rf \
161 $(HOST_BUILD_DIR) \
162 $(HOST_BUILD_DIR1) \
163 $(HOST_BUILD_DIR2) \
164 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
165 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
166 endef
167
168 $(eval $(call HostBuild))