#===-- 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:
#
# 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
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
###########################################################################
# 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:
# Some of the compiled LLVM tools which are used for compilation of runtime
# libraries.
#
-LLVMAS := $(LLVMTOOLCURRENT)/as
+LLVMAS := $(LLVMTOOLCURRENT)/llvm-as
###########################################################################
# 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
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)
$(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 $(LLVMAS)
@echo "Compiling $< to bytecode"
# 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)
endif
endif
-cleandeps::
- $(VERB) rm -f $(SourceDepend)
-
+endif # ifndef DISABLE_AUTO_DEPENDENCIES