Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #
  2. # Copyright (C) 2006-2010 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:=eglibc
  9. PKG_VERSION:=$(call qstrip,$(CONFIG_EGLIBC_VERSION))
  10. PKG_REVISION:=$(call qstrip,$(CONFIG_EGLIBC_REVISION))
  11. PKG_SOURCE_PROTO:=svn
  12. PKG_SOURCE_VERSION:=$(PKG_REVISION)
  13. PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REVISION)
  14. PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
  15. ifneq ($(CONFIG_EGLIBC_VERSION_2_6),)
  16. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_6
  17. endif
  18. ifneq ($(CONFIG_EGLIBC_VERSION_2_7),)
  19. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_7
  20. endif
  21. ifneq ($(CONFIG_EGLIBC_VERSION_2_8),)
  22. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_8
  23. endif
  24. ifneq ($(CONFIG_EGLIBC_VERSION_2_9),)
  25. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_9
  26. endif
  27. ifneq ($(CONFIG_EGLIBC_VERSION_2_10),)
  28. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_10
  29. endif
  30. ifneq ($(CONFIG_EGLIBC_VERSION_2_11),)
  31. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_11
  32. endif
  33. ifneq ($(CONFIG_EGLIBC_VERSION_2_12),)
  34. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_12
  35. endif
  36. ifneq ($(CONFIG_EGLIBC_VERSION_TRUNK),)
  37. PKG_SOURCE_URL:=svn://svn.eglibc.org/trunk
  38. endif
  39. PATCH_DIR:=./patches/$(PKG_VERSION)
  40. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
  41. include $(INCLUDE_DIR)/toolchain-build.mk
  42. HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.eglibc_built
  43. HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.eglibc_installed
  44. HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
  45. HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
  46. # XXX: {e,}glibc does not build w/ -Os
  47. # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
  48. EGLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
  49. EGLIBC_CONFIGURE:= \
  50. BUILD_CC="$(HOSTCC)" \
  51. $(TARGET_CONFIGURE_OPTS) \
  52. CFLAGS="$(EGLIBC_CFLAGS)" \
  53. libc_cv_slibdir="/lib" \
  54. $(HOST_BUILD_DIR)/libc/configure \
  55. --prefix= \
  56. --build=$(GNU_HOST_NAME) \
  57. --host=$(REAL_GNU_TARGET_NAME) \
  58. --with-headers=$(TOOLCHAIN_DIR)/include \
  59. --disable-profile \
  60. --without-gd \
  61. --without-cvs \
  62. --enable-add-ons \
  63. ifeq ($(CONFIG_SOFT_FLOAT),)
  64. EGLIBC_CONFIGURE+= \
  65. --with-fp
  66. else
  67. EGLIBC_CONFIGURE+= \
  68. --without-fp
  69. endif
  70. EGLIBC_MAKE:= \
  71. $(MAKE) \
  72. define Host/SetToolchainInfo
  73. $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
  74. $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
  75. $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
  76. $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
  77. endef
  78. define Stage1/Configure
  79. mkdir -p $(HOST_BUILD_DIR1)
  80. $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR1)/
  81. ( cd $(HOST_BUILD_DIR1); rm -f config.cache; \
  82. $(EGLIBC_CONFIGURE) \
  83. );
  84. endef
  85. define Stage1/Compile
  86. endef
  87. define Stage1/Install
  88. mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/{include,lib}
  89. $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
  90. install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
  91. install-bootstrap-headers=yes \
  92. install-headers
  93. $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR1) \
  94. csu/subdir_lib
  95. ( cd $(HOST_BUILD_DIR1); \
  96. $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/ \
  97. )
  98. $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
  99. -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/libc.so
  100. endef
  101. define Stage2/Configure
  102. mkdir -p $(HOST_BUILD_DIR2)
  103. $(CP) $(HOST_BUILD_DIR)/libc/option-groups.config $(HOST_BUILD_DIR2)/
  104. ( cd $(HOST_BUILD_DIR2); rm -f config.cache; \
  105. $(EGLIBC_CONFIGURE) \
  106. );
  107. endef
  108. define Stage2/Compile
  109. $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) all
  110. endef
  111. define Stage2/Install
  112. $(EGLIBC_MAKE) -C $(HOST_BUILD_DIR2) \
  113. install_root="$(TOOLCHAIN_DIR)" \
  114. install
  115. ( cd $(TOOLCHAIN_DIR) ; \
  116. for d in lib usr/lib ; do \
  117. for f in libc.so libpthread.so libgcc_s.so ; do \
  118. if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
  119. $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
  120. fi \
  121. done \
  122. done \
  123. )
  124. endef
  125. define Host/Prepare
  126. $(call Host/SetToolchainInfo)
  127. $(call Host/Prepare/Default)
  128. ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  129. $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
  130. grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(HOST_BUILD_DIR)/libc/option-groups.config
  131. ln -sf ../ports $(HOST_BUILD_DIR)/libc/
  132. ( cd $(HOST_BUILD_DIR)/libc; autoconf --force )
  133. $(call Stage1/Configure)
  134. $(call Stage1/Compile)
  135. $(call Stage1/Install)
  136. endef
  137. define Host/Configure
  138. endef
  139. define Host/Compile
  140. $(call Stage2/Configure)
  141. $(call Stage2/Compile)
  142. $(call Stage2/Install)
  143. endef
  144. define Host/Install
  145. endef
  146. define Host/Clean
  147. rm -rf $(HOST_BUILD_DIR) $(HOST_BUILD_DIR1) $(HOST_BUILD_DIR2) \
  148. $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
  149. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  150. endef
  151. $(eval $(call HostBuild))