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
168	ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
169		DSYM = $(EXE).debug
170	endif
171endif
172
173LIMIT_DEBUG_INFO_FLAGS =
174ifneq (,$(findstring clang,$(CC)))
175   LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info
176endif
177
178CFLAGS ?= -g -O0 -fno-builtin
179ifeq "$(OS)" "Darwin"
180	CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include
181else
182	CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include
183endif
184
185CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS)
186
187# Use this one if you want to build one part of the result without debug information:
188ifeq "$(OS)" "Darwin"
189	CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
190else
191	CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
192endif
193
194ifeq "$(MAKE_DWO)" "YES"
195	CFLAGS += -gsplit-dwarf
196endif
197
198CXXFLAGS += -std=c++11
199CXXFLAGS += $(CFLAGS)
200LD = $(CC)
201LDFLAGS ?= $(CFLAGS)
202LDFLAGS += $(LD_EXTRAS)
203ifeq (,$(filter $(OS), Windows_NT Android))
204	ifneq (,$(filter YES,$(ENABLE_THREADS) $(ENABLE_STD_THREADS)))
205		LDFLAGS += -pthread
206	endif
207endif
208OBJECTS =
209EXE ?= a.out
210
211ifneq "$(DYLIB_NAME)" ""
212	ifeq "$(OS)" "Darwin"
213		DYLIB_FILENAME = lib$(DYLIB_NAME).dylib
214		DYLIB_EXECUTABLE_PATH ?= @executable_path
215	else ifeq "$(OS)" "Windows_NT"
216		DYLIB_FILENAME = $(DYLIB_NAME).dll
217	else
218		DYLIB_FILENAME = lib$(DYLIB_NAME).so
219	endif
220endif
221
222# Function that returns the counterpart C++ compiler, given $(CC) as arg.
223cxx_compiler_notdir = $(if $(findstring clang,$(1)), \
224                           $(subst clang,clang++,$(1)), \
225                           $(if $(findstring icc,$(1)), \
226                                $(subst icc,icpc,$(1)), \
227                                $(if $(findstring llvm-gcc,$(1)), \
228                                     $(subst llvm-gcc,llvm-g++,$(1)), \
229                                     $(if $(findstring gcc,$(1)), \
230                                          $(subst gcc,g++,$(1)), \
231                                          $(subst cc,c++,$(1))))))
232cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1)))
233
234# Function that returns the C++ linker, given $(CC) as arg.
235cxx_linker_notdir = $(if $(findstring clang,$(1)), \
236                         $(subst clang,clang++,$(1)), \
237                         $(if $(findstring icc,$(1)), \
238                              $(subst icc,icpc,$(1)), \
239                              $(if $(findstring llvm-gcc,$(1)), \
240                                   $(subst llvm-gcc,llvm-g++,$(1)), \
241                                   $(if $(findstring gcc,$(1)), \
242                                        $(subst gcc,g++,$(1)), \
243                                        $(subst cc,c++,$(1))))))
244cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1)))
245
246OBJCOPY := $(CROSS_COMPILE)objcopy
247
248#----------------------------------------------------------------------
249# Windows specific options
250#----------------------------------------------------------------------
251ifeq "$(OS)" "Windows_NT"
252	ifneq (,$(findstring clang,$(CC)))
253		# Clang for Windows doesn't support C++ Exceptions
254		CXXFLAGS += -fno-exceptions
255		CXXFLAGS += -D_HAS_EXCEPTIONS=0
256		ifeq "$(VisualStudioVersion)" "14.0"
257			CXXFLAGS += -fms-compatibility-version=19.0
258		endif
259		# The MSVC linker doesn't understand long section names
260		# generated by the clang compiler.
261		LDFLAGS += -fuse-ld=lld
262	endif
263endif
264
265#----------------------------------------------------------------------
266# Android specific options
267#----------------------------------------------------------------------
268ifeq "$(OS)" "Android"
269    ifdef PIE
270        LDFLAGS += -pie
271    endif
272    replace_with = $(if $(findstring clang,$(1)), \
273                        $(subst clang,$(2),$(1)), \
274                        $(if $(findstring gcc,$(1)), \
275                             $(subst gcc,$(2),$(1)), \
276                             $(subst cc,$(2),$(1))))
277    ifeq "$(notdir $(CC))" "$(CC)"
278        replace_cc_with = $(call replace_with,$(CC),$(1))
279    else
280        replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(notdir $(CC)),$(1)))
281    endif
282    OBJCOPY = $(call replace_cc_with,objcopy)
283    AR = $(call replace_cc_with,ar)
284endif
285
286#----------------------------------------------------------------------
287# C++ standard library options
288#----------------------------------------------------------------------
289ifeq (1,$(USE_LIBSTDCPP))
290	# Clang requires an extra flag: -stdlib=libstdc++
291	ifneq (,$(findstring clang,$(CC)))
292		CXXFLAGS += -stdlib=libstdc++
293		LDFLAGS += -stdlib=libstdc++
294	endif
295endif
296
297ifeq (1,$(USE_LIBCPP))
298	# Clang requires an extra flag: -stdlib=libstdc++
299	ifneq (,$(findstring clang,$(CC)))
300		ifeq "$(OS)" "Linux"
301			# This is the default install location on Ubuntu 14.04
302			ifneq ($(wildcard /usr/include/c++/v1/.),)
303				CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
304				LDFLAGS += -stdlib=libc++
305				CXXFLAGS += -I/usr/include/c++/v1
306			endif
307		else
308			CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
309			LDFLAGS += -stdlib=libc++
310		endif
311	endif
312endif
313
314#----------------------------------------------------------------------
315# dylib settings
316#----------------------------------------------------------------------
317ifneq "$(strip $(DYLIB_C_SOURCES))" ""
318	DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o))
319endif
320
321ifneq "$(strip $(DYLIB_OBJC_SOURCES))" ""
322	DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o))
323endif
324
325ifneq "$(strip $(DYLIB_CXX_SOURCES))" ""
326    DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o))
327    CXX = $(call cxx_compiler,$(CC))
328    LD = $(call cxx_linker,$(CC))
329endif
330
331#----------------------------------------------------------------------
332# Check if we have any C source files
333#----------------------------------------------------------------------
334ifneq "$(strip $(C_SOURCES))" ""
335	OBJECTS +=$(strip $(C_SOURCES:.c=.o))
336endif
337
338#----------------------------------------------------------------------
339# Check if we have any C++ source files
340#----------------------------------------------------------------------
341ifneq "$(strip $(CXX_SOURCES))" ""
342	OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
343	CXX = $(call cxx_compiler,$(CC))
344	LD = $(call cxx_linker,$(CC))
345endif
346
347#----------------------------------------------------------------------
348# Check if we have any ObjC source files
349#----------------------------------------------------------------------
350ifneq "$(strip $(OBJC_SOURCES))" ""
351	OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
352	LDFLAGS +=-lobjc
353endif
354
355#----------------------------------------------------------------------
356# Check if we have any ObjC++ source files
357#----------------------------------------------------------------------
358ifneq "$(strip $(OBJCXX_SOURCES))" ""
359	OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
360	CXX = $(call cxx_compiler,$(CC))
361	LD = $(call cxx_linker,$(CC))
362	ifeq "$(findstring lobjc,$(LDFLAGS))" ""
363		LDFLAGS +=-lobjc
364	endif
365endif
366
367#----------------------------------------------------------------------
368# Check if we have any C source files for archive
369#----------------------------------------------------------------------
370ifneq "$(strip $(ARCHIVE_C_SOURCES))" ""
371	ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o))
372endif
373
374#----------------------------------------------------------------------
375# Check if we have any C++ source files for archive
376#----------------------------------------------------------------------
377ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" ""
378	ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o))
379	CXX = $(call cxx_compiler,$(CC))
380	LD = $(call cxx_linker,$(CC))
381endif
382
383#----------------------------------------------------------------------
384# Check if we have any ObjC source files for archive
385#----------------------------------------------------------------------
386ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" ""
387	ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o))
388	LDFLAGS +=-lobjc
389endif
390
391#----------------------------------------------------------------------
392# Check if we have any ObjC++ source files for archive
393#----------------------------------------------------------------------
394ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" ""
395	ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o))
396	CXX = $(call cxx_compiler,$(CC))
397	LD = $(call cxx_linker,$(CC))
398	ifeq "$(findstring lobjc,$(LDFLAGS))" ""
399		LDFLAGS +=-lobjc
400	endif
401endif
402
403#----------------------------------------------------------------------
404# Check if we are compiling with gcc 4.6
405#----------------------------------------------------------------------
406ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" ""
407ifneq "$(filter g++,$(CXX))" ""
408	CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3)
409	ifeq "$(CXXVERSION)" "4.6"
410                # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x
411                # instead. FIXME: remove once GCC version is upgraded.
412		override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS))
413	endif
414endif
415endif
416
417#----------------------------------------------------------------------
418# DYLIB_ONLY variable can be used to skip the building of a.out.
419# See the sections below regarding dSYM file as well as the building of
420# EXE from all the objects.
421#----------------------------------------------------------------------
422
423#----------------------------------------------------------------------
424# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO"
425#----------------------------------------------------------------------
426ifneq "$(DYLIB_ONLY)" "YES"
427$(DSYM) : $(EXE)
428ifeq "$(OS)" "Darwin"
429ifneq "$(MAKE_DSYM)" "NO"
430	"$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
431endif
432else
433ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
434	$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
435	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
436endif
437endif
438endif
439
440#----------------------------------------------------------------------
441# Compile the executable from all the objects.
442#----------------------------------------------------------------------
443ifneq "$(DYLIB_NAME)" ""
444ifeq "$(DYLIB_ONLY)" ""
445$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME)
446	$(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"
447else
448EXE = $(DYLIB_FILENAME)
449endif
450else
451$(EXE) : $(OBJECTS) $(ARCHIVE_NAME)
452	$(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)"
453endif
454
455#----------------------------------------------------------------------
456# Make the archive
457#----------------------------------------------------------------------
458ifneq "$(ARCHIVE_NAME)" ""
459ifeq "$(OS)" "Darwin"
460$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS)
461	$(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
462	$(RM) $(ARCHIVE_OBJECTS)
463else
464$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj)))
465endif
466endif
467
468#----------------------------------------------------------------------
469# Make the dylib
470#----------------------------------------------------------------------
471$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL
472
473$(DYLIB_FILENAME) : $(DYLIB_OBJECTS)
474ifeq "$(OS)" "Darwin"
475	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_EXECUTABLE_PATH)/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)"
476ifneq "$(MAKE_DSYM)" "NO"
477ifneq "$(DS)" ""
478	"$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)"
479endif
480endif
481else
482	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
483ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
484	$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
485	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
486endif
487endif
488
489#----------------------------------------------------------------------
490# Automatic variables based on items already entered. Below we create
491# an object's lists from the list of sources by replacing all entries
492# that end with .c with .o, and we also create a list of prerequisite
493# files by replacing all .c files with .d.
494#----------------------------------------------------------------------
495PREREQS := $(OBJECTS:.o=.d)
496DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo)
497ifneq "$(DYLIB_NAME)" ""
498	DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d)
499	DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo)
500endif
501
502#----------------------------------------------------------------------
503# Rule for Generating Prerequisites Automatically using .d files and
504# the compiler -MM option. The -M option will list all system headers,
505# and the -MM option will list all non-system dependencies.
506#----------------------------------------------------------------------
507ifeq "$(HOST_OS)" "Windows_NT"
508	JOIN_CMD = &
509	QUOTE = "
510else
511	JOIN_CMD = ;
512	QUOTE = '
513endif
514
515%.d: %.c
516	@rm -f $@ $(JOIN_CMD) \
517	$(CC) -M $(CFLAGS) $< > [email protected] && \
518	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \
519	rm -f [email protected]
520
521%.d: %.cpp
522	@rm -f $@ $(JOIN_CMD) \
523	$(CXX) -M $(CXXFLAGS) $< > [email protected] && \
524	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \
525	rm -f [email protected]
526
527%.d: %.m
528	@rm -f $@ $(JOIN_CMD) \
529	$(CC) -M $(CFLAGS) $< > [email protected] && \
530	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \
531	rm -f [email protected]
532
533%.d: %.mm
534	@rm -f $@ $(JOIN_CMD) \
535	$(CXX) -M $(CXXFLAGS) $< > [email protected] && \
536	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < [email protected] > $@ $(JOIN_CMD) \
537	rm -f [email protected]
538
539#----------------------------------------------------------------------
540# Include all of the makefiles for each source file so we don't have
541# to manually track all of the prerequisites for each source file.
542#----------------------------------------------------------------------
543sinclude $(PREREQS)
544ifneq "$(DYLIB_NAME)" ""
545	sinclude $(DYLIB_PREREQS)
546endif
547
548# Define a suffix rule for .mm -> .o
549.SUFFIXES: .mm .o
550.mm.o:
551	$(CXX) $(CXXFLAGS) -c $<
552
553.PHONY: clean
554dsym:	$(DSYM)
555all:	$(EXE) $(DSYM)
556clean::
557	$(RM) $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
558ifneq "$(DYLIB_NAME)" ""
559	$(RM) -r $(DYLIB_FILENAME).dSYM
560	$(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug
561endif
562ifneq "$(DSYM)" ""
563	$(RM) -r "$(DSYM)"
564endif
565ifeq "$(OS)" "Windows_NT"
566# http://llvm.org/pr24589
567	IF EXIST "$(EXE)" del "$(EXE)"
568	$(RM) $(wildcard *.manifest *.pdb *.ilk)
569ifneq "$(DYLIB_NAME)" ""
570	$(RM) $(DYLIB_NAME).lib $(DYLIB_NAME).exp
571endif
572else
573	$(RM) "$(EXE)"
574endif
575
576#----------------------------------------------------------------------
577# From http://blog.melski.net/tag/debugging-makefiles/
578#
579# Usage: make print-CC print-CXX print-LD
580#----------------------------------------------------------------------
581print-%:
582	@echo '$*=$($*)'
583	@echo '  origin = $(origin $*)'
584	@echo '  flavor = $(flavor $*)'
585	@echo '   value = $(value  $*)'
586
587### Local Variables: ###
588### mode:makefile ###
589### End: ###
590