Makefile 4.2 KB

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