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