glibc.mk 4.2 KB

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