Makefile 4.1 KB

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