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 := 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# 15# Also might be of interest: 16# FRAMEWORK_INCLUDES (Darwin only) := 17# CFLAGS_EXTRAS := 18# LD_EXTRAS := 19# SPLIT_DEBUG_SYMBOLS := YES 20# CROSS_COMPILE := 21# 22# And test/functionalities/archives/Makefile: 23# MAKE_DSYM := NO 24# ARCHIVE_NAME := libfoo.a 25# ARCHIVE_C_SOURCES := a.c b.c 26 27# Uncomment line below for debugging shell commands 28# SHELL = /bin/sh -x 29 30THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ 31LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../ 32 33 34#---------------------------------------------------------------------- 35# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more 36# from the triple alone 37#---------------------------------------------------------------------- 38TRIPLE_CFLAGS := 39ifneq "$(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 's/\([a-z]*\)\(.*\)/\1 \2/') 44 TRIPLE_OS =$(word 1, $(triple_os_and_version)) 45 TRIPLE_VERSION =$(word 2, $(triple_os_and_version)) 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) 52 ifeq "$(TRIPLE_VERSION)" "" 53 TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/') 54 endif 55 TRIPLE_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" 56 else 57 SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path) 58 ifeq "$(TRIPLE_VERSION)" "" 59 TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/') 60 endif 61 TRIPLE_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" 62 endif 63 endif 64 endif 65 endif 66endif 67 68#---------------------------------------------------------------------- 69# If OS is not defined, use 'uname -s' to determine the OS name. 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#---------------------------------------------------------------------- 76HOST_OS = $(shell uname -s) 77ifeq "$(HOST_OS)" "windows32" 78 HOST_OS = Windows_NT 79endif 80ifeq "$(OS)" "" 81 OS = $(HOST_OS) 82endif 83 84#---------------------------------------------------------------------- 85# If ARCH is not defined, default to x86_64. 86#---------------------------------------------------------------------- 87ifeq "$(ARCH)" "" 88ifeq "$(OS)" "Windows_NT" 89 ARCH = x86 90else 91 ARCH = x86_64 92endif 93endif 94 95#---------------------------------------------------------------------- 96# CC defaults to clang. 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# 102# See also these functions: 103# o cxx_compiler 104# o cxx_linker 105#---------------------------------------------------------------------- 106CC ?= clang 107ifeq "$(CC)" "cc" 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 115endif 116 117#---------------------------------------------------------------------- 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#---------------------------------------------------------------------- 121ARCHFLAG ?= -arch 122 123#---------------------------------------------------------------------- 124# Change any build/tool options needed 125#---------------------------------------------------------------------- 126ifeq "$(OS)" "Darwin" 127 DS := $(shell xcrun -find -toolchain default dsymutil) 128 DSFLAGS = 129 DSYM = $(EXE).dSYM 130 AR := $(CROSS_COMPILE)libtool 131 ARFLAGS := -static -o 132else 133 AR := $(CROSS_COMPILE)ar 134 # On non-Apple platforms, -arch becomes -m 135 ARCHFLAG := -m 136 137 # i386, i686, x86 -> 32 138 # amd64, x86_64, x64 -> 64 139 ifeq "$(ARCH)" "amd64" 140 override ARCH := $(subst amd64,64,$(ARCH)) 141 endif 142 ifeq "$(ARCH)" "x86_64" 143 override ARCH := $(subst x86_64,64,$(ARCH)) 144 endif 145 ifeq "$(ARCH)" "x64" 146 override ARCH := $(subst x64,64,$(ARCH)) 147 endif 148 ifeq "$(ARCH)" "x86" 149 override ARCH := $(subst x86,32,$(ARCH)) 150 endif 151 ifeq "$(ARCH)" "i386" 152 override ARCH := $(subst i386,32,$(ARCH)) 153 endif 154 ifeq "$(ARCH)" "i686" 155 override ARCH := $(subst i686,32,$(ARCH)) 156 endif 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 163 ifeq "$(ARCH)" "aarch64" 164 override ARCH := 165 override ARCHFLAG := 166 endif 167 ifeq "$(ARCH)" "arm" 168 override ARCH := 169 override ARCHFLAG := 170 endif 171 ifeq "$(findstring mips,$(ARCH))" "mips" 172 override ARCHFLAG := - 173 endif 174 175 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" 176 DSYM = $(EXE).debug 177 endif 178endif 179 180LIMIT_DEBUG_INFO_FLAGS = 181NO_LIMIT_DEBUG_INFO_FLAGS = 182ifneq (,$(findstring clang,$(CC))) 183 LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info 184 NO_LIMIT_DEBUG_INFO_FLAGS += -fno-limit-debug-info 185endif 186 187DEBUG_INFO_FLAG ?= -g 188 189CFLAGS ?= $(DEBUG_INFO_FLAG) -O0 -fno-builtin 190ifeq "$(OS)" "Darwin" 191 CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include 192else 193 CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include 194endif 195 196CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS) 197 198# Use this one if you want to build one part of the result without debug information: 199ifeq "$(OS)" "Darwin" 200 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS) 201else 202 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS) 203endif 204 205ifeq "$(MAKE_DWO)" "YES" 206 CFLAGS += -gsplit-dwarf 207endif 208 209CXXFLAGS += -std=c++11 210CXXFLAGS += $(CFLAGS) 211LD = $(CC) 212LDFLAGS ?= $(CFLAGS) 213LDFLAGS += $(LD_EXTRAS) 214ifeq (,$(filter $(OS), Windows_NT Android)) 215 ifneq (,$(filter YES,$(ENABLE_THREADS))) 216 LDFLAGS += -pthread 217 endif 218endif 219OBJECTS = 220EXE ?= a.out 221 222ifneq "$(DYLIB_NAME)" "" 223 ifeq "$(OS)" "Darwin" 224 DYLIB_FILENAME = lib$(DYLIB_NAME).dylib 225 DYLIB_EXECUTABLE_PATH ?= @executable_path 226 else ifeq "$(OS)" "Windows_NT" 227 DYLIB_FILENAME = $(DYLIB_NAME).dll 228 else 229 DYLIB_FILENAME = lib$(DYLIB_NAME).so 230 endif 231endif 232 233# Function that returns the counterpart C++ compiler, given $(CC) as arg. 234cxx_compiler_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)))))) 243cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1))) 244 245# Function that returns the C++ linker, given $(CC) as arg. 246cxx_linker_notdir = $(if $(findstring clang,$(1)), \ 247 $(subst clang,clang++,$(1)), \ 248 $(if $(findstring icc,$(1)), \ 249 $(subst icc,icpc,$(1)), \ 250 $(if $(findstring llvm-gcc,$(1)), \ 251 $(subst llvm-gcc,llvm-g++,$(1)), \ 252 $(if $(findstring gcc,$(1)), \ 253 $(subst gcc,g++,$(1)), \ 254 $(subst cc,c++,$(1)))))) 255cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1))) 256 257OBJCOPY := $(CROSS_COMPILE)objcopy 258 259#---------------------------------------------------------------------- 260# Windows specific options 261#---------------------------------------------------------------------- 262ifeq "$(OS)" "Windows_NT" 263 ifneq (,$(findstring clang,$(CC))) 264 # Clang for Windows doesn't support C++ Exceptions 265 CXXFLAGS += -fno-exceptions 266 CXXFLAGS += -D_HAS_EXCEPTIONS=0 267 ifeq "$(VisualStudioVersion)" "14.0" 268 CXXFLAGS += -fms-compatibility-version=19.0 269 endif 270 # The MSVC linker doesn't understand long section names 271 # generated by the clang compiler. 272 LDFLAGS += -fuse-ld=lld 273 endif 274endif 275 276#---------------------------------------------------------------------- 277# Android specific options 278#---------------------------------------------------------------------- 279ifeq "$(OS)" "Android" 280 ifdef PIE 281 LDFLAGS += -pie 282 endif 283 replace_with = $(if $(findstring clang,$(1)), \ 284 $(subst clang,$(2),$(1)), \ 285 $(if $(findstring gcc,$(1)), \ 286 $(subst gcc,$(2),$(1)), \ 287 $(subst cc,$(2),$(1)))) 288 ifeq "$(notdir $(CC))" "$(CC)" 289 replace_cc_with = $(call replace_with,$(CC),$(1)) 290 else 291 replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(notdir $(CC)),$(1))) 292 endif 293 OBJCOPY = $(call replace_cc_with,objcopy) 294 AR = $(call replace_cc_with,ar) 295endif 296 297#---------------------------------------------------------------------- 298# C++ standard library options 299#---------------------------------------------------------------------- 300ifeq (1,$(USE_LIBSTDCPP)) 301 # Clang requires an extra flag: -stdlib=libstdc++ 302 ifneq (,$(findstring clang,$(CC))) 303 CXXFLAGS += -stdlib=libstdc++ 304 LDFLAGS += -stdlib=libstdc++ 305 endif 306endif 307 308ifeq (1,$(USE_LIBCPP)) 309 # Clang requires an extra flag: -stdlib=libstdc++ 310 ifneq (,$(findstring clang,$(CC))) 311 ifeq "$(OS)" "Linux" 312 # This is the default install location on Ubuntu 14.04 313 ifneq ($(wildcard /usr/include/c++/v1/.),) 314 CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP 315 LDFLAGS += -stdlib=libc++ 316 CXXFLAGS += -I/usr/include/c++/v1 317 endif 318 else 319 CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP 320 LDFLAGS += -stdlib=libc++ 321 endif 322 endif 323endif 324 325#---------------------------------------------------------------------- 326# dylib settings 327#---------------------------------------------------------------------- 328ifneq "$(strip $(DYLIB_C_SOURCES))" "" 329 DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o)) 330endif 331 332ifneq "$(strip $(DYLIB_OBJC_SOURCES))" "" 333 DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o)) 334endif 335 336ifneq "$(strip $(DYLIB_CXX_SOURCES))" "" 337 DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o)) 338 CXX = $(call cxx_compiler,$(CC)) 339 LD = $(call cxx_linker,$(CC)) 340endif 341 342#---------------------------------------------------------------------- 343# Check if we have any C source files 344#---------------------------------------------------------------------- 345ifneq "$(strip $(C_SOURCES))" "" 346 OBJECTS +=$(strip $(C_SOURCES:.c=.o)) 347endif 348 349#---------------------------------------------------------------------- 350# Check if we have any C++ source files 351#---------------------------------------------------------------------- 352ifneq "$(strip $(CXX_SOURCES))" "" 353 OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) 354 CXX = $(call cxx_compiler,$(CC)) 355 LD = $(call cxx_linker,$(CC)) 356endif 357 358#---------------------------------------------------------------------- 359# Check if we have any ObjC source files 360#---------------------------------------------------------------------- 361ifneq "$(strip $(OBJC_SOURCES))" "" 362 OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) 363 LDFLAGS +=-lobjc 364endif 365 366#---------------------------------------------------------------------- 367# Check if we have any ObjC++ source files 368#---------------------------------------------------------------------- 369ifneq "$(strip $(OBJCXX_SOURCES))" "" 370 OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) 371 CXX = $(call cxx_compiler,$(CC)) 372 LD = $(call cxx_linker,$(CC)) 373 ifeq "$(findstring lobjc,$(LDFLAGS))" "" 374 LDFLAGS +=-lobjc 375 endif 376endif 377 378#---------------------------------------------------------------------- 379# Check if we have any C source files for archive 380#---------------------------------------------------------------------- 381ifneq "$(strip $(ARCHIVE_C_SOURCES))" "" 382 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o)) 383endif 384 385#---------------------------------------------------------------------- 386# Check if we have any C++ source files for archive 387#---------------------------------------------------------------------- 388ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" "" 389 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o)) 390 CXX = $(call cxx_compiler,$(CC)) 391 LD = $(call cxx_linker,$(CC)) 392endif 393 394#---------------------------------------------------------------------- 395# Check if we have any ObjC source files for archive 396#---------------------------------------------------------------------- 397ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" "" 398 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o)) 399 LDFLAGS +=-lobjc 400endif 401 402#---------------------------------------------------------------------- 403# Check if we have any ObjC++ source files for archive 404#---------------------------------------------------------------------- 405ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" "" 406 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o)) 407 CXX = $(call cxx_compiler,$(CC)) 408 LD = $(call cxx_linker,$(CC)) 409 ifeq "$(findstring lobjc,$(LDFLAGS))" "" 410 LDFLAGS +=-lobjc 411 endif 412endif 413 414#---------------------------------------------------------------------- 415# Check if we are compiling with gcc 4.6 416#---------------------------------------------------------------------- 417ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" "" 418ifneq "$(filter g++,$(CXX))" "" 419 CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3) 420 ifeq "$(CXXVERSION)" "4.6" 421 # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x 422 # instead. FIXME: remove once GCC version is upgraded. 423 override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS)) 424 endif 425endif 426endif 427 428#---------------------------------------------------------------------- 429# DYLIB_ONLY variable can be used to skip the building of a.out. 430# See the sections below regarding dSYM file as well as the building of 431# EXE from all the objects. 432#---------------------------------------------------------------------- 433 434#---------------------------------------------------------------------- 435# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO" 436#---------------------------------------------------------------------- 437ifneq "$(DYLIB_ONLY)" "YES" 438$(DSYM) : $(EXE) 439ifeq "$(OS)" "Darwin" 440ifneq "$(MAKE_DSYM)" "NO" 441 "$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)" 442endif 443else 444ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" 445 $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)" 446 $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)" 447endif 448endif 449endif 450 451#---------------------------------------------------------------------- 452# Compile the executable from all the objects. 453#---------------------------------------------------------------------- 454ifneq "$(DYLIB_NAME)" "" 455ifeq "$(DYLIB_ONLY)" "" 456$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME) 457 $(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)" 458else 459EXE = $(DYLIB_FILENAME) 460endif 461else 462$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) 463 $(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)" 464endif 465 466#---------------------------------------------------------------------- 467# Make the archive 468#---------------------------------------------------------------------- 469ifneq "$(ARCHIVE_NAME)" "" 470ifeq "$(OS)" "Darwin" 471$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS) 472 $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) 473 $(RM) $(ARCHIVE_OBJECTS) 474else 475$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj))) 476endif 477endif 478 479#---------------------------------------------------------------------- 480# Make the dylib 481#---------------------------------------------------------------------- 482$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL 483 484$(DYLIB_FILENAME) : $(DYLIB_OBJECTS) 485ifeq "$(OS)" "Darwin" 486 $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_EXECUTABLE_PATH)/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)" 487ifneq "$(MAKE_DSYM)" "NO" 488ifneq "$(DS)" "" 489 "$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)" 490endif 491endif 492else 493 $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)" 494ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" 495 $(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug" 496 $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)" 497endif 498endif 499 500#---------------------------------------------------------------------- 501# Automatic variables based on items already entered. Below we create 502# an object's lists from the list of sources by replacing all entries 503# that end with .c with .o, and we also create a list of prerequisite 504# files by replacing all .c files with .d. 505#---------------------------------------------------------------------- 506PREREQS := $(OBJECTS:.o=.d) 507DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo) 508ifneq "$(DYLIB_NAME)" "" 509 DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d) 510 DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo) 511endif 512 513#---------------------------------------------------------------------- 514# Rule for Generating Prerequisites Automatically using .d files and 515# the compiler -MM option. The -M option will list all system headers, 516# and the -MM option will list all non-system dependencies. 517#---------------------------------------------------------------------- 518ifeq "$(HOST_OS)" "Windows_NT" 519 JOIN_CMD = & 520 QUOTE = " 521else 522 JOIN_CMD = ; 523 QUOTE = ' 524endif 525 526%.d: %.c 527 @rm -f $@ $(JOIN_CMD) \ 528 $(CC) -M $(CFLAGS) $< > [email protected] && \ 529 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \ 530 rm -f [email protected] 531 532%.d: %.cpp 533 @rm -f $@ $(JOIN_CMD) \ 534 $(CXX) -M $(CXXFLAGS) $< > [email protected] && \ 535 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \ 536 rm -f [email protected] 537 538%.d: %.m 539 @rm -f $@ $(JOIN_CMD) \ 540 $(CC) -M $(CFLAGS) $< > [email protected] && \ 541 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \ 542 rm -f [email protected] 543 544%.d: %.mm 545 @rm -f $@ $(JOIN_CMD) \ 546 $(CXX) -M $(CXXFLAGS) $< > [email protected] && \ 547 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \ 548 rm -f [email protected] 549 550#---------------------------------------------------------------------- 551# Include all of the makefiles for each source file so we don't have 552# to manually track all of the prerequisites for each source file. 553#---------------------------------------------------------------------- 554sinclude $(PREREQS) 555ifneq "$(DYLIB_NAME)" "" 556 sinclude $(DYLIB_PREREQS) 557endif 558 559# Define a suffix rule for .mm -> .o 560.SUFFIXES: .mm .o 561.mm.o: 562 $(CXX) $(CXXFLAGS) -c $< 563 564.PHONY: clean 565dsym: $(DSYM) 566all: $(EXE) $(DSYM) 567clean:: 568 $(RM) $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) 569ifneq "$(DYLIB_NAME)" "" 570 $(RM) -r $(DYLIB_FILENAME).dSYM 571 $(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug 572endif 573ifneq "$(DSYM)" "" 574 $(RM) -r "$(DSYM)" 575endif 576ifeq "$(OS)" "Windows_NT" 577# http://llvm.org/pr24589 578 IF EXIST "$(EXE)" del "$(EXE)" 579 $(RM) $(wildcard *.manifest *.pdb *.ilk) 580ifneq "$(DYLIB_NAME)" "" 581 $(RM) $(DYLIB_NAME).lib $(DYLIB_NAME).exp 582endif 583else 584 $(RM) "$(EXE)" 585endif 586 587#---------------------------------------------------------------------- 588# From http://blog.melski.net/tag/debugging-makefiles/ 589# 590# Usage: make print-CC print-CXX print-LD 591#---------------------------------------------------------------------- 592print-%: 593 @echo '$*=$($*)' 594 @echo ' origin = $(origin $*)' 595 @echo ' flavor = $(flavor $*)' 596 @echo ' value = $(value $*)' 597 598### Local Variables: ### 599### mode:makefile ### 600### End: ### 601