Makefile 5.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
BUILD_SCRIPT := $(CURDIR)/cmake/CMakeBuild/bin/cmake.py

# Define here a list of generic targets to be built separately using a suffix to select the variant and link option.
# Examples: <project> must be replaced by a make target defined below.
#
# How to build a single target:
#  make <project>-a  => build variant=debug,release,relwithdebinfo
#  make <project>-r  => build variant=release
#  make <project>-d  => build variant=debug
#  make <project>-p  => build variant=relwithdebinfo
#
# How to clean and build a single target:
#  make <project>-ca  => clean + build variant=debug,release,relwithdebinfo
#  make <project>-cr  => clean + build variant=release
#  make <project>-cd  => clean + build variant=debug
#  make <project>-cp  => clean + build variant=relwithdebinfo
#

TARGETS := CommonLib DecoderAnalyserApp DecoderAnalyserLib DecoderApp DecoderLib 
20
TARGETS += EncoderApp EncoderLib Utilities SEIRemovalApp StreamMergeApp
21 22

ifeq ($(OS),Windows_NT)
23 24 25 26 27
  ifneq ($(MSYSTEM),)
    # MSYS runtime environment
    UNAME_S := $(shell uname -s)
    PYTHON_LAUNCHER := python3
    BUILD_CMD := $(PYTHON_LAUNCHER) $(BUILD_SCRIPT)
28
  else
29 30 31 32 33 34 35 36 37 38 39 40
    UNAME_S := Windows
    PY := $(wildcard c:/windows/py.*)
    ifeq ($(PY),)
      PYTHON_LAUNCHER := python
    else
      PYTHON_LAUNCHER := $(notdir $(PY))
    endif
    # If a plain cmake.py is used, the exit codes won't arrive in make; i.e. build failures are reported as success by make.
    BUILD_CMD := $(PYTHON_LAUNCHER) $(BUILD_SCRIPT)
    ifeq ($(toolset),gcc)
      g := mgwmake
    endif
41 42 43
  endif
else
  UNAME_S := $(shell uname -s)
44
  BUILD_CMD := $(BUILD_SCRIPT)
45
  ifeq ($(UNAME_S),Linux)
46
    # for Jenkins: run trace build only on Linux
47
    LINUXBUILD := TRUE
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  endif
  ifeq ($(UNAME_S),Darwin)
    # MAC
  endif
endif

ifeq ($(j),)
BUILD_JOBS += -j
else
BUILD_JOBS += -j$(j)
endif

ifneq ($(g),)
CONFIG_OPTIONS += -g $(g)
endif

ifneq ($(toolset),)
65 66 67 68 69 70
  # aarch64 and mingw are two shortcuts to simplify toolset specification.
  ifeq ($(toolset),mingw)
    CONFIG_OPTIONS += toolset=x86_64-w64-mingw32-gcc-posix
  else
    CONFIG_OPTIONS += toolset=$(toolset)
  endif
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
endif

ifneq ($(address-model),)
CONFIG_OPTIONS += address-model=$(address-model)
endif

ifneq ($(address-sanitizer),)
CMAKE_OPTIONS += -DUSE_ADDRESS_SANITIZER=ON
endif

ifneq ($(verbose),)
CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE=ON
endif

ifneq ($(enable-tracing),)
CONFIG_OPTIONS += -DSET_ENABLE_TRACING=ON -DENABLE_TRACING=$(enable-tracing)
endif

ifneq ($(parallel-split),)
CONFIG_OPTIONS += -DSET_ENABLE_SPLIT_PARALLELISM=ON -DENABLE_SPLIT_PARALLELISM=$(parallel-split)
endif

ifneq ($(parallel-wpp),)
CONFIG_OPTIONS += -DSET_ENABLE_WPP_PARALLELISM=ON -DENABLE_WPP_PARALLELISM=$(parallel-wpp)
endif

ifneq ($(static),)
CONFIG_OPTIONS += -DBUILD_STATIC=$(static)
endif

BUILD_OPTIONS := $(CONFIG_OPTIONS) -b

debug:
104
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug
105 106

all:
107
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo
108 109

release:
110
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release
111 112

relwithdebinfo:
113
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo
114 115 116 117

clean:
	#  clean is equal to realclean to ensure that CMake options are reset
	$(RM) -rf bin build lib
118
#	$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --target clean
119 120

clean-r:
121
	$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target clean
122 123

clean-d:
124
	$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target clean
125 126

clean-p:
127
	$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target clean
128 129

configure:
130
	$(BUILD_CMD) $(CONFIG_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo
131

132 133
linuxbuild:
ifeq ($(LINUXBUILD),TRUE)
134
	# option for automated jenkins build
135 136
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug
endif
137

138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
#
# project specific targets
#

# build the list of release, debug targets given the generic targets
TARGETS_ALL := $(foreach t,$(TARGETS),$(t)-a)
TARGETS_RELEASE := $(foreach t,$(TARGETS),$(t)-r)
TARGETS_DEBUG := $(foreach t,$(TARGETS),$(t)-d)
TARGETS_RELWITHDEBINFO := $(foreach t,$(TARGETS),$(t)-p)

TARGETS_ALL_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-ca)
TARGETS_RELEASE_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cr)
TARGETS_DEBUG_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cd)
TARGETS_RELWITHDEBINFO_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cp)

$(TARGETS_ALL):
154
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --target $(patsubst %-a,%,$@)
155 156

$(TARGETS_ALL_CLEAN_FIRST):
157
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --clean-first --target $(patsubst %-ca,%,$@)
158 159

$(TARGETS_RELEASE):
160
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target $(patsubst %-r,%,$@)
161 162

$(TARGETS_RELEASE_CLEAN_FIRST):
163
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --clean-first --target $(patsubst %-cr,%,$@)
164 165

$(TARGETS_DEBUG):
166
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target $(patsubst %-d,%,$@)
167 168

$(TARGETS_DEBUG_CLEAN_FIRST):
169
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target $(patsubst %-cd,%,$@) --clean-first
170 171

$(TARGETS_RELWITHDEBINFO):
172
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target $(patsubst %-p,%,$@)
173 174

$(TARGETS_RELWITHDEBINFO_CLEAN_FIRST):
175
	$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target $(patsubst %-cp,%,$@) --clean-first
176 177 178 179 180

realclean:
	$(RM) -rf bin build lib

.NOTPARALLEL: