b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2006-2020 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.38 |
| 11 | PKG_RELEASE:=1 |
| 12 | |
| 13 | PKG_SOURCE_PROTO:=git |
| 14 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) |
| 15 | PKG_SOURCE_VERSION:=e9f05fa1c62c8044ff025963498063f73eb51c5f |
| 16 | PKG_MIRROR_HASH:=fd61eb2caea0d4100638b8aa8285b0f1bc23af921c376516307c9ab8ac307739 |
| 17 | PKG_SOURCE_URL:=https://sourceware.org/git/glibc.git |
| 18 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.zst |
| 19 | PKG_CPE_ID:=cpe:/a:gnu:glibc |
| 20 | |
| 21 | HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR) |
| 22 | CUR_BUILD_DIR:=$(HOST_BUILD_DIR)-$(VARIANT) |
| 23 | PATCH_DIR:=$(PATH_PREFIX)/patches |
| 24 | |
| 25 | include $(INCLUDE_DIR)/toolchain-build.mk |
| 26 | |
| 27 | HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared |
| 28 | HOST_STAMP_CONFIGURED:=$(CUR_BUILD_DIR)/.configured |
| 29 | HOST_STAMP_BUILT:=$(CUR_BUILD_DIR)/.built |
| 30 | HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_$(VARIANT)_installed |
| 31 | |
| 32 | ifeq ($(ARCH),mips64) |
| 33 | ifdef CONFIG_MIPS64_ABI_N64 |
| 34 | TARGET_CFLAGS += -mabi=64 |
| 35 | endif |
| 36 | ifdef CONFIG_MIPS64_ABI_N32 |
| 37 | TARGET_CFLAGS += -mabi=n32 |
| 38 | endif |
| 39 | ifdef CONFIG_MIPS64_ABI_O32 |
| 40 | TARGET_CFLAGS += -mabi=32 |
| 41 | endif |
| 42 | endif |
| 43 | |
| 44 | TARGET_CFLAGS := $(filter-out -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS)) |
| 45 | |
| 46 | # -Os miscompiles w. 2.24 gcc5/gcc6 |
| 47 | # only -O2 tested by upstream changeset |
| 48 | # "Optimize i386 syscall inlining for GCC 5" |
| 49 | GLIBC_CONFIGURE:= \ |
| 50 | unset LD_LIBRARY_PATH; \ |
| 51 | BUILD_CC="$(HOSTCC)" \ |
| 52 | $(TARGET_CONFIGURE_OPTS) \ |
| 53 | CFLAGS="-O2 $(filter-out -Os,$(call qstrip,$(TARGET_CFLAGS)))" \ |
| 54 | libc_cv_slibdir="/lib" \ |
| 55 | use_ldconfig=no \ |
| 56 | $(HOST_BUILD_DIR)/$(GLIBC_PATH)configure \ |
| 57 | --prefix= \ |
| 58 | --build=$(GNU_HOST_NAME) \ |
| 59 | --host=$(REAL_GNU_TARGET_NAME) \ |
| 60 | --with-headers=$(TOOLCHAIN_DIR)/include \ |
| 61 | --disable-profile \ |
| 62 | --disable-werror \ |
| 63 | --without-gd \ |
| 64 | --without-cvs \ |
| 65 | --enable-add-ons \ |
| 66 | --enable-crypt \ |
| 67 | --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp \ |
| 68 | $(if $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),--enable-stack-protector=yes) \ |
| 69 | $(if $(CONFIG_PKG_CC_STACKPROTECTOR_STRONG),--enable-stack-protector=strong) \ |
| 70 | $(if $(CONFIG_PKG_CC_STACKPROTECTOR_ALL),--enable-stack-protector=all) \ |
| 71 | $(if $(CONFIG_PKG_RELRO_FULL),--enable-bind-now) \ |
| 72 | $(if $(CONFIG_PKG_FORTIFY_SOURCE_1),--enable-fortify-source=1) \ |
| 73 | $(if $(CONFIG_PKG_FORTIFY_SOURCE_2),--enable-fortify-source=2) \ |
| 74 | --enable-kernel=4.14.0 |
| 75 | |
| 76 | export libc_cv_ssp=no |
| 77 | export libc_cv_ssp_strong=no |
| 78 | export ac_cv_header_cpuid_h=yes |
| 79 | export HOST_CFLAGS := $(HOST_CFLAGS) -idirafter $(CURDIR)/$(PATH_PREFIX)/include |
| 80 | |
| 81 | define Host/SetToolchainInfo |
| 82 | $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk |
| 83 | $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk |
| 84 | $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk |
| 85 | $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk |
| 86 | endef |
| 87 | |
| 88 | define Host/Configure |
| 89 | mkdir -p $(CUR_BUILD_DIR) |
| 90 | ( cd $(CUR_BUILD_DIR); rm -f config.cache; \ |
| 91 | $(GLIBC_CONFIGURE) \ |
| 92 | ); |
| 93 | endef |
| 94 | |
| 95 | define Host/Prepare |
| 96 | $(call Host/Prepare/Default) |
| 97 | ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) |
| 98 | endef |
| 99 | |
| 100 | define Host/Clean |
| 101 | rm -rf $(CUR_BUILD_DIR)* \ |
| 102 | $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \ |
| 103 | $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) |
| 104 | endef |