Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1.NOTPARALLEL :2# Disable builtin variables, rules and suffixes.3MAKEFLAGS += --no-builtin-rules --no-builtin-variables5# Pattern rule to print variables, e.g. make print-top_srcdir6print-%: FORCE7@echo '$*'='$($*)'9# When invoking a sub-make, keep only the command line variable definitions10# matching the pattern in the filter function.11#12# e.g. invoking:13# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS14#15# with the following in the Makefile:16# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES))17#18# will print:19# MAKEOVERRIDES = A=120# MAKEFLAGS = -- A=121#22# this is because as the GNU make manual says:23# The command line variable definitions really appear in the variable24# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable.25#26# and since the GNU make manual also says:27# variables defined on the command line are passed to the sub-make through28# MAKEFLAGS29#30# this means that sub-makes will be invoked as if:31# $(MAKE) A=1 blah blah32MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES))33SOURCES_PATH ?= $(BASEDIR)/sources34WORK_PATH = $(BASEDIR)/work35BASE_CACHE ?= $(BASEDIR)/built36SDK_PATH ?= $(BASEDIR)/SDKs37NO_BOOST ?=38NO_QT ?=39NO_QR ?=40NO_WALLET ?=41NO_ZMQ ?=42NO_USDT ?=43# Default NO_IPC value is 1 on Windows44NO_IPC ?= $(if $(findstring mingw32,$(HOST)),1,)45LTO ?=46FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources48C_STANDARD ?= c1149CXX_STANDARD ?= c++2051BUILD = $(shell unset CC && ./config.guess)52PATCHES_PATH = $(BASEDIR)/patches53BASEDIR = $(CURDIR)54HASH_LENGTH:=1155DOWNLOAD_CONNECT_TIMEOUT:=3056DOWNLOAD_RETRIES:=357HOST_ID_SALT ?= salt58BUILD_ID_SALT ?= salt60ifneq ($(DEBUG),)61release_type=debug62else63release_type=release64endif66base_build_dir=$(WORK_PATH)/build67base_staging_dir=$(WORK_PATH)/staging68base_download_dir=$(WORK_PATH)/download69build:=$(shell ./config.sub $(BUILD))71host:=$(build)72ifneq ($(HOST),)73host:=$(HOST)74endif75HOST ?= $(BUILD)76canonical_host:=$(shell ./config.sub $(HOST))78build_arch =$(firstword $(subst -, ,$(build)))79build_vendor=$(word 2,$(subst -, ,$(build)))80full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build))81build_os:=$(findstring linux,$(full_build_os))82build_os+=$(findstring darwin,$(full_build_os))83build_os+=$(findstring freebsd,$(full_build_os))84build_os+=$(findstring netbsd,$(full_build_os))85build_os+=$(findstring openbsd,$(full_build_os))86build_os:=$(strip $(build_os))87ifeq ($(build_os),)88build_os=$(full_build_os)89endif91host_arch=$(firstword $(subst -, ,$(canonical_host)))92host_vendor=$(word 2,$(subst -, ,$(canonical_host)))93full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host))94host_os:=$(findstring linux,$(full_host_os))95host_os+=$(findstring darwin,$(full_host_os))96host_os+=$(findstring freebsd,$(full_host_os))97host_os+=$(findstring netbsd,$(full_host_os))98host_os+=$(findstring openbsd,$(full_host_os))99host_os+=$(findstring mingw32,$(full_host_os))101host_os:=$(strip $(host_os))102ifeq ($(host_os),)103host_os=$(full_host_os)104endif106$(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)107$(host_arch)_$(host_os)_host=$(host)108host_prefix=$($(host_arch)_$(host_os)_prefix)109build_prefix=$(host_prefix)/native110build_host=$(build)112all: install114include hosts/$(host_os).mk115include hosts/default.mk116include builders/$(build_os).mk117include builders/default.mk118include packages/packages.mk120# Previously, we directly invoked the well-known programs using $(shell ...)121# to construct build_id_string. However, that was problematic because:122#123# 1. When invoking a shell, GNU Make special-cases exit code 127 (command not124# found) by not capturing the output but instead passing it through. This is125# not done for any other exit code.126#127# 2. Characters like '#' (from these programs' output) would end up in make128# variables like build_id_string, which would be wrongly interpreted by make129# when these variables were used.130#131# Therefore, we should avoid having arbitrary strings in make variables where132# possible. The gen_id script used here hashes the output to construct a133# "make-safe" id.134#135# Also note that these lines need to be:136#137# 1. After including {hosts,builders}/*.mk, since they rely on the tool138# variables (e.g. build_CC, host_STRIP, etc.) to be set.139#140# 2. Before including packages/*.mk (excluding packages/packages.mk), since141# they rely on the build_id variables142#143build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' \144AR='$(build_AR)' NM='$(build_NM)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' \145DEBUG='$(DEBUG)' \146./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')148$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' \149CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' LDFLAGS='$(LDFLAGS)' \150AR='$(host_AR)' NM='$(host_NM)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' \151DEBUG='$(DEBUG)' LTO='$(LTO)' \152./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')154boost_packages_$(NO_BOOST) = $(boost_packages)156qrencode_packages_$(NO_QR) = $(qrencode_$(host_os)_packages)158qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages) $(qt_$(host_arch)_$(host_os)_packages) $(qrencode_packages_)159qt_native_packages_$(NO_QT) = $(qt_native_packages)161wallet_packages_$(NO_WALLET) = $(sqlite_packages)163zmq_packages_$(NO_ZMQ) = $(zmq_packages)164ipc_packages_$(NO_IPC) = $(ipc_packages)165usdt_packages_$(NO_USDT) = $(usdt_$(host_os)_packages)167packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(boost_packages_) $(qt_packages_) $(wallet_packages_) $(usdt_packages_)168native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) $(qt_native_packages_)170ifneq ($(zmq_packages_),)171packages += $(zmq_packages)172endif174ifneq ($(ipc_packages_),)175packages += $(ipc_packages)176native_packages += $(multiprocess_native_packages)177endif179all_packages = $(packages) $(native_packages)181meta_depends = Makefile config.guess config.sub funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk183include funcs.mk185final_build_id_long+=$(shell $(build_SHA256SUM) toolchain.cmake.in)186final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))187$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)188rm -rf $(@D)189mkdir -p $(@D)190echo copying packages: $^191echo to: $(@D)192cd $(@D); $(foreach package,$^, $(build_TAR) xf $($(package)_cached); )193echo To build Bitcoin Core with these packages, pass \'--toolchain $(@D)/toolchain.cmake\' to the first CMake invocation.194touch $@196ifeq ($(host),$(build))197crosscompiling=FALSE198else199crosscompiling=TRUE200endif202$(host_prefix)/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_$(final_build_id)203@mkdir -p $(@D)204sed -e 's|@depends_crosscompiling@|$(crosscompiling)|' \205-e 's|@host@|$(host)|' \206-e 's|@host_system_name@|$($(host_os)_cmake_system_name)|' \207-e 's|@host_system_version@|$($(host_os)_cmake_system_version)|' \208-e 's|@host_arch@|$(host_arch)|' \209-e 's|@CC@|$(host_CC)|' \210-e 's|@CXX@|$(host_CXX)|' \211-e 's|@OSX_SDK@|$(OSX_SDK)|' \212-e 's|@AR@|$(host_AR)|' \213-e 's|@RANLIB@|$(host_RANLIB)|' \214-e 's|@STRIP@|$(host_STRIP)|' \215-e 's|@OBJCOPY@|$(host_OBJCOPY)|' \216-e 's|@OBJDUMP@|$(host_OBJDUMP)|' \217-e 's|@CFLAGS@|$(strip $(host_CFLAGS))|' \218-e 's|@CFLAGS_RELEASE@|$(strip $(host_release_CFLAGS))|' \219-e 's|@CFLAGS_DEBUG@|$(strip $(host_debug_CFLAGS))|' \220-e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS))|' \221-e 's|@CXXFLAGS_RELEASE@|$(strip $(host_release_CXXFLAGS))|' \222-e 's|@CXXFLAGS_DEBUG@|$(strip $(host_debug_CXXFLAGS))|' \223-e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS))|' \224-e 's|@CPPFLAGS_RELEASE@|$(strip $(host_release_CPPFLAGS))|' \225-e 's|@CPPFLAGS_DEBUG@|$(strip $(host_debug_CPPFLAGS))|' \226-e 's|@LDFLAGS@|$(strip $(host_LDFLAGS))|' \227-e 's|@LDFLAGS_RELEASE@|$(strip $(host_release_LDFLAGS))|' \228-e 's|@LDFLAGS_DEBUG@|$(strip $(host_debug_LDFLAGS))|' \229-e 's|@qt_packages@|$(qt_packages_)|' \230-e 's|@qrencode_packages@|$(qrencode_packages_)|' \231-e 's|@zmq_packages@|$(zmq_packages_)|' \232-e 's|@wallet_packages@|$(wallet_packages_)|' \233-e 's|@usdt_packages@|$(usdt_packages_)|' \234-e 's|@ipc_packages@|$(ipc_packages_)|' \235$< > $@236touch $@238define check_or_remove_cached239mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \240$(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \241( rm -f $($(package)_cached_checksum); \242if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )243endef245define check_or_remove_sources246mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \247test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \248( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \249rm -f $($(package)_all_sources) $($(1)_fetched))) || true250endef
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.