.DEFAULT_GOAL := all # Copyright (c) 2026 Agrarian Developers # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php. SHELL := /bin/bash BASEDIR := $(CURDIR) BUILD ?= $(shell ./config.guess) HOST ?= $(BUILD) build := $(BUILD) host := $(HOST) PATCHES_PATH ?= $(BASEDIR)/patches SOURCES_PATH ?= $(BASEDIR)/sources BASE_CACHE ?= $(BASEDIR)/built workdir ?= $(BASEDIR)/work base_build_dir ?= $(workdir)/build base_staging_dir ?= $(workdir)/staging base_download_dir ?= $(workdir)/download HASH_LENGTH ?= 8 # Derive build_os for builder tooling (host_os comes from hosts/$(host).mk) build_os := ifneq (,$(findstring linux,$(build))) build_os := linux else ifneq (,$(findstring darwin,$(build))) build_os := darwin else build_os := linux endif # Host-triplet file (must exist) HOST_MK := hosts/$(host).mk ifeq ($(wildcard $(HOST_MK)),) $(error Missing $(HOST_MK). Create it under depends/hosts/.) endif # Common recipe dependencies for build-id hashing meta_depends = \ Makefile \ funcs.mk \ builders/default.mk \ builders/$(build_os).mk \ hosts/default.mk \ $(HOST_MK) \ packages/packages.mk include $(HOST_MK) include builders/default.mk include builders/$(build_os).mk include packages/packages.mk include funcs.mk # -------------------------------------------------------------------- # IMPORTANT: # Do NOT depend on $($(p)_cached_checksum) here — those vars are created # later (inside funcs.mk macros), so they'd expand to empty at parse-time. # Instead depend on the package phony targets (boost, openssl, etc). # -------------------------------------------------------------------- .PHONY: all all: install # Optional convenience targets (only build what you need) .PHONY: base wallet zmq upnp qt-deps base: $(packages) wallet: $(wallet_packages) zmq: $(zmq_packages) upnp: $(upnp_packages) qt-deps: $(qt_packages) $(qt_$(host_os)_packages) # Download-only: uses stage targets generated by funcs.mk .PHONY: download download: $(foreach p,$(all_packages),$($(p)_fetched)) # -------------------------------------------------------------------- # Beginner-friendly: populate depends/$(HOST)/ prefix from built cache # and generate share/config.site for top-level ./configure. # -------------------------------------------------------------------- .PHONY: install install-clean reinstall install-prefix install: install-prefix install-prefix: $(packages) @echo "== Installing depends into: $(host_prefix)" @rm -rf "$(host_prefix)" @mkdir -p "$(host_prefix)" @set -euo pipefail; \ for f in $(foreach p,$(packages),$($(p)_cached)); do \ p="$$(basename "$$(dirname "$$f")")"; \ if [[ ! -f "$$f" ]]; then \ echo "ERROR: expected current built artifact for $$p: $$f"; \ exit 1; \ fi; \ echo " - $$p: $$f"; \ tar --no-same-owner -xzf "$$f" -C "$(host_prefix)"; \ done ifneq ($(native_packages),) @echo "== Installing native depends into: $(build_prefix)" @rm -rf "$(build_prefix)" @mkdir -p "$(build_prefix)" @set -euo pipefail; \ for f in $(foreach p,$(native_packages),$($(p)_cached)); do \ p="$$(basename "$$(dirname "$$f")")"; \ if [[ ! -f "$$f" ]]; then \ echo "ERROR: expected current native built artifact for $$p: $$f"; \ exit 1; \ fi; \ echo " - $$p: $$f"; \ tar --no-same-owner -xzf "$$f" -C "$(build_prefix)"; \ done endif @echo "== Writing config.site: $(host_prefix)/share/config.site" @mkdir -p "$(host_prefix)/share" @{ \ echo "# Autoconf site defaults for Agrarian depends (generated)"; \ echo "depends_prefix='$(host_prefix)'"; \ echo "cross_compiling=maybe"; \ echo "host_alias='$(HOST)'"; \ echo "ac_tool_prefix='$(HOST)-'"; \ echo "with_boost='$(host_prefix)'"; \ echo "with_qt_incdir='$(host_prefix)/include'"; \ echo "with_qt_libdir='$(host_prefix)/lib'"; \ echo "with_qt_plugindir='$(host_prefix)/plugins'"; \ echo "with_qt_translationdir='$(host_prefix)/translations'"; \ echo "with_qt_bindir='$(host_prefix)/bin'"; \ echo "CPPFLAGS='-I$(host_prefix)/include'"; \ echo "LDFLAGS='-L$(host_prefix)/lib'"; \ echo "BOOST_CPPFLAGS='-I$(host_prefix)/include'"; \ echo "BOOST_LDFLAGS='-L$(host_prefix)/lib'"; \ echo "PATH=\"$(build_prefix)/bin:\$$PATH\""; \ echo "PKG_CONFIG='`which pkg-config` --static'"; \ echo "PKG_CONFIG_LIBDIR='$(host_prefix)/lib/pkgconfig:$(host_prefix)/share/pkgconfig'"; \ echo "PKG_CONFIG_PATH=\"\$$PKG_CONFIG_LIBDIR\""; \ echo "export PKG_CONFIG_LIBDIR"; \ echo "export PKG_CONFIG_PATH"; \ echo "export PKG_CONFIG"; \ echo "BDB_CFLAGS='-I$(host_prefix)/include'"; \ echo "BDB_LIBS='-L$(host_prefix)/lib -ldb_cxx-4.8 -ldb-4.8'"; \ } > "$(host_prefix)/share/config.site" @# Ensure boost headers are available under include/boost for configure probes. @set -euo pipefail; \ if [[ ! -e "$(host_prefix)/include/boost" ]]; then \ boost_inc="$$(ls -d "$(host_prefix)"/include/boost-* 2>/dev/null | sort -V | tail -n 1)"; \ if [[ -n "$$boost_inc" && -d "$$boost_inc/boost" ]]; then \ ln -sfn "$$(basename "$$boost_inc")/boost" "$(host_prefix)/include/boost"; \ fi; \ fi @# If Boost emits versioned/-mt libs, create non-mt and unversioned symlinks. @set -euo pipefail; \ shopt -s nullglob; \ for f in "$(host_prefix)"/lib/libboost_*-mt*; do \ if [[ -f "$$f" || -L "$$f" ]]; then \ base="$${f/-mt/}"; \ if [[ "$$base" != "$$f" ]]; then \ ln -sf "$$(basename "$$f")" "$$base"; \ fi; \ fi; \ done @set -euo pipefail; \ shopt -s nullglob; \ for f in "$(host_prefix)"/lib/libboost_*.a; do \ name="$$(basename "$$f")"; \ unversioned="$${name%%-gcc*}"; \ if [[ "$$unversioned" != "$$name" ]]; then \ if [[ ! -e "$(host_prefix)/lib/$$unversioned" ]]; then \ ln -sf "$$name" "$(host_prefix)/lib/$$unversioned"; \ fi; \ fi; \ done @if [[ "$(NO_QT)" = "0" ]] && [[ "$(host_os)" = "linux" ]]; then \ for lib in Qt6Core Qt6Gui Qt6Network Qt6Widgets; do \ if [[ ! -f "$(host_prefix)/lib/lib$${lib}.a" ]]; then \ echo "ERROR: missing Qt library lib$${lib}.a under $(host_prefix)/lib"; \ echo "Fix: make -C $(BASEDIR) HOST=$(HOST) USE_WALLET=$(USE_WALLET)"; \ exit 1; \ fi; \ done; \ for tool in qmake qt-cmake; do \ if [[ ! -x "$(host_prefix)/bin/$${tool}" ]]; then \ echo "ERROR: missing Qt tool $${tool} under $(host_prefix)/bin"; \ echo "Fix: make -C $(BASEDIR) HOST=$(HOST) USE_WALLET=$(USE_WALLET)"; \ exit 1; \ fi; \ done; \ fi @echo "== Done." install-clean: @rm -rf "$(host_prefix)" reinstall: install-clean install # -------------------------------------------------------------------- # Cleaning # - clean: removes working dirs only (keeps built cache + sources) # - clean-cache: removes built cache too # - distclean: removes everything generated by depends # -------------------------------------------------------------------- .PHONY: clean clean-cache distclean clean: @rm -rf "$(workdir)" clean-cache: clean @rm -rf "$(BASE_CACHE)" distclean: clean-cache @rm -rf "$(SOURCES_PATH)" "$(BASEDIR)/SDKs"