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