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