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.
1define int_vars2#Set defaults for vars which may be overridden per-package3$(1)_cc=$$($$($(1)_type)_CC)4$(1)_cxx=$$($$($(1)_type)_CXX)5$(1)_objc=$$($$($(1)_type)_OBJC)6$(1)_objcxx=$$($$($(1)_type)_OBJCXX)7$(1)_ar=$$($$($(1)_type)_AR)8$(1)_ranlib=$$($$($(1)_type)_RANLIB)9$(1)_nm=$$($$($(1)_type)_NM)10$(1)_cflags=$$($$($(1)_type)_CFLAGS) \11$$($$($(1)_type)_$$(release_type)_CFLAGS) \12-pipe -std=$(C_STANDARD)13$(1)_cxxflags=$$($$($(1)_type)_CXXFLAGS) \14$$($$($(1)_type)_$$(release_type)_CXXFLAGS) \15-pipe -std=$(CXX_STANDARD)16$(1)_ldflags=$$($$($(1)_type)_LDFLAGS) \17$$($$($(1)_type)_$$(release_type)_LDFLAGS) \18-L$$($($(1)_type)_prefix)/lib19$(1)_cppflags=$$($$($(1)_type)_CPPFLAGS) \20$$($$($(1)_type)_$$(release_type)_CPPFLAGS) \21-I$$($$($(1)_type)_prefix)/include22$(1)_recipe_hash:=23endef25define int_get_all_dependencies26$(sort $(foreach dep,$(2),$(2) $(call int_get_all_dependencies,$(1),$($(dep)_dependencies))))27endef29define fetch_file_inner30( mkdir -p $$($(1)_download_dir) && echo Fetching $(3) from $(2) && \31$(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(2)/$(3)" && \32echo "$(5) $$($(1)_download_dir)/$(4).temp" > $$($(1)_download_dir)/.$(4).hash && \33$(build_SHA256SUM) -c $$($(1)_download_dir)/.$(4).hash && \34mv $$($(1)_download_dir)/$(4).temp $$($(1)_source_dir)/$(4) && \35rm -rf $$($(1)_download_dir) )36endef38define fetch_file39( $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5)) || \40$(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(4),$(4),$(5)))41endef43# Shell script to create a source tarball in $(1)_source from local directory44# $(1)_local_dir instead of downloading remote sources. Tarball is recreated if45# any paths in the local directory have a newer mtime, and checksum of the46# tarball is saved to $(1)_fetched and returned as output.47define fetch_local_dir_sha25648if ! [ -f $($(1)_source) ] || [ -n "$$(find $($(1)_local_dir) -newer $($(1)_source) | head -n1)" ]; then \49mkdir -p $(dir $($(1)_source)) && \50( \51cd $($(1)_local_dir) && \52find . -print0 | TZ=UTC xargs -0r $(build_TOUCH) && \53find . | LC_ALL=C sort | $(build_TAR) --no-recursion -c -f $($(1)_source) -T - \54) && \55rm -f $($(1)_fetched); \56fi && \57if ! [ -f $($(1)_fetched) ] || [ -n "$$(find $($(1)_source) -newer $($(1)_fetched))" ]; then \58mkdir -p $(dir $($(1)_fetched)) && \59cd $($(1)_source_dir) && \60$(build_SHA256SUM) $($(1)_all_sources) > $($(1)_fetched); \61fi && \62cut -d" " -f1 $($(1)_fetched)63endef65define int_get_build_recipe_hash66$(eval $(1)_patches_path?=$(PATCHES_PATH)/$(1))67$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $$(grep "^include " packages/$(1).mk | cut -d' ' -f2 | xargs) $(addprefix $($(1)_patches_path)/,$($(1)_patches)) | cut -d" " -f1))68# If $(1)_local_dir is set, create a tarball of the local directory contents to69# use as the source of the package, and include a hash of the tarball in the70# package id, so if directory contents change, the package and packages71# depending on it will be rebuilt.72$(if $($(1)_local_dir),$(eval $(1)_sha256_hash:=$(shell $(call fetch_local_dir_sha256,$(1)))))73$(if $($(1)_local_dir),$(eval $(1)_all_file_checksums+=$($(1)_sha256_hash)))74$(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1))75endef77define int_get_build_id78$(eval $(1)_dependencies += $($(1)_$(host_arch)_$(host_os)_dependencies) $($(1)_$(host_os)_dependencies))79$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($(1)_dependencies)))80$(foreach dep,$($(1)_all_dependencies),$(eval $(1)_build_id_deps+=$(dep)-$($(dep)_version)-$($(dep)_recipe_hash)))81$(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps) $($($(1)_type)_id))82$(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)))83final_build_id_long+=$($(package)_build_id_long)85#compute package-specific paths86$(1)_staging_dir=$(base_staging_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)87$(1)_staging_prefix_dir:=$$($(1)_staging_dir)$($($(1)_type)_prefix)88$(1)_extract_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)89$(1)_build_dir:=$$($(1)_extract_dir)/$$($(1)_build_subdir)90$(1)_cached_checksum:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz.hash91$(1)_patch_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)/.patches-$($(1)_build_id)92$(1)_cached:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz93$(1)_build_log:=$(BASEDIR)/$(1)-$($(1)_version)-$($(1)_build_id).log94endef96# Convert a string to a human-readable filename, replacing dot, slash, and space97# characters that could cause problems with dashes and collapsing them.98define int_friendly_file_name99$(subst $(null) $(null),-,$(strip $(subst ., ,$(subst /, ,$(1)))))100endef102define int_get_build_properties103$(1)_build_subdir?=.104$(1)_download_file?=$($(1)_file_name)105$(1)_source_dir:=$(SOURCES_PATH)106# If $(1)_file_name is empty and $(1)_local_dir is nonempty, set file name to a107# .tar file with a friendly filename named after the directory path.108$(if $($(1)_file_name),,$(if $($(1)_local_dir),$(eval $(1)_file_name:=$(call int_friendly_file_name,$($(1)_local_dir)).tar)))109$(1)_source:=$$($(1)_source_dir)/$($(1)_file_name)110$(1)_download_dir:=$(base_download_dir)/$(1)-$($(1)_version)111$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/112$(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources)114#stamps115$(1)_fetched=$(SOURCES_PATH)/download-stamps/.stamp_fetched-$(1)-$($(1)_file_name).hash116$(1)_extracted=$$($(1)_extract_dir)/.stamp_extracted117$(1)_preprocessed=$$($(1)_extract_dir)/.stamp_preprocessed118$(1)_cleaned=$$($(1)_extract_dir)/.stamp_cleaned119$(1)_built=$$($(1)_build_dir)/.stamp_built120$(1)_configured=$(host_prefix)/.$(1)_stamp_configured121$(1)_staged=$$($(1)_staging_dir)/.stamp_staged122$(1)_postprocessed=$$($(1)_staging_prefix_dir)/.stamp_postprocessed123$(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path))126#default commands127# The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior128$(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash))129$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) --no-same-owner --strip-components=1 -xf $$($(1)_source)130$(1)_preprocess_cmds ?= true131$(1)_build_cmds ?= true132$(1)_config_cmds ?= true133$(1)_stage_cmds ?= true134$(1)_set_vars ?=137all_sources+=$$($(1)_fetched)138endef139#$(foreach dep_target,$($(1)_all_dependencies),$(eval $(1)_dependency_targets=$($(dep_target)_cached)))142define int_config_attach_build_config143$(eval $(call $(1)_set_vars,$(1)))144$(1)_cflags+=$($(1)_cflags_$(release_type))145$(1)_cflags+=$($(1)_cflags_$(host_arch)) $($(1)_cflags_$(host_arch)_$(release_type))146$(1)_cflags+=$($(1)_cflags_$(host_os)) $($(1)_cflags_$(host_os)_$(release_type))147$(1)_cflags+=$($(1)_cflags_$(host_arch)_$(host_os)) $($(1)_cflags_$(host_arch)_$(host_os)_$(release_type))149$(1)_cxxflags+=$($(1)_cxxflags_$(release_type))150$(1)_cxxflags+=$($(1)_cxxflags_$(host_arch)) $($(1)_cxxflags_$(host_arch)_$(release_type))151$(1)_cxxflags+=$($(1)_cxxflags_$(host_os)) $($(1)_cxxflags_$(host_os)_$(release_type))152$(1)_cxxflags+=$($(1)_cxxflags_$(host_arch)_$(host_os)) $($(1)_cxxflags_$(host_arch)_$(host_os)_$(release_type))154$(1)_cppflags+=$($(1)_cppflags_$(release_type))155$(1)_cppflags+=$($(1)_cppflags_$(host_arch)) $($(1)_cppflags_$(host_arch)_$(release_type))156$(1)_cppflags+=$($(1)_cppflags_$(host_os)) $($(1)_cppflags_$(host_os)_$(release_type))157$(1)_cppflags+=$($(1)_cppflags_$(host_arch)_$(host_os)) $($(1)_cppflags_$(host_arch)_$(host_os)_$(release_type))159$(1)_ldflags+=$($(1)_ldflags_$(release_type))160$(1)_ldflags+=$($(1)_ldflags_$(host_arch)) $($(1)_ldflags_$(host_arch)_$(release_type))161$(1)_ldflags+=$($(1)_ldflags_$(host_os)) $($(1)_ldflags_$(host_os)_$(release_type))162$(1)_ldflags+=$($(1)_ldflags_$(host_arch)_$(host_os)) $($(1)_ldflags_$(host_arch)_$(host_os)_$(release_type))164$(1)_build_opts+=$$($(1)_build_opts_$(release_type))165$(1)_build_opts+=$$($(1)_build_opts_$(host_arch)) $$($(1)_build_opts_$(host_arch)_$(release_type))166$(1)_build_opts+=$$($(1)_build_opts_$(host_os)) $$($(1)_build_opts_$(host_os)_$(release_type))167$(1)_build_opts+=$$($(1)_build_opts_$(host_arch)_$(host_os)) $$($(1)_build_opts_$(host_arch)_$(host_os)_$(release_type))169$(1)_config_opts+=$$($(1)_config_opts_$(release_type))170$(1)_config_opts+=$$($(1)_config_opts_$(host_arch)) $$($(1)_config_opts_$(host_arch)_$(release_type))171$(1)_config_opts+=$$($(1)_config_opts_$(host_os)) $$($(1)_config_opts_$(host_os)_$(release_type))172$(1)_config_opts+=$$($(1)_config_opts_$(host_arch)_$(host_os)) $$($(1)_config_opts_$(host_arch)_$(host_os)_$(release_type))174$(1)_config_env+=$$($(1)_config_env_$(release_type))175$(1)_config_env+=$($(1)_config_env_$(host_arch)) $($(1)_config_env_$(host_arch)_$(release_type))176$(1)_config_env+=$($(1)_config_env_$(host_os)) $($(1)_config_env_$(host_os)_$(release_type))177$(1)_config_env+=$($(1)_config_env_$(host_arch)_$(host_os)) $($(1)_config_env_$(host_arch)_$(host_os)_$(release_type))179$(1)_config_env+=PKG_CONFIG_LIBDIR=$($($(1)_type)_prefix)/lib/pkgconfig180$(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig181$(1)_config_env+=PKG_CONFIG_SYSROOT_DIR=/182$(1)_config_env+=CMAKE_MODULE_PATH=$($($(1)_type)_prefix)/lib/cmake183$(1)_config_env+=PATH="$(build_prefix)/bin:$(PATH)"184$(1)_build_env+=PATH="$(build_prefix)/bin:$(PATH)"185$(1)_stage_env+=PATH="$(build_prefix)/bin:$(PATH)"187# Setting a --build type that differs from --host will explicitly enable188# cross-compilation mode. Note that --build defaults to the output of189# config.guess, which is what we set it too here. This also quells autoconf190# warnings, "If you wanted to set the --build type, don't use --host.",191# when using versions older than 2.70.192$(1)_autoconf=./configure --build=$(BUILD) --host=$($($(1)_type)_host) --prefix=$($($(1)_type)_prefix) --with-pic $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)"193ifneq ($($(1)_nm),)194$(1)_autoconf += NM="$$($(1)_nm)"195endif196ifneq ($($(1)_ranlib),)197$(1)_autoconf += RANLIB="$$($(1)_ranlib)"198endif199ifneq ($($(1)_ar),)200$(1)_autoconf += AR="$$($(1)_ar)"201endif202ifneq ($($(1)_cflags),)203$(1)_autoconf += CFLAGS="$$($(1)_cflags)"204endif205ifneq ($($(1)_cxxflags),)206$(1)_autoconf += CXXFLAGS="$$($(1)_cxxflags)"207endif208ifneq ($($(1)_cppflags),)209$(1)_autoconf += CPPFLAGS="$$($(1)_cppflags)"210endif211ifneq ($($(1)_ldflags),)212$(1)_autoconf += LDFLAGS="$$($(1)_ldflags)"213endif215# We hardcode the library install path to "lib" to match the PKG_CONFIG_PATH216# setting in depends/toolchain.cmake.in, which also hardcodes "lib".217# Without this setting, CMake by default would use the OS library218# directory, which might be "lib64" or something else, not "lib", on multiarch systems.219$(1)_cmake=env CC="$$($(1)_cc)" \220CFLAGS="$$($(1)_cppflags) $$($(1)_cflags)" \221CXX="$$($(1)_cxx)" \222CXXFLAGS="$$($(1)_cppflags) $$($(1)_cxxflags)" \223LDFLAGS="$$($(1)_ldflags)" \224cmake -G "Unix Makefiles" \225-DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" \226-DCMAKE_AR=`which $$($(1)_ar)` \227-DCMAKE_NM=`which $$($(1)_nm)` \228-DCMAKE_RANLIB=`which $$($(1)_ranlib)` \229-DCMAKE_INSTALL_LIBDIR=lib \230-DCMAKE_POSITION_INDEPENDENT_CODE=ON \231-DCMAKE_VERBOSE_MAKEFILE:BOOL=$(V) \232-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY:BOOL=TRUE \233$$($(1)_config_opts)234ifeq ($($(1)_type),build)235$(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib"236else237ifneq ($(host),$(build))238$(1)_cmake += -DCMAKE_SYSTEM_NAME=$($(host_os)_cmake_system_name)239$(1)_cmake += -DCMAKE_C_COMPILER_TARGET=$(host)240$(1)_cmake += -DCMAKE_CXX_COMPILER_TARGET=$(host)241endif242endif243endef245define int_add_cmds246ifneq ($(LOG),)247$(1)_logging = >>$$($(1)_build_log) 2>&1 || { if test -f $$($(1)_build_log); then cat $$($(1)_build_log); fi; exit 1; }248endif250$($(1)_fetched):
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.