Use `llvm-dis' instead of simply `dis'.
[oota-llvm.git] / Makefile.common
index 4b2ecde43679006f5c06cef4bc90be5be2b0e790..45a25edb0ab4916908277737a97eaa8b75928a5d 100644 (file)
@@ -1,9 +1,9 @@
 #===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--====
 #
 # This file is included by all of the LLVM makefiles.  This file defines common
-# rules to do things like compile a .cpp file or generate dependancy info.
-# These are platform dependant, so this is the file used to specify these
-# system dependant operations.
+# rules to do things like compile a .cpp file or generate dependency info.
+# These are platform dependent, so this is the file used to specify these
+# system dependent operations.
 #
 # The following functionality can be set by setting incoming variables.
 # The variable $(LEVEL) *must* be set:
@@ -32,9 +32,6 @@
 #
 # 6. LLVM_SRC_ROOT - If specified, points to the top of the LLVM source tree.
 #
-# 7. LLVM_OBJ_ROOT - If specified, points to the top directory where LLVM
-#    object files are placed.
-#
 # 8. BUILD_SRC_DIR - The directory which contains the current set of Makefiles
 #    and usually the source code too (unless SourceDir is set).
 #
 #     placed.
 #
 # For building,
-#      LLVM, LLVM_SRC_ROOT = BUILD_SRC_ROOT, and
-#      LLVM_OBJ_ROOT = BUILD_OBJ_ROOT.
+#      LLVM, LLVM_SRC_ROOT = BUILD_SRC_ROOT
 #
 #===-----------------------------------------------------------------------====
 
 #
 # Configuration file to set paths specific to local installation of LLVM
 # 
+ifdef LLVM_SRC_ROOT
+include $(LLVM_SRC_ROOT)/Makefile.config
+else
 include $(LEVEL)/Makefile.config
+endif
 
 ###########################################################################
 # Directory Configuration
@@ -116,18 +116,22 @@ endif
 endif
 
 #
-# Set the LLVM source directory.
-# It is typically the root directory of what we're compiling now.
+# Set the LLVM object directory.
 #
-ifndef LLVM_SRC_ROOT
-LLVM_SRC_ROOT := $(BUILD_SRC_ROOT)
+ifndef LLVM_OBJ_ROOT
+ifdef LLVM_SRC_ROOT
+LLVM_OBJ_ROOT := $(shell cd $(BUILD_OBJ_DIR); cd $(LLVM_SRC_ROOT); pwd)
+else
+LLVM_OBJ_ROOT := $(shell cd $(BUILD_OBJ_ROOT); pwd)
+endif
 endif
 
 #
-# Set the LLVM object directory.
+# Set the LLVM source directory.
+# It is typically the root directory of what we're compiling now.
 #
-ifndef LLVM_OBJ_ROOT
-LLVM_OBJ_ROOT := $(BUILD_OBJ_ROOT)
+ifndef LLVM_SRC_ROOT
+LLVM_SRC_ROOT := $(BUILD_SRC_ROOT)
 endif
 
 ###########################################################################
@@ -161,13 +165,24 @@ bytecode::
 
 # Print out the directories used for building
 prdirs::
-       echo "Home Offset      : " $(HOME_OBJ_ROOT)
-       echo "Build Source Root: " $(BUILD_SRC_ROOT)
-       echo "Build Source Dir : " $(BUILD_SRC_DIR)
-       echo "Build Object Root: " $(BUILD_OBJ_ROOT)
-       echo "Build Object Dir : " $(BUILD_OBJ_DIR)
-       echo "LLVM  Source Root: " $(LLVM_SRC_ROOT)
-       echo "LLVM  Object Root: " $(LLVM_OBJ_ROOT)
+       @echo "Home Offset      : " $(HOME_OBJ_ROOT)
+       @echo "Build Source Root: " $(BUILD_SRC_ROOT)
+       @echo "Build Source Dir : " $(BUILD_SRC_DIR)
+       @echo "Build Object Root: " $(BUILD_OBJ_ROOT)
+       @echo "Build Object Dir : " $(BUILD_OBJ_DIR)
+       @echo "LLVM  Source Root: " $(LLVM_SRC_ROOT)
+       @echo "LLVM  Object Root: " $(LLVM_OBJ_ROOT)
+
+###########################################################################
+# Suffixes and implicit rules:
+#      Empty out the list of suffixes, generate a list that is only
+#      used by this Makefile, and cancel useless implicit rules.   This
+#      will hopefully speed up compilation a little bit.
+###########################################################################
+.SUFFIXES:
+.SUFFIXES: .c .cpp .h .hpp .y .l
+.SUFFIXES: .lo .o .a .so .bc
+.SUFFIXES: .ps .dot .d
 
 #
 # Mark all of these targets as phony.  This will hopefully speed up builds
