blob: 899406c841603eaa1ba0c36b7339f78b15424315 [file] [log] [blame]
Jeffrey Yasskinc9017192010-02-25 06:34:33 +00001##===- tools/shlib/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 = ../..
11
12LIBRARYNAME = LLVM-$(LLVMVersion)
13
14NO_BUILD_ARCHIVE = 1
15LINK_LIBS_IN_SHARED = 1
16SHARED_LIBRARY = 1
17
18include $(LEVEL)/Makefile.common
19
20# Include all archives in libLLVM.(so|dylib) except the ones that have
21# their own dynamic libraries.
22Archives := $(wildcard $(LibDir)/libLLVM*.a)
23SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT))
24IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives))
25LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%)
26LLVMLibsPaths := $(IncludeInLibLlvm)
27
28$(LibName.SO): $(LLVMLibsPaths)
29
30ifeq ($(HOST_OS),Darwin)
31 # set dylib internal version number to llvmCore submission number
32 ifdef LLVM_SUBMIT_VERSION
33 LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \
34 -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \
35 -Wl,-compatibility_version -Wl,1
36 endif
37 # Include everything from the .a's into the shared library.
38 LLVMLibsOptions := $(LLVMLibsOptions) -all_load
39 # extra options to override libtool defaults
40 LLVMLibsOptions := $(LLVMLibsOptions) \
Jeffrey Yasskinc9017192010-02-25 06:34:33 +000041 -Wl,-dead_strip \
42 -Wl,-seg1addr -Wl,0xE0000000
43
44 # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
45 DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
46 ifneq ($(DARWIN_VERS),8)
47 LLVMLibsOptions := $(LLVMLibsOptions) \
48 -Wl,-install_name \
49 -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
50 endif
51endif
52
53ifeq ($(HOST_OS), Linux)
54 # Include everything from the .a's into the shared library.
55 LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \
56 -Wl,--no-whole-archive
57 # Don't allow unresolved symbols.
58 LLVMLibsOptions += -Wl,--no-undefined
59endif