blob: a0077d252181c5830bf10eb804730760be01fe4d [file] [log] [blame]
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +02001################################################################################
2#
3# glibc/eglibc
4#
5################################################################################
6
Baruch Siach1ec6bc52014-06-02 06:42:04 +03007GLIBC_VERSION = $(call qstrip,$(BR2_GLIBC_VERSION_STRING))
8
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +02009ifeq ($(BR2_TOOLCHAIN_BUILDROOT_EGLIBC),y)
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +020010GLIBC_SITE = http://downloads.yoctoproject.org/releases/eglibc/
11GLIBC_SOURCE = eglibc-$(GLIBC_VERSION).tar.bz2
12GLIBC_SRC_SUBDIR = libc
13else
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +020014GLIBC_SITE = $(BR2_GNU_MIRROR)/libc
15GLIBC_SOURCE = glibc-$(GLIBC_VERSION).tar.xz
16GLIBC_SRC_SUBDIR = .
17endif
18
19GLIBC_LICENSE = GPLv2+ (programs), LGPLv2.1+, BSD-3c, MIT (library)
20GLIBC_LICENSE_FILES = $(addprefix $(GLIBC_SRC_SUBDIR)/,COPYING COPYING.LIB LICENSES)
21
Fabio Porceddab2fd9f92014-02-14 10:55:04 +010022# glibc is part of the toolchain so disable the toolchain dependency
23GLIBC_ADD_TOOLCHAIN_DEPENDENCY = NO
24
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +020025# Before (e)glibc is configured, we must have the first stage
26# cross-compiler and the kernel headers
Thomas Petazzonid8664dd2013-10-08 20:16:58 +020027GLIBC_DEPENDENCIES = host-gcc-initial linux-headers host-gawk
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +020028
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +020029GLIBC_SUBDIR = build
30
31GLIBC_INSTALL_STAGING = YES
32
33GLIBC_INSTALL_STAGING_OPT = install_root=$(STAGING_DIR) install
34
35# Thumb build is broken, build in ARM mode
36ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
37GLIBC_EXTRA_CFLAGS += -marm
38endif
39
Markos Chandras3dfa23f2013-09-25 16:00:57 +010040# MIPS64 defaults to n32 so pass the correct -mabi if
41# we are using a different ABI. OABI32 is also used
42# in MIPS so we pass -mabi=32 in this case as well
43# even though it's not strictly necessary.
44ifeq ($(BR2_MIPS_NABI64),y)
45GLIBC_EXTRA_CFLAGS += -mabi=64
46else ifeq ($(BR2_MIPS_OABI32),y)
47GLIBC_EXTRA_CFLAGS += -mabi=32
48endif
49
Thomas Petazzoni03b05402013-10-08 20:16:59 +020050# The stubs.h header is not installed by install-headers, but is
51# needed for the gcc build. An empty stubs.h will work, as explained
52# in http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html. The same trick
53# is used by Crosstool-NG.
54ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GLIBC),y)
55define GLIBC_ADD_MISSING_STUB_H
56 mkdir -p $(STAGING_DIR)/usr/include/gnu
57 touch $(STAGING_DIR)/usr/include/gnu/stubs.h
58endef
59endif
60
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +020061# Even though we use the autotools-package infrastructure, we have to
62# override the default configure commands for several reasons:
63#
64# 1. We have to build out-of-tree, but we can't use the same
65# 'symbolic link to configure' used with the gcc packages.
66#
67# 2. We have to execute the configure script with bash and not sh.
68#
69# Note that as mentionned in
70# http://patches.openembedded.org/patch/38849/, eglibc/glibc must be
71# built with -O2, so we pass our own CFLAGS and CXXFLAGS below.
72define GLIBC_CONFIGURE_CMDS
73 mkdir -p $(@D)/build
74 # Do the configuration
75 (cd $(@D)/build; \
76 $(TARGET_CONFIGURE_OPTS) \
77 CFLAGS="-O2 $(GLIBC_EXTRA_CFLAGS)" CPPFLAGS="" \
78 CXXFLAGS="-O2 $(GLIBC_EXTRA_CFLAGS)" \
79 $(SHELL) $(@D)/$(GLIBC_SRC_SUBDIR)/configure \
80 ac_cv_path_BASH_SHELL=/bin/bash \
81 libc_cv_forced_unwind=yes \
82 --target=$(GNU_TARGET_NAME) \
83 --host=$(GNU_TARGET_NAME) \
84 --build=$(GNU_HOST_NAME) \
85 --prefix=/usr \
86 --enable-shared \
87 $(if $(BR2_SOFT_FLOAT),--without-fp,--with-fp) \
88 --with-pkgversion="Buildroot" \
89 --without-cvs \
90 --disable-profile \
91 --without-gd \
92 --enable-obsolete-rpc \
93 --with-headers=$(STAGING_DIR)/usr/include)
94 # Install headers and start files
95 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build \
96 install_root=$(STAGING_DIR) \
97 install-bootstrap-headers=yes \
98 install-headers
99 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build csu/subdir_lib
100 cp $(@D)/build/csu/crt1.o $(STAGING_DIR)/usr/lib/
101 cp $(@D)/build/csu/crti.o $(STAGING_DIR)/usr/lib/
102 cp $(@D)/build/csu/crtn.o $(STAGING_DIR)/usr/lib/
Thomas Petazzoni03b05402013-10-08 20:16:59 +0200103 $(GLIBC_ADD_MISSING_STUB_H)
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +0200104 $(TARGET_CROSS)gcc -nostdlib \
105 -nostartfiles -shared -x c /dev/null -o $(STAGING_DIR)/usr/lib/libc.so
106endef
107
108
109#
110# We also override the install to target commands since we only want
111# to install the libraries, and nothing more.
112#
113
114GLIBC_LIBS_LIB = \
Thomas Petazzoni186a99b2013-10-08 20:17:06 +0200115 ld*.so.* libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* libm.so.* \
116 libnsl.so.* libpthread.so.* libresolv.so.* librt.so.* libutil.so.* \
117 libnss_files.so.* libnss_dns.so.*
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +0200118
Thomas Petazzoni934f8222013-10-29 21:54:02 +0100119ifeq ($(BR2_PACKAGE_GDB),y)
Thomas Petazzoni186a99b2013-10-08 20:17:06 +0200120GLIBC_LIBS_LIB += libthread_db.so.*
Thomas Petazzoni14a2d0b2013-09-02 18:06:33 +0200121endif
122
123define GLIBC_INSTALL_TARGET_CMDS
124 for libs in $(GLIBC_LIBS_LIB); do \
125 $(call copy_toolchain_lib_root,$(STAGING_DIR)/,,lib,$$libs,/lib) ; \
126 done
127endef
128
129$(eval $(autotools-package))
Fabio Porcedda6c5c08b2014-02-14 10:55:05 +0100130
131# Before (e)glibc is built, we must have the second stage cross-compiler
132$(GLIBC_TARGET_BUILD): | host-gcc-intermediate