@@ -175,7 +190,7 @@ prdirs::
 # which are marked as Phony.
 #
 .PHONY: all dynamic bytecodelib bytecodelib-install
-.PHONY: clean cleandeps distclean install test bytecode prdirs
+.PHONY: clean distclean install test bytecode prdirs
 
 ###########################################################################
 # Miscellaneous paths and commands:
@@ -212,11 +227,6 @@ ifdef ENABLE_PROFILING
   PROFILE = -pg
 endif
 
-#
-# Suffixes for library compilation rules
-#
-.SUFFIXES: .so
-
 ###########################################################################
 # Library Locations:
 #      These variables describe various library locations:
@@ -314,15 +324,15 @@ TBLGEN  := $(LLVMTOOLCURRENT)/tblgen
 # The LLVM GCC front-end in C and C++ flavors
 #
 LLVMGCC := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/gcc
-LCC1    := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
+LCC1    := $(LLVMGCCDIR)/libexec/gcc/$(LLVMGCCARCH)/cc1
 LLVMGXX := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/g++
-LCC1XX  := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
+LCC1XX  := $(LLVMGCCDIR)/libexec/gcc/$(LLVMGCCARCH)/cc1plus
 
 #--------------------------------------------------------------------------
 # Some of the compiled LLVM tools which are used for compilation of runtime
 # libraries.
 #
-LLVMAS  := $(LLVMTOOLCURRENT)/as
+LLVMAS  := $(LLVMTOOLCURRENT)/llvm-as
 
 
 ###########################################################################
@@ -344,14 +354,15 @@ endif
 # Allow gnu extensions...
 CPPFLAGS += -D_GNU_SOURCE
 
-CompileCommonOpts := -Wall -W  -Wwrite-strings -Wno-unused -I$(LEVEL)/include
-CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
+CompileWarnings  := -Wall -W  -Wwrite-strings -Wno-unused
+CompileCommonOpts := $(CompileWarnings) -I$(LEVEL)/include -fshort-enums
+CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions
 
 #
 # Compile commands with libtool.
 #
 Compile  := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
-CompileC  := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
+CompileC  := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(CompileCommonOpts)
 
 # Compile a cpp file, don't link...
 CompileG := $(Compile) -g  -D_DEBUG
@@ -380,9 +391,6 @@ LinkP    := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PR
 
 # Create one .o file from a bunch of .o files...
 Relink := ${LIBTOOL} --mode=link $(CXX)
-ifndef SHARED_LIBRARY
-Relink += -only-static
-endif
 
 #
 # Configure where the item being compiled should go.
@@ -395,7 +403,7 @@ ifdef TOOLNAME
 Link += -rpath $(DESTTOOLCURRENT)
 endif
 
-# Create dependancy file from CPP file, send to stdout.
+# Create dependency file from CPP file, send to stdout.
 Depend   := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) 
 DependC  := $(CC)  -MM -I$(LEVEL)/include $(CPPFLAGS) 
 
@@ -435,7 +443,7 @@ RObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(RObjs))
 #---------------------------------------------------------
 
 ifdef DIRS
