Revert "[toolchain/eglibc} eglibc in fact can be built with -Os"
[openwrt.git] / toolchain / eglibc / Makefile
1 #
2 # Copyright (C) 2006-2010 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_6),)
19 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_6
20 endif
21 ifneq ($(CONFIG_EGLIBC_VERSION_2_7),)
22 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_7
23 endif
24 ifneq ($(CONFIG_EGLIBC_VERSION_2_8),)
25 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_8
26 endif
27 ifneq ($(CONFIG_EGLIBC_VERSION_2_9),)
28 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_9
29 endif
30 ifneq ($(CONFIG_EGLIBC_VERSION_2_10),)
31 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_10
32 endif
33 ifneq ($(CONFIG_EGLIBC_VERSION_2_11),)
34 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_11
35 endif
36 ifneq ($(CONFIG_EGLIBC_VERSION_2_12),)
37 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_12
38 endif
39 ifneq ($(CONFIG_EGLIBC_VERSION_2_13),)
40 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_13
41 endif
42 ifneq ($(CONFIG_EGLIBC_VERSION_TRUNK),)
43 PKG_SOURCE_URL:=svn://svn.eglibc.org/trunk
44 endif
45
46 PATCH_DIR:=./patches/$(PKG_VERSION)
47
48 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
49
50 include $(INCLUDE_DIR)/toolchain-build.mk
51
52 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.eglibc_built
53 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.eglibc_installed
54
55 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
56 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
57
58 # XXX: {e,}glibc does not build w/ -Os
59 # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
60 EGLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
61
62 EGLIBC_CONFIGURE:= \
63 BUILD_CC="$(HOSTCC)" \
64 $(TARGET_CONFIGURE_OPTS) \
65 CFLAGS="$(EGLIBC_CFLAGS)" \
66 libc_cv_slibdir="/lib" \
67 use_ldconfig=no \
68 $(HOST_BUILD_DIR)/libc/configure \
69 --prefix= \
70 --build=$(GNU_HOST_NAME) \
71 --host=$(REAL_GNU_TARGET_NAME) \
72 --with-headers=$(TOOLCHAIN_DIR)/include \
73 --disable-profile \
74 --without-gd \
75 --without-cvs \
76 --enable-add-ons \
77
78 ifeq ($(CONFIG_SOFT_FLOAT),)
79 EGLIBC_CONFIGURE+= \
80 --with-fp
81 else
82 EGLIBC_CONFIGURE+= \
83 --without-fp
84 endif
85
86 EGLIBC_MAKE:= \
87 $(MAKE) \
88
89 export libc_cv_ssp=no
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.eglibc.org/,' $(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 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR1)/
101 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
102 $(EGLIBC_CONFIGURE) \
103 );
104 endef
105
106 define Stage1/Compile
107 endef
108
109 define Stage1/Install
110 mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/{include,lib}
111 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
112 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
113 install-bootstrap-headers=yes \
114 install-headers
115 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
116 csu/subdir_lib
117 ( cd $(HOST_BUILD_DIR1); \
118 $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/ \
119 )
120 $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
121 -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/libc.so
122 endef
123
124 define Stage2/Configure
125 mkdir -p $(HOST_BUILD_DIR2)
126 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR2)/
127 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
128 $(EGLIBC_CONFIGURE) \
129 );
130 endef
131
132 define Stage2/Compile
133 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
134 endef
135
136 define Stage2/Install
137 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
138 install_root="$(TOOLCHAIN_DIR)" \
139 install
140 ( cd $(TOOLCHAIN_DIR) ; \
141 for d in lib usr/lib ; do \
142 for f in libc.so libpthread.so libgcc_s.so ; do \
143 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
144 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
145 fi \
146 done \
147 done \
148 )
149 endef
150
151 define Host/Prepare
152 $(call Host/SetToolchainInfo)
153 $(call Host/Prepare/Default)
154 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
155 $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
156 grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(HOST_BUILD_DIR)/libc/option-groups.config
157 ln -sf ../ports $(HOST_BUILD_DIR)/libc/
158 ( cd $(HOST_BUILD_DIR)/libc; autoconf --force )
159 $(call Stage1/Configure)
160 $(call Stage1/Compile)
161 $(call Stage1/Install)
162 endef
163
164 define Host/Configure
165 endef
166
167 define Host/Compile
168 $(call Stage2/Configure)
169 $(call Stage2/Compile)
170 $(call Stage2/Install)
171 endef
172
173 define Host/Install
174 endef
175
176 define Host/Clean
177 rm -rf $(HOST_BUILD_DIR) $(HOST_BUILD_DIR1) $(HOST_BUILD_DIR2) \
178 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
179 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
180 endef
181
182 $(eval $(call HostBuild))
This page took 0.04634 seconds and 5 git commands to generate.