Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------- |
| 2 | # Clients fill in the source files to build |
| 3 | #---------------------------------------------------------------------- |
| 4 | # C_SOURCES := main.c |
| 5 | # CXX_SOURCES := |
| 6 | # OBJC_SOURCES := |
| 7 | # OBJCXX_SOURCES := |
| 8 | # DYLIB_C_SOURCES := |
Johnny Chen | e9f9770 | 2012-01-11 01:42:58 +0000 | [diff] [blame] | 9 | # DYLIB_CXX_SOURCES := |
| 10 | # |
| 11 | # Specifying DYLIB_ONLY has the effect of building dylib only, skipping |
| 12 | # the building of the a.out executable program. For example, |
| 13 | # DYLIB_ONLY := YES |
| 14 | # |
Johnny Chen | 64a7e74 | 2012-01-17 00:58:08 +0000 | [diff] [blame] | 15 | # Also might be of interest: |
Johnny Chen | 4876b5f | 2012-01-11 01:59:55 +0000 | [diff] [blame] | 16 | # FRAMEWORK_INCLUDES (Darwin only) := |
Robert Flack | fa8aa17 | 2015-04-20 18:07:55 +0000 | [diff] [blame] | 17 | # CFLAGS_EXTRAS := |
Johnny Chen | 4876b5f | 2012-01-11 01:59:55 +0000 | [diff] [blame] | 18 | # LD_EXTRAS := |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 19 | # SPLIT_DEBUG_SYMBOLS := YES |
Robert Flack | fa8aa17 | 2015-04-20 18:07:55 +0000 | [diff] [blame] | 20 | # CROSS_COMPILE := |
Johnny Chen | 64a7e74 | 2012-01-17 00:58:08 +0000 | [diff] [blame] | 21 | # |
| 22 | # And test/functionalities/archives/Makefile: |
| 23 | # MAKE_DSYM := NO |
| 24 | # ARCHIVE_NAME := libfoo.a |
| 25 | # ARCHIVE_C_SOURCES := a.c b.c |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 26 | |
| 27 | # Uncomment line below for debugging shell commands |
| 28 | # SHELL = /bin/sh -x |
| 29 | |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 30 | THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ |
| 31 | LLDB_BASE_DIR := $(THIS_FILE_DIR)../../ |
| 32 | |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 33 | |
| 34 | #---------------------------------------------------------------------- |
| 35 | # If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more |
| 36 | # from the triple alone |
| 37 | #---------------------------------------------------------------------- |
| 38 | TRIPLE_CFLAGS := |
| 39 | ifneq "$(TRIPLE)" "" |
| 40 | triple_space = $(subst -, ,$(TRIPLE)) |
| 41 | ARCH =$(word 1, $(triple_space)) |
| 42 | TRIPLE_VENDOR =$(word 2, $(triple_space)) |
| 43 | triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed -e 's/\(.*\)\([0-9]\.[0-9]\).*/\1 \2/') |
| 44 | TRIPLE_OS =$(word 1, $(triple_os_and_version)) |
| 45 | TRIPLE_VERSION =$(word 2, $(triple_os_and_version)) |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 46 | ifeq "$(TRIPLE_VENDOR)" "apple" |
| 47 | ifeq "$(TRIPLE_OS)" "ios" |
| 48 | ifeq "$(SDKROOT)" "" |
| 49 | # Set SDKROOT if it wasn't set |
| 50 | ifneq (,$(findstring arm,$(ARCH))) |
| 51 | SDKROOT = $(shell xcrun --sdk iphoneos --show-sdk-path) |
Greg Clayton | 5e3f20d | 2015-06-02 21:42:31 +0000 | [diff] [blame] | 52 | ifeq "$(TRIPLE_VERSION)" "" |
| 53 | TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/') |
| 54 | endif |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 55 | TRIPLE_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" |
| 56 | else |
| 57 | SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path) |
Greg Clayton | 5e3f20d | 2015-06-02 21:42:31 +0000 | [diff] [blame] | 58 | ifeq "$(TRIPLE_VERSION)" "" |
| 59 | TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/') |
| 60 | endif |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 61 | TRIPLE_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" |
| 62 | endif |
| 63 | endif |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 64 | endif |
| 65 | endif |
| 66 | endif |
| 67 | |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 68 | #---------------------------------------------------------------------- |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 69 | # If OS is not defined, use 'uname -s' to determine the OS name. |
Adrian McCarthy | b4b8bb7 | 2015-04-15 23:38:23 +0000 | [diff] [blame] | 70 | # |
| 71 | # uname on Windows gives "windows32", but most environments standardize |
| 72 | # on "Windows_NT", so we'll make it consistent here. When running |
| 73 | # tests from Visual Studio, the environment variable isn't inherited |
| 74 | # all the way down to the process spawned for make. |
| 75 | #---------------------------------------------------------------------- |
Chaoren Lin | d761a95 | 2015-09-16 21:51:51 +0000 | [diff] [blame] | 76 | HOST_OS = $(shell uname -s) |
| 77 | ifeq "$(HOST_OS)" "windows32" |
| 78 | HOST_OS = Windows_NT |
Adrian McCarthy | b4b8bb7 | 2015-04-15 23:38:23 +0000 | [diff] [blame] | 79 | endif |
Chaoren Lin | d761a95 | 2015-09-16 21:51:51 +0000 | [diff] [blame] | 80 | ifeq "$(OS)" "" |
| 81 | OS = $(HOST_OS) |
Adrian McCarthy | b4b8bb7 | 2015-04-15 23:38:23 +0000 | [diff] [blame] | 82 | endif |
| 83 | |
| 84 | #---------------------------------------------------------------------- |
| 85 | # If ARCH is not defined, default to x86_64. |
Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 86 | #---------------------------------------------------------------------- |
| 87 | ifeq "$(ARCH)" "" |
Zachary Turner | e068d91 | 2014-12-01 23:13:41 +0000 | [diff] [blame] | 88 | ifeq "$(OS)" "Windows_NT" |
| 89 | ARCH = x86 |
| 90 | else |
Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 91 | ARCH = x86_64 |
| 92 | endif |
Zachary Turner | e068d91 | 2014-12-01 23:13:41 +0000 | [diff] [blame] | 93 | endif |
Johnny Chen | 6c17c08 | 2010-09-16 20:54:06 +0000 | [diff] [blame] | 94 | |
| 95 | #---------------------------------------------------------------------- |
Johnny Chen | 597cbbb | 2011-08-23 21:54:10 +0000 | [diff] [blame] | 96 | # CC defaults to clang. |
Johnny Chen | 4ab4a9b | 2011-08-24 18:12:53 +0000 | [diff] [blame] | 97 | # |
| 98 | # If you change the defaults of CC, be sure to also change it in the file |
| 99 | # test/plugins/builder_base.py, which provides a Python way to return the |
| 100 | # value of the make variable CC -- getCompiler(). |
| 101 | # |
Johnny Chen | 6055b44 | 2011-01-14 20:55:13 +0000 | [diff] [blame] | 102 | # See also these functions: |
| 103 | # o cxx_compiler |
| 104 | # o cxx_linker |
Johnny Chen | d43e208 | 2011-01-14 20:46:49 +0000 | [diff] [blame] | 105 | #---------------------------------------------------------------------- |
Johnny Chen | 597cbbb | 2011-08-23 21:54:10 +0000 | [diff] [blame] | 106 | CC ?= clang |
Johnny Chen | d43e208 | 2011-01-14 20:46:49 +0000 | [diff] [blame] | 107 | ifeq "$(CC)" "cc" |
Vince Harron | 847e261 | 2015-05-27 04:42:54 +0000 | [diff] [blame] | 108 | ifneq "$(shell which clang)" "" |
| 109 | CC = clang |
| 110 | else ifneq "$(shell which clang-3.5)" "" |
| 111 | CC = clang-3.5 |
| 112 | else ifneq "$(shell which gcc)" "" |
| 113 | CC = gcc |
| 114 | endif |
Johnny Chen | d43e208 | 2011-01-14 20:46:49 +0000 | [diff] [blame] | 115 | endif |
| 116 | |
| 117 | #---------------------------------------------------------------------- |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 118 | # ARCHFLAG is the flag used to tell the compiler which architecture |
| 119 | # to compile for. The default is the flag that clang accepts. |
| 120 | #---------------------------------------------------------------------- |
Greg Clayton | 2c93b80 | 2015-04-16 01:18:05 +0000 | [diff] [blame] | 121 | ARCHFLAG ?= -arch |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 122 | |
| 123 | #---------------------------------------------------------------------- |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 124 | # Change any build/tool options needed |
| 125 | #---------------------------------------------------------------------- |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 126 | ifeq "$(OS)" "Darwin" |
Greg Clayton | 82625d3 | 2014-07-29 20:10:59 +0000 | [diff] [blame] | 127 | DS := $(shell xcrun -find -toolchain default dsymutil) |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 128 | DSFLAGS = |
| 129 | DSYM = $(EXE).dSYM |
Robert Flack | fa8aa17 | 2015-04-20 18:07:55 +0000 | [diff] [blame] | 130 | AR := $(CROSS_COMPILE)libtool |
Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 131 | ARFLAGS := -static -o |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 132 | else |
Robert Flack | fa8aa17 | 2015-04-20 18:07:55 +0000 | [diff] [blame] | 133 | AR := $(CROSS_COMPILE)ar |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 134 | # On non-Apple platforms, -arch becomes -m |
| 135 | ARCHFLAG := -m |
| 136 | |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 137 | # i386, i686, x86 -> 32 |
Zachary Turner | 7c1bc2b | 2014-07-31 21:07:41 +0000 | [diff] [blame] | 138 | # amd64, x86_64, x64 -> 64 |
Ed Maste | 4fe0aba | 2014-02-20 18:40:01 +0000 | [diff] [blame] | 139 | ifeq "$(ARCH)" "amd64" |
Zachary Turner | 7c1bc2b | 2014-07-31 21:07:41 +0000 | [diff] [blame] | 140 | override ARCH := $(subst amd64,64,$(ARCH)) |
Ed Maste | 4fe0aba | 2014-02-20 18:40:01 +0000 | [diff] [blame] | 141 | endif |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 142 | ifeq "$(ARCH)" "x86_64" |
Zachary Turner | 7c1bc2b | 2014-07-31 21:07:41 +0000 | [diff] [blame] | 143 | override ARCH := $(subst x86_64,64,$(ARCH)) |
| 144 | endif |
| 145 | ifeq "$(ARCH)" "x64" |
| 146 | override ARCH := $(subst x64,64,$(ARCH)) |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 147 | endif |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 148 | ifeq "$(ARCH)" "x86" |
| 149 | override ARCH := $(subst x86,32,$(ARCH)) |
| 150 | endif |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 151 | ifeq "$(ARCH)" "i386" |
Zachary Turner | 7c1bc2b | 2014-07-31 21:07:41 +0000 | [diff] [blame] | 152 | override ARCH := $(subst i386,32,$(ARCH)) |
| 153 | endif |
| 154 | ifeq "$(ARCH)" "i686" |
| 155 | override ARCH := $(subst i686,32,$(ARCH)) |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 156 | endif |
Justin Hibbits | 3cba1c2 | 2014-11-12 15:13:58 +0000 | [diff] [blame] | 157 | ifeq "$(ARCH)" "powerpc" |
| 158 | override ARCH := $(subst powerpc,32,$(ARCH)) |
| 159 | endif |
| 160 | ifeq "$(ARCH)" "powerpc64" |
| 161 | override ARCH := $(subst powerpc64,64,$(ARCH)) |
| 162 | endif |
Tamas Berghammer | 1e209fc | 2015-03-13 11:36:47 +0000 | [diff] [blame] | 163 | ifeq "$(ARCH)" "aarch64" |
| 164 | override ARCH := |
| 165 | override ARCHFLAG := |
| 166 | endif |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 167 | |
| 168 | ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" |
| 169 | DSYM = $(EXE).debug |
| 170 | endif |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 171 | endif |
| 172 | |
Siva Chandra | 27e33a8 | 2015-10-07 22:11:52 +0000 | [diff] [blame] | 173 | LIMIT_DEBUG_INFO_FLAGS = |
| 174 | ifneq (,$(findstring clang,$(CC))) |
| 175 | LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info |
| 176 | endif |
| 177 | |
Ilia K | feda0b7 | 2015-05-12 12:13:12 +0000 | [diff] [blame] | 178 | CFLAGS ?= -g -O0 -fno-builtin |
Greg Clayton | 2c93b80 | 2015-04-16 01:18:05 +0000 | [diff] [blame] | 179 | ifeq "$(OS)" "Darwin" |
| 180 | CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include |
| 181 | else |
| 182 | CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include |
| 183 | endif |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 184 | CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS) |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 185 | |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 186 | # Use this one if you want to build one part of the result without debug information: |
Greg Clayton | 2c93b80 | 2015-04-16 01:18:05 +0000 | [diff] [blame] | 187 | ifeq "$(OS)" "Darwin" |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 188 | CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS) |
Greg Clayton | 2c93b80 | 2015-04-16 01:18:05 +0000 | [diff] [blame] | 189 | else |
Greg Clayton | 315b88d | 2015-06-02 21:38:10 +0000 | [diff] [blame] | 190 | CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS) |
Greg Clayton | 2c93b80 | 2015-04-16 01:18:05 +0000 | [diff] [blame] | 191 | endif |
Jim Ingham | 4b4b247 | 2014-03-13 02:47:14 +0000 | [diff] [blame] | 192 | |
Tamas Berghammer | 4c0c7a7 | 2015-10-07 10:02:17 +0000 | [diff] [blame] | 193 | ifeq "$(MAKE_DWO)" "YES" |
| 194 | CFLAGS += -gsplit-dwarf |
| 195 | endif |
| 196 | |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 197 | CXXFLAGS += -std=c++11 |
| 198 | CXXFLAGS += $(CFLAGS) |
Johnny Chen | 53e2edb | 2011-08-09 20:07:16 +0000 | [diff] [blame] | 199 | LD = $(CC) |
| 200 | LDFLAGS ?= $(CFLAGS) |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 201 | LDFLAGS += $(LD_EXTRAS) |
Tamas Berghammer | 37099e8 | 2015-02-25 13:02:08 +0000 | [diff] [blame] | 202 | ifeq (,$(filter $(OS), Windows_NT Android)) |
Chaoren Lin | f4a92bd | 2015-04-13 18:21:31 +0000 | [diff] [blame] | 203 | ifneq (,$(filter YES,$(ENABLE_THREADS) $(ENABLE_STD_THREADS))) |
Chaoren Lin | 36758cf | 2015-05-21 00:19:15 +0000 | [diff] [blame] | 204 | LDFLAGS += -pthread |
Chaoren Lin | f4a92bd | 2015-04-13 18:21:31 +0000 | [diff] [blame] | 205 | endif |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 206 | endif |
Johnny Chen | 53e2edb | 2011-08-09 20:07:16 +0000 | [diff] [blame] | 207 | OBJECTS = |
| 208 | EXE ?= a.out |
| 209 | |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 210 | ifneq "$(DYLIB_NAME)" "" |
| 211 | ifeq "$(OS)" "Darwin" |
| 212 | DYLIB_FILENAME = lib$(DYLIB_NAME).dylib |
Chaoren Lin | 2944915 | 2015-07-21 17:50:16 +0000 | [diff] [blame] | 213 | DYLIB_EXECUTABLE_PATH ?= @executable_path |
Chaoren Lin | f4a92bd | 2015-04-13 18:21:31 +0000 | [diff] [blame] | 214 | else ifeq "$(OS)" "Windows_NT" |
| 215 | DYLIB_FILENAME = $(DYLIB_NAME).dll |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 216 | else |
| 217 | DYLIB_FILENAME = lib$(DYLIB_NAME).so |
| 218 | endif |
| 219 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 220 | |
Johnny Chen | bdb4efc | 2011-01-14 18:19:53 +0000 | [diff] [blame] | 221 | # Function that returns the counterpart C++ compiler, given $(CC) as arg. |
Shawn Best | 1ecb68d | 2014-11-11 17:34:58 +0000 | [diff] [blame] | 222 | cxx_compiler_notdir = $(if $(findstring clang,$(1)), \ |
| 223 | $(subst clang,clang++,$(1)), \ |
| 224 | $(if $(findstring icc,$(1)), \ |
| 225 | $(subst icc,icpc,$(1)), \ |
| 226 | $(if $(findstring llvm-gcc,$(1)), \ |
| 227 | $(subst llvm-gcc,llvm-g++,$(1)), \ |
| 228 | $(if $(findstring gcc,$(1)), \ |
| 229 | $(subst gcc,g++,$(1)), \ |
| 230 | $(subst cc,c++,$(1)))))) |
Greg Clayton | b39751b | 2013-11-22 21:05:25 +0000 | [diff] [blame] | 231 | cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1))) |
Johnny Chen | bdb4efc | 2011-01-14 18:19:53 +0000 | [diff] [blame] | 232 | |
| 233 | # Function that returns the C++ linker, given $(CC) as arg. |
Shawn Best | 1ecb68d | 2014-11-11 17:34:58 +0000 | [diff] [blame] | 234 | cxx_linker_notdir = $(if $(findstring clang,$(1)), \ |
| 235 | $(subst clang,clang++,$(1)), \ |
| 236 | $(if $(findstring icc,$(1)), \ |
| 237 | $(subst icc,icpc,$(1)), \ |
| 238 | $(if $(findstring llvm-gcc,$(1)), \ |
| 239 | $(subst llvm-gcc,llvm-g++,$(1)), \ |
| 240 | $(if $(findstring gcc,$(1)), \ |
| 241 | $(subst gcc,g++,$(1)), \ |
| 242 | $(subst cc,c++,$(1)))))) |
Greg Clayton | b39751b | 2013-11-22 21:05:25 +0000 | [diff] [blame] | 243 | cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1))) |
Johnny Chen | 832d233 | 2010-09-30 01:22:34 +0000 | [diff] [blame] | 244 | |
Robert Flack | fa8aa17 | 2015-04-20 18:07:55 +0000 | [diff] [blame] | 245 | OBJCOPY := $(CROSS_COMPILE)objcopy |
Tamas Berghammer | dcc8e59 | 2015-04-02 11:09:28 +0000 | [diff] [blame] | 246 | |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 247 | #---------------------------------------------------------------------- |
Zachary Turner | e068d91 | 2014-12-01 23:13:41 +0000 | [diff] [blame] | 248 | # Windows specific options |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 249 | #---------------------------------------------------------------------- |
| 250 | ifeq "$(OS)" "Windows_NT" |
| 251 | ifneq (,$(findstring clang,$(CC))) |
Zachary Turner | e068d91 | 2014-12-01 23:13:41 +0000 | [diff] [blame] | 252 | # Clang for Windows doesn't support C++ Exceptions |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 253 | CXXFLAGS += -fno-exceptions |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 254 | CXXFLAGS += -D_HAS_EXCEPTIONS=0 |
Zachary Turner | e068d91 | 2014-12-01 23:13:41 +0000 | [diff] [blame] | 255 | # The MSVC linker doesn't understand long section names |
| 256 | # generated by the clang compiler. |
| 257 | LDFLAGS += -fuse-ld=lld |
Zachary Turner | c782652 | 2014-08-13 17:44:53 +0000 | [diff] [blame] | 258 | endif |
| 259 | endif |
| 260 | |
| 261 | #---------------------------------------------------------------------- |
Tamas Berghammer | 37099e8 | 2015-02-25 13:02:08 +0000 | [diff] [blame] | 262 | # Android specific options |
| 263 | #---------------------------------------------------------------------- |
| 264 | ifeq "$(OS)" "Android" |
Chaoren Lin | 9070f53 | 2015-07-17 22:13:29 +0000 | [diff] [blame] | 265 | ifdef PIE |
| 266 | LDFLAGS += -pie |
| 267 | endif |
Chaoren Lin | 7d76a13 | 2015-06-02 16:43:19 +0000 | [diff] [blame] | 268 | replace_with = $(if $(findstring clang,$(1)), \ |
| 269 | $(subst clang,$(2),$(1)), \ |
| 270 | $(if $(findstring gcc,$(1)), \ |
| 271 | $(subst gcc,$(2),$(1)), \ |
| 272 | $(subst cc,$(2),$(1)))) |
| 273 | ifeq "$(notdir $(CC))" "$(CC)" |
| 274 | replace_cc_with = $(call replace_with,$(CC),$(1)) |
| 275 | else |
| 276 | replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(notdir $(CC)),$(1))) |
| 277 | endif |
| 278 | OBJCOPY = $(call replace_cc_with,objcopy) |
| 279 | AR = $(call replace_cc_with,ar) |
Tamas Berghammer | 37099e8 | 2015-02-25 13:02:08 +0000 | [diff] [blame] | 280 | endif |
| 281 | |
| 282 | #---------------------------------------------------------------------- |
Daniel Malea | c7ffa7a | 2013-06-05 19:32:34 +0000 | [diff] [blame] | 283 | # C++ standard library options |
| 284 | #---------------------------------------------------------------------- |
| 285 | ifeq (1,$(USE_LIBSTDCPP)) |
| 286 | # Clang requires an extra flag: -stdlib=libstdc++ |
| 287 | ifneq (,$(findstring clang,$(CC))) |
Enrico Granata | a1acb49 | 2013-06-07 01:58:52 +0000 | [diff] [blame] | 288 | CXXFLAGS += -stdlib=libstdc++ |
Daniel Malea | c7ffa7a | 2013-06-05 19:32:34 +0000 | [diff] [blame] | 289 | LDFLAGS += -stdlib=libstdc++ |
| 290 | endif |
| 291 | endif |
| 292 | |
Greg Clayton | 1767a73 | 2013-06-13 21:27:14 +0000 | [diff] [blame] | 293 | ifeq (1,$(USE_LIBCPP)) |
| 294 | # Clang requires an extra flag: -stdlib=libstdc++ |
| 295 | ifneq (,$(findstring clang,$(CC))) |
Vince Harron | f2e3760 | 2015-05-04 02:56:32 +0000 | [diff] [blame] | 296 | ifeq "$(OS)" "Linux" |
| 297 | # This is the default install location on Ubuntu 14.04 |
Enrico Granata | f6fe302 | 2015-09-18 22:26:34 +0000 | [diff] [blame] | 298 | ifneq ($(wildcard /usr/include/c++/v1/.),) |
Todd Fiala | 82ffb8e | 2015-10-22 00:23:38 +0000 | [diff] [blame] | 299 | CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP |
Enrico Granata | f6fe302 | 2015-09-18 22:26:34 +0000 | [diff] [blame] | 300 | LDFLAGS += -stdlib=libc++ |
| 301 | CXXFLAGS += -I/usr/include/c++/v1 |
| 302 | endif |
| 303 | else |
Todd Fiala | 82ffb8e | 2015-10-22 00:23:38 +0000 | [diff] [blame] | 304 | CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP |
Enrico Granata | f6fe302 | 2015-09-18 22:26:34 +0000 | [diff] [blame] | 305 | LDFLAGS += -stdlib=libc++ |
| 306 | endif |
Greg Clayton | 1767a73 | 2013-06-13 21:27:14 +0000 | [diff] [blame] | 307 | endif |
| 308 | endif |
| 309 | |
Daniel Malea | c7ffa7a | 2013-06-05 19:32:34 +0000 | [diff] [blame] | 310 | #---------------------------------------------------------------------- |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 311 | # dylib settings |
| 312 | #---------------------------------------------------------------------- |
| 313 | ifneq "$(strip $(DYLIB_C_SOURCES))" "" |
| 314 | DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o)) |
| 315 | endif |
| 316 | |
Sean Callanan | 7277284 | 2012-02-22 23:57:45 +0000 | [diff] [blame] | 317 | ifneq "$(strip $(DYLIB_OBJC_SOURCES))" "" |
| 318 | DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o)) |
| 319 | endif |
| 320 | |
Greg Clayton | d50d238 | 2012-01-10 00:00:15 +0000 | [diff] [blame] | 321 | ifneq "$(strip $(DYLIB_CXX_SOURCES))" "" |
| 322 | DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o)) |
| 323 | CXX = $(call cxx_compiler,$(CC)) |
| 324 | LD = $(call cxx_linker,$(CC)) |
| 325 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 326 | |
| 327 | #---------------------------------------------------------------------- |
| 328 | # Check if we have any C source files |
| 329 | #---------------------------------------------------------------------- |
| 330 | ifneq "$(strip $(C_SOURCES))" "" |
| 331 | OBJECTS +=$(strip $(C_SOURCES:.c=.o)) |
| 332 | endif |
| 333 | |
| 334 | #---------------------------------------------------------------------- |
| 335 | # Check if we have any C++ source files |
| 336 | #---------------------------------------------------------------------- |
| 337 | ifneq "$(strip $(CXX_SOURCES))" "" |
| 338 | OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) |
Johnny Chen | 832d233 | 2010-09-30 01:22:34 +0000 | [diff] [blame] | 339 | CXX = $(call cxx_compiler,$(CC)) |
Johnny Chen | bdb4efc | 2011-01-14 18:19:53 +0000 | [diff] [blame] | 340 | LD = $(call cxx_linker,$(CC)) |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 341 | endif |
| 342 | |
| 343 | #---------------------------------------------------------------------- |
| 344 | # Check if we have any ObjC source files |
| 345 | #---------------------------------------------------------------------- |
| 346 | ifneq "$(strip $(OBJC_SOURCES))" "" |
| 347 | OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) |
| 348 | LDFLAGS +=-lobjc |
| 349 | endif |
| 350 | |
| 351 | #---------------------------------------------------------------------- |
| 352 | # Check if we have any ObjC++ source files |
| 353 | #---------------------------------------------------------------------- |
| 354 | ifneq "$(strip $(OBJCXX_SOURCES))" "" |
| 355 | OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) |
Johnny Chen | 832d233 | 2010-09-30 01:22:34 +0000 | [diff] [blame] | 356 | CXX = $(call cxx_compiler,$(CC)) |
Johnny Chen | bdb4efc | 2011-01-14 18:19:53 +0000 | [diff] [blame] | 357 | LD = $(call cxx_linker,$(CC)) |
Johnny Chen | 8da4ddf | 2012-04-24 23:05:07 +0000 | [diff] [blame] | 358 | ifeq "$(findstring lobjc,$(LDFLAGS))" "" |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 359 | LDFLAGS +=-lobjc |
| 360 | endif |
| 361 | endif |
| 362 | |
Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 363 | #---------------------------------------------------------------------- |
| 364 | # Check if we have any C source files for archive |
| 365 | #---------------------------------------------------------------------- |
| 366 | ifneq "$(strip $(ARCHIVE_C_SOURCES))" "" |
| 367 | ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o)) |
| 368 | endif |
| 369 | |
| 370 | #---------------------------------------------------------------------- |
| 371 | # Check if we have any C++ source files for archive |
| 372 | #---------------------------------------------------------------------- |
| 373 | ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" "" |
| 374 | ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o)) |
| 375 | CXX = $(call cxx_compiler,$(CC)) |
| 376 | LD = $(call cxx_linker,$(CC)) |
| 377 | endif |
| 378 | |
| 379 | #---------------------------------------------------------------------- |
| 380 | # Check if we have any ObjC source files for archive |
| 381 | #---------------------------------------------------------------------- |
| 382 | ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" "" |
| 383 | ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o)) |
| 384 | LDFLAGS +=-lobjc |
| 385 | endif |
| 386 | |
| 387 | #---------------------------------------------------------------------- |
| 388 | # Check if we have any ObjC++ source files for archive |
| 389 | #---------------------------------------------------------------------- |
| 390 | ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" "" |
| 391 | ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o)) |
| 392 | CXX = $(call cxx_compiler,$(CC)) |
| 393 | LD = $(call cxx_linker,$(CC)) |
Johnny Chen | 8da4ddf | 2012-04-24 23:05:07 +0000 | [diff] [blame] | 394 | ifeq "$(findstring lobjc,$(LDFLAGS))" "" |
Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 395 | LDFLAGS +=-lobjc |
| 396 | endif |
| 397 | endif |
| 398 | |
Matt Kopec | f2430f5 | 2013-07-24 21:39:24 +0000 | [diff] [blame] | 399 | #---------------------------------------------------------------------- |
| 400 | # Check if we are compiling with gcc 4.6 |
| 401 | #---------------------------------------------------------------------- |
Ed Maste | 375432e | 2015-05-29 19:52:02 +0000 | [diff] [blame] | 402 | ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" "" |
| 403 | ifneq "$(filter g++,$(CXX))" "" |
| 404 | CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3) |
Matt Kopec | f2430f5 | 2013-07-24 21:39:24 +0000 | [diff] [blame] | 405 | ifeq "$(CXXVERSION)" "4.6" |
| 406 | # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x |
| 407 | # instead. FIXME: remove once GCC version is upgraded. |
| 408 | override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS)) |
| 409 | endif |
| 410 | endif |
Ed Maste | 375432e | 2015-05-29 19:52:02 +0000 | [diff] [blame] | 411 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 412 | |
| 413 | #---------------------------------------------------------------------- |
Johnny Chen | beac8f9 | 2012-01-10 00:41:11 +0000 | [diff] [blame] | 414 | # DYLIB_ONLY variable can be used to skip the building of a.out. |
| 415 | # See the sections below regarding dSYM file as well as the building of |
| 416 | # EXE from all the objects. |
| 417 | #---------------------------------------------------------------------- |
| 418 | |
| 419 | #---------------------------------------------------------------------- |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 420 | # Make the dSYM file from the executable if $(MAKE_DSYM) != "NO" |
| 421 | #---------------------------------------------------------------------- |
Matt Kopec | 7663b3a | 2013-09-25 17:44:00 +0000 | [diff] [blame] | 422 | ifneq "$(DYLIB_ONLY)" "YES" |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 423 | $(DSYM) : $(EXE) |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 424 | ifeq "$(OS)" "Darwin" |
Johnny Chen | 9101639 | 2011-06-20 20:08:26 +0000 | [diff] [blame] | 425 | ifneq "$(MAKE_DSYM)" "NO" |
Enrico Granata | 489af08 | 2014-11-18 22:47:33 +0000 | [diff] [blame] | 426 | "$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)" |
Johnny Chen | 9101639 | 2011-06-20 20:08:26 +0000 | [diff] [blame] | 427 | endif |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 428 | else |
| 429 | ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" |
Tamas Berghammer | dcc8e59 | 2015-04-02 11:09:28 +0000 | [diff] [blame] | 430 | $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)" |
| 431 | $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)" |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 432 | endif |
| 433 | endif |
Johnny Chen | beac8f9 | 2012-01-10 00:41:11 +0000 | [diff] [blame] | 434 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 435 | |
| 436 | #---------------------------------------------------------------------- |
| 437 | # Compile the executable from all the objects. |
| 438 | #---------------------------------------------------------------------- |
Johnny Chen | beac8f9 | 2012-01-10 00:41:11 +0000 | [diff] [blame] | 439 | ifneq "$(DYLIB_NAME)" "" |
| 440 | ifeq "$(DYLIB_ONLY)" "" |
Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 441 | $(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME) |
Richard Mitton | ec8b282 | 2013-10-17 20:09:33 +0000 | [diff] [blame] | 442 | $(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)" |
Johnny Chen | beac8f9 | 2012-01-10 00:41:11 +0000 | [diff] [blame] | 443 | else |
| 444 | EXE = $(DYLIB_FILENAME) |
| 445 | endif |
| 446 | else |
Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 447 | $(EXE) : $(OBJECTS) $(ARCHIVE_NAME) |
Daniel Malea | 2745d84 | 2013-01-25 00:31:48 +0000 | [diff] [blame] | 448 | $(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)" |
Johnny Chen | fe14162 | 2012-01-12 23:09:42 +0000 | [diff] [blame] | 449 | endif |
| 450 | |
| 451 | #---------------------------------------------------------------------- |
| 452 | # Make the archive |
| 453 | #---------------------------------------------------------------------- |
| 454 | ifneq "$(ARCHIVE_NAME)" "" |
| 455 | ifeq "$(OS)" "Darwin" |
| 456 | $(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS) |
| 457 | $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) |
| 458 | $(RM) $(ARCHIVE_OBJECTS) |
| 459 | else |
| 460 | $(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj))) |
| 461 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 462 | endif |
| 463 | |
| 464 | #---------------------------------------------------------------------- |
| 465 | # Make the dylib |
| 466 | #---------------------------------------------------------------------- |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 467 | $(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL |
| 468 | |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 469 | $(DYLIB_FILENAME) : $(DYLIB_OBJECTS) |
| 470 | ifeq "$(OS)" "Darwin" |
Chaoren Lin | 2944915 | 2015-07-21 17:50:16 +0000 | [diff] [blame] | 471 | $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_EXECUTABLE_PATH)/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)" |
Greg Clayton | 0c9773c | 2012-09-20 21:43:11 +0000 | [diff] [blame] | 472 | ifneq "$(MAKE_DSYM)" "NO" |
| 473 | ifneq "$(DS)" "" |
Kate Stone | 2136ace | 2015-01-21 19:30:00 +0000 | [diff] [blame] | 474 | "$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)" |
Greg Clayton | 0c9773c | 2012-09-20 21:43:11 +0000 | [diff] [blame] | 475 | endif |
| 476 | endif |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 477 | else |
Chaoren Lin | 54fff4c | 2015-04-16 22:03:43 +0000 | [diff] [blame] | 478 | $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)" |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 479 | ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" |
Tamas Berghammer | dcc8e59 | 2015-04-02 11:09:28 +0000 | [diff] [blame] | 480 | $(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug" |
| 481 | $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)" |
Michael Sartain | 802b055 | 2013-07-02 18:13:13 +0000 | [diff] [blame] | 482 | endif |
Peter Collingbourne | 518f03d | 2011-06-20 19:06:04 +0000 | [diff] [blame] | 483 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 484 | |
| 485 | #---------------------------------------------------------------------- |
| 486 | # Automatic variables based on items already entered. Below we create |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 487 | # an object's lists from the list of sources by replacing all entries |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 488 | # that end with .c with .o, and we also create a list of prerequisite |
| 489 | # files by replacing all .c files with .d. |
| 490 | #---------------------------------------------------------------------- |
| 491 | PREREQS := $(OBJECTS:.o=.d) |
Pavel Labath | baf54a8 | 2015-10-21 12:56:37 +0000 | [diff] [blame] | 492 | DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo) |
Johnny Chen | e3dc0f0 | 2010-08-24 16:35:00 +0000 | [diff] [blame] | 493 | ifneq "$(DYLIB_NAME)" "" |
| 494 | DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d) |
Tamas Berghammer | 1535beb | 2015-09-09 10:20:30 +0000 | [diff] [blame] | 495 | DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo) |
Johnny Chen | e3dc0f0 | 2010-08-24 16:35:00 +0000 | [diff] [blame] | 496 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 497 | |
| 498 | #---------------------------------------------------------------------- |
| 499 | # Rule for Generating Prerequisites Automatically using .d files and |
| 500 | # the compiler -MM option. The -M option will list all system headers, |
| 501 | # and the -MM option will list all non-system dependencies. |
| 502 | #---------------------------------------------------------------------- |
Chaoren Lin | d761a95 | 2015-09-16 21:51:51 +0000 | [diff] [blame] | 503 | ifeq "$(HOST_OS)" "Windows_NT" |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 504 | JOIN_CMD = & |
| 505 | QUOTE = " |
| 506 | else |
| 507 | JOIN_CMD = ; |
| 508 | QUOTE = ' |
| 509 | endif |
| 510 | |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 511 | %.d: %.c |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 512 | @rm -f $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 513 | $(CC) -M $(CFLAGS) $< > $@.tmp && \ |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 514 | sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 515 | rm -f $@.tmp |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 516 | |
| 517 | %.d: %.cpp |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 518 | @rm -f $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 519 | $(CXX) -M $(CXXFLAGS) $< > $@.tmp && \ |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 520 | sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 521 | rm -f $@.tmp |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 522 | |
| 523 | %.d: %.m |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 524 | @rm -f $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 525 | $(CC) -M $(CFLAGS) $< > $@.tmp && \ |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 526 | sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 527 | rm -f $@.tmp |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 528 | |
| 529 | %.d: %.mm |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 530 | @rm -f $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 531 | $(CXX) -M $(CXXFLAGS) $< > $@.tmp && \ |
Zachary Turner | 794e6a6 | 2015-03-13 21:51:11 +0000 | [diff] [blame] | 532 | sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \ |
Pavel Labath | f81ed47 | 2015-02-05 09:52:42 +0000 | [diff] [blame] | 533 | rm -f $@.tmp |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 534 | |
| 535 | #---------------------------------------------------------------------- |
| 536 | # Include all of the makefiles for each source file so we don't have |
| 537 | # to manually track all of the prerequisites for each source file. |
| 538 | #---------------------------------------------------------------------- |
| 539 | sinclude $(PREREQS) |
Johnny Chen | e3dc0f0 | 2010-08-24 16:35:00 +0000 | [diff] [blame] | 540 | ifneq "$(DYLIB_NAME)" "" |
| 541 | sinclude $(DYLIB_PREREQS) |
| 542 | endif |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 543 | |
Johnny Chen | 8da4ddf | 2012-04-24 23:05:07 +0000 | [diff] [blame] | 544 | # Define a suffix rule for .mm -> .o |
| 545 | .SUFFIXES: .mm .o |
| 546 | .mm.o: |
| 547 | $(CXX) $(CXXFLAGS) -c $< |
| 548 | |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 549 | .PHONY: clean |
| 550 | dsym: $(DSYM) |
| 551 | all: $(EXE) $(DSYM) |
Johnny Chen | e1030cd | 2010-09-27 20:44:46 +0000 | [diff] [blame] | 552 | clean:: |
Tamas Berghammer | 1535beb | 2015-09-09 10:20:30 +0000 | [diff] [blame] | 553 | $(RM) $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) |
Ed Maste | 0990e05 | 2014-03-07 17:20:50 +0000 | [diff] [blame] | 554 | ifneq "$(DYLIB_NAME)" "" |
Jason Molenda | 53b8ea1 | 2014-03-08 01:53:27 +0000 | [diff] [blame] | 555 | $(RM) -r $(DYLIB_FILENAME).dSYM |
Tamas Berghammer | 1535beb | 2015-09-09 10:20:30 +0000 | [diff] [blame] | 556 | $(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug |
Johnny Chen | 9bc867a | 2010-08-23 23:56:08 +0000 | [diff] [blame] | 557 | endif |
Ed Maste | 0990e05 | 2014-03-07 17:20:50 +0000 | [diff] [blame] | 558 | ifneq "$(DSYM)" "" |
Jason Molenda | 53b8ea1 | 2014-03-08 01:53:27 +0000 | [diff] [blame] | 559 | $(RM) -r "$(DSYM)" |
Ed Maste | 0990e05 | 2014-03-07 17:20:50 +0000 | [diff] [blame] | 560 | endif |
Zachary Turner | 3e9ca3a | 2014-12-16 16:48:19 +0000 | [diff] [blame] | 561 | ifeq "$(OS)" "Windows_NT" |
Zachary Turner | 0844d8d | 2015-08-26 19:44:45 +0000 | [diff] [blame] | 562 | # http://llvm.org/pr24589 |
| 563 | IF EXIST "$(EXE)" del "$(EXE)" |
Zachary Turner | 65fe1eb | 2015-03-26 16:43:25 +0000 | [diff] [blame] | 564 | $(RM) $(wildcard *.manifest *.pdb *.ilk) |
Zachary Turner | 0844d8d | 2015-08-26 19:44:45 +0000 | [diff] [blame] | 565 | ifneq "$(DYLIB_NAME)" "" |
Zachary Turner | 65fe1eb | 2015-03-26 16:43:25 +0000 | [diff] [blame] | 566 | $(RM) $(DYLIB_NAME).lib $(DYLIB_NAME).exp |
Zachary Turner | 0844d8d | 2015-08-26 19:44:45 +0000 | [diff] [blame] | 567 | endif |
| 568 | else |
| 569 | $(RM) "$(EXE)" |
Zachary Turner | 3e9ca3a | 2014-12-16 16:48:19 +0000 | [diff] [blame] | 570 | endif |
Johnny Chen | fa38041 | 2011-01-14 21:18:12 +0000 | [diff] [blame] | 571 | |
| 572 | #---------------------------------------------------------------------- |
| 573 | # From http://blog.melski.net/tag/debugging-makefiles/ |
| 574 | # |
| 575 | # Usage: make print-CC print-CXX print-LD |
| 576 | #---------------------------------------------------------------------- |
| 577 | print-%: |
| 578 | @echo '$*=$($*)' |
| 579 | @echo ' origin = $(origin $*)' |
| 580 | @echo ' flavor = $(flavor $*)' |
| 581 | @echo ' value = $(value $*)' |
Johnny Chen | 8b2c321 | 2011-01-28 17:22:29 +0000 | [diff] [blame] | 582 | |
Johnny Chen | 8b2c321 | 2011-01-28 17:22:29 +0000 | [diff] [blame] | 583 | ### Local Variables: ### |
| 584 | ### mode:makefile ### |
| 585 | ### End: ### |