| Jeffrey Yasskin | 6b718f7 | 2010-02-25 06:34:33 +0000 | [diff] [blame] | 1 | ##===- 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 |  | 
|  | 10 | LEVEL = ../.. | 
|  | 11 |  | 
|  | 12 | LIBRARYNAME = LLVM-$(LLVMVersion) | 
|  | 13 |  | 
|  | 14 | NO_BUILD_ARCHIVE = 1 | 
|  | 15 | LINK_LIBS_IN_SHARED = 1 | 
|  | 16 | SHARED_LIBRARY = 1 | 
|  | 17 |  | 
| Anton Korobeynikov | 51b8b1d | 2010-08-17 19:03:03 +0000 | [diff] [blame] | 18 | include $(LEVEL)/Makefile.config | 
|  | 19 |  | 
|  | 20 | ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) | 
|  | 21 | EXPORTED_SYMBOL_FILE = $(ObjDir)/$(LIBRARYNAME).exports | 
|  | 22 |  | 
|  | 23 | # It is needed to force static-stdc++.a linked. | 
|  | 24 | # FIXME: It should be omitted when configure detects system's stdc++.dll. | 
|  | 25 | SHLIB_FRAG_NAMES += stdc++.a.o | 
|  | 26 |  | 
|  | 27 | endif | 
|  | 28 |  | 
| Jeffrey Yasskin | 6b718f7 | 2010-02-25 06:34:33 +0000 | [diff] [blame] | 29 | include $(LEVEL)/Makefile.common | 
|  | 30 |  | 
|  | 31 | # Include all archives in libLLVM.(so|dylib) except the ones that have | 
|  | 32 | # their own dynamic libraries. | 
|  | 33 | Archives := $(wildcard $(LibDir)/libLLVM*.a) | 
|  | 34 | SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT)) | 
|  | 35 | IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives)) | 
|  | 36 | LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%) | 
|  | 37 | LLVMLibsPaths   := $(IncludeInLibLlvm) | 
|  | 38 |  | 
|  | 39 | $(LibName.SO): $(LLVMLibsPaths) | 
|  | 40 |  | 
|  | 41 | ifeq ($(HOST_OS),Darwin) | 
|  | 42 | # set dylib internal version number to llvmCore submission number | 
|  | 43 | ifdef LLVM_SUBMIT_VERSION | 
|  | 44 | LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \ | 
|  | 45 | -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \ | 
|  | 46 | -Wl,-compatibility_version -Wl,1 | 
|  | 47 | endif | 
|  | 48 | # Include everything from the .a's into the shared library. | 
|  | 49 | LLVMLibsOptions    := $(LLVMLibsOptions) -all_load | 
|  | 50 | # extra options to override libtool defaults | 
|  | 51 | LLVMLibsOptions    := $(LLVMLibsOptions)  \ | 
| Jeffrey Yasskin | 6b718f7 | 2010-02-25 06:34:33 +0000 | [diff] [blame] | 52 | -Wl,-dead_strip \ | 
|  | 53 | -Wl,-seg1addr -Wl,0xE0000000 | 
|  | 54 |  | 
|  | 55 | # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line | 
|  | 56 | DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/') | 
|  | 57 | ifneq ($(DARWIN_VERS),8) | 
|  | 58 | LLVMLibsOptions    := $(LLVMLibsOptions)  \ | 
|  | 59 | -Wl,-install_name \ | 
|  | 60 | -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)" | 
|  | 61 | endif | 
|  | 62 | endif | 
|  | 63 |  | 
| NAKAMURA Takumi | a1d4430 | 2010-10-28 06:45:57 +0000 | [diff] [blame] | 64 | ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux FreeBSD OpenBSD)) | 
| Jeffrey Yasskin | 6b718f7 | 2010-02-25 06:34:33 +0000 | [diff] [blame] | 65 | # Include everything from the .a's into the shared library. | 
|  | 66 | LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \ | 
|  | 67 | -Wl,--no-whole-archive | 
| NAKAMURA Takumi | a1d4430 | 2010-10-28 06:45:57 +0000 | [diff] [blame] | 68 | endif | 
|  | 69 |  | 
|  | 70 | ifeq ($(HOST_OS),Linux) | 
| Jeffrey Yasskin | 6b718f7 | 2010-02-25 06:34:33 +0000 | [diff] [blame] | 71 | # Don't allow unresolved symbols. | 
|  | 72 | LLVMLibsOptions += -Wl,--no-undefined | 
|  | 73 | endif | 
| Anton Korobeynikov | 51b8b1d | 2010-08-17 19:03:03 +0000 | [diff] [blame] | 74 |  | 
|  | 75 | ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) | 
|  | 76 |  | 
|  | 77 | SHLIB_STUBS := $(addprefix $(ObjDir)/, $(SHLIB_FRAG_NAMES)) | 
|  | 78 | SHLIB_FRAGS := $(patsubst %.a.o, $(ObjDir)/%.syms.txt, $(LIBRARYNAME).a.o $(SHLIB_FRAG_NAMES)) | 
|  | 79 | LLVMLibsOptions := $(SHLIB_STUBS) $(LLVMLibsOptions) | 
|  | 80 |  | 
|  | 81 | $(LibName.SO): $(SHLIB_STUBS) | 
|  | 82 |  | 
|  | 83 | %.syms.txt: %.a.o | 
|  | 84 | $(Echo) Collecting global symbols of $(notdir $*) | 
|  | 85 | $(Verb) $(NM_PATH) -g $< > $@ | 
|  | 86 |  | 
|  | 87 | $(ObjDir)/$(LIBRARYNAME).exports: $(SHLIB_FRAGS) $(ObjDir)/.dir | 
|  | 88 | $(Echo) Generating exports for $(LIBRARYNAME) | 
|  | 89 | $(Verb) ($(SED) -n \ | 
|  | 90 | -e "s/^.* T _\([^.][^.]*\)$$/\1/p" \ | 
|  | 91 | -e "s/^.* [BDR] _\([^.][^.]*\)$$/\1 DATA/p" \ | 
|  | 92 | $(SHLIB_FRAGS) \ | 
|  | 93 | | sort -u) > $@ | 
|  | 94 |  | 
|  | 95 | $(ObjDir)/$(LIBRARYNAME).a.o: $(LLVMLibsPaths) $(ObjDir)/.dir | 
|  | 96 | $(Echo) Linking all LLVMLibs together for $(LIBRARYNAME) | 
|  | 97 | $(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \ | 
|  | 98 | -Wl,--whole-archive $(LLVMLibsPaths) \ | 
|  | 99 | -Wl,--no-whole-archive | 
|  | 100 |  | 
|  | 101 | $(ObjDir)/stdc++.a.o: $(ObjDir)/.dir | 
|  | 102 | $(Echo) Linking all libs together for static libstdc++.a | 
|  | 103 | $(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \ | 
|  | 104 | -Wl,--whole-archive -lstdc++ \ | 
|  | 105 | -Wl,--no-whole-archive | 
|  | 106 | # FIXME: workaround to invalidate -lstdc++ | 
|  | 107 | $(Echo) Making dummy -lstdc++ to lib | 
|  | 108 | $(Verb) $(AR) rc $(ToolDir)/libstdc++.dll.a | 
|  | 109 | # FIXME: Is install-local needed? | 
|  | 110 |  | 
|  | 111 | clean-local:: | 
|  | 112 | $(Verb) $(RM) -f $(ToolDir)/libstdc++.dll.a | 
|  | 113 |  | 
|  | 114 | endif |