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_OBJC_SOURCES := 10# DYLIB_CXX_SOURCES := 11# 12# Specifying DYLIB_ONLY has the effect of building dylib only, skipping 13# the building of the a.out executable program. For example, 14# DYLIB_ONLY := YES 15# 16# Specifying FRAMEWORK and its variants has the effect of building a NeXT-style 17# framework. 18# FRAMEWORK := "Foo" 19# FRAMEWORK_HEADERS := "Foo.h" 20# FRAMEWORK_MODULES := "module.modulemap" 21# 22# Also might be of interest: 23# FRAMEWORK_INCLUDES (Darwin only) := 24# CFLAGS_EXTRAS := 25# LD_EXTRAS := 26# SPLIT_DEBUG_SYMBOLS := YES 27# CROSS_COMPILE := 28# USE_PRIVATE_MODULE_CACHE := YES 29 30# Uncomment line below for debugging shell commands 31# SHELL = /bin/sh -x 32 33# Suppress built-in suffix rules. We explicitly define rules for %.o. 34.SUFFIXES: 35 36SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST))) 37BUILDDIR := $(shell pwd) 38MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST)) 39THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES)) 40LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ 41 42# The test harness invokes the test Makefiles with an explicit 'all' 43# target, but its handy to be able to recursively call this Makefile 44# without specifying a goal. You almost certainly want to build 'all', 45# and not only the first target defined in this file (which might vary 46# according to variable values). 47.DEFAULT_GOAL := all 48 49#---------------------------------------------------------------------- 50# If OS is not defined, use 'uname -s' to determine the OS name. 51# 52# uname on Windows gives "windows32" or "server version windows32", but most 53# environments standardize on "Windows_NT", so we'll make it consistent here. 54# When running tests from Visual Studio, the environment variable isn't 55# inherited all the way down to the process spawned for make. 56#---------------------------------------------------------------------- 57HOST_OS := $(shell uname -s) 58ifneq (,$(findstring windows32,$(HOST_OS))) 59 HOST_OS := Windows_NT 60endif 61ifeq "$(OS)" "" 62 OS := $(HOST_OS) 63endif 64 65#---------------------------------------------------------------------- 66# If OS is Windows, force SHELL to be cmd 67# 68# Some versions of make on Windows will search for other shells such as 69# C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons 70# so default to using cmd.exe. 71#---------------------------------------------------------------------- 72ifeq "$(OS)" "Windows_NT" 73 SHELL = $(WINDIR)\system32\cmd.exe 74endif 75 76#---------------------------------------------------------------------- 77# If the OS is Windows use double-quotes in commands 78# 79# For other operating systems, single-quotes work fine, but on Windows 80# we strictly required double-quotes 81#---------------------------------------------------------------------- 82ifeq "$(HOST_OS)" "Windows_NT" 83 QUOTE = " 84 FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = " 85else 86 QUOTE = ' 87 FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = ' 88endif 89 90#---------------------------------------------------------------------- 91# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more 92# from the triple alone 93#---------------------------------------------------------------------- 94ARCH_CFLAGS := 95ifeq "$(OS)" "Android" 96 include $(THIS_FILE_DIR)/Android.rules 97endif 98 99#---------------------------------------------------------------------- 100# If ARCH is not defined, default to x86_64. 101#---------------------------------------------------------------------- 102ifeq "$(ARCH)" "" 103ifeq "$(OS)" "Windows_NT" 104 ARCH = x86 105else 106 ARCH = x86_64 107endif 108endif 109 110#---------------------------------------------------------------------- 111# CC defaults to clang. 112# 113# If you change the defaults of CC, be sure to also change it in the file 114# test/builders/builder_base.py, which provides a Python way to return the 115# value of the make variable CC -- getCompiler(). 116# 117# See also these functions: 118# o cxx_compiler 119# o cxx_linker 120#---------------------------------------------------------------------- 121ifeq "$(CC)" "" 122$(error "C compiler is not specified. Please run tests through lldb-dotest or lit") 123endif 124 125#---------------------------------------------------------------------- 126# Handle SDKROOT on Darwin 127#---------------------------------------------------------------------- 128 129ifeq "$(OS)" "Darwin" 130 ifeq "$(SDKROOT)" "" 131 # We haven't otherwise set the SDKROOT, so set it now to macosx 132 SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path) 133 endif 134endif 135 136#---------------------------------------------------------------------- 137# ARCHFLAG is the flag used to tell the compiler which architecture 138# to compile for. The default is the flag that clang accepts. 139#---------------------------------------------------------------------- 140ARCHFLAG ?= -arch 141 142#---------------------------------------------------------------------- 143# Change any build/tool options needed 144#---------------------------------------------------------------------- 145ifeq "$(OS)" "Darwin" 146 DS := $(DSYMUTIL) 147 DSFLAGS = 148 DSYM = $(EXE).dSYM 149 AR := $(CROSS_COMPILE)libtool 150 ARFLAGS := -static -o 151else 152 AR := $(CROSS_COMPILE)ar 153 # On non-Apple platforms, -arch becomes -m 154 ARCHFLAG := -m 155 156 # i386, i686, x86 -> 32 157 # amd64, x86_64, x64 -> 64 158 ifeq "$(ARCH)" "amd64" 159 override ARCH := $(subst amd64,64,$(ARCH)) 160 endif 161 ifeq "$(ARCH)" "x86_64" 162 override ARCH := $(subst x86_64,64,$(ARCH)) 163 endif 164 ifeq "$(ARCH)" "x64" 165 override ARCH := $(subst x64,64,$(ARCH)) 166 endif 167 ifeq "$(ARCH)" "x86" 168 override ARCH := $(subst x86,32,$(ARCH)) 169 endif 170 ifeq "$(ARCH)" "i386" 171 override ARCH := $(subst i386,32,$(ARCH)) 172 endif 173 ifeq "$(ARCH)" "i686" 174 override ARCH := $(subst i686,32,$(ARCH)) 175 endif 176 ifeq "$(ARCH)" "powerpc" 177 override ARCH := $(subst powerpc,32,$(ARCH)) 178 endif 179 ifeq "$(ARCH)" "powerpc64" 180 override ARCH := $(subst powerpc64,64,$(ARCH)) 181 endif 182 ifeq "$(ARCH)" "powerpc64le" 183 override ARCH := $(subst powerpc64le,64,$(ARCH)) 184 endif 185 ifeq "$(ARCH)" "aarch64" 186 override ARCH := 187 override ARCHFLAG := 188 endif 189 ifeq "$(findstring arm,$(ARCH))" "arm" 190 override ARCH := 191 override ARCHFLAG := 192 endif 193 ifeq "$(ARCH)" "s390x" 194 override ARCH := 195 override ARCHFLAG := 196 endif 197 ifeq "$(findstring mips,$(ARCH))" "mips" 198 override ARCHFLAG := - 199 endif 200 201 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" 202 DSYM = $(EXE).debug 203 endif 204endif 205 206LIMIT_DEBUG_INFO_FLAGS = 207NO_LIMIT_DEBUG_INFO_FLAGS = 208MODULE_DEBUG_INFO_FLAGS = 209ifneq (,$(findstring clang,$(CC))) 210 LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info 211 NO_LIMIT_DEBUG_INFO_FLAGS += -fno-limit-debug-info 212 MODULE_DEBUG_INFO_FLAGS += -gmodules 213endif 214 215DEBUG_INFO_FLAG ?= -g 216 217CFLAGS ?= $(DEBUG_INFO_FLAG) -O0 -fno-builtin 218 219ifeq "$(OS)" "Darwin" 220 ifneq "$(SDKROOT)" "" 221 CFLAGS += -isysroot "$(SDKROOT)" 222 endif 223endif 224 225ifeq "$(OS)" "Darwin" 226 CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include 227else 228 CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include 229endif 230 231CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR) 232 233ifndef NO_TEST_COMMON_H 234 CFLAGS += -include $(THIS_FILE_DIR)/test_common.h 235endif 236 237CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) 238 239# If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will build 240# with codeview by default but all the tests rely on dwarf. 241ifeq "$(OS)" "Windows_NT" 242 CFLAGS += -gdwarf 243endif 244 245# Use this one if you want to build one part of the result without debug information: 246ifeq "$(OS)" "Darwin" 247 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) -isysroot "$(SDKROOT)" 248else 249 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) 250endif 251 252ifeq "$(MAKE_DWO)" "YES" 253 CFLAGS += -gsplit-dwarf 254endif 255 256ifeq "$(USE_PRIVATE_MODULE_CACHE)" "YES" 257THE_CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/private-module-cache 258else 259THE_CLANG_MODULE_CACHE_DIR := $(CLANG_MODULE_CACHE_DIR) 260endif 261 262MODULE_BASE_FLAGS := -fmodules -gmodules -fmodules-cache-path=$(THE_CLANG_MODULE_CACHE_DIR) 263MANDATORY_MODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -gmodules 264# Build flags for building with C++ modules. 265# -glldb is necessary for emitting information about what modules were imported. 266MANDATORY_CXXMODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -fcxx-modules -glldb 267 268ifeq "$(OS)" "Darwin" 269 MANDATORY_MODULE_BUILD_CFLAGS += -fcxx-modules 270endif 271 272ifeq "$(MAKE_GMODULES)" "YES" 273 CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) 274 CXXFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) 275endif 276 277CFLAGS += $(CFLAGS_EXTRAS) 278CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_EXTRAS) 279LD = $(CC) 280LDFLAGS ?= $(CFLAGS) 281LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS) 282ifneq (,$(LLVM_LIBS_DIR)) 283 ifeq ($(OS),NetBSD) 284 LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LLVM_LIBS_DIR) 285 endif 286endif 287ifeq (,$(filter $(OS), Windows_NT Android Darwin)) 288 ifneq (,$(filter YES,$(ENABLE_THREADS))) 289 LDFLAGS += -pthread 290 endif 291endif 292OBJECTS = 293EXE ?= a.out 294 295ifneq "$(FRAMEWORK)" "" 296 DYLIB_NAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK) 297 DYLIB_FILENAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK) 298endif 299 300ifneq "$(DYLIB_NAME)" "" 301 ifeq "$(OS)" "Darwin" 302 ifneq "$(FRAMEWORK)" "" 303 DYLIB_INSTALL_NAME ?= @executable_path/$(FRAMEWORK).framework/Versions/A/$(FRAMEWORK) 304 else 305 DYLIB_FILENAME = lib$(DYLIB_NAME).dylib 306 DYLIB_INSTALL_NAME ?= @executable_path/$(DYLIB_FILENAME) 307 endif 308 else ifeq "$(OS)" "Windows_NT" 309 DYLIB_FILENAME = $(DYLIB_NAME).dll 310 else 311 DYLIB_FILENAME = lib$(DYLIB_NAME).so 312 endif 313endif 314 315# Function that returns the counterpart C++ compiler, given $(CC) as arg. 316cxx_compiler_notdir = $(if $(findstring icc,$(1)), \ 317 $(subst icc,icpc,$(1)), \ 318 $(if $(findstring llvm-gcc,$(1)), \ 319 $(subst llvm-gcc,llvm-g++,$(1)), \ 320 $(if $(findstring gcc,$(1)), \ 321 $(subst gcc,g++,$(1)), \ 322 $(subst cc,c++,$(1))))) 323cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1))) 324 325# Function that returns the C++ linker, given $(CC) as arg. 326cxx_linker_notdir = $(if $(findstring icc,$(1)), \ 327 $(subst icc,icpc,$(1)), \ 328 $(if $(findstring llvm-gcc,$(1)), \ 329 $(subst llvm-gcc,llvm-g++,$(1)), \ 330 $(if $(findstring gcc,$(1)), \ 331 $(subst gcc,g++,$(1)), \ 332 $(subst cc,c++,$(1))))) 333cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1))) 334 335ifneq "$(OS)" "Darwin" 336 CLANG_OR_GCC := $(strip $(if $(findstring clang,$(CC)), \ 337 $(findstring clang,$(CC)), \ 338 $(if $(findstring gcc,$(CC)), \ 339 $(findstring gcc,$(CC)), \ 340 cc))) 341 342 CC_LASTWORD := $(strip $(lastword $(subst -, ,$(CC)))) 343 344 replace_with = $(strip $(if $(findstring $(3),$(CC_LASTWORD)), \ 345 $(subst $(3),$(1),$(2)), \ 346 $(subst $(3),$(1),$(subst -$(CC_LASTWORD),,$(2))))) 347 348 ifeq "$(notdir $(CC))" "$(CC)" 349 replace_cc_with = $(call replace_with,$(1),$(CC),$(CLANG_OR_GCC)) 350 else 351 replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(1),$(notdir $(CC)),$(CLANG_OR_GCC))) 352 endif 353 354 OBJCOPY ?= $(call replace_cc_with,objcopy) 355 ARCHIVER ?= $(call replace_cc_with,ar) 356 override AR = $(ARCHIVER) 357endif 358 359ifdef PIE 360 LDFLAGS += -pie 361endif 362 363#---------------------------------------------------------------------- 364# Windows specific options 365#---------------------------------------------------------------------- 366ifeq "$(OS)" "Windows_NT" 367 ifneq (,$(findstring clang,$(CC))) 368 # Clang for Windows doesn't support C++ Exceptions 369 CXXFLAGS += -fno-exceptions 370 CXXFLAGS += -D_HAS_EXCEPTIONS=0 371 372 # MSVC 2015 or higher is required, which depends on c++14, so 373 # append these values unconditionally. 374 CXXFLAGS += -fms-compatibility-version=19.0 375 override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS)) 376 377 # The MSVC linker doesn't understand long section names 378 # generated by the clang compiler. 379 LDFLAGS += -fuse-ld=lld 380 endif 381endif 382 383#---------------------------------------------------------------------- 384# C++ standard library options 385#---------------------------------------------------------------------- 386ifeq (1,$(USE_LIBSTDCPP)) 387 # Clang requires an extra flag: -stdlib=libstdc++ 388 ifneq (,$(findstring clang,$(CC))) 389 CXXFLAGS += -stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP 390 LDFLAGS += -stdlib=libstdc++ 391 endif 392endif 393 394ifeq (1,$(USE_LIBCPP)) 395 CXXFLAGS += -DLLDB_USING_LIBCPP 396 ifeq "$(OS)" "Linux" 397 ifneq (,$(findstring clang,$(CC))) 398 CXXFLAGS += -stdlib=libc++ 399 LDFLAGS += -stdlib=libc++ 400 else 401 CXXFLAGS += -isystem /usr/include/c++/v1 402 LDFLAGS += -lc++ 403 endif 404 else ifeq "$(OS)" "Android" 405 # Nothing to do, this is already handled in 406 # Android.rules. 407 else 408 CXXFLAGS += -stdlib=libc++ 409 LDFLAGS += -stdlib=libc++ 410 endif 411endif 412 413#---------------------------------------------------------------------- 414# Additional system libraries 415#---------------------------------------------------------------------- 416ifeq (1,$(USE_LIBDL)) 417 ifeq (,$(filter $(OS), NetBSD Windows_NT)) 418 LDFLAGS += -ldl 419 endif 420endif 421 422#---------------------------------------------------------------------- 423# dylib settings 424#---------------------------------------------------------------------- 425 426DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o)) 427DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o)) 428ifneq "$(strip $(DYLIB_CXX_SOURCES))" "" 429 DYLIB_OBJECTS +=$(strip $(patsubst %.mm, %.o, $(DYLIB_CXX_SOURCES:.cpp=.o))) 430 CXX = $(call cxx_compiler,$(CC)) 431 LD = $(call cxx_linker,$(CC)) 432endif 433 434#---------------------------------------------------------------------- 435# Check if we have a precompiled header 436#---------------------------------------------------------------------- 437ifneq "$(strip $(PCH_CXX_SOURCE))" "" 438 PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch) 439 PCHFLAGS = -include $(PCH_CXX_SOURCE) 440endif 441 442#---------------------------------------------------------------------- 443# Check if we have any C source files 444#---------------------------------------------------------------------- 445ifneq "$(strip $(C_SOURCES))" "" 446 OBJECTS +=$(strip $(C_SOURCES:.c=.o)) 447endif 448 449#---------------------------------------------------------------------- 450# Check if we have any C++ source files 451#---------------------------------------------------------------------- 452ifneq "$(strip $(CXX_SOURCES))" "" 453 OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) 454 CXX = $(call cxx_compiler,$(CC)) 455 LD = $(call cxx_linker,$(CC)) 456endif 457 458#---------------------------------------------------------------------- 459# Check if we have any ObjC source files 460#---------------------------------------------------------------------- 461ifneq "$(strip $(OBJC_SOURCES))" "" 462 OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) 463 LDFLAGS +=-lobjc 464endif 465 466#---------------------------------------------------------------------- 467# Check if we have any ObjC++ source files 468#---------------------------------------------------------------------- 469ifneq "$(strip $(OBJCXX_SOURCES))" "" 470 OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) 471 CXX = $(call cxx_compiler,$(CC)) 472 LD = $(call cxx_linker,$(CC)) 473 ifeq "$(findstring lobjc,$(LDFLAGS))" "" 474 LDFLAGS +=-lobjc 475 endif 476endif 477 478ifeq ($(findstring clang, $(CXX)), clang) 479 CXXFLAGS += --driver-mode=g++ 480endif 481 482ifneq "$(CXX)" "" 483 ifeq ($(findstring clang, $(LD)), clang) 484 LDFLAGS += --driver-mode=g++ 485 endif 486endif 487 488#---------------------------------------------------------------------- 489# DYLIB_ONLY variable can be used to skip the building of a.out. 490# See the sections below regarding dSYM file as well as the building of 491# EXE from all the objects. 492#---------------------------------------------------------------------- 493 494#---------------------------------------------------------------------- 495# Compile the executable from all the objects. 496#---------------------------------------------------------------------- 497ifneq "$(DYLIB_NAME)" "" 498ifeq "$(DYLIB_ONLY)" "" 499$(EXE) : $(OBJECTS) $(DYLIB_FILENAME) 500 $(LD) $(OBJECTS) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)" 501ifneq "$(CODESIGN)" "" 502 $(CODESIGN) -s - "$(EXE)" 503endif 504else 505EXE = $(DYLIB_FILENAME) 506endif 507else 508$(EXE) : $(OBJECTS) 509 $(LD) $(OBJECTS) $(LDFLAGS) -o "$(EXE)" 510ifneq "$(CODESIGN)" "" 511 $(CODESIGN) -s - "$(EXE)" 512endif 513endif 514 515#---------------------------------------------------------------------- 516# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO" 517#---------------------------------------------------------------------- 518$(DSYM) : $(EXE) 519ifeq "$(OS)" "Darwin" 520ifneq "$(MAKE_DSYM)" "NO" 521 "$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)" 522else 523endif 524else 525ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" 526 $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)" 527 $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)" 528endif 529endif 530 531#---------------------------------------------------------------------- 532# Make the dylib 533#---------------------------------------------------------------------- 534$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL 535 536ifneq "$(OS)" "Windows_NT" 537$(DYLIB_OBJECTS) : CFLAGS += -fPIC 538$(DYLIB_OBJECTS) : CXXFLAGS += -fPIC 539endif 540 541$(DYLIB_FILENAME) : $(DYLIB_OBJECTS) 542ifeq "$(OS)" "Darwin" 543ifneq "$(FRAMEWORK)" "" 544 mkdir -p $(FRAMEWORK).framework/Versions/A/Headers 545 mkdir -p $(FRAMEWORK).framework/Versions/A/Modules 546 mkdir -p $(FRAMEWORK).framework/Versions/A/Resources 547ifneq "$(FRAMEWORK_MODULES)" "" 548 cp -r $(FRAMEWORK_MODULES) $(FRAMEWORK).framework/Versions/A/Modules 549endif 550ifneq "$(FRAMEWORK_HEADERS)" "" 551 cp -r $(FRAMEWORK_HEADERS) $(FRAMEWORK).framework/Versions/A/Headers 552endif 553 (cd $(FRAMEWORK).framework/Versions; ln -sf A Current) 554 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/Headers Headers) 555 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/Modules Modules) 556 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/Resources Resources) 557 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/$(FRAMEWORK) $(FRAMEWORK)) 558endif 559 $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_INSTALL_NAME)" -dynamiclib -o "$(DYLIB_FILENAME)" 560ifneq "$(CODESIGN)" "" 561 $(CODESIGN) -s - "$(DYLIB_FILENAME)" 562endif 563ifneq "$(MAKE_DSYM)" "NO" 564ifneq "$(DS)" "" 565 "$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)" 566endif 567endif 568else 569 $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)" 570ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" 571 $(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug" 572 $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)" 573endif 574endif 575 576#---------------------------------------------------------------------- 577# Make the precompiled header and compile C++ sources against it 578#---------------------------------------------------------------------- 579 580ifneq "$(PCH_OUTPUT)" "" 581$(PCH_OUTPUT) : $(PCH_CXX_SOURCE) 582 $(CXX) $(CXXFLAGS) -x c++-header -o $@ $< 583endif 584 585%.o: %.c %.d 586 $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< 587 588%.o: %.cpp %.d $(PCH_OUTPUT) 589 $(CXX) $(PCHFLAGS) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< 590 591%.o: %.m %.d 592 $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< 593 594%.o: %.mm %.d 595 $(CXX) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< 596 597#---------------------------------------------------------------------- 598# Automatic variables based on items already entered. Below we create 599# an object's lists from the list of sources by replacing all entries 600# that end with .c with .o, and we also create a list of prerequisite 601# files by replacing all .c files with .d. 602#---------------------------------------------------------------------- 603PREREQS := $(OBJECTS:.o=.d) 604DWOS := $(OBJECTS:.o=.dwo) 605ifneq "$(DYLIB_NAME)" "" 606 DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d) 607 DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo) 608endif 609 610# Don't error if a .d file is deleted. 611$(PREREQS) $(DYLIB_PREREQS): ; 612 613#---------------------------------------------------------------------- 614# Include all of the makefiles for each source file so we don't have 615# to manually track all of the prerequisites for each source file. 616#---------------------------------------------------------------------- 617include $(wildcard $(PREREQS) $(DYLIB_PREREQS)) 618 619.PHONY: clean 620dsym: $(DSYM) 621all: $(EXE) $(DSYM) 622clean:: 623ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" "" 624 $(error Trying to invoke the clean rule, but not using the default build tree layout) 625else 626 $(RM) -r $(wildcard $(BUILDDIR)/*) 627endif 628 629#---------------------------------------------------------------------- 630# From http://blog.melski.net/tag/debugging-makefiles/ 631# 632# Usage: make print-CC print-CXX print-LD 633#---------------------------------------------------------------------- 634print-%: 635 @echo '$*=$($*)' 636 @echo ' origin = $(origin $*)' 637 @echo ' flavor = $(flavor $*)' 638 @echo ' value = $(value $*)' 639 640### Local Variables: ### 641### mode:makefile ### 642### End: ### 643