-all install clean cleandeps test bytecode ::
+all install clean test bytecode ::
        $(VERB) for dir in ${DIRS}; do \
                (cd $$dir; $(MAKE) $@) || exit 1; \
        done
@@ -446,18 +454,16 @@ ifdef PARALLEL_DIRS
 all      :: $(addsuffix /.makeall     , $(PARALLEL_DIRS))
 install  :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
 clean    :: $(addsuffix /.makeclean   , $(PARALLEL_DIRS))
-cleandeps:: $(addsuffix /.makecleandeps, $(PARALLEL_DIRS))
 test     :: $(addsuffix /.maketest    , $(PARALLEL_DIRS))
 bytecode :: $(addsuffix /.makebytecode, $(PARALLEL_DIRS))
 
-%/.makeall %/.makeinstall %/.makeclean %/.makecleandeps %/.maketest \
-    %/.makebytecode:
+%/.makeall %/.makeinstall %/.makeclean %/.maketest %/.makebytecode:
        $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
 endif
 
 # Handle directories that may or may not exist
 ifdef OPTIONAL_DIRS
-all install clean cleandeps test bytecode ::
+all install clean test bytecode ::
        $(VERB) for dir in ${OPTIONAL_DIRS}; do \
                if [ -d $$dir ]; \
                then\
@@ -614,8 +620,10 @@ endif
 
 ifdef ETAGS
 ifeq ($(LEVEL), .)
+SRCDIRS := $(wildcard include lib tools)
+
 tags:
-       $(ETAGS) -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
+       $(ETAGS) -l c++ `find $(SRCDIRS) -name '*.cpp' -o -name '*.h'`
 all:: tags
 endif
 else
@@ -732,13 +740,13 @@ $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
 
 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1XX)
        @echo "Compiling $< to bytecode"
-       $(VERB) $(LLVMGXX) $(CPPFLAGS) -c $< -o $@
+       $(VERB) $(LLVMGXX) $(CompileWarnings) $(CPPFLAGS) -c $< -o $@
 
 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
        @echo "Compiling $< to bytecode"
-       $(VERB) $(LLVMGCC) $(CPPFLAGS) -c $< -o $@
+       $(VERB) $(LLVMGCC) $(CompileWarnings) $(CPPFLAGS) -c $< -o $@
 
-$(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.ll $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
+$(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.ll $(BUILD_OBJ_DIR)/Bytecode/.dir $(LLVMAS)
        @echo "Compiling $< to bytecode"
        $(VERB) $(LLVMAS) $< -f -o $@
 
@@ -811,21 +819,23 @@ clean::
 #      from C/C++ source files.
 ###########################################################################
 
+ifndef DISABLE_AUTO_DEPENDENCIES
+
 # If dependencies were generated for the file that included this file,
-# include the dependancies now...
+# include the dependencies now...
 #
 SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
 SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
 
 # Create dependencies for the *.cpp files...
-#$(SourceDepend): \x
 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
        $(VERB) $(Depend) $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
+       $(VERB) $(Depend) $< | $(SED) 's|$*.o: $*.cpp||' | $(SED) 's|[^\]$$|&::|' >> $@
 
 # Create dependencies for the *.c files...
-#$(SourceDepend): \x
 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
        $(VERB) $(DependC) -o $@ $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
+       $(VERB) $(Depend) $< | $(SED) 's|$*.o: $*.c||' | $(SED) 's|[^\]$$|&::|' >> $@
 
 #
 # Include dependencies generated from C/C++ source files, but not if we
@@ -833,14 +843,8 @@ $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
 #
 ifneq ($(MAKECMDGOALS),clean)
 ifneq ($(MAKECMDGOALS),distclean)
-ifneq ($(MAKECMDGOALS),cleandeps)
-ifneq ($(SourceDepend),)
--include $(SourceDepend)
+-include /dev/null $(SourceDepend)
 endif
 endif
-endif
-endif
-
-cleandeps::
-       $(VERB) rm -f $(SourceDepend)
 
+endif  # ifndef DISABLE_AUTO_DEPENDENCIES