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

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