Merge #10419: [trivial] Fix three recently introduced typos
[bitcoinplatinum.git] / depends / Makefile
blobdedb0674cf14974702cefc520b4ad0da309a940b
1 .NOTPARALLEL :
3 SOURCES_PATH ?= $(BASEDIR)/sources
4 BASE_CACHE ?= $(BASEDIR)/built
5 SDK_PATH ?= $(BASEDIR)/SDKs
6 NO_QT ?=
7 NO_WALLET ?=
8 NO_UPNP ?=
9 FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources
11 BUILD = $(shell ./config.guess)
12 HOST ?= $(BUILD)
13 PATCHES_PATH = $(BASEDIR)/patches
14 BASEDIR = $(CURDIR)
15 HASH_LENGTH:=11
16 DOWNLOAD_CONNECT_TIMEOUT:=10
17 DOWNLOAD_RETRIES:=3
18 HOST_ID_SALT ?= salt
19 BUILD_ID_SALT ?= salt
21 host:=$(BUILD)
22 ifneq ($(HOST),)
23 host:=$(HOST)
24 host_toolchain:=$(HOST)-
25 endif
27 ifneq ($(DEBUG),)
28 release_type=debug
29 else
30 release_type=release
31 endif
33 base_build_dir=$(BASEDIR)/work/build
34 base_staging_dir=$(BASEDIR)/work/staging
35 base_download_dir=$(BASEDIR)/work/download
36 canonical_host:=$(shell ./config.sub $(HOST))
37 build:=$(shell ./config.sub $(BUILD))
39 build_arch =$(firstword $(subst -, ,$(build)))
40 build_vendor=$(word 2,$(subst -, ,$(build)))
41 full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build))
42 build_os:=$(findstring linux,$(full_build_os))
43 build_os+=$(findstring darwin,$(full_build_os))
44 build_os:=$(strip $(build_os))
45 ifeq ($(build_os),)
46 build_os=$(full_build_os)
47 endif
49 host_arch=$(firstword $(subst -, ,$(canonical_host)))
50 host_vendor=$(word 2,$(subst -, ,$(canonical_host)))
51 full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host))
52 host_os:=$(findstring linux,$(full_host_os))
53 host_os+=$(findstring darwin,$(full_host_os))
54 host_os+=$(findstring mingw32,$(full_host_os))
55 host_os:=$(strip $(host_os))
56 ifeq ($(host_os),)
57 host_os=$(full_host_os)
58 endif
60 $(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)
61 $(host_arch)_$(host_os)_host=$(host)
62 host_prefix=$($(host_arch)_$(host_os)_prefix)
63 build_prefix=$(host_prefix)/native
64 build_host=$(build)
66 AT_$(V):=
67 AT_:=@
68 AT:=$(AT_$(V))
70 all: install
72 include hosts/$(host_os).mk
73 include hosts/default.mk
74 include builders/$(build_os).mk
75 include builders/default.mk
76 include packages/packages.mk
78 build_id_string:=$(BUILD_ID_SALT)
79 build_id_string+=$(shell $(build_CC) --version 2>/dev/null)
80 build_id_string+=$(shell $(build_AR) --version 2>/dev/null)
81 build_id_string+=$(shell $(build_CXX) --version 2>/dev/null)
82 build_id_string+=$(shell $(build_RANLIB) --version 2>/dev/null)
83 build_id_string+=$(shell $(build_STRIP) --version 2>/dev/null)
85 $(host_arch)_$(host_os)_id_string:=$(HOST_ID_SALT)
86 $(host_arch)_$(host_os)_id_string+=$(shell $(host_CC) --version 2>/dev/null)
87 $(host_arch)_$(host_os)_id_string+=$(shell $(host_AR) --version 2>/dev/null)
88 $(host_arch)_$(host_os)_id_string+=$(shell $(host_CXX) --version 2>/dev/null)
89 $(host_arch)_$(host_os)_id_string+=$(shell $(host_RANLIB) --version 2>/dev/null)
90 $(host_arch)_$(host_os)_id_string+=$(shell $(host_STRIP) --version 2>/dev/null)
92 qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages) $(qt_$(host_arch)_$(host_os)_packages)
93 wallet_packages_$(NO_WALLET) = $(wallet_packages)
94 upnp_packages_$(NO_UPNP) = $(upnp_packages)
96 packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_)
97 native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
99 ifneq ($(qt_packages_),)
100 native_packages += $(qt_native_packages)
101 endif
103 all_packages = $(packages) $(native_packages)
105 meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
107 $(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
109 include funcs.mk
111 toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
112 final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
113 final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
114 $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
115 $(AT)rm -rf $(@D)
116 $(AT)mkdir -p $(@D)
117 $(AT)echo copying packages: $^
118 $(AT)echo to: $(@D)
119 $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
120 $(AT)touch $@
122 $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
123 $(AT)@mkdir -p $(@D)
124 $(AT)sed -e 's|@HOST@|$(host)|' \
125 -e 's|@CC@|$(toolchain_path)$(host_CC)|' \
126 -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \
127 -e 's|@AR@|$(toolchain_path)$(host_AR)|' \
128 -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \
129 -e 's|@NM@|$(toolchain_path)$(host_NM)|' \
130 -e 's|@STRIP@|$(toolchain_path)$(host_STRIP)|' \
131 -e 's|@build_os@|$(build_os)|' \
132 -e 's|@host_os@|$(host_os)|' \
133 -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \
134 -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \
135 -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \
136 -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \
137 -e 's|@no_qt@|$(NO_QT)|' \
138 -e 's|@no_wallet@|$(NO_WALLET)|' \
139 -e 's|@no_upnp@|$(NO_UPNP)|' \
140 -e 's|@debug@|$(DEBUG)|' \
141 $< > $@
142 $(AT)touch $@
145 define check_or_remove_cached
146 mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
147 $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \
148 ( rm -f $($(package)_cached_checksum); \
149 if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )
150 endef
152 define check_or_remove_sources
153 mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \
154 test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \
155 ( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \
156 rm -f $($(package)_all_sources) $($(1)_fetched))) || true
157 endef
159 check-packages:
160 @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));)
161 check-sources:
162 @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
164 $(host_prefix)/share/config.site: check-packages
166 check-packages: check-sources
168 install: check-packages $(host_prefix)/share/config.site
171 download-one: check-sources $(all_sources)
173 download-osx:
174 @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one
175 download-linux:
176 @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
177 download-win:
178 @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
179 download: download-osx download-linux download-win
181 .PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources