1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
10 # This file is included by all of the LLVM makefiles. For details on how to use
11 # it properly, please see the document MakefileGuide.html in the docs directory.
13 #===-----------------------------------------------------------------------====#
15 ################################################################################
16 # TARGETS: Define standard targets that can be invoked
17 ################################################################################
19 #--------------------------------------------------------------------
20 # Define the various target sets
21 #--------------------------------------------------------------------
22 RecursiveTargets := all clean clean-all install uninstall install-bytecode \
24 LocalTargets := all-local clean-local clean-all-local check-local \
25 install-local printvars uninstall-local \
26 install-bytecode-local
27 TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
29 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30 InternalTargets := preconditions distdir dist-hook
32 ################################################################################
33 # INITIALIZATION: Basic things the makefile needs
34 ################################################################################
36 #--------------------------------------------------------------------
37 # Set the VPATH so that we can find source files.
38 #--------------------------------------------------------------------
41 #--------------------------------------------------------------------
42 # Reset the list of suffixes we know how to build.
43 #--------------------------------------------------------------------
45 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .td .ps .dot .m .mm
46 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
48 #--------------------------------------------------------------------
49 # Mark all of these targets as phony to avoid implicit rule search
50 #--------------------------------------------------------------------
51 .PHONY: $(UserTargets) $(InternalTargets)
53 #--------------------------------------------------------------------
54 # Make sure all the user-target rules are double colon rules and
55 # they are defined first.
56 #--------------------------------------------------------------------
60 #------------------------------------------------------------------------
61 # LLVMBuild Integration
62 #------------------------------------------------------------------------
64 # We use llvm-build to generate all the data required by the Makefile based
65 # build system in one swoop:
67 # - We generate a file (a Makefile fragment) in the object root which contains
68 # all the definitions that are required by Makefiles across the entire
71 # - We generate the library table used by llvm-config.
73 # - We generate the dependencies for the Makefile fragment, so that we will
74 # automatically reconfigure outselves.
76 # The path to the llvm-build tool itself.
77 LLVMBuildTool := $(PROJ_SRC_ROOT)/utils/llvm-build/llvm-build
79 # The files we are going to generate using llvm-build.
80 LLVMBuildMakeFrag := $(PROJ_OBJ_ROOT)/Makefile.llvmbuild
81 LLVMConfigLibraryDependenciesInc := \
82 $(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc
84 # This is for temporary backwards compatibility.
85 ifndef TARGET_NATIVE_ARCH
86 TARGET_NATIVE_ARCH := $(ARCH)
89 # The rule to create the LLVMBuild Makefile fragment as well as the llvm-config
92 # Note that this target gets its real dependencies generated for us by
95 # We include a dependency on this Makefile to ensure that changes to the
96 # generation command get picked up.
97 $(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \
98 $(PROJ_OBJ_ROOT)/Makefile.config
99 $(Echo) Constructing LLVMBuild project information.
100 $(Verb)$(PYTHON) $(LLVMBuildTool) \
101 --native-target "$(TARGET_NATIVE_ARCH)" \
102 --enable-targets "$(TARGETS_TO_BUILD)" \
103 --enable-optional-components "$(OPTIONAL_COMPONENTS)" \
104 --write-library-table $(LLVMConfigLibraryDependenciesInc) \
105 --write-make-fragment $(LLVMBuildMakeFrag)
107 # For completeness, let Make know how the extra files are generated.
108 $(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrag)
110 # Include the generated Makefile fragment.
112 # We currently only include the dependencies for the fragment itself if we are
113 # at the top-level. Otherwise, recursive invocations would ends up doing
114 # substantially more redundant stat'ing.
116 # This means that we won't properly regenerate things for developers used to
117 # building from a subdirectory, but that is always somewhat unreliable.
119 LLVMBUILD_INCLUDE_DEPENDENCIES := 1
121 # Clean the generated makefile fragment at the top-level.
123 -$(Verb) $(RM) -f $(LLVMBuildMakeFrag)
125 -include $(LLVMBuildMakeFrag)
127 ################################################################################
128 # PRECONDITIONS: that which must be built/checked first
129 ################################################################################
131 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
132 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
133 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
134 ConfigureScript := $(PROJ_SRC_ROOT)/configure
135 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
136 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
137 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
138 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
139 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
140 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
141 ifneq ($(MakefileCommonIn),)
142 PreConditions += $(MakefileCommon)
145 ifneq ($(MakefileConfigIn),)
146 PreConditions += $(MakefileConfig)
149 preconditions: $(PreConditions)
151 #------------------------------------------------------------------------
152 # Make sure the BUILT_SOURCES are built first
153 #------------------------------------------------------------------------
154 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
157 ifneq ($(strip $(BUILT_SOURCES)),)
158 -$(Verb) $(RM) -f $(BUILT_SOURCES)
161 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
163 $(Verb) if test -x config.status ; then \
164 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
165 $(MKDIR) .spotless.save ; \
166 $(MV) config.status .spotless.save ; \
167 $(MV) mklib .spotless.save ; \
168 $(MV) projects .spotless.save ; \
170 $(MV) .spotless.save/config.status . ; \
171 $(MV) .spotless.save/mklib . ; \
172 $(MV) .spotless.save/projects . ; \
173 $(RM) -rf .spotless.save ; \
174 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
175 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
176 $(ConfigStatusScript) ; \
178 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
182 $(EchoCmd) "spotless target not supported for objdir == srcdir"
185 $(BUILT_SOURCES) : $(ObjMakefiles)
187 #------------------------------------------------------------------------
188 # Make sure we're not using a stale configuration
189 #------------------------------------------------------------------------
191 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
192 $(Verb) cd $(PROJ_OBJ_ROOT) && \
193 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
194 $(ConfigStatusScript)
196 .PRECIOUS: $(ConfigStatusScript)
197 $(ConfigStatusScript): $(ConfigureScript)
198 $(Echo) Reconfiguring with $<
199 $(Verb) cd $(PROJ_OBJ_ROOT) && \
200 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
201 $(ConfigStatusScript)
203 #------------------------------------------------------------------------
204 # Make sure the configuration makefile is up to date
205 #------------------------------------------------------------------------
206 ifneq ($(MakefileConfigIn),)
207 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
208 $(Echo) Regenerating $@
209 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
212 ifneq ($(MakefileCommonIn),)
213 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
214 $(Echo) Regenerating $@
215 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
218 #------------------------------------------------------------------------
219 # If the Makefile in the source tree has been updated, copy it over into the
220 # build tree. But, only do this if the source and object makefiles differ
221 #------------------------------------------------------------------------
223 PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
226 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
228 Makefile: $(PROJ_MAKEFILE) $(ExtraMakefiles)
229 $(Echo) "Updating Makefile"
230 $(Verb) $(MKDIR) $(@D)
231 $(Verb) $(CP) -f $< $@
233 # Copy the Makefile.* files unless we're in the root directory which avoids
234 # the copying of Makefile.config.in or other things that should be explicitly
236 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
238 *Makefile.rules) ;; \
240 *) $(EchoCmd) "Updating $(@F)" ; \
247 #------------------------------------------------------------------------
248 # Set up the basic dependencies
249 #------------------------------------------------------------------------
250 $(UserTargets):: $(PreConditions)
254 clean-all:: clean-local clean-all-local
255 install:: install-local
256 uninstall:: uninstall-local
257 install-local:: all-local
258 install-bytecode:: install-bytecode-local
260 ###############################################################################
261 # VARIABLES: Set up various variables based on configuration data
262 ###############################################################################
264 # Variable for if this make is for a "cleaning" target
265 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
269 #--------------------------------------------------------------------
270 # Variables derived from configuration we are building
271 #--------------------------------------------------------------------
274 ifeq ($(ENABLE_OPTIMIZED),1)
276 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
277 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
278 OmitFramePointer := -fomit-frame-pointer
281 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
282 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
283 LD.Flags += $(OPTIMIZE_OPTION)
285 BuildMode := $(BuildMode)+Debug
291 ifdef NO_DEBUG_SYMBOLS
292 BuildMode := Unoptimized
298 ifeq ($(ENABLE_SPLIT_DWARF), 1)
299 CXX.Flags += -gsplit-dwarf
300 C.Flags += -gsplit-dwarf
309 ifeq ($(ENABLE_LIBCPP),1)
310 CXX.Flags += -stdlib=libc++
311 LD.Flags += -stdlib=libc++
314 ifeq ($(ENABLE_CXX11),1)
315 CXX.Flags += -std=c++11
318 ifeq ($(ENABLE_WERROR),1)
323 ifeq ($(ENABLE_PROFILING),1)
324 BuildMode := $(BuildMode)+Profile
325 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
326 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
327 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg
331 ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
332 CXX.Flags += -fvisibility-inlines-hidden
335 ifdef ENABLE_EXPENSIVE_CHECKS
336 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
337 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
341 # IF REQUIRES_EH=1 is specified then don't disable exceptions
343 CXX.Flags += -fno-exceptions
345 # If the library requires EH, it also requires RTTI.
349 ifdef REQUIRES_FRAME_POINTER
350 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
351 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
352 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
355 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
356 ifneq ($(REQUIRES_RTTI), 1)
357 CXX.Flags += -fno-rtti
360 ifeq ($(ENABLE_COVERAGE),1)
361 BuildMode := $(BuildMode)+Coverage
362 CXX.Flags += -ftest-coverage -fprofile-arcs
363 C.Flags += -ftest-coverage -fprofile-arcs
366 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
367 # then disable assertions by defining the appropriate preprocessor symbols.
368 ifeq ($(DISABLE_ASSERTIONS),1)
369 CPP.Defines += -DNDEBUG
371 BuildMode := $(BuildMode)+Asserts
372 CPP.Defines += -D_DEBUG
375 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
376 # configured), then enable expensive checks by defining the
377 # appropriate preprocessor symbols.
378 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
379 BuildMode := $(BuildMode)+Checks
380 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
383 # LOADABLE_MODULE implies several other things so we force them to be
385 ifdef LOADABLE_MODULE
387 LINK_LIBS_IN_SHARED := 1
395 ifeq ($(ENABLE_PIC),1)
396 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
397 # Nothing. Win32 defaults to PIC and warns when given -fPIC
399 ifeq ($(HOST_OS),Darwin)
400 # Common symbols not allowed in dylib files
401 CXX.Flags += -fno-common
402 C.Flags += -fno-common
404 # Linux and others; pass -fPIC
410 ifeq ($(HOST_OS),Darwin)
411 CXX.Flags += -mdynamic-no-pic
412 C.Flags += -mdynamic-no-pic
416 # Support makefile variable to disable any kind of timestamp/non-deterministic
417 # info from being used in the build.
418 ifeq ($(ENABLE_TIMESTAMPS),1)
419 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
421 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
424 ifeq ($(HOST_OS),MingW)
426 CPP.Defines += -D__NO_CTYPE_INLINE
427 ifeq ($(LLVM_CROSS_COMPILING),1)
428 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
430 LD.Flags += -Wl,--allow-multiple-definition
435 CXX.Flags += -Woverloaded-virtual
436 CPP.BaseFlags += $(CPP.Defines)
439 # Make Floating point IEEE compliant on Alpha.
442 CPP.BaseFlags += -mieee
443 ifeq ($(ENABLE_PIC),0)
445 CPP.BaseFlags += -fPIC
448 LD.Flags += -Wl,--no-relax
451 # GNU ld/PECOFF accepts but ignores them below;
455 # FIXME: autoconf should be aware of them.
456 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
457 HAVE_LINK_VERSION_SCRIPT := 0
459 RDYNAMIC := -Wl,--export-all-symbols
462 #--------------------------------------------------------------------
463 # Directory locations
464 #--------------------------------------------------------------------
466 ifeq ($(LLVM_CROSS_COMPILING),1)
467 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
470 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
471 ObjDir := $(ObjRootDir)
472 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
473 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
474 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
475 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
476 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
477 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
479 #--------------------------------------------------------------------
480 # Locations of shared libraries
481 #--------------------------------------------------------------------
484 SharedLibDir := $(LibDir)
485 LLVMSharedLibDir := $(LLVMLibDir)
487 # Win32.DLL prefers to be located on the "PATH" of binaries.
488 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
489 SharedLibDir := $(ToolDir)
490 LLVMSharedLibDir := $(LLVMToolDir)
492 ifeq ($(HOST_OS),Cygwin)
499 #--------------------------------------------------------------------
500 # Full Paths To Compiled Tools and Utilities
501 #--------------------------------------------------------------------
502 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
503 ifdef BUILD_DIRS_ONLY
504 EchoCmd := $(EchoCmd) "(build tools)":
509 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
512 ifeq ($(LLVM_CROSS_COMPILING),1)
513 LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
515 LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
518 ifeq ($(LLVM_CROSS_COMPILING),1)
519 LLVM_CONFIG := $(BuildLLVMToolDir)/llvm-config$(BUILD_EXEEXT)
521 LLVM_CONFIG := $(LLVMToolDir)/llvm-config$(EXEEXT)
524 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
527 LLI := $(LLVMToolDir)/lli$(EXEEXT)
530 LLC := $(LLVMToolDir)/llc$(EXEEXT)
533 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
536 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
539 LLVMLINK := $(LLVMToolDir)/llvm-link$(EXEEXT)
542 #--------------------------------------------------------------------
543 # Adjust to user's request
544 #--------------------------------------------------------------------
546 ifeq ($(HOST_OS),Darwin)
547 ifdef MACOSX_DEPLOYMENT_TARGET
548 DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
550 DARWIN_VERSION := `sw_vers -productVersion`
552 # Strip a number like 10.4.7 to 10.4
553 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/')
554 # Get "4" out of 10.4 for later pieces in the makefile.
555 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/')
557 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
558 SharedLinkOptions := -dynamiclib
559 ifdef DEPLOYMENT_TARGET
560 SharedLinkOptions += $(DEPLOYMENT_TARGET)
563 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
567 SharedLinkOptions=-shared
570 ifeq ($(TARGET_OS),Darwin)
571 ifdef DEPLOYMENT_TARGET
572 TargetCommonOpts += $(DEPLOYMENT_TARGET)
575 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
581 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
582 ifneq ($(HOST_OS),Darwin)
583 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
595 # Adjust settings for verbose mode
598 AR.Flags += >/dev/null 2>/dev/null
599 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
601 ConfigureScriptFLAGS :=
604 # By default, strip symbol information from executable
606 Strip := $(PLATFORMSTRIPOPTS)
607 StripWarnMsg := "(without symbols)"
608 Install.StripFlag += -s
611 # By default, strip dead symbols at link time
612 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
613 ifneq ($(HOST_OS),Darwin)
614 ifneq ($(HOST_ARCH),Mips)
615 CXX.Flags += -ffunction-sections -fdata-sections
620 ifeq ($(HOST_OS),Darwin)
621 LD.Flags += -Wl,-dead_strip
623 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
624 LD.Flags += -Wl,--gc-sections
629 # Adjust linker flags for building an executable
630 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
631 ifndef TOOL_NO_EXPORTS
632 LD.Flags += $(RDYNAMIC)
634 ifneq ($(HOST_OS), Darwin)
636 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
639 ifneq ($(DARWIN_MAJVERS),4)
640 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
643 TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
644 LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
650 #----------------------------------------------------------
651 # Options To Invoke Tools
652 #----------------------------------------------------------
654 ifdef EXTRA_LD_OPTIONS
655 LD.Flags += $(EXTRA_LD_OPTIONS)
659 CompileCommonOpts += -pedantic -Wno-long-long
661 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
662 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
663 $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
664 $(NO_MISSING_FIELD_INITIALIZERS)
665 # Enable cast-qual for C++; the workaround is to use const_cast.
666 CXX.Flags += -Wcast-qual
668 ifeq ($(HOST_OS),HP-UX)
669 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
672 # If we are building a universal binary on Mac OS/X, pass extra options. This
673 # is useful to people that want to link the LLVM libraries into their universal
676 # The following can be optionally specified:
677 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
678 # For Mac OS/X 10.4 Intel machines, the traditional one is:
679 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
680 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
681 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
684 ifndef UNIVERSAL_ARCH
685 UNIVERSAL_ARCH := i386 ppc
687 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
688 TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
689 ifdef UNIVERSAL_SDK_PATH
690 TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
693 # Building universal cannot compute dependencies automatically.
694 DISABLE_AUTO_DEPENDENCIES=1
696 ifeq ($(TARGET_OS),Darwin)
697 ifeq ($(ARCH),x86_64)
698 TargetCommonOpts = -m64
701 TargetCommonOpts = -m32
707 ifeq ($(HOST_OS),SunOS)
708 CPP.BaseFlags += -include llvm/Support/Solaris.h
711 ifeq ($(HOST_OS),AuroraUX)
712 CPP.BaseFlags += -include llvm/Support/Solaris.h
713 endif # !HOST_OS - AuroraUX.
715 # On Windows, SharedLibDir != LibDir. The order is important.
716 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
717 LD.Flags += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
719 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
722 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
723 # All -I flags should go here, so that they don't confuse llvm-config.
724 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
725 $(patsubst %,-I%/include,\
726 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
727 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
730 ifeq ($(INCLUDE_BUILD_DIR),1)
731 CPP.Flags += -I$(ObjDir)
734 # SHOW_DIAGNOSTICS support.
735 ifeq ($(SHOW_DIAGNOSTICS),1)
736 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
737 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
742 Compile.C = $(Compile.Wrapper) \
743 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
744 $(TargetCommonOpts) $(CompileCommonOpts) -c
745 Compile.CXX = $(Compile.Wrapper) \
746 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
747 $(TargetCommonOpts) $(CompileCommonOpts) -c
748 Preprocess.CXX= $(Compile.Wrapper) \
749 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
750 $(CompileCommonOpts) $(CXX.Flags) -E
751 Link = $(Compile.Wrapper) \
752 $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
753 $(TargetCommonOpts) $(Strip)
755 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
756 $(TargetCommonOpts) $(CompileCommonOpts) -E
758 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
759 ScriptInstall = $(INSTALL) -m 0755
760 DataInstall = $(INSTALL) -m 0644
762 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
763 # paths. In this case, the SYSPATH function (defined in
764 # Makefile.config) transforms Unix paths into Windows paths.
765 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
766 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
767 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
768 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
769 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
771 Archive = $(AR) $(AR.Flags)
780 #----------------------------------------------------------
781 # Get the list of source files and compute object file
783 #----------------------------------------------------------
786 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
787 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
789 Sources := $(SOURCES)
793 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
796 BaseNameSources := $(sort $(basename $(Sources)))
797 SourceDirs := $(sort $(dir $(Sources)))
799 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
800 ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
802 #----------------------------------------------------------
803 # For Mingw MSYS bash and Python/w32:
805 # $(ECHOPATH) prints DOSish pathstring.
806 # ex) $(ECHOPATH) /include/sys/types.h
807 # --> C:/mingw/include/sys/types.h
808 # built-in "echo" does not transform path to DOSish path.
810 # FIXME: It would not be needed when MSYS's python
812 #----------------------------------------------------------
814 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
815 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
817 ECHOPATH := $(Verb)$(ECHO)
820 ###############################################################################
821 # DIRECTORIES: Handle recursive descent of directory structure
822 ###############################################################################
824 #---------------------------------------------------------
825 # Provide rules to make install dirs. This must be early
826 # in the file so they get built before dependencies
827 #---------------------------------------------------------
829 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
832 # To create other directories, as needed, and timestamp their creation
834 $(Verb) $(MKDIR) $* > /dev/null
835 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
837 .PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
838 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
840 #---------------------------------------------------------
841 # Collect the object directories (as there may be more
842 # than one if the source code is spread across
844 #---------------------------------------------------------
846 OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
847 .PRECIOUS: $(OBJECT_DIRS)
849 #---------------------------------------------------------
850 # Handle the DIRS options for sequential construction
851 #---------------------------------------------------------
857 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
858 $(RecursiveTargets)::
859 $(Verb) for dir in $(DIRS); do \
860 if ([ ! -f $$dir/Makefile ] || \
861 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
863 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
865 ($(MAKE) -C $$dir $@ ) || exit 1; \
868 $(RecursiveTargets)::
869 $(Verb) for dir in $(DIRS); do \
870 ($(MAKE) -C $$dir $@ ) || exit 1; \
876 #---------------------------------------------------------
877 # Handle the EXPERIMENTAL_DIRS options ensuring success
878 # after each directory is built.
879 #---------------------------------------------------------
880 ifdef EXPERIMENTAL_DIRS
881 $(RecursiveTargets)::
882 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
883 if ([ ! -f $$dir/Makefile ] || \
884 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
886 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
888 ($(MAKE) -C $$dir $@ ) || exit 0; \
892 #-----------------------------------------------------------
893 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
894 #-----------------------------------------------------------
895 ifdef OPTIONAL_PARALLEL_DIRS
896 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
899 #-----------------------------------------------------------
900 # Handle the PARALLEL_DIRS options for parallel construction
901 #-----------------------------------------------------------
904 SubDirs += $(PARALLEL_DIRS)
906 # Unfortunately, this list must be maintained if new recursive targets are added
907 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
908 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
909 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
910 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
911 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
912 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
913 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
915 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
919 SD=$(PROJ_SRC_DIR)/$(@D); \
921 if [ ! -f $$SD/Makefile ]; then \
923 DD=$(notdir $(@D)); \
925 if ([ ! -f $$DD/Makefile ] || \
926 command test $$DD/Makefile -ot \
927 $$SD/Makefile ); then \
929 $(CP) $$SD/Makefile $$DD/Makefile; \
931 $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
934 #---------------------------------------------------------
935 # Handle the OPTIONAL_DIRS options for directores that may
937 #---------------------------------------------------------
940 SubDirs += $(OPTIONAL_DIRS)
942 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
943 $(RecursiveTargets)::
944 $(Verb) for dir in $(OPTIONAL_DIRS); do \
945 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
946 if ([ ! -f $$dir/Makefile ] || \
947 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
949 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
951 ($(MAKE) -C$$dir $@ ) || exit 1; \
955 $(RecursiveTargets)::
956 $(Verb) for dir in $(OPTIONAL_DIRS); do \
957 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
958 ($(MAKE) -C$$dir $@ ) || exit 1; \
964 #---------------------------------------------------------
965 # Handle the CONFIG_FILES options
966 #---------------------------------------------------------
971 $(Echo) Install circumvented with NO_INSTALL
973 $(Echo) UnInstall circumvented with NO_INSTALL
975 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
976 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
977 $(Verb)for file in $(CONFIG_FILES); do \
978 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
979 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
980 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
981 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
983 $(ECHO) Error: cannot find config file $${file}. ; \
988 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
989 $(Verb)for file in $(CONFIG_FILES); do \
990 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
996 ###############################################################################
997 # Set up variables for building libraries
998 ###############################################################################
1000 #---------------------------------------------------------
1001 # Define various command line options pertaining to the
1002 # libraries needed when linking. There are "Proj" libs
1003 # (defined by the user's project) and "LLVM" libs (defined
1004 # by the LLVM project).
1005 #---------------------------------------------------------
1008 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1009 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
1010 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1011 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1015 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1016 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1017 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1018 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1021 # Loadable module for Win32 requires all symbols resolved for linking.
1022 # Then all symbols in LLVM.dll will be available.
1023 ifeq ($(ENABLE_SHARED),1)
1024 ifdef LOADABLE_MODULE
1025 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1026 LINK_COMPONENTS += all
1031 ifndef IS_CLEANING_TARGET
1032 ifdef LINK_COMPONENTS
1034 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
1035 # clean in tools, then do a make in tools (instead of at the top level).
1037 @echo "*** llvm-config doesn't exist - rebuilding it."
1038 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1040 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1042 ifeq ($(ENABLE_SHARED), 1)
1043 # We can take the "auto-import" feature to get rid of using dllimport.
1044 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1045 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1048 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1049 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1052 ifndef NO_LLVM_CONFIG
1053 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1054 ifeq ($(LLVMConfigLibs),Error)
1055 $(error llvm-config --libs failed)
1057 LLVMLibsOptions += $(LLVMConfigLibs)
1058 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1059 ifeq ($(LLVMConfigLibfiles),Error)
1060 $(error llvm-config --libfiles failed)
1062 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1069 # Set up the library exports file.
1070 ifdef EXPORTED_SYMBOL_FILE
1072 # First, set up the native export file, which may differ from the source
1075 ifeq ($(HOST_OS),Darwin)
1076 # Darwin convention prefixes symbols with underscores.
1077 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1078 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1079 $(Verb) sed -e 's/^/_/' < $< > $@
1081 -$(Verb) $(RM) -f $(NativeExportsFile)
1083 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1084 # Gold and BFD ld require a version script rather than a plain list.
1085 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1086 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1087 $(Verb) echo "{" > $@
1088 $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || :
1089 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
1090 ifneq ($(HOST_OS),OpenBSD)
1091 $(Verb) echo " local: *;" >> $@
1093 $(Verb) echo "};" >> $@
1095 -$(Verb) $(RM) -f $(NativeExportsFile)
1097 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1098 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1099 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1100 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1101 $(Echo) Generating $(notdir $@)
1102 $(Verb) $(ECHO) "EXPORTS" > $@
1103 $(Verb) $(CAT) $< >> $@
1105 -$(Verb) $(RM) -f $(NativeExportsFile)
1107 # Default behavior: just use the exports file verbatim.
1108 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1113 # Now add the linker command-line options to use the native export file.
1116 ifeq ($(HOST_OS),Darwin)
1117 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1120 # gold, bfd ld, etc.
1121 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1122 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1126 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1127 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1128 SharedLinkOptions += $(NativeExportsFile)
1133 ###############################################################################
1134 # Library Build Rules: Four ways to build a library
1135 ###############################################################################
1137 # if we're building a library ...
1140 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1141 LIBRARYNAME := $(strip $(LIBRARYNAME))
1142 ifdef LOADABLE_MODULE
1143 BaseLibName.A := $(LIBRARYNAME).a
1144 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1146 BaseLibName.A := lib$(LIBRARYNAME).a
1147 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1149 LibName.A := $(LibDir)/$(BaseLibName.A)
1150 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1151 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1153 #---------------------------------------------------------
1154 # Shared Library Targets:
1155 # If the user asked for a shared library to be built
1156 # with the SHARED_LIBRARY variable, then we provide
1157 # targets for building them.
1158 #---------------------------------------------------------
1159 ifdef SHARED_LIBRARY
1161 all-local:: $(LibName.SO)
1163 ifdef EXPORTED_SYMBOL_FILE
1164 $(LibName.SO): $(NativeExportsFile)
1167 ifdef LINK_LIBS_IN_SHARED
1168 ifdef LOADABLE_MODULE
1169 SharedLibKindMessage := "Loadable Module"
1170 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1172 SharedLibKindMessage := "Shared Library"
1174 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1175 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1177 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1178 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1180 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1181 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1182 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1186 ifneq ($(strip $(LibName.SO)),)
1187 -$(Verb) $(RM) -f $(LibName.SO)
1192 $(Echo) Install circumvented with NO_INSTALL
1194 $(Echo) Uninstall circumvented with NO_INSTALL
1197 # Win32.DLL prefers to be located on the "PATH" of binaries.
1198 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1199 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1201 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1203 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1205 install-local:: $(DestSharedLib)
1207 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1208 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1209 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1212 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1213 -$(Verb) $(RM) -f $(DestSharedLib)
1217 #---------------------------------------------------------
1219 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1220 # building an archive.
1221 #---------------------------------------------------------
1222 ifndef NO_BUILD_ARCHIVE
1223 ifndef BUILD_ARCHIVE
1224 ifndef LOADABLE_MODULE
1230 #---------------------------------------------------------
1231 # Archive Library Targets:
1232 # If the user wanted a regular archive library built,
1233 # then we provide targets for building them.
1234 #---------------------------------------------------------
1237 all-local:: $(LibName.A)
1239 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1240 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1241 -$(Verb) $(RM) -f $@
1242 $(Verb) $(Archive) $@ $(ObjectsO)
1243 $(Verb) $(Ranlib) $@
1246 ifneq ($(strip $(LibName.A)),)
1247 -$(Verb) $(RM) -f $(LibName.A)
1252 $(Echo) Install circumvented with NO_INSTALL
1254 $(Echo) Uninstall circumvented with NO_INSTALL
1256 ifdef NO_INSTALL_ARCHIVES
1258 $(Echo) Install circumvented with NO_INSTALL
1260 $(Echo) Uninstall circumvented with NO_INSTALL
1262 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1264 install-local:: $(DestArchiveLib)
1266 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1267 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1268 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1269 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1272 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1273 -$(Verb) $(RM) -f $(DestArchiveLib)
1281 ###############################################################################
1282 # Tool Build Rules: Build executable tool based on TOOLNAME option
1283 ###############################################################################
1287 #---------------------------------------------------------
1288 # Set up variables for building a tool.
1289 #---------------------------------------------------------
1290 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1292 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1294 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1297 # TOOLALIAS is a name to symlink (or copy) the tool to.
1300 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1302 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1306 #---------------------------------------------------------
1308 #---------------------------------------------------------
1310 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1311 # not exporting all of the weak symbols from the binary. This reduces dyld
1312 # startup time by 4x on darwin in some cases.
1313 ifdef TOOL_NO_EXPORTS
1314 ifeq ($(HOST_OS),Darwin)
1316 # Tiger tools don't support this.
1317 ifneq ($(DARWIN_MAJVERS),4)
1318 LD.Flags += -Wl,-exported_symbol,_main
1322 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1323 ifneq ($(ARCH), Mips)
1324 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1329 #---------------------------------------------------------
1330 # Tool Order File Support
1331 #---------------------------------------------------------
1333 ifeq ($(HOST_OS),Darwin)
1334 ifdef TOOL_ORDER_FILE
1336 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1341 #---------------------------------------------------------
1342 # Tool Version Info Support
1343 #---------------------------------------------------------
1345 ifeq ($(HOST_OS),Darwin)
1346 ifdef TOOL_INFO_PLIST
1348 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1350 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1352 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1353 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1354 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1355 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1356 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1357 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1363 #---------------------------------------------------------
1364 # Provide targets for building the tools
1365 #---------------------------------------------------------
1366 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1369 ifneq ($(strip $(ToolBuildPath)),)
1370 -$(Verb) $(RM) -f $(ToolBuildPath)
1372 ifneq ($(strip $(ToolAliasBuildPath)),)
1373 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1377 $(ToolBuildPath): $(ExmplDir)/.dir
1379 $(ToolBuildPath): $(ToolDir)/.dir
1382 ifdef CODESIGN_TOOLS
1383 TOOL_CODESIGN_IDENTITY ?= -
1385 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1386 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1387 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1388 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1389 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1391 $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1392 $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1394 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1395 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1396 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1397 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1398 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1402 ifneq ($(strip $(ToolAliasBuildPath)),)
1403 $(ToolAliasBuildPath): $(ToolBuildPath)
1404 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1405 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1406 $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1407 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1413 $(Echo) Install circumvented with NO_INSTALL
1415 $(Echo) Uninstall circumvented with NO_INSTALL
1419 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1421 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1423 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1425 install-local:: $(DestTool)
1427 $(DestTool): $(ToolBuildPath)
1428 $(Echo) Installing $(BuildMode) $(DestTool)
1429 $(Verb) $(MKDIR) $(ToolBinDir)
1430 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1433 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1434 -$(Verb) $(RM) -f $(DestTool)
1436 # TOOLALIAS install.
1438 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1440 install-local:: $(DestToolAlias)
1442 $(DestToolAlias): $(DestTool)
1443 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1444 $(Verb) $(RM) -f $(DestToolAlias)
1445 $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1448 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1449 -$(Verb) $(RM) -f $(DestToolAlias)
1455 ###############################################################################
1456 # Object Build Rules: Build object files based on sources
1457 ###############################################################################
1459 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1460 ifeq ($(HOST_OS),HP-UX)
1461 DISABLE_AUTO_DEPENDENCIES=1
1464 COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1466 # Provide rule sets for when dependency generation is enabled
1467 ifndef DISABLE_AUTO_DEPENDENCIES
1469 #---------------------------------------------------------
1470 # Create .o files in the ObjDir directory from the .cpp and .c files...
1471 #---------------------------------------------------------
1473 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1474 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1476 # If the build succeeded, move the dependency file over, otherwise
1478 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1479 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1481 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1482 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1483 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1486 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1487 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1488 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1491 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1492 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1493 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1496 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1497 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1498 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1501 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1502 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1503 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1506 # Provide alternate rule sets if dependencies are disabled
1509 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1510 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1511 $(Compile.CXX) $< -o $@
1513 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1514 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1515 $(Compile.CXX) $< -o $@
1517 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1518 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1519 $(Compile.CXX) $< -o $@
1521 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1522 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1523 $(Compile.C) $< -o $@
1525 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1526 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1527 $(Compile.C) $< -o $@
1531 ## Rules for building preprocessed (.i/.ii) outputs.
1532 $(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1533 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1534 $(Verb) $(Preprocess.CXX) $< -o $@
1536 $(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1537 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1538 $(Verb) $(Preprocess.CXX) $< -o $@
1540 $(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1541 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1542 $(Verb) $(Preprocess.CXX) $< -o $@
1544 $(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1545 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1546 $(Verb) $(Preprocess.C) $< -o $@
1548 $(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1549 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1550 $(Verb) $(Preprocess.C) $< -o $@
1553 $(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1554 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1555 $(Compile.CXX) $< -o $@ -S
1557 $(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1558 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1559 $(Compile.CXX) $< -o $@ -S
1561 $(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1562 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1563 $(Compile.CXX) $< -o $@ -S
1565 $(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1566 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1567 $(Compile.C) $< -o $@ -S
1569 $(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1570 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1571 $(Compile.C) $< -o $@ -S
1573 ###############################################################################
1574 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1575 ###############################################################################
1578 TABLEGEN_INC_FILES_COMMON = 1
1581 ifdef TABLEGEN_INC_FILES_COMMON
1583 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1584 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1585 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1587 # INCFiles rule: All of the tblgen generated files are emitted to
1588 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1589 # us to only "touch" the real file if the contents of it change. IOW, if
1590 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1591 # dependencies of the .inc files are, unless the contents of the .inc file
1593 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1594 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1596 endif # TABLEGEN_INC_FILES_COMMON
1600 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1601 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1602 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1603 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1604 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1605 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1606 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1608 # All .inc.tmp files depend on the .td files.
1609 $(INCTMPFiles) : $(TDFiles)
1611 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1612 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1613 $(Echo) "Building $(<F) register info implementation with tblgen"
1614 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1616 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1617 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1618 $(Echo) "Building $(<F) instruction information with tblgen"
1619 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1621 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1622 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1623 $(Echo) "Building $(<F) assembly writer with tblgen"
1624 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1626 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1627 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1628 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1629 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1631 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1632 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1633 $(Echo) "Building $(<F) assembly matcher with tblgen"
1634 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1636 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1637 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1638 $(Echo) "Building $(<F) MC code emitter with tblgen"
1639 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1641 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1642 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1643 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1644 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1646 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1647 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1648 $(Echo) "Building $(<F) code emitter with tblgen"
1649 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1651 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1652 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1653 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1654 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1656 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1657 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1658 $(Echo) "Building $(<F) disassembly tables with tblgen"
1659 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1661 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1662 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1663 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1664 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1666 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1667 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1668 $(Echo) "Building $(<F) subtarget information with tblgen"
1669 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1671 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1672 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1673 $(Echo) "Building $(<F) calling convention information with tblgen"
1674 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1676 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1677 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1678 $(Echo) "Building $(<F) intrinsics information with tblgen"
1679 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1681 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1682 $(Echo) "Building $(<F) decoder tables with tblgen"
1683 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1685 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1686 $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1687 $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1690 -$(Verb) $(RM) -f $(INCFiles)
1694 ###############################################################################
1695 # OTHER RULES: Other rules needed
1696 ###############################################################################
1698 # To create postscript files from dot files...
1699 ifneq ($(DOT),false)
1701 $(DOT) -Tps < $< > $@
1704 $(Echo) "Cannot build $@: The program dot is not installed"
1707 # This rules ensures that header files that are removed still have a rule for
1708 # which they can be "generated." This allows make to ignore them and
1709 # reproduce the dependency lists.
1713 # Define clean-local to clean the current directory. Note that this uses a
1714 # very conservative approach ensuring that empty variables do not cause
1715 # errors or disastrous removal.
1717 ifneq ($(strip $(ObjRootDir)),)
1718 -$(Verb) $(RM) -rf $(ObjRootDir)
1720 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1721 -$(Verb) $(RM) -f *$(SHLIBEXT)
1725 -$(Verb) $(RM) -rf Debug Release Profile
1728 ###############################################################################
1729 # DEPENDENCIES: Include the dependency files if we should
1730 ###############################################################################
1731 ifndef DISABLE_AUTO_DEPENDENCIES
1733 # If its not one of the cleaning targets
1734 ifndef IS_CLEANING_TARGET
1736 # Get the list of dependency files
1737 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1738 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1740 -include $(DependFiles) ""
1746 ###############################################################################
1747 # CHECK: Running the test suite
1748 ###############################################################################
1751 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1752 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1753 $(EchoCmd) Running test suite ; \
1754 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1755 TESTSUITE=$(TESTSUITE) ; \
1757 $(EchoCmd) No Makefile in test directory ; \
1760 $(EchoCmd) No test directory ; \
1763 # An alias dating from when both lit and DejaGNU test runners were used.
1767 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1768 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1769 $(EchoCmd) Running test suite ; \
1770 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1772 $(EchoCmd) No Makefile in test directory ; \
1775 $(EchoCmd) No test directory ; \
1778 ###############################################################################
1779 # UNITTESTS: Running the unittests test suite
1780 ###############################################################################
1783 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1784 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1785 $(EchoCmd) Running unittests test suite ; \
1786 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1788 $(EchoCmd) No Makefile in unittests directory ; \
1791 $(EchoCmd) No unittests directory ; \
1794 ###############################################################################
1795 # DISTRIBUTION: Handle construction of a distribution tarball
1796 ###############################################################################
1798 #------------------------------------------------------------------------
1799 # Define distribution related variables
1800 #------------------------------------------------------------------------
1801 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1802 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1803 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1804 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1805 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1806 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1807 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1808 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1809 Makefile.config.in configure autoconf
1810 DistOther := $(notdir $(wildcard \
1811 $(PROJ_SRC_DIR)/*.h \
1812 $(PROJ_SRC_DIR)/*.td \
1813 $(PROJ_SRC_DIR)/*.def \
1814 $(PROJ_SRC_DIR)/*.ll \
1815 $(PROJ_SRC_DIR)/*.in))
1816 DistSubDirs := $(SubDirs)
1817 DistSources = $(Sources) $(EXTRA_DIST)
1818 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1820 #------------------------------------------------------------------------
1821 # We MUST build distribution with OBJ_DIR != SRC_DIR
1822 #------------------------------------------------------------------------
1823 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1824 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1825 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1829 #------------------------------------------------------------------------
1830 # Prevent attempt to run dist targets from anywhere but the top level
1831 #------------------------------------------------------------------------
1833 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1834 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1837 #------------------------------------------------------------------------
1838 # Provide the top level targets
1839 #------------------------------------------------------------------------
1841 dist-gzip:: $(DistTarGZip)
1843 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1844 $(Echo) Packing gzipped distribution tar file.
1845 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1846 $(GZIP) -c > "$(DistTarGZip)"
1848 dist-bzip2:: $(DistTarBZ2)
1850 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1851 $(Echo) Packing bzipped distribution tar file.
1852 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1853 $(BZIP2) -c >$(DistTarBZ2)
1855 dist-zip:: $(DistZip)
1857 $(DistZip) : $(TopDistDir)/.makedistdir
1858 $(Echo) Packing zipped distribution file.
1859 $(Verb) rm -f $(DistZip)
1860 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1862 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1863 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1865 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1867 dist-check:: $(DistTarGZip)
1868 $(Echo) Checking distribution tar file.
1869 $(Verb) if test -d $(DistCheckDir) ; then \
1870 $(RM) -rf $(DistCheckDir) ; \
1872 $(Verb) $(MKDIR) $(DistCheckDir)
1873 $(Verb) cd $(DistCheckDir) && \
1874 $(MKDIR) $(DistCheckDir)/build && \
1875 $(MKDIR) $(DistCheckDir)/install && \
1876 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1878 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1879 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1882 $(MAKE) unittests && \
1883 $(MAKE) install && \
1884 $(MAKE) uninstall && \
1885 $(MAKE) dist-clean && \
1886 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1889 $(Echo) Cleaning distribution files
1890 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1895 #------------------------------------------------------------------------
1896 # Provide the recursive distdir target for building the distribution directory
1897 #------------------------------------------------------------------------
1898 distdir: $(DistDir)/.makedistdir
1899 $(DistDir)/.makedistdir: $(DistSources)
1900 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1901 if test -d "$(DistDir)" ; then \
1902 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1905 $(EchoCmd) Removing old $(DistDir) ; \
1906 $(RM) -rf $(DistDir); \
1907 $(EchoCmd) Making 'all' to verify build ; \
1908 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1910 $(Echo) Building Distribution Directory $(DistDir)
1911 $(Verb) $(MKDIR) $(DistDir)
1912 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1913 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1914 for file in $(DistFiles) ; do \
1916 $(PROJ_SRC_DIR)/*) \
1917 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1919 $(PROJ_SRC_ROOT)/*) \
1920 file=`echo "$$file" | \
1921 sed "s#^$$srcrootstrip/##"` \
1924 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1925 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1926 from_dir="$(PROJ_SRC_DIR)" ; \
1927 elif test -f "$$file" || test -d "$$file" ; then \
1930 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1931 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1932 to_dir="$(DistDir)/$$dir"; \
1933 $(MKDIR) "$$to_dir" ; \
1935 to_dir="$(DistDir)"; \
1937 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1938 if test -n "$$mid_dir" ; then \
1939 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1941 if test -d "$$from_dir/$$file"; then \
1942 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1943 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1944 cd $(PROJ_SRC_DIR) ; \
1945 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1946 ( cd $$to_dir ; $(TAR) xf - ) ; \
1947 cd $(PROJ_OBJ_DIR) ; \
1950 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1951 ( cd $$to_dir ; $(TAR) xf - ) ; \
1952 cd $(PROJ_OBJ_DIR) ; \
1954 elif test -f "$$from_dir/$$file" ; then \
1955 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1956 elif test -L "$$from_dir/$$file" ; then \
1957 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1958 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1959 $(EchoCmd) "===== WARNING: Distribution Source " \
1960 "$$from_dir/$$file Not Found!" ; \
1961 elif test "$(Verb)" != '@' ; then \
1962 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1965 $(Verb) for subdir in $(DistSubDirs) ; do \
1966 if test "$$subdir" \!= "." ; then \
1967 new_distdir="$(DistDir)/$$subdir" ; \
1968 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1969 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1970 DistDir="$$new_distdir" distdir ) || exit 1; \
1973 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1974 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1975 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1976 -name .svn \) -print` ;\
1977 $(MAKE) dist-hook ; \
1978 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1979 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1980 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1981 -o ! -type d ! -perm -444 -exec \
1982 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1983 || chmod -R a+r $(DistDir) ; \
1986 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1992 ###############################################################################
1993 # TOP LEVEL - targets only to apply at the top level directory
1994 ###############################################################################
1998 #------------------------------------------------------------------------
1999 # Install support for the project's include files:
2000 #------------------------------------------------------------------------
2003 $(Echo) Install circumvented with NO_INSTALL
2005 $(Echo) Uninstall circumvented with NO_INSTALL
2008 $(Echo) Installing include files
2009 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2010 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2011 cd $(PROJ_SRC_ROOT)/include && \
2012 for hdr in `find . -type f \
2013 '(' -name LICENSE.TXT \
2018 ')' -print | grep -v CVS | \
2019 grep -v .svn` ; do \
2020 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2021 if test \! -d "$$instdir" ; then \
2022 $(EchoCmd) Making install directory $$instdir ; \
2023 $(MKDIR) $$instdir ;\
2025 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2028 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2029 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2030 cd $(PROJ_OBJ_ROOT)/include && \
2031 for hdr in `find . -type f \
2032 '(' -name LICENSE.TXT \
2037 ')' -print | grep -v CVS | \
2038 grep -v .svn` ; do \
2039 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2040 if test \! -d "$$instdir" ; then \
2041 $(EchoCmd) Making install directory $$instdir ; \
2042 $(MKDIR) $$instdir ;\
2044 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2050 $(Echo) Uninstalling include files
2051 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2052 cd $(PROJ_SRC_ROOT)/include && \
2053 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2054 '!' '(' -name '*~' -o -name '.#*' \
2055 -o -name '*.in' ')' -print ')' | \
2056 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2057 cd $(PROJ_SRC_ROOT)/include && \
2058 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2059 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2065 @echo searching for overlength lines in files: $(Sources)
2068 egrep -n '.{81}' $(Sources) /dev/null
2071 @echo searching for tabs in files: $(Sources)
2074 egrep -n ' ' $(Sources) /dev/null
2077 @ls -l $(LibDir) | awk '\
2078 BEGIN { sum = 0; } \
2080 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2081 @ls -l $(ToolDir) | awk '\
2082 BEGIN { sum = 0; } \
2084 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2085 #------------------------------------------------------------------------
2086 # Print out the directories used for building
2087 #------------------------------------------------------------------------
2089 $(Echo) "BuildMode : " '$(BuildMode)'
2090 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2091 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2092 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2093 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2094 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2095 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2096 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2097 $(Echo) "PROJ_internal_prefix : " '$(PROJ_internal_prefix)'
2098 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2099 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2100 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2101 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2102 $(Echo) "UserTargets : " '$(UserTargets)'
2103 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2104 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2105 $(Echo) "ObjDir : " '$(ObjDir)'
2106 $(Echo) "LibDir : " '$(LibDir)'
2107 $(Echo) "ToolDir : " '$(ToolDir)'
2108 $(Echo) "ExmplDir : " '$(ExmplDir)'
2109 $(Echo) "Sources : " '$(Sources)'
2110 $(Echo) "TDFiles : " '$(TDFiles)'
2111 $(Echo) "INCFiles : " '$(INCFiles)'
2112 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2113 $(Echo) "PreConditions: " '$(PreConditions)'
2114 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2115 $(Echo) "Compile.C : " '$(Compile.C)'
2116 $(Echo) "Archive : " '$(Archive)'
2117 $(Echo) "YaccFiles : " '$(YaccFiles)'
2118 $(Echo) "LexFiles : " '$(LexFiles)'
2119 $(Echo) "Module : " '$(Module)'
2120 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2121 $(Echo) "SubDirs : " '$(SubDirs)'
2122 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2123 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2128 # General debugging rule, use 'make dbg-print-XXX' to print the
2129 # definition, value and origin of XXX.
2131 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))