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