3 SOURCES_PATH ?= $(BASEDIR)/sources
4 BASE_CACHE ?= $(BASEDIR)/built
5 SDK_PATH ?= $(BASEDIR)/SDKs
8 FALLBACK_DOWNLOAD_PATH ?= https://supernet/depends-sources
10 BUILD ?= $(shell ./config.guess)
12 PATCHES_PATH = $(BASEDIR)/patches
15 DOWNLOAD_CONNECT_TIMEOUT:=10
21 host_toolchain:=$(HOST)-
30 base_build_dir=$(BASEDIR)/work/build
31 base_staging_dir=$(BASEDIR)/work/staging
32 base_download_dir=$(BASEDIR)/work/download
33 canonical_host:=$(shell ./config.sub $(HOST))
34 build:=$(shell ./config.sub $(BUILD))
36 build_arch =$(firstword $(subst -, ,$(build)))
37 build_vendor=$(word 2,$(subst -, ,$(build)))
38 full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build))
39 build_os:=$(findstring linux,$(full_build_os))
40 build_os+=$(findstring darwin,$(full_build_os))
41 build_os:=$(strip $(build_os))
43 build_os=$(full_build_os)
46 host_arch=$(firstword $(subst -, ,$(canonical_host)))
47 host_vendor=$(word 2,$(subst -, ,$(canonical_host)))
48 full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host))
49 host_os:=$(findstring linux,$(full_host_os))
50 host_os+=$(findstring darwin,$(full_host_os))
51 host_os+=$(findstring mingw32,$(full_host_os))
52 host_os:=$(strip $(host_os))
54 host_os=$(full_host_os)
57 $(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)
58 $(host_arch)_$(host_os)_host=$(host)
59 host_prefix=$($(host_arch)_$(host_os)_prefix)
60 build_prefix=$(host_prefix)/native
69 include hosts/$(host_os).mk
70 include hosts/default.mk
71 include builders/$(build_os).mk
72 include builders/default.mk
73 include packages/packages.mk
75 rust_packages_$(NO_RUST) = $(rust_packages)
76 wallet_packages_$(NO_WALLET) = $(wallet_packages)
77 proton_packages_$(NO_PROTON) = $(proton_packages)
79 packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages_) $(proton_packages_) $(wallet_packages_)
80 native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
81 all_packages = $(packages) $(native_packages)
83 meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
85 $(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
89 toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
90 final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
91 final_build_id+=$(shell echo -n $(final_build_id_long) | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
92 $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
95 $(AT)echo copying packages: $^
97 $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
100 $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
102 $(AT)sed -e 's|@HOST@|$(host)|' \
103 -e 's|@CC@|$(toolchain_path)$(host_CC)|' \
104 -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \
105 -e 's|@AR@|$(toolchain_path)$(host_AR)|' \
106 -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \
107 -e 's|@NM@|$(toolchain_path)$(host_NM)|' \
108 -e 's|@STRIP@|$(toolchain_path)$(host_STRIP)|' \
109 -e 's|@build_os@|$(build_os)|' \
110 -e 's|@host_os@|$(host_os)|' \
111 -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \
112 -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \
113 -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \
114 -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \
115 -e 's|@no_wallet@|$(NO_WALLET)|' \
116 -e 's|@debug@|$(DEBUG)|' \
121 define check_or_remove_cached
122 mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
123 $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \
124 ( rm -f $($(package)_cached_checksum); \
125 if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )
128 define check_or_remove_sources
129 mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \
130 $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \
131 ( if test -f $($(package)_all_sources); then echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; fi; \
132 rm -f $($(package)_all_sources) $($(1)_fetched))
136 @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));)
138 @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
140 $(host_prefix)/share/config.site: check-packages
142 check-packages: check-sources
144 install: check-packages $(host_prefix)/share/config.site
147 download-one: check-sources $(all_sources)
150 @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one
152 @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
154 @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
155 download: download-osx download-linux download-win
157 .PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources