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
#
# Set the VPATH so that we can find source files.
John Criswell
committed
#
VPATH=$(BUILD_SRC_DIR)
###############################################################################
# TARGETS: Define standard targets that can be invoked
###############################################################################
John Criswell
committed
#--------------------------------------------------------------------
# Define the various target sets
#--------------------------------------------------------------------
RECURSIVE_TARGETS := all clean check install uninstall
LOCAL_TARGETS := all-local clean-local check-local install-local \
printvars uninstall-local
TOPLEV_TARGETS := dist dist-check dist-clean tags
USER_TARGETS := $(RECURSIVE_TARGETS) $(LOCAL_TARGETS) $(TOPLEV_TARGETS)
INTERNAL_TARGETS := preconditions
###############################################################################
# INITIALIZATION: Basic things the makefile needs
###############################################################################
#--------------------------------------------------------------------
# Reset the list of suffixes we know how to build
#--------------------------------------------------------------------
.SUFFIXES:
.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a $(SHLIBEXT) .bc .td .ps .dot $(SUFFIXES)
#--------------------------------------------------------------------
# Mark all of these targets as phony to avoid implicit rule search
#--------------------------------------------------------------------
#--------------------------------------------------------------------
# Make sure all the user-target rules are double colon rules and
# they are defined first.
#--------------------------------------------------------------------
$(USER_TARGETS)::
################################################################################
# PRECONDITIONS: that which must be built/checked first
################################################################################
SRCMKFILES := $(filter %Makefile %Makefile.rules %Makefile.tests \
%Makefile.JIT,$(wildcard $(BUILD_SRC_DIR)/Makefile*))
OBJMKFILES := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SRCMKFILES))
CONFIGURE := $(LLVM_SRC_ROOT)/configure
CONFIG_STATUS := $(LLVM_OBJ_ROOT)/config.status
MAKE_CONFIG_IN:= $(LLVM_SRC_ROOT)/Makefile.config.in
MAKE_CONFIG := $(LLVM_OBJ_ROOT)/Makefile.config
PRECONDITIONS := $(CONFIG_STATUS) $(MAKE_CONFIG) $(OBJMKFILES)
preconditions : $(PRECONDITIONS)
#------------------------------------------------------------------------
# Make sure the BUILT_SOURCES are built first
#------------------------------------------------------------------------
$(filter-out clean clean-local,USER_TARGETS):: $(BUILT_SOURCES)
clean-local::
ifneq ($(strip $(BUILT_SOURCES)),)
$(VERB) $(RM) -f $(BUILT_SOURCES)
endif
#------------------------------------------------------------------------
# Make sure we're not using a stale configuration
#------------------------------------------------------------------------
.PRECIOUS: $(CONFIG_STATUS)
$(CONFIG_STATUS): $(CONFIGURE)
@$(ECHO) Reconfiguring with $<
$(VERB) $(CONFIG_STATUS) --recheck $(CONFIGUREFLAGS)
$(VERB) $(CONFIG_STATUS)
#------------------------------------------------------------------------
# Make sure the configuration makefile is up to date
#------------------------------------------------------------------------
$(MAKE_CONFIG): $(MAKE_CONFIG_IN) $(CONFIG_STATUS)
@$(ECHO) Regenerating $@
$(VERB) cd $(LLVM_OBJ_ROOT) ; $(CONFIG_STATUS) 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))
$(BUILD_OBJ_DIR)/Makefile : $(BUILD_SRC_DIR)/Makefile
@$(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
#------------------------------------------------------------------------
$(USER_TARGETS):: $(PRECONDITIONS)
all:: 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
CONFIGURATION := Profile
LLVMCXXFLAGS := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
LLVMCFLAGS := -O3 -DNDEBUG -pg
LLVMLDFLAGS := -O3 -DNDEBUG -pg
Chris Lattner
committed
else
ifdef ENABLE_OPTIMIZED
CONFIGURATION := Release
LLVMCXXFLAGS := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
LLVMCFLAGS := -O3 -DNDEBUG -fomit-frame-pointer
LLVMLDFLAGS := -O3 -DNDEBUG
Chris Lattner
committed
else
CONFIGURATION := Debug
LLVMCXXFLAGS := -g -D_DEBUG
LLVMCFLAGS := -g -D_DEBUG
LLVMLDFLAGS := -g -D_DEBUG
KEEP_SYMBOLS := 1
Chris Lattner
committed
endif
endif
LLVMCXXFLAGS += $(CXXFLAGS)
LLVMCFLAGS += $(CFLAGS)
LLVMCPPFLAGS += $(CPPFLAGS)
LLVMLDFLAGS += $(LDFLAGS)
LLVMARFLAGS := cru
#--------------------------------------------------------------------
# Directory locations
#--------------------------------------------------------------------
OBJDIR := $(BUILD_OBJ_DIR)/$(CONFIGURATION)
LIBDIR := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
TOOLDIR := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
LLVMLIBDIR := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
LLVMTOOLDIR := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
#--------------------------------------------------------------------
# Full Paths To Compiled Tools and Utilities
#--------------------------------------------------------------------
LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
LLVMAS := $(LLVMTOOLDIR)/llvm-as$(EXEEXT)
BURG := $(LLVMTOOLDIR)/burg$(EXEEXT)
TBLGEN := $(LLVMTOOLDIR)/tblgen$(EXEEXT)
GCCLD := $(LLVMTOOLDIR)/gccld$(EXEEXT)
LLVMGCC := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
LLVMGXX := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
# Need a better way to compute this.
LLVMGCCLIBDIR := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
#--------------------------------------------------------------------
# Adjust to user's request
#--------------------------------------------------------------------
John Criswell
committed
ifndef SHARED_LIBRARY
LIBTOOL += --tag=disable-shared
Loading
Loading full blame...