Makefile 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # Main makefile for the host tools
  8. #
  9. curdir:=tools
  10. # subdirectories to descend into
  11. tools-y :=
  12. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  13. BUILD_TOOLCHAIN := y
  14. ifdef CONFIG_GCC_USE_GRAPHITE
  15. BUILD_ISL = y
  16. endif
  17. endif
  18. ifneq ($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_BRCMSMAC_USE_FW_FROM_WL),)
  19. BUILD_B43_TOOLS = y
  20. endif
  21. tools-y += autoconf
  22. tools-y += autoconf-archive
  23. tools-y += automake
  24. tools-y += bc
  25. tools-y += bison
  26. tools-y += cmake
  27. tools-y += cpio
  28. tools-y += dosfstools
  29. tools-y += e2fsprogs
  30. tools-y += expat
  31. tools-y += fakeroot
  32. tools-y += findutils
  33. tools-y += firmware-utils
  34. tools-y += flex
  35. tools-y += gengetopt
  36. tools-y += libressl
  37. tools-y += libtool
  38. tools-y += lzma
  39. tools-y += m4
  40. tools-y += make-ext4fs
  41. tools-y += meson
  42. tools-y += missing-macros
  43. tools-y += mkimage
  44. tools-y += mklibs
  45. tools-y += mtd-utils
  46. tools-y += mtools
  47. tools-y += ninja
  48. tools-y += padjffs2
  49. tools-y += patch-image
  50. tools-y += patchelf
  51. tools-y += pkgconf
  52. tools-y += quilt
  53. tools-y += squashfskit4
  54. tools-y += sstrip
  55. tools-y += zip
  56. tools-y += zlib
  57. tools-y += zstd
  58. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_B43_TOOLS),y) += b43-tools
  59. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_ISL),y) += isl
  60. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_TOOLCHAIN),y) += gmp mpc mpfr
  61. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_apm821xx)$(CONFIG_TARGET_gemini),y) += genext2fs
  62. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_ath79),y) += lzma-old squashfs
  63. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_mxs),y) += elftosb sdimage
  64. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_realtek),y) += 7z
  65. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_tegra),y) += cbootimage cbootimage-configs
  66. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USES_MINOR),y) += kernel2minor
  67. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_SPARSE),y) += sparse
  68. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_LLVM_BUILD),y) += llvm-bpf
  69. # builddir dependencies
  70. $(curdir)/autoconf/compile := $(curdir)/m4/compile
  71. $(curdir)/automake/compile := $(curdir)/autoconf/compile $(curdir)/pkgconf/compile $(curdir)/xz/compile
  72. $(curdir)/b43-tools/compile := $(curdir)/bison/compile
  73. $(curdir)/bc/compile := $(curdir)/bison/compile $(curdir)/libtool/compile
  74. $(curdir)/bison/compile := $(curdir)/flex/compile
  75. $(curdir)/cbootimage/compile += $(curdir)/automake/compile
  76. $(curdir)/cmake/compile += $(curdir)/libressl/compile $(curdir)/ninja/compile $(curdir)/expat/compile $(curdir)/xz/compile $(curdir)/zlib/compile $(curdir)/zstd/compile
  77. $(curdir)/dosfstools/compile := $(curdir)/automake/compile
  78. $(curdir)/e2fsprogs/compile := $(curdir)/libtool/compile
  79. $(curdir)/fakeroot/compile := $(curdir)/libtool/compile
  80. $(curdir)/findutils/compile := $(curdir)/bison/compile
  81. $(curdir)/firmware-utils/compile += $(curdir)/cmake/compile
  82. $(curdir)/flex/compile := $(curdir)/libtool/compile
  83. $(curdir)/genext2fs/compile := $(curdir)/libtool/compile
  84. $(curdir)/gengetopt/compile := $(curdir)/libtool/compile
  85. $(curdir)/gmp/compile := $(curdir)/libtool/compile
  86. $(curdir)/isl/compile := $(curdir)/gmp/compile
  87. $(curdir)/libressl/compile := $(curdir)/pkgconf/compile
  88. $(curdir)/libtool/compile := $(curdir)/automake/compile $(curdir)/missing-macros/compile
  89. $(curdir)/lzma-old/compile := $(curdir)/zlib/compile
  90. $(curdir)/llvm-bpf/compile := $(curdir)/cmake/compile
  91. $(curdir)/make-ext4fs/compile := $(curdir)/zlib/compile
  92. $(curdir)/meson/compile := $(curdir)/ninja/compile
  93. $(curdir)/missing-macros/compile := $(curdir)/autoconf/compile
  94. $(curdir)/mkimage/compile += $(curdir)/bison/compile $(curdir)/libressl/compile
  95. $(curdir)/mklibs/compile := $(curdir)/libtool/compile
  96. $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile
  97. $(curdir)/mpfr/compile := $(curdir)/gmp/compile
  98. $(curdir)/mtd-utils/compile := $(curdir)/libtool/compile $(curdir)/e2fsprogs/compile $(curdir)/zlib/compile
  99. $(curdir)/padjffs2/compile := $(curdir)/findutils/compile
  100. $(curdir)/patchelf/compile := $(curdir)/libtool/compile
  101. $(curdir)/pkgconf/compile := $(curdir)/meson/compile
  102. $(curdir)/quilt/compile := $(curdir)/autoconf/compile $(curdir)/findutils/compile
  103. $(curdir)/sdcc/compile := $(curdir)/bison/compile
  104. $(curdir)/squashfs/compile := $(curdir)/lzma-old/compile
  105. $(curdir)/squashfskit4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile
  106. $(curdir)/zstd/compile := $(curdir)/meson/compile
  107. ifneq ($(HOST_OS),Linux)
  108. $(curdir)/squashfskit4/compile += $(curdir)/coreutils/compile
  109. tools-y += coreutils
  110. endif
  111. ifeq ($(HOST_OS),Darwin)
  112. tools-y += bash
  113. else
  114. $(curdir)/dwarves/compile += $(curdir)/elfutils/compile
  115. $(curdir)/elfutils/compile := $(curdir)/m4/compile $(curdir)/zlib/compile
  116. tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_DWARVES),y) += dwarves
  117. tools-y += elfutils
  118. endif
  119. ifneq ($(CONFIG_CCACHE)$(CONFIG_SDK),)
  120. $(foreach tool, $(filter-out zstd zlib xz pkgconf patch ninja meson libressl expat cmake,$(tools-y)), $(eval $(curdir)/$(tool)/compile += $(curdir)/ccache/compile))
  121. tools-y += ccache
  122. $(curdir)/ccache/compile := $(curdir)/cmake/compile
  123. endif
  124. # in case there is no patch tool on the host we need to make patch tool a
  125. # dependency for tools which have patches directory
  126. $(foreach tool, $(tools-y), $(if $(wildcard $(curdir)/$(tool)/patches),$(eval $(curdir)/$(tool)/compile += $(curdir)/patch/compile)))
  127. $(foreach tool, $(filter-out xz,$(tools-y)), $(eval $(curdir)/$(tool)/compile += $(curdir)/xz/compile))
  128. # make any tool depend on tar, xz and patch to ensure that archives can be unpacked and patched properly
  129. tools-core := tar xz patch
  130. $(foreach tool, $(tools-y), $(eval $(curdir)/$(tool)/compile += $(patsubst %,$(curdir)/%/compile,$(tools-core))))
  131. tools-y += $(tools-core)
  132. # make core tools depend on sed and flock
  133. $(foreach tool, $(filter-out xz,$(tools-core)), $(eval $(curdir)/$(tool)/compile += $(curdir)/sed/compile))
  134. $(curdir)/xz/compile += $(curdir)/flock/compile
  135. $(curdir)/sed/compile := $(curdir)/flock/compile $(curdir)/xz/compile
  136. tools-y += flock sed
  137. $(curdir)/autoremove := 1
  138. $(curdir)/builddirs := $(tools-y) $(tools-dep) $(tools-)
  139. $(curdir)/builddirs-default := $(tools-y)
  140. ifdef CHECK_ALL
  141. $(curdir)/builddirs-check:=$($(curdir)/builddirs)
  142. $(curdir)/builddirs-download:=$($(curdir)/builddirs)
  143. endif
  144. ifndef DUMP_TARGET_DB
  145. define PrepareStaging
  146. @for dir in $(1); do ( \
  147. $(if $(QUIET),,set -x;) \
  148. mkdir -p "$$dir"; \
  149. cd "$$dir"; \
  150. mkdir -p bin lib stamp usr/include usr/lib; \
  151. ); done
  152. endef
  153. $(BIN_DIR):
  154. mkdir -p $@
  155. # preparatory work
  156. $(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
  157. $(call PrepareStaging,$(STAGING_DIR))
  158. mkdir -p $(BUILD_DIR)/stamp
  159. touch $@
  160. $(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
  161. $(call PrepareStaging,$(STAGING_DIR_HOST))
  162. mkdir -p $(BUILD_DIR_HOST)/stamp $(STAGING_DIR_HOST)/include/sys
  163. $(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
  164. $(INSTALL_DATA) $(TOPDIR)/tools/include/sys/*.h $(STAGING_DIR_HOST)/include/sys/
  165. ifneq ($(HOST_OS),Linux)
  166. mkdir -p $(STAGING_DIR_HOST)/include/asm
  167. $(INSTALL_DATA) $(TOPDIR)/tools/include/asm/*.h $(STAGING_DIR_HOST)/include/asm/
  168. endif
  169. ln -snf lib $(STAGING_DIR_HOST)/lib64
  170. touch $@
  171. endif
  172. $(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $(BIN_DIR)
  173. $(curdir)//compile = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $(BIN_DIR)
  174. # prerequisites for the individual targets
  175. $(curdir)/ := .config prereq
  176. $(curdir)/install: $(curdir)/compile
  177. tools_enabled = $(foreach tool,$(sort $(tools-y) $(tools-)),$(if $(filter $(tool),$(tools-y)),y,n))
  178. $(eval $(call stampfile,$(curdir),tools,compile,,_$(subst $(space),,$(tools_enabled)),$(STAGING_DIR_HOST)))
  179. $(eval $(call stampfile,$(curdir),tools,check,$(TMP_DIR)/.build,,$(STAGING_DIR_HOST)))
  180. $(eval $(call subdir,$(curdir)))