1##===- source/Makefile -------------------------------------*- Makefile -*-===##
2# 
3#                     The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7# 
8##===----------------------------------------------------------------------===##
9
10LEVEL := ../../..
11LLDB_LEVEL := ..
12
13LIBRARYNAME = lldb
14
15#EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/resources/lldb-framework-exports
16NO_BUILD_ARCHIVE = 1
17LINK_LIBS_IN_SHARED = 1
18SHARED_LIBRARY = 1
19
20PYTHON_BUILD_FLAGS = $(shell python-config --ldflags)
21
22# Include all archives in liblldb.so file
23USEDLIBS = lldbAPI.a \
24	lldbBreakpoint.a \
25	lldbCommands.a \
26	lldbCore.a \
27	lldbDataFormatters.a \
28	lldbExpression.a \
29	lldbHostCommon.a \
30	lldbInitAndLog.a \
31	lldbInterpreter.a \
32	lldbPluginABIMacOSX_arm.a \
33	lldbPluginABIMacOSX_i386.a \
34	lldbPluginABISysV_x86_64.a \
35	lldbPluginDisassemblerLLVM.a \
36	lldbPluginDynamicLoaderStatic.a \
37	lldbPluginDynamicLoaderPOSIX.a \
38	lldbPluginEmulateInstructionARM.a \
39	lldbPluginLanguageRuntimeCPlusPlusItaniumABI.a \
40	lldbPluginLanguageRuntimeObjCAppleObjCRuntime.a \
41	lldbPluginObjectContainerBSDArchive.a \
42	lldbPluginObjectFileELF.a \
43	lldbPluginSymbolVendorELF.a \
44	lldbPluginObjectFilePECOFF.a \
45	lldbPluginOperatingSystemPython.a \
46	lldbPluginPlatformGDBServer.a \
47	lldbPluginProcessGDBRemote.a \
48	lldbPluginSymbolFileDWARF.a \
49	lldbPluginSymbolFileSymtab.a \
50	lldbPluginUnwindAssemblyInstEmulation.a \
51	lldbPluginUnwindAssemblyx86.a \
52	lldbPluginUtility.a \
53	lldbSymbol.a \
54	lldbTarget.a \
55	lldbUtility.a \
56	clangAnalysis.a \
57	clangAST.a \
58	clangBasic.a \
59	clangCodeGen.a \
60	clangFrontend.a \
61	clangDriver.a \
62	clangEdit.a \
63	clangLex.a \
64	clangParse.a \
65	clangSema.a \
66	clangSerialization.a \
67	LLVMMCDisassembler.a \
68	lldbPluginPlatformMacOSX.a \
69	lldbPluginPlatformLinux.a \
70	lldbPluginPlatformFreeBSD.a
71
72# Because GCC requires RTTI enabled for lldbCore (see source/Core/Makefile) it is
73# necessary to also link the clang rewriter libraries so vtable references can
74# be resolved correctly, if we are building with GCC.
75ifeq (g++,$(shell basename $(CXX) | colrm 4))
76  USEDLIBS += clangRewriteCore.a \
77              clangRewriteFrontend.a
78endif
79
80include $(LLDB_LEVEL)/../../Makefile.config
81
82LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader bitwriter codegen \
83                   instrumentation ipo irreader selectiondag jit mc mcjit \
84                   linker option
85
86ifeq ($(HOST_OS),Darwin)
87  USEDLIBS += lldbHostMacOSX.a \
88              lldbPluginDynamicLoaderMacOSX.a \
89              lldbPluginDynamicLoaderDarwinKernel.a \
90              lldbPluginObjectContainerUniversalMachO.a \
91              lldbPluginObjectFileMachO.a \
92              lldbPluginSymbolVendorMacOSX.a \
93              lldbPluginProcessDarwin.a \
94              lldbPluginProcessMachCore.a
95endif
96
97ifeq ($(HOST_OS),Linux)
98  USEDLIBS += lldbHostLinux.a \
99              lldbPluginProcessLinux.a \
100              lldbPluginProcessPOSIX.a \
101              lldbPluginDynamicLoaderMacOSX.a \
102              lldbPluginProcessElfCore.a
103endif
104
105ifneq (,$(filter $(HOST_OS), FreeBSD GNU/kFreeBSD))
106  USEDLIBS += lldbHostFreeBSD.a \
107              lldbPluginProcessPOSIX.a \
108              lldbPluginProcessFreeBSD.a \
109              lldbPluginProcessElfCore.a
110endif
111
112include $(LEVEL)/Makefile.common
113
114ifeq ($(HOST_OS),Darwin)
115    LLVMLibsOptions += -Wl,-all_load
116    # set dylib internal version number to llvmCore submission number
117    ifdef LLDB_SUBMIT_VERSION
118        LLVMLibsOptions += -Wl,-current_version \
119                           -Wl,$(LLDB_SUBMIT_VERSION).$(LLDB_SUBMIT_SUBVERSION) \
120                           -Wl,-compatibility_version -Wl,1
121    endif
122    # extra options to override libtool defaults 
123	LLVMLibsOptions += -F/System/Library/Frameworks -F/System/Library/PrivateFrameworks
124	LLVMLibsOptions += -framework Foundation -framework CoreFoundation
125	LLVMLibsOptions += -framework CoreServices -framework Carbon -framework Security
126	LLVMLibsOptions += -framework DebugSymbols $(PYTHON_BUILD_FLAGS) -lobjc
127	LLVMLibsOptions += -lxml2
128	ifneq ($(EXPORTED_SYMBOL_FILE),)
129		LLVMLibsOptions += -Wl,-exported_symbols_list -Wl,"$(EXPORTED_SYMBOL_FILE)"
130	endif
131    # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
132    DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
133    ifneq ($(DARWIN_VERS),8)
134       LLVMLibsOptions  += -Wl,-install_name \
135                           -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
136    endif
137endif
138
139ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux GNU GNU/kFreeBSD))
140    # Include everything from the .a's into the shared library.
141    ProjLibsOptions := -Wl,--whole-archive $(ProjLibsOptions) \
142                       -Wl,--no-whole-archive
143    # Don't allow unresolved symbols.
144    LLVMLibsOptions += -Wl,--no-undefined
145    # Link in python
146    LLVMLibsOptions += $(PYTHON_BUILD_FLAGS) -lrt
147    LLVMLibsOptions += -Wl,--soname,lib$(LIBRARYNAME)$(SHLIBEXT)
148endif
149
150ifeq ($(HOST_OS),FreeBSD)
151    # Include everything from the .a's into the shared library.
152    ProjLibsOptions := -Wl,--whole-archive $(ProjLibsOptions) \
153                       -Wl,--no-whole-archive
154    # Allow unresolved symbols.
155    LLVMLibsOptions += -Wl,--allow-shlib-undefined
156    # Link in python
157    LLVMLibsOptions += $(PYTHON_BUILD_FLAGS) -lrt -L/usr/local/lib -lexecinfo
158endif
159