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