Merge pull request #6424
[bitcoinplatinum.git] / depends / Makefile
blobef5a20e6c36aa9c9cbb0fa9334ec8d24824a0bc2
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
19 host:=$(BUILD)
20 ifneq ($(HOST),)
21 host:=$(HOST)
22 host_toolchain:=$(HOST)-
23 endif
25 ifneq ($(DEBUG),)
26 release_type=debug
27 else
28 release_type=release
29 endif
31 base_build_dir=$(BASEDIR)/work/build
32 base_staging_dir=$(BASEDIR)/work/staging
33 base_download_dir=$(BASEDIR)/work/download
34 canonical_host:=$(shell ./config.sub $(HOST))
35 build:=$(shell ./config.sub $(BUILD))
37 build_arch =$(firstword $(subst -, ,$(build)))
38 build_vendor=$(word 2,$(subst -, ,$(build)))
39 full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build))
40 build_os:=$(findstring linux,$(full_build_os))
41 build_os+=$(findstring darwin,$(full_build_os))
42 build_os:=$(strip $(build_os))
43 ifeq ($(build_os),)
44 build_os=$(full_build_os)
45 endif
47 host_arch=$(firstword $(subst -, ,$(canonical_host)))
48 host_vendor=$(word 2,$(subst -, ,$(canonical_host)))
49 full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host))
50 host_os:=$(findstring linux,$(full_host_os))
51 host_os+=$(findstring darwin,$(full_host_os))
52 host_os+=$(findstring mingw32,$(full_host_os))
53 host_os:=$(strip $(host_os))
54 ifeq ($(host_os),)
55 host_os=$(full_host_os)
56 endif
58 $(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)
59 $(host_arch)_$(host_os)_host=$(host)
60 host_prefix=$($(host_arch)_$(host_os)_prefix)
61 build_prefix=$(host_prefix)/native
62 build_host=$(build)
64 AT_$(V):=
65 AT_:=@
66 AT:=$(AT_$(V))
68 all: install
70 include hosts/$(host_os).mk
71 include hosts/default.mk
72 include builders/$(build_os).mk
73 include builders/default.mk
74 include packages/packages.mk
76 qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages)
77 qt_native_packages_$(NO_QT) = $(qt_native_packages)
78 wallet_packages_$(NO_WALLET) = $(wallet_packages)
79 upnp_packages_$(NO_UPNP) = $(upnp_packages)
81 packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_)
82 native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) $(qt_native_packages_)
83 all_packages = $(packages) $(native_packages)
85 meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
87 $(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
89 include funcs.mk
91 toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
92 final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
93 final_build_id+=$(shell echo -n $(final_build_id_long) | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
94 $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
95 $(AT)rm -rf $(@D)
96 $(AT)mkdir -p $(@D)
97 $(AT)echo copying packages: $^
98 $(AT)echo to: $(@D)
99 $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
100 $(AT)touch $@
102 $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
103 $(AT)@mkdir -p $(@D)
104 $(AT)sed -e 's|@HOST@|$(host)|' \
105 -e 's|@CC@|$(toolchain_path)$(host_CC)|' \
106 -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \
107 -e 's|@AR@|$(toolchain_path)$(host_AR)|' \
108 -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \
109 -e 's|@NM@|$(toolchain_path)$(host_NM)|' \
110 -e 's|@STRIP@|$(toolchain_path)$(host_STRIP)|' \
111 -e 's|@build_os@|$(build_os)|' \
112 -e 's|@host_os@|$(host_os)|' \
113 -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \
114 -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \
115 -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \
116 -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \
117 -e 's|@no_qt@|$(NO_QT)|' \
118 -e 's|@no_wallet@|$(NO_WALLET)|' \
119 -e 's|@no_upnp@|$(NO_UPNP)|' \
120 -e 's|@debug@|$(DEBUG)|' \
121 $< > $@
122 $(AT)touch $@
125 define check_or_remove_cached
126 mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
127 $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \
128 ( rm -f $($(package)_cached_checksum); \
129 if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )
130 endef
132 define check_or_remove_sources
133 mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \
134 $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \
135 ( if test -f $($(package)_all_sources); then echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; fi; \
136 rm -f $($(package)_all_sources) $($(1)_fetched))
137 endef
139 check-packages:
140 @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));)
141 check-sources:
142 @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
144 $(host_prefix)/share/config.site: check-packages
146 check-packages: check-sources
148 install: check-packages $(host_prefix)/share/config.site
151 download-one: check-sources $(all_sources)
153 download-osx:
154 @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one
155 download-linux:
156 @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
157 download-win:
158 @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
159 download: download-osx download-linux download-win
161 .PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources