1.NOTPARALLEL : 2 3# Pattern rule to print variables, e.g. make print-top_srcdir 4print-%: 5 @echo $* = $($*) 6 7# When invoking a sub-make, keep only the command line variable definitions 8# matching the pattern in the filter function. 9# 10# e.g. invoking: 11# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS 12# 13# with the following in the Makefile: 14# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES)) 15# 16# will print: 17# MAKEOVERRIDES = A=1 18# MAKEFLAGS = -- A=1 19# 20# this is because as the GNU make manual says: 21# The command line variable definitions really appear in the variable 22# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable. 23# 24# and since the GNU make manual also says: 25# variables defined on the command line are passed to the sub-make through 26# MAKEFLAGS 27# 28# this means that sub-makes will be invoked as if: 29# $(MAKE) A=1 blah blah 30MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES)) 31SOURCES_PATH ?= $(BASEDIR)/sources 32WORK_PATH = $(BASEDIR)/work 33BASE_CACHE ?= $(BASEDIR)/built 34SDK_PATH ?= $(BASEDIR)/SDKs 35NO_QT ?= 36NO_QR ?= 37NO_WALLET ?= 38NO_ZMQ ?= 39NO_UPNP ?= 40MULTIPROCESS ?= 41FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources 42 43BUILD = $(shell ./config.guess) 44HOST ?= $(BUILD) 45PATCHES_PATH = $(BASEDIR)/patches 46BASEDIR = $(CURDIR) 47HASH_LENGTH:=11 48DOWNLOAD_CONNECT_TIMEOUT:=30 49DOWNLOAD_RETRIES:=3 50HOST_ID_SALT ?= salt 51BUILD_ID_SALT ?= salt 52 53host:=$(BUILD) 54ifneq ($(HOST),) 55host:=$(HOST) 56endif 57 58ifneq ($(DEBUG),) 59release_type=debug 60else 61release_type=release 62endif 63 64base_build_dir=$(WORK_PATH)/build 65base_staging_dir=$(WORK_PATH)/staging 66base_download_dir=$(WORK_PATH)/download 67canonical_host:=$(shell ./config.sub $(HOST)) 68build:=$(shell ./config.sub $(BUILD)) 69 70build_arch =$(firstword $(subst -, ,$(build))) 71build_vendor=$(word 2,$(subst -, ,$(build))) 72full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build)) 73build_os:=$(findstring linux,$(full_build_os)) 74build_os+=$(findstring darwin,$(full_build_os)) 75build_os:=$(strip $(build_os)) 76ifeq ($(build_os),) 77build_os=$(full_build_os) 78endif 79 80host_arch=$(firstword $(subst -, ,$(canonical_host))) 81host_vendor=$(word 2,$(subst -, ,$(canonical_host))) 82full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host)) 83host_os:=$(findstring linux,$(full_host_os)) 84host_os+=$(findstring darwin,$(full_host_os)) 85host_os+=$(findstring mingw32,$(full_host_os)) 86 87ifeq (android,$(findstring android,$(full_host_os))) 88host_os:=android 89endif 90 91host_os:=$(strip $(host_os)) 92ifeq ($(host_os),) 93host_os=$(full_host_os) 94endif 95 96$(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host) 97$(host_arch)_$(host_os)_host=$(host) 98host_prefix=$($(host_arch)_$(host_os)_prefix) 99build_prefix=$(host_prefix)/native 100build_host=$(build) 101 102AT_$(V):= 103AT_:=@ 104AT:=$(AT_$(V)) 105 106all: install 107 108include hosts/$(host_os).mk 109include hosts/default.mk 110include builders/$(build_os).mk 111include builders/default.mk 112include packages/packages.mk 113 114build_id_string:=$(BUILD_ID_SALT) 115build_id_string+=$(shell $(build_CC) --version 2>/dev/null) 116build_id_string+=$(shell $(build_AR) --version 2>/dev/null) 117build_id_string+=$(shell $(build_CXX) --version 2>/dev/null) 118build_id_string+=$(shell $(build_RANLIB) --version 2>/dev/null) 119build_id_string+=$(shell $(build_STRIP) --version 2>/dev/null) 120 121$(host_arch)_$(host_os)_id_string:=$(HOST_ID_SALT) 122$(host_arch)_$(host_os)_id_string+=$(shell $(host_CC) --version 2>/dev/null) 123$(host_arch)_$(host_os)_id_string+=$(shell $(host_AR) --version 2>/dev/null) 124$(host_arch)_$(host_os)_id_string+=$(shell $(host_CXX) --version 2>/dev/null) 125$(host_arch)_$(host_os)_id_string+=$(shell $(host_RANLIB) --version 2>/dev/null) 126$(host_arch)_$(host_os)_id_string+=$(shell $(host_STRIP) --version 2>/dev/null) 127 128ifneq ($(strip $(FORCE_USE_SYSTEM_CLANG)),) 129build_id_string+=system_clang 130$(host_arch)_$(host_os)_id_string+=system_clang 131endif 132 133qrencode_packages_$(NO_QR) = $(qrencode_packages) 134 135qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages) $(qt_$(host_arch)_$(host_os)_packages) $(qrencode_packages_) 136 137bdb_packages_$(NO_BDB) = $(bdb_packages) 138sqlite_packages_$(NO_SQLITE) = $(sqlite_packages) 139wallet_packages_$(NO_WALLET) = $(bdb_packages_) $(sqlite_packages_) 140 141upnp_packages_$(NO_UPNP) = $(upnp_packages) 142zmq_packages_$(NO_ZMQ) = $(zmq_packages) 143multiprocess_packages_$(MULTIPROCESS) = $(multiprocess_packages) 144 145packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) 146native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) 147 148ifneq ($(zmq_packages_),) 149packages += $(zmq_packages) 150endif 151 152ifeq ($(multiprocess_packages_),) 153packages += $(multiprocess_packages) 154native_packages += $(multiprocess_native_packages) 155endif 156 157all_packages = $(packages) $(native_packages) 158 159meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk 160 161$(host_arch)_$(host_os)_native_binutils?=$($(host_os)_native_binutils) 162$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain) 163 164include funcs.mk 165 166binutils_path=$($($(host_arch)_$(host_os)_native_binutils)_prefixbin) 167ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),) 168toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin) 169else 170toolchain_path= 171endif 172final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in) 173final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)) 174$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) 175 $(AT)rm -rf $(@D) 176 $(AT)mkdir -p $(@D) 177 $(AT)echo copying packages: $^ 178 $(AT)echo to: $(@D) 179 $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); ) 180 $(AT)touch $@ 181 182$(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id) 183 $(AT)@mkdir -p $(@D) 184 $(AT)sed -e 's|@HOST@|$(host)|' \ 185 -e 's|@CC@|$(toolchain_path)$(host_CC)|' \ 186 -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \ 187 -e 's|@AR@|$(binutils_path)$(host_AR)|' \ 188 -e 's|@RANLIB@|$(binutils_path)$(host_RANLIB)|' \ 189 -e 's|@NM@|$(binutils_path)$(host_NM)|' \ 190 -e 's|@STRIP@|$(binutils_path)$(host_STRIP)|' \ 191 -e 's|@build_os@|$(build_os)|' \ 192 -e 's|@host_os@|$(host_os)|' \ 193 -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \ 194 -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ 195 -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ 196 -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ 197 -e 's|@allow_host_packages@|$(ALLOW_HOST_PACKAGES)|' \ 198 -e 's|@no_qt@|$(NO_QT)|' \ 199 -e 's|@no_qr@|$(NO_QR)|' \ 200 -e 's|@no_zmq@|$(NO_ZMQ)|' \ 201 -e 's|@no_wallet@|$(NO_WALLET)|' \ 202 -e 's|@no_upnp@|$(NO_UPNP)|' \ 203 -e 's|@multiprocess@|$(MULTIPROCESS)|' \ 204 -e 's|@debug@|$(DEBUG)|' \ 205 $< > $@ 206 $(AT)touch $@ 207 208 209define check_or_remove_cached 210 mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \ 211 $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \ 212 ( rm -f $($(package)_cached_checksum); \ 213 if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi ) 214endef 215 216define check_or_remove_sources 217 mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \ 218 test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \ 219 ( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \ 220 rm -f $($(package)_all_sources) $($(1)_fetched))) || true 221endef 222 223check-packages: 224 @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));) 225check-sources: 226 @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));) 227 228$(host_prefix)/share/config.site: check-packages 229 230check-packages: check-sources 231 232clean-all: clean 233 @rm -rf $(SOURCES_PATH) x86_64* i686* mips* arm* aarch64* powerpc* riscv32* riscv64* s390x* 234 235clean: 236 @rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) 237 238install: check-packages $(host_prefix)/share/config.site 239 240 241download-one: check-sources $(all_sources) 242 243download-osx: 244 @$(MAKE) -s HOST=x86_64-apple-darwin14 download-one 245download-linux: 246 @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one 247download-win: 248 @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one 249download: download-osx download-linux download-win 250 251$(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package)))) 252 253.PHONY: install cached clean clean-all download-one download-osx download-linux download-win download check-packages check-sources 254