- Refactor the code that resolve basic block references to a TargetJITInfo
[oota-llvm.git] / Makefile.rules
index dd3ed014aa73fc5837ea43624e32948c9452a8e3..779e0a6933b5cd8bc217b8c20fc7c3d203784069 100644 (file)
@@ -208,9 +208,9 @@ endif
 
 ifdef ENABLE_PROFILING
   BuildMode := Profile
-  CXX.Flags := $(OPTIMIZE_OPTION) -pg
-  C.Flags   := $(OPTIMIZE_OPTION) -pg
-  LD.Flags  := $(OPTIMIZE_OPTION) -pg 
+  CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
+  C.Flags   := $(OPTIMIZE_OPTION) -pg -g
+  LD.Flags  := $(OPTIMIZE_OPTION) -pg -g
 else
   ifdef ENABLE_OPTIMIZED
     BuildMode := Release
@@ -228,7 +228,7 @@ else
     BuildMode := Debug
     CXX.Flags := -g
     C.Flags   := -g
-    LD.Flags  := -g 
+    LD.Flags  := -g
     KEEP_SYMBOLS := 1
   endif
 endif
@@ -253,8 +253,8 @@ LibTool.Flags := --tag=CXX
 
 #Make Floating point ieee complient on alpha
 ifeq ($(ARCH),Alpha)
-  CXX.Flags     += -mieee
-  CPP.BaseFlags += -mieee
+  CXX.Flags     += -mieee -fPIC
+  CPP.BaseFlags += -mieee -fPIC
 endif
 
 #--------------------------------------------------------------------
@@ -370,13 +370,22 @@ endif
 
 # If we are building a universal binary on Mac OS/X, pass extra options.  This
 # is useful to people that want to link the LLVM libraries into their universal
-# apps.  The UNIVERSAL_SDK_PATH variable can optionally be specified as a path
-# to the SDK to use.  For Mac OS/X 10.4 Intel machines, the traditional one is:
-#   UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
+# apps.
+#
+# The following can be optionally specified:
+#   UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
+#      For Mac OS/X 10.4 Intel machines, the traditional one is:
+#      UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
+#   UNIVERSAL_ARCH can be optionally specified to be a list of architectures
+#      to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64".  This defaults to
+#      i386/ppc only.
 ifdef UNIVERSAL
-  CompileCommonOpts += -arch i386 -arch ppc
-  Relink.Flags := -XCClinker -arch -XCClinker i386 -XCClinker -arch \
-                  -XCClinker ppc
+  ifndef UNIVERSAL_ARCH
+    UNIVERSAL_ARCH := i386 ppc
+  endif
+  UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
+  CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
+  Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
   ifdef UNIVERSAL_SDK_PATH
     CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
     Relink.Flags      += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
@@ -386,11 +395,6 @@ ifdef UNIVERSAL
   DISABLE_AUTO_DEPENDENCIES=1
 endif
 
-# Temporary workaround for a Mac OSX compatibility issue.
-ifeq ($(OS),Darwin)
-  CXX.Flags += -fno-use-cxa-atexit
-endif
-
 LD.Flags      += -L$(LibDir) -L$(LLVMLibDir) 
 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
 # All -I flags should go here, so that they don't confuse llvm-config.
@@ -600,7 +604,8 @@ ifeq ($(LLVMLIBS),JIT)
 Link += -dlopen self
 
 # Generic JIT libraries
-JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
+JIT_LIBS := LLVMInterpreter LLVMJIT LLVMSelectionDAG.a LLVMCodeGen.a \
+            LLVMExecutionEngine
 
 # You can enable the X86 JIT on a non-X86 host by setting the flag
 # ENABLE_X86_JIT on the make command line. If not, it will still be
@@ -611,7 +616,7 @@ endif
 
 # What the X86 JIT requires
 ifdef ENABLE_X86_JIT
-  JIT_LIBS += LLVMX86 LLVMSelectionDAG
+  JIT_LIBS += LLVMX86 
 endif
 
 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
