# Reset the list of suffixes we know how to build.
#--------------------------------------------------------------------
.SUFFIXES:
-.SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll .m .mm
+.SUFFIXES: .c .cpp .cc .h .hpp .o .a .td .ps .dot .m .mm
.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
#--------------------------------------------------------------------
# The files we are going to generate using llvm-build.
LLVMBuildMakeFrag := $(PROJ_OBJ_ROOT)/Makefile.llvmbuild
+LLVMBuildCMakeFrag := $(PROJ_OBJ_ROOT)/LLVMBuild.cmake
+LLVMBuildCMakeExportsFrag := $(PROJ_OBJ_ROOT)/cmake/modules/LLVMBuildExports.cmake
+LLVMBuildMakeFrags := \
+ $(LLVMBuildMakeFrag) \
+ $(LLVMBuildCMakeFrag) \
+ $(LLVMBuildCMakeExportsFrag)
LLVMConfigLibraryDependenciesInc := \
$(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc
#
# We include a dependency on this Makefile to ensure that changes to the
# generation command get picked up.
-$(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \
- $(PROJ_OBJ_ROOT)/Makefile.config
+$(LLVMBuildMakeFrags): $(PROJ_SRC_ROOT)/Makefile.rules \
+ $(PROJ_OBJ_ROOT)/Makefile.config
$(Echo) Constructing LLVMBuild project information.
- $(Verb) $(LLVMBuildTool) \
+ $(Verb)$(PYTHON) $(LLVMBuildTool) \
--native-target "$(TARGET_NATIVE_ARCH)" \
--enable-targets "$(TARGETS_TO_BUILD)" \
--enable-optional-components "$(OPTIONAL_COMPONENTS)" \
--write-library-table $(LLVMConfigLibraryDependenciesInc) \
- --write-make-fragment $(LLVMBuildMakeFrag)
+ --write-make-fragment $(LLVMBuildMakeFrag) \
+ --write-cmake-fragment $(LLVMBuildCMakeFrag) \
+ --write-cmake-exports-fragment $(LLVMBuildCMakeExportsFrag)
# For completeness, let Make know how the extra files are generated.
-$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrag)
+$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrags)
# Include the generated Makefile fragment.
#
# Clean the generated makefile fragment at the top-level.
clean-local::
- -$(Verb) $(RM) -f $(LLVMBuildMakeFrag)
+ -$(Verb) $(RM) -f $(LLVMBuildMakeFrags)
endif
-include $(LLVMBuildMakeFrag)
ifeq ($(ENABLE_OPTIMIZED),1)
BuildMode := Release
# Don't use -fomit-frame-pointer on Darwin or FreeBSD.
- ifneq ($(HOST_OS),FreeBSD)
- ifneq ($(HOST_OS),Darwin)
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
OmitFramePointer := -fomit-frame-pointer
endif
- endif
- # Darwin requires -fstrict-aliasing to be explicitly enabled.
- # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
- # with -fstrict-aliasing and ipa-type-escape radr://6756684
- #ifeq ($(HOST_OS),Darwin)
- # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
- #endif
CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
LD.Flags += $(OPTIMIZE_OPTION)
BuildMode := $(BuildMode)+Debug
CXX.Flags += -g
C.Flags += -g
- LD.Flags += -g
KEEP_SYMBOLS := 1
endif
else
BuildMode := Unoptimized
CXX.Flags +=
C.Flags +=
- LD.Flags +=
KEEP_SYMBOLS := 1
else
BuildMode := Debug
+ ifeq ($(ENABLE_SPLIT_DWARF), 1)
+ CXX.Flags += -gsplit-dwarf
+ C.Flags += -gsplit-dwarf
+ else
CXX.Flags += -g
C.Flags += -g
- LD.Flags += -g
+ endif
KEEP_SYMBOLS := 1
endif
endif
LD.Flags += -stdlib=libc++
endif
-ifeq ($(ENABLE_CXX11),1)
- CXX.Flags += -std=c++11
+ifeq ($(ENABLE_CXX1Y),1)
+ CXX.Flags += -std=c++1y
+else
+ ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ # MinGW and Cygwin are a bit stricter and lack things like
+ # 'strdup', 'stricmp', etc in c++11 mode.
+ CXX.Flags += -std=gnu++11
+ else
+ CXX.Flags += -std=c++11
+ endif
+endif
+
+ifeq ($(ENABLE_WERROR),1)
+ CXX.Flags += -Werror
+ C.Flags += -Werror
endif
ifeq ($(ENABLE_PROFILING),1)
BuildMode := $(BuildMode)+Profile
CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
- LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
+ LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg
KEEP_SYMBOLS := 1
endif
endif
endif
-#--------------------------------------------------------------------
-# LLVM Capable Compiler
-#--------------------------------------------------------------------
-
-ifneq ($(findstring llvm-gcc,$(LLVMCC_OPTION)),)
- LLVMCC := $(LLVMGCC)
- LLVMCXX := $(LLVMGXX)
-else
- ifneq ($(findstring clang,$(LLVMCC_OPTION)),)
- ifneq ($(CLANGPATH),)
- LLVMCC := $(CLANGPATH)
- LLVMCXX := $(CLANGXXPATH)
- else
- ifeq ($(ENABLE_BUILT_CLANG),1)
- LLVMCC := $(LLVMToolDir)/clang
- LLVMCXX := $(LLVMToolDir)/clang++
- endif
- endif
- endif
-endif
-
#--------------------------------------------------------------------
# Full Paths To Compiled Tools and Utilities
#--------------------------------------------------------------------
#--------------------------------------------------------------------
ifeq ($(HOST_OS),Darwin)
+ ifdef MACOSX_DEPLOYMENT_TARGET
+ DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
+ else
DARWIN_VERSION := `sw_vers -productVersion`
+ endif
# Strip a number like 10.4.7 to 10.4
- DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
+ DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/')
# Get "4" out of 10.4 for later pieces in the makefile.
- DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
+ DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/')
LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
SharedLinkOptions := -dynamiclib
- ifneq ($(ARCH),ARM)
- SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
+ ifdef DEPLOYMENT_TARGET
+ SharedLinkOptions += $(DEPLOYMENT_TARGET)
+ else
+ ifneq ($(ARCH),ARM)
+ SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
+ endif
endif
else
SharedLinkOptions=-shared
endif
ifeq ($(TARGET_OS),Darwin)
- ifneq ($(ARCH),ARM)
- TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
+ ifdef DEPLOYMENT_TARGET
+ TargetCommonOpts += $(DEPLOYMENT_TARGET)
+ else
+ ifneq ($(ARCH),ARM)
+ TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
+ endif
endif
endif
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
ifneq ($(HOST_OS),Darwin)
LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
+else
+ LD.Flags += -Wl,-install_name -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
endif
endif
endif
Install.StripFlag += -s
endif
-ifdef TOOL_NO_EXPORTS
- DynamicFlags :=
-else
- DynamicFlag := $(RDYNAMIC)
+# By default, strip dead symbols at link time
+ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ifneq ($(HOST_OS),Darwin)
+ifneq ($(HOST_ARCH),Mips)
+ CXX.Flags += -ffunction-sections -fdata-sections
+endif
+endif
+endif
+ifndef NO_DEAD_STRIP
+ ifeq ($(HOST_OS),Darwin)
+ LD.Flags += -Wl,-dead_strip
+ else
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ LD.Flags += -Wl,--gc-sections
+ endif
+ endif
endif
# Adjust linker flags for building an executable
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
-ifneq ($(HOST_OS), Darwin)
-ifdef TOOLNAME
- LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
- ifdef EXAMPLE_TOOL
- LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
+ ifndef TOOL_NO_EXPORTS
+ LD.Flags += $(RDYNAMIC)
+ endif
+ ifneq ($(HOST_OS), Darwin)
+ ifdef TOOLNAME
+ LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
+ endif
else
- LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
+ ifneq ($(DARWIN_MAJVERS),4)
+ LD.Flags += $(RPATH) -Wl,@executable_path/../lib
+ endif
+ ifeq ($(RC_XBS),YES)
+ TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
+ LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
+ endif
endif
endif
-else
-ifneq ($(DARWIN_MAJVERS),4)
- LD.Flags += $(RPATH) -Wl,@executable_path/../lib
-endif
-endif
-endif
#----------------------------------------------------------
CompileCommonOpts += -pedantic -Wno-long-long
endif
CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
- $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT)
+ $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
+ $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
+ $(NO_MISSING_FIELD_INITIALIZERS)
# Enable cast-qual for C++; the workaround is to use const_cast.
CXX.Flags += -Wcast-qual
CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
endif
-# If we are building a universal binary on Mac OS/X, pass extra options. This
+# If we are building a universal binary on Mac OS X, pass extra options. This
# is useful to people that want to link the LLVM libraries into their universal
# apps.
#
# The following can be optionally specified:
# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
-# For Mac OS/X 10.4 Intel machines, the traditional one is:
+# For Mac OS X 10.4 Intel machines, the traditional one is:
# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
UNIVERSAL_ARCH := i386 ppc
endif
UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
- CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
+ TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
ifdef UNIVERSAL_SDK_PATH
- CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
+ TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
endif
# Building universal cannot compute dependencies automatically.
$(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
$(CompileCommonOpts) $(CXX.Flags) -E
Link = $(Compile.Wrapper) \
- $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LD.Flags) \
- $(LDFLAGS) $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
+ $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
+ $(TargetCommonOpts) $(Strip)
-BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
- $(TargetCommonOpts) $(CompileCommonOpts)
Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
$(TargetCommonOpts) $(CompileCommonOpts) -E
-BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
- $(TargetCommonOpts) $(CompileCommonOpts)
-
ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
ScriptInstall = $(INSTALL) -m 0755
DataInstall = $(INSTALL) -m 0644
LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
Archive = $(AR) $(AR.Flags)
-LArchive = $(LLVMToolDir)/llvm-ar rcsf
ifdef RANLIB
Ranlib = $(RANLIB)
else
Ranlib = ranlib
endif
-AliasTool = ln -s
+AliasTool = ln -sf
#----------------------------------------------------------
# Get the list of source files and compute object file
endif
BaseNameSources := $(sort $(basename $(Sources)))
+SourceDirs := $(sort $(dir $(Sources)))
ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
-ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
+ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
#----------------------------------------------------------
# For Mingw MSYS bash and Python/w32:
#----------------------------------------------------------
ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
- ECHOPATH := $(Verb)python -u -c "import sys;print ' '.join(sys.argv[1:])"
+ ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
else
ECHOPATH := $(Verb)$(ECHO)
endif
$(Verb) $(MKDIR) $* > /dev/null
$(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
-.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
+.PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
+#---------------------------------------------------------
+# Collect the object directories (as there may be more
+# than one if the source code is spread across
+# subdirectories).
+#---------------------------------------------------------
+
+OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
+.PRECIOUS: $(OBJECT_DIRS)
+
#---------------------------------------------------------
# Handle the DIRS options for sequential construction
#---------------------------------------------------------
# Library Build Rules: Four ways to build a library
###############################################################################
-#---------------------------------------------------------
-# Bytecode Module Targets:
-# If the user set MODULE_NAME then they want to build a
-# bytecode module from the sources. We compile all the
-# sources and link it together into a single bytecode
-# module.
-#---------------------------------------------------------
-
-ifdef MODULE_NAME
-ifeq ($(strip $(LLVMCC)),)
-$(warning Modules require LLVM capable compiler but none is available ****)
-else
-
-Module := $(LibDir)/$(MODULE_NAME).bc
-LinkModule := $(LLVMLINK)
-
-
-ifdef EXPORTED_SYMBOL_FILE
-LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
-endif
-
-$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLINK)
- $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
- $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
-
-all-local:: $(Module)
-
-clean-local::
-ifneq ($(strip $(Module)),)
- -$(Verb) $(RM) -f $(Module)
-endif
-
-ifdef BYTECODE_DESTINATION
-ModuleDestDir := $(BYTECODE_DESTINATION)
-else
-ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
-endif
-
-ifdef NO_INSTALL
-install-local::
- $(Echo) Install circumvented with NO_INSTALL
-uninstall-local::
- $(Echo) Uninstall circumvented with NO_INSTALL
-else
-DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
-
-install-module:: $(DestModule)
-install-local:: $(DestModule)
-
-$(DestModule): $(ModuleDestDir) $(Module)
- $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
- $(Verb) $(DataInstall) $(Module) $(DestModule)
-
-uninstall-local::
- $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
- -$(Verb) $(RM) -f $(DestModule)
-endif
-
-endif
-endif
-
# if we're building a library ...
ifdef LIBRARYNAME
# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
LIBRARYNAME := $(strip $(LIBRARYNAME))
+LIBRARYALIASNAME := $(strip $(LIBRARYALIASNAME))
ifdef LOADABLE_MODULE
BaseLibName.A := $(LIBRARYNAME).a
BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
+BaseAliasName.SO := $(LIBRARYALIASNAME)$(SHLIBEXT)
else
BaseLibName.A := lib$(LIBRARYNAME).a
BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
+BaseAliasName.SO := $(SharedPrefix)$(LIBRARYALIASNAME)$(SHLIBEXT)
endif
LibName.A := $(LibDir)/$(BaseLibName.A)
LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
+AliasName.SO := $(SharedLibDir)/$(BaseAliasName.SO)
LibName.O := $(LibDir)/$(LIBRARYNAME).o
-LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
#---------------------------------------------------------
# Shared Library Targets:
DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
endif
DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
+DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO)
install-local:: $(DestSharedLib)
$(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
$(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
$(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
-
-uninstall-local::
- $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
- -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
+ifdef SHARED_ALIAS
+ $(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias)
+ $(Verb) $(AliasTool) $(DestSharedLib) $(DestSharedAlias)
endif
-endif
-
-#---------------------------------------------------------
-# Bytecode Library Targets:
-# If the user asked for a bytecode library to be built
-# with the BYTECODE_LIBRARY variable, then we provide
-# targets for building them.
-#---------------------------------------------------------
-ifdef BYTECODE_LIBRARY
-ifeq ($(strip $(LLVMCC)),)
-$(warning Bytecode libraries require LLVM capable compiler but none is available ****)
-else
-
-all-local:: $(LibName.BCA)
-
-ifdef EXPORTED_SYMBOL_FILE
-BCLinkLib = $(LLVMLINK) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
-
-$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLINK) \
- $(LLVMToolDir)/llvm-ar
- $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
- "(internalize)"
- $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
- $(Verb) $(RM) -f $@
- $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
-else
-$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
- $(LLVMToolDir)/llvm-ar
- $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
- $(Verb) $(RM) -f $@
- $(Verb) $(LArchive) $@ $(ObjectsBC)
-
-endif
-
-clean-local::
-ifneq ($(strip $(LibName.BCA)),)
- -$(Verb) $(RM) -f $(LibName.BCA)
-endif
-
-ifdef BYTECODE_DESTINATION
-BytecodeDestDir := $(BYTECODE_DESTINATION)
-else
-BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
-endif
-
-DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
-
-install-bytecode-local:: $(DestBytecodeLib)
-
-ifdef NO_INSTALL
-install-local::
- $(Echo) Install circumvented with NO_INSTALL
-uninstall-local::
- $(Echo) Uninstall circumvented with NO_INSTALL
-else
-install-local:: $(DestBytecodeLib)
-
-$(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
- $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
- $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
uninstall-local::
- $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
- -$(Verb) $(RM) -f $(DestBytecodeLib)
-endif
+ $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
+ -$(Verb) $(RM) -f $(DestSharedLib)
endif
endif
endif
endif
-ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD GNU))
+ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
ifneq ($(ARCH), Mips)
LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
endif
endif
ifdef CODESIGN_TOOLS
+TOOL_CODESIGN_IDENTITY ?= -
+
$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
$(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
$(StripWarnMsg)
$(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
- $(Verb) codesign -s - $@
+ $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
else
$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(ToolAliasBuildPath): $(ToolBuildPath)
$(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
$(Verb) $(RM) -f $(ToolAliasBuildPath)
- $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
+ $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
$(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
$(StripWarnMsg)
endif
else
ToolBinDir = $(DESTDIR)$(PROJ_bindir)
endif
-DestTool = $(ToolBinDir)/$(TOOLEXENAME)
+DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
install-local:: $(DestTool)
# TOOLALIAS install.
ifdef TOOLALIAS
-DestToolAlias = $(ToolBinDir)/$(TOOLALIAS)$(EXEEXT)
+DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
install-local:: $(DestToolAlias)
$(DestToolAlias): $(DestTool)
$(Echo) Installing $(BuildMode) $(DestToolAlias)
$(Verb) $(RM) -f $(DestToolAlias)
- $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
+ $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
DISABLE_AUTO_DEPENDENCIES=1
endif
+COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
+
# Provide rule sets for when dependency generation is enabled
ifndef DISABLE_AUTO_DEPENDENCIES
DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
-$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
+$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
$(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
-$(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
+$(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
$(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
-$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
+$(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
-$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
+$(ObjDir)/%.o: %.c $(COMPILE_DEPS)
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
-$(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
+$(ObjDir)/%.o: %.m $(COMPILE_DEPS)
$(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
-#---------------------------------------------------------
-# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
-#---------------------------------------------------------
-
-BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
- -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
-
-# If the build succeeded, move the dependency file over, otherwise
-# remove it.
-BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
- else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
-
-$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
- $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
- $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
- $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
- $(BC_DEPEND_MOVEFILE)
-
-$(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
- $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
- $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
- $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
- $(BC_DEPEND_MOVEFILE)
-
-$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
- $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
- $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
- $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
- $(BC_DEPEND_MOVEFILE)
-
-$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
- $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
- $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
- $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
- $(BC_DEPEND_MOVEFILE)
-
-$(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
- $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
- $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
- $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
- $(BC_DEPEND_MOVEFILE)
-
# Provide alternate rule sets if dependencies are disabled
else
-$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
$(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
$(Compile.CXX) $< -o $@
-$(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
$(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
$(Compile.CXX) $< -o $@
-$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
$(Compile.CXX) $< -o $@
-$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.o: %.c $(COMPILE_DEPS)
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(Compile.C) $< -o $@
-$(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.o: %.m $(COMPILE_DEPS)
$(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
$(Compile.C) $< -o $@
-
-$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
- $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
- $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
-
-$(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
- $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
- $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
-
-$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
- $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
- $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
-
-$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
- $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
- $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
-
-$(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
- $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
- $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
-
endif
## Rules for building preprocessed (.i/.ii) outputs.
-$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+$(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
$(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
-$(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
+$(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
$(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
-$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+$(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
$(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
$(Verb) $(Preprocess.CXX) $< -o $@
-$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+$(BuildMode)/%.i: %.c $(COMPILE_DEPS)
$(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
$(Verb) $(Preprocess.C) $< -o $@
-$(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
+$(BuildMode)/%.i: %.m $(COMPILE_DEPS)
$(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
$(Verb) $(Preprocess.C) $< -o $@
-$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
$(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
$(Compile.CXX) $< -o $@ -S
-$(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
$(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
$(Compile.CXX) $< -o $@ -S
-$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
$(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
$(Compile.CXX) $< -o $@ -S
-$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.s: %.c $(COMPILE_DEPS)
$(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
$(Compile.C) $< -o $@ -S
-$(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
+$(ObjDir)/%.s: %.m $(COMPILE_DEPS)
$(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
$(Compile.C) $< -o $@ -S
-
-# make the C and C++ compilers strip debug info out of bytecode libraries.
-ifdef DEBUG_RUNTIME
-$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
- $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
- $(Verb) $(LOPT) $< -std-compile-opts -o $@
-else
-$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
- $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
- $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
-endif
-
-
-#---------------------------------------------------------
-# Provide rule to build .bc files from .ll sources,
-# regardless of dependencies
-#---------------------------------------------------------
-$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
- $(Echo) "Compiling $*.ll for $(BuildMode) build"
- $(Verb) $(LLVMAS) $< -f -o $@
-
###############################################################################
# TABLEGEN: Provide rules for running tblgen to produce *.inc files
###############################################################################
$(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
$(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
$(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
- $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
+ $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
# All .inc.tmp files depend on the .td files.
$(INCTMPFiles) : $(TDFiles)
$(Echo) "Building $(<F) disassembly tables with tblgen"
$(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
-$(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
-$(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
- $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
- $(Verb) $(LLVMTableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
-
$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
-# Include bitcode dependency files if using bitcode libraries
-ifdef BYTECODE_LIBRARY
-DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
-endif
-
-include $(DependFiles) ""
endif
# CHECK: Running the test suite
###############################################################################
-check::
+check:: all
$(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
$(EchoCmd) Running test suite ; \