Makefile 7.4 KB

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