Makefile 8.9 KB

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