Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. ifeq ($(PKG_VERSION),2.6.1)
  16. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_6
  17. endif
  18. ifeq ($(PKG_VERSION),2.7)
  19. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_7
  20. endif
  21. ifeq ($(PKG_VERSION),2.8)
  22. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_8
  23. endif
  24. ifeq ($(PKG_VERSION),2.9)
  25. PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_9
  26. endif
  27. ifeq ($(PKG_VERSION),trunk)
  28. PKG_SOURCE_URL:=svn://svn.eglibc.org/trunk
  29. endif
  30. PATCH_DIR:=./patches/$(PKG_VERSION)
  31. STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
  32. BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
  33. PKG_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_SOURCE_SUBDIR)
  34. override CONFIG_AUTOREBUILD=
  35. include $(INCLUDE_DIR)/host-build.mk
  36. STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.eglibc_built
  37. STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.eglibc_installed
  38. PKG_BUILD_DIR1:=$(PKG_BUILD_DIR)-initial
  39. PKG_BUILD_DIR2:=$(PKG_BUILD_DIR)-final
  40. # XXX: {e,}glibc does not build w/ -Os
  41. # http://sourceware.org/bugzilla/show_bug.cgi?id=5203
  42. EGLIBC_CFLAGS:=$(subst -Os,-O2,$(TARGET_CFLAGS))
  43. EGLIBC_CONFIGURE:= \
  44. BUILD_CC="$(HOSTCC)" \
  45. $(TARGET_CONFIGURE_OPTS) \
  46. CFLAGS="$(EGLIBC_CFLAGS)" \
  47. $(PKG_BUILD_DIR)/libc/configure \
  48. --prefix=/usr \
  49. --build=$(GNU_HOST_NAME) \
  50. --host=$(REAL_GNU_TARGET_NAME) \
  51. --with-headers=$(TOOLCHAIN_DIR)/usr/include \
  52. --disable-profile \
  53. --without-gd \
  54. --without-cvs \
  55. --enable-add-ons \
  56. ifeq ($(CONFIG_SOFT_FLOAT),)
  57. EGLIBC_CONFIGURE+= \
  58. --with-fp
  59. else
  60. EGLIBC_CONFIGURE+= \
  61. --without-fp
  62. endif
  63. EGLIBC_MAKE:= \
  64. $(MAKE) \
  65. define Build/SetToolchainInfo
  66. $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
  67. $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
  68. $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
  69. $(SED) 's,^\(LIBC_PATCHVER\)=.*,\1=$(PKG_EXTRAVERSION),' $(TOOLCHAIN_DIR)/info.mk
  70. endef
  71. define Stage1/Configure
  72. mkdir -p $(PKG_BUILD_DIR1)
  73. $(CP) $(PKG_BUILD_DIR)/libc/option-groups.config $(PKG_BUILD_DIR1)/
  74. ( cd $(PKG_BUILD_DIR1); rm -f config.cache; \
  75. $(EGLIBC_CONFIGURE) \
  76. );
  77. endef
  78. define Stage1/Compile
  79. endef
  80. define Stage1/Install
  81. mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/{include,lib}
  82. $(EGLIBC_MAKE) -C $(PKG_BUILD_DIR1) \
  83. install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
  84. install-bootstrap-headers=yes \
  85. install-headers
  86. $(EGLIBC_MAKE) -C $(PKG_BUILD_DIR1) \
  87. csu/subdir_lib
  88. ( cd $(PKG_BUILD_DIR1); \
  89. $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/lib/ \
  90. )
  91. $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
  92. -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/usr/lib/libc.so
  93. endef
  94. define Stage2/Configure
  95. mkdir -p $(PKG_BUILD_DIR2)
  96. $(CP) $(PKG_BUILD_DIR)/libc/option-groups.config $(PKG_BUILD_DIR2)/
  97. ( cd $(PKG_BUILD_DIR2); rm -f config.cache; \
  98. $(EGLIBC_CONFIGURE) \
  99. );
  100. endef
  101. define Stage2/Compile
  102. $(EGLIBC_MAKE) -C $(PKG_BUILD_DIR2) all
  103. endef
  104. define Stage2/Install
  105. $(EGLIBC_MAKE) -C $(PKG_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 Build/Prepare
  119. $(call Build/SetToolchainInfo)
  120. $(call Build/Prepare/Default)
  121. ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  122. $(SED) 's,y,n,' $(PKG_BUILD_DIR)/libc/option-groups.defaults
  123. grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(PKG_BUILD_DIR)/libc/option-groups.config
  124. ln -sf ../ports $(PKG_BUILD_DIR)/libc/
  125. ( cd $(PKG_BUILD_DIR)/libc; autoconf --force )
  126. $(call Stage1/Configure)
  127. $(call Stage1/Compile)
  128. $(call Stage1/Install)
  129. endef
  130. define Build/Configure
  131. endef
  132. define Build/Compile
  133. $(call Stage2/Configure)
  134. $(call Stage2/Compile)
  135. $(call Stage2/Install)
  136. endef
  137. define Build/Install
  138. endef
  139. define Build/Clean
  140. rm -rf $(PKG_BUILD_DIR) $(PKG_BUILD_DIR1) $(PKG_BUILD_DIR2) \
  141. $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
  142. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  143. endef
  144. $(eval $(call HostBuild))