1 #----------------------------------------------------------------------
2 # Clients fill in the source files to build
3 #----------------------------------------------------------------------
9 # DYLIB_OBJC_SOURCES :=
10 # DYLIB_CXX_SOURCES :=
12 # Specifying DYLIB_ONLY has the effect of building dylib only, skipping
13 # the building of the a.out executable program. For example,
16 # Specifying FRAMEWORK and its variants has the effect of building a NeXT-style
19 # FRAMEWORK_HEADERS := "Foo.h"
20 # FRAMEWORK_MODULES := "module.modulemap"
22 # Also might be of interest:
23 # FRAMEWORK_INCLUDES (Darwin only) :=
26 # SPLIT_DEBUG_SYMBOLS := YES
28 # USE_PRIVATE_MODULE_CACHE := YES
30 # And test/functionalities/archives/Makefile:
32 # ARCHIVE_NAME := libfoo.a
33 # ARCHIVE_C_SOURCES := a.c b.c
35 # Uncomment line below for debugging shell commands
38 SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))
39 BUILDDIR := $(shell pwd)
40 MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST))
41 THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES))
42 LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
44 # The test harness invokes the test Makefiles with an explicit 'all'
45 # target, but its handy to be able to recursively call this Makefile
46 # without specifying a goal. You almost certainly want to build 'all',
47 # and not only the first target defined in this file (which might vary
48 # according to variable values).
51 #----------------------------------------------------------------------
52 # If OS is not defined, use 'uname -s' to determine the OS name.
54 # uname on Windows gives "windows32" or "server version windows32", but most
55 # environments standardize on "Windows_NT", so we'll make it consistent here.
56 # When running tests from Visual Studio, the environment variable isn't
57 # inherited all the way down to the process spawned for make.
58 #----------------------------------------------------------------------
59 HOST_OS = $(shell uname -s)
60 ifneq (,$(findstring windows32,$(HOST_OS)))
67 #----------------------------------------------------------------------
68 # If OS is Windows, force SHELL to be cmd
70 # Some versions of make on Windows will search for other shells such as
71 # C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons
72 # so default to using cmd.exe.
73 #----------------------------------------------------------------------
74 ifeq "$(OS)" "Windows_NT"
75 SHELL = $(WINDIR)\system32\cmd.exe
78 #----------------------------------------------------------------------
79 # If the OS is Windows use double-quotes in commands
81 # For other operating systems, single-quotes work fine, but on Windows
82 # we strictly required double-quotes
83 #----------------------------------------------------------------------
84 ifeq "$(HOST_OS)" "Windows_NT"
87 FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = "
91 FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = '
94 #----------------------------------------------------------------------
95 # If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
96 # from the triple alone
97 #----------------------------------------------------------------------
100 triple_space = $(subst -, ,$(TRIPLE))
101 ARCH =$(word 1, $(triple_space))
102 TRIPLE_VENDOR =$(word 2, $(triple_space))
103 triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/')
104 TRIPLE_OS =$(word 1, $(triple_os_and_version))
105 TRIPLE_VERSION =$(word 2, $(triple_os_and_version))
106 TRIPLE_ENV =$(word 4, $(triple_space))
107 ifeq "$(TRIPLE_VENDOR)" "apple"
108 ifeq "$(TRIPLE_OS)" "ios"
111 # Set SDKROOT if it wasn't set
112 ifneq (,$(findstring arm,$(ARCH)))
113 SDKROOT = $(shell xcrun --sdk iphoneos --show-sdk-path)
114 ifeq "$(TRIPLE_VERSION)" ""
115 TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
117 ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
119 ifeq "$(TRIPLE_ENV)" "macabi"
120 SDKROOT = $(shell xcrun --sdk macosx --show-sdk-path)
122 SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
124 ifeq "$(TRIPLE_VERSION)" ""
125 TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
127 ifeq "$(TRIPLE_ENV)" "macabi"
128 ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
130 ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
135 ifeq "$(TRIPLE_OS)" "watchos"
138 # Set SDKROOT if it wasn't set
139 ifneq (,$(findstring arm,$(ARCH)))
140 SDKROOT = $(shell xcrun --sdk watchos --show-sdk-path)
141 ifeq "$(TRIPLE_VERSION)" ""
142 TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
144 ARCH_CFLAGS :=-mwatchos-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
146 SDKROOT = $(shell xcrun --sdk watchsimulator --show-sdk-path)
147 ifeq "$(TRIPLE_VERSION)" ""
148 TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
150 ARCH_CFLAGS :=-mwatchos-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
156 ifeq "$(OS)" "Android"
157 include $(THIS_FILE_DIR)/Android.rules
160 #----------------------------------------------------------------------
161 # If ARCH is not defined, default to x86_64.
162 #----------------------------------------------------------------------
164 ifeq "$(OS)" "Windows_NT"
171 #----------------------------------------------------------------------
172 # CC defaults to clang.
174 # If you change the defaults of CC, be sure to also change it in the file
175 # test/plugins/builder_base.py, which provides a Python way to return the
176 # value of the make variable CC -- getCompiler().
178 # See also these functions:
181 #----------------------------------------------------------------------
183 $(error "C compiler is not specified. Please run tests through lldb-dotest or lit")
186 #----------------------------------------------------------------------
187 # Handle SDKROOT on Darwin
188 #----------------------------------------------------------------------
190 ifeq "$(OS)" "Darwin"
192 # We haven't otherwise set the SDKROOT, so set it now to macosx
193 SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
197 #----------------------------------------------------------------------
198 # ARCHFLAG is the flag used to tell the compiler which architecture
199 # to compile for. The default is the flag that clang accepts.
200 #----------------------------------------------------------------------
203 #----------------------------------------------------------------------
204 # Change any build/tool options needed
205 #----------------------------------------------------------------------
206 ifeq "$(OS)" "Darwin"
210 AR := $(CROSS_COMPILE)libtool
211 ARFLAGS := -static -o
213 AR := $(CROSS_COMPILE)ar
214 # On non-Apple platforms, -arch becomes -m
217 # i386, i686, x86 -> 32
218 # amd64, x86_64, x64 -> 64
219 ifeq "$(ARCH)" "amd64"
220 override ARCH := $(subst amd64,64,$(ARCH))
222 ifeq "$(ARCH)" "x86_64"
223 override ARCH := $(subst x86_64,64,$(ARCH))
226 override ARCH := $(subst x64,64,$(ARCH))
229 override ARCH := $(subst x86,32,$(ARCH))
231 ifeq "$(ARCH)" "i386"
232 override ARCH := $(subst i386,32,$(ARCH))
234 ifeq "$(ARCH)" "i686"
235 override ARCH := $(subst i686,32,$(ARCH))
237 ifeq "$(ARCH)" "powerpc"
238 override ARCH := $(subst powerpc,32,$(ARCH))
240 ifeq "$(ARCH)" "powerpc64"
241 override ARCH := $(subst powerpc64,64,$(ARCH))
243 ifeq "$(ARCH)" "powerpc64le"
244 override ARCH := $(subst powerpc64le,64,$(ARCH))
246 ifeq "$(ARCH)" "aarch64"
250 ifeq "$(findstring arm,$(ARCH))" "arm"
254 ifeq "$(ARCH)" "s390x"
258 ifeq "$(findstring mips,$(ARCH))" "mips"
259 override ARCHFLAG := -
262 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
267 LIMIT_DEBUG_INFO_FLAGS =
268 NO_LIMIT_DEBUG_INFO_FLAGS =
269 MODULE_DEBUG_INFO_FLAGS =
270 ifneq (,$(findstring clang,$(CC)))
271 LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info
272 NO_LIMIT_DEBUG_INFO_FLAGS += -fno-limit-debug-info
273 MODULE_DEBUG_INFO_FLAGS += -gmodules
276 DEBUG_INFO_FLAG ?= -g
278 CFLAGS ?= $(DEBUG_INFO_FLAG) -O0 -fno-builtin
280 ifeq "$(OS)" "Darwin"
281 ifneq "$(SDKROOT)" ""
282 CFLAGS += -isysroot "$(SDKROOT)"
286 ifeq "$(OS)" "Darwin"
287 CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include
289 CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include
292 CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR)
294 ifndef NO_TEST_COMMON_H
295 CFLAGS += -include $(THIS_FILE_DIR)/test_common.h
298 CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
300 # If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will build
301 # with codeview by default but all the tests rely on dwarf.
302 ifeq "$(OS)" "Windows_NT"
306 # Use this one if you want to build one part of the result without debug information:
307 ifeq "$(OS)" "Darwin"
308 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
310 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
313 ifeq "$(MAKE_DWO)" "YES"
314 CFLAGS += -gsplit-dwarf
317 ifeq "$(USE_PRIVATE_MODULE_CACHE)" "YES"
318 THE_CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/private-module-cache
320 THE_CLANG_MODULE_CACHE_DIR := $(CLANG_MODULE_CACHE_DIR)
323 MODULE_BASE_FLAGS := -fmodules -gmodules -fmodules-cache-path=$(THE_CLANG_MODULE_CACHE_DIR)
324 MANDATORY_MODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -gmodules
325 # Build flags for building with C++ modules.
326 # -glldb is necessary for emitting information about what modules were imported.
327 MANDATORY_CXXMODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -fcxx-modules -glldb
329 ifeq "$(OS)" "Darwin"
330 MANDATORY_MODULE_BUILD_CFLAGS += -fcxx-modules
333 ifeq "$(MAKE_GMODULES)" "YES"
334 CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)
335 CXXFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)
338 CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_EXTRAS)
341 LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
342 ifneq (,$(LLVM_LIBS_DIR))
344 LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LLVM_LIBS_DIR)
347 ifeq (,$(filter $(OS), Windows_NT Android Darwin))
348 ifneq (,$(filter YES,$(ENABLE_THREADS)))
355 ifneq "$(FRAMEWORK)" ""
356 DYLIB_NAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)
357 DYLIB_FILENAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)
360 ifneq "$(DYLIB_NAME)" ""
361 ifeq "$(OS)" "Darwin"
362 ifneq "$(FRAMEWORK)" ""
363 DYLIB_INSTALL_NAME ?= @executable_path/$(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)
365 DYLIB_FILENAME = lib$(DYLIB_NAME).dylib
366 DYLIB_INSTALL_NAME ?= @executable_path/$(DYLIB_FILENAME)
368 else ifeq "$(OS)" "Windows_NT"
369 DYLIB_FILENAME = $(DYLIB_NAME).dll
371 DYLIB_FILENAME = lib$(DYLIB_NAME).so
375 # Function that returns the counterpart C++ compiler, given $(CC) as arg.
376 cxx_compiler_notdir = $(if $(findstring icc,$(1)), \
377 $(subst icc,icpc,$(1)), \
378 $(if $(findstring llvm-gcc,$(1)), \
379 $(subst llvm-gcc,llvm-g++,$(1)), \
380 $(if $(findstring gcc,$(1)), \
381 $(subst gcc,g++,$(1)), \
382 $(subst cc,c++,$(1)))))
383 cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1)))
385 # Function that returns the C++ linker, given $(CC) as arg.
386 cxx_linker_notdir = $(if $(findstring icc,$(1)), \
387 $(subst icc,icpc,$(1)), \
388 $(if $(findstring llvm-gcc,$(1)), \
389 $(subst llvm-gcc,llvm-g++,$(1)), \
390 $(if $(findstring gcc,$(1)), \
391 $(subst gcc,g++,$(1)), \
392 $(subst cc,c++,$(1)))))
393 cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1)))
395 ifneq "$(OS)" "Darwin"
396 CLANG_OR_GCC := $(strip $(if $(findstring clang,$(CC)), \
397 $(findstring clang,$(CC)), \
398 $(if $(findstring gcc,$(CC)), \
399 $(findstring gcc,$(CC)), \
402 CC_LASTWORD := $(strip $(lastword $(subst -, ,$(CC))))
404 replace_with = $(strip $(if $(findstring $(3),$(CC_LASTWORD)), \
405 $(subst $(3),$(1),$(2)), \
406 $(subst $(3),$(1),$(subst -$(CC_LASTWORD),,$(2)))))
408 ifeq "$(notdir $(CC))" "$(CC)"
409 replace_cc_with = $(call replace_with,$(1),$(CC),$(CLANG_OR_GCC))
411 replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(1),$(notdir $(CC)),$(CLANG_OR_GCC)))
414 OBJCOPY ?= $(call replace_cc_with,objcopy)
415 ARCHIVER ?= $(call replace_cc_with,ar)
416 override AR = $(ARCHIVER)
423 #----------------------------------------------------------------------
424 # Windows specific options
425 #----------------------------------------------------------------------
426 ifeq "$(OS)" "Windows_NT"
427 ifneq (,$(findstring clang,$(CC)))
428 # Clang for Windows doesn't support C++ Exceptions
429 CXXFLAGS += -fno-exceptions
430 CXXFLAGS += -D_HAS_EXCEPTIONS=0
432 # MSVC 2015 or higher is required, which depends on c++14, so
433 # append these values unconditionally.
434 CXXFLAGS += -fms-compatibility-version=19.0
435 override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
437 # The MSVC linker doesn't understand long section names
438 # generated by the clang compiler.
439 LDFLAGS += -fuse-ld=lld
443 #----------------------------------------------------------------------
444 # C++ standard library options
445 #----------------------------------------------------------------------
446 ifeq (1,$(USE_LIBSTDCPP))
447 # Clang requires an extra flag: -stdlib=libstdc++
448 ifneq (,$(findstring clang,$(CC)))
449 CXXFLAGS += -stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP
450 LDFLAGS += -stdlib=libstdc++
454 ifeq (1,$(USE_LIBCPP))
455 CXXFLAGS += -DLLDB_USING_LIBCPP
457 ifneq (,$(findstring clang,$(CC)))
458 CXXFLAGS += -stdlib=libc++
459 LDFLAGS += -stdlib=libc++
461 CXXFLAGS += -isystem /usr/include/c++/v1
464 else ifeq "$(OS)" "Android"
465 # Nothing to do, this is already handled in
468 CXXFLAGS += -stdlib=libc++
469 LDFLAGS += -stdlib=libc++
473 #----------------------------------------------------------------------
474 # Additional system libraries
475 #----------------------------------------------------------------------
476 ifeq (1,$(USE_LIBDL))
482 #----------------------------------------------------------------------
484 #----------------------------------------------------------------------
486 DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o))
487 DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o))
488 ifneq "$(strip $(DYLIB_CXX_SOURCES))" ""
489 DYLIB_OBJECTS +=$(strip $(patsubst %.mm, %.o, $(DYLIB_CXX_SOURCES:.cpp=.o)))
490 CXX = $(call cxx_compiler,$(CC))
491 LD = $(call cxx_linker,$(CC))
494 #----------------------------------------------------------------------
495 # Check if we have a precompiled header
496 #----------------------------------------------------------------------
497 ifneq "$(strip $(PCH_CXX_SOURCE))" ""
498 PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch)
499 PCHFLAGS = -include $(PCH_CXX_SOURCE)
502 #----------------------------------------------------------------------
503 # Check if we have any C source files
504 #----------------------------------------------------------------------
505 ifneq "$(strip $(C_SOURCES))" ""
506 OBJECTS +=$(strip $(C_SOURCES:.c=.o))
509 #----------------------------------------------------------------------
510 # Check if we have any C++ source files
511 #----------------------------------------------------------------------
512 ifneq "$(strip $(CXX_SOURCES))" ""
513 OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
514 CXX = $(call cxx_compiler,$(CC))
515 LD = $(call cxx_linker,$(CC))
518 #----------------------------------------------------------------------
519 # Check if we have any ObjC source files
520 #----------------------------------------------------------------------
521 ifneq "$(strip $(OBJC_SOURCES))" ""
522 OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
526 #----------------------------------------------------------------------
527 # Check if we have any ObjC++ source files
528 #----------------------------------------------------------------------
529 ifneq "$(strip $(OBJCXX_SOURCES))" ""
530 OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
531 CXX = $(call cxx_compiler,$(CC))
532 LD = $(call cxx_linker,$(CC))
533 ifeq "$(findstring lobjc,$(LDFLAGS))" ""
538 #----------------------------------------------------------------------
539 # Check if we have any C source files for archive
540 #----------------------------------------------------------------------
541 ifneq "$(strip $(ARCHIVE_C_SOURCES))" ""
542 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o))
545 #----------------------------------------------------------------------
546 # Check if we have any C++ source files for archive
547 #----------------------------------------------------------------------
548 ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" ""
549 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o))
550 CXX = $(call cxx_compiler,$(CC))
551 LD = $(call cxx_linker,$(CC))
554 #----------------------------------------------------------------------
555 # Check if we have any ObjC source files for archive
556 #----------------------------------------------------------------------
557 ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" ""
558 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o))
562 #----------------------------------------------------------------------
563 # Check if we have any ObjC++ source files for archive
564 #----------------------------------------------------------------------
565 ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" ""
566 ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o))
567 CXX = $(call cxx_compiler,$(CC))
568 LD = $(call cxx_linker,$(CC))
569 ifeq "$(findstring lobjc,$(LDFLAGS))" ""
574 #----------------------------------------------------------------------
575 # Check if we are compiling with gcc 4.6
576 #----------------------------------------------------------------------
577 ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" ""
578 ifneq "$(filter g++,$(CXX))" ""
579 CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3)
580 ifeq "$(CXXVERSION)" "4.6"
581 # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x
582 # instead. FIXME: remove once GCC version is upgraded.
583 override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS))
588 ifeq ($(findstring clang, $(CXX)), clang)
589 CXXFLAGS += --driver-mode=g++
593 ifeq ($(findstring clang, $(LD)), clang)
594 LDFLAGS += --driver-mode=g++
598 #----------------------------------------------------------------------
599 # DYLIB_ONLY variable can be used to skip the building of a.out.
600 # See the sections below regarding dSYM file as well as the building of
601 # EXE from all the objects.
602 #----------------------------------------------------------------------
604 #----------------------------------------------------------------------
605 # Compile the executable from all the objects.
606 #----------------------------------------------------------------------
607 ifneq "$(DYLIB_NAME)" ""
608 ifeq "$(DYLIB_ONLY)" ""
609 $(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME)
610 $(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"
611 ifneq "$(CODESIGN)" ""
612 $(CODESIGN) -s - "$(EXE)"
615 EXE = $(DYLIB_FILENAME)
618 $(EXE) : $(OBJECTS) $(ARCHIVE_NAME)
619 $(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)"
620 ifneq "$(CODESIGN)" ""
621 $(CODESIGN) -s - "$(EXE)"
625 #----------------------------------------------------------------------
626 # Make the dSYM file from the executable if $(MAKE_DSYM) != "NO"
627 #----------------------------------------------------------------------
629 ifeq "$(OS)" "Darwin"
630 ifneq "$(MAKE_DSYM)" "NO"
631 "$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
635 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
636 $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
637 $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
641 #----------------------------------------------------------------------
643 #----------------------------------------------------------------------
644 ifneq "$(ARCHIVE_NAME)" ""
645 ifeq "$(OS)" "Darwin"
646 $(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS)
647 $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
648 $(RM) $(ARCHIVE_OBJECTS)
650 $(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj)))
654 #----------------------------------------------------------------------
656 #----------------------------------------------------------------------
657 $(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL
659 ifneq "$(OS)" "Windows_NT"
660 $(DYLIB_OBJECTS) : CFLAGS += -fPIC
661 $(DYLIB_OBJECTS) : CXXFLAGS += -fPIC
664 $(DYLIB_FILENAME) : $(DYLIB_OBJECTS)
665 ifeq "$(OS)" "Darwin"
666 ifneq "$(FRAMEWORK)" ""
667 mkdir -p $(FRAMEWORK).framework/Versions/A/Headers
668 mkdir -p $(FRAMEWORK).framework/Versions/A/Modules
669 mkdir -p $(FRAMEWORK).framework/Versions/A/Resources
670 ifneq "$(FRAMEWORK_MODULES)" ""
671 cp -r $(FRAMEWORK_MODULES) $(FRAMEWORK).framework/Versions/A/Modules
673 ifneq "$(FRAMEWORK_HEADERS)" ""
674 cp -r $(FRAMEWORK_HEADERS) $(FRAMEWORK).framework/Versions/A/Headers
676 (cd $(FRAMEWORK).framework/Versions; ln -sf A Current)
677 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/Headers Headers)
678 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/Modules Modules)
679 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/Resources Resources)
680 (cd $(FRAMEWORK).framework/; ln -sf Versions/A/$(FRAMEWORK) $(FRAMEWORK))
682 $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_INSTALL_NAME)" -dynamiclib -o "$(DYLIB_FILENAME)"
683 ifneq "$(CODESIGN)" ""
684 $(CODESIGN) -s - "$(DYLIB_FILENAME)"
686 ifneq "$(MAKE_DSYM)" "NO"
688 "$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)"
692 $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
693 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
694 $(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
695 $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
699 #----------------------------------------------------------------------
700 # Make the precompiled header and compile C++ sources against it
701 #----------------------------------------------------------------------
703 #ifneq "$(PCH_OUTPUT)" ""
704 $(PCH_OUTPUT) : $(PCH_CXX_SOURCE)
705 $(CXX) $(CXXFLAGS) -x c++-header -o $@ $<
706 %.o : %.cpp $(PCH_OUTPUT)
707 $(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $<
710 #----------------------------------------------------------------------
711 # Automatic variables based on items already entered. Below we create
712 # an object's lists from the list of sources by replacing all entries
713 # that end with .c with .o, and we also create a list of prerequisite
714 # files by replacing all .c files with .d.
715 #----------------------------------------------------------------------
716 PREREQS := $(OBJECTS:.o=.d)
717 DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo)
718 ifneq "$(DYLIB_NAME)" ""
719 DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d)
720 DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo)
723 #----------------------------------------------------------------------
724 # Rule for Generating Prerequisites Automatically using .d files and
725 # the compiler -MM option. The -M option will list all system headers,
726 # and the -MM option will list all non-system dependencies.
727 #----------------------------------------------------------------------
729 @rm -f $@ $(JOIN_CMD) \
730 $(CC) -M $(CFLAGS) $< > $@.tmp && \
731 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
735 @rm -f $@ $(JOIN_CMD) \
736 $(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
737 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
741 @rm -f $@ $(JOIN_CMD) \
742 $(CC) -M $(CFLAGS) $< > $@.tmp && \
743 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
747 @rm -f $@ $(JOIN_CMD) \
748 $(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
749 sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
752 #----------------------------------------------------------------------
753 # Include all of the makefiles for each source file so we don't have
754 # to manually track all of the prerequisites for each source file.
755 #----------------------------------------------------------------------
757 ifneq "$(DYLIB_NAME)" ""
758 sinclude $(DYLIB_PREREQS)
761 # Define a suffix rule for .mm -> .o
764 $(CXX) $(CXXFLAGS) -c $<
770 ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
771 $(error Trying to invoke the clean rule, but not using the default build tree layout)
773 $(RM) -r $(wildcard $(BUILDDIR)/*)
776 #----------------------------------------------------------------------
777 # From http://blog.melski.net/tag/debugging-makefiles/
779 # Usage: make print-CC print-CXX print-LD
780 #----------------------------------------------------------------------
783 @echo ' origin = $(origin $*)'
784 @echo ' flavor = $(flavor $*)'
785 @echo ' value = $(value $*)'
787 ### Local Variables: ###
788 ### mode:makefile ###