Makefile 8.4 KB

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