port the eglibc cross compiling fix to version 2.9
[openwrt.git] / toolchain / eglibc / Makefile
1 #
2 # Copyright (C) 2006-2008 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 ifeq ($(PKG_VERSION),2.6.1)
18 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_6
19 endif
20 ifeq ($(PKG_VERSION),2.7)
21 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_7
22 endif
23 ifeq ($(PKG_VERSION),2.8)
24 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_8
25 endif
26 ifeq ($(PKG_VERSION),2.9)
27 PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_9
28 endif
29 ifeq ($(PKG_VERSION),trunk)
30 PKG_SOURCE_URL:=svn://svn.eglibc.org/trunk
31 endif
32
33 PATCH_DIR:=./patches/$(PKG_VERSION)
34
35 STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
36 BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
37 PKG_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_SOURCE_SUBDIR)
38
39 override CONFIG_AUTOREBUILD=
40
41 include $(INCLUDE_DIR)/host-build.mk
42
43 STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.eglibc_built
44 STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.eglibc_installed
45
46 PKG_BUILD_DIR1:=$(PKG_BUILD_DIR)-initial
47 PKG_BUILD_DIR2:=$(PKG_BUILD_DIR)-final
48
49 # XXX: {e,}glibc does not build w/ -Os
50 # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
51 EGLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
52
53 EGLIBC_CONFIGURE:= \
54 BUILD_CC="$(HOSTCC)" \
55 $(TARGET_CONFIGURE_OPTS) \
56 CFLAGS="$(EGLIBC_CFLAGS)" \
57 $(PKG_BUILD_DIR)/libc/configure \
58 --prefix=/usr \
59 --build=$(GNU_HOST_NAME) \
60 --host=$(REAL_GNU_TARGET_NAME) \
61 --with-headers=$(TOOLCHAIN_DIR)/usr/include \
62 --disable-profile \
63 --without-gd \
64 --without-cvs \
65 --enable-add-ons \
66
67 ifeq ($(CONFIG_SOFT_FLOAT),)
68 EGLIBC_CONFIGURE+= --with-fp
69 else
70 EGLIBC_CONFIGURE+= --without-fp
71 endif
72
73 EGLIBC_MAKE:= \
74 $(MAKE) \
75
76
77 define Build/SetToolchainInfo
78 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
79 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
80 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
81 $(SED) 's,^\(LIBC_PATCHVER\)=.*,\1=$(PKG_EXTRAVERSION),' $(TOOLCHAIN_DIR)/info.mk
82 endef
83
84 define Stage1/Configure
85 mkdir -p $(PKG_BUILD_DIR1)
86 $(CP) $(PKG_BUILD_DIR)/libc/option-groups.config $(PKG_BUILD_DIR1)/
87 ( cd $(PKG_BUILD_DIR1); rm -f config.cache; \
88 $(EGLIBC_CONFIGURE) \
89 );
90 endef
91
92 define Stage1/Compile
93 endef
94
95 define Stage1/Install
96 mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/{include,lib}
97 $(EGLIBC_MAKE) -C $(PKG_BUILD_DIR1) \
98 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
99 install-bootstrap-headers=yes \
100 install-headers
101 $(EGLIBC_MAKE) -C $(PKG_BUILD_DIR1) \
102 csu/subdir_lib
103 ( cd $(PKG_BUILD_DIR1); \
104 $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/lib/ \
105 )
106 $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
107 -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/lib/libc.so
108 endef
109
110 define Stage2/Configure
111 mkdir -p $(PKG_BUILD_DIR2)
112 $(CP) $(PKG_BUILD_DIR)/libc/option-groups.config $(PKG_BUILD_DIR2)/
113 ( cd $(PKG_BUILD_DIR2); rm -f config.cache; \
114 $(EGLIBC_CONFIGURE) \
115 );
116 endef
117
118 define Stage2/Compile
119 $(EGLIBC_MAKE) -C $(PKG_BUILD_DIR2) all
120 endef
121
122 define Stage2/Install
123 $(EGLIBC_MAKE) -C $(PKG_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 )
135 endef
136
137 define Build/Prepare
138 $(call Build/SetToolchainInfo)
139 $(call Build/Prepare/Default)
140 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
141 $(SED) 's,y,n,' $(PKG_BUILD_DIR)/libc/option-groups.defaults
142 grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(PKG_BUILD_DIR)/libc/option-groups.config
143 ln -sf ../ports $(PKG_BUILD_DIR)/libc/
144 ( cd $(PKG_BUILD_DIR)/libc; autoconf --force )
145 $(call Stage1/Configure)
146 $(call Stage1/Compile)
147 $(call Stage1/Install)
148 endef
149
150 define Build/Configure
151 endef
152
153 define Build/Compile
154 $(call Stage2/Configure)
155 $(call Stage2/Compile)
156 $(call Stage2/Install)
157 endef
158
159 define Build/Install
160 endef
161
162 define Build/Clean
163 rm -rf $(PKG_BUILD_DIR) $(PKG_BUILD_DIR1) $(PKG_BUILD_DIR2) \
164 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
165 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
166 endef
167
168 $(eval $(call HostBuild))
This page took 0.047714 seconds and 5 git commands to generate.