Root/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#
7include $(TOPDIR)/rules.mk
8
9PKG_NAME:=glibc
10PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION))
11
12ifeq ($(PKG_VERSION),2.3.6)
13  PKG_MD5SUM:=bfdce99f82d6dbcb64b7f11c05d6bc96
14endif
15ifeq ($(PKG_VERSION),2.4)
16  PKG_MD5SUM:=7e9a88dcd41fbc53801dbe5bdacaf245
17endif
18ifeq ($(PKG_VERSION),2.6.1)
19  PKG_MD5SUM:=11cf6d3fc86dbe0890b8d00372eb6286
20endif
21ifeq ($(PKG_VERSION),2.7)
22  PKG_MD5SUM:=065c5952b439deba40083ccd67bcc8f7
23endif
24
25PKG_SOURCE_URL:=@GNU/glibc/
26PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
27
28PATCH_DIR:=./patches/$(PKG_VERSION)
29
30include $(INCLUDE_DIR)/toolchain-build.mk
31
32HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.glibc_built
33HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_installed
34
35HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
36HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
37
38GLIBC_ADD_ONS+=nptl,
39
40ifneq ($(CONFIG_GLIBC_PORTS),)
41  GLIBC_ADD_ONS+=ports,
42  define Host/Prepare/ports
43    ln -snf ../glibc-ports $(HOST_BUILD_DIR)/ports
44  endef
45endif
46
47# XXX: {e,}glibc does not build w/ -Os
48# http://sourceware.org/bugzilla/show_bug.cgi?id=5203
49GLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
50
51GLIBC_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
71ifeq ($(CONFIG_SOFT_FLOAT),)
72  GLIBC_CONFIGURE+= \
73        --with-fp
74else
75  GLIBC_CONFIGURE+= \
76        --without-fp
77endif
78
79GLIBC_CONFIGURE_STAGE1:= \
80    $(GLIBC_CONFIGURE) \
81        --disable-sanity-checks \
82        --enable-hacker-mode \
83    
84GLIBC_CONFIGURE_STAGE2:= \
85    $(GLIBC_CONFIGURE) \
86
87GLIBC_MAKE:= \
88    $(MAKE) \
89
90
91define 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
96endef
97
98define Stage1/Configure
99    mkdir -p $(HOST_BUILD_DIR1)
100    ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
101        $(GLIBC_CONFIGURE_STAGE1) \
102    );
103endef
104
105define Stage1/Compile
106endef
107
108define 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
119endef
120
121define Stage2/Configure
122    mkdir -p $(HOST_BUILD_DIR2)
123    ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
124        $(GLIBC_CONFIGURE_STAGE2) \
125    );
126endef
127
128define Stage2/Compile
129    $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
130endef
131
132define 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    )
145endef
146
147define 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)
155endef
156
157define Host/Configure
158endef
159
160define Host/Compile
161    $(call Stage2/Configure)
162    $(call Stage2/Compile)
163    $(call Stage2/Install)
164endef
165
166define Host/Install
167endef
168
169define 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)
176endef
177
178$(eval $(call HostBuild))
179

Archive Download this file



interactive