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 CXX.Flags += -ffunction-sections -fdata-sections
618 ifeq ($(HOST_OS),Darwin)
619 LD.Flags += -Wl,-dead_strip
621 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
622 LD.Flags += -Wl,--gc-sections
627 # Adjust linker flags for building an executable
628 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
629 ifndef TOOL_NO_EXPORTS
630 LD.Flags += $(RDYNAMIC)
632 ifneq ($(HOST_OS), Darwin)
634 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
637 ifneq ($(DARWIN_MAJVERS),4)
638 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
641 TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
642 LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
648 #----------------------------------------------------------
649 # Options To Invoke Tools
650 #----------------------------------------------------------
652 ifdef EXTRA_LD_OPTIONS
653 LD.Flags += $(EXTRA_LD_OPTIONS)
657 CompileCommonOpts += -pedantic -Wno-long-long
659 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
660 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
661 $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
662 $(NO_MISSING_FIELD_INITIALIZERS)
663 # Enable cast-qual for C++; the workaround is to use const_cast.
664 CXX.Flags += -Wcast-qual
666 ifeq ($(HOST_OS),HP-UX)
667 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
670 # If we are building a universal binary on Mac OS/X, pass extra options. This
671 # is useful to people that want to link the LLVM libraries into their universal
674 # The following can be optionally specified:
675 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
676 # For Mac OS/X 10.4 Intel machines, the traditional one is:
677 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
678 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
679 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
682 ifndef UNIVERSAL_ARCH
683 UNIVERSAL_ARCH := i386 ppc
685 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
686 TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
687 ifdef UNIVERSAL_SDK_PATH
688 TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
691 # Building universal cannot compute dependencies automatically.
692 DISABLE_AUTO_DEPENDENCIES=1
694 ifeq ($(TARGET_OS),Darwin)
695 ifeq ($(ARCH),x86_64)
696 TargetCommonOpts = -m64
699 TargetCommonOpts = -m32
705 ifeq ($(HOST_OS),SunOS)
706 CPP.BaseFlags += -include llvm/Support/Solaris.h
709 ifeq ($(HOST_OS),AuroraUX)
710 CPP.BaseFlags += -include llvm/Support/Solaris.h
711 endif # !HOST_OS - AuroraUX.
713 # On Windows, SharedLibDir != LibDir. The order is important.
714 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
715 LD.Flags += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
717 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
720 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
721 # All -I flags should go here, so that they don't confuse llvm-config.
722 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
723 $(patsubst %,-I%/include,\
724 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
725 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
728 ifeq ($(INCLUDE_BUILD_DIR),1)
729 CPP.Flags += -I$(ObjDir)
732 # SHOW_DIAGNOSTICS support.
733 ifeq ($(SHOW_DIAGNOSTICS),1)
734 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
735 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
740 Compile.C = $(Compile.Wrapper) \
741 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
742 $(TargetCommonOpts) $(CompileCommonOpts) -c
743 Compile.CXX = $(Compile.Wrapper) \
744 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
745 $(TargetCommonOpts) $(CompileCommonOpts) -c
746 Preprocess.CXX= $(Compile.Wrapper) \
747 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
748 $(CompileCommonOpts) $(CXX.Flags) -E
749 Link = $(Compile.Wrapper) \
750 $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
751 $(TargetCommonOpts) $(Strip)
753 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
754 $(TargetCommonOpts) $(CompileCommonOpts) -E
756 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
757 ScriptInstall = $(INSTALL) -m 0755
758 DataInstall = $(INSTALL) -m 0644
760 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
761 # paths. In this case, the SYSPATH function (defined in
762 # Makefile.config) transforms Unix paths into Windows paths.
763 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
764 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
765 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
766 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
767 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
769 Archive = $(AR) $(AR.Flags)
778 #----------------------------------------------------------
779 # Get the list of source files and compute object file
781 #----------------------------------------------------------
784 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
785 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
787 Sources := $(SOURCES)
791 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
794 BaseNameSources := $(sort $(basename $(Sources)))
795 SourceDirs := $(sort $(dir $(Sources)))
797 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
798 ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
800 #----------------------------------------------------------
801 # For Mingw MSYS bash and Python/w32:
803 # $(ECHOPATH) prints DOSish pathstring.
804 # ex) $(ECHOPATH) /include/sys/types.h
805 # --> C:/mingw/include/sys/types.h
806 # built-in "echo" does not transform path to DOSish path.
808 # FIXME: It would not be needed when MSYS's python
810 #----------------------------------------------------------
812 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
813 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
815 ECHOPATH := $(Verb)$(ECHO)
818 ###############################################################################
819 # DIRECTORIES: Handle recursive descent of directory structure
820 ###############################################################################
822 #---------------------------------------------------------
823 # Provide rules to make install dirs. This must be early
824 # in the file so they get built before dependencies
825 #---------------------------------------------------------
827 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
830 # To create other directories, as needed, and timestamp their creation
832 $(Verb) $(MKDIR) $* > /dev/null
833 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
835 .PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
836 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
838 #---------------------------------------------------------
839 # Collect the object directories (as there may be more
840 # than one if the source code is spread across
842 #---------------------------------------------------------
844 OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
845 .PRECIOUS: $(OBJECT_DIRS)
847 #---------------------------------------------------------
848 # Handle the DIRS options for sequential construction
849 #---------------------------------------------------------
855 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
856 $(RecursiveTargets)::
857 $(Verb) for dir in $(DIRS); do \
858 if ([ ! -f $$dir/Makefile ] || \
859 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
861 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
863 ($(MAKE) -C $$dir $@ ) || exit 1; \
866 $(RecursiveTargets)::
867 $(Verb) for dir in $(DIRS); do \
868 ($(MAKE) -C $$dir $@ ) || exit 1; \
874 #---------------------------------------------------------
875 # Handle the EXPERIMENTAL_DIRS options ensuring success
876 # after each directory is built.
877 #---------------------------------------------------------
878 ifdef EXPERIMENTAL_DIRS
879 $(RecursiveTargets)::
880 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
881 if ([ ! -f $$dir/Makefile ] || \
882 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
884 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
886 ($(MAKE) -C $$dir $@ ) || exit 0; \
890 #-----------------------------------------------------------
891 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
892 #-----------------------------------------------------------
893 ifdef OPTIONAL_PARALLEL_DIRS
894 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
897 #-----------------------------------------------------------
898 # Handle the PARALLEL_DIRS options for parallel construction
899 #-----------------------------------------------------------
902 SubDirs += $(PARALLEL_DIRS)
904 # Unfortunately, this list must be maintained if new recursive targets are added
905 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
906 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
907 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
908 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
909 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
910 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
911 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
913 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
917 SD=$(PROJ_SRC_DIR)/$(@D); \
919 if [ ! -f $$SD/Makefile ]; then \
921 DD=$(notdir $(@D)); \
923 if ([ ! -f $$DD/Makefile ] || \
924 command test $$DD/Makefile -ot \
925 $$SD/Makefile ); then \
927 $(CP) $$SD/Makefile $$DD/Makefile; \
929 $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
932 #---------------------------------------------------------
933 # Handle the OPTIONAL_DIRS options for directores that may
935 #---------------------------------------------------------
938 SubDirs += $(OPTIONAL_DIRS)
940 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
941 $(RecursiveTargets)::
942 $(Verb) for dir in $(OPTIONAL_DIRS); do \
943 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
944 if ([ ! -f $$dir/Makefile ] || \
945 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
947 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
949 ($(MAKE) -C$$dir $@ ) || exit 1; \
953 $(RecursiveTargets)::
954 $(Verb) for dir in $(OPTIONAL_DIRS); do \
955 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
956 ($(MAKE) -C$$dir $@ ) || exit 1; \
962 #---------------------------------------------------------
963 # Handle the CONFIG_FILES options
964 #---------------------------------------------------------
969 $(Echo) Install circumvented with NO_INSTALL
971 $(Echo) UnInstall circumvented with NO_INSTALL
973 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
974 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
975 $(Verb)for file in $(CONFIG_FILES); do \
976 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
977 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
978 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
979 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
981 $(ECHO) Error: cannot find config file $${file}. ; \
986 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
987 $(Verb)for file in $(CONFIG_FILES); do \
988 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
994 ###############################################################################
995 # Set up variables for building libraries
996 ###############################################################################
998 #---------------------------------------------------------
999 # Define various command line options pertaining to the
1000 # libraries needed when linking. There are "Proj" libs
1001 # (defined by the user's project) and "LLVM" libs (defined
1002 # by the LLVM project).
1003 #---------------------------------------------------------
1006 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1007 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
1008 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1009 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1013 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1014 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1015 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1016 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1019 # Loadable module for Win32 requires all symbols resolved for linking.
1020 # Then all symbols in LLVM.dll will be available.
1021 ifeq ($(ENABLE_SHARED),1)
1022 ifdef LOADABLE_MODULE
1023 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1024 LINK_COMPONENTS += all
1029 ifndef IS_CLEANING_TARGET
1030 ifdef LINK_COMPONENTS
1032 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
1033 # clean in tools, then do a make in tools (instead of at the top level).
1035 @echo "*** llvm-config doesn't exist - rebuilding it."
1036 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1038 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1040 ifeq ($(ENABLE_SHARED), 1)
1041 # We can take the "auto-import" feature to get rid of using dllimport.
1042 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1043 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1046 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1047 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1050 ifndef NO_LLVM_CONFIG
1051 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1052 ifeq ($(LLVMConfigLibs),Error)
1053 $(error llvm-config --libs failed)
1055 LLVMLibsOptions += $(LLVMConfigLibs)
1056 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1057 ifeq ($(LLVMConfigLibfiles),Error)
1058 $(error llvm-config --libfiles failed)
1060 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1067 # Set up the library exports file.
1068 ifdef EXPORTED_SYMBOL_FILE
1070 # First, set up the native export file, which may differ from the source
1073 ifeq ($(HOST_OS),Darwin)
1074 # Darwin convention prefixes symbols with underscores.
1075 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1076 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1077 $(Verb) sed -e 's/^/_/' < $< > $@
1079 -$(Verb) $(RM) -f $(NativeExportsFile)
1081 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1082 # Gold and BFD ld require a version script rather than a plain list.
1083 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1084 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1085 $(Verb) echo "{" > $@
1086 $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || :
1087 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
1088 ifneq ($(HOST_OS),OpenBSD)
1089 $(Verb) echo " local: *;" >> $@
1091 $(Verb) echo "};" >> $@
1093 -$(Verb) $(RM) -f $(NativeExportsFile)
1095 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1096 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1097 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1098 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1099 $(Echo) Generating $(notdir $@)
1100 $(Verb) $(ECHO) "EXPORTS" > $@
1101 $(Verb) $(CAT) $< >> $@
1103 -$(Verb) $(RM) -f $(NativeExportsFile)
1105 # Default behavior: just use the exports file verbatim.
1106 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1111 # Now add the linker command-line options to use the native export file.
1114 ifeq ($(HOST_OS),Darwin)
1115 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1118 # gold, bfd ld, etc.
1119 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1120 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1124 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1125 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1126 SharedLinkOptions += $(NativeExportsFile)
1131 ###############################################################################
1132 # Library Build Rules: Four ways to build a library
1133 ###############################################################################
1135 # if we're building a library ...
1138 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1139 LIBRARYNAME := $(strip $(LIBRARYNAME))
1140 ifdef LOADABLE_MODULE
1141 BaseLibName.A := $(LIBRARYNAME).a
1142 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1144 BaseLibName.A := lib$(LIBRARYNAME).a
1145 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1147 LibName.A := $(LibDir)/$(BaseLibName.A)
1148 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1149 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1151 #---------------------------------------------------------
1152 # Shared Library Targets:
1153 # If the user asked for a shared library to be built
1154 # with the SHARED_LIBRARY variable, then we provide
1155 # targets for building them.
1156 #---------------------------------------------------------
1157 ifdef SHARED_LIBRARY
1159 all-local:: $(LibName.SO)
1161 ifdef EXPORTED_SYMBOL_FILE
1162 $(LibName.SO): $(NativeExportsFile)
1165 ifdef LINK_LIBS_IN_SHARED
1166 ifdef LOADABLE_MODULE
1167 SharedLibKindMessage := "Loadable Module"
1168 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1170 SharedLibKindMessage := "Shared Library"
1172 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1173 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1175 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1176 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1178 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1179 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1180 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1184 ifneq ($(strip $(LibName.SO)),)
1185 -$(Verb) $(RM) -f $(LibName.SO)
1190 $(Echo) Install circumvented with NO_INSTALL
1192 $(Echo) Uninstall circumvented with NO_INSTALL
1195 # Win32.DLL prefers to be located on the "PATH" of binaries.
1196 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1197 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1199 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1201 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1203 install-local:: $(DestSharedLib)
1205 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1206 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1207 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1210 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1211 -$(Verb) $(RM) -f $(DestSharedLib)
1215 #---------------------------------------------------------
1217 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1218 # building an archive.
1219 #---------------------------------------------------------
1220 ifndef NO_BUILD_ARCHIVE
1221 ifndef BUILD_ARCHIVE
1222 ifndef LOADABLE_MODULE
1228 #---------------------------------------------------------
1229 # Archive Library Targets:
1230 # If the user wanted a regular archive library built,
1231 # then we provide targets for building them.
1232 #---------------------------------------------------------
1235 all-local:: $(LibName.A)
1237 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1238 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1239 -$(Verb) $(RM) -f $@
1240 $(Verb) $(Archive) $@ $(ObjectsO)
1241 $(Verb) $(Ranlib) $@
1244 ifneq ($(strip $(LibName.A)),)
1245 -$(Verb) $(RM) -f $(LibName.A)
1250 $(Echo) Install circumvented with NO_INSTALL
1252 $(Echo) Uninstall circumvented with NO_INSTALL
1254 ifdef NO_INSTALL_ARCHIVES
1256 $(Echo) Install circumvented with NO_INSTALL
1258 $(Echo) Uninstall circumvented with NO_INSTALL
1260 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1262 install-local:: $(DestArchiveLib)
1264 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1265 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1266 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1267 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1270 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1271 -$(Verb) $(RM) -f $(DestArchiveLib)
1279 ###############################################################################
1280 # Tool Build Rules: Build executable tool based on TOOLNAME option
1281 ###############################################################################
1285 #---------------------------------------------------------
1286 # Set up variables for building a tool.
1287 #---------------------------------------------------------
1288 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1290 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1292 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1295 # TOOLALIAS is a name to symlink (or copy) the tool to.
1298 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1300 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1304 #---------------------------------------------------------
1306 #---------------------------------------------------------
1308 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1309 # not exporting all of the weak symbols from the binary. This reduces dyld
1310 # startup time by 4x on darwin in some cases.
1311 ifdef TOOL_NO_EXPORTS
1312 ifeq ($(HOST_OS),Darwin)
1314 # Tiger tools don't support this.
1315 ifneq ($(DARWIN_MAJVERS),4)
1316 LD.Flags += -Wl,-exported_symbol,_main
1320 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1321 ifneq ($(ARCH), Mips)
1322 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1327 #---------------------------------------------------------
1328 # Tool Order File Support
1329 #---------------------------------------------------------
1331 ifeq ($(HOST_OS),Darwin)
1332 ifdef TOOL_ORDER_FILE
1334 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1339 #---------------------------------------------------------
1340 # Tool Version Info Support
1341 #---------------------------------------------------------
1343 ifeq ($(HOST_OS),Darwin)
1344 ifdef TOOL_INFO_PLIST
1346 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1348 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1350 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1351 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1352 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1353 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1354 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1355 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1361 #---------------------------------------------------------
1362 # Provide targets for building the tools
1363 #---------------------------------------------------------
1364 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1367 ifneq ($(strip $(ToolBuildPath)),)
1368 -$(Verb) $(RM) -f $(ToolBuildPath)
1370 ifneq ($(strip $(ToolAliasBuildPath)),)
1371 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1375 $(ToolBuildPath): $(ExmplDir)/.dir
1377 $(ToolBuildPath): $(ToolDir)/.dir
1380 ifdef CODESIGN_TOOLS
1381 TOOL_CODESIGN_IDENTITY ?= -
1383 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1384 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1385 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1386 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1387 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1389 $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1390 $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1392 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1393 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1394 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1395 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1396 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1400 ifneq ($(strip $(ToolAliasBuildPath)),)
1401 $(ToolAliasBuildPath): $(ToolBuildPath)
1402 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1403 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1404 $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1405 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1411 $(Echo) Install circumvented with NO_INSTALL
1413 $(Echo) Uninstall circumvented with NO_INSTALL
1417 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1419 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1421 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1423 install-local:: $(DestTool)
1425 $(DestTool): $(ToolBuildPath)
1426 $(Echo) Installing $(BuildMode) $(DestTool)
1427 $(Verb) $(MKDIR) $(ToolBinDir)
1428 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1431 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1432 -$(Verb) $(RM) -f $(DestTool)
1434 # TOOLALIAS install.
1436 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1438 install-local:: $(DestToolAlias)
1440 $(DestToolAlias): $(DestTool)
1441 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1442 $(Verb) $(RM) -f $(DestToolAlias)
1443 $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1446 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1447 -$(Verb) $(RM) -f $(DestToolAlias)
1453 ###############################################################################
1454 # Object Build Rules: Build object files based on sources
1455 ###############################################################################
1457 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1458 ifeq ($(HOST_OS),HP-UX)
1459 DISABLE_AUTO_DEPENDENCIES=1
1462 COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1464 # Provide rule sets for when dependency generation is enabled
1465 ifndef DISABLE_AUTO_DEPENDENCIES
1467 #---------------------------------------------------------
1468 # Create .o files in the ObjDir directory from the .cpp and .c files...
1469 #---------------------------------------------------------
1471 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1472 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1474 # If the build succeeded, move the dependency file over, otherwise
1476 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1477 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1479 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1480 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1481 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1484 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1485 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1486 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1489 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1490 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1491 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1494 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1495 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1496 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1499 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1500 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1501 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1504 # Provide alternate rule sets if dependencies are disabled
1507 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1508 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1509 $(Compile.CXX) $< -o $@
1511 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1512 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1513 $(Compile.CXX) $< -o $@
1515 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1516 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1517 $(Compile.CXX) $< -o $@
1519 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1520 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1521 $(Compile.C) $< -o $@
1523 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1524 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1525 $(Compile.C) $< -o $@
1529 ## Rules for building preprocessed (.i/.ii) outputs.
1530 $(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1531 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1532 $(Verb) $(Preprocess.CXX) $< -o $@
1534 $(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1535 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1536 $(Verb) $(Preprocess.CXX) $< -o $@
1538 $(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1539 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1540 $(Verb) $(Preprocess.CXX) $< -o $@
1542 $(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1543 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1544 $(Verb) $(Preprocess.C) $< -o $@
1546 $(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1547 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1548 $(Verb) $(Preprocess.C) $< -o $@
1551 $(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1552 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1553 $(Compile.CXX) $< -o $@ -S
1555 $(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1556 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1557 $(Compile.CXX) $< -o $@ -S
1559 $(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1560 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1561 $(Compile.CXX) $< -o $@ -S
1563 $(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1564 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1565 $(Compile.C) $< -o $@ -S
1567 $(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1568 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1569 $(Compile.C) $< -o $@ -S
1571 ###############################################################################
1572 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1573 ###############################################################################
1576 TABLEGEN_INC_FILES_COMMON = 1
1579 ifdef TABLEGEN_INC_FILES_COMMON
1581 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1582 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1583 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1585 # INCFiles rule: All of the tblgen generated files are emitted to
1586 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1587 # us to only "touch" the real file if the contents of it change. IOW, if
1588 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1589 # dependencies of the .inc files are, unless the contents of the .inc file
1591 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1592 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1594 endif # TABLEGEN_INC_FILES_COMMON
1598 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1599 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1600 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1601 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1602 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1603 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1604 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1606 # All .inc.tmp files depend on the .td files.
1607 $(INCTMPFiles) : $(TDFiles)
1609 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1610 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1611 $(Echo) "Building $(<F) register info implementation with tblgen"
1612 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1614 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1615 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1616 $(Echo) "Building $(<F) instruction information with tblgen"
1617 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1619 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1620 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1621 $(Echo) "Building $(<F) assembly writer with tblgen"
1622 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1624 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1625 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1626 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1627 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1629 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1630 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1631 $(Echo) "Building $(<F) assembly matcher with tblgen"
1632 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1634 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1635 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1636 $(Echo) "Building $(<F) MC code emitter with tblgen"
1637 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1639 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1640 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1641 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1642 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1644 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1645 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1646 $(Echo) "Building $(<F) code emitter with tblgen"
1647 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1649 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1650 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1651 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1652 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1654 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1655 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1656 $(Echo) "Building $(<F) disassembly tables with tblgen"
1657 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1659 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1660 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1661 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1662 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1664 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1665 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1666 $(Echo) "Building $(<F) subtarget information with tblgen"
1667 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1669 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1670 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1671 $(Echo) "Building $(<F) calling convention information with tblgen"
1672 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1674 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1675 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1676 $(Echo) "Building $(<F) intrinsics information with tblgen"
1677 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1679 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1680 $(Echo) "Building $(<F) decoder tables with tblgen"
1681 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1683 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1684 $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1685 $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1688 -$(Verb) $(RM) -f $(INCFiles)
1692 ###############################################################################
1693 # OTHER RULES: Other rules needed
1694 ###############################################################################
1696 # To create postscript files from dot files...
1697 ifneq ($(DOT),false)
1699 $(DOT) -Tps < $< > $@
1702 $(Echo) "Cannot build $@: The program dot is not installed"
1705 # This rules ensures that header files that are removed still have a rule for
1706 # which they can be "generated." This allows make to ignore them and
1707 # reproduce the dependency lists.
1711 # Define clean-local to clean the current directory. Note that this uses a
1712 # very conservative approach ensuring that empty variables do not cause
1713 # errors or disastrous removal.
1715 ifneq ($(strip $(ObjRootDir)),)
1716 -$(Verb) $(RM) -rf $(ObjRootDir)
1718 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1719 -$(Verb) $(RM) -f *$(SHLIBEXT)
1723 -$(Verb) $(RM) -rf Debug Release Profile
1726 ###############################################################################
1727 # DEPENDENCIES: Include the dependency files if we should
1728 ###############################################################################
1729 ifndef DISABLE_AUTO_DEPENDENCIES
1731 # If its not one of the cleaning targets
1732 ifndef IS_CLEANING_TARGET
1734 # Get the list of dependency files
1735 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1736 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1738 -include $(DependFiles) ""
1744 ###############################################################################
1745 # CHECK: Running the test suite
1746 ###############################################################################
1749 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1750 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1751 $(EchoCmd) Running test suite ; \
1752 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1753 TESTSUITE=$(TESTSUITE) ; \
1755 $(EchoCmd) No Makefile in test directory ; \
1758 $(EchoCmd) No test directory ; \
1761 # An alias dating from when both lit and DejaGNU test runners were used.
1765 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1766 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1767 $(EchoCmd) Running test suite ; \
1768 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1770 $(EchoCmd) No Makefile in test directory ; \
1773 $(EchoCmd) No test directory ; \
1776 ###############################################################################
1777 # UNITTESTS: Running the unittests test suite
1778 ###############################################################################
1781 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1782 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1783 $(EchoCmd) Running unittests test suite ; \
1784 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1786 $(EchoCmd) No Makefile in unittests directory ; \
1789 $(EchoCmd) No unittests directory ; \
1792 ###############################################################################
1793 # DISTRIBUTION: Handle construction of a distribution tarball
1794 ###############################################################################
1796 #------------------------------------------------------------------------
1797 # Define distribution related variables
1798 #------------------------------------------------------------------------
1799 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1800 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1801 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1802 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1803 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1804 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1805 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1806 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1807 Makefile.config.in configure autoconf
1808 DistOther := $(notdir $(wildcard \
1809 $(PROJ_SRC_DIR)/*.h \
1810 $(PROJ_SRC_DIR)/*.td \
1811 $(PROJ_SRC_DIR)/*.def \
1812 $(PROJ_SRC_DIR)/*.ll \
1813 $(PROJ_SRC_DIR)/*.in))
1814 DistSubDirs := $(SubDirs)
1815 DistSources = $(Sources) $(EXTRA_DIST)
1816 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1818 #------------------------------------------------------------------------
1819 # We MUST build distribution with OBJ_DIR != SRC_DIR
1820 #------------------------------------------------------------------------
1821 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1822 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1823 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1827 #------------------------------------------------------------------------
1828 # Prevent attempt to run dist targets from anywhere but the top level
1829 #------------------------------------------------------------------------
1831 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1832 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1835 #------------------------------------------------------------------------
1836 # Provide the top level targets
1837 #------------------------------------------------------------------------
1839 dist-gzip:: $(DistTarGZip)
1841 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1842 $(Echo) Packing gzipped distribution tar file.
1843 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1844 $(GZIP) -c > "$(DistTarGZip)"
1846 dist-bzip2:: $(DistTarBZ2)
1848 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1849 $(Echo) Packing bzipped distribution tar file.
1850 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1851 $(BZIP2) -c >$(DistTarBZ2)
1853 dist-zip:: $(DistZip)
1855 $(DistZip) : $(TopDistDir)/.makedistdir
1856 $(Echo) Packing zipped distribution file.
1857 $(Verb) rm -f $(DistZip)
1858 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1860 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1861 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1863 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1865 dist-check:: $(DistTarGZip)
1866 $(Echo) Checking distribution tar file.
1867 $(Verb) if test -d $(DistCheckDir) ; then \
1868 $(RM) -rf $(DistCheckDir) ; \
1870 $(Verb) $(MKDIR) $(DistCheckDir)
1871 $(Verb) cd $(DistCheckDir) && \
1872 $(MKDIR) $(DistCheckDir)/build && \
1873 $(MKDIR) $(DistCheckDir)/install && \
1874 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1876 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1877 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1880 $(MAKE) unittests && \
1881 $(MAKE) install && \
1882 $(MAKE) uninstall && \
1883 $(MAKE) dist-clean && \
1884 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1887 $(Echo) Cleaning distribution files
1888 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1893 #------------------------------------------------------------------------
1894 # Provide the recursive distdir target for building the distribution directory
1895 #------------------------------------------------------------------------
1896 distdir: $(DistDir)/.makedistdir
1897 $(DistDir)/.makedistdir: $(DistSources)
1898 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1899 if test -d "$(DistDir)" ; then \
1900 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1903 $(EchoCmd) Removing old $(DistDir) ; \
1904 $(RM) -rf $(DistDir); \
1905 $(EchoCmd) Making 'all' to verify build ; \
1906 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1908 $(Echo) Building Distribution Directory $(DistDir)
1909 $(Verb) $(MKDIR) $(DistDir)
1910 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1911 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1912 for file in $(DistFiles) ; do \
1914 $(PROJ_SRC_DIR)/*) \
1915 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1917 $(PROJ_SRC_ROOT)/*) \
1918 file=`echo "$$file" | \
1919 sed "s#^$$srcrootstrip/##"` \
1922 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1923 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1924 from_dir="$(PROJ_SRC_DIR)" ; \
1925 elif test -f "$$file" || test -d "$$file" ; then \
1928 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1929 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1930 to_dir="$(DistDir)/$$dir"; \
1931 $(MKDIR) "$$to_dir" ; \
1933 to_dir="$(DistDir)"; \
1935 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1936 if test -n "$$mid_dir" ; then \
1937 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1939 if test -d "$$from_dir/$$file"; then \
1940 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1941 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1942 cd $(PROJ_SRC_DIR) ; \
1943 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1944 ( cd $$to_dir ; $(TAR) xf - ) ; \
1945 cd $(PROJ_OBJ_DIR) ; \
1948 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1949 ( cd $$to_dir ; $(TAR) xf - ) ; \
1950 cd $(PROJ_OBJ_DIR) ; \
1952 elif test -f "$$from_dir/$$file" ; then \
1953 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1954 elif test -L "$$from_dir/$$file" ; then \
1955 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1956 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1957 $(EchoCmd) "===== WARNING: Distribution Source " \
1958 "$$from_dir/$$file Not Found!" ; \
1959 elif test "$(Verb)" != '@' ; then \
1960 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1963 $(Verb) for subdir in $(DistSubDirs) ; do \
1964 if test "$$subdir" \!= "." ; then \
1965 new_distdir="$(DistDir)/$$subdir" ; \
1966 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1967 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1968 DistDir="$$new_distdir" distdir ) || exit 1; \
1971 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1972 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1973 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1974 -name .svn \) -print` ;\
1975 $(MAKE) dist-hook ; \
1976 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1977 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1978 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1979 -o ! -type d ! -perm -444 -exec \
1980 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1981 || chmod -R a+r $(DistDir) ; \
1984 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1990 ###############################################################################
1991 # TOP LEVEL - targets only to apply at the top level directory
1992 ###############################################################################
1996 #------------------------------------------------------------------------
1997 # Install support for the project's include files:
1998 #------------------------------------------------------------------------
2001 $(Echo) Install circumvented with NO_INSTALL
2003 $(Echo) Uninstall circumvented with NO_INSTALL
2006 $(Echo) Installing include files
2007 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2008 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2009 cd $(PROJ_SRC_ROOT)/include && \
2010 for hdr in `find . -type f \
2011 '(' -name LICENSE.TXT \
2016 ')' -print | grep -v CVS | \
2017 grep -v .svn` ; do \
2018 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2019 if test \! -d "$$instdir" ; then \
2020 $(EchoCmd) Making install directory $$instdir ; \
2021 $(MKDIR) $$instdir ;\
2023 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2026 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2027 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2028 cd $(PROJ_OBJ_ROOT)/include && \
2029 for hdr in `find . -type f \
2030 '(' -name LICENSE.TXT \
2035 ')' -print | grep -v CVS | \
2036 grep -v .svn` ; do \
2037 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2038 if test \! -d "$$instdir" ; then \
2039 $(EchoCmd) Making install directory $$instdir ; \
2040 $(MKDIR) $$instdir ;\
2042 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2048 $(Echo) Uninstalling include files
2049 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2050 cd $(PROJ_SRC_ROOT)/include && \
2051 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2052 '!' '(' -name '*~' -o -name '.#*' \
2053 -o -name '*.in' ')' -print ')' | \
2054 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2055 cd $(PROJ_SRC_ROOT)/include && \
2056 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2057 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2063 @echo searching for overlength lines in files: $(Sources)
2066 egrep -n '.{81}' $(Sources) /dev/null
2069 @echo searching for tabs in files: $(Sources)
2072 egrep -n ' ' $(Sources) /dev/null
2075 @ls -l $(LibDir) | awk '\
2076 BEGIN { sum = 0; } \
2078 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2079 @ls -l $(ToolDir) | awk '\
2080 BEGIN { sum = 0; } \
2082 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2083 #------------------------------------------------------------------------
2084 # Print out the directories used for building
2085 #------------------------------------------------------------------------
2087 $(Echo) "BuildMode : " '$(BuildMode)'
2088 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2089 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2090 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2091 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2092 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2093 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2094 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2095 $(Echo) "PROJ_internal_prefix : " '$(PROJ_internal_prefix)'
2096 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2097 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2098 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2099 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2100 $(Echo) "UserTargets : " '$(UserTargets)'
2101 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2102 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2103 $(Echo) "ObjDir : " '$(ObjDir)'
2104 $(Echo) "LibDir : " '$(LibDir)'
2105 $(Echo) "ToolDir : " '$(ToolDir)'
2106 $(Echo) "ExmplDir : " '$(ExmplDir)'
2107 $(Echo) "Sources : " '$(Sources)'
2108 $(Echo) "TDFiles : " '$(TDFiles)'
2109 $(Echo) "INCFiles : " '$(INCFiles)'
2110 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2111 $(Echo) "PreConditions: " '$(PreConditions)'
2112 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2113 $(Echo) "Compile.C : " '$(Compile.C)'
2114 $(Echo) "Archive : " '$(Archive)'
2115 $(Echo) "YaccFiles : " '$(YaccFiles)'
2116 $(Echo) "LexFiles : " '$(LexFiles)'
2117 $(Echo) "Module : " '$(Module)'
2118 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2119 $(Echo) "SubDirs : " '$(SubDirs)'
2120 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2121 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2126 # General debugging rule, use 'make dbg-print-XXX' to print the
2127 # definition, value and origin of XXX.
2129 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))