Makefile 7.5 KB

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