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 # PRECONDITIONS: that which must be built/checked first
62 ################################################################################
64 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
65 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
66 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
67 ConfigureScript := $(PROJ_SRC_ROOT)/configure
68 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
69 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
70 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
71 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
72 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
73 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
74 ifneq ($(MakefileCommonIn),)
75 PreConditions += $(MakefileCommon)
78 ifneq ($(MakefileConfigIn),)
79 PreConditions += $(MakefileConfig)
82 preconditions: $(PreConditions)
84 #------------------------------------------------------------------------
85 # Make sure the BUILT_SOURCES are built first
86 #------------------------------------------------------------------------
87 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
90 ifneq ($(strip $(BUILT_SOURCES)),)
91 -$(Verb) $(RM) -f $(BUILT_SOURCES)
94 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
96 $(Verb) if test -x config.status ; then \
97 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
98 $(MKDIR) .spotless.save ; \
99 $(MV) config.status .spotless.save ; \
100 $(MV) mklib .spotless.save ; \
101 $(MV) projects .spotless.save ; \
103 $(MV) .spotless.save/config.status . ; \
104 $(MV) .spotless.save/mklib . ; \
105 $(MV) .spotless.save/projects . ; \
106 $(RM) -rf .spotless.save ; \
107 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript) ; \
111 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
115 $(EchoCmd) "spotless target not supported for objdir == srcdir"
118 $(BUILT_SOURCES) : $(ObjMakefiles)
120 #------------------------------------------------------------------------
121 # Make sure we're not using a stale configuration
122 #------------------------------------------------------------------------
124 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
125 $(Verb) cd $(PROJ_OBJ_ROOT) && \
126 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
127 $(ConfigStatusScript)
129 .PRECIOUS: $(ConfigStatusScript)
130 $(ConfigStatusScript): $(ConfigureScript)
131 $(Echo) Reconfiguring with $<
132 $(Verb) cd $(PROJ_OBJ_ROOT) && \
133 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
134 $(ConfigStatusScript)
136 #------------------------------------------------------------------------
137 # Make sure the configuration makefile is up to date
138 #------------------------------------------------------------------------
139 ifneq ($(MakefileConfigIn),)
140 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
141 $(Echo) Regenerating $@
142 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
145 ifneq ($(MakefileCommonIn),)
146 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
147 $(Echo) Regenerating $@
148 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
151 #------------------------------------------------------------------------
152 # If the Makefile in the source tree has been updated, copy it over into the
153 # build tree. But, only do this if the source and object makefiles differ
154 #------------------------------------------------------------------------
156 PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
159 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
161 Makefile: $(PROJ_MAKEFILE) $(ExtraMakefiles)
162 $(Echo) "Updating Makefile"
163 $(Verb) $(MKDIR) $(@D)
164 $(Verb) $(CP) -f $< $@
166 # Copy the Makefile.* files unless we're in the root directory which avoids
167 # the copying of Makefile.config.in or other things that should be explicitly
169 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
171 *Makefile.rules) ;; \
173 *) $(EchoCmd) "Updating $(@F)" ; \
180 #------------------------------------------------------------------------
181 # Set up the basic dependencies
182 #------------------------------------------------------------------------
183 $(UserTargets):: $(PreConditions)
187 clean-all:: clean-local clean-all-local
188 install:: install-local
189 uninstall:: uninstall-local
190 install-local:: all-local
191 install-bytecode:: install-bytecode-local
193 ###############################################################################
194 # VARIABLES: Set up various variables based on configuration data
195 ###############################################################################
197 # Variable for if this make is for a "cleaning" target
198 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
202 #--------------------------------------------------------------------
203 # Variables derived from configuration we are building
204 #--------------------------------------------------------------------
207 ifeq ($(ENABLE_OPTIMIZED),1)
209 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
210 ifneq ($(HOST_OS),FreeBSD)
211 ifneq ($(HOST_OS),GNU/kFreeBSD)
212 ifneq ($(HOST_OS),Darwin)
213 OmitFramePointer := -fomit-frame-pointer
218 # Darwin requires -fstrict-aliasing to be explicitly enabled.
219 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
220 # with -fstrict-aliasing and ipa-type-escape radr://6756684
221 #ifeq ($(HOST_OS),Darwin)
222 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
224 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
225 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
226 LD.Flags += $(OPTIMIZE_OPTION)
228 BuildMode := $(BuildMode)+Debug
235 ifdef NO_DEBUG_SYMBOLS
236 BuildMode := Unoptimized
250 ifeq ($(ENABLE_LIBCPP),1)
251 CXX.Flags += -stdlib=libc++
252 LD.Flags += -stdlib=libc++
255 ifeq ($(ENABLE_CXX11),1)
256 CXX.Flags += -std=c++11
259 ifeq ($(ENABLE_WERROR),1)
264 ifeq ($(ENABLE_PROFILING),1)
265 BuildMode := $(BuildMode)+Profile
266 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
267 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
268 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
272 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
273 # CXX.Flags += -fvisibility-inlines-hidden
276 ifdef ENABLE_EXPENSIVE_CHECKS
277 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
278 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
282 # IF REQUIRES_EH=1 is specified then don't disable exceptions
284 CXX.Flags += -fno-exceptions
286 # If the library requires EH, it also requires RTTI.
290 ifdef REQUIRES_FRAME_POINTER
291 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
292 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
293 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
296 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
297 ifneq ($(REQUIRES_RTTI), 1)
298 CXX.Flags += -fno-rtti
301 ifeq ($(ENABLE_COVERAGE),1)
302 BuildMode := $(BuildMode)+Coverage
303 CXX.Flags += -ftest-coverage -fprofile-arcs
304 C.Flags += -ftest-coverage -fprofile-arcs
307 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
308 # then disable assertions by defining the appropriate preprocessor symbols.
309 ifeq ($(DISABLE_ASSERTIONS),1)
310 CPP.Defines += -DNDEBUG
312 BuildMode := $(BuildMode)+Asserts
313 CPP.Defines += -D_DEBUG
316 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
317 # configured), then enable expensive checks by defining the
318 # appropriate preprocessor symbols.
319 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
320 BuildMode := $(BuildMode)+Checks
321 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
324 # LOADABLE_MODULE implies several other things so we force them to be
326 ifdef LOADABLE_MODULE
328 LINK_LIBS_IN_SHARED := 1
336 ifeq ($(ENABLE_PIC),1)
337 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
338 # Nothing. Win32 defaults to PIC and warns when given -fPIC
340 ifeq ($(HOST_OS),Darwin)
341 # Common symbols not allowed in dylib files
342 CXX.Flags += -fno-common
343 C.Flags += -fno-common
345 # Linux and others; pass -fPIC
351 ifeq ($(HOST_OS),Darwin)
352 CXX.Flags += -mdynamic-no-pic
353 C.Flags += -mdynamic-no-pic
357 # Support makefile variable to disable any kind of timestamp/non-deterministic
358 # info from being used in the build.
359 ifeq ($(ENABLE_TIMESTAMPS),1)
360 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
362 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
365 ifeq ($(HOST_OS),MingW)
367 CPP.Defines += -D__NO_CTYPE_INLINE
368 ifeq ($(LLVM_CROSS_COMPILING),1)
369 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
371 LD.Flags += -Wl,--allow-multiple-definition
376 CXX.Flags += -Woverloaded-virtual
377 CPP.BaseFlags += $(CPP.Defines)
380 # Make Floating point IEEE compliant on Alpha.
383 CPP.BaseFlags += -mieee
384 ifeq ($(ENABLE_PIC),0)
386 CPP.BaseFlags += -fPIC
389 LD.Flags += -Wl,--no-relax
392 # GNU ld/PECOFF accepts but ignores them below;
396 # FIXME: autoconf should be aware of them.
397 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
398 HAVE_LINK_VERSION_SCRIPT := 0
400 RDYNAMIC := -Wl,--export-all-symbols
403 #--------------------------------------------------------------------
404 # Directory locations
405 #--------------------------------------------------------------------
407 ifeq ($(LLVM_CROSS_COMPILING),1)
408 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
411 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
412 ObjDir := $(ObjRootDir)
413 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
414 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
415 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
416 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
417 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
418 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
420 #--------------------------------------------------------------------
421 # Locations of shared libraries
422 #--------------------------------------------------------------------
425 SharedLibDir := $(LibDir)
426 LLVMSharedLibDir := $(LLVMLibDir)
428 # Win32.DLL prefers to be located on the "PATH" of binaries.
429 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
430 SharedLibDir := $(ToolDir)
431 LLVMSharedLibDir := $(LLVMToolDir)
433 ifeq ($(HOST_OS),Cygwin)
440 #--------------------------------------------------------------------
441 # Full Paths To Compiled Tools and Utilities
442 #--------------------------------------------------------------------
443 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
446 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
449 ifeq ($(LLVM_CROSS_COMPILING),1)
450 LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
452 LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
455 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
457 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
460 LLI := $(LLVMToolDir)/lli$(EXEEXT)
463 LLC := $(LLVMToolDir)/llc$(EXEEXT)
466 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
469 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
472 #--------------------------------------------------------------------
473 # Adjust to user's request
474 #--------------------------------------------------------------------
476 ifeq ($(HOST_OS),Darwin)
477 DARWIN_VERSION := `sw_vers -productVersion`
478 # Strip a number like 10.4.7 to 10.4
479 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
480 # Get "4" out of 10.4 for later pieces in the makefile.
481 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
483 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
484 SharedLinkOptions := -dynamiclib
485 ifdef DEPLOYMENT_TARGET
486 SharedLinkOptions += $(DEPLOYMENT_TARGET)
489 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
493 SharedLinkOptions=-shared
496 ifeq ($(TARGET_OS),Darwin)
497 ifdef DEPLOYMENT_TARGET
498 TargetCommonOpts += $(DEPLOYMENT_TARGET)
501 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
507 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
508 ifneq ($(HOST_OS),Darwin)
509 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
521 # Adjust settings for verbose mode
524 AR.Flags += >/dev/null 2>/dev/null
525 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
527 ConfigureScriptFLAGS :=
530 # By default, strip symbol information from executable
532 Strip := $(PLATFORMSTRIPOPTS)
533 StripWarnMsg := "(without symbols)"
534 Install.StripFlag += -s
537 # Adjust linker flags for building an executable
538 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
539 ifndef TOOL_NO_EXPORTS
540 LD.Flags += $(RDYNAMIC)
542 ifneq ($(HOST_OS), Darwin)
544 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
546 LD.Flags += $(RPATH) -Wl,$(ExmplDir)
548 LD.Flags += $(RPATH) -Wl,$(ToolDir)
552 ifneq ($(DARWIN_MAJVERS),4)
553 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
559 #----------------------------------------------------------
560 # Options To Invoke Tools
561 #----------------------------------------------------------
563 ifdef EXTRA_LD_OPTIONS
564 LD.Flags += $(EXTRA_LD_OPTIONS)
568 CompileCommonOpts += -pedantic -Wno-long-long
570 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
571 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT)
572 # Enable cast-qual for C++; the workaround is to use const_cast.
573 CXX.Flags += -Wcast-qual
575 ifeq ($(HOST_OS),HP-UX)
576 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
579 # If we are building a universal binary on Mac OS X, pass extra options. This
580 # is useful to people that want to link the LLVM libraries into their universal
583 # The following can be optionally specified:
584 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
585 # For Mac OS X 10.4 Intel machines, the traditional one is:
586 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
587 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
588 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
591 ifndef UNIVERSAL_ARCH
592 UNIVERSAL_ARCH := i386 ppc
594 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
595 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
596 ifdef UNIVERSAL_SDK_PATH
597 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
600 # Building universal cannot compute dependencies automatically.
601 DISABLE_AUTO_DEPENDENCIES=1
603 ifeq ($(TARGET_OS),Darwin)
604 ifeq ($(ARCH),x86_64)
605 TargetCommonOpts = -m64
608 TargetCommonOpts = -m32
614 ifeq ($(HOST_OS),SunOS)
615 CPP.BaseFlags += -include llvm/Support/Solaris.h
618 ifeq ($(HOST_OS),AuroraUX)
619 CPP.BaseFlags += -include llvm/Support/Solaris.h
620 endif # !HOST_OS - AuroraUX.
622 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
623 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
624 # All -I flags should go here, so that they don't confuse llvm-config.
625 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
626 $(patsubst %,-I%/include,\
627 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
628 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
631 # SHOW_DIAGNOSTICS support.
632 ifeq ($(SHOW_DIAGNOSTICS),1)
633 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
634 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
639 ifeq ($(BUILD_COMPONENT), 1)
640 Compile.C = $(Compile.Wrapper) \
641 $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
642 $(TargetCommonOpts) $(CompileCommonOpts) -c
643 Compile.CXX = $(Compile.Wrapper) \
644 $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
646 $(TargetCommonOpts) $(CompileCommonOpts) -c
647 Preprocess.CXX= $(Compile.Wrapper) \
648 $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
649 $(CompileCommonOpts) $(CXX.Flags) -E
650 Link = $(Compile.Wrapper) \
651 $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
652 $(LD.Flags) $(LDFLAGS) \
653 $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
655 Compile.C = $(Compile.Wrapper) \
656 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
657 $(TargetCommonOpts) $(CompileCommonOpts) -c
658 Compile.CXX = $(Compile.Wrapper) \
659 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
660 $(TargetCommonOpts) $(CompileCommonOpts) -c
661 Preprocess.CXX= $(Compile.Wrapper) \
662 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
663 $(CompileCommonOpts) $(CXX.Flags) -E
664 Link = $(Compile.Wrapper) \
665 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LD.Flags) \
666 $(LDFLAGS) $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
669 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
670 $(TargetCommonOpts) $(CompileCommonOpts) -E
672 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
673 ScriptInstall = $(INSTALL) -m 0755
674 DataInstall = $(INSTALL) -m 0644
676 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
677 # paths. In this case, the SYSPATH function (defined in
678 # Makefile.config) transforms Unix paths into Windows paths.
679 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
680 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
681 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
682 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
683 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
685 Archive = $(AR) $(AR.Flags)
694 #----------------------------------------------------------
695 # Get the list of source files and compute object file
697 #----------------------------------------------------------
700 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
701 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
703 Sources := $(SOURCES)
707 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
710 BaseNameSources := $(sort $(basename $(Sources)))
712 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
714 #----------------------------------------------------------
715 # For Mingw MSYS bash and Python/w32:
717 # $(ECHOPATH) prints DOSish pathstring.
718 # ex) $(ECHOPATH) /include/sys/types.h
719 # --> C:/mingw/include/sys/types.h
720 # built-in "echo" does not transform path to DOSish path.
722 # FIXME: It would not be needed when MSYS's python
724 #----------------------------------------------------------
726 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
727 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
729 ECHOPATH := $(Verb)$(ECHO)
732 ###############################################################################
733 # DIRECTORIES: Handle recursive descent of directory structure
734 ###############################################################################
736 #---------------------------------------------------------
737 # Provide rules to make install dirs. This must be early
738 # in the file so they get built before dependencies
739 #---------------------------------------------------------
741 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
744 # To create other directories, as needed, and timestamp their creation
746 $(Verb) $(MKDIR) $* > /dev/null
747 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
749 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
750 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
752 #---------------------------------------------------------
753 # Handle the DIRS options for sequential construction
754 #---------------------------------------------------------
760 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
761 $(RecursiveTargets)::
762 $(Verb) for dir in $(DIRS); do \
763 if ([ ! -f $$dir/Makefile ] || \
764 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
766 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
768 ($(MAKE) -C $$dir $@ ) || exit 1; \
771 $(RecursiveTargets)::
772 $(Verb) for dir in $(DIRS); do \
773 ($(MAKE) -C $$dir $@ ) || exit 1; \
779 #---------------------------------------------------------
780 # Handle the EXPERIMENTAL_DIRS options ensuring success
781 # after each directory is built.
782 #---------------------------------------------------------
783 ifdef EXPERIMENTAL_DIRS
784 $(RecursiveTargets)::
785 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
786 if ([ ! -f $$dir/Makefile ] || \
787 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
789 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
791 ($(MAKE) -C $$dir $@ ) || exit 0; \
795 #-----------------------------------------------------------
796 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
797 #-----------------------------------------------------------
798 ifdef OPTIONAL_PARALLEL_DIRS
799 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
802 #-----------------------------------------------------------
803 # Handle the PARALLEL_DIRS options for parallel construction
804 #-----------------------------------------------------------
807 SubDirs += $(PARALLEL_DIRS)
809 # Unfortunately, this list must be maintained if new recursive targets are added
810 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
811 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
812 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
813 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
814 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
815 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
816 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
818 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
821 $(Verb) if ([ ! -f $(@D)/Makefile ] || \
822 command test $(@D)/Makefile -ot \
823 $(PROJ_SRC_DIR)/$(@D)/Makefile ); then \
825 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
827 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
830 #---------------------------------------------------------
831 # Handle the OPTIONAL_DIRS options for directores that may
833 #---------------------------------------------------------
836 SubDirs += $(OPTIONAL_DIRS)
838 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
839 $(RecursiveTargets)::
840 $(Verb) for dir in $(OPTIONAL_DIRS); do \
841 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
842 if ([ ! -f $$dir/Makefile ] || \
843 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
845 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
847 ($(MAKE) -C$$dir $@ ) || exit 1; \
851 $(RecursiveTargets)::
852 $(Verb) for dir in $(OPTIONAL_DIRS); do \
853 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
854 ($(MAKE) -C$$dir $@ ) || exit 1; \
860 #---------------------------------------------------------
861 # Handle the CONFIG_FILES options
862 #---------------------------------------------------------
867 $(Echo) Install circumvented with NO_INSTALL
869 $(Echo) UnInstall circumvented with NO_INSTALL
871 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
872 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
873 $(Verb)for file in $(CONFIG_FILES); do \
874 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
875 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
876 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
877 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
879 $(ECHO) Error: cannot find config file $${file}. ; \
884 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
885 $(Verb)for file in $(CONFIG_FILES); do \
886 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
892 ###############################################################################
893 # Set up variables for building libraries
894 ###############################################################################
896 #---------------------------------------------------------
897 # Define various command line options pertaining to the
898 # libraries needed when linking. There are "Proj" libs
899 # (defined by the user's project) and "LLVM" libs (defined
900 # by the LLVM project).
901 #---------------------------------------------------------
904 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
905 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
906 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
907 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
911 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
912 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
913 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
914 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
917 # Loadable module for Win32 requires all symbols resolved for linking.
918 # Then all symbols in LLVM.dll will be available.
919 ifeq ($(ENABLE_SHARED),1)
920 ifdef LOADABLE_MODULE
921 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
922 LINK_COMPONENTS += all
927 ifndef IS_CLEANING_TARGET
928 ifdef LINK_COMPONENTS
930 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
931 # clean in tools, then do a make in tools (instead of at the top level).
933 @echo "*** llvm-config doesn't exist - rebuilding it."
934 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
936 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
938 ifeq ($(ENABLE_SHARED), 1)
939 # We can take the "auto-import" feature to get rid of using dllimport.
940 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
941 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
944 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
945 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
948 ifndef NO_LLVM_CONFIG
949 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
950 ifeq ($(LLVMConfigLibs),Error)
951 $(error llvm-config --libs failed)
953 LLVMLibsOptions += $(LLVMConfigLibs)
954 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
955 ifeq ($(LLVMConfigLibfiles),Error)
956 $(error llvm-config --libfiles failed)
958 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
965 # Set up the library exports file.
966 ifdef EXPORTED_SYMBOL_FILE
968 # First, set up the native export file, which may differ from the source
971 ifeq ($(HOST_OS),Darwin)
972 # Darwin convention prefixes symbols with underscores.
973 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
974 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
975 $(Verb) sed -e 's/^/_/' < $< > $@
977 -$(Verb) $(RM) -f $(NativeExportsFile)
979 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
980 # Gold and BFD ld require a version script rather than a plain list.
981 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
982 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
983 $(Verb) echo "{" > $@
984 $(Verb) grep -q "\<" $< && echo " global:" >> $@ || :
985 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
986 ifneq ($(HOST_OS),OpenBSD)
987 $(Verb) echo " local: *;" >> $@
989 $(Verb) echo "};" >> $@
991 -$(Verb) $(RM) -f $(NativeExportsFile)
993 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
994 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
995 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
996 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
997 $(Echo) Generating $(notdir $@)
998 $(Verb) $(ECHO) "EXPORTS" > $@
999 $(Verb) $(CAT) $< >> $@
1001 -$(Verb) $(RM) -f $(NativeExportsFile)
1003 # Default behavior: just use the exports file verbatim.
1004 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1009 # Now add the linker command-line options to use the native export file.
1012 ifeq ($(HOST_OS),Darwin)
1013 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1016 # gold, bfd ld, etc.
1017 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1018 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1022 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1023 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1024 SharedLinkOptions += $(NativeExportsFile)
1029 ###############################################################################
1030 # Library Build Rules: Four ways to build a library
1031 ###############################################################################
1033 # if we're building a library ...
1036 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1037 LIBRARYNAME := $(strip $(LIBRARYNAME))
1038 ifdef LOADABLE_MODULE
1039 BaseLibName.A := $(LIBRARYNAME).a
1040 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1042 BaseLibName.A := lib$(LIBRARYNAME).a
1043 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1045 LibName.A := $(LibDir)/$(BaseLibName.A)
1046 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1047 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1049 #---------------------------------------------------------
1050 # Shared Library Targets:
1051 # If the user asked for a shared library to be built
1052 # with the SHARED_LIBRARY variable, then we provide
1053 # targets for building them.
1054 #---------------------------------------------------------
1055 ifdef SHARED_LIBRARY
1057 all-local:: $(LibName.SO)
1059 ifdef EXPORTED_SYMBOL_FILE
1060 $(LibName.SO): $(NativeExportsFile)
1063 ifdef LINK_LIBS_IN_SHARED
1064 ifdef LOADABLE_MODULE
1065 SharedLibKindMessage := "Loadable Module"
1066 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1068 SharedLibKindMessage := "Shared Library"
1070 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1071 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1073 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1074 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1076 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1077 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1078 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1082 ifneq ($(strip $(LibName.SO)),)
1083 -$(Verb) $(RM) -f $(LibName.SO)
1088 $(Echo) Install circumvented with NO_INSTALL
1090 $(Echo) Uninstall circumvented with NO_INSTALL
1093 # Win32.DLL prefers to be located on the "PATH" of binaries.
1094 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1095 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1097 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1099 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1101 install-local:: $(DestSharedLib)
1103 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1104 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1105 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1108 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1109 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
1113 #---------------------------------------------------------
1115 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1116 # building an archive.
1117 #---------------------------------------------------------
1118 ifndef NO_BUILD_ARCHIVE
1119 ifndef BUILD_ARCHIVE
1120 ifndef LOADABLE_MODULE
1126 #---------------------------------------------------------
1127 # Archive Library Targets:
1128 # If the user wanted a regular archive library built,
1129 # then we provide targets for building them.
1130 #---------------------------------------------------------
1133 all-local:: $(LibName.A)
1135 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1136 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1137 -$(Verb) $(RM) -f $@
1138 $(Verb) $(Archive) $@ $(ObjectsO)
1139 $(Verb) $(Ranlib) $@
1142 ifneq ($(strip $(LibName.A)),)
1143 -$(Verb) $(RM) -f $(LibName.A)
1148 $(Echo) Install circumvented with NO_INSTALL
1150 $(Echo) Uninstall circumvented with NO_INSTALL
1152 ifdef NO_INSTALL_ARCHIVES
1154 $(Echo) Install circumvented with NO_INSTALL
1156 $(Echo) Uninstall circumvented with NO_INSTALL
1158 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1160 install-local:: $(DestArchiveLib)
1162 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1163 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1164 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1165 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1168 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1169 -$(Verb) $(RM) -f $(DestArchiveLib)
1177 ###############################################################################
1178 # Tool Build Rules: Build executable tool based on TOOLNAME option
1179 ###############################################################################
1183 #---------------------------------------------------------
1184 # Set up variables for building a tool.
1185 #---------------------------------------------------------
1186 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1188 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1190 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1193 # TOOLALIAS is a name to symlink (or copy) the tool to.
1196 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1198 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1202 #---------------------------------------------------------
1204 #---------------------------------------------------------
1206 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1207 # not exporting all of the weak symbols from the binary. This reduces dyld
1208 # startup time by 4x on darwin in some cases.
1209 ifdef TOOL_NO_EXPORTS
1210 ifeq ($(HOST_OS),Darwin)
1212 # Tiger tools don't support this.
1213 ifneq ($(DARWIN_MAJVERS),4)
1214 LD.Flags += -Wl,-exported_symbol,_main
1218 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD GNU/kFreeBSD))
1219 ifneq ($(ARCH), Mips)
1220 LD.Flags += -Wl,--version-script=$(PROJ_SRC_ROOT)/autoconf/ExportMap.map
1225 #---------------------------------------------------------
1226 # Tool Order File Support
1227 #---------------------------------------------------------
1229 ifeq ($(HOST_OS),Darwin)
1230 ifdef TOOL_ORDER_FILE
1232 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1237 #---------------------------------------------------------
1238 # Tool Version Info Support
1239 #---------------------------------------------------------
1241 ifeq ($(HOST_OS),Darwin)
1242 ifdef TOOL_INFO_PLIST
1244 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1246 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1248 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1249 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1250 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1251 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1252 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1253 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1259 #---------------------------------------------------------
1260 # Provide targets for building the tools
1261 #---------------------------------------------------------
1262 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1265 ifneq ($(strip $(ToolBuildPath)),)
1266 -$(Verb) $(RM) -f $(ToolBuildPath)
1268 ifneq ($(strip $(ToolAliasBuildPath)),)
1269 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1273 $(ToolBuildPath): $(ExmplDir)/.dir
1275 $(ToolBuildPath): $(ToolDir)/.dir
1278 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1279 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1280 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1281 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1282 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1285 ifneq ($(strip $(ToolAliasBuildPath)),)
1286 $(ToolAliasBuildPath): $(ToolBuildPath)
1287 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1288 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1289 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1290 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1296 $(Echo) Install circumvented with NO_INSTALL
1298 $(Echo) Uninstall circumvented with NO_INSTALL
1300 DestTool = $(DESTDIR)$(PROJ_bindir)/$(program_prefix)$(TOOLEXENAME)
1302 install-local:: $(DestTool)
1304 $(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
1305 $(Echo) Installing $(BuildMode) $(DestTool)
1306 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1309 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1310 -$(Verb) $(RM) -f $(DestTool)
1312 # TOOLALIAS install.
1314 DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1316 install-local:: $(DestToolAlias)
1318 $(DestToolAlias): $(DestTool)
1319 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1320 $(Verb) $(RM) -f $(DestToolAlias)
1321 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1324 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1325 -$(Verb) $(RM) -f $(DestToolAlias)
1331 ###############################################################################
1332 # Object Build Rules: Build object files based on sources
1333 ###############################################################################
1335 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1336 ifeq ($(HOST_OS),HP-UX)
1337 DISABLE_AUTO_DEPENDENCIES=1
1340 # Provide rule sets for when dependency generation is enabled
1341 ifndef DISABLE_AUTO_DEPENDENCIES
1343 #---------------------------------------------------------
1344 # Create .o files in the ObjDir directory from the .cpp and .c files...
1345 #---------------------------------------------------------
1347 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1348 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1350 # If the build succeeded, move the dependency file over, otherwise
1352 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1353 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1355 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1356 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1357 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1360 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1361 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1362 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1365 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1366 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1367 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1370 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1371 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1372 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1375 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1376 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1377 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1380 # Provide alternate rule sets if dependencies are disabled
1383 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1384 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1385 $(Compile.CXX) $< -o $@
1387 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1388 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1389 $(Compile.CXX) $< -o $@
1391 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1392 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1393 $(Compile.CXX) $< -o $@
1395 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1396 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1397 $(Compile.C) $< -o $@
1399 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1400 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1401 $(Compile.C) $< -o $@
1405 ## Rules for building preprocessed (.i/.ii) outputs.
1406 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1407 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1408 $(Verb) $(Preprocess.CXX) $< -o $@
1410 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1411 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1412 $(Verb) $(Preprocess.CXX) $< -o $@
1414 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1415 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1416 $(Verb) $(Preprocess.CXX) $< -o $@
1418 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1419 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1420 $(Verb) $(Preprocess.C) $< -o $@
1422 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1423 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1424 $(Verb) $(Preprocess.C) $< -o $@
1427 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1428 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1429 $(Compile.CXX) $< -o $@ -S
1431 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1432 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1433 $(Compile.CXX) $< -o $@ -S
1435 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1436 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1437 $(Compile.CXX) $< -o $@ -S
1439 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1440 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1441 $(Compile.C) $< -o $@ -S
1443 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1444 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1445 $(Compile.C) $< -o $@ -S
1447 ###############################################################################
1448 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1449 ###############################################################################
1452 TABLEGEN_INC_FILES_COMMON = 1
1455 ifdef TABLEGEN_INC_FILES_COMMON
1457 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1458 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1459 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1461 # INCFiles rule: All of the tblgen generated files are emitted to
1462 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1463 # us to only "touch" the real file if the contents of it change. IOW, if
1464 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1465 # dependencies of the .inc files are, unless the contents of the .inc file
1467 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1468 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1470 endif # TABLEGEN_INC_FILES_COMMON
1474 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1475 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1476 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1477 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1478 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1479 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1480 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1482 # All .inc.tmp files depend on the .td files.
1483 $(INCTMPFiles) : $(TDFiles)
1485 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1486 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1487 $(Echo) "Building $(<F) register info implementation with tblgen"
1488 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1490 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1491 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1492 $(Echo) "Building $(<F) instruction information with tblgen"
1493 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1495 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1496 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1497 $(Echo) "Building $(<F) assembly writer with tblgen"
1498 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1500 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1501 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1502 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1503 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1505 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1506 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1507 $(Echo) "Building $(<F) assembly matcher with tblgen"
1508 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1510 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1511 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1512 $(Echo) "Building $(<F) MC code emitter with tblgen"
1513 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1515 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1516 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1517 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1518 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1520 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1521 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1522 $(Echo) "Building $(<F) code emitter with tblgen"
1523 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1525 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1526 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1527 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1528 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1530 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1531 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1532 $(Echo) "Building $(<F) disassembly tables with tblgen"
1533 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1535 $(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1536 $(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1537 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1538 $(Verb) $(LLVMTableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1540 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1541 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1542 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1543 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1545 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1546 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1547 $(Echo) "Building $(<F) subtarget information with tblgen"
1548 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1550 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1551 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1552 $(Echo) "Building $(<F) calling convention information with tblgen"
1553 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1555 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1556 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1557 $(Echo) "Building $(<F) intrinsics information with tblgen"
1558 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1560 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1561 $(Echo) "Building $(<F) decoder tables with tblgen"
1562 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1566 -$(Verb) $(RM) -f $(INCFiles)
1570 ###############################################################################
1571 # OTHER RULES: Other rules needed
1572 ###############################################################################
1574 # To create postscript files from dot files...
1575 ifneq ($(DOT),false)
1577 $(DOT) -Tps < $< > $@
1580 $(Echo) "Cannot build $@: The program dot is not installed"
1583 # This rules ensures that header files that are removed still have a rule for
1584 # which they can be "generated." This allows make to ignore them and
1585 # reproduce the dependency lists.
1589 # Define clean-local to clean the current directory. Note that this uses a
1590 # very conservative approach ensuring that empty variables do not cause
1591 # errors or disastrous removal.
1593 ifneq ($(strip $(ObjRootDir)),)
1594 -$(Verb) $(RM) -rf $(ObjRootDir)
1596 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1597 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1598 -$(Verb) $(RM) -f *$(SHLIBEXT)
1602 -$(Verb) $(RM) -rf Debug Release Profile
1605 ###############################################################################
1606 # DEPENDENCIES: Include the dependency files if we should
1607 ###############################################################################
1608 ifndef DISABLE_AUTO_DEPENDENCIES
1610 # If its not one of the cleaning targets
1611 ifndef IS_CLEANING_TARGET
1613 # Get the list of dependency files
1614 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1615 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1617 -include $(DependFiles) ""
1623 ###############################################################################
1624 # CHECK: Running the test suite
1625 ###############################################################################
1628 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1629 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1630 $(EchoCmd) Running test suite ; \
1631 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1632 TESTSUITE=$(TESTSUITE) ; \
1634 $(EchoCmd) No Makefile in test directory ; \
1637 $(EchoCmd) No test directory ; \
1640 # An alias dating from when both lit and DejaGNU test runners were used.
1644 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1645 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1646 $(EchoCmd) Running test suite ; \
1647 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1649 $(EchoCmd) No Makefile in test directory ; \
1652 $(EchoCmd) No test directory ; \
1655 ###############################################################################
1656 # UNITTESTS: Running the unittests test suite
1657 ###############################################################################
1660 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1661 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1662 $(EchoCmd) Running unittests test suite ; \
1663 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1665 $(EchoCmd) No Makefile in unittests directory ; \
1668 $(EchoCmd) No unittests directory ; \
1671 ###############################################################################
1672 # DISTRIBUTION: Handle construction of a distribution tarball
1673 ###############################################################################
1675 #------------------------------------------------------------------------
1676 # Define distribution related variables
1677 #------------------------------------------------------------------------
1678 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1679 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1680 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1681 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1682 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1683 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1684 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1685 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1686 Makefile.config.in configure autoconf
1687 DistOther := $(notdir $(wildcard \
1688 $(PROJ_SRC_DIR)/*.h \
1689 $(PROJ_SRC_DIR)/*.td \
1690 $(PROJ_SRC_DIR)/*.def \
1691 $(PROJ_SRC_DIR)/*.ll \
1692 $(PROJ_SRC_DIR)/*.in))
1693 DistSubDirs := $(SubDirs)
1694 DistSources = $(Sources) $(EXTRA_DIST)
1695 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1697 #------------------------------------------------------------------------
1698 # We MUST build distribution with OBJ_DIR != SRC_DIR
1699 #------------------------------------------------------------------------
1700 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1701 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1702 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1706 #------------------------------------------------------------------------
1707 # Prevent attempt to run dist targets from anywhere but the top level
1708 #------------------------------------------------------------------------
1710 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1711 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1714 #------------------------------------------------------------------------
1715 # Provide the top level targets
1716 #------------------------------------------------------------------------
1718 dist-gzip:: $(DistTarGZip)
1720 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1721 $(Echo) Packing gzipped distribution tar file.
1722 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1723 $(GZIP) -c > "$(DistTarGZip)"
1725 dist-bzip2:: $(DistTarBZ2)
1727 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1728 $(Echo) Packing bzipped distribution tar file.
1729 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1730 $(BZIP2) -c >$(DistTarBZ2)
1732 dist-zip:: $(DistZip)
1734 $(DistZip) : $(TopDistDir)/.makedistdir
1735 $(Echo) Packing zipped distribution file.
1736 $(Verb) rm -f $(DistZip)
1737 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1739 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1740 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1742 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1744 dist-check:: $(DistTarGZip)
1745 $(Echo) Checking distribution tar file.
1746 $(Verb) if test -d $(DistCheckDir) ; then \
1747 $(RM) -rf $(DistCheckDir) ; \
1749 $(Verb) $(MKDIR) $(DistCheckDir)
1750 $(Verb) cd $(DistCheckDir) && \
1751 $(MKDIR) $(DistCheckDir)/build && \
1752 $(MKDIR) $(DistCheckDir)/install && \
1753 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1755 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1756 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1759 $(MAKE) unittests && \
1760 $(MAKE) install && \
1761 $(MAKE) uninstall && \
1762 $(MAKE) dist-clean && \
1763 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1766 $(Echo) Cleaning distribution files
1767 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1772 #------------------------------------------------------------------------
1773 # Provide the recursive distdir target for building the distribution directory
1774 #------------------------------------------------------------------------
1775 distdir: $(DistDir)/.makedistdir
1776 $(DistDir)/.makedistdir: $(DistSources)
1777 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1778 if test -d "$(DistDir)" ; then \
1779 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1782 $(EchoCmd) Removing old $(DistDir) ; \
1783 $(RM) -rf $(DistDir); \
1784 $(EchoCmd) Making 'all' to verify build ; \
1785 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1787 $(Echo) Building Distribution Directory $(DistDir)
1788 $(Verb) $(MKDIR) $(DistDir)
1789 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1790 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1791 for file in $(DistFiles) ; do \
1793 $(PROJ_SRC_DIR)/*) \
1794 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1796 $(PROJ_SRC_ROOT)/*) \
1797 file=`echo "$$file" | \
1798 sed "s#^$$srcrootstrip/##"` \
1801 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1802 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1803 from_dir="$(PROJ_SRC_DIR)" ; \
1804 elif test -f "$$file" || test -d "$$file" ; then \
1807 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1808 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1809 to_dir="$(DistDir)/$$dir"; \
1810 $(MKDIR) "$$to_dir" ; \
1812 to_dir="$(DistDir)"; \
1814 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1815 if test -n "$$mid_dir" ; then \
1816 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1818 if test -d "$$from_dir/$$file"; then \
1819 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1820 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1821 cd $(PROJ_SRC_DIR) ; \
1822 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1823 ( cd $$to_dir ; $(TAR) xf - ) ; \
1824 cd $(PROJ_OBJ_DIR) ; \
1827 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1828 ( cd $$to_dir ; $(TAR) xf - ) ; \
1829 cd $(PROJ_OBJ_DIR) ; \
1831 elif test -f "$$from_dir/$$file" ; then \
1832 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1833 elif test -L "$$from_dir/$$file" ; then \
1834 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1835 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1836 $(EchoCmd) "===== WARNING: Distribution Source " \
1837 "$$from_dir/$$file Not Found!" ; \
1838 elif test "$(Verb)" != '@' ; then \
1839 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1842 $(Verb) for subdir in $(DistSubDirs) ; do \
1843 if test "$$subdir" \!= "." ; then \
1844 new_distdir="$(DistDir)/$$subdir" ; \
1845 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1846 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1847 DistDir="$$new_distdir" distdir ) || exit 1; \
1850 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1851 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1852 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1853 -name .svn \) -print` ;\
1854 $(MAKE) dist-hook ; \
1855 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1856 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1857 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1858 -o ! -type d ! -perm -444 -exec \
1859 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1860 || chmod -R a+r $(DistDir) ; \
1863 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1869 ###############################################################################
1870 # TOP LEVEL - targets only to apply at the top level directory
1871 ###############################################################################
1875 #------------------------------------------------------------------------
1876 # Install support for the project's include files:
1877 #------------------------------------------------------------------------
1880 $(Echo) Install circumvented with NO_INSTALL
1882 $(Echo) Uninstall circumvented with NO_INSTALL
1885 $(Echo) Installing include files
1886 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
1887 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1888 cd $(PROJ_SRC_ROOT)/include && \
1889 for hdr in `find . -type f \
1890 '(' -name LICENSE.TXT \
1895 ')' -print | grep -v CVS | \
1896 grep -v .svn` ; do \
1897 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
1898 if test \! -d "$$instdir" ; then \
1899 $(EchoCmd) Making install directory $$instdir ; \
1900 $(MKDIR) $$instdir ;\
1902 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
1905 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1906 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1907 cd $(PROJ_OBJ_ROOT)/include && \
1908 for hdr in `find . -type f \
1909 '(' -name LICENSE.TXT \
1914 ')' -print | grep -v CVS | \
1915 grep -v .svn` ; do \
1916 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
1917 if test \! -d "$$instdir" ; then \
1918 $(EchoCmd) Making install directory $$instdir ; \
1919 $(MKDIR) $$instdir ;\
1921 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
1927 $(Echo) Uninstalling include files
1928 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1929 cd $(PROJ_SRC_ROOT)/include && \
1930 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1931 '!' '(' -name '*~' -o -name '.#*' \
1932 -o -name '*.in' ')' -print ')' | \
1933 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
1934 cd $(PROJ_SRC_ROOT)/include && \
1935 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1936 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
1942 @echo searching for overlength lines in files: $(Sources)
1945 egrep -n '.{81}' $(Sources) /dev/null
1948 @echo searching for tabs in files: $(Sources)
1951 egrep -n ' ' $(Sources) /dev/null
1954 @ls -l $(LibDir) | awk '\
1955 BEGIN { sum = 0; } \
1957 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1958 @ls -l $(ToolDir) | awk '\
1959 BEGIN { sum = 0; } \
1961 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1962 #------------------------------------------------------------------------
1963 # Print out the directories used for building
1964 #------------------------------------------------------------------------
1966 $(Echo) "BuildMode : " '$(BuildMode)'
1967 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1968 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1969 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1970 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1971 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1972 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1973 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1974 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1975 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1976 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1977 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1978 $(Echo) "UserTargets : " '$(UserTargets)'
1979 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1980 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1981 $(Echo) "ObjDir : " '$(ObjDir)'
1982 $(Echo) "LibDir : " '$(LibDir)'
1983 $(Echo) "ToolDir : " '$(ToolDir)'
1984 $(Echo) "ExmplDir : " '$(ExmplDir)'
1985 $(Echo) "Sources : " '$(Sources)'
1986 $(Echo) "TDFiles : " '$(TDFiles)'
1987 $(Echo) "INCFiles : " '$(INCFiles)'
1988 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1989 $(Echo) "PreConditions: " '$(PreConditions)'
1990 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1991 $(Echo) "Compile.C : " '$(Compile.C)'
1992 $(Echo) "Archive : " '$(Archive)'
1993 $(Echo) "YaccFiles : " '$(YaccFiles)'
1994 $(Echo) "LexFiles : " '$(LexFiles)'
1995 $(Echo) "Module : " '$(Module)'
1996 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1997 $(Echo) "SubDirs : " '$(SubDirs)'
1998 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1999 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2004 # General debugging rule, use 'make dbg-print-XXX' to print the
2005 # definition, value and origin of XXX.
2007 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))