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 ifdef TOOL_NO_EXPORTS
540 DynamicFlag := $(RDYNAMIC)
543 # Adjust linker flags for building an executable
544 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
545 ifneq ($(HOST_OS), Darwin)
547 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
549 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
551 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
555 ifneq ($(DARWIN_MAJVERS),4)
556 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
562 #----------------------------------------------------------
563 # Options To Invoke Tools
564 #----------------------------------------------------------
566 ifdef EXTRA_LD_OPTIONS
567 LD.Flags += $(EXTRA_LD_OPTIONS)
571 CompileCommonOpts += -pedantic -Wno-long-long
573 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
574 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT)
575 # Enable cast-qual for C++; the workaround is to use const_cast.
576 CXX.Flags += -Wcast-qual
578 ifeq ($(HOST_OS),HP-UX)
579 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
582 # If we are building a universal binary on Mac OS/X, pass extra options. This
583 # is useful to people that want to link the LLVM libraries into their universal
586 # The following can be optionally specified:
587 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
588 # For Mac OS/X 10.4 Intel machines, the traditional one is:
589 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
590 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
591 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
594 ifndef UNIVERSAL_ARCH
595 UNIVERSAL_ARCH := i386 ppc
597 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
598 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
599 ifdef UNIVERSAL_SDK_PATH
600 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
603 # Building universal cannot compute dependencies automatically.
604 DISABLE_AUTO_DEPENDENCIES=1
606 ifeq ($(TARGET_OS),Darwin)
607 ifeq ($(ARCH),x86_64)
608 TargetCommonOpts = -m64
611 TargetCommonOpts = -m32
617 ifeq ($(HOST_OS),SunOS)
618 CPP.BaseFlags += -include llvm/Support/Solaris.h
621 ifeq ($(HOST_OS),AuroraUX)
622 CPP.BaseFlags += -include llvm/Support/Solaris.h
623 endif # !HOST_OS - AuroraUX.
625 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
626 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
627 # All -I flags should go here, so that they don't confuse llvm-config.
628 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
629 $(patsubst %,-I%/include,\
630 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
631 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
634 # SHOW_DIAGNOSTICS support.
635 ifeq ($(SHOW_DIAGNOSTICS),1)
636 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
637 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
642 ifeq ($(BUILD_COMPONENT), 1)
643 Compile.C = $(Compile.Wrapper) \
644 $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
645 $(TargetCommonOpts) $(CompileCommonOpts) -c
646 Compile.CXX = $(Compile.Wrapper) \
647 $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
649 $(TargetCommonOpts) $(CompileCommonOpts) -c
650 Preprocess.CXX= $(Compile.Wrapper) \
651 $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
652 $(CompileCommonOpts) $(CXX.Flags) -E
653 Link = $(Compile.Wrapper) \
654 $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
655 $(LD.Flags) $(LDFLAGS) \
656 $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
658 Compile.C = $(Compile.Wrapper) \
659 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
660 $(TargetCommonOpts) $(CompileCommonOpts) -c
661 Compile.CXX = $(Compile.Wrapper) \
662 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
663 $(TargetCommonOpts) $(CompileCommonOpts) -c
664 Preprocess.CXX= $(Compile.Wrapper) \
665 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
666 $(CompileCommonOpts) $(CXX.Flags) -E
667 Link = $(Compile.Wrapper) \
668 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LD.Flags) \
669 $(LDFLAGS) $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
672 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
673 $(TargetCommonOpts) $(CompileCommonOpts) -E
675 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
676 ScriptInstall = $(INSTALL) -m 0755
677 DataInstall = $(INSTALL) -m 0644
679 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
680 # paths. In this case, the SYSPATH function (defined in
681 # Makefile.config) transforms Unix paths into Windows paths.
682 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
683 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
684 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
685 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
686 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
688 Archive = $(AR) $(AR.Flags)
697 #----------------------------------------------------------
698 # Get the list of source files and compute object file
700 #----------------------------------------------------------
703 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
704 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
706 Sources := $(SOURCES)
710 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
713 BaseNameSources := $(sort $(basename $(Sources)))
715 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
717 #----------------------------------------------------------
718 # For Mingw MSYS bash and Python/w32:
720 # $(ECHOPATH) prints DOSish pathstring.
721 # ex) $(ECHOPATH) /include/sys/types.h
722 # --> C:/mingw/include/sys/types.h
723 # built-in "echo" does not transform path to DOSish path.
725 # FIXME: It would not be needed when MSYS's python
727 #----------------------------------------------------------
729 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
730 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
732 ECHOPATH := $(Verb)$(ECHO)
735 ###############################################################################
736 # DIRECTORIES: Handle recursive descent of directory structure
737 ###############################################################################
739 #---------------------------------------------------------
740 # Provide rules to make install dirs. This must be early
741 # in the file so they get built before dependencies
742 #---------------------------------------------------------
744 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
747 # To create other directories, as needed, and timestamp their creation
749 $(Verb) $(MKDIR) $* > /dev/null
750 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
752 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
753 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
755 #---------------------------------------------------------
756 # Handle the DIRS options for sequential construction
757 #---------------------------------------------------------
763 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
764 $(RecursiveTargets)::
765 $(Verb) for dir in $(DIRS); do \
766 if ([ ! -f $$dir/Makefile ] || \
767 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
769 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
771 ($(MAKE) -C $$dir $@ ) || exit 1; \
774 $(RecursiveTargets)::
775 $(Verb) for dir in $(DIRS); do \
776 ($(MAKE) -C $$dir $@ ) || exit 1; \
782 #---------------------------------------------------------
783 # Handle the EXPERIMENTAL_DIRS options ensuring success
784 # after each directory is built.
785 #---------------------------------------------------------
786 ifdef EXPERIMENTAL_DIRS
787 $(RecursiveTargets)::
788 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
789 if ([ ! -f $$dir/Makefile ] || \
790 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
792 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
794 ($(MAKE) -C $$dir $@ ) || exit 0; \
798 #-----------------------------------------------------------
799 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
800 #-----------------------------------------------------------
801 ifdef OPTIONAL_PARALLEL_DIRS
802 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
805 #-----------------------------------------------------------
806 # Handle the PARALLEL_DIRS options for parallel construction
807 #-----------------------------------------------------------
810 SubDirs += $(PARALLEL_DIRS)
812 # Unfortunately, this list must be maintained if new recursive targets are added
813 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
814 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
815 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
816 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
817 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
818 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
819 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
821 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
824 $(Verb) if ([ ! -f $(@D)/Makefile ] || \
825 command test $(@D)/Makefile -ot \
826 $(PROJ_SRC_DIR)/$(@D)/Makefile ); then \
828 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
830 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
833 #---------------------------------------------------------
834 # Handle the OPTIONAL_DIRS options for directores that may
836 #---------------------------------------------------------
839 SubDirs += $(OPTIONAL_DIRS)
841 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
842 $(RecursiveTargets)::
843 $(Verb) for dir in $(OPTIONAL_DIRS); do \
844 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
845 if ([ ! -f $$dir/Makefile ] || \
846 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
848 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
850 ($(MAKE) -C$$dir $@ ) || exit 1; \
854 $(RecursiveTargets)::
855 $(Verb) for dir in $(OPTIONAL_DIRS); do \
856 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
857 ($(MAKE) -C$$dir $@ ) || exit 1; \
863 #---------------------------------------------------------
864 # Handle the CONFIG_FILES options
865 #---------------------------------------------------------
870 $(Echo) Install circumvented with NO_INSTALL
872 $(Echo) UnInstall circumvented with NO_INSTALL
874 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
875 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
876 $(Verb)for file in $(CONFIG_FILES); do \
877 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
878 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
879 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
880 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
882 $(ECHO) Error: cannot find config file $${file}. ; \
887 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
888 $(Verb)for file in $(CONFIG_FILES); do \
889 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
895 ###############################################################################
896 # Set up variables for building libraries
897 ###############################################################################
899 #---------------------------------------------------------
900 # Define various command line options pertaining to the
901 # libraries needed when linking. There are "Proj" libs
902 # (defined by the user's project) and "LLVM" libs (defined
903 # by the LLVM project).
904 #---------------------------------------------------------
907 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
908 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
909 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
910 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
914 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
915 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
916 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
917 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
920 # Loadable module for Win32 requires all symbols resolved for linking.
921 # Then all symbols in LLVM.dll will be available.
922 ifeq ($(ENABLE_SHARED),1)
923 ifdef LOADABLE_MODULE
924 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
925 LINK_COMPONENTS += all
930 ifndef IS_CLEANING_TARGET
931 ifdef LINK_COMPONENTS
933 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
934 # clean in tools, then do a make in tools (instead of at the top level).
936 @echo "*** llvm-config doesn't exist - rebuilding it."
937 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
939 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
941 ifeq ($(ENABLE_SHARED), 1)
942 # We can take the "auto-import" feature to get rid of using dllimport.
943 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
944 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
947 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
948 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
951 ifndef NO_LLVM_CONFIG
952 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
953 ifeq ($(LLVMConfigLibs),Error)
954 $(error llvm-config --libs failed)
956 LLVMLibsOptions += $(LLVMConfigLibs)
957 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
958 ifeq ($(LLVMConfigLibfiles),Error)
959 $(error llvm-config --libfiles failed)
961 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
968 # Set up the library exports file.
969 ifdef EXPORTED_SYMBOL_FILE
971 # First, set up the native export file, which may differ from the source
974 ifeq ($(HOST_OS),Darwin)
975 # Darwin convention prefixes symbols with underscores.
976 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
977 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
978 $(Verb) sed -e 's/^/_/' < $< > $@
980 -$(Verb) $(RM) -f $(NativeExportsFile)
982 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
983 # Gold and BFD ld require a version script rather than a plain list.
984 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
985 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
986 $(Verb) echo "{" > $@
987 $(Verb) grep -q "\<" $< && echo " global:" >> $@ || :
988 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
989 ifneq ($(HOST_OS),OpenBSD)
990 $(Verb) echo " local: *;" >> $@
992 $(Verb) echo "};" >> $@
994 -$(Verb) $(RM) -f $(NativeExportsFile)
996 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
997 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
998 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
999 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1000 $(Echo) Generating $(notdir $@)
1001 $(Verb) $(ECHO) "EXPORTS" > $@
1002 $(Verb) $(CAT) $< >> $@
1004 -$(Verb) $(RM) -f $(NativeExportsFile)
1006 # Default behavior: just use the exports file verbatim.
1007 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1012 # Now add the linker command-line options to use the native export file.
1015 ifeq ($(HOST_OS),Darwin)
1016 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1019 # gold, bfd ld, etc.
1020 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1021 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1025 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1026 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1027 SharedLinkOptions += $(NativeExportsFile)
1032 ###############################################################################
1033 # Library Build Rules: Four ways to build a library
1034 ###############################################################################
1036 # if we're building a library ...
1039 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1040 LIBRARYNAME := $(strip $(LIBRARYNAME))
1041 ifdef LOADABLE_MODULE
1042 BaseLibName.A := $(LIBRARYNAME).a
1043 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1045 BaseLibName.A := lib$(LIBRARYNAME).a
1046 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1048 LibName.A := $(LibDir)/$(BaseLibName.A)
1049 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1050 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1052 #---------------------------------------------------------
1053 # Shared Library Targets:
1054 # If the user asked for a shared library to be built
1055 # with the SHARED_LIBRARY variable, then we provide
1056 # targets for building them.
1057 #---------------------------------------------------------
1058 ifdef SHARED_LIBRARY
1060 all-local:: $(LibName.SO)
1062 ifdef EXPORTED_SYMBOL_FILE
1063 $(LibName.SO): $(NativeExportsFile)
1066 ifdef LINK_LIBS_IN_SHARED
1067 ifdef LOADABLE_MODULE
1068 SharedLibKindMessage := "Loadable Module"
1069 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1071 SharedLibKindMessage := "Shared Library"
1073 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1074 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1076 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1077 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1079 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1080 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1081 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1085 ifneq ($(strip $(LibName.SO)),)
1086 -$(Verb) $(RM) -f $(LibName.SO)
1091 $(Echo) Install circumvented with NO_INSTALL
1093 $(Echo) Uninstall circumvented with NO_INSTALL
1096 # Win32.DLL prefers to be located on the "PATH" of binaries.
1097 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1098 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1100 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1102 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1104 install-local:: $(DestSharedLib)
1106 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1107 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1108 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1111 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1112 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
1116 #---------------------------------------------------------
1118 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1119 # building an archive.
1120 #---------------------------------------------------------
1121 ifndef NO_BUILD_ARCHIVE
1122 ifndef BUILD_ARCHIVE
1123 ifndef LOADABLE_MODULE
1129 #---------------------------------------------------------
1130 # Archive Library Targets:
1131 # If the user wanted a regular archive library built,
1132 # then we provide targets for building them.
1133 #---------------------------------------------------------
1136 all-local:: $(LibName.A)
1138 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1139 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1140 -$(Verb) $(RM) -f $@
1141 $(Verb) $(Archive) $@ $(ObjectsO)
1142 $(Verb) $(Ranlib) $@
1145 ifneq ($(strip $(LibName.A)),)
1146 -$(Verb) $(RM) -f $(LibName.A)
1151 $(Echo) Install circumvented with NO_INSTALL
1153 $(Echo) Uninstall circumvented with NO_INSTALL
1155 ifdef NO_INSTALL_ARCHIVES
1157 $(Echo) Install circumvented with NO_INSTALL
1159 $(Echo) Uninstall circumvented with NO_INSTALL
1161 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1163 install-local:: $(DestArchiveLib)
1165 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1166 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1167 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1168 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1171 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1172 -$(Verb) $(RM) -f $(DestArchiveLib)
1180 ###############################################################################
1181 # Tool Build Rules: Build executable tool based on TOOLNAME option
1182 ###############################################################################
1186 #---------------------------------------------------------
1187 # Set up variables for building a tool.
1188 #---------------------------------------------------------
1189 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1191 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1193 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1196 # TOOLALIAS is a name to symlink (or copy) the tool to.
1199 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1201 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1205 #---------------------------------------------------------
1207 #---------------------------------------------------------
1209 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1210 # not exporting all of the weak symbols from the binary. This reduces dyld
1211 # startup time by 4x on darwin in some cases.
1212 ifdef TOOL_NO_EXPORTS
1213 ifeq ($(HOST_OS),Darwin)
1215 # Tiger tools don't support this.
1216 ifneq ($(DARWIN_MAJVERS),4)
1217 LD.Flags += -Wl,-exported_symbol,_main
1221 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD GNU/kFreeBSD))
1222 ifneq ($(ARCH), Mips)
1223 LD.Flags += -Wl,--version-script=$(PROJ_SRC_ROOT)/autoconf/ExportMap.map
1228 #---------------------------------------------------------
1229 # Tool Order File Support
1230 #---------------------------------------------------------
1232 ifeq ($(HOST_OS),Darwin)
1233 ifdef TOOL_ORDER_FILE
1235 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1240 #---------------------------------------------------------
1241 # Tool Version Info Support
1242 #---------------------------------------------------------
1244 ifeq ($(HOST_OS),Darwin)
1245 ifdef TOOL_INFO_PLIST
1247 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1249 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1251 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1252 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1253 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1254 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1255 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1256 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1262 #---------------------------------------------------------
1263 # Provide targets for building the tools
1264 #---------------------------------------------------------
1265 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1268 ifneq ($(strip $(ToolBuildPath)),)
1269 -$(Verb) $(RM) -f $(ToolBuildPath)
1271 ifneq ($(strip $(ToolAliasBuildPath)),)
1272 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1276 $(ToolBuildPath): $(ExmplDir)/.dir
1278 $(ToolBuildPath): $(ToolDir)/.dir
1281 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1282 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1283 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1284 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1285 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1288 ifneq ($(strip $(ToolAliasBuildPath)),)
1289 $(ToolAliasBuildPath): $(ToolBuildPath)
1290 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1291 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1292 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1293 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1299 $(Echo) Install circumvented with NO_INSTALL
1301 $(Echo) Uninstall circumvented with NO_INSTALL
1303 DestTool = $(DESTDIR)$(PROJ_bindir)/$(program_prefix)$(TOOLEXENAME)
1305 install-local:: $(DestTool)
1307 $(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
1308 $(Echo) Installing $(BuildMode) $(DestTool)
1309 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1312 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1313 -$(Verb) $(RM) -f $(DestTool)
1315 # TOOLALIAS install.
1317 DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1319 install-local:: $(DestToolAlias)
1321 $(DestToolAlias): $(DestTool)
1322 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1323 $(Verb) $(RM) -f $(DestToolAlias)
1324 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1327 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1328 -$(Verb) $(RM) -f $(DestToolAlias)
1334 ###############################################################################
1335 # Object Build Rules: Build object files based on sources
1336 ###############################################################################
1338 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1339 ifeq ($(HOST_OS),HP-UX)
1340 DISABLE_AUTO_DEPENDENCIES=1
1343 # Provide rule sets for when dependency generation is enabled
1344 ifndef DISABLE_AUTO_DEPENDENCIES
1346 #---------------------------------------------------------
1347 # Create .o files in the ObjDir directory from the .cpp and .c files...
1348 #---------------------------------------------------------
1350 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1351 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1353 # If the build succeeded, move the dependency file over, otherwise
1355 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1356 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1358 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1359 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1360 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1363 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1364 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1365 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1368 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1369 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1370 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1373 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1374 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1375 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1378 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1379 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1380 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1383 # Provide alternate rule sets if dependencies are disabled
1386 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1387 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1388 $(Compile.CXX) $< -o $@
1390 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1391 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1392 $(Compile.CXX) $< -o $@
1394 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1395 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1396 $(Compile.CXX) $< -o $@
1398 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1399 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1400 $(Compile.C) $< -o $@
1402 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1403 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1404 $(Compile.C) $< -o $@
1408 ## Rules for building preprocessed (.i/.ii) outputs.
1409 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1410 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1411 $(Verb) $(Preprocess.CXX) $< -o $@
1413 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1414 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1415 $(Verb) $(Preprocess.CXX) $< -o $@
1417 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1418 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1419 $(Verb) $(Preprocess.CXX) $< -o $@
1421 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1422 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1423 $(Verb) $(Preprocess.C) $< -o $@
1425 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1426 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1427 $(Verb) $(Preprocess.C) $< -o $@
1430 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1431 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1432 $(Compile.CXX) $< -o $@ -S
1434 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1435 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1436 $(Compile.CXX) $< -o $@ -S
1438 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1439 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1440 $(Compile.CXX) $< -o $@ -S
1442 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1443 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1444 $(Compile.C) $< -o $@ -S
1446 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1447 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1448 $(Compile.C) $< -o $@ -S
1450 ###############################################################################
1451 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1452 ###############################################################################
1455 TABLEGEN_INC_FILES_COMMON = 1
1458 ifdef TABLEGEN_INC_FILES_COMMON
1460 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1461 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1462 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1464 # INCFiles rule: All of the tblgen generated files are emitted to
1465 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1466 # us to only "touch" the real file if the contents of it change. IOW, if
1467 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1468 # dependencies of the .inc files are, unless the contents of the .inc file
1470 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1471 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1473 endif # TABLEGEN_INC_FILES_COMMON
1477 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1478 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1479 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1480 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1481 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1482 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1483 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1485 # All .inc.tmp files depend on the .td files.
1486 $(INCTMPFiles) : $(TDFiles)
1488 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1489 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1490 $(Echo) "Building $(<F) register info implementation with tblgen"
1491 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1493 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1494 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1495 $(Echo) "Building $(<F) instruction information with tblgen"
1496 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1498 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1499 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1500 $(Echo) "Building $(<F) assembly writer with tblgen"
1501 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1503 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1504 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1505 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1506 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1508 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1509 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1510 $(Echo) "Building $(<F) assembly matcher with tblgen"
1511 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1513 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1514 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1515 $(Echo) "Building $(<F) MC code emitter with tblgen"
1516 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1518 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1519 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1520 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1521 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1523 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1524 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1525 $(Echo) "Building $(<F) code emitter with tblgen"
1526 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1528 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1529 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1530 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1531 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1533 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1534 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1535 $(Echo) "Building $(<F) disassembly tables with tblgen"
1536 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1538 $(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1539 $(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1540 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1541 $(Verb) $(LLVMTableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1543 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1544 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1545 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1546 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1548 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1549 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1550 $(Echo) "Building $(<F) subtarget information with tblgen"
1551 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1553 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1554 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1555 $(Echo) "Building $(<F) calling convention information with tblgen"
1556 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1558 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1559 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1560 $(Echo) "Building $(<F) intrinsics information with tblgen"
1561 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1563 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1564 $(Echo) "Building $(<F) decoder tables with tblgen"
1565 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1569 -$(Verb) $(RM) -f $(INCFiles)
1573 ###############################################################################
1574 # OTHER RULES: Other rules needed
1575 ###############################################################################
1577 # To create postscript files from dot files...
1578 ifneq ($(DOT),false)
1580 $(DOT) -Tps < $< > $@
1583 $(Echo) "Cannot build $@: The program dot is not installed"
1586 # This rules ensures that header files that are removed still have a rule for
1587 # which they can be "generated." This allows make to ignore them and
1588 # reproduce the dependency lists.
1592 # Define clean-local to clean the current directory. Note that this uses a
1593 # very conservative approach ensuring that empty variables do not cause
1594 # errors or disastrous removal.
1596 ifneq ($(strip $(ObjRootDir)),)
1597 -$(Verb) $(RM) -rf $(ObjRootDir)
1599 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1600 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1601 -$(Verb) $(RM) -f *$(SHLIBEXT)
1605 -$(Verb) $(RM) -rf Debug Release Profile
1608 ###############################################################################
1609 # DEPENDENCIES: Include the dependency files if we should
1610 ###############################################################################
1611 ifndef DISABLE_AUTO_DEPENDENCIES
1613 # If its not one of the cleaning targets
1614 ifndef IS_CLEANING_TARGET
1616 # Get the list of dependency files
1617 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1618 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1620 -include $(DependFiles) ""
1626 ###############################################################################
1627 # CHECK: Running the test suite
1628 ###############################################################################
1631 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1632 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1633 $(EchoCmd) Running test suite ; \
1634 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1635 TESTSUITE=$(TESTSUITE) ; \
1637 $(EchoCmd) No Makefile in test directory ; \
1640 $(EchoCmd) No test directory ; \
1643 # An alias dating from when both lit and DejaGNU test runners were used.
1647 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1648 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1649 $(EchoCmd) Running test suite ; \
1650 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1652 $(EchoCmd) No Makefile in test directory ; \
1655 $(EchoCmd) No test directory ; \
1658 ###############################################################################
1659 # UNITTESTS: Running the unittests test suite
1660 ###############################################################################
1663 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1664 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1665 $(EchoCmd) Running unittests test suite ; \
1666 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1668 $(EchoCmd) No Makefile in unittests directory ; \
1671 $(EchoCmd) No unittests directory ; \
1674 ###############################################################################
1675 # DISTRIBUTION: Handle construction of a distribution tarball
1676 ###############################################################################
1678 #------------------------------------------------------------------------
1679 # Define distribution related variables
1680 #------------------------------------------------------------------------
1681 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1682 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1683 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1684 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1685 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1686 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1687 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1688 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1689 Makefile.config.in configure autoconf
1690 DistOther := $(notdir $(wildcard \
1691 $(PROJ_SRC_DIR)/*.h \
1692 $(PROJ_SRC_DIR)/*.td \
1693 $(PROJ_SRC_DIR)/*.def \
1694 $(PROJ_SRC_DIR)/*.ll \
1695 $(PROJ_SRC_DIR)/*.in))
1696 DistSubDirs := $(SubDirs)
1697 DistSources = $(Sources) $(EXTRA_DIST)
1698 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1700 #------------------------------------------------------------------------
1701 # We MUST build distribution with OBJ_DIR != SRC_DIR
1702 #------------------------------------------------------------------------
1703 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1704 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1705 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1709 #------------------------------------------------------------------------
1710 # Prevent attempt to run dist targets from anywhere but the top level
1711 #------------------------------------------------------------------------
1713 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1714 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1717 #------------------------------------------------------------------------
1718 # Provide the top level targets
1719 #------------------------------------------------------------------------
1721 dist-gzip:: $(DistTarGZip)
1723 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1724 $(Echo) Packing gzipped distribution tar file.
1725 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1726 $(GZIP) -c > "$(DistTarGZip)"
1728 dist-bzip2:: $(DistTarBZ2)
1730 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1731 $(Echo) Packing bzipped distribution tar file.
1732 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1733 $(BZIP2) -c >$(DistTarBZ2)
1735 dist-zip:: $(DistZip)
1737 $(DistZip) : $(TopDistDir)/.makedistdir
1738 $(Echo) Packing zipped distribution file.
1739 $(Verb) rm -f $(DistZip)
1740 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1742 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1743 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1745 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1747 dist-check:: $(DistTarGZip)
1748 $(Echo) Checking distribution tar file.
1749 $(Verb) if test -d $(DistCheckDir) ; then \
1750 $(RM) -rf $(DistCheckDir) ; \
1752 $(Verb) $(MKDIR) $(DistCheckDir)
1753 $(Verb) cd $(DistCheckDir) && \
1754 $(MKDIR) $(DistCheckDir)/build && \
1755 $(MKDIR) $(DistCheckDir)/install && \
1756 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1758 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1759 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1762 $(MAKE) unittests && \
1763 $(MAKE) install && \
1764 $(MAKE) uninstall && \
1765 $(MAKE) dist-clean && \
1766 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1769 $(Echo) Cleaning distribution files
1770 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1775 #------------------------------------------------------------------------
1776 # Provide the recursive distdir target for building the distribution directory
1777 #------------------------------------------------------------------------
1778 distdir: $(DistDir)/.makedistdir
1779 $(DistDir)/.makedistdir: $(DistSources)
1780 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1781 if test -d "$(DistDir)" ; then \
1782 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1785 $(EchoCmd) Removing old $(DistDir) ; \
1786 $(RM) -rf $(DistDir); \
1787 $(EchoCmd) Making 'all' to verify build ; \
1788 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1790 $(Echo) Building Distribution Directory $(DistDir)
1791 $(Verb) $(MKDIR) $(DistDir)
1792 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1793 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1794 for file in $(DistFiles) ; do \
1796 $(PROJ_SRC_DIR)/*) \
1797 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1799 $(PROJ_SRC_ROOT)/*) \
1800 file=`echo "$$file" | \
1801 sed "s#^$$srcrootstrip/##"` \
1804 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1805 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1806 from_dir="$(PROJ_SRC_DIR)" ; \
1807 elif test -f "$$file" || test -d "$$file" ; then \
1810 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1811 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1812 to_dir="$(DistDir)/$$dir"; \
1813 $(MKDIR) "$$to_dir" ; \
1815 to_dir="$(DistDir)"; \
1817 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1818 if test -n "$$mid_dir" ; then \
1819 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1821 if test -d "$$from_dir/$$file"; then \
1822 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1823 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1824 cd $(PROJ_SRC_DIR) ; \
1825 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1826 ( cd $$to_dir ; $(TAR) xf - ) ; \
1827 cd $(PROJ_OBJ_DIR) ; \
1830 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1831 ( cd $$to_dir ; $(TAR) xf - ) ; \
1832 cd $(PROJ_OBJ_DIR) ; \
1834 elif test -f "$$from_dir/$$file" ; then \
1835 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1836 elif test -L "$$from_dir/$$file" ; then \
1837 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1838 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1839 $(EchoCmd) "===== WARNING: Distribution Source " \
1840 "$$from_dir/$$file Not Found!" ; \
1841 elif test "$(Verb)" != '@' ; then \
1842 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1845 $(Verb) for subdir in $(DistSubDirs) ; do \
1846 if test "$$subdir" \!= "." ; then \
1847 new_distdir="$(DistDir)/$$subdir" ; \
1848 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1849 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1850 DistDir="$$new_distdir" distdir ) || exit 1; \
1853 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1854 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1855 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1856 -name .svn \) -print` ;\
1857 $(MAKE) dist-hook ; \
1858 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1859 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1860 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1861 -o ! -type d ! -perm -444 -exec \
1862 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1863 || chmod -R a+r $(DistDir) ; \
1866 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1872 ###############################################################################
1873 # TOP LEVEL - targets only to apply at the top level directory
1874 ###############################################################################
1878 #------------------------------------------------------------------------
1879 # Install support for the project's include files:
1880 #------------------------------------------------------------------------
1883 $(Echo) Install circumvented with NO_INSTALL
1885 $(Echo) Uninstall circumvented with NO_INSTALL
1888 $(Echo) Installing include files
1889 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
1890 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1891 cd $(PROJ_SRC_ROOT)/include && \
1892 for hdr in `find . -type f \
1893 '(' -name LICENSE.TXT \
1898 ')' -print | grep -v CVS | \
1899 grep -v .svn` ; do \
1900 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
1901 if test \! -d "$$instdir" ; then \
1902 $(EchoCmd) Making install directory $$instdir ; \
1903 $(MKDIR) $$instdir ;\
1905 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
1908 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1909 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1910 cd $(PROJ_OBJ_ROOT)/include && \
1911 for hdr in `find . -type f \
1912 '(' -name LICENSE.TXT \
1917 ')' -print | grep -v CVS | \
1918 grep -v .svn` ; do \
1919 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
1920 if test \! -d "$$instdir" ; then \
1921 $(EchoCmd) Making install directory $$instdir ; \
1922 $(MKDIR) $$instdir ;\
1924 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
1930 $(Echo) Uninstalling include files
1931 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1932 cd $(PROJ_SRC_ROOT)/include && \
1933 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1934 '!' '(' -name '*~' -o -name '.#*' \
1935 -o -name '*.in' ')' -print ')' | \
1936 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
1937 cd $(PROJ_SRC_ROOT)/include && \
1938 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1939 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
1945 @echo searching for overlength lines in files: $(Sources)
1948 egrep -n '.{81}' $(Sources) /dev/null
1951 @echo searching for tabs in files: $(Sources)
1954 egrep -n ' ' $(Sources) /dev/null
1957 @ls -l $(LibDir) | awk '\
1958 BEGIN { sum = 0; } \
1960 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1961 @ls -l $(ToolDir) | awk '\
1962 BEGIN { sum = 0; } \
1964 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1965 #------------------------------------------------------------------------
1966 # Print out the directories used for building
1967 #------------------------------------------------------------------------
1969 $(Echo) "BuildMode : " '$(BuildMode)'
1970 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1971 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1972 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1973 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1974 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1975 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1976 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1977 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1978 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1979 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1980 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1981 $(Echo) "UserTargets : " '$(UserTargets)'
1982 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1983 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1984 $(Echo) "ObjDir : " '$(ObjDir)'
1985 $(Echo) "LibDir : " '$(LibDir)'
1986 $(Echo) "ToolDir : " '$(ToolDir)'
1987 $(Echo) "ExmplDir : " '$(ExmplDir)'
1988 $(Echo) "Sources : " '$(Sources)'
1989 $(Echo) "TDFiles : " '$(TDFiles)'
1990 $(Echo) "INCFiles : " '$(INCFiles)'
1991 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1992 $(Echo) "PreConditions: " '$(PreConditions)'
1993 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1994 $(Echo) "Compile.C : " '$(Compile.C)'
1995 $(Echo) "Archive : " '$(Archive)'
1996 $(Echo) "YaccFiles : " '$(YaccFiles)'
1997 $(Echo) "LexFiles : " '$(LexFiles)'
1998 $(Echo) "Module : " '$(Module)'
1999 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2000 $(Echo) "SubDirs : " '$(SubDirs)'
2001 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2002 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2007 # General debugging rule, use 'make dbg-print-XXX' to print the
2008 # definition, value and origin of XXX.
2010 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))