Make BasicAliasAnalysis recognize the fact a noalias argument cannot alias another...
[oota-llvm.git] / tools / llvm-shlib / Makefile
index fd8a107c4733935e2f26d71a2b5683dbf348195a..6d6c6e9f14be50aca9b9bfc097921ed04f760d21 100644 (file)
@@ -7,20 +7,34 @@
 # 
 ##===----------------------------------------------------------------------===##
 
-LEVEL = ../..
+LEVEL := ../..
+
 LIBRARYNAME = LLVM-$(LLVMVersion)
 
-NO_BUILD_ARCHIVE = 1
-LINK_LIBS_IN_SHARED = 1
-SHARED_LIBRARY = 1
+NO_BUILD_ARCHIVE := 1
+LINK_LIBS_IN_SHARED := 1
+SHARED_LIBRARY := 1
+
+include $(LEVEL)/Makefile.config
+
+ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+  EXPORTED_SYMBOL_FILE = $(ObjDir)/$(LIBRARYNAME).exports
+
+  ifeq (1,$(ENABLE_EMBED_STDCXX))
+    # It is needed to force static-stdc++.a linked.
+    SHLIB_FRAG_NAMES += stdc++.a.o
+  endif
+
+endif
 
 include $(LEVEL)/Makefile.common
 
 # Include all archives in libLLVM.(so|dylib) except the ones that have
-# their own dynamic libraries.
+# their own dynamic libraries and TableGen.
 Archives := $(wildcard $(LibDir)/libLLVM*.a)
 SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT))
-IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives))
+ExcludeFromLibLlvm := $(basename $(SharedLibraries)).a %/libLLVMTableGen.a
+IncludeInLibLlvm := $(filter-out $(ExcludeFromLibLlvm), $(Archives))
 LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%)
 LLVMLibsPaths   := $(IncludeInLibLlvm)
 
@@ -37,7 +51,6 @@ ifeq ($(HOST_OS),Darwin)
     LLVMLibsOptions    := $(LLVMLibsOptions) -all_load
     # extra options to override libtool defaults 
     LLVMLibsOptions    := $(LLVMLibsOptions)  \
-                         -avoid-version \
                          -Wl,-dead_strip \
                          -Wl,-seg1addr -Wl,0xE0000000 
 
@@ -50,18 +63,64 @@ ifeq ($(HOST_OS),Darwin)
     endif
 endif
 
-ifeq ($(HOST_OS), Linux)
+ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux FreeBSD OpenBSD GNU Bitrig))
     # Include everything from the .a's into the shared library.
     LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \
                        -Wl,--no-whole-archive
-    # Warn if we'll need to modify the text segment when loading libLLVM.so.
-    LLVMLibsOptions += -Wl,--warn-shared-textrel
+endif
+
+ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux FreeBSD GNU))
+    # Add soname to the library.
+    LLVMLibsOptions += -Wl,--soname,lib$(LIBRARYNAME)$(SHLIBEXT)
+endif
+
+ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux GNU))
     # Don't allow unresolved symbols.
     LLVMLibsOptions += -Wl,--no-undefined
-    ifneq ($(ARCH), ARM)
-        # ARM's shared libgcc omits several of the __sync functions that are
-        # present in the static libgcc, so we also link in the static gcc.  This
-        # is described at http://gcc.gnu.org/PR40133.
-        LLVMLibsOptions += -lgcc
-    endif
+endif
+
+ifeq ($(HOST_OS),SunOS)
+    # add -z allextract ahead of other libraries on Solaris
+    LLVMLibsOptions := -Wl,-z -Wl,allextract $(LLVMLibsOptions)
+endif
+
+ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+
+SHLIB_STUBS := $(addprefix $(ObjDir)/, $(SHLIB_FRAG_NAMES))
+SHLIB_FRAGS := $(patsubst %.a.o, $(ObjDir)/%.syms.txt, $(LIBRARYNAME).a.o $(SHLIB_FRAG_NAMES))
+LLVMLibsOptions := $(SHLIB_STUBS) $(LLVMLibsOptions)
+
+$(LibName.SO): $(SHLIB_STUBS)
+
+%.syms.txt: %.a.o
+       $(Echo) Collecting global symbols of $(notdir $*)
+       $(Verb) $(NM_PATH) -g $< > $@
+
+$(ObjDir)/$(LIBRARYNAME).exports: $(SHLIB_FRAGS) $(ObjDir)/.dir
+       $(Echo) Generating exports for $(LIBRARYNAME)
+       $(Verb) ($(SED) -n \
+                       -e "s/^.* T _\([^.][^.]*\)$$/\1/p" \
+                       -e "s/^.* [BDR] _\([^.][^.]*\)$$/\1 DATA/p" \
+                       $(SHLIB_FRAGS) \
+                | sort -u) > $@
+
+$(ObjDir)/$(LIBRARYNAME).a.o: $(LLVMLibsPaths) $(ObjDir)/.dir
+       $(Echo) Linking all LLVMLibs together for $(LIBRARYNAME)
+       $(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \
+                       -Wl,--whole-archive $(LLVMLibsPaths) \
+                       -Wl,--no-whole-archive
+
+$(ObjDir)/stdc++.a.o: $(ObjDir)/.dir
+       $(Echo) Linking all libs together for static libstdc++.a
+       $(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \
+                       -Wl,--whole-archive -lstdc++ \
+                       -Wl,--no-whole-archive
+# FIXME: workaround to invalidate -lstdc++
+       $(Echo) Making dummy -lstdc++ to lib
+       $(Verb) $(AR) rc $(ToolDir)/libstdc++.dll.a
+# FIXME: Is install-local needed?
+
+clean-local::
+       $(Verb) $(RM) -f $(ToolDir)/libstdc++.dll.a
+
 endif