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.14)
13  PKG_MD5SUM:=1588cc22e796c296223744895ebc4cef
14endif
15
16PKG_SOURCE_URL:=@GNU/glibc
17PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
18
19PATCH_DIR:=./patches/$(PKG_VERSION)
20
21include $(INCLUDE_DIR)/toolchain-build.mk
22
23HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.glibc_built
24HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_installed
25
26HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
27HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
28
29GLIBC_ADD_ONS+=nptl,
30
31ifneq ($(CONFIG_GLIBC_PORTS),)
32  GLIBC_ADD_ONS+=ports,
33  define Host/Prepare/ports
34    ln -snf ../glibc-ports $(HOST_BUILD_DIR)/ports
35  endef
36endif
37
38# XXX: {e,}glibc does not build w/ -Os
39# http://sourceware.org/bugzilla/show_bug.cgi?id=5203
40GLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
41
42GLIBC_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
62ifeq ($(CONFIG_SOFT_FLOAT),)
63  GLIBC_CONFIGURE+= \
64        --with-fp
65else
66  GLIBC_CONFIGURE+= \
67        --without-fp
68endif
69
70GLIBC_CONFIGURE_STAGE1:= \
71    $(GLIBC_CONFIGURE) \
72        --disable-sanity-checks \
73        --enable-hacker-mode \
74    
75GLIBC_CONFIGURE_STAGE2:= \
76    $(GLIBC_CONFIGURE) \
77
78GLIBC_MAKE:= \
79    $(MAKE) \
80
81define 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
86endef
87
88define Stage1/Configure
89    mkdir -p $(HOST_BUILD_DIR1)
90    ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
91        $(GLIBC_CONFIGURE_STAGE1) \
92    );
93endef
94
95define Stage1/Compile
96endef
97
98define 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
109endef
110
111define Stage2/Configure
112    mkdir -p $(HOST_BUILD_DIR2)
113    ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
114        $(GLIBC_CONFIGURE_STAGE2) \
115    );
116endef
117
118define Stage2/Compile
119    $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
120endef
121
122define 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    )
135endef
136
137define 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)
145endef
146
147define Host/Configure
148endef
149
150define Host/Compile
151    $(call Stage2/Configure)
152    $(call Stage2/Compile)
153    $(call Stage2/Install)
154endef
155
156define Host/Install
157endef
158
159define 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)
166endef
167
168$(eval $(call HostBuild))
169

Archive Download this file



interactive