glibc: fix applying of patches
[openwrt/staging/wigyori.git] / toolchain / glibc / common.mk
1 #
2 # Copyright (C) 2006-2016 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:=2.26
11
12 PKG_SOURCE_URL:=@GNU/libc
13 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
14 PKG_HASH:=e54e0a934cd2bc94429be79da5e9385898d2306b9eaf3c92d5a77af96190f6bd
15
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
18 CUR_BUILD_DIR:=$(HOST_BUILD_DIR)-$(VARIANT)
19 PATCH_DIR:=$(PATH_PREFIX)/patches
20
21 include $(INCLUDE_DIR)/toolchain-build.mk
22
23 HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
24 HOST_STAMP_CONFIGURED:=$(CUR_BUILD_DIR)/.configured
25 HOST_STAMP_BUILT:=$(CUR_BUILD_DIR)/.built
26 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_$(VARIANT)_installed
27
28 ifeq ($(ARCH),mips64)
29 ifdef CONFIG_MIPS64_ABI_N64
30 TARGET_CFLAGS += -mabi=64
31 endif
32 ifdef CONFIG_MIPS64_ABI_N32
33 TARGET_CFLAGS += -mabi=n32
34 endif
35 ifdef CONFIG_MIPS64_ABI_O32
36 TARGET_CFLAGS += -mabi=32
37 endif
38 endif
39
40
41 # -Os miscompiles w. 2.24 gcc5/gcc6
42 # only -O2 tested by upstream changeset
43 # "Optimize i386 syscall inlining for GCC 5"
44 GLIBC_CONFIGURE:= \
45 BUILD_CC="$(HOSTCC)" \
46 $(TARGET_CONFIGURE_OPTS) \
47 CFLAGS="-O2 $(filter-out -Os,$(call qstrip,$(TARGET_CFLAGS)))" \
48 libc_cv_slibdir="/lib" \
49 use_ldconfig=no \
50 $(HOST_BUILD_DIR)/$(GLIBC_PATH)configure \
51 --prefix= \
52 --build=$(GNU_HOST_NAME) \
53 --host=$(REAL_GNU_TARGET_NAME) \
54 --with-headers=$(TOOLCHAIN_DIR)/include \
55 --disable-profile \
56 --disable-werror \
57 --without-gd \
58 --without-cvs \
59 --enable-add-ons \
60 --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp
61
62 export libc_cv_ssp=no
63 export libc_cv_ssp_strong=no
64 export ac_cv_header_cpuid_h=yes
65 export HOST_CFLAGS := $(HOST_CFLAGS) -idirafter $(CURDIR)/$(PATH_PREFIX)/include
66
67 define Host/SetToolchainInfo
68 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
69 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
70 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
71 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
72 endef
73
74 define Host/Configure
75 [ -f $(HOST_BUILD_DIR)/.autoconf ] || { \
76 cd $(HOST_BUILD_DIR)/; \
77 autoconf --force && \
78 touch $(HOST_BUILD_DIR)/.autoconf; \
79 }
80 mkdir -p $(CUR_BUILD_DIR)
81 ( cd $(CUR_BUILD_DIR); rm -f config.cache; \
82 $(GLIBC_CONFIGURE) \
83 );
84 endef
85
86 define Host/Prepare
87 $(call Host/Prepare/Default)
88 ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
89 endef
90
91 define Host/Clean
92 rm -rf $(CUR_BUILD_DIR)* \
93 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
94 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
95 endef