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