eglibc: work around a broken configure test to fix compile errors on x86
[openwrt/openwrt.git] / toolchain / eglibc / Makefile
1 #
2 # Copyright (C) 2006-2011 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:=eglibc
10 PKG_VERSION:=$(call qstrip,$(CONFIG_EGLIBC_VERSION))
11 PKG_REVISION:=$(call qstrip,$(CONFIG_EGLIBC_REVISION))
12
13 PKG_SOURCE_PROTO:=svn
14 PKG_SOURCE_VERSION:=$(PKG_REVISION)
15 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REVISION)
16 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
17
18 ifneq ($(CONFIG_EGLIBC_VERSION_2_13),)
19 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_13
20 endif
21 ifneq ($(CONFIG_EGLIBC_VERSION_2_14),)
22 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_14
23 endif
24 ifneq ($(CONFIG_EGLIBC_VERSION_2_15),)
25 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_15
26 endif
27
28 PATCH_DIR:=./patches/$(PKG_VERSION)
29
30 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
31
32 include $(INCLUDE_DIR)/toolchain-build.mk
33
34 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.eglibc_built
35 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.eglibc_installed
36
37 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
38 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
39
40 EGLIBC_CFLAGS:= \
41 $(TARGET_CFLAGS)
42
43 EGLIBC_CONFIGURE:= \
44 BUILD_CC="$(HOSTCC)" \
45 $(TARGET_CONFIGURE_OPTS) \
46 CFLAGS="$(EGLIBC_CFLAGS)" \
47 libc_cv_slibdir="/lib" \
48 use_ldconfig=no \
49 $(HOST_BUILD_DIR)/libc/configure \
50 --prefix= \
51 --build=$(GNU_HOST_NAME) \
52 --host=$(REAL_GNU_TARGET_NAME) \
53 --with-headers=$(TOOLCHAIN_DIR)/include \
54 --disable-profile \
55 --without-gd \
56 --without-cvs \
57 --enable-add-ons \
58
59 ifeq ($(CONFIG_SOFT_FLOAT),)
60 EGLIBC_CONFIGURE+= \
61 --with-fp
62 else
63 EGLIBC_CONFIGURE+= \
64 --without-fp
65 endif
66
67 EGLIBC_MAKE:= \
68 $(MAKE) \
69
70 export libc_cv_ssp=no
71 export ac_cv_header_cpuid_h=yes
72
73 define Host/SetToolchainInfo
74 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
75 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
76 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
77 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
78 endef
79
80 define Stage1/Configure
81 mkdir -p $(HOST_BUILD_DIR1)
82 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR1)/
83 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
84 $(EGLIBC_CONFIGURE) \
85 );
86 endef
87
88 define Stage1/Compile
89 endef
90
91 define Stage1/Install
92 mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/{include,lib}
93 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
94 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
95 install-bootstrap-headers=yes \
96 install-headers
97 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
98 csu/subdir_lib
99 ( cd $(HOST_BUILD_DIR1); \
100 $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/ \
101 )
102 $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
103 -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/libc.so
104 endef
105
106 define Stage2/Configure
107 mkdir -p $(HOST_BUILD_DIR2)
108 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR2)/
109 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
110 $(EGLIBC_CONFIGURE) \
111 );
112 endef
113
114 define Stage2/Compile
115 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
116 endef
117
118 define Stage2/Install
119 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
120 install_root="$(TOOLCHAIN_DIR)" \
121 install
122 ( cd $(TOOLCHAIN_DIR) ; \
123 for d in lib usr/lib ; do \
124 for f in libc.so libpthread.so libgcc_s.so ; do \
125 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
126 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
127 fi \
128 done \
129 done \
130 )
131 endef
132
133 define Host/Prepare
134 $(call Host/SetToolchainInfo)
135 $(call Host/Prepare/Default)
136 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
137 $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
138 grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(HOST_BUILD_DIR)/libc/option-groups.config
139 ln -sf ../ports $(HOST_BUILD_DIR)/libc/
140 ( cd $(HOST_BUILD_DIR)/libc; autoconf --force )
141 $(call Stage1/Configure)
142 $(call Stage1/Compile)
143 $(call Stage1/Install)
144 endef
145
146 define Host/Configure
147 endef
148
149 define Host/Compile
150 $(call Stage2/Configure)
151 $(call Stage2/Compile)
152 $(call Stage2/Install)
153 endef
154
155 define Host/Install
156 endef
157
158 define Host/Clean
159 rm -rf $(HOST_BUILD_DIR) $(HOST_BUILD_DIR1) $(HOST_BUILD_DIR2) \
160 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
161 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
162 endef
163
164 $(eval $(call HostBuild))