fd6acc46b881ff6994df3af95c5a68966096a70d
[openwrt-10.03/.git] / toolchain / glibc / Makefile
1 #
2 # Copyright (C) 2006-2008 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.3.6)
13   PKG_MD5SUM:=bfdce99f82d6dbcb64b7f11c05d6bc96
14 endif
15 ifeq ($(PKG_VERSION),2.6.1)
16   PKG_MD5SUM:=11cf6d3fc86dbe0890b8d00372eb6286
17 endif
18 ifeq ($(PKG_VERSION),2.7)
19   PKG_MD5SUM:=065c5952b439deba40083ccd67bcc8f7
20 endif
21
22 PKG_SOURCE_URL:=@GNU/glibc/
23 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
24 PKG_CAT:=bzcat
25
26 PATCH_DIR:=./patches/$(PKG_VERSION)
27
28 STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
29 BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
30
31 override CONFIG_AUTOREBUILD=
32
33 include $(INCLUDE_DIR)/host-build.mk
34
35 STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.glibc_built
36 STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_installed
37
38 PKG_BUILD_DIR1:=$(PKG_BUILD_DIR)-initial
39 PKG_BUILD_DIR2:=$(PKG_BUILD_DIR)-final
40
41 GLIBC_ADD_ONS+=nptl,
42
43 ifneq ($(CONFIG_GLIBC_PORTS),)
44   GLIBC_ADD_ONS+=ports,
45   define Build/Prepare/ports
46         ln -snf ../glibc-ports $(PKG_BUILD_DIR)/ports
47   endef
48 endif
49
50 # XXX: {e,}glibc does not build w/ -Os
51 # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
52 GLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
53
54 GLIBC_CONFIGURE_COMMON:= \
55         BUILD_CC="$(HOSTCC)" \
56         $(TARGET_CONFIGURE_OPTS) \
57         CFLAGS="$(GLIBC_CFLAGS)" \
58         libc_cv_forced_unwind=yes \
59         libc_cv_c_cleanup=yes \
60         libc_cv_386_tls=yes \
61         $(PKG_BUILD_DIR)/configure \
62                 --prefix=/usr \
63                 --build=$(GNU_HOST_NAME) \
64                 --host=$(REAL_GNU_TARGET_NAME) \
65                 --with-headers="$(TOOLCHAIN_DIR)/usr/include" \
66                 --disable-debug \
67                 --disable-profile \
68                 --enable-add-ons="$(GLIBC_ADD_ONS)" \
69                 --without-gd \
70                 --without-cvs \
71
72 ifeq ($(CONFIG_SOFT_FLOAT),)
73   GLIBC_CONFIGURE_COMMON+= \
74                 --with-fp
75 else
76   GLIBC_CONFIGURE_COMMON+= \
77                 --without-fp
78 endif
79
80 GLIBC_CONFIGURE_STAGE1:= \
81         $(GLIBC_CONFIGURE_COMMON) \
82                 --disable-sanity-checks \
83                 --enable-hacker-mode \
84         
85 GLIBC_CONFIGURE_STAGE2:= \
86         $(GLIBC_CONFIGURE_COMMON) \
87
88 GLIBC_MAKE:= \
89         $(MAKE) \
90
91
92 define Build/SetToolchainInfo
93         $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
94         $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
95         $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
96         $(SED) 's,^\(LIBC_PATCHVER\)=.*,\1=,' $(TOOLCHAIN_DIR)/info.mk
97 endef
98
99 define Stage1/Configure
100         mkdir -p $(PKG_BUILD_DIR1)
101         ( cd $(PKG_BUILD_DIR1); rm -f config.cache; \
102                 $(GLIBC_CONFIGURE_STAGE1) \
103         );
104 endef
105
106 define Stage1/Compile
107 endef
108
109 define Stage1/Install
110         $(GLIBC_MAKE) -C $(PKG_BUILD_DIR1) \
111                 CFLAGS="-DBOOTSTRAP_GCC" \
112                 cross-compiling=yes \
113                 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
114                 install-headers
115         [ -f $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/bits/stdio_lim.h ] || \
116                 $(CP) $(PKG_BUILD_DIR1)/bits/stdio_lim.h \
117                         $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/bits/stdio_lim.h
118         [ -f $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/gnu/stubs.h ] || \
119                 touch $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/gnu/stubs.h
120 endef
121
122 define Stage2/Configure
123         mkdir -p $(PKG_BUILD_DIR2)
124         ( cd $(PKG_BUILD_DIR2); rm -f config.cache; \
125                 $(GLIBC_CONFIGURE_STAGE2) \
126         );
127 endef
128
129 define Stage2/Compile
130         $(GLIBC_MAKE) -C $(PKG_BUILD_DIR2) all
131 endef
132
133 define Stage2/Install
134         $(GLIBC_MAKE) -C $(PKG_BUILD_DIR2) \
135                 install_root="$(TOOLCHAIN_DIR)" \
136                 install
137         ( cd $(TOOLCHAIN_DIR) ; \
138                 for d in lib usr/lib ; do \
139                   for f in libc.so libpthread.so libgcc_s.so ; do \
140                     if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
141                       $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
142                     fi \
143                   done \
144                 done \
145         )
146 endef
147
148 define Build/Prepare
149         $(call Build/SetToolchainInfo)
150         $(call Build/Prepare/Default)
151         ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
152         $(call Build/Prepare/ports)
153         $(call Stage1/Configure)
154         $(call Stage1/Compile)
155         $(call Stage1/Install)
156 endef
157
158 define Build/Configure
159 endef
160
161 define Build/Compile
162         $(call Stage2/Configure)
163         $(call Stage2/Compile)
164         $(call Stage2/Install)
165 endef
166
167 define Build/Install
168 endef
169
170 define Build/Clean
171         rm -rf \
172                 $(PKG_BUILD_DIR) \
173                 $(PKG_BUILD_DIR1) \
174                 $(PKG_BUILD_DIR2) \
175                 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
176                 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
177 endef
178
179 $(eval $(call HostBuild))