@@ -623,7 +628,7 @@ endif
 
 # What the PowerPC JIT requires
 ifdef ENABLE_PPC_JIT
-  JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
+  JIT_LIBS += LLVMPowerPC 
 endif
 
 # You can enable the Alpha JIT on a non-Alpha host by setting the flag
@@ -635,7 +640,7 @@ endif
 
 # What the Alpha JIT requires
 ifdef ENABLE_ALPHA_JIT
-  JIT_LIBS += LLVMAlpha LLVMSelectionDAG
+  JIT_LIBS += LLVMAlpha 
 endif
 
 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
@@ -981,71 +986,40 @@ ifeq ($(OS),HP-UX)
   DISABLE_AUTO_DEPENDENCIES=1
 endif
 
+ifdef SHARED_LIBRARY
+PIC_FLAG = "(PIC)"
+MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
+MAYBE_PIC_Compile.C = $(LTCompile.C)
+else
+MAYBE_PIC_Compile.CXX = $(Compile.CXX)
+MAYBE_PIC_Compile.C = $(Compile.C)
+endif
+
 # Provide rule sets for when dependency generation is enabled
 ifndef DISABLE_AUTO_DEPENDENCIES
 
 #---------------------------------------------------------
 # Create .lo files in the ObjDir directory from the .cpp and .c files...
 #---------------------------------------------------------
-ifdef SHARED_LIBRARY
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
-       $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
-       then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
+       $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
+       $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
+         then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
+         else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
-       $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
+       $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
+       $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
        then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
        else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
-       $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
+       $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
+       $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
        then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
        else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
 
-#---------------------------------------------------------
-# Create .o files in the ObjDir directory from the .cpp and .c files...
-#---------------------------------------------------------
-else
-
-$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cpp for $(BuildMode) build"
-       $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
-       then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
-
-$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cc for $(BuildMode) build"
-       $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
-       then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
-
-$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.c for $(BuildMode) build"
-       $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
-       then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
-
-endif
-
-## Rules for building preprocessed (.i/.ii) outputs.
-$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
-       $(Verb) $(Preprocess.CXX) $< -o $@
-
-$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
-       $(Verb) $(Preprocess.CXX) $< -o $@
-
- $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
-       $(Verb) $(Preprocess.C) $< -o $@
-
-
 #---------------------------------------------------------
 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
 #---------------------------------------------------------
@@ -1074,34 +1048,17 @@ $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
 # Provide alternate rule sets if dependencies are disabled
 else
 
-ifdef SHARED_LIBRARY
-
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
-       $(LTCompile.CXX) $< -o $@ 
+       $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
+       $(MAYBE_PIC_Compile.CXX) $< -o $@ 
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
-       $(LTCompile.CXX) $< -o $@ 
+       $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
+       $(MAYBE_PIC_Compile.CXX) $< -o $@ 
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
-       $(LTCompile.C) $< -o $@ 
-
-else
-
-$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cpp for $(BuildMode) build"
-       $(Compile.CXX) $< -o $@ 
-
-$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.cc for $(BuildMode) build"
-       $(Compile.CXX) $< -o $@ 
-
-$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
-       $(Echo) "Compiling $*.c for $(BuildMode) build"
-       $(Compile.C) $< -o $@ 
-endif
+       $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
+       $(MAYBE_PIC_Compile.C) $< -o $@ 
 
 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
        $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
@@ -1117,6 +1074,34 @@ $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
 
 endif
 
+
+## Rules for building preprocessed (.i/.ii) outputs.
+$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
+       $(Verb) $(Preprocess.CXX) $< -o $@
+
+$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
+       $(Verb) $(Preprocess.CXX) $< -o $@
+
+ $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
+       $(Verb) $(Preprocess.C) $< -o $@
+
+
+$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
+       $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
+
+$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
+       $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
+
+$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
+       $(MAYBE_PIC_Compile.C) $< -o $@ -S
+
+
 # make the C and C++ compilers strip debug info out of bytecode libraries.
 ifdef DEBUG_RUNTIME
 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)