eade1c1b5ccf84c7a75dd75c26d9f69ef20c2243
[openwrt/svn-archive/archive.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
72 define Host/SetToolchainInfo
73 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
74 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
75 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
76 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
77 endef
78
79 define Stage1/Configure
80 mkdir -p $(HOST_BUILD_DIR1)
81 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR1)/
82 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
83 $(EGLIBC_CONFIGURE) \
84 );
85 endef
86
87 define Stage1/Compile
88 endef
89
90 define Stage1/Install
91 mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/{include,lib}
92 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
93 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
94 install-bootstrap-headers=yes \
95 install-headers
96 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
97 csu/subdir_lib
98 ( cd $(HOST_BUILD_DIR1); \
99 $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/ \
100 )
101 $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
102 -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/libc.so
103 endef
104
105 define Stage2/Configure
106 mkdir -p $(HOST_BUILD_DIR2)
107 $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR2)/
108 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
109 $(EGLIBC_CONFIGURE) \
110 );
111 endef
112
113 define Stage2/Compile
114 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
115 endef
116
117 define Stage2/Install
118 $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
119 install_root="$(TOOLCHAIN_DIR)" \
120 install
121 ( cd $(TOOLCHAIN_DIR) ; \
122 for d in lib usr/lib ; do \
123 for f in libc.so libpthread.so libgcc_s.so ; do \
124 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
125 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
126 fi \
127 done \
128 done \
129 )
130 endef
131
132 define Host/Prepare
133 $(call Host/SetToolchainInfo)
134 $(call Host/Prepare/Default)
135 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
136 $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
137 grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(HOST_BUILD_DIR)/libc/option-groups.config
138 ln -sf ../ports $(HOST_BUILD_DIR)/libc/
139 ( cd $(HOST_BUILD_DIR)/libc; autoconf --force )
140 $(call Stage1/Configure)
141 $(call Stage1/Compile)
142 $(call Stage1/Install)
143 endef
144
145 define Host/Configure
146 endef
147
148 define Host/Compile
149 $(call Stage2/Configure)
150 $(call Stage2/Compile)
151 $(call Stage2/Install)
152 endef
153
154 define Host/Install
155 endef
156
157 define Host/Clean
158 rm -rf $(HOST_BUILD_DIR) $(HOST_BUILD_DIR1) $(HOST_BUILD_DIR2) \
159 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
160 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
161 endef
162
163 $(eval $(call HostBuild))