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.

141 lines
4.8 KiB

  1. # Copyright 2005-2013 Intel Corporation. All Rights Reserved.
  2. #
  3. # This file is part of Threading Building Blocks.
  4. #
  5. # Threading Building Blocks is free software; you can redistribute it
  6. # and/or modify it under the terms of the GNU General Public License
  7. # version 2 as published by the Free Software Foundation.
  8. #
  9. # Threading Building Blocks is distributed in the hope that it will be
  10. # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  11. # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with Threading Building Blocks; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. #
  18. # As a special exception, you may use this file as part of a free software
  19. # library without restriction. Specifically, if other files instantiate
  20. # templates or use macros or inline functions from this file, or you compile
  21. # this file and link it with other files to produce an executable, this
  22. # file does not by itself cause the resulting executable to be covered by
  23. # the GNU General Public License. This exception does not however
  24. # invalidate any other reasons why the executable file might be covered by
  25. # the GNU General Public License.
  26. ifndef tbb_os
  27. # Windows sets environment variable OS; for other systems, ask uname
  28. ifeq ($(OS),)
  29. OS:=$(shell uname)
  30. ifeq ($(OS),)
  31. $(error "Cannot detect operating system")
  32. endif
  33. export tbb_os=$(OS)
  34. endif
  35. ifeq ($(OS), Windows_NT)
  36. export tbb_os=windows
  37. endif
  38. ifeq ($(OS), Linux)
  39. export tbb_os=linux
  40. endif
  41. ifeq ($(OS), Darwin)
  42. export tbb_os=macos
  43. endif
  44. endif # !tbb_os
  45. ifeq ($(tbb_cpf),1)
  46. export CPF_SUFFIX ?=_preview
  47. endif
  48. ifeq (,$(wildcard $(tbb_root)/build/$(tbb_os).inc))
  49. $(error "$(tbb_os)" is not supported. Add build/$(tbb_os).inc file with os-specific settings )
  50. endif
  51. # detect arch and runtime versions, provide common host-specific definitions
  52. include $(tbb_root)/build/$(tbb_os).inc
  53. ifeq ($(arch),)
  54. $(error Architecture not detected)
  55. endif
  56. ifeq ($(runtime),)
  57. $(error Runtime version not detected)
  58. endif
  59. # process target-dependent compilation and testing configurations
  60. ifdef target
  61. # optionally process target-dependent options for compilation and testing
  62. ifneq (,$(wildcard $(tbb_root)/build/$(target).inc))
  63. include $(tbb_root)/build/$(target).inc
  64. endif
  65. # optionally process host-dependent environment for target-dependent compilation and testing
  66. ifneq (,$(wildcard $(tbb_root)/build/$(target).$(tbb_os).inc))
  67. include $(tbb_root)/build/$(target).$(tbb_os).inc
  68. endif
  69. # insure at least one target-dependent configuration file was found for compilation and testing
  70. ifeq (,$(wildcard $(tbb_root)/build/$(target).inc)$(wildcard $(tbb_root)/build/$(target).$(tbb_os).inc))
  71. $(error "$(target)" is not supported. Add build/$(target).inc or build/$(target).$(tbb_os).inc file)
  72. endif
  73. endif #target
  74. # Support for running debug tests to release library and vice versa
  75. flip_cfg=$(subst _flipcfg,_release,$(subst _release,_debug,$(subst _debug,_flipcfg,$(1))))
  76. cross_cfg = $(if $(crosstest),$(call flip_cfg,$(1)),$(1))
  77. ifdef BUILDING_PHASE
  78. # Setting default configuration to release
  79. cfg?=release
  80. # No lambas or other C++0x extensions by default for compilers that implement them as experimental features
  81. # TODO: it should become unnecessary when all relevant tests are "moved" to the TEST_TBB_CPP11 set
  82. lambdas ?= 0
  83. cpp0x ?= 0
  84. ifndef target
  85. target:=$(tbb_os)
  86. endif
  87. # process host/target compiler-dependent build configuration
  88. ifeq (,$(wildcard $(tbb_root)/build/$(target).$(compiler).inc))
  89. $(error "$(compiler)" is not supported on $(target). Add build/$(target).$(compiler).inc file with compiler-specific settings. )
  90. endif
  91. include $(tbb_root)/build/$(target).$(compiler).inc
  92. endif
  93. ifneq ($(BUILDING_PHASE),1)
  94. # definitions for top-level Makefiles
  95. origin_build_dir:=$(origin tbb_build_dir)
  96. tbb_build_dir?=$(tbb_root)$(SLASH)build
  97. tbb_build_prefix?=$(tbb_os)_$(arch)_$(compiler)_$(runtime)$(CPF_SUFFIX)
  98. work_dir=$(tbb_build_dir)$(SLASH)$(tbb_build_prefix)
  99. endif # BUILDING_PHASE != 1
  100. ifdef offload
  101. extra_inc=$(offload).offload.inc
  102. endif
  103. ifdef extra_inc
  104. ifneq (,$(wildcard $(tbb_root)/build/$(extra_inc)))
  105. include $(tbb_root)/build/$(extra_inc)
  106. else
  107. $(error specified build file: "build/$(extra_inc)" is not found. )
  108. endif
  109. endif
  110. ifndef BUILDING_PHASE
  111. work_dir:=$(work_dir)
  112. # assign new value for tbb_root if path is not absolute (the filter keeps only /* paths)
  113. ifeq ($(filter /% $(SLASH)%, $(subst :, ,$(tbb_root)) ),)
  114. ifeq ($(origin_build_dir),undefined)
  115. override tbb_root:=../..
  116. else
  117. override tbb_root:=$(CWD)/$(tbb_root)
  118. endif
  119. endif
  120. export tbb_root
  121. endif # !BUILDING_PHASE
  122. .DELETE_ON_ERROR: # Make will delete target if error occurred when building it.