xref: /openbsd-src/gnu/llvm/lldb/packages/Python/lldbsuite/test/make/Makefile.rules (revision 5a38ef86d0b61900239c7913d24a05e7b88a58f0)
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)
282ifeq (,$(filter $(OS), Windows_NT Android Darwin))
283	ifneq (,$(filter YES,$(ENABLE_THREADS)))
284		LDFLAGS += -pthread
285	endif
286endif
287OBJECTS =
288EXE ?= a.out
289
290ifneq "$(FRAMEWORK)" ""
291	DYLIB_NAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)
292	DYLIB_FILENAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)
293endif
294
295ifneq "$(DYLIB_NAME)" ""
296	ifeq "$(OS)" "Darwin"
297		ifneq "$(FRAMEWORK)" ""
298			DYLIB_INSTALL_NAME ?= @executable_path/$(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)
299		else
300			DYLIB_FILENAME = lib$(DYLIB_NAME).dylib
301			DYLIB_INSTALL_NAME ?= @executable_path/$(DYLIB_FILENAME)
302		endif
303	else ifeq "$(OS)" "Windows_NT"
304		DYLIB_FILENAME = $(DYLIB_NAME).dll
305	else
306		DYLIB_FILENAME = lib$(DYLIB_NAME).so
307	endif
308endif
309
310# Function that returns the counterpart C++ compiler, given $(CC) as arg.
311cxx_compiler_notdir = $(if $(findstring icc,$(1)), \
312			$(subst icc,icpc,$(1)), \
313			$(if $(findstring llvm-gcc,$(1)), \
314				$(subst llvm-gcc,llvm-g++,$(1)), \
315				$(if $(findstring gcc,$(1)), \
316					$(subst gcc,g++,$(1)), \
317					$(subst cc,c++,$(1)))))
318cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1)))
319
320# Function that returns the C++ linker, given $(CC) as arg.
321cxx_linker_notdir = $(if $(findstring icc,$(1)), \
322			$(subst icc,icpc,$(1)), \
323			$(if $(findstring llvm-gcc,$(1)), \
324				$(subst llvm-gcc,llvm-g++,$(1)), \
325				$(if $(findstring gcc,$(1)), \
326					$(subst gcc,g++,$(1)), \
327					$(subst cc,c++,$(1)))))
328cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1)))
329
330ifneq "$(OS)" "Darwin"
331	CLANG_OR_GCC := $(strip $(if $(findstring clang,$(CC)), \
332				$(findstring clang,$(CC)), \
333				$(if $(findstring gcc,$(CC)), \
334					$(findstring gcc,$(CC)), \
335					cc)))
336
337	CC_LASTWORD := $(strip $(lastword $(subst -, ,$(CC))))
338
339	replace_with = $(strip $(if $(findstring $(3),$(CC_LASTWORD)), \
340			$(subst $(3),$(1),$(2)), \
341			$(subst $(3),$(1),$(subst -$(CC_LASTWORD),,$(2)))))
342
343	ifeq "$(notdir $(CC))" "$(CC)"
344		replace_cc_with = $(call replace_with,$(1),$(CC),$(CLANG_OR_GCC))
345	else
346		replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(1),$(notdir $(CC)),$(CLANG_OR_GCC)))
347	endif
348
349	OBJCOPY ?= $(call replace_cc_with,objcopy)
350	ARCHIVER ?= $(call replace_cc_with,ar)
351	override AR = $(ARCHIVER)
352endif
353
354ifdef PIE
355	LDFLAGS += -pie
356endif
357
358#----------------------------------------------------------------------
359# Windows specific options
360#----------------------------------------------------------------------
361ifeq "$(OS)" "Windows_NT"
362	ifneq (,$(findstring clang,$(CC)))
363		# Clang for Windows doesn't support C++ Exceptions
364		CXXFLAGS += -fno-exceptions
365		CXXFLAGS += -D_HAS_EXCEPTIONS=0
366
367		# MSVC 2015 or higher is required, which depends on c++14, so
368		# append these values unconditionally.
369		CXXFLAGS += -fms-compatibility-version=19.0
370		override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
371
372		# The MSVC linker doesn't understand long section names
373		# generated by the clang compiler.
374		LDFLAGS += -fuse-ld=lld
375	endif
376endif
377
378#----------------------------------------------------------------------
379# C++ standard library options
380#----------------------------------------------------------------------
381ifeq (1,$(USE_LIBSTDCPP))
382	# Clang requires an extra flag: -stdlib=libstdc++
383	ifneq (,$(findstring clang,$(CC)))
384		CXXFLAGS += -stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP
385		LDFLAGS += -stdlib=libstdc++
386	endif
387endif
388
389ifeq (1,$(USE_LIBCPP))
390	CXXFLAGS += -DLLDB_USING_LIBCPP
391	ifeq "$(OS)" "Android"
392		# Nothing to do, this is already handled in
393		# Android.rules.
394	else
395		CXXFLAGS += -stdlib=libc++
396		LDFLAGS += -stdlib=libc++
397	endif
398	ifneq (,$(filter $(OS), FreeBSD Linux NetBSD))
399		ifneq (,$(LLVM_LIBS_DIR))
400			LDFLAGS += -Wl,-rpath,$(LLVM_LIBS_DIR)
401		endif
402	endif
403endif
404
405#----------------------------------------------------------------------
406# Additional system libraries
407#----------------------------------------------------------------------
408ifeq (1,$(USE_LIBDL))
409	ifeq (,$(filter $(OS), NetBSD Windows_NT))
410		LDFLAGS += -ldl
411	endif
412endif
413
414#----------------------------------------------------------------------
415# dylib settings
416#----------------------------------------------------------------------
417
418DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o))
419DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o))
420ifneq "$(strip $(DYLIB_CXX_SOURCES))" ""
421	DYLIB_OBJECTS +=$(strip $(patsubst %.mm, %.o, $(DYLIB_CXX_SOURCES:.cpp=.o)))
422	CXX = $(call cxx_compiler,$(CC))
423	LD = $(call cxx_linker,$(CC))
424endif
425
426#----------------------------------------------------------------------
427# Check if we have a precompiled header
428#----------------------------------------------------------------------
429ifneq "$(strip $(PCH_CXX_SOURCE))" ""
430	PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch)
431	PCHFLAGS = -include $(PCH_CXX_SOURCE)
432endif
433
434#----------------------------------------------------------------------
435# Check if we have any C source files
436#----------------------------------------------------------------------
437ifneq "$(strip $(C_SOURCES))" ""
438	OBJECTS +=$(strip $(C_SOURCES:.c=.o))
439endif
440
441#----------------------------------------------------------------------
442# Check if we have any C++ source files
443#----------------------------------------------------------------------
444ifneq "$(strip $(CXX_SOURCES))" ""
445	OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
446	CXX = $(call cxx_compiler,$(CC))
447	LD = $(call cxx_linker,$(CC))
448endif
449
450#----------------------------------------------------------------------
451# Check if we have any ObjC source files
452#----------------------------------------------------------------------
453ifneq "$(strip $(OBJC_SOURCES))" ""
454	OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
455	LDFLAGS +=-lobjc
456endif
457
458#----------------------------------------------------------------------
459# Check if we have any ObjC++ source files
460#----------------------------------------------------------------------
461ifneq "$(strip $(OBJCXX_SOURCES))" ""
462	OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
463	CXX = $(call cxx_compiler,$(CC))
464	LD = $(call cxx_linker,$(CC))
465	ifeq "$(findstring lobjc,$(LDFLAGS))" ""
466		LDFLAGS +=-lobjc
467	endif
468endif
469
470ifeq ($(findstring clang, $(CXX)), clang)
471	CXXFLAGS += --driver-mode=g++
472endif
473
474ifneq "$(CXX)" ""
475	ifeq ($(findstring clang, $(LD)), clang)
476		LDFLAGS += --driver-mode=g++
477	endif
478endif
479
480#----------------------------------------------------------------------
481# DYLIB_ONLY variable can be used to skip the building of a.out.
482# See the sections below regarding dSYM file as well as the building of
483# EXE from all the objects.
484#----------------------------------------------------------------------
485
486#----------------------------------------------------------------------
487# Compile the executable from all the objects.
488#----------------------------------------------------------------------
489ifneq "$(DYLIB_NAME)" ""
490ifeq "$(DYLIB_ONLY)" ""
491$(EXE) : $(OBJECTS) $(DYLIB_FILENAME)
492	$(LD) $(OBJECTS) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"
493ifneq "$(CODESIGN)" ""
494	$(CODESIGN) -s - "$(EXE)"
495endif
496else
497EXE = $(DYLIB_FILENAME)
498endif
499else
500$(EXE) : $(OBJECTS)
501	$(LD) $(OBJECTS) $(LDFLAGS) -o "$(EXE)"
502ifneq "$(CODESIGN)" ""
503	$(CODESIGN) -s - "$(EXE)"
504endif
505endif
506
507#----------------------------------------------------------------------
508# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO"
509#----------------------------------------------------------------------
510$(DSYM) : $(EXE)
511ifeq "$(OS)" "Darwin"
512ifneq "$(MAKE_DSYM)" "NO"
513	"$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
514else
515endif
516else
517ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
518	$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
519	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
520endif
521endif
522
523#----------------------------------------------------------------------
524# Make the dylib
525#----------------------------------------------------------------------
526$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL
527
528ifneq "$(OS)" "Windows_NT"
529$(DYLIB_OBJECTS) : CFLAGS += -fPIC
530$(DYLIB_OBJECTS) : CXXFLAGS += -fPIC
531endif
532
533$(DYLIB_FILENAME) : $(DYLIB_OBJECTS)
534ifeq "$(OS)" "Darwin"
535ifneq "$(FRAMEWORK)" ""
536	mkdir -p $(FRAMEWORK).framework/Versions/A/Headers
537	mkdir -p $(FRAMEWORK).framework/Versions/A/Modules
538	mkdir -p $(FRAMEWORK).framework/Versions/A/Resources
539ifneq "$(FRAMEWORK_MODULES)" ""
540	cp -r $(FRAMEWORK_MODULES) $(FRAMEWORK).framework/Versions/A/Modules
541endif
542ifneq "$(FRAMEWORK_HEADERS)" ""
543	cp -r $(FRAMEWORK_HEADERS) $(FRAMEWORK).framework/Versions/A/Headers
544endif
545	(cd $(FRAMEWORK).framework/Versions; ln -sf A Current)
546	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/Headers Headers)
547	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/Modules Modules)
548	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/Resources Resources)
549	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/$(FRAMEWORK) $(FRAMEWORK))
550endif
551	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_INSTALL_NAME)" -dynamiclib -o "$(DYLIB_FILENAME)"
552ifneq "$(CODESIGN)" ""
553	$(CODESIGN) -s - "$(DYLIB_FILENAME)"
554endif
555ifneq "$(MAKE_DSYM)" "NO"
556ifneq "$(DS)" ""
557	"$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)"
558endif
559endif
560else
561	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
562ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
563	$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
564	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
565endif
566endif
567
568#----------------------------------------------------------------------
569# Make the precompiled header and compile C++ sources against it
570#----------------------------------------------------------------------
571
572ifneq "$(PCH_OUTPUT)" ""
573$(PCH_OUTPUT) : $(PCH_CXX_SOURCE)
574	$(CXX) $(CXXFLAGS) -x c++-header -o $@ $<
575endif
576
577%.o: %.c %.d
578	$(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
579
580%.o: %.cpp %.d $(PCH_OUTPUT)
581	$(CXX) $(PCHFLAGS) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
582
583%.o: %.m %.d
584	$(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
585
586%.o: %.mm %.d
587	$(CXX) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
588
589#----------------------------------------------------------------------
590# Automatic variables based on items already entered. Below we create
591# an object's lists from the list of sources by replacing all entries
592# that end with .c with .o, and we also create a list of prerequisite
593# files by replacing all .c files with .d.
594#----------------------------------------------------------------------
595PREREQS := $(OBJECTS:.o=.d)
596DWOS := $(OBJECTS:.o=.dwo)
597ifneq "$(DYLIB_NAME)" ""
598	DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d)
599	DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo)
600endif
601
602# Don't error if a .d file is deleted.
603$(PREREQS) $(DYLIB_PREREQS): ;
604
605#----------------------------------------------------------------------
606# Include all of the makefiles for each source file so we don't have
607# to manually track all of the prerequisites for each source file.
608#----------------------------------------------------------------------
609include $(wildcard $(PREREQS) $(DYLIB_PREREQS))
610
611.PHONY: clean
612dsym:	$(DSYM)
613all:	$(EXE) $(DSYM)
614clean::
615ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
616	$(error Trying to invoke the clean rule, but not using the default build tree layout)
617else
618	$(RM) -r $(wildcard $(BUILDDIR)/*)
619endif
620
621#----------------------------------------------------------------------
622# From http://blog.melski.net/tag/debugging-makefiles/
623#
624# Usage: make print-CC print-CXX print-LD
625#----------------------------------------------------------------------
626print-%:
627	@echo '$*=$($*)'
628	@echo '  origin = $(origin $*)'
629	@echo '  flavor = $(flavor $*)'
630	@echo '   value = $(value  $*)'
631
632### Local Variables: ###
633### mode:makefile ###
634### End: ###
635