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 \
install-config-dir install-shared-library install-bytecode-library \
install-archive-library install-relinked-library install-tool \
uninstall-config-dir uninstall-shared-library uninstall-bytecode-library \
uninstall-archive-library uninstall-relinked-library uninstall-tool
###############################################################################
# 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.
#--------------------------------------------------------------------
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
$(USER_TARGETS)::
################################################################################
# PRECONDITIONS: that which must be built/checked first
################################################################################
SRCMKFILES := $(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)
#------------------------------------------------------------------------
# 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 $< $@
$(VERB) $(MAKE) $(MAKECMDGOALS)
# 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.
ifneq ($(BUILD_OBJ_DIR),$(BUILD_OBJ_ROOT))
$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
@$(ECHO) "Updating $(@F)"
$(VERB) $(MKDIR) $(@D)
$(VERB) cp -f $< $@
$(VERB) $(MAKE) $(MAKECMDGOALS)
endif
endif
#------------------------------------------------------------------------
# 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
CXXFLAGS += -O3 -DNDEBUG -felide-constructors -finline-functions -pg
CFLAGS += -O3 -DNDEBUG -pg
LDFLAGS += -O3 -DNDEBUG -pg
Chris Lattner
committed
else
ifdef ENABLE_OPTIMIZED
CONFIGURATION := Release
CXXFLAGS += -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
CFLAGS += -O3 -DNDEBUG -fomit-frame-pointer
LDFLAGS += -O3 -DNDEBUG
Chris Lattner
committed
else
CONFIGURATION := Debug
CXXFLAGS += -g -D_DEBUG
CFLAGS += -g -D_DEBUG
LDFLAGS += -g -D_DEBUG
KEEP_SYMBOLS := 1
Chris Lattner
committed
endif
endif
ARFLAGS := 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
else
LDFLAGS += -rpath $(LIBDIR)
endif
Loading
Loading full blame...