2014-07-22 22:31:30 -07:00
|
|
|
.NOTPARALLEL :
|
|
|
|
|
|
|
|
SOURCES_PATH ?= $(BASEDIR)/sources
|
|
|
|
BASE_CACHE ?= $(BASEDIR)/built
|
|
|
|
SDK_PATH ?= $(BASEDIR)/SDKs
|
|
|
|
NO_WALLET ?=
|
2020-08-07 01:13:23 -07:00
|
|
|
FALLBACK_DOWNLOAD_PATH ?= https://download.z.cash/depends-sources
|
2014-07-22 22:31:30 -07:00
|
|
|
|
2016-10-19 19:36:52 -07:00
|
|
|
BUILD ?= $(shell ./config.guess)
|
2014-07-22 22:31:30 -07:00
|
|
|
HOST ?= $(BUILD)
|
|
|
|
PATCHES_PATH = $(BASEDIR)/patches
|
|
|
|
BASEDIR = $(CURDIR)
|
|
|
|
HASH_LENGTH:=11
|
2014-08-27 00:40:30 -07:00
|
|
|
DOWNLOAD_CONNECT_TIMEOUT:=10
|
|
|
|
DOWNLOAD_RETRIES:=3
|
2018-03-16 07:14:52 -07:00
|
|
|
CRATE_REGISTRY:=vendored-sources
|
2014-07-22 22:31:30 -07:00
|
|
|
|
2019-09-07 01:05:56 -07:00
|
|
|
LIBRUSTZCASH_OVERRIDE ?=
|
|
|
|
|
2014-07-22 22:31:30 -07:00
|
|
|
host:=$(BUILD)
|
|
|
|
ifneq ($(HOST),)
|
|
|
|
host:=$(HOST)
|
|
|
|
host_toolchain:=$(HOST)-
|
|
|
|
endif
|
|
|
|
|
2014-09-23 13:59:03 -07:00
|
|
|
ifneq ($(DEBUG),)
|
|
|
|
release_type=debug
|
|
|
|
else
|
|
|
|
release_type=release
|
|
|
|
endif
|
|
|
|
|
2014-07-22 22:31:30 -07:00
|
|
|
base_build_dir=$(BASEDIR)/work/build
|
|
|
|
base_staging_dir=$(BASEDIR)/work/staging
|
2014-12-11 12:40:41 -08:00
|
|
|
base_download_dir=$(BASEDIR)/work/download
|
2014-07-22 22:31:30 -07:00
|
|
|
canonical_host:=$(shell ./config.sub $(HOST))
|
|
|
|
build:=$(shell ./config.sub $(BUILD))
|
|
|
|
|
|
|
|
build_arch =$(firstword $(subst -, ,$(build)))
|
|
|
|
build_vendor=$(word 2,$(subst -, ,$(build)))
|
|
|
|
full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build))
|
|
|
|
build_os:=$(findstring linux,$(full_build_os))
|
|
|
|
build_os+=$(findstring darwin,$(full_build_os))
|
2019-05-22 03:46:21 -07:00
|
|
|
build_os+=$(findstring freebsd,$(full_build_os))
|
2014-07-22 22:31:30 -07:00
|
|
|
build_os:=$(strip $(build_os))
|
|
|
|
ifeq ($(build_os),)
|
|
|
|
build_os=$(full_build_os)
|
|
|
|
endif
|
|
|
|
|
|
|
|
host_arch=$(firstword $(subst -, ,$(canonical_host)))
|
|
|
|
host_vendor=$(word 2,$(subst -, ,$(canonical_host)))
|
|
|
|
full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host))
|
|
|
|
host_os:=$(findstring linux,$(full_host_os))
|
|
|
|
host_os+=$(findstring darwin,$(full_host_os))
|
2019-05-22 03:46:21 -07:00
|
|
|
host_os+=$(findstring freebsd,$(full_host_os))
|
2014-07-22 22:31:30 -07:00
|
|
|
host_os+=$(findstring mingw32,$(full_host_os))
|
|
|
|
host_os:=$(strip $(host_os))
|
|
|
|
ifeq ($(host_os),)
|
|
|
|
host_os=$(full_host_os)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)
|
|
|
|
$(host_arch)_$(host_os)_host=$(host)
|
|
|
|
host_prefix=$($(host_arch)_$(host_os)_prefix)
|
2020-07-15 17:52:33 -07:00
|
|
|
crate_prefix=$(host_prefix)/$(CRATE_REGISTRY)
|
2014-07-22 22:31:30 -07:00
|
|
|
build_prefix=$(host_prefix)/native
|
|
|
|
build_host=$(build)
|
|
|
|
|
|
|
|
AT_$(V):=
|
|
|
|
AT_:=@
|
|
|
|
AT:=$(AT_$(V))
|
|
|
|
|
|
|
|
all: install
|
|
|
|
|
|
|
|
include hosts/$(host_os).mk
|
|
|
|
include hosts/default.mk
|
|
|
|
include builders/$(build_os).mk
|
|
|
|
include builders/default.mk
|
|
|
|
include packages/packages.mk
|
|
|
|
|
|
|
|
wallet_packages_$(NO_WALLET) = $(wallet_packages)
|
2019-11-12 02:11:08 -08:00
|
|
|
|
2020-07-15 17:52:33 -07:00
|
|
|
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(wallet_packages_)
|
2017-03-03 22:02:29 -08:00
|
|
|
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
|
2020-07-15 17:52:33 -07:00
|
|
|
all_packages = $(packages) $(rust_crates) $(native_packages)
|
2014-07-22 22:31:30 -07:00
|
|
|
|
2018-03-16 07:14:52 -07:00
|
|
|
meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk cargo-checksum.sh
|
2014-07-22 22:31:30 -07:00
|
|
|
|
2019-10-09 17:10:00 -07:00
|
|
|
$(host_arch)_$(host_os)_native_binutils?=$($(host_os)_native_binutils)
|
2014-07-22 22:31:30 -07:00
|
|
|
$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
|
|
|
|
|
|
|
|
include funcs.mk
|
|
|
|
|
2019-10-09 17:10:00 -07:00
|
|
|
binutils_path=$($($(host_arch)_$(host_os)_native_binutils)_prefixbin)
|
2014-07-22 22:31:30 -07:00
|
|
|
toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
|
|
|
|
final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
|
|
|
|
final_build_id+=$(shell echo -n $(final_build_id_long) | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
|
2020-07-15 17:52:33 -07:00
|
|
|
$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) $(rust_crates)
|
2014-07-22 22:31:30 -07:00
|
|
|
$(AT)rm -rf $(@D)
|
|
|
|
$(AT)mkdir -p $(@D)
|
2015-05-13 18:12:04 -07:00
|
|
|
$(AT)echo copying packages: $^
|
2014-07-22 22:31:30 -07:00
|
|
|
$(AT)echo to: $(@D)
|
2015-05-13 18:12:04 -07:00
|
|
|
$(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
|
2014-07-22 22:31:30 -07:00
|
|
|
$(AT)touch $@
|
|
|
|
|
|
|
|
$(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
|
|
|
|
$(AT)@mkdir -p $(@D)
|
|
|
|
$(AT)sed -e 's|@HOST@|$(host)|' \
|
|
|
|
-e 's|@CC@|$(toolchain_path)$(host_CC)|' \
|
|
|
|
-e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \
|
2019-10-09 17:10:00 -07:00
|
|
|
-e 's|@AR@|$(binutils_path)$(host_AR)|' \
|
|
|
|
-e 's|@RANLIB@|$(binutils_path)$(host_RANLIB)|' \
|
|
|
|
-e 's|@NM@|$(binutils_path)$(host_NM)|' \
|
|
|
|
-e 's|@STRIP@|$(binutils_path)$(host_STRIP)|' \
|
2014-07-22 22:31:30 -07:00
|
|
|
-e 's|@build_os@|$(build_os)|' \
|
|
|
|
-e 's|@host_os@|$(host_os)|' \
|
2014-09-23 13:59:03 -07:00
|
|
|
-e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \
|
|
|
|
-e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \
|
|
|
|
-e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \
|
|
|
|
-e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \
|
2020-07-15 17:52:33 -07:00
|
|
|
-e 's|@rust_target@|$(call rust_target,native_rust,$(canonical_host),$(host_os))|' \
|
2014-07-22 22:31:30 -07:00
|
|
|
-e 's|@no_wallet@|$(NO_WALLET)|' \
|
2014-09-23 13:59:03 -07:00
|
|
|
-e 's|@debug@|$(DEBUG)|' \
|
2014-07-22 22:31:30 -07:00
|
|
|
$< > $@
|
|
|
|
$(AT)touch $@
|
|
|
|
|
2015-05-13 18:12:04 -07:00
|
|
|
|
|
|
|
define check_or_remove_cached
|
|
|
|
mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
|
|
|
|
$(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \
|
|
|
|
( rm -f $($(package)_cached_checksum); \
|
|
|
|
if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )
|
|
|
|
endef
|
|
|
|
|
|
|
|
define check_or_remove_sources
|
|
|
|
mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \
|
|
|
|
$(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \
|
|
|
|
( if test -f $($(package)_all_sources); then echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; fi; \
|
|
|
|
rm -f $($(package)_all_sources) $($(1)_fetched))
|
|
|
|
endef
|
|
|
|
|
|
|
|
check-packages:
|
2020-08-10 11:23:06 -07:00
|
|
|
@$(foreach package,$(packages),$(call check_or_remove_cached,$(package));)
|
|
|
|
@$(foreach package,$(rust_crates),$(call check_or_remove_cached,$(package));)
|
|
|
|
@$(foreach package,$(native_packages),$(call check_or_remove_cached,$(package));)
|
2015-05-13 18:12:04 -07:00
|
|
|
check-sources:
|
2020-08-10 11:23:06 -07:00
|
|
|
@$(foreach package,$(packages),$(call check_or_remove_sources,$(package));)
|
|
|
|
@$(foreach package,$(rust_crates),$(call check_or_remove_sources,$(package));)
|
|
|
|
@$(foreach package,$(native_packages),$(call check_or_remove_sources,$(package));)
|
2015-05-13 18:12:04 -07:00
|
|
|
|
|
|
|
$(host_prefix)/share/config.site: check-packages
|
|
|
|
|
|
|
|
check-packages: check-sources
|
|
|
|
|
|
|
|
install: check-packages $(host_prefix)/share/config.site
|
|
|
|
|
|
|
|
|
|
|
|
download-one: check-sources $(all_sources)
|
|
|
|
|
2014-12-11 12:38:29 -08:00
|
|
|
download-osx:
|
2018-07-08 09:15:46 -07:00
|
|
|
@$(MAKE) -s HOST=x86_64-apple-darwin14 download-one
|
2014-12-11 12:38:29 -08:00
|
|
|
download-linux:
|
|
|
|
@$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
|
|
|
|
download-win:
|
|
|
|
@$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
|
|
|
|
download: download-osx download-linux download-win
|
2015-05-13 18:12:04 -07:00
|
|
|
|
|
|
|
.PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources
|