2
0

Makefile 4.7 KB

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