822309d0588d80021a32b090c32b0d29fb7904b9
[openwrt.git] / toolchain / eglibc / 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 #
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_TRUNK),)
37 PKG_SOURCE_URL:=svn://svn.eglibc.org/trunk
38 endif
39
40 PATCH_DIR:=./patches/$(PKG_VERSION)
41
42 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
43
44 include $(INCLUDE_DIR)/toolchain-build.mk
45
46 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.eglibc_built
47 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.eglibc_installed
48
49 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
50 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
51
52 # XXX: {e,}glibc does not build w/ -Os
53 # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
54 EGLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
55
56 EGLIBC_CONFIGURE:= \
57 BUILD_CC="$(HOSTCC)" \
58 $(TARGET_CONFIGURE_OPTS) \
59 CFLAGS="$(EGLIBC_CFLAGS)" \
60 libc_cv_slibdir="/lib" \
61 $(HOST_BUILD_DIR)/libc/configure \
62 --prefix=/usr \
63 --build=$(GNU_HOST_NAME) \
64 --host=$(REAL_GNU_TARGET_NAME) \
65 --with-headers=$(TOOLCHAIN_DIR)/usr/include \
66 --disable-profile \
67 --without-gd \
68 --without-cvs \
69 --enable-add-ons \
70
71 ifeq ($(CONFIG_SOFT_FLOAT),)
72 EGLIBC_CONFIGURE+= \
73 --with-fp
74 else
75 EGLIBC_CONFIGURE+= \
76 --without-fp
77 endif
78
79 EGLIBC_MAKE:= \
80 $(MAKE) \
81
82
83 define Host/SetToolchainInfo
84 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
85 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
86 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
87 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
88 endef
89
90 define Stage1/Configure
91 mkdir -p $(HOST_BUILD_DIR1)
92 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR1)/
93 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
94 $(EGLIBC_CONFIGURE) \
95 );
96 endef
97
98 define Stage1/Compile
99 endef
100
101 define Stage1/Install
102 mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/{include,lib}
103 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
104 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
105 install-bootstrap-headers=yes \
106 install-headers
107 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
108 csu/subdir_lib
109 ( cd $(HOST_BUILD_DIR1); \
110 $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/lib/ \
111 )
112 $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
113 -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/lib/libc.so
114 endef
115
116 define Stage2/Configure
117 mkdir -p $(HOST_BUILD_DIR2)
118 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR2)/
119 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
120 $(EGLIBC_CONFIGURE) \
121 );
122 endef
123
124 define Stage2/Compile
125 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
126 endef
127
128 define Stage2/Install
129 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
130 install_root="$(TOOLCHAIN_DIR)" \
131 install
132 ( cd $(TOOLCHAIN_DIR) ; \
133 for d in lib usr/lib ; do \
134 for f in libc.so libpthread.so libgcc_s.so ; do \
135 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
136 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
137 fi \
138 done \
139 done \
140 )
141 endef
142
143 define Host/Prepare
144 $(call Host/SetToolchainInfo)
145 $(call Host/Prepare/Default)
146 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
147 $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
148 grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(HOST_BUILD_DIR)/libc/option-groups.config
149 ln -sf ../ports $(HOST_BUILD_DIR)/libc/
150 ( cd $(HOST_BUILD_DIR)/libc; autoconf --force )
151 $(call Stage1/Configure)
152 $(call Stage1/Compile)
153 $(call Stage1/Install)
154 endef
155
156 define Host/Configure
157 endef
158
159 define Host/Compile
160 $(call Stage2/Configure)
161 $(call Stage2/Compile)
162 $(call Stage2/Install)
163 endef
164
165 define Host/Install
166 endef
167
168 define Host/Clean
169 rm -rf $(HOST_BUILD_DIR) $(HOST_BUILD_DIR1) $(HOST_BUILD_DIR2) \
170 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
171 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
172 endef
173
174 $(eval $(call HostBuild))
This page took 0.061544 seconds and 3 git commands to generate.