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