You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. .NOTPARALLEL :
  2. SOURCES_PATH ?= $(BASEDIR)/sources
  3. BASE_CACHE ?= $(BASEDIR)/built
  4. SDK_PATH ?= $(BASEDIR)/SDKs
  5. NO_QT ?=
  6. NO_WALLET ?=
  7. NO_UPNP ?=
  8. FALLBACK_DOWNLOAD_PATH ?= https://github.com/starwels/depends-sources
  9. BUILD = $(shell ./config.guess)
  10. HOST ?= $(BUILD)
  11. PATCHES_PATH = $(BASEDIR)/patches
  12. BASEDIR = $(CURDIR)
  13. HASH_LENGTH:=11
  14. DOWNLOAD_CONNECT_TIMEOUT:=10
  15. DOWNLOAD_RETRIES:=3
  16. HOST_ID_SALT ?= salt
  17. BUILD_ID_SALT ?= salt
  18. host:=$(BUILD)
  19. ifneq ($(HOST),)
  20. host:=$(HOST)
  21. host_toolchain:=$(HOST)-
  22. endif
  23. ifneq ($(DEBUG),)
  24. release_type=debug
  25. else
  26. release_type=release
  27. endif
  28. base_build_dir=$(BASEDIR)/work/build
  29. base_staging_dir=$(BASEDIR)/work/staging
  30. base_download_dir=$(BASEDIR)/work/download
  31. canonical_host:=$(shell ./config.sub $(HOST))
  32. build:=$(shell ./config.sub $(BUILD))
  33. build_arch =$(firstword $(subst -, ,$(build)))
  34. build_vendor=$(word 2,$(subst -, ,$(build)))
  35. full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build))
  36. build_os:=$(findstring linux,$(full_build_os))
  37. build_os+=$(findstring darwin,$(full_build_os))
  38. build_os:=$(strip $(build_os))
  39. ifeq ($(build_os),)
  40. build_os=$(full_build_os)
  41. endif
  42. host_arch=$(firstword $(subst -, ,$(canonical_host)))
  43. host_vendor=$(word 2,$(subst -, ,$(canonical_host)))
  44. full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host))
  45. host_os:=$(findstring linux,$(full_host_os))
  46. host_os+=$(findstring darwin,$(full_host_os))
  47. host_os+=$(findstring mingw32,$(full_host_os))
  48. host_os:=$(strip $(host_os))
  49. ifeq ($(host_os),)
  50. host_os=$(full_host_os)
  51. endif
  52. $(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)
  53. $(host_arch)_$(host_os)_host=$(host)
  54. host_prefix=$($(host_arch)_$(host_os)_prefix)
  55. build_prefix=$(host_prefix)/native
  56. build_host=$(build)
  57. AT_$(V):=
  58. AT_:=@
  59. AT:=$(AT_$(V))
  60. all: install
  61. include hosts/$(host_os).mk
  62. include hosts/default.mk
  63. include builders/$(build_os).mk
  64. include builders/default.mk
  65. include packages/packages.mk
  66. build_id_string:=$(BUILD_ID_SALT)
  67. build_id_string+=$(shell $(build_CC) --version 2>/dev/null)
  68. build_id_string+=$(shell $(build_AR) --version 2>/dev/null)
  69. build_id_string+=$(shell $(build_CXX) --version 2>/dev/null)
  70. build_id_string+=$(shell $(build_RANLIB) --version 2>/dev/null)
  71. build_id_string+=$(shell $(build_STRIP) --version 2>/dev/null)
  72. $(host_arch)_$(host_os)_id_string:=$(HOST_ID_SALT)
  73. $(host_arch)_$(host_os)_id_string+=$(shell $(host_CC) --version 2>/dev/null)
  74. $(host_arch)_$(host_os)_id_string+=$(shell $(host_AR) --version 2>/dev/null)
  75. $(host_arch)_$(host_os)_id_string+=$(shell $(host_CXX) --version 2>/dev/null)
  76. $(host_arch)_$(host_os)_id_string+=$(shell $(host_RANLIB) --version 2>/dev/null)
  77. $(host_arch)_$(host_os)_id_string+=$(shell $(host_STRIP) --version 2>/dev/null)
  78. qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages) $(qt_$(host_arch)_$(host_os)_packages)
  79. wallet_packages_$(NO_WALLET) = $(wallet_packages)
  80. upnp_packages_$(NO_UPNP) = $(upnp_packages)
  81. packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_)
  82. native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
  83. ifneq ($(qt_packages_),)
  84. native_packages += $(qt_native_packages)
  85. endif
  86. all_packages = $(packages) $(native_packages)
  87. meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
  88. $(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
  89. include funcs.mk
  90. toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
  91. final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
  92. final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
  93. $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
  94. $(AT)rm -rf $(@D)
  95. $(AT)mkdir -p $(@D)
  96. $(AT)echo copying packages: $^
  97. $(AT)echo to: $(@D)
  98. $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
  99. $(AT)touch $@
  100. $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
  101. $(AT)@mkdir -p $(@D)
  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|@allow_host_packages@|$(ALLOW_HOST_PACKAGES)|' \
  116. -e 's|@no_qt@|$(NO_QT)|' \
  117. -e 's|@no_wallet@|$(NO_WALLET)|' \
  118. -e 's|@no_upnp@|$(NO_UPNP)|' \
  119. -e 's|@debug@|$(DEBUG)|' \
  120. $< > $@
  121. $(AT)touch $@
  122. define check_or_remove_cached
  123. mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
  124. $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \
  125. ( rm -f $($(package)_cached_checksum); \
  126. if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )
  127. endef
  128. define check_or_remove_sources
  129. mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \
  130. test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \
  131. ( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \
  132. rm -f $($(package)_all_sources) $($(1)_fetched))) || true
  133. endef
  134. check-packages:
  135. @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));)
  136. check-sources:
  137. @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
  138. $(host_prefix)/share/config.site: check-packages
  139. check-packages: check-sources
  140. install: check-packages $(host_prefix)/share/config.site
  141. download-one: check-sources $(all_sources)
  142. download-osx:
  143. @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one
  144. download-linux:
  145. @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
  146. download-win:
  147. @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
  148. download: download-osx download-linux download-win
  149. .PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources