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 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
127 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
129 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
130 $(ConfigStatusScript)
132 # FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
133 # up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
135 .PRECIOUS: $(ConfigStatusScript)
136 $(ConfigStatusScript): $(ConfigureScript) $(LLVM_SRC_ROOT)/lib/Target/PIC16/AsmPrinter/Makefile $(LLVM_SRC_ROOT)/lib/Target/MSP430/AsmPrinter/Makefile
137 $(Echo) Reconfiguring with $<
138 $(Verb) cd $(PROJ_OBJ_ROOT) && \
139 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
140 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
142 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
143 $(ConfigStatusScript)
145 #------------------------------------------------------------------------
146 # Make sure the configuration makefile is up to date
147 #------------------------------------------------------------------------
148 ifneq ($(MakefileConfigIn),)
149 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
150 $(Echo) Regenerating $@
151 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
154 ifneq ($(MakefileCommonIn),)
155 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
156 $(Echo) Regenerating $@
157 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
160 #------------------------------------------------------------------------
161 # If the Makefile in the source tree has been updated, copy it over into the
162 # build tree. But, only do this if the source and object makefiles differ
163 #------------------------------------------------------------------------
164 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
166 Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
167 $(Echo) "Updating Makefile"
168 $(Verb) $(MKDIR) $(@D)
169 $(Verb) $(CP) -f $< $@
171 # Copy the Makefile.* files unless we're in the root directory which avoids
172 # the copying of Makefile.config.in or other things that should be explicitly
174 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
176 *Makefile.rules) ;; \
178 *) $(EchoCmd) "Updating $(@F)" ; \
185 #------------------------------------------------------------------------
186 # Set up the basic dependencies
187 #------------------------------------------------------------------------
188 $(UserTargets):: $(PreConditions)
192 clean-all:: clean-local clean-all-local
193 install:: install-local
194 uninstall:: uninstall-local
195 install-local:: all-local
196 install-bytecode:: install-bytecode-local
198 ###############################################################################
199 # LLVMC: Provide rules for compiling llvmc-based driver
200 ###############################################################################
202 ifdef LLVMC_BASED_DRIVER
204 TOOLNAME = $(LLVMC_BASED_DRIVER)
206 LLVMLIBS = CompilerDriver.a
207 LINK_COMPONENTS = support system
209 endif # LLVMC_BASED_DRIVER
211 ###############################################################################
212 # VARIABLES: Set up various variables based on configuration data
213 ###############################################################################
215 # Variable for if this make is for a "cleaning" target
216 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
220 #--------------------------------------------------------------------
221 # Variables derived from configuration we are building
222 #--------------------------------------------------------------------
225 ifeq ($(ENABLE_OPTIMIZED),1)
227 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
228 ifneq ($(HOST_OS),FreeBSD)
229 ifneq ($(HOST_OS),Darwin)
230 OmitFramePointer := -fomit-frame-pointer
234 # Darwin requires -fstrict-aliasing to be explicitly enabled.
235 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
236 # with -fstrict-aliasing and ipa-type-escape radr://6756684
237 #ifeq ($(HOST_OS),Darwin)
238 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
240 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
241 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
242 LD.Flags += $(OPTIMIZE_OPTION)
244 BuildMode := $(BuildMode)+Debug
251 ifdef NO_DEBUG_SYMBOLS
252 BuildMode := Unoptimized
266 ifeq ($(ENABLE_PROFILING),1)
267 BuildMode := $(BuildMode)+Profile
268 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
269 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
270 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
274 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
275 # CXX.Flags += -fvisibility-inlines-hidden
278 ifdef ENABLE_EXPENSIVE_CHECKS
279 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
280 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
284 # IF REQUIRES_EH=1 is specified then don't disable exceptions
286 CXX.Flags += -fno-exceptions
288 # If the library requires EH, it also requires RTTI.
292 ifdef REQUIRES_FRAME_POINTER
293 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
294 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
295 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
298 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
299 ifneq ($(REQUIRES_RTTI), 1)
300 CXX.Flags += -fno-rtti
303 ifdef ENABLE_COVERAGE
304 BuildMode := $(BuildMode)+Coverage
305 CXX.Flags += -ftest-coverage -fprofile-arcs
306 C.Flags += -ftest-coverage -fprofile-arcs
309 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
310 # then disable assertions by defining the appropriate preprocessor symbols.
311 ifndef DISABLE_ASSERTIONS
312 BuildMode := $(BuildMode)+Asserts
313 CPP.Defines += -D_DEBUG
315 CPP.Defines += -DNDEBUG
318 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
319 # configured), then enable expensive checks by defining the
320 # appropriate preprocessor symbols.
321 ifdef ENABLE_EXPENSIVE_CHECKS
322 BuildMode := $(BuildMode)+Checks
323 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
326 # LOADABLE_MODULE implies several other things so we force them to be
328 ifdef LOADABLE_MODULE
330 LINK_LIBS_IN_SHARED := 1
338 ifeq ($(ENABLE_PIC),1)
339 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
340 # Nothing. Win32 defaults to PIC and warns when given -fPIC
342 ifeq ($(HOST_OS),Darwin)
343 # Common symbols not allowed in dylib files
344 CXX.Flags += -fno-common
345 C.Flags += -fno-common
347 # Linux and others; pass -fPIC
353 ifeq ($(HOST_OS),Darwin)
354 CXX.Flags += -mdynamic-no-pic
355 C.Flags += -mdynamic-no-pic
359 # Support makefile variable to disable any kind of timestamp/non-deterministic
360 # info from being used in the build.
361 ifeq ($(ENABLE_TIMESTAMPS),1)
362 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
364 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
367 ifeq ($(HOST_OS),MingW)
369 CPP.Defines += -D__NO_CTYPE_INLINE
370 ifeq ($(LLVM_CROSS_COMPILING),1)
371 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
373 LD.Flags += -Wl,--allow-multiple-definition
378 CXX.Flags += -Woverloaded-virtual
379 CPP.BaseFlags += $(CPP.Defines)
382 # Make Floating point IEEE compliant on Alpha.
385 CPP.BaseFlags += -mieee
386 ifeq ($(ENABLE_PIC),0)
388 CPP.BaseFlags += -fPIC
393 LD.Flags += -Wl,--no-relax
396 #--------------------------------------------------------------------
397 # Directory locations
398 #--------------------------------------------------------------------
400 ifeq ($(LLVM_CROSS_COMPILING),1)
401 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
404 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
405 ObjDir := $(ObjRootDir)
406 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
407 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
408 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
409 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
410 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
411 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
413 #--------------------------------------------------------------------
414 # Locations of shared libraries
415 #--------------------------------------------------------------------
418 SharedLibDir := $(LibDir)
419 LLVMSharedLibDir := $(LLVMLibDir)
421 # Win32.DLL prefers to be located on the "PATH" of binaries.
422 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
423 SharedLibDir := $(ToolDir)
424 LLVMSharedLibDir := $(LLVMToolDir)
426 ifeq ($(HOST_OS),Cygwin)
433 #--------------------------------------------------------------------
434 # LLVM Capable Compiler
435 #--------------------------------------------------------------------
437 ifeq ($(LLVMCC_OPTION),llvm-gcc)
439 LLVMCXX := $(LLVMGXX)
441 ifeq ($(LLVMCC_OPTION),clang)
442 ifneq ($(CLANGPATH),)
443 LLVMCC := $(CLANGPATH)
444 LLVMCXX := $(CLANGXXPATH)
446 ifeq ($(ENABLE_BUILT_CLANG),1)
447 LLVMCC := $(LLVMToolDir)/clang
448 LLVMCXX := $(LLVMToolDir)/clang++
454 #--------------------------------------------------------------------
455 # Full Paths To Compiled Tools and Utilities
456 #--------------------------------------------------------------------
457 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
460 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
463 ifeq ($(LLVM_CROSS_COMPILING),1)
464 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
466 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
469 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
471 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
474 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
477 LLI := $(LLVMToolDir)/lli$(EXEEXT)
480 LLC := $(LLVMToolDir)/llc$(EXEEXT)
483 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
486 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
489 #--------------------------------------------------------------------
490 # Adjust to user's request
491 #--------------------------------------------------------------------
493 ifeq ($(HOST_OS),Darwin)
494 DARWIN_VERSION := `sw_vers -productVersion`
495 # Strip a number like 10.4.7 to 10.4
496 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
497 # Get "4" out of 10.4 for later pieces in the makefile.
498 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
500 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined,suppress \
503 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
506 SharedLinkOptions=-shared
509 ifeq ($(TARGET_OS),Darwin)
511 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
516 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
517 ifneq ($(HOST_OS),Darwin)
518 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
520 ifneq ($(DARWIN_MAJVERS),4)
521 LD.Flags += $(RPATH) -Wl,$(SharedLibDir)
534 # Adjust settings for verbose mode
537 AR.Flags += >/dev/null 2>/dev/null
538 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
540 ConfigureScriptFLAGS :=
543 # By default, strip symbol information from executable
545 Strip := $(PLATFORMSTRIPOPTS)
546 StripWarnMsg := "(without symbols)"
547 Install.StripFlag += -s
550 # Adjust linker flags for building an executable
551 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
552 ifneq ($(HOST_OS), Darwin)
554 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
556 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
558 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
562 ifneq ($(DARWIN_MAJVERS),4)
563 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
569 #----------------------------------------------------------
570 # Options To Invoke Tools
571 #----------------------------------------------------------
574 CompileCommonOpts += -pedantic -Wno-long-long
576 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
578 # Enable cast-qual for C++; the workaround is to use const_cast.
579 CXX.Flags += -Wcast-qual
581 ifeq ($(HOST_OS),HP-UX)
582 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
585 # If we are building a universal binary on Mac OS/X, pass extra options. This
586 # is useful to people that want to link the LLVM libraries into their universal
589 # The following can be optionally specified:
590 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
591 # For Mac OS/X 10.4 Intel machines, the traditional one is:
592 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
593 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
594 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
597 ifndef UNIVERSAL_ARCH
598 UNIVERSAL_ARCH := i386 ppc
600 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
601 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
602 ifdef UNIVERSAL_SDK_PATH
603 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
606 # Building universal cannot compute dependencies automatically.
607 DISABLE_AUTO_DEPENDENCIES=1
609 ifeq ($(TARGET_OS),Darwin)
610 ifeq ($(ARCH),x86_64)
611 TargetCommonOpts = -m64
614 TargetCommonOpts = -m32
620 ifeq ($(HOST_OS),SunOS)
621 CPP.BaseFlags += -include llvm/System/Solaris.h
624 ifeq ($(HOST_OS),AuroraUX)
625 CPP.BaseFlags += -include llvm/System/Solaris.h
626 endif # !HOST_OS - AuroraUX.
628 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
629 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
630 # All -I flags should go here, so that they don't confuse llvm-config.
631 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
632 $(patsubst %,-I%/include,\
633 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
634 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
637 ifeq ($(BUILD_COMPONENT), 1)
638 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
639 $(TargetCommonOpts) $(CompileCommonOpts) -c
640 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
642 $(TargetCommonOpts) $(CompileCommonOpts) -c
643 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
644 $(CompileCommonOpts) $(CXX.Flags) -E
645 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
647 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
649 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
650 $(TargetCommonOpts) $(CompileCommonOpts) -c
651 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
652 $(TargetCommonOpts) $(CompileCommonOpts) -c
653 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
654 $(CompileCommonOpts) $(CXX.Flags) -E
655 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
656 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
659 BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
660 $(TargetCommonOpts) $(CompileCommonOpts)
661 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
662 $(TargetCommonOpts) $(CompileCommonOpts) -E
664 BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
665 $(TargetCommonOpts) $(CompileCommonOpts)
667 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
668 ScriptInstall = $(INSTALL) -m 0755
669 DataInstall = $(INSTALL) -m 0644
671 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
672 # paths. In this case, the SYSPATH function (defined in
673 # Makefile.config) transforms Unix paths into Windows paths.
674 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
675 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
676 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
677 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
679 Archive = $(AR) $(AR.Flags)
680 LArchive = $(LLVMToolDir)/llvm-ar rcsf
689 #----------------------------------------------------------
690 # Get the list of source files and compute object file
692 #----------------------------------------------------------
695 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
696 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
698 Sources := $(SOURCES)
702 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
705 BaseNameSources := $(sort $(basename $(Sources)))
707 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
708 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
710 ###############################################################################
711 # DIRECTORIES: Handle recursive descent of directory structure
712 ###############################################################################
714 #---------------------------------------------------------
715 # Provide rules to make install dirs. This must be early
716 # in the file so they get built before dependencies
717 #---------------------------------------------------------
719 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
722 # To create other directories, as needed, and timestamp their creation
724 $(Verb) $(MKDIR) $* > /dev/null
725 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
727 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
728 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
730 #---------------------------------------------------------
731 # Handle the DIRS options for sequential construction
732 #---------------------------------------------------------
738 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
739 $(RecursiveTargets)::
740 $(Verb) for dir in $(DIRS); do \
741 if ([ ! -f $$dir/Makefile ] || \
742 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
744 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
746 ($(MAKE) -C $$dir $@ ) || exit 1; \
749 $(RecursiveTargets)::
750 $(Verb) for dir in $(DIRS); do \
751 ($(MAKE) -C $$dir $@ ) || exit 1; \
757 #---------------------------------------------------------
758 # Handle the EXPERIMENTAL_DIRS options ensuring success
759 # after each directory is built.
760 #---------------------------------------------------------
761 ifdef EXPERIMENTAL_DIRS
762 $(RecursiveTargets)::
763 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
764 if ([ ! -f $$dir/Makefile ] || \
765 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
767 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
769 ($(MAKE) -C $$dir $@ ) || exit 0; \
773 #-----------------------------------------------------------
774 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
775 #-----------------------------------------------------------
776 ifdef OPTIONAL_PARALLEL_DIRS
777 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
780 #-----------------------------------------------------------
781 # Handle the PARALLEL_DIRS options for parallel construction
782 #-----------------------------------------------------------
785 SubDirs += $(PARALLEL_DIRS)
787 # Unfortunately, this list must be maintained if new recursive targets are added
788 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
789 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
790 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
791 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
792 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
793 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
794 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
796 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
799 $(Verb) if ([ ! -f $(@D)/Makefile ] || \
800 command test $(@D)/Makefile -ot \
801 $(PROJ_SRC_DIR)/$(@D)/Makefile ); then \
803 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
805 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
808 #---------------------------------------------------------
809 # Handle the OPTIONAL_DIRS options for directores that may
811 #---------------------------------------------------------
814 SubDirs += $(OPTIONAL_DIRS)
816 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
817 $(RecursiveTargets)::
818 $(Verb) for dir in $(OPTIONAL_DIRS); do \
819 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
820 if ([ ! -f $$dir/Makefile ] || \
821 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
823 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
825 ($(MAKE) -C$$dir $@ ) || exit 1; \
829 $(RecursiveTargets)::
830 $(Verb) for dir in $(OPTIONAL_DIRS); do \
831 ($(MAKE) -C$$dir $@ ) || exit 1; \
836 #---------------------------------------------------------
837 # Handle the CONFIG_FILES options
838 #---------------------------------------------------------
843 $(Echo) Install circumvented with NO_INSTALL
845 $(Echo) UnInstall circumvented with NO_INSTALL
847 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
848 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
849 $(Verb)for file in $(CONFIG_FILES); do \
850 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
851 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
852 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
853 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
855 $(ECHO) Error: cannot find config file $${file}. ; \
860 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
861 $(Verb)for file in $(CONFIG_FILES); do \
862 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
868 ###############################################################################
869 # Set up variables for building libraries
870 ###############################################################################
872 #---------------------------------------------------------
873 # Define various command line options pertaining to the
874 # libraries needed when linking. There are "Proj" libs
875 # (defined by the user's project) and "LLVM" libs (defined
876 # by the LLVM project).
877 #---------------------------------------------------------
880 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
881 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
882 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
883 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
887 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
888 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
889 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
890 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
893 # Win32.DLL may refer to other components.
894 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
895 ifdef LOADABLE_MODULE
896 LINK_COMPONENTS := all
900 ifndef IS_CLEANING_TARGET
901 ifdef LINK_COMPONENTS
903 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
904 # clean in tools, then do a make in tools (instead of at the top level).
906 @echo "*** llvm-config doesn't exist - rebuilding it."
907 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
909 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
911 ifeq ($(ENABLE_SHARED), 1)
912 # We can take the "auto-import" feature to get rid of using dllimport.
913 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
914 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
917 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
918 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
921 ifndef NO_LLVM_CONFIG
922 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
923 ifeq ($(LLVMConfigLibs),Error)
924 $(error llvm-config --libs failed)
926 LLVMLibsOptions += $(LLVMConfigLibs)
927 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
928 ifeq ($(LLVMConfigLibfiles),Error)
929 $(error llvm-config --libfiles failed)
931 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
938 # Set up the library exports file.
939 ifdef EXPORTED_SYMBOL_FILE
941 # First, set up the native export file, which may differ from the source
944 ifeq ($(HOST_OS),Darwin)
945 # Darwin convention prefixes symbols with underscores.
946 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
947 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
948 $(Verb) sed -e 's/^/_/' < $< > $@
950 -$(Verb) $(RM) -f $(NativeExportsFile)
952 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
953 # Gold and BFD ld require a version script rather than a plain list.
954 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
955 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
956 $(Verb) echo "{" > $@
957 $(Verb) grep -q "\<" $< && echo " global:" >> $@ || :
958 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
959 $(Verb) echo " local: *;" >> $@
960 $(Verb) echo "};" >> $@
962 -$(Verb) $(RM) -f $(NativeExportsFile)
964 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
968 # Now add the linker command-line options to use the native export file.
970 ifeq ($(HOST_OS),Darwin)
971 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
974 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
975 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
976 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
978 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
979 SharedLinkOptions += $(NativeExportsFile)
981 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
982 $(Echo) Generating $(notdir $@)
983 $(Verb) $(ECHO) "EXPORTS" > $@
984 $(Verb) $(CAT) $< >> $@
986 -$(Verb) $(RM) -f $(NativeExportsFile)
990 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
991 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
998 ###############################################################################
999 # Library Build Rules: Four ways to build a library
1000 ###############################################################################
1002 #---------------------------------------------------------
1003 # Bytecode Module Targets:
1004 # If the user set MODULE_NAME then they want to build a
1005 # bytecode module from the sources. We compile all the
1006 # sources and link it together into a single bytecode
1008 #---------------------------------------------------------
1011 ifeq ($(strip $(LLVMCC)),)
1012 $(warning Modules require LLVM capable compiler but none is available ****)
1015 Module := $(LibDir)/$(MODULE_NAME).bc
1016 LinkModule := $(LLVMLD) -r
1019 ifdef EXPORTED_SYMBOL_FILE
1020 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1023 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
1024 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
1025 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1027 all-local:: $(Module)
1030 ifneq ($(strip $(Module)),)
1031 -$(Verb) $(RM) -f $(Module)
1034 ifdef BYTECODE_DESTINATION
1035 ModuleDestDir := $(BYTECODE_DESTINATION)
1037 ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
1042 $(Echo) Install circumvented with NO_INSTALL
1044 $(Echo) Uninstall circumvented with NO_INSTALL
1046 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1048 install-module:: $(DestModule)
1049 install-local:: $(DestModule)
1051 $(DestModule): $(ModuleDestDir) $(Module)
1052 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1053 $(Verb) $(DataInstall) $(Module) $(DestModule)
1056 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1057 -$(Verb) $(RM) -f $(DestModule)
1063 # if we're building a library ...
1066 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1067 LIBRARYNAME := $(strip $(LIBRARYNAME))
1068 ifdef LOADABLE_MODULE
1069 LibName.A := $(LibDir)/$(LIBRARYNAME).a
1070 LibName.SO := $(SharedLibDir)/$(LIBRARYNAME)$(SHLIBEXT)
1072 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
1073 LibName.SO := $(SharedLibDir)/$(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1075 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1076 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1078 #---------------------------------------------------------
1079 # Shared Library Targets:
1080 # If the user asked for a shared library to be built
1081 # with the SHARED_LIBRARY variable, then we provide
1082 # targets for building them.
1083 #---------------------------------------------------------
1084 ifdef SHARED_LIBRARY
1086 all-local:: $(LibName.SO)
1088 ifdef EXPORTED_SYMBOL_FILE
1089 $(LibName.SO): $(NativeExportsFile)
1092 ifdef LINK_LIBS_IN_SHARED
1093 ifdef LOADABLE_MODULE
1094 SharedLibKindMessage := "Loadable Module"
1096 SharedLibKindMessage := "Shared Library"
1098 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1099 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1101 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1102 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1104 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1105 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1106 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1110 ifneq ($(strip $(LibName.SO)),)
1111 -$(Verb) $(RM) -f $(LibName.SO)
1116 $(Echo) Install circumvented with NO_INSTALL
1118 $(Echo) Uninstall circumvented with NO_INSTALL
1121 # Win32.DLL prefers to be located on the "PATH" of binaries.
1122 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1123 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1125 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1127 DestSharedLib := $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1129 install-local:: $(DestSharedLib)
1131 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1132 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1133 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1136 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1137 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
1141 #---------------------------------------------------------
1142 # Bytecode Library Targets:
1143 # If the user asked for a bytecode library to be built
1144 # with the BYTECODE_LIBRARY variable, then we provide
1145 # targets for building them.
1146 #---------------------------------------------------------
1147 ifdef BYTECODE_LIBRARY
1148 ifeq ($(strip $(LLVMCC)),)
1149 $(warning Bytecode libraries require LLVM capable compiler but none is available ****)
1152 all-local:: $(LibName.BCA)
1154 ifdef EXPORTED_SYMBOL_FILE
1155 BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1157 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1158 $(LLVMToolDir)/llvm-ar
1159 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1161 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1163 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1165 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1166 $(LLVMToolDir)/llvm-ar
1167 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1169 $(Verb) $(LArchive) $@ $(ObjectsBC)
1174 ifneq ($(strip $(LibName.BCA)),)
1175 -$(Verb) $(RM) -f $(LibName.BCA)
1178 ifdef BYTECODE_DESTINATION
1179 BytecodeDestDir := $(BYTECODE_DESTINATION)
1181 BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
1184 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1186 install-bytecode-local:: $(DestBytecodeLib)
1190 $(Echo) Install circumvented with NO_INSTALL
1192 $(Echo) Uninstall circumvented with NO_INSTALL
1194 install-local:: $(DestBytecodeLib)
1196 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1197 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1198 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1201 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1202 -$(Verb) $(RM) -f $(DestBytecodeLib)
1207 #---------------------------------------------------------
1209 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1210 # building an archive.
1211 #---------------------------------------------------------
1212 ifndef NO_BUILD_ARCHIVE
1213 ifndef BUILD_ARCHIVE
1214 ifndef LOADABLE_MODULE
1220 #---------------------------------------------------------
1221 # Archive Library Targets:
1222 # If the user wanted a regular archive library built,
1223 # then we provide targets for building them.
1224 #---------------------------------------------------------
1227 all-local:: $(LibName.A)
1229 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1230 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1231 -$(Verb) $(RM) -f $@
1232 $(Verb) $(Archive) $@ $(ObjectsO)
1233 $(Verb) $(Ranlib) $@
1236 ifneq ($(strip $(LibName.A)),)
1237 -$(Verb) $(RM) -f $(LibName.A)
1242 $(Echo) Install circumvented with NO_INSTALL
1244 $(Echo) Uninstall circumvented with NO_INSTALL
1246 ifdef NO_INSTALL_ARCHIVES
1248 $(Echo) Install circumvented with NO_INSTALL
1250 $(Echo) Uninstall circumvented with NO_INSTALL
1252 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1254 install-local:: $(DestArchiveLib)
1256 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1257 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1258 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1259 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1262 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1263 -$(Verb) $(RM) -f $(DestArchiveLib)
1271 ###############################################################################
1272 # Tool Build Rules: Build executable tool based on TOOLNAME option
1273 ###############################################################################
1277 #---------------------------------------------------------
1278 # Set up variables for building a tool.
1279 #---------------------------------------------------------
1280 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1282 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1284 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1287 # TOOLALIAS is a name to symlink (or copy) the tool to.
1290 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1292 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1296 #---------------------------------------------------------
1298 #---------------------------------------------------------
1300 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1301 # not exporting all of the weak symbols from the binary. This reduces dyld
1302 # startup time by 4x on darwin in some cases.
1303 ifdef TOOL_NO_EXPORTS
1304 ifeq ($(HOST_OS),Darwin)
1306 # Tiger tools don't support this.
1307 ifneq ($(DARWIN_MAJVERS),4)
1308 LD.Flags += -Wl,-exported_symbol,_main
1312 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1313 ifneq ($(ARCH), Mips)
1314 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1319 #---------------------------------------------------------
1320 # Tool Version Info Support
1321 #---------------------------------------------------------
1323 ifeq ($(HOST_OS),Darwin)
1324 ifdef TOOL_INFO_PLIST
1326 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1328 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1330 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1331 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1332 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1333 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1334 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1335 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1341 #---------------------------------------------------------
1342 # Provide targets for building the tools
1343 #---------------------------------------------------------
1344 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1347 ifneq ($(strip $(ToolBuildPath)),)
1348 -$(Verb) $(RM) -f $(ToolBuildPath)
1350 ifneq ($(strip $(ToolAliasBuildPath)),)
1351 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1355 $(ToolBuildPath): $(ExmplDir)/.dir
1357 $(ToolBuildPath): $(ToolDir)/.dir
1360 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1361 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1362 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1363 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1364 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1367 ifneq ($(strip $(ToolAliasBuildPath)),)
1368 $(ToolAliasBuildPath): $(ToolBuildPath)
1369 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1370 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1371 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1372 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1378 $(Echo) Install circumvented with NO_INSTALL
1380 $(Echo) Uninstall circumvented with NO_INSTALL
1382 DestTool = $(DESTDIR)$(PROJ_bindir)/$(TOOLEXENAME)
1384 install-local:: $(DestTool)
1386 $(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
1387 $(Echo) Installing $(BuildMode) $(DestTool)
1388 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1391 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1392 -$(Verb) $(RM) -f $(DestTool)
1394 # TOOLALIAS install.
1396 DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)
1398 install-local:: $(DestToolAlias)
1400 $(DestToolAlias): $(DestTool)
1401 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1402 $(Verb) $(RM) -f $(DestToolAlias)
1403 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1406 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1407 -$(Verb) $(RM) -f $(DestToolAlias)
1413 ###############################################################################
1414 # Object Build Rules: Build object files based on sources
1415 ###############################################################################
1417 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1418 ifeq ($(HOST_OS),HP-UX)
1419 DISABLE_AUTO_DEPENDENCIES=1
1422 # Provide rule sets for when dependency generation is enabled
1423 ifndef DISABLE_AUTO_DEPENDENCIES
1425 #---------------------------------------------------------
1426 # Create .o files in the ObjDir directory from the .cpp and .c files...
1427 #---------------------------------------------------------
1429 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1430 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1432 # If the build succeeded, move the dependency file over, otherwise
1434 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1435 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1437 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1438 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1439 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1442 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1443 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1444 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1447 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1448 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1449 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1452 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1453 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1454 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1457 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1458 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1459 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1462 #---------------------------------------------------------
1463 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1464 #---------------------------------------------------------
1466 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1467 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1469 # If the build succeeded, move the dependency file over, otherwise
1471 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1472 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1474 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1475 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1476 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1477 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1478 $(BC_DEPEND_MOVEFILE)
1480 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1481 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1482 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1483 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1484 $(BC_DEPEND_MOVEFILE)
1486 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1487 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1488 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1489 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1490 $(BC_DEPEND_MOVEFILE)
1492 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1493 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1494 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1495 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1496 $(BC_DEPEND_MOVEFILE)
1498 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1499 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1500 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1501 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1502 $(BC_DEPEND_MOVEFILE)
1504 # Provide alternate rule sets if dependencies are disabled
1507 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1508 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1509 $(Compile.CXX) $< -o $@
1511 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1512 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1513 $(Compile.CXX) $< -o $@
1515 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1516 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1517 $(Compile.CXX) $< -o $@
1519 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1520 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1521 $(Compile.C) $< -o $@
1523 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1524 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1525 $(Compile.C) $< -o $@
1527 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1528 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1529 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1531 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1532 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1533 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1535 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1536 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1537 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1539 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1540 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1541 $(BCCompile.C) $< -o $@ -S -emit-llvm
1543 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1544 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1545 $(BCCompile.C) $< -o $@ -S -emit-llvm
1550 ## Rules for building preprocessed (.i/.ii) outputs.
1551 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1552 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1553 $(Verb) $(Preprocess.CXX) $< -o $@
1555 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1556 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1557 $(Verb) $(Preprocess.CXX) $< -o $@
1559 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1560 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1561 $(Verb) $(Preprocess.CXX) $< -o $@
1563 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1564 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1565 $(Verb) $(Preprocess.C) $< -o $@
1567 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1568 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1569 $(Verb) $(Preprocess.C) $< -o $@
1572 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1573 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1574 $(Compile.CXX) $< -o $@ -S
1576 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1577 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1578 $(Compile.CXX) $< -o $@ -S
1580 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1581 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1582 $(Compile.CXX) $< -o $@ -S
1584 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1585 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1586 $(Compile.C) $< -o $@ -S
1588 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1589 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1590 $(Compile.C) $< -o $@ -S
1593 # make the C and C++ compilers strip debug info out of bytecode libraries.
1595 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1596 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1597 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1599 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1600 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1601 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1605 #---------------------------------------------------------
1606 # Provide rule to build .bc files from .ll sources,
1607 # regardless of dependencies
1608 #---------------------------------------------------------
1609 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1610 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1611 $(Verb) $(LLVMAS) $< -f -o $@
1613 ###############################################################################
1614 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1615 ###############################################################################
1618 TABLEGEN_INC_FILES_COMMON = 1
1621 ifdef LLVMC_BASED_DRIVER
1622 TABLEGEN_INC_FILES_COMMON = 1
1625 ifdef TABLEGEN_INC_FILES_COMMON
1627 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1628 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1629 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1631 # INCFiles rule: All of the tblgen generated files are emitted to
1632 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1633 # us to only "touch" the real file if the contents of it change. IOW, if
1634 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1635 # dependencies of the .inc files are, unless the contents of the .inc file
1637 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1638 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1640 endif # TABLEGEN_INC_FILES_COMMON
1644 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1645 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1646 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1647 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1648 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1649 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1650 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1652 # All of these files depend on tblgen and the .td files.
1653 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1655 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1656 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1657 $(Echo) "Building $(<F) register names with tblgen"
1658 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1660 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1661 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1662 $(Echo) "Building $(<F) register information header with tblgen"
1663 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1665 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1666 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1667 $(Echo) "Building $(<F) register info implementation with tblgen"
1668 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1670 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1671 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1672 $(Echo) "Building $(<F) instruction names with tblgen"
1673 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1675 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1676 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1677 $(Echo) "Building $(<F) instruction information with tblgen"
1678 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1680 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1681 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1682 $(Echo) "Building $(<F) assembly writer with tblgen"
1683 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1685 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1686 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1687 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1688 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1690 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1691 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1692 $(Echo) "Building $(<F) assembly matcher with tblgen"
1693 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1695 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1696 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1697 $(Echo) "Building $(<F) code emitter with tblgen"
1698 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1700 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1701 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1702 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1703 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1705 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1706 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir
1707 $(Echo) "Building $(<F) disassembly tables with tblgen"
1708 $(Verb) $(TableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1710 $(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1711 $(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir
1712 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1713 $(Verb) $(TableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1715 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1716 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1717 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1718 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1720 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1721 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1722 $(Echo) "Building $(<F) subtarget information with tblgen"
1723 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1725 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1726 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1727 $(Echo) "Building $(<F) calling convention information with tblgen"
1728 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1730 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1731 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir
1732 $(Echo) "Building $(<F) intrinsics information with tblgen"
1733 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1735 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir
1736 $(Echo) "Building $(<F) decoder tables with tblgen"
1737 $(Verb) $(TableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1741 -$(Verb) $(RM) -f $(INCFiles)
1745 ifdef LLVMC_BASED_DRIVER
1747 TDSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1748 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1750 TDCommon := $(strip $(wildcard \
1751 $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1753 TDFiles := $(TDSrc) $(TDCommon)
1755 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1757 $(ObjDir)/%.inc.tmp: %.td $(ObjDir)/.dir
1758 $(Echo) "Building LLVMC compilation graph description with tblgen"
1759 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1762 -$(Verb) $(RM) -f $(INCFiles)
1764 endif # LLVMC_BASED_DRIVER
1766 ###############################################################################
1767 # OTHER RULES: Other rules needed
1768 ###############################################################################
1770 # To create postscript files from dot files...
1771 ifneq ($(DOT),false)
1773 $(DOT) -Tps < $< > $@
1776 $(Echo) "Cannot build $@: The program dot is not installed"
1779 # This rules ensures that header files that are removed still have a rule for
1780 # which they can be "generated." This allows make to ignore them and
1781 # reproduce the dependency lists.
1785 # Define clean-local to clean the current directory. Note that this uses a
1786 # very conservative approach ensuring that empty variables do not cause
1787 # errors or disastrous removal.
1789 ifneq ($(strip $(ObjRootDir)),)
1790 -$(Verb) $(RM) -rf $(ObjRootDir)
1792 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1793 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1794 -$(Verb) $(RM) -f *$(SHLIBEXT)
1798 -$(Verb) $(RM) -rf Debug Release Profile
1801 ###############################################################################
1802 # DEPENDENCIES: Include the dependency files if we should
1803 ###############################################################################
1804 ifndef DISABLE_AUTO_DEPENDENCIES
1806 # If its not one of the cleaning targets
1807 ifndef IS_CLEANING_TARGET
1809 # Get the list of dependency files
1810 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1811 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1813 # Include bitcode dependency files if using bitcode libraries
1814 ifdef BYTECODE_LIBRARY
1815 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1818 -include $(DependFiles) ""
1824 ###############################################################################
1825 # CHECK: Running the test suite
1826 ###############################################################################
1829 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1830 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1831 $(EchoCmd) Running test suite ; \
1832 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1833 TESTSUITE=$(TESTSUITE) ; \
1835 $(EchoCmd) No Makefile in test directory ; \
1838 $(EchoCmd) No test directory ; \
1844 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1845 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1846 $(EchoCmd) Running test suite ; \
1847 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-dg ; \
1849 $(EchoCmd) No Makefile in test directory ; \
1852 $(EchoCmd) No test directory ; \
1856 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1857 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1858 $(EchoCmd) Running test suite ; \
1859 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1861 $(EchoCmd) No Makefile in test directory ; \
1864 $(EchoCmd) No test directory ; \
1867 ###############################################################################
1868 # UNITTESTS: Running the unittests test suite
1869 ###############################################################################
1872 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1873 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1874 $(EchoCmd) Running unittests test suite ; \
1875 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1877 $(EchoCmd) No Makefile in unittests directory ; \
1880 $(EchoCmd) No unittests directory ; \
1883 ###############################################################################
1884 # DISTRIBUTION: Handle construction of a distribution tarball
1885 ###############################################################################
1887 #------------------------------------------------------------------------
1888 # Define distribution related variables
1889 #------------------------------------------------------------------------
1890 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1891 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1892 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1893 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1894 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1895 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1896 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1897 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1898 Makefile.config.in configure autoconf
1899 DistOther := $(notdir $(wildcard \
1900 $(PROJ_SRC_DIR)/*.h \
1901 $(PROJ_SRC_DIR)/*.td \
1902 $(PROJ_SRC_DIR)/*.def \
1903 $(PROJ_SRC_DIR)/*.ll \
1904 $(PROJ_SRC_DIR)/*.in))
1905 DistSubDirs := $(SubDirs)
1906 DistSources = $(Sources) $(EXTRA_DIST)
1907 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1909 #------------------------------------------------------------------------
1910 # We MUST build distribution with OBJ_DIR != SRC_DIR
1911 #------------------------------------------------------------------------
1912 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1913 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1914 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1918 #------------------------------------------------------------------------
1919 # Prevent attempt to run dist targets from anywhere but the top level
1920 #------------------------------------------------------------------------
1922 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1923 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1926 #------------------------------------------------------------------------
1927 # Provide the top level targets
1928 #------------------------------------------------------------------------
1930 dist-gzip:: $(DistTarGZip)
1932 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1933 $(Echo) Packing gzipped distribution tar file.
1934 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1935 $(GZIP) -c > "$(DistTarGZip)"
1937 dist-bzip2:: $(DistTarBZ2)
1939 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1940 $(Echo) Packing bzipped distribution tar file.
1941 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1942 $(BZIP2) -c >$(DistTarBZ2)
1944 dist-zip:: $(DistZip)
1946 $(DistZip) : $(TopDistDir)/.makedistdir
1947 $(Echo) Packing zipped distribution file.
1948 $(Verb) rm -f $(DistZip)
1949 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1951 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1952 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1954 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1956 dist-check:: $(DistTarGZip)
1957 $(Echo) Checking distribution tar file.
1958 $(Verb) if test -d $(DistCheckDir) ; then \
1959 $(RM) -rf $(DistCheckDir) ; \
1961 $(Verb) $(MKDIR) $(DistCheckDir)
1962 $(Verb) cd $(DistCheckDir) && \
1963 $(MKDIR) $(DistCheckDir)/build && \
1964 $(MKDIR) $(DistCheckDir)/install && \
1965 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1967 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1968 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1971 $(MAKE) unittests && \
1972 $(MAKE) install && \
1973 $(MAKE) uninstall && \
1974 $(MAKE) dist-clean && \
1975 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1978 $(Echo) Cleaning distribution files
1979 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1984 #------------------------------------------------------------------------
1985 # Provide the recursive distdir target for building the distribution directory
1986 #------------------------------------------------------------------------
1987 distdir: $(DistDir)/.makedistdir
1988 $(DistDir)/.makedistdir: $(DistSources)
1989 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1990 if test -d "$(DistDir)" ; then \
1991 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1994 $(EchoCmd) Removing old $(DistDir) ; \
1995 $(RM) -rf $(DistDir); \
1996 $(EchoCmd) Making 'all' to verify build ; \
1997 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1999 $(Echo) Building Distribution Directory $(DistDir)
2000 $(Verb) $(MKDIR) $(DistDir)
2001 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
2002 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
2003 for file in $(DistFiles) ; do \
2005 $(PROJ_SRC_DIR)/*) \
2006 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
2008 $(PROJ_SRC_ROOT)/*) \
2009 file=`echo "$$file" | \
2010 sed "s#^$$srcrootstrip/##"` \
2013 if test -f "$(PROJ_SRC_DIR)/$$file" || \
2014 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
2015 from_dir="$(PROJ_SRC_DIR)" ; \
2016 elif test -f "$$file" || test -d "$$file" ; then \
2019 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
2020 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
2021 to_dir="$(DistDir)/$$dir"; \
2022 $(MKDIR) "$$to_dir" ; \
2024 to_dir="$(DistDir)"; \
2026 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
2027 if test -n "$$mid_dir" ; then \
2028 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
2030 if test -d "$$from_dir/$$file"; then \
2031 if test -d "$(PROJ_SRC_DIR)/$$file" && \
2032 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
2033 cd $(PROJ_SRC_DIR) ; \
2034 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2035 ( cd $$to_dir ; $(TAR) xf - ) ; \
2036 cd $(PROJ_OBJ_DIR) ; \
2039 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2040 ( cd $$to_dir ; $(TAR) xf - ) ; \
2041 cd $(PROJ_OBJ_DIR) ; \
2043 elif test -f "$$from_dir/$$file" ; then \
2044 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
2045 elif test -L "$$from_dir/$$file" ; then \
2046 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
2047 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
2048 $(EchoCmd) "===== WARNING: Distribution Source " \
2049 "$$from_dir/$$file Not Found!" ; \
2050 elif test "$(Verb)" != '@' ; then \
2051 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
2054 $(Verb) for subdir in $(DistSubDirs) ; do \
2055 if test "$$subdir" \!= "." ; then \
2056 new_distdir="$(DistDir)/$$subdir" ; \
2057 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
2058 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
2059 DistDir="$$new_distdir" distdir ) || exit 1; \
2062 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2063 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2064 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2065 -name .svn \) -print` ;\
2066 $(MAKE) dist-hook ; \
2067 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2068 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2069 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2070 -o ! -type d ! -perm -444 -exec \
2071 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2072 || chmod -R a+r $(DistDir) ; \
2075 # This is invoked by distdir target, define it as a no-op to avoid errors if not
2081 ###############################################################################
2082 # TOP LEVEL - targets only to apply at the top level directory
2083 ###############################################################################
2087 #------------------------------------------------------------------------
2088 # Install support for the project's include files:
2089 #------------------------------------------------------------------------
2092 $(Echo) Install circumvented with NO_INSTALL
2094 $(Echo) Uninstall circumvented with NO_INSTALL
2097 $(Echo) Installing include files
2098 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2099 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2100 cd $(PROJ_SRC_ROOT)/include && \
2101 for hdr in `find . -type f '!' '(' -name '*~' \
2102 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
2103 grep -v .svn` ; do \
2104 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2105 if test \! -d "$$instdir" ; then \
2106 $(EchoCmd) Making install directory $$instdir ; \
2107 $(MKDIR) $$instdir ;\
2109 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2112 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2113 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2114 cd $(PROJ_OBJ_ROOT)/include && \
2115 for hdr in `find . -type f -print | grep -v CVS` ; do \
2116 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2122 $(Echo) Uninstalling include files
2123 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2124 cd $(PROJ_SRC_ROOT)/include && \
2125 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2126 '!' '(' -name '*~' -o -name '.#*' \
2127 -o -name '*.in' ')' -print ')' | \
2128 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2129 cd $(PROJ_SRC_ROOT)/include && \
2130 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2131 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2137 @echo searching for overlength lines in files: $(Sources)
2140 egrep -n '.{81}' $(Sources) /dev/null
2143 @echo searching for tabs in files: $(Sources)
2146 egrep -n ' ' $(Sources) /dev/null
2149 @ls -l $(LibDir) | awk '\
2150 BEGIN { sum = 0; } \
2152 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2153 @ls -l $(ToolDir) | awk '\
2154 BEGIN { sum = 0; } \
2156 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2157 #------------------------------------------------------------------------
2158 # Print out the directories used for building
2159 #------------------------------------------------------------------------
2161 $(Echo) "BuildMode : " '$(BuildMode)'
2162 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2163 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2164 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2165 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2166 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2167 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2168 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2169 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2170 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2171 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2172 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2173 $(Echo) "UserTargets : " '$(UserTargets)'
2174 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2175 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2176 $(Echo) "ObjDir : " '$(ObjDir)'
2177 $(Echo) "LibDir : " '$(LibDir)'
2178 $(Echo) "ToolDir : " '$(ToolDir)'
2179 $(Echo) "ExmplDir : " '$(ExmplDir)'
2180 $(Echo) "Sources : " '$(Sources)'
2181 $(Echo) "TDFiles : " '$(TDFiles)'
2182 $(Echo) "INCFiles : " '$(INCFiles)'
2183 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2184 $(Echo) "PreConditions: " '$(PreConditions)'
2185 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2186 $(Echo) "Compile.C : " '$(Compile.C)'
2187 $(Echo) "Archive : " '$(Archive)'
2188 $(Echo) "YaccFiles : " '$(YaccFiles)'
2189 $(Echo) "LexFiles : " '$(LexFiles)'
2190 $(Echo) "Module : " '$(Module)'
2191 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2192 $(Echo) "SubDirs : " '$(SubDirs)'
2193 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2194 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2199 # General debugging rule, use 'make dbg-print-XXX' to print the
2200 # definition, value and origin of XXX.
2202 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))