Skip to content
Makefile.rules 40.7 KiB
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.
# 
#===------------------------------------------------------------------------===#
Chris Lattner's avatar
Chris Lattner committed
#
Reid Spencer's avatar
Reid Spencer committed
# 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.
#===-----------------------------------------------------------------------====
Chris Lattner's avatar
Chris Lattner committed

################################################################################
Reid Spencer's avatar
Reid Spencer committed
# TARGETS: Define standard targets that can be invoked
################################################################################
Reid Spencer's avatar
Reid Spencer 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
################################################################################
Reid Spencer's avatar
Reid Spencer committed
# INITIALIZATION: Basic things the makefile needs
################################################################################

#--------------------------------------------------------------------
# Set the VPATH so that we can find source files.
#--------------------------------------------------------------------
VPATH=$(BUILD_SRC_DIR)
Reid Spencer's avatar
Reid Spencer committed

#--------------------------------------------------------------------
# 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)
Reid Spencer's avatar
Reid Spencer committed

Reid Spencer's avatar
Reid Spencer committed
#--------------------------------------------------------------------
# Mark all of these targets as phony to avoid implicit rule search
#--------------------------------------------------------------------
.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer's avatar
Reid Spencer committed
#--------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
# Make sure all the user-target rules are double colon rules and 
# they are defined first.
Reid Spencer's avatar
Reid Spencer committed
#--------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed

################################################################################
# PRECONDITIONS: that which must be built/checked first
################################################################################

SrcMakefiles       := $(filter %Makefile %Makefile.rules %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)
Reid Spencer's avatar
Reid Spencer committed

Reid Spencer's avatar
Reid Spencer committed

#------------------------------------------------------------------------
# Make sure the BUILT_SOURCES are built first
#------------------------------------------------------------------------
$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
Reid Spencer's avatar
Reid Spencer committed

clean-local::
ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer's avatar
Reid Spencer committed
endif

$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer's avatar
Reid Spencer committed

Reid Spencer's avatar
Reid Spencer committed
#------------------------------------------------------------------------
# Make sure we're not using a stale configuration
#------------------------------------------------------------------------
.PRECIOUS: $(ConfigStatusScript)
$(ConfigStatusScript): $(ConfigureScript)
	$(Echo) Reconfiguring with $<
	$(Verb) $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS)
	$(Verb) $(ConfigStatusScript)
Reid Spencer's avatar
Reid Spencer committed

#------------------------------------------------------------------------
# Make sure the configuration makefile is up to date
#------------------------------------------------------------------------
$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
	$(Echo) Regenerating $@
	$(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer's avatar
Reid Spencer committed

#------------------------------------------------------------------------
# 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))

$(BUILD_OBJ_DIR)/Makefile : $(BUILD_SRC_DIR)/Makefile
	$(Echo) "Updating Makefile"
	$(Verb) $(MKDIR) $(@D)
	$(Verb) cp -f $< $@
Reid Spencer's avatar
Reid Spencer committed

# 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) ;; \
Reid Spencer's avatar
Reid Spencer committed
endif
Reid Spencer's avatar
Reid Spencer committed
#------------------------------------------------------------------------
# Set up the basic dependencies
#------------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed

all:: all-local
Reid Spencer's avatar
Reid Spencer committed
check:: check-local
clean:: clean-local 
clean-all:: clean-local clean-all-local
Reid Spencer's avatar
Reid Spencer committed
install:: install-local
uninstall:: uninstall-local
check-local:: all-local
install-local:: all-local 
Reid Spencer's avatar
Reid Spencer committed

###############################################################################
# VARIABLES: Set up various variables based on configuration data
###############################################################################
Chris Lattner's avatar
Chris Lattner committed
#--------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
# Variables derived from configuration we are building
Chris Lattner's avatar
Chris Lattner committed
#--------------------------------------------------------------------

  CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
  C.Flags   := -O3 -DNDEBUG -pg
  LD.Flags  := -O3 -DNDEBUG -pg 
    CXX.Flags  := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
    C.Flags    := -O3 -DNDEBUG -fomit-frame-pointer
    LD.Flags   := -O3 -DNDEBUG 
    CXX.Flags := -g -D_DEBUG 
    C.Flags   := -g -D_DEBUG
    LD.Flags  := -g -D_DEBUG 
CXX.Flags += $(CXXFLAGS)
C.Flags   += $(CFLAGS)
CPP.Flags += $(CPPFLAGS)
LD.Flags  += $(LDFLAGS)
AR.Flags  := cru
LibTool.Flags := --tag=CXX
Reid Spencer's avatar
Reid Spencer committed

#--------------------------------------------------------------------
Reid Spencer's avatar
Reid Spencer committed
#--------------------------------------------------------------------
ObjDir      := $(BUILD_OBJ_DIR)/$(BuildMode)
LibDir      := $(BUILD_OBJ_ROOT)/lib/$(BuildMode)
ToolDir     := $(BUILD_OBJ_ROOT)/tools/$(BuildMode)
LLVMLibDir  := $(LLVM_OBJ_ROOT)/lib/$(BuildMode)
LLVMToolDir := $(LLVM_OBJ_ROOT)/tools/$(BuildMode)
Reid Spencer's avatar
Reid Spencer committed
#--------------------------------------------------------------------
# Full Paths To Compiled Tools and Utilities
Reid Spencer's avatar
Reid Spencer committed
#--------------------------------------------------------------------
EchoCmd  := $(ECHO) llvm[$(MAKELEVEL)]:
Echo     := @$(EchoCmd)
ifndef LIBTOOL
endif
ifndef LLVMAS
LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
endif
ifndef BURG
BURG     := $(LLVMToolDir)/burg$(EXEEXT)
endif
ifndef TBLGEN
TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
endif
Loading
Loading full blame...