| Jeffrey Yasskin | 9b39a93 | 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 | 88481b5 | 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 | 9b39a93 | 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 | 9b39a93 | 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 |  | 
 | 64 | ifeq ($(HOST_OS), Linux) | 
 | 65 |     # Include everything from the .a's into the shared library. | 
 | 66 |     LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \ | 
 | 67 |                        -Wl,--no-whole-archive | 
 | 68 |     # Don't allow unresolved symbols. | 
 | 69 |     LLVMLibsOptions += -Wl,--no-undefined | 
 | 70 | endif | 
| Anton Korobeynikov | 88481b5 | 2010-08-17 19:03:03 +0000 | [diff] [blame] | 71 |  | 
 | 72 | ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW)) | 
 | 73 |  | 
 | 74 | SHLIB_STUBS := $(addprefix $(ObjDir)/, $(SHLIB_FRAG_NAMES)) | 
 | 75 | SHLIB_FRAGS := $(patsubst %.a.o, $(ObjDir)/%.syms.txt, $(LIBRARYNAME).a.o $(SHLIB_FRAG_NAMES)) | 
 | 76 | LLVMLibsOptions := $(SHLIB_STUBS) $(LLVMLibsOptions) | 
 | 77 |  | 
 | 78 | $(LibName.SO): $(SHLIB_STUBS) | 
 | 79 |  | 
 | 80 | %.syms.txt: %.a.o | 
 | 81 | 	$(Echo) Collecting global symbols of $(notdir $*) | 
 | 82 | 	$(Verb) $(NM_PATH) -g $< > $@ | 
 | 83 |  | 
 | 84 | $(ObjDir)/$(LIBRARYNAME).exports: $(SHLIB_FRAGS) $(ObjDir)/.dir | 
 | 85 | 	$(Echo) Generating exports for $(LIBRARYNAME) | 
 | 86 | 	$(Verb) ($(SED) -n \ | 
 | 87 | 			-e "s/^.* T _\([^.][^.]*\)$$/\1/p" \ | 
 | 88 | 			-e "s/^.* [BDR] _\([^.][^.]*\)$$/\1 DATA/p" \ | 
 | 89 | 			$(SHLIB_FRAGS) \ | 
 | 90 | 		 | sort -u) > $@ | 
 | 91 |  | 
 | 92 | $(ObjDir)/$(LIBRARYNAME).a.o: $(LLVMLibsPaths) $(ObjDir)/.dir | 
 | 93 | 	$(Echo) Linking all LLVMLibs together for $(LIBRARYNAME) | 
 | 94 | 	$(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \ | 
 | 95 | 			-Wl,--whole-archive $(LLVMLibsPaths) \ | 
 | 96 | 			-Wl,--no-whole-archive | 
 | 97 |  | 
 | 98 | $(ObjDir)/stdc++.a.o: $(ObjDir)/.dir | 
 | 99 | 	$(Echo) Linking all libs together for static libstdc++.a | 
 | 100 | 	$(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \ | 
 | 101 | 			-Wl,--whole-archive -lstdc++ \ | 
 | 102 | 			-Wl,--no-whole-archive | 
 | 103 | # FIXME: workaround to invalidate -lstdc++ | 
 | 104 | 	$(Echo) Making dummy -lstdc++ to lib | 
 | 105 | 	$(Verb) $(AR) rc $(ToolDir)/libstdc++.dll.a | 
 | 106 | # FIXME: Is install-local needed? | 
 | 107 |  | 
 | 108 | clean-local:: | 
 | 109 | 	$(Verb) $(RM) -f $(ToolDir)/libstdc++.dll.a | 
 | 110 |  | 
 | 111 | endif |