Newer
Older
#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file was developed by the LLVM research group and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
# This file is included by all of the LLVM makefiles. For details on how to use
# it properly, please see the document MakefileGuide.html in the docs directory.
#===-----------------------------------------------------------------------====
################################################################################
################################################################################
John Criswell
committed
#--------------------------------------------------------------------
# Define the various target sets
#--------------------------------------------------------------------
RecursiveTargets := all clean clean-all check install uninstall
LocalTargets := all-local clean-local clean-all-local check-local \
install-local printvars uninstall-local
TopLevelTargets := dist dist-check dist-clean tags dist-gzip dist-bzip2 \
dist-zip
UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
InternalTargets := preconditions distdir dist-hook
################################################################################
################################################################################
#--------------------------------------------------------------------
# Set the VPATH so that we can find source files.
#--------------------------------------------------------------------
VPATH=$(BUILD_SRC_DIR)
#--------------------------------------------------------------------
# Reset the list of suffixes we know how to build
#--------------------------------------------------------------------
.SUFFIXES:
.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
#--------------------------------------------------------------------
# Mark all of these targets as phony to avoid implicit rule search
#--------------------------------------------------------------------
.PHONY: $(UserTargets) $(InternalTargets)
#--------------------------------------------------------------------
# Make sure all the user-target rules are double colon rules and
# they are defined first.
#--------------------------------------------------------------------
$(UserTargets)::
################################################################################
# PRECONDITIONS: that which must be built/checked first
################################################################################
SrcMakefiles := $(filter %Makefile %Makefile.tests %Makefile.JIT,\
$(wildcard $(BUILD_SRC_DIR)/Makefile*))
ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
ConfigureScript := $(LLVM_SRC_ROOT)/configure
ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
preconditions : $(PreConditions)
#------------------------------------------------------------------------
# Make sure the BUILT_SOURCES are built first
#------------------------------------------------------------------------
$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
-$(Verb) $(RM) -f $(BUILT_SOURCES)
$(BUILT_SOURCES) : $(ObjMakefiles)
#------------------------------------------------------------------------
# Make sure we're not using a stale configuration
#------------------------------------------------------------------------
.PRECIOUS: $(ConfigStatusScript)
$(ConfigStatusScript): $(ConfigureScript)
$(Echo) Reconfiguring with $<
$(Verb) $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS)
$(Verb) $(ConfigStatusScript)
#------------------------------------------------------------------------
# Make sure the configuration makefile is up to date
#------------------------------------------------------------------------
$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
$(Echo) Regenerating $@
$(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
#------------------------------------------------------------------------
# If the Makefile in the source tree has been updated, copy it over into the
# build tree. But, only do this if the source and object makefiles differ
#------------------------------------------------------------------------
ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
$(Echo) "Updating Makefile"
$(Verb) $(MKDIR) $(@D)
$(Verb) cp -f $< $@
# Copy the Makefile.* files unless we're in the root directory which avoids
# the copying of Makefile.config.in or other things that should be explicitly
# taken care of.
$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
@case '$?' in \
*Makefile.rules) ;; \
*.in) ;; \
*) $(Echo) "Updating $(@F)" ; \
$(MKDIR) $(@D) ; \
cp -f $< $@ ;; \
esac
#------------------------------------------------------------------------
# Set up the basic dependencies
#------------------------------------------------------------------------
$(UserTargets):: $(PreConditions)
clean-all:: clean-local clean-all-local
install:: install-local
uninstall:: uninstall-local
check-local:: all-local
install-local:: all-local
###############################################################################
# VARIABLES: Set up various variables based on configuration data
###############################################################################
#--------------------------------------------------------------------
#--------------------------------------------------------------------
Chris Lattner
committed
ifdef ENABLE_PROFILING
BuildMode := Profile
CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
C.Flags := -O3 -DNDEBUG -pg
LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner
committed
else
ifdef ENABLE_OPTIMIZED
BuildMode := Release
CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
LD.Flags := -O3 -DNDEBUG
Chris Lattner
committed
else
BuildMode := Debug
CXX.Flags := -g -D_DEBUG
C.Flags := -g -D_DEBUG
LD.Flags := -g -D_DEBUG
KEEP_SYMBOLS := 1
Chris Lattner
committed
endif
endif
CXX.Flags += $(CXXFLAGS)
C.Flags += $(CFLAGS)
CPP.Flags += $(CPPFLAGS)
LD.Flags += $(LDFLAGS)
AR.Flags := cru
LibTool.Flags := --tag=CXX
#--------------------------------------------------------------------
# Directory locations
#--------------------------------------------------------------------
ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/tools
ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/tools
LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
#--------------------------------------------------------------------
# Full Paths To Compiled Tools and Utilities
#--------------------------------------------------------------------
EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
Echo := @$(EchoCmd)
ifndef LIBTOOL
LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
endif
ifndef LLVMAS
LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
endif
ifndef BURG
BURG := $(LLVMToolDir)/burg$(EXEEXT)
endif
ifndef TBLGEN
Loading
Loading full blame...