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-$(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)$(LLVM_VERSION_SUFFIX) 13 LIBRARYALIASNAME = LLVM-$(LLVMVersion) 14 15 NO_BUILD_ARCHIVE := 1 16 LINK_LIBS_IN_SHARED := 1 17 SHARED_LIBRARY := 1 18 SHARED_ALIAS := 1 19 20 include $(LEVEL)/Makefile.config 21 22 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) 23 EXPORTED_SYMBOL_FILE = $(ObjDir)/$(LIBRARYNAME).exports 24 25 ifeq (1,$(ENABLE_EMBED_STDCXX)) 26 # It is needed to force static-stdc++.a linked. 27 SHLIB_FRAG_NAMES += stdc++.a.o 28 endif 29 30 endif 31 32 include $(LEVEL)/Makefile.common 33 34 # Include all archives in libLLVM.(so|dylib) except the ones that have 35 # their own dynamic libraries and TableGen. 36 Archives := $(wildcard $(LibDir)/libLLVM*.a) 37 SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT)) 38 ExcludeFromLibLlvm := $(basename $(SharedLibraries)).a %/libLLVMTableGen.a 39 IncludeInLibLlvm := $(filter-out $(ExcludeFromLibLlvm), $(Archives)) 40 LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%) 41 LLVMLibsPaths := $(IncludeInLibLlvm) 42 43 $(LibName.SO): $(LLVMLibsPaths) 44 45 ifeq ($(HOST_OS),Darwin) 46 # set dylib internal version number to llvmCore submission number 47 ifdef LLVM_SUBMIT_VERSION 48 LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \ 49 -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \ 50 -Wl,-compatibility_version -Wl,1 51 endif 52 # Include everything from the .a's into the shared library. 53 LLVMLibsOptions := $(LLVMLibsOptions) -all_load 54 endif 55 56 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux FreeBSD GNU/kFreeBSD OpenBSD GNU Bitrig)) 57 # Include everything from the .a's into the shared library. 58 LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \ 59 -Wl,--no-whole-archive 60 endif 61 62 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux FreeBSD GNU/kFreeBSD GNU)) 63 # Add soname to the library. 64 LLVMLibsOptions += -Wl,--soname,lib$(LIBRARYNAME)$(SHLIBEXT) 65 endif 66 67 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux GNU GNU/kFreeBSD)) 68 # Don't allow unresolved symbols. 69 LLVMLibsOptions += -Wl,--no-undefined 70 endif 71 72 ifeq ($(HOST_OS),SunOS) 73 # add -z allextract ahead of other libraries on Solaris 74 LLVMLibsOptions := -Wl,-z -Wl,allextract $(LLVMLibsOptions) 75 endif 76 77 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) 78 79 SHLIB_STUBS := $(addprefix $(ObjDir)/, $(SHLIB_FRAG_NAMES)) 80 SHLIB_FRAGS := $(patsubst %.a.o, $(ObjDir)/%.syms.txt, $(LIBRARYNAME).a.o $(SHLIB_FRAG_NAMES)) 81 LLVMLibsOptions := $(SHLIB_STUBS) $(LLVMLibsOptions) 82 83 $(LibName.SO): $(SHLIB_STUBS) 84 85 %.syms.txt: %.a.o 86 $(Echo) Collecting global symbols of $(notdir $*) 87 $(Verb) $(NM_PATH) -g $< > $@ 88 89 $(ObjDir)/$(LIBRARYNAME).exports: $(SHLIB_FRAGS) $(ObjDir)/.dir 90 $(Echo) Generating exports for $(LIBRARYNAME) 91 $(Verb) ($(SED) -n \ 92 -e "s/^.* T _\([^.][^.]*\)$$/\1/p" \ 93 -e "s/^.* [BDR] _\([^.][^.]*\)$$/\1 DATA/p" \ 94 $(SHLIB_FRAGS) \ 95 | sort -u) > $@ 96 97 $(ObjDir)/$(LIBRARYNAME).a.o: $(LLVMLibsPaths) $(ObjDir)/.dir 98 $(Echo) Linking all LLVMLibs together for $(LIBRARYNAME) 99 $(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \ 100 -Wl,--whole-archive $(LLVMLibsPaths) \ 101 -Wl,--no-whole-archive 102 103 $(ObjDir)/stdc++.a.o: $(ObjDir)/.dir 104 $(Echo) Linking all libs together for static libstdc++.a 105 $(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \ 106 -Wl,--whole-archive -lstdc++ \ 107 -Wl,--no-whole-archive 108 # FIXME: workaround to invalidate -lstdc++ 109 $(Echo) Making dummy -lstdc++ to lib 110 $(Verb) $(AR) rc $(ToolDir)/libstdc++.dll.a 111 # FIXME: Is install-local needed? 112 113 clean-local:: 114 $(Verb) $(RM) -f $(ToolDir)/libstdc++.dll.a 115 116 endif 117