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 .bc .td .ps .dot .ll .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),Darwin)
212 OmitFramePointer := -fomit-frame-pointer
216 # Darwin requires -fstrict-aliasing to be explicitly enabled.
217 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
218 # with -fstrict-aliasing and ipa-type-escape radr://6756684
219 #ifeq ($(HOST_OS),Darwin)
220 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
222 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
223 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
224 LD.Flags += $(OPTIMIZE_OPTION)
226 BuildMode := $(BuildMode)+Debug
233 ifdef NO_DEBUG_SYMBOLS
234 BuildMode := Unoptimized
248 ifeq ($(ENABLE_LIBCPP),1)
249 CXX.Flags += -stdlib=libc++
250 LD.Flags += -stdlib=libc++
253 ifeq ($(ENABLE_PROFILING),1)
254 BuildMode := $(BuildMode)+Profile
255 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
256 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
257 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
261 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
262 # CXX.Flags += -fvisibility-inlines-hidden
265 ifdef ENABLE_EXPENSIVE_CHECKS
266 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
267 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
271 # IF REQUIRES_EH=1 is specified then don't disable exceptions
273 CXX.Flags += -fno-exceptions
275 # If the library requires EH, it also requires RTTI.
279 ifdef REQUIRES_FRAME_POINTER
280 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
281 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
282 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
285 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
286 ifneq ($(REQUIRES_RTTI), 1)
287 CXX.Flags += -fno-rtti
290 ifeq ($(ENABLE_COVERAGE),1)
291 BuildMode := $(BuildMode)+Coverage
292 CXX.Flags += -ftest-coverage -fprofile-arcs
293 C.Flags += -ftest-coverage -fprofile-arcs
296 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
297 # then disable assertions by defining the appropriate preprocessor symbols.
298 ifeq ($(DISABLE_ASSERTIONS),1)
299 CPP.Defines += -DNDEBUG
301 BuildMode := $(BuildMode)+Asserts
302 CPP.Defines += -D_DEBUG
305 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
306 # configured), then enable expensive checks by defining the
307 # appropriate preprocessor symbols.
308 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
309 BuildMode := $(BuildMode)+Checks
310 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
313 # LOADABLE_MODULE implies several other things so we force them to be
315 ifdef LOADABLE_MODULE
317 LINK_LIBS_IN_SHARED := 1
325 ifeq ($(ENABLE_PIC),1)
326 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
327 # Nothing. Win32 defaults to PIC and warns when given -fPIC
329 ifeq ($(HOST_OS),Darwin)
330 # Common symbols not allowed in dylib files
331 CXX.Flags += -fno-common
332 C.Flags += -fno-common
334 # Linux and others; pass -fPIC
340 ifeq ($(HOST_OS),Darwin)
341 CXX.Flags += -mdynamic-no-pic
342 C.Flags += -mdynamic-no-pic
346 # Support makefile variable to disable any kind of timestamp/non-deterministic
347 # info from being used in the build.
348 ifeq ($(ENABLE_TIMESTAMPS),1)
349 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
351 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
354 ifeq ($(HOST_OS),MingW)
356 CPP.Defines += -D__NO_CTYPE_INLINE
357 ifeq ($(LLVM_CROSS_COMPILING),1)
358 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
360 LD.Flags += -Wl,--allow-multiple-definition
365 CXX.Flags += -Woverloaded-virtual
366 CPP.BaseFlags += $(CPP.Defines)
369 # Make Floating point IEEE compliant on Alpha.
372 CPP.BaseFlags += -mieee
373 ifeq ($(ENABLE_PIC),0)
375 CPP.BaseFlags += -fPIC
378 LD.Flags += -Wl,--no-relax
381 # GNU ld/PECOFF accepts but ignores them below;
385 # FIXME: autoconf should be aware of them.
386 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
387 HAVE_LINK_VERSION_SCRIPT := 0
389 RDYNAMIC := -Wl,--export-all-symbols
392 #--------------------------------------------------------------------
393 # Directory locations
394 #--------------------------------------------------------------------
396 ifeq ($(LLVM_CROSS_COMPILING),1)
397 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
400 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
401 ObjDir := $(ObjRootDir)
402 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
403 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
404 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
405 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
406 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
407 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
409 #--------------------------------------------------------------------
410 # Locations of shared libraries
411 #--------------------------------------------------------------------
414 SharedLibDir := $(LibDir)
415 LLVMSharedLibDir := $(LLVMLibDir)
417 # Win32.DLL prefers to be located on the "PATH" of binaries.
418 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
419 SharedLibDir := $(ToolDir)
420 LLVMSharedLibDir := $(LLVMToolDir)
422 ifeq ($(HOST_OS),Cygwin)
429 #--------------------------------------------------------------------
430 # LLVM Capable Compiler
431 #--------------------------------------------------------------------
433 ifneq ($(findstring llvm-gcc,$(LLVMCC_OPTION)),)
435 LLVMCXX := $(LLVMGXX)
437 ifneq ($(findstring clang,$(LLVMCC_OPTION)),)
438 ifneq ($(CLANGPATH),)
439 LLVMCC := $(CLANGPATH)
440 LLVMCXX := $(CLANGXXPATH)
442 ifeq ($(ENABLE_BUILT_CLANG),1)
443 LLVMCC := $(LLVMToolDir)/clang
444 LLVMCXX := $(LLVMToolDir)/clang++
450 #--------------------------------------------------------------------
451 # Full Paths To Compiled Tools and Utilities
452 #--------------------------------------------------------------------
453 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
456 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
459 ifeq ($(LLVM_CROSS_COMPILING),1)
460 LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
462 LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
465 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
467 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
470 LLI := $(LLVMToolDir)/lli$(EXEEXT)
473 LLC := $(LLVMToolDir)/llc$(EXEEXT)
476 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
479 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
482 #--------------------------------------------------------------------
483 # Adjust to user's request
484 #--------------------------------------------------------------------
486 ifeq ($(HOST_OS),Darwin)
487 DARWIN_VERSION := `sw_vers -productVersion`
488 # Strip a number like 10.4.7 to 10.4
489 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
490 # Get "4" out of 10.4 for later pieces in the makefile.
491 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
493 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
494 SharedLinkOptions := -dynamiclib
496 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
499 SharedLinkOptions=-shared
502 ifeq ($(TARGET_OS),Darwin)
504 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
509 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
510 ifneq ($(HOST_OS),Darwin)
511 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
523 # Adjust settings for verbose mode
526 AR.Flags += >/dev/null 2>/dev/null
527 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
529 ConfigureScriptFLAGS :=
532 # By default, strip symbol information from executable
534 Strip := $(PLATFORMSTRIPOPTS)
535 StripWarnMsg := "(without symbols)"
536 Install.StripFlag += -s
539 ifdef TOOL_NO_EXPORTS
542 DynamicFlag := $(RDYNAMIC)
545 # Adjust linker flags for building an executable
546 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
547 ifneq ($(HOST_OS), Darwin)
549 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
551 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
553 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
557 ifneq ($(DARWIN_MAJVERS),4)
558 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
564 #----------------------------------------------------------
565 # Options To Invoke Tools
566 #----------------------------------------------------------
568 ifdef EXTRA_LD_OPTIONS
569 LD.Flags += $(EXTRA_LD_OPTIONS)
573 CompileCommonOpts += -pedantic -Wno-long-long
575 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
576 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT)
577 # Enable cast-qual for C++; the workaround is to use const_cast.
578 CXX.Flags += -Wcast-qual
580 ifeq ($(HOST_OS),HP-UX)
581 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
584 # If we are building a universal binary on Mac OS/X, pass extra options. This
585 # is useful to people that want to link the LLVM libraries into their universal
588 # The following can be optionally specified:
589 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
590 # For Mac OS/X 10.4 Intel machines, the traditional one is:
591 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
592 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
593 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
596 ifndef UNIVERSAL_ARCH
597 UNIVERSAL_ARCH := i386 ppc
599 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
600 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
601 ifdef UNIVERSAL_SDK_PATH
602 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
605 # Building universal cannot compute dependencies automatically.
606 DISABLE_AUTO_DEPENDENCIES=1
608 ifeq ($(TARGET_OS),Darwin)
609 ifeq ($(ARCH),x86_64)
610 TargetCommonOpts = -m64
613 TargetCommonOpts = -m32
619 ifeq ($(HOST_OS),SunOS)
620 CPP.BaseFlags += -include llvm/Support/Solaris.h
623 ifeq ($(HOST_OS),AuroraUX)
624 CPP.BaseFlags += -include llvm/Support/Solaris.h
625 endif # !HOST_OS - AuroraUX.
627 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
628 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
629 # All -I flags should go here, so that they don't confuse llvm-config.
630 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
631 $(patsubst %,-I%/include,\
632 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
633 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
636 # SHOW_DIAGNOSTICS support.
637 ifeq ($(SHOW_DIAGNOSTICS),1)
638 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
639 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
644 ifeq ($(BUILD_COMPONENT), 1)
645 Compile.C = $(Compile.Wrapper) \
646 $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
647 $(TargetCommonOpts) $(CompileCommonOpts) -c
648 Compile.CXX = $(Compile.Wrapper) \
649 $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
651 $(TargetCommonOpts) $(CompileCommonOpts) -c
652 Preprocess.CXX= $(Compile.Wrapper) \
653 $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
654 $(CompileCommonOpts) $(CXX.Flags) -E
655 Link = $(Compile.Wrapper) \
656 $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
657 $(LD.Flags) $(LDFLAGS) \
658 $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
660 Compile.C = $(Compile.Wrapper) \
661 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
662 $(TargetCommonOpts) $(CompileCommonOpts) -c
663 Compile.CXX = $(Compile.Wrapper) \
664 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
665 $(TargetCommonOpts) $(CompileCommonOpts) -c
666 Preprocess.CXX= $(Compile.Wrapper) \
667 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
668 $(CompileCommonOpts) $(CXX.Flags) -E
669 Link = $(Compile.Wrapper) \
670 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LD.Flags) \
671 $(LDFLAGS) $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
674 BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
675 $(TargetCommonOpts) $(CompileCommonOpts)
676 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
677 $(TargetCommonOpts) $(CompileCommonOpts) -E
679 BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
680 $(TargetCommonOpts) $(CompileCommonOpts)
682 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
683 ScriptInstall = $(INSTALL) -m 0755
684 DataInstall = $(INSTALL) -m 0644
686 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
687 # paths. In this case, the SYSPATH function (defined in
688 # Makefile.config) transforms Unix paths into Windows paths.
689 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
690 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
691 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
692 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
693 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
695 Archive = $(AR) $(AR.Flags)
696 LArchive = $(LLVMToolDir)/llvm-ar rcsf
705 #----------------------------------------------------------
706 # Get the list of source files and compute object file
708 #----------------------------------------------------------
711 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
712 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
714 Sources := $(SOURCES)
718 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
721 BaseNameSources := $(sort $(basename $(Sources)))
723 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
724 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
726 #----------------------------------------------------------
727 # For Mingw MSYS bash and Python/w32:
729 # $(ECHOPATH) prints DOSish pathstring.
730 # ex) $(ECHOPATH) /include/sys/types.h
731 # --> C:/mingw/include/sys/types.h
732 # built-in "echo" does not transform path to DOSish path.
734 # FIXME: It would not be needed when MSYS's python
736 #----------------------------------------------------------
738 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
739 ECHOPATH := $(Verb)python -u -c "import sys;print ' '.join(sys.argv[1:])"
741 ECHOPATH := $(Verb)$(ECHO)
744 ###############################################################################
745 # DIRECTORIES: Handle recursive descent of directory structure
746 ###############################################################################
748 #---------------------------------------------------------
749 # Provide rules to make install dirs. This must be early
750 # in the file so they get built before dependencies
751 #---------------------------------------------------------
753 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
756 # To create other directories, as needed, and timestamp their creation
758 $(Verb) $(MKDIR) $* > /dev/null
759 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
761 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
762 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
764 #---------------------------------------------------------
765 # Handle the DIRS options for sequential construction
766 #---------------------------------------------------------
772 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
773 $(RecursiveTargets)::
774 $(Verb) for dir in $(DIRS); do \
775 if ([ ! -f $$dir/Makefile ] || \
776 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
778 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
780 ($(MAKE) -C $$dir $@ ) || exit 1; \
783 $(RecursiveTargets)::
784 $(Verb) for dir in $(DIRS); do \
785 ($(MAKE) -C $$dir $@ ) || exit 1; \
791 #---------------------------------------------------------
792 # Handle the EXPERIMENTAL_DIRS options ensuring success
793 # after each directory is built.
794 #---------------------------------------------------------
795 ifdef EXPERIMENTAL_DIRS
796 $(RecursiveTargets)::
797 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
798 if ([ ! -f $$dir/Makefile ] || \
799 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
801 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
803 ($(MAKE) -C $$dir $@ ) || exit 0; \
807 #-----------------------------------------------------------
808 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
809 #-----------------------------------------------------------
810 ifdef OPTIONAL_PARALLEL_DIRS
811 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
814 #-----------------------------------------------------------
815 # Handle the PARALLEL_DIRS options for parallel construction
816 #-----------------------------------------------------------
819 SubDirs += $(PARALLEL_DIRS)
821 # Unfortunately, this list must be maintained if new recursive targets are added
822 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
823 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
824 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
825 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
826 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
827 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
828 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
830 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
833 $(Verb) if ([ ! -f $(@D)/Makefile ] || \
834 command test $(@D)/Makefile -ot \
835 $(PROJ_SRC_DIR)/$(@D)/Makefile ); then \
837 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
839 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
842 #---------------------------------------------------------
843 # Handle the OPTIONAL_DIRS options for directores that may
845 #---------------------------------------------------------
848 SubDirs += $(OPTIONAL_DIRS)
850 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
851 $(RecursiveTargets)::
852 $(Verb) for dir in $(OPTIONAL_DIRS); do \
853 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
854 if ([ ! -f $$dir/Makefile ] || \
855 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
857 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
859 ($(MAKE) -C$$dir $@ ) || exit 1; \
863 $(RecursiveTargets)::
864 $(Verb) for dir in $(OPTIONAL_DIRS); do \
865 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
866 ($(MAKE) -C$$dir $@ ) || exit 1; \
872 #---------------------------------------------------------
873 # Handle the CONFIG_FILES options
874 #---------------------------------------------------------
879 $(Echo) Install circumvented with NO_INSTALL
881 $(Echo) UnInstall circumvented with NO_INSTALL
883 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
884 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
885 $(Verb)for file in $(CONFIG_FILES); do \
886 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
887 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
888 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
889 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
891 $(ECHO) Error: cannot find config file $${file}. ; \
896 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
897 $(Verb)for file in $(CONFIG_FILES); do \
898 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
904 ###############################################################################
905 # Set up variables for building libraries
906 ###############################################################################
908 #---------------------------------------------------------
909 # Define various command line options pertaining to the
910 # libraries needed when linking. There are "Proj" libs
911 # (defined by the user's project) and "LLVM" libs (defined
912 # by the LLVM project).
913 #---------------------------------------------------------
916 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
917 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
918 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
919 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
923 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
924 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
925 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
926 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
929 # Loadable module for Win32 requires all symbols resolved for linking.
930 # Then all symbols in LLVM.dll will be available.
931 ifeq ($(ENABLE_SHARED),1)
932 ifdef LOADABLE_MODULE
933 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
934 LINK_COMPONENTS += all
939 ifndef IS_CLEANING_TARGET
940 ifdef LINK_COMPONENTS
942 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
943 # clean in tools, then do a make in tools (instead of at the top level).
945 @echo "*** llvm-config doesn't exist - rebuilding it."
946 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
948 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
950 ifeq ($(ENABLE_SHARED), 1)
951 # We can take the "auto-import" feature to get rid of using dllimport.
952 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
953 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
956 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
957 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
960 ifndef NO_LLVM_CONFIG
961 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
962 ifeq ($(LLVMConfigLibs),Error)
963 $(error llvm-config --libs failed)
965 LLVMLibsOptions += $(LLVMConfigLibs)
966 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
967 ifeq ($(LLVMConfigLibfiles),Error)
968 $(error llvm-config --libfiles failed)
970 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
977 # Set up the library exports file.
978 ifdef EXPORTED_SYMBOL_FILE
980 # First, set up the native export file, which may differ from the source
983 ifeq ($(HOST_OS),Darwin)
984 # Darwin convention prefixes symbols with underscores.
985 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
986 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
987 $(Verb) sed -e 's/^/_/' < $< > $@
989 -$(Verb) $(RM) -f $(NativeExportsFile)
991 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
992 # Gold and BFD ld require a version script rather than a plain list.
993 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
994 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
995 $(Verb) echo "{" > $@
996 $(Verb) grep -q "\<" $< && echo " global:" >> $@ || :
997 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
998 ifneq ($(HOST_OS),OpenBSD)
999 $(Verb) echo " local: *;" >> $@
1001 $(Verb) echo "};" >> $@
1003 -$(Verb) $(RM) -f $(NativeExportsFile)
1005 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1006 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1007 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1008 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1009 $(Echo) Generating $(notdir $@)
1010 $(Verb) $(ECHO) "EXPORTS" > $@
1011 $(Verb) $(CAT) $< >> $@
1013 -$(Verb) $(RM) -f $(NativeExportsFile)
1015 # Default behavior: just use the exports file verbatim.
1016 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1021 # Now add the linker command-line options to use the native export file.
1024 ifeq ($(HOST_OS),Darwin)
1025 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1028 # gold, bfd ld, etc.
1029 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1030 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1034 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1035 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1036 SharedLinkOptions += $(NativeExportsFile)
1041 ###############################################################################
1042 # Library Build Rules: Four ways to build a library
1043 ###############################################################################
1045 #---------------------------------------------------------
1046 # Bytecode Module Targets:
1047 # If the user set MODULE_NAME then they want to build a
1048 # bytecode module from the sources. We compile all the
1049 # sources and link it together into a single bytecode
1051 #---------------------------------------------------------
1054 ifeq ($(strip $(LLVMCC)),)
1055 $(warning Modules require LLVM capable compiler but none is available ****)
1058 Module := $(LibDir)/$(MODULE_NAME).bc
1059 LinkModule := $(LLVMLD) -r
1062 ifdef EXPORTED_SYMBOL_FILE
1063 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1066 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
1067 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
1068 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1070 all-local:: $(Module)
1073 ifneq ($(strip $(Module)),)
1074 -$(Verb) $(RM) -f $(Module)
1077 ifdef BYTECODE_DESTINATION
1078 ModuleDestDir := $(BYTECODE_DESTINATION)
1080 ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
1085 $(Echo) Install circumvented with NO_INSTALL
1087 $(Echo) Uninstall circumvented with NO_INSTALL
1089 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1091 install-module:: $(DestModule)
1092 install-local:: $(DestModule)
1094 $(DestModule): $(ModuleDestDir) $(Module)
1095 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1096 $(Verb) $(DataInstall) $(Module) $(DestModule)
1099 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1100 -$(Verb) $(RM) -f $(DestModule)
1106 # if we're building a library ...
1109 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1110 LIBRARYNAME := $(strip $(LIBRARYNAME))
1111 ifdef LOADABLE_MODULE
1112 BaseLibName.A := $(LIBRARYNAME).a
1113 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1115 BaseLibName.A := lib$(LIBRARYNAME).a
1116 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1118 LibName.A := $(LibDir)/$(BaseLibName.A)
1119 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1120 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1121 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1123 #---------------------------------------------------------
1124 # Shared Library Targets:
1125 # If the user asked for a shared library to be built
1126 # with the SHARED_LIBRARY variable, then we provide
1127 # targets for building them.
1128 #---------------------------------------------------------
1129 ifdef SHARED_LIBRARY
1131 all-local:: $(LibName.SO)
1133 ifdef EXPORTED_SYMBOL_FILE
1134 $(LibName.SO): $(NativeExportsFile)
1137 ifdef LINK_LIBS_IN_SHARED
1138 ifdef LOADABLE_MODULE
1139 SharedLibKindMessage := "Loadable Module"
1140 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1142 SharedLibKindMessage := "Shared Library"
1144 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1145 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1147 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1148 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1150 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1151 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1152 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1156 ifneq ($(strip $(LibName.SO)),)
1157 -$(Verb) $(RM) -f $(LibName.SO)
1162 $(Echo) Install circumvented with NO_INSTALL
1164 $(Echo) Uninstall circumvented with NO_INSTALL
1167 # Win32.DLL prefers to be located on the "PATH" of binaries.
1168 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1169 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1171 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1173 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1175 install-local:: $(DestSharedLib)
1177 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1178 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1179 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1182 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1183 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
1187 #---------------------------------------------------------
1188 # Bytecode Library Targets:
1189 # If the user asked for a bytecode library to be built
1190 # with the BYTECODE_LIBRARY variable, then we provide
1191 # targets for building them.
1192 #---------------------------------------------------------
1193 ifdef BYTECODE_LIBRARY
1194 ifeq ($(strip $(LLVMCC)),)
1195 $(warning Bytecode libraries require LLVM capable compiler but none is available ****)
1198 all-local:: $(LibName.BCA)
1200 ifdef EXPORTED_SYMBOL_FILE
1201 BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1203 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1204 $(LLVMToolDir)/llvm-ar
1205 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1207 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1209 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1211 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1212 $(LLVMToolDir)/llvm-ar
1213 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1215 $(Verb) $(LArchive) $@ $(ObjectsBC)
1220 ifneq ($(strip $(LibName.BCA)),)
1221 -$(Verb) $(RM) -f $(LibName.BCA)
1224 ifdef BYTECODE_DESTINATION
1225 BytecodeDestDir := $(BYTECODE_DESTINATION)
1227 BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
1230 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1232 install-bytecode-local:: $(DestBytecodeLib)
1236 $(Echo) Install circumvented with NO_INSTALL
1238 $(Echo) Uninstall circumvented with NO_INSTALL
1240 install-local:: $(DestBytecodeLib)
1242 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1243 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1244 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1247 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1248 -$(Verb) $(RM) -f $(DestBytecodeLib)
1253 #---------------------------------------------------------
1255 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1256 # building an archive.
1257 #---------------------------------------------------------
1258 ifndef NO_BUILD_ARCHIVE
1259 ifndef BUILD_ARCHIVE
1260 ifndef LOADABLE_MODULE
1266 #---------------------------------------------------------
1267 # Archive Library Targets:
1268 # If the user wanted a regular archive library built,
1269 # then we provide targets for building them.
1270 #---------------------------------------------------------
1273 all-local:: $(LibName.A)
1275 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1276 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1277 -$(Verb) $(RM) -f $@
1278 $(Verb) $(Archive) $@ $(ObjectsO)
1279 $(Verb) $(Ranlib) $@
1282 ifneq ($(strip $(LibName.A)),)
1283 -$(Verb) $(RM) -f $(LibName.A)
1288 $(Echo) Install circumvented with NO_INSTALL
1290 $(Echo) Uninstall circumvented with NO_INSTALL
1292 ifdef NO_INSTALL_ARCHIVES
1294 $(Echo) Install circumvented with NO_INSTALL
1296 $(Echo) Uninstall circumvented with NO_INSTALL
1298 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1300 install-local:: $(DestArchiveLib)
1302 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1303 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1304 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1305 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1308 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1309 -$(Verb) $(RM) -f $(DestArchiveLib)
1317 ###############################################################################
1318 # Tool Build Rules: Build executable tool based on TOOLNAME option
1319 ###############################################################################
1323 #---------------------------------------------------------
1324 # Set up variables for building a tool.
1325 #---------------------------------------------------------
1326 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1328 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1330 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1333 # TOOLALIAS is a name to symlink (or copy) the tool to.
1336 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1338 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1342 #---------------------------------------------------------
1344 #---------------------------------------------------------
1346 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1347 # not exporting all of the weak symbols from the binary. This reduces dyld
1348 # startup time by 4x on darwin in some cases.
1349 ifdef TOOL_NO_EXPORTS
1350 ifeq ($(HOST_OS),Darwin)
1352 # Tiger tools don't support this.
1353 ifneq ($(DARWIN_MAJVERS),4)
1354 LD.Flags += -Wl,-exported_symbol,_main
1358 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1359 ifneq ($(ARCH), Mips)
1360 LD.Flags += -Wl,--version-script=$(PROJ_SRC_ROOT)/autoconf/ExportMap.map
1365 #---------------------------------------------------------
1366 # Tool Order File Support
1367 #---------------------------------------------------------
1369 ifeq ($(HOST_OS),Darwin)
1370 ifdef TOOL_ORDER_FILE
1372 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1377 #---------------------------------------------------------
1378 # Tool Version Info Support
1379 #---------------------------------------------------------
1381 ifeq ($(HOST_OS),Darwin)
1382 ifdef TOOL_INFO_PLIST
1384 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1386 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1388 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1389 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1390 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1391 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1392 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1393 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1399 #---------------------------------------------------------
1400 # Provide targets for building the tools
1401 #---------------------------------------------------------
1402 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1405 ifneq ($(strip $(ToolBuildPath)),)
1406 -$(Verb) $(RM) -f $(ToolBuildPath)
1408 ifneq ($(strip $(ToolAliasBuildPath)),)
1409 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1413 $(ToolBuildPath): $(ExmplDir)/.dir
1415 $(ToolBuildPath): $(ToolDir)/.dir
1418 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1419 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1420 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1421 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1422 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1425 ifneq ($(strip $(ToolAliasBuildPath)),)
1426 $(ToolAliasBuildPath): $(ToolBuildPath)
1427 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1428 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1429 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1430 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1436 $(Echo) Install circumvented with NO_INSTALL
1438 $(Echo) Uninstall circumvented with NO_INSTALL
1440 DestTool = $(DESTDIR)$(PROJ_bindir)/$(TOOLEXENAME)
1442 install-local:: $(DestTool)
1444 $(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
1445 $(Echo) Installing $(BuildMode) $(DestTool)
1446 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1449 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1450 -$(Verb) $(RM) -f $(DestTool)
1452 # TOOLALIAS install.
1454 DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)
1456 install-local:: $(DestToolAlias)
1458 $(DestToolAlias): $(DestTool)
1459 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1460 $(Verb) $(RM) -f $(DestToolAlias)
1461 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1464 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1465 -$(Verb) $(RM) -f $(DestToolAlias)
1471 ###############################################################################
1472 # Object Build Rules: Build object files based on sources
1473 ###############################################################################
1475 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1476 ifeq ($(HOST_OS),HP-UX)
1477 DISABLE_AUTO_DEPENDENCIES=1
1480 # Provide rule sets for when dependency generation is enabled
1481 ifndef DISABLE_AUTO_DEPENDENCIES
1483 #---------------------------------------------------------
1484 # Create .o files in the ObjDir directory from the .cpp and .c files...
1485 #---------------------------------------------------------
1487 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1488 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1490 # If the build succeeded, move the dependency file over, otherwise
1492 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1493 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1495 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1496 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1497 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1500 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1501 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1502 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1505 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1506 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1507 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1510 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1511 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1512 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1515 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1516 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1517 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1520 #---------------------------------------------------------
1521 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1522 #---------------------------------------------------------
1524 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1525 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1527 # If the build succeeded, move the dependency file over, otherwise
1529 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1530 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1532 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1533 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1534 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1535 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1536 $(BC_DEPEND_MOVEFILE)
1538 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1539 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1540 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1541 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1542 $(BC_DEPEND_MOVEFILE)
1544 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1545 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1546 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1547 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1548 $(BC_DEPEND_MOVEFILE)
1550 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1551 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1552 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1553 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1554 $(BC_DEPEND_MOVEFILE)
1556 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1557 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1558 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1559 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1560 $(BC_DEPEND_MOVEFILE)
1562 # Provide alternate rule sets if dependencies are disabled
1565 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1566 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1567 $(Compile.CXX) $< -o $@
1569 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1570 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1571 $(Compile.CXX) $< -o $@
1573 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1574 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1575 $(Compile.CXX) $< -o $@
1577 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1578 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1579 $(Compile.C) $< -o $@
1581 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1582 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1583 $(Compile.C) $< -o $@
1585 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1586 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1587 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1589 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1590 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1591 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1593 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1594 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1595 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1597 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1598 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1599 $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1601 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1602 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1603 $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1608 ## Rules for building preprocessed (.i/.ii) outputs.
1609 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1610 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1611 $(Verb) $(Preprocess.CXX) $< -o $@
1613 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1614 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1615 $(Verb) $(Preprocess.CXX) $< -o $@
1617 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1618 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1619 $(Verb) $(Preprocess.CXX) $< -o $@
1621 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1622 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1623 $(Verb) $(Preprocess.C) $< -o $@
1625 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1626 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1627 $(Verb) $(Preprocess.C) $< -o $@
1630 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1631 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1632 $(Compile.CXX) $< -o $@ -S
1634 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1635 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1636 $(Compile.CXX) $< -o $@ -S
1638 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1639 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1640 $(Compile.CXX) $< -o $@ -S
1642 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1643 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1644 $(Compile.C) $< -o $@ -S
1646 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1647 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1648 $(Compile.C) $< -o $@ -S
1651 # make the C and C++ compilers strip debug info out of bytecode libraries.
1653 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1654 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1655 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1657 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1658 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1659 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1663 #---------------------------------------------------------
1664 # Provide rule to build .bc files from .ll sources,
1665 # regardless of dependencies
1666 #---------------------------------------------------------
1667 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1668 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1669 $(Verb) $(LLVMAS) $< -f -o $@
1671 ###############################################################################
1672 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1673 ###############################################################################
1676 TABLEGEN_INC_FILES_COMMON = 1
1679 ifdef TABLEGEN_INC_FILES_COMMON
1681 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1682 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1683 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1685 # INCFiles rule: All of the tblgen generated files are emitted to
1686 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1687 # us to only "touch" the real file if the contents of it change. IOW, if
1688 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1689 # dependencies of the .inc files are, unless the contents of the .inc file
1691 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1692 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1694 endif # TABLEGEN_INC_FILES_COMMON
1698 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1699 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1700 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1701 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1702 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1703 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1704 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1706 # All .inc.tmp files depend on the .td files.
1707 $(INCTMPFiles) : $(TDFiles)
1709 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1710 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1711 $(Echo) "Building $(<F) register info implementation with tblgen"
1712 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1714 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1715 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1716 $(Echo) "Building $(<F) instruction information with tblgen"
1717 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1719 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1720 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1721 $(Echo) "Building $(<F) assembly writer with tblgen"
1722 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1724 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1725 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1726 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1727 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1729 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1730 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1731 $(Echo) "Building $(<F) assembly matcher with tblgen"
1732 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1734 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1735 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1736 $(Echo) "Building $(<F) MC code emitter with tblgen"
1737 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1739 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1740 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1741 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1742 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1744 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1745 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1746 $(Echo) "Building $(<F) code emitter with tblgen"
1747 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1749 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1750 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1751 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1752 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1754 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1755 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1756 $(Echo) "Building $(<F) disassembly tables with tblgen"
1757 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1759 $(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1760 $(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1761 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1762 $(Verb) $(LLVMTableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1764 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1765 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1766 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1767 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1769 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1770 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1771 $(Echo) "Building $(<F) subtarget information with tblgen"
1772 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1774 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1775 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1776 $(Echo) "Building $(<F) calling convention information with tblgen"
1777 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1779 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1780 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1781 $(Echo) "Building $(<F) intrinsics information with tblgen"
1782 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1784 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1785 $(Echo) "Building $(<F) decoder tables with tblgen"
1786 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1790 -$(Verb) $(RM) -f $(INCFiles)
1794 ###############################################################################
1795 # OTHER RULES: Other rules needed
1796 ###############################################################################
1798 # To create postscript files from dot files...
1799 ifneq ($(DOT),false)
1801 $(DOT) -Tps < $< > $@
1804 $(Echo) "Cannot build $@: The program dot is not installed"
1807 # This rules ensures that header files that are removed still have a rule for
1808 # which they can be "generated." This allows make to ignore them and
1809 # reproduce the dependency lists.
1813 # Define clean-local to clean the current directory. Note that this uses a
1814 # very conservative approach ensuring that empty variables do not cause
1815 # errors or disastrous removal.
1817 ifneq ($(strip $(ObjRootDir)),)
1818 -$(Verb) $(RM) -rf $(ObjRootDir)
1820 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1821 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1822 -$(Verb) $(RM) -f *$(SHLIBEXT)
1826 -$(Verb) $(RM) -rf Debug Release Profile
1829 ###############################################################################
1830 # DEPENDENCIES: Include the dependency files if we should
1831 ###############################################################################
1832 ifndef DISABLE_AUTO_DEPENDENCIES
1834 # If its not one of the cleaning targets
1835 ifndef IS_CLEANING_TARGET
1837 # Get the list of dependency files
1838 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1839 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1841 # Include bitcode dependency files if using bitcode libraries
1842 ifdef BYTECODE_LIBRARY
1843 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1846 -include $(DependFiles) ""
1852 ###############################################################################
1853 # CHECK: Running the test suite
1854 ###############################################################################
1857 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1858 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1859 $(EchoCmd) Running test suite ; \
1860 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1861 TESTSUITE=$(TESTSUITE) ; \
1863 $(EchoCmd) No Makefile in test directory ; \
1866 $(EchoCmd) No test directory ; \
1869 # An alias dating from when both lit and DejaGNU test runners were used.
1873 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1874 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1875 $(EchoCmd) Running test suite ; \
1876 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1878 $(EchoCmd) No Makefile in test directory ; \
1881 $(EchoCmd) No test directory ; \
1884 ###############################################################################
1885 # UNITTESTS: Running the unittests test suite
1886 ###############################################################################
1889 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1890 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1891 $(EchoCmd) Running unittests test suite ; \
1892 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1894 $(EchoCmd) No Makefile in unittests directory ; \
1897 $(EchoCmd) No unittests directory ; \
1900 ###############################################################################
1901 # DISTRIBUTION: Handle construction of a distribution tarball
1902 ###############################################################################
1904 #------------------------------------------------------------------------
1905 # Define distribution related variables
1906 #------------------------------------------------------------------------
1907 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1908 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1909 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1910 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1911 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1912 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1913 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1914 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1915 Makefile.config.in configure autoconf
1916 DistOther := $(notdir $(wildcard \
1917 $(PROJ_SRC_DIR)/*.h \
1918 $(PROJ_SRC_DIR)/*.td \
1919 $(PROJ_SRC_DIR)/*.def \
1920 $(PROJ_SRC_DIR)/*.ll \
1921 $(PROJ_SRC_DIR)/*.in))
1922 DistSubDirs := $(SubDirs)
1923 DistSources = $(Sources) $(EXTRA_DIST)
1924 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1926 #------------------------------------------------------------------------
1927 # We MUST build distribution with OBJ_DIR != SRC_DIR
1928 #------------------------------------------------------------------------
1929 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1930 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1931 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1935 #------------------------------------------------------------------------
1936 # Prevent attempt to run dist targets from anywhere but the top level
1937 #------------------------------------------------------------------------
1939 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1940 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1943 #------------------------------------------------------------------------
1944 # Provide the top level targets
1945 #------------------------------------------------------------------------
1947 dist-gzip:: $(DistTarGZip)
1949 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1950 $(Echo) Packing gzipped distribution tar file.
1951 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1952 $(GZIP) -c > "$(DistTarGZip)"
1954 dist-bzip2:: $(DistTarBZ2)
1956 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1957 $(Echo) Packing bzipped distribution tar file.
1958 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1959 $(BZIP2) -c >$(DistTarBZ2)
1961 dist-zip:: $(DistZip)
1963 $(DistZip) : $(TopDistDir)/.makedistdir
1964 $(Echo) Packing zipped distribution file.
1965 $(Verb) rm -f $(DistZip)
1966 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1968 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1969 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1971 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1973 dist-check:: $(DistTarGZip)
1974 $(Echo) Checking distribution tar file.
1975 $(Verb) if test -d $(DistCheckDir) ; then \
1976 $(RM) -rf $(DistCheckDir) ; \
1978 $(Verb) $(MKDIR) $(DistCheckDir)
1979 $(Verb) cd $(DistCheckDir) && \
1980 $(MKDIR) $(DistCheckDir)/build && \
1981 $(MKDIR) $(DistCheckDir)/install && \
1982 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1984 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1985 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1988 $(MAKE) unittests && \
1989 $(MAKE) install && \
1990 $(MAKE) uninstall && \
1991 $(MAKE) dist-clean && \
1992 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1995 $(Echo) Cleaning distribution files
1996 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
2001 #------------------------------------------------------------------------
2002 # Provide the recursive distdir target for building the distribution directory
2003 #------------------------------------------------------------------------
2004 distdir: $(DistDir)/.makedistdir
2005 $(DistDir)/.makedistdir: $(DistSources)
2006 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2007 if test -d "$(DistDir)" ; then \
2008 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
2011 $(EchoCmd) Removing old $(DistDir) ; \
2012 $(RM) -rf $(DistDir); \
2013 $(EchoCmd) Making 'all' to verify build ; \
2014 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
2016 $(Echo) Building Distribution Directory $(DistDir)
2017 $(Verb) $(MKDIR) $(DistDir)
2018 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
2019 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
2020 for file in $(DistFiles) ; do \
2022 $(PROJ_SRC_DIR)/*) \
2023 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
2025 $(PROJ_SRC_ROOT)/*) \
2026 file=`echo "$$file" | \
2027 sed "s#^$$srcrootstrip/##"` \
2030 if test -f "$(PROJ_SRC_DIR)/$$file" || \
2031 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
2032 from_dir="$(PROJ_SRC_DIR)" ; \
2033 elif test -f "$$file" || test -d "$$file" ; then \
2036 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
2037 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
2038 to_dir="$(DistDir)/$$dir"; \
2039 $(MKDIR) "$$to_dir" ; \
2041 to_dir="$(DistDir)"; \
2043 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
2044 if test -n "$$mid_dir" ; then \
2045 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
2047 if test -d "$$from_dir/$$file"; then \
2048 if test -d "$(PROJ_SRC_DIR)/$$file" && \
2049 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
2050 cd $(PROJ_SRC_DIR) ; \
2051 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2052 ( cd $$to_dir ; $(TAR) xf - ) ; \
2053 cd $(PROJ_OBJ_DIR) ; \
2056 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2057 ( cd $$to_dir ; $(TAR) xf - ) ; \
2058 cd $(PROJ_OBJ_DIR) ; \
2060 elif test -f "$$from_dir/$$file" ; then \
2061 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
2062 elif test -L "$$from_dir/$$file" ; then \
2063 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
2064 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
2065 $(EchoCmd) "===== WARNING: Distribution Source " \
2066 "$$from_dir/$$file Not Found!" ; \
2067 elif test "$(Verb)" != '@' ; then \
2068 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
2071 $(Verb) for subdir in $(DistSubDirs) ; do \
2072 if test "$$subdir" \!= "." ; then \
2073 new_distdir="$(DistDir)/$$subdir" ; \
2074 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
2075 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
2076 DistDir="$$new_distdir" distdir ) || exit 1; \
2079 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2080 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2081 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2082 -name .svn \) -print` ;\
2083 $(MAKE) dist-hook ; \
2084 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2085 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2086 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2087 -o ! -type d ! -perm -444 -exec \
2088 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2089 || chmod -R a+r $(DistDir) ; \
2092 # This is invoked by distdir target, define it as a no-op to avoid errors if not
2098 ###############################################################################
2099 # TOP LEVEL - targets only to apply at the top level directory
2100 ###############################################################################
2104 #------------------------------------------------------------------------
2105 # Install support for the project's include files:
2106 #------------------------------------------------------------------------
2109 $(Echo) Install circumvented with NO_INSTALL
2111 $(Echo) Uninstall circumvented with NO_INSTALL
2114 $(Echo) Installing include files
2115 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2116 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2117 cd $(PROJ_SRC_ROOT)/include && \
2118 for hdr in `find . -type f \
2119 '(' -name LICENSE.TXT \
2124 ')' -print | grep -v CVS | \
2125 grep -v .svn` ; do \
2126 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2127 if test \! -d "$$instdir" ; then \
2128 $(EchoCmd) Making install directory $$instdir ; \
2129 $(MKDIR) $$instdir ;\
2131 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2134 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2135 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2136 cd $(PROJ_OBJ_ROOT)/include && \
2137 for hdr in `find . -type f \
2138 '(' -name LICENSE.TXT \
2143 ')' -print | grep -v CVS | \
2144 grep -v .svn` ; do \
2145 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2146 if test \! -d "$$instdir" ; then \
2147 $(EchoCmd) Making install directory $$instdir ; \
2148 $(MKDIR) $$instdir ;\
2150 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2156 $(Echo) Uninstalling include files
2157 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2158 cd $(PROJ_SRC_ROOT)/include && \
2159 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2160 '!' '(' -name '*~' -o -name '.#*' \
2161 -o -name '*.in' ')' -print ')' | \
2162 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2163 cd $(PROJ_SRC_ROOT)/include && \
2164 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2165 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2171 @echo searching for overlength lines in files: $(Sources)
2174 egrep -n '.{81}' $(Sources) /dev/null
2177 @echo searching for tabs in files: $(Sources)
2180 egrep -n ' ' $(Sources) /dev/null
2183 @ls -l $(LibDir) | awk '\
2184 BEGIN { sum = 0; } \
2186 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2187 @ls -l $(ToolDir) | awk '\
2188 BEGIN { sum = 0; } \
2190 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2191 #------------------------------------------------------------------------
2192 # Print out the directories used for building
2193 #------------------------------------------------------------------------
2195 $(Echo) "BuildMode : " '$(BuildMode)'
2196 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2197 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2198 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2199 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2200 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2201 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2202 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2203 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2204 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2205 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2206 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2207 $(Echo) "UserTargets : " '$(UserTargets)'
2208 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2209 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2210 $(Echo) "ObjDir : " '$(ObjDir)'
2211 $(Echo) "LibDir : " '$(LibDir)'
2212 $(Echo) "ToolDir : " '$(ToolDir)'
2213 $(Echo) "ExmplDir : " '$(ExmplDir)'
2214 $(Echo) "Sources : " '$(Sources)'
2215 $(Echo) "TDFiles : " '$(TDFiles)'
2216 $(Echo) "INCFiles : " '$(INCFiles)'
2217 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2218 $(Echo) "PreConditions: " '$(PreConditions)'
2219 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2220 $(Echo) "Compile.C : " '$(Compile.C)'
2221 $(Echo) "Archive : " '$(Archive)'
2222 $(Echo) "YaccFiles : " '$(YaccFiles)'
2223 $(Echo) "LexFiles : " '$(LexFiles)'
2224 $(Echo) "Module : " '$(Module)'
2225 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2226 $(Echo) "SubDirs : " '$(SubDirs)'
2227 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2228 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2233 # General debugging rule, use 'make dbg-print-XXX' to print the
2234 # definition, value and origin of XXX.
2236 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))