144 lines
4.3 KiB
Makefile
144 lines
4.3 KiB
Makefile
.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
|
|
base: $(packages)
|
|
wallet: $(wallet_packages)
|
|
zmq: $(zmq_packages)
|
|
upnp: $(upnp_packages)
|
|
qt: $(qt_packages) $(qt_$(host_os)_packages)
|
|
|
|
# Download-only: uses stage targets generated by funcs.mk
|
|
.PHONY: download
|
|
download: $(addsuffix _fetched,$(all_packages))
|
|
|
|
# --------------------------------------------------------------------
|
|
# 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 p in $(packages); do \
|
|
f="$(BASE_CACHE)/$(HOST)/$$p/"*.tar.gz; \
|
|
if ! ls $$f >/dev/null 2>&1; then \
|
|
echo "ERROR: missing built artifact for $$p (expected: $$f)"; \
|
|
exit 1; \
|
|
fi; \
|
|
echo " - $$p: $$f"; \
|
|
tar -xzf $$f -C "$(host_prefix)"; \
|
|
done
|
|
@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 "with_boost='$(host_prefix)'"; \
|
|
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 "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 "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"
|
|
@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"
|