[toolchain] move common variables to a dedicated include file
[openwrt.git] / toolchain / glibc / 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:=glibc
10 PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION))
11
12 ifeq ($(PKG_VERSION),2.3.6)
13 PKG_MD5SUM:=bfdce99f82d6dbcb64b7f11c05d6bc96
14 endif
15 ifeq ($(PKG_VERSION),2.6.1)
16 PKG_MD5SUM:=11cf6d3fc86dbe0890b8d00372eb6286
17 endif
18 ifeq ($(PKG_VERSION),2.7)
19 PKG_MD5SUM:=065c5952b439deba40083ccd67bcc8f7
20 endif
21
22 PKG_SOURCE_URL:=@GNU/glibc/
23 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
24
25 PATCH_DIR:=./patches/$(PKG_VERSION)
26
27 include $(INCLUDE_DIR)/toolchain-build.mk
28
29 STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.glibc_built
30 STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_installed
31
32 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
33 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
34
35 GLIBC_ADD_ONS+=nptl,
36
37 ifneq ($(CONFIG_GLIBC_PORTS),)
38 GLIBC_ADD_ONS+=ports,
39 define Host/Prepare/ports
40 ln -snf ../glibc-ports $(HOST_BUILD_DIR)/ports
41 endef
42 endif
43
44 # XXX: {e,}glibc does not build w/ -Os
45 # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
46 GLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
47
48 GLIBC_CONFIGURE:= \
49 BUILD_CC="$(HOSTCC)" \
50 $(TARGET_CONFIGURE_OPTS) \
51 CFLAGS="$(GLIBC_CFLAGS)" \
52 libc_cv_forced_unwind=yes \
53 libc_cv_c_cleanup=yes \
54 libc_cv_386_tls=yes \
55 $(HOST_BUILD_DIR)/configure \
56 --prefix=/usr \
57 --build=$(GNU_HOST_NAME) \
58 --host=$(REAL_GNU_TARGET_NAME) \
59 --with-headers="$(TOOLCHAIN_DIR)/usr/include" \
60 --disable-debug \
61 --disable-profile \
62 --enable-add-ons="$(GLIBC_ADD_ONS)" \
63 --without-gd \
64 --without-cvs \
65
66 ifeq ($(CONFIG_SOFT_FLOAT),)
67 GLIBC_CONFIGURE+= \
68 --with-fp
69 else
70 GLIBC_CONFIGURE+= \
71 --without-fp
72 endif
73
74 GLIBC_CONFIGURE_STAGE1:= \
75 $(GLIBC_CONFIGURE) \
76 --disable-sanity-checks \
77 --enable-hacker-mode \
78
79 GLIBC_CONFIGURE_STAGE2:= \
80 $(GLIBC_CONFIGURE) \
81
82 GLIBC_MAKE:= \
83 $(MAKE) \
84
85
86 define Host/SetToolchainInfo
87 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
88 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
89 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
90 $(SED) 's,^\(LIBC_PATCHVER\)=.*,\1=,' $(TOOLCHAIN_DIR)/info.mk
91 endef
92
93 define Stage1/Configure
94 mkdir -p $(HOST_BUILD_DIR1)
95 ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
96 $(GLIBC_CONFIGURE_STAGE1) \
97 );
98 endef
99
100 define Stage1/Compile
101 endef
102
103 define Stage1/Install
104 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
105 CFLAGS="-DBOOTSTRAP_GCC" \
106 cross-compiling=yes \
107 install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
108 install-headers
109 [ -f $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/bits/stdio_lim.h ] || \
110 $(CP) $(HOST_BUILD_DIR1)/bits/stdio_lim.h \
111 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/bits/stdio_lim.h
112 [ -f $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/gnu/stubs.h ] || \
113 touch $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/include/gnu/stubs.h
114 endef
115
116 define Stage2/Configure
117 mkdir -p $(HOST_BUILD_DIR2)
118 ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
119 $(GLIBC_CONFIGURE_STAGE2) \
120 );
121 endef
122
123 define Stage2/Compile
124 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
125 endef
126
127 define Stage2/Install
128 $(GLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
129 install_root="$(TOOLCHAIN_DIR)" \
130 install
131 ( cd $(TOOLCHAIN_DIR) ; \
132 for d in lib usr/lib ; do \
133 for f in libc.so libpthread.so libgcc_s.so ; do \
134 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
135 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
136 fi \
137 done \
138 done \
139 )
140 endef
141
142 define Host/Prepare
143 $(call Host/SetToolchainInfo)
144 $(call Host/Prepare/Default)
145 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
146 $(call Host/Prepare/ports)
147 $(call Stage1/Configure)
148 $(call Stage1/Compile)
149 $(call Stage1/Install)
150 endef
151
152 define Host/Configure
153 endef
154
155 define Host/Compile
156 $(call Stage2/Configure)
157 $(call Stage2/Compile)
158 $(call Stage2/Install)
159 endef
160
161 define Host/Install
162 endef
163
164 define Host/Clean
165 rm -rf \
166 $(HOST_BUILD_DIR) \
167 $(HOST_BUILD_DIR1) \
168 $(HOST_BUILD_DIR2) \
169 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
170 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
171 endef
172
173 $(eval $(call HostBuild))
This page took 0.047921 seconds and 5 git commands to generate.