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 plugins
200 ###############################################################################
204 LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
205 CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
207 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
208 LD.Flags += -lCompilerDriver
211 # Build a dynamic library if the user runs `make` directly from the plugin
213 ifndef LLVMC_BUILTIN_PLUGIN
218 ifneq ($(BUILT_SOURCES),)
219 LLVMC_BUILD_AUTOGENERATED_INC=1
224 ifdef LLVMC_BASED_DRIVER
226 TOOLNAME = $(LLVMC_BASED_DRIVER)
228 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
229 LD.Flags += -lCompilerDriver
231 LLVMLIBS = CompilerDriver.a
232 LINK_COMPONENTS = support system
235 # Preprocessor magic that generates references to static variables in built-in
237 ifneq ($(LLVMC_BUILTIN_PLUGINS),)
239 USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
241 LLVMC_BUILTIN_PLUGINS.pre := \
242 $(patsubst %,-DLLVMC_BUILTIN_PLUGIN_%=, \
243 1 2 3 4 5 6 7 8 9 10)
246 $(filter-out $(LLVMC_BUILTIN_PLUGINS.pre) $(LLVMC_BUILTIN_PLUGINS), \
247 $(join $(LLVMC_BUILTIN_PLUGINS.pre), $(LLVMC_BUILTIN_PLUGINS)))
251 endif # LLVMC_BASED_DRIVER
253 ###############################################################################
254 # VARIABLES: Set up various variables based on configuration data
255 ###############################################################################
257 # Variable for if this make is for a "cleaning" target
258 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
262 #--------------------------------------------------------------------
263 # Variables derived from configuration we are building
264 #--------------------------------------------------------------------
267 ifeq ($(ENABLE_OPTIMIZED),1)
269 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
270 ifneq ($(HOST_OS),FreeBSD)
271 ifneq ($(HOST_OS),Darwin)
272 OmitFramePointer := -fomit-frame-pointer
276 # Darwin requires -fstrict-aliasing to be explicitly enabled.
277 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
278 # with -fstrict-aliasing and ipa-type-escape radr://6756684
279 #ifeq ($(HOST_OS),Darwin)
280 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
282 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
283 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
284 LD.Flags += $(OPTIMIZE_OPTION)
286 BuildMode := $(BuildMode)+Debug
293 ifdef NO_DEBUG_SYMBOLS
294 BuildMode := Unoptimized
308 ifeq ($(ENABLE_PROFILING),1)
309 BuildMode := $(BuildMode)+Profile
310 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
311 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
312 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
316 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
317 # CXX.Flags += -fvisibility-inlines-hidden
320 ifdef ENABLE_EXPENSIVE_CHECKS
321 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
322 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
326 # IF REQUIRES_EH=1 is specified then don't disable exceptions
328 CXX.Flags += -fno-exceptions
330 # If the library requires EH, it also requires RTTI.
334 ifdef REQUIRES_FRAME_POINTER
335 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
336 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
337 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
340 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
341 ifneq ($(REQUIRES_RTTI), 1)
342 CXX.Flags += -fno-rtti
345 ifdef ENABLE_COVERAGE
346 BuildMode := $(BuildMode)+Coverage
347 CXX.Flags += -ftest-coverage -fprofile-arcs
348 C.Flags += -ftest-coverage -fprofile-arcs
351 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
352 # then disable assertions by defining the appropriate preprocessor symbols.
353 ifndef DISABLE_ASSERTIONS
354 BuildMode := $(BuildMode)+Asserts
355 CPP.Defines += -D_DEBUG
357 CPP.Defines += -DNDEBUG
360 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
361 # configured), then enable expensive checks by defining the
362 # appropriate preprocessor symbols.
363 ifdef ENABLE_EXPENSIVE_CHECKS
364 BuildMode := $(BuildMode)+Checks
365 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
368 # LOADABLE_MODULE implies several other things so we force them to be
370 ifdef LOADABLE_MODULE
372 LINK_LIBS_IN_SHARED := 1
380 ifeq ($(ENABLE_PIC),1)
381 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
382 # Nothing. Win32 defaults to PIC and warns when given -fPIC
384 ifeq ($(HOST_OS),Darwin)
385 # Common symbols not allowed in dylib files
386 CXX.Flags += -fno-common
387 C.Flags += -fno-common
389 # Linux and others; pass -fPIC
395 ifeq ($(HOST_OS),Darwin)
396 CXX.Flags += -mdynamic-no-pic
397 C.Flags += -mdynamic-no-pic
401 # Support makefile variable to disable any kind of timestamp/non-deterministic
402 # info from being used in the build.
403 ifeq ($(ENABLE_TIMESTAMPS),1)
404 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
406 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
409 ifeq ($(HOST_OS),MingW)
411 CPP.Defines += -D__NO_CTYPE_INLINE
412 ifeq ($(LLVM_CROSS_COMPILING),1)
413 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
415 LD.Flags += -Wl,--allow-multiple-definition
420 CXX.Flags += -Woverloaded-virtual
421 CPP.BaseFlags += $(CPP.Defines)
424 # Make Floating point IEEE compliant on Alpha.
427 CPP.BaseFlags += -mieee
428 ifeq ($(ENABLE_PIC),0)
430 CPP.BaseFlags += -fPIC
435 LD.Flags += -Wl,--no-relax
438 #--------------------------------------------------------------------
439 # Directory locations
440 #--------------------------------------------------------------------
442 ifeq ($(LLVM_CROSS_COMPILING),1)
443 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
446 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
447 ObjDir := $(ObjRootDir)
448 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
449 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
450 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
451 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
452 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
453 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
455 #--------------------------------------------------------------------
456 # LLVM Capable Compiler
457 #--------------------------------------------------------------------
459 ifeq ($(LLVMCC_OPTION),llvm-gcc)
461 LLVMCXX := $(LLVMGXX)
463 ifeq ($(LLVMCC_OPTION),clang)
464 ifneq ($(CLANGPATH),)
465 LLVMCC := $(CLANGPATH)
466 LLVMCXX := $(CLANGXXPATH)
468 ifeq ($(ENABLE_BUILT_CLANG),1)
469 LLVMCC := $(LLVMToolDir)/clang
470 LLVMCXX := $(LLVMToolDir)/clang++
476 #--------------------------------------------------------------------
477 # Full Paths To Compiled Tools and Utilities
478 #--------------------------------------------------------------------
479 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
482 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
485 ifeq ($(LLVM_CROSS_COMPILING),1)
486 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
488 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
491 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
493 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
496 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
499 LLI := $(LLVMToolDir)/lli$(EXEEXT)
502 LLC := $(LLVMToolDir)/llc$(EXEEXT)
505 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
508 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
511 #--------------------------------------------------------------------
512 # Adjust to user's request
513 #--------------------------------------------------------------------
515 ifeq ($(HOST_OS),Darwin)
516 DARWIN_VERSION := `sw_vers -productVersion`
517 # Strip a number like 10.4.7 to 10.4
518 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
519 # Get "4" out of 10.4 for later pieces in the makefile.
520 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
522 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined,suppress \
525 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
528 ifeq ($(HOST_OS),Cygwin)
529 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
530 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
532 SharedLinkOptions=-shared
536 ifeq ($(TARGET_OS),Darwin)
538 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
543 ifneq ($(HOST_OS),Darwin)
544 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
546 ifneq ($(DARWIN_MAJVERS),4)
547 LD.Flags += $(RPATH) -Wl,$(LibDir)
559 # Adjust settings for verbose mode
562 AR.Flags += >/dev/null 2>/dev/null
563 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
565 ConfigureScriptFLAGS :=
568 # By default, strip symbol information from executable
570 Strip := $(PLATFORMSTRIPOPTS)
571 StripWarnMsg := "(without symbols)"
572 Install.StripFlag += -s
575 # Adjust linker flags for building an executable
576 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
577 ifneq ($(HOST_OS), Darwin)
579 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
581 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
583 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
587 ifneq ($(DARWIN_MAJVERS),4)
588 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
594 #----------------------------------------------------------
595 # Options To Invoke Tools
596 #----------------------------------------------------------
599 CompileCommonOpts += -pedantic -Wno-long-long
601 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
603 # Enable cast-qual for C++; the workaround is to use const_cast.
604 CXX.Flags += -Wcast-qual
606 ifeq ($(HOST_OS),HP-UX)
607 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
610 # If we are building a universal binary on Mac OS/X, pass extra options. This
611 # is useful to people that want to link the LLVM libraries into their universal
614 # The following can be optionally specified:
615 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
616 # For Mac OS/X 10.4 Intel machines, the traditional one is:
617 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
618 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
619 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
622 ifndef UNIVERSAL_ARCH
623 UNIVERSAL_ARCH := i386 ppc
625 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
626 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
627 ifdef UNIVERSAL_SDK_PATH
628 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
631 # Building universal cannot compute dependencies automatically.
632 DISABLE_AUTO_DEPENDENCIES=1
634 ifeq ($(TARGET_OS),Darwin)
635 ifeq ($(ARCH),x86_64)
636 TargetCommonOpts = -m64
639 TargetCommonOpts = -m32
645 ifeq ($(HOST_OS),SunOS)
646 CPP.BaseFlags += -include llvm/System/Solaris.h
649 ifeq ($(HOST_OS),AuroraUX)
650 CPP.BaseFlags += -include llvm/System/Solaris.h
651 endif # !HOST_OS - AuroraUX.
653 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
654 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
655 # All -I flags should go here, so that they don't confuse llvm-config.
656 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
657 $(patsubst %,-I%/include,\
658 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
659 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
662 ifeq ($(BUILD_COMPONENT), 1)
663 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
664 $(TargetCommonOpts) $(CompileCommonOpts) -c
665 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
667 $(TargetCommonOpts) $(CompileCommonOpts) -c
668 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
669 $(CompileCommonOpts) $(CXX.Flags) -E
670 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
672 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
674 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
675 $(TargetCommonOpts) $(CompileCommonOpts) -c
676 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
677 $(TargetCommonOpts) $(CompileCommonOpts) -c
678 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
679 $(CompileCommonOpts) $(CXX.Flags) -E
680 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
681 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
684 BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
685 $(TargetCommonOpts) $(CompileCommonOpts)
686 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
687 $(TargetCommonOpts) $(CompileCommonOpts) -E
689 BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
690 $(TargetCommonOpts) $(CompileCommonOpts)
692 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
693 ScriptInstall = $(INSTALL) -m 0755
694 DataInstall = $(INSTALL) -m 0644
696 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
697 # paths. In this case, the SYSPATH function (defined in
698 # Makefile.config) transforms Unix paths into Windows paths.
699 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
700 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
701 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
702 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
704 Archive = $(AR) $(AR.Flags)
705 LArchive = $(LLVMToolDir)/llvm-ar rcsf
714 #----------------------------------------------------------
715 # Get the list of source files and compute object file
717 #----------------------------------------------------------
720 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
721 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
723 Sources := $(SOURCES)
727 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
730 BaseNameSources := $(sort $(basename $(Sources)))
732 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
733 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
735 ###############################################################################
736 # DIRECTORIES: Handle recursive descent of directory structure
737 ###############################################################################
739 #---------------------------------------------------------
740 # Provide rules to make install dirs. This must be early
741 # in the file so they get built before dependencies
742 #---------------------------------------------------------
744 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
747 # To create other directories, as needed, and timestamp their creation
749 $(Verb) $(MKDIR) $* > /dev/null
750 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
752 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
753 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
755 #---------------------------------------------------------
756 # Handle the DIRS options for sequential construction
757 #---------------------------------------------------------
763 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
764 $(RecursiveTargets)::
765 $(Verb) for dir in $(DIRS); do \
766 if ([ ! -f $$dir/Makefile ] || \
767 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
769 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
771 ($(MAKE) -C $$dir $@ ) || exit 1; \
774 $(RecursiveTargets)::
775 $(Verb) for dir in $(DIRS); do \
776 ($(MAKE) -C $$dir $@ ) || exit 1; \
782 #---------------------------------------------------------
783 # Handle the EXPERIMENTAL_DIRS options ensuring success
784 # after each directory is built.
785 #---------------------------------------------------------
786 ifdef EXPERIMENTAL_DIRS
787 $(RecursiveTargets)::
788 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
789 if ([ ! -f $$dir/Makefile ] || \
790 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
792 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
794 ($(MAKE) -C $$dir $@ ) || exit 0; \
798 #-----------------------------------------------------------
799 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
800 #-----------------------------------------------------------
801 ifdef OPTIONAL_PARALLEL_DIRS
802 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
805 #-----------------------------------------------------------
806 # Handle the PARALLEL_DIRS options for parallel construction
807 #-----------------------------------------------------------
810 SubDirs += $(PARALLEL_DIRS)
812 # Unfortunately, this list must be maintained if new recursive targets are added
813 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
814 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
815 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
816 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
817 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
818 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
819 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
821 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
824 $(Verb) if ([ ! -f $(@D)/Makefile ] || \
825 command test $(@D)/Makefile -ot \
826 $(PROJ_SRC_DIR)/$(@D)/Makefile ); then \
828 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
830 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
833 #---------------------------------------------------------
834 # Handle the OPTIONAL_DIRS options for directores that may
836 #---------------------------------------------------------
839 SubDirs += $(OPTIONAL_DIRS)
841 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
842 $(RecursiveTargets)::
843 $(Verb) for dir in $(OPTIONAL_DIRS); do \
844 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
845 if ([ ! -f $$dir/Makefile ] || \
846 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
848 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
850 ($(MAKE) -C$$dir $@ ) || exit 1; \
854 $(RecursiveTargets)::
855 $(Verb) for dir in $(OPTIONAL_DIRS); do \
856 ($(MAKE) -C$$dir $@ ) || exit 1; \
861 #---------------------------------------------------------
862 # Handle the CONFIG_FILES options
863 #---------------------------------------------------------
868 $(Echo) Install circumvented with NO_INSTALL
870 $(Echo) UnInstall circumvented with NO_INSTALL
872 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
873 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
874 $(Verb)for file in $(CONFIG_FILES); do \
875 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
876 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
877 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
878 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
880 $(ECHO) Error: cannot find config file $${file}. ; \
885 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
886 $(Verb)for file in $(CONFIG_FILES); do \
887 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
893 ###############################################################################
894 # Set up variables for building libraries
895 ###############################################################################
897 #---------------------------------------------------------
898 # Define various command line options pertaining to the
899 # libraries needed when linking. There are "Proj" libs
900 # (defined by the user's project) and "LLVM" libs (defined
901 # by the LLVM project).
902 #---------------------------------------------------------
905 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
906 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
907 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
908 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
912 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
913 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
914 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
915 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
918 ifndef IS_CLEANING_TARGET
919 ifdef LINK_COMPONENTS
921 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
922 # clean in tools, then do a make in tools (instead of at the top level).
924 @echo "*** llvm-config doesn't exist - rebuilding it."
925 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
927 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
929 ifeq ($(ENABLE_SHARED), 1)
930 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
931 LLVMLibsPaths += $(LibDir)/libLLVM-$(LLVMVersion)$(SHLIBEXT)
933 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
934 LLVMLibsPaths += $(LLVM_CONFIG) \
935 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
940 # Set up the library exports file.
941 ifdef EXPORTED_SYMBOL_FILE
943 # First, set up the native export file, which may differ from the source
946 ifeq ($(HOST_OS),Darwin)
947 # Darwin convention prefixes symbols with underscores.
948 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
949 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
950 $(Verb) sed -e 's/^/_/' < $< > $@
952 -$(Verb) $(RM) -f $(NativeExportsFile)
954 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
955 # Gold and BFD ld require a version script rather than a plain list.
956 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
957 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
958 $(Verb) echo "{" > $@
959 $(Verb) grep -q "\<" $< && echo " global:" >> $@ || :
960 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
961 $(Verb) echo " local: *;" >> $@
962 $(Verb) echo "};" >> $@
964 -$(Verb) $(RM) -f $(NativeExportsFile)
966 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
970 # Now add the linker command-line options to use the native export file.
972 ifeq ($(HOST_OS),Darwin)
973 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
977 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
978 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
983 ###############################################################################
984 # Library Build Rules: Four ways to build a library
985 ###############################################################################
987 #---------------------------------------------------------
988 # Bytecode Module Targets:
989 # If the user set MODULE_NAME then they want to build a
990 # bytecode module from the sources. We compile all the
991 # sources and link it together into a single bytecode
993 #---------------------------------------------------------
996 ifeq ($(strip $(LLVMCC)),)
997 $(warning Modules require LLVM capable compiler but none is available ****)
1000 Module := $(LibDir)/$(MODULE_NAME).bc
1001 LinkModule := $(LLVMLD) -r
1004 ifdef EXPORTED_SYMBOL_FILE
1005 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1008 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
1009 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
1010 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1012 all-local:: $(Module)
1015 ifneq ($(strip $(Module)),)
1016 -$(Verb) $(RM) -f $(Module)
1019 ifdef BYTECODE_DESTINATION
1020 ModuleDestDir := $(BYTECODE_DESTINATION)
1022 ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
1027 $(Echo) Install circumvented with NO_INSTALL
1029 $(Echo) Uninstall circumvented with NO_INSTALL
1031 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1033 install-module:: $(DestModule)
1034 install-local:: $(DestModule)
1036 $(DestModule): $(ModuleDestDir) $(Module)
1037 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1038 $(Verb) $(DataInstall) $(Module) $(DestModule)
1041 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1042 -$(Verb) $(RM) -f $(DestModule)
1048 # if we're building a library ...
1051 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1052 LIBRARYNAME := $(strip $(LIBRARYNAME))
1053 ifdef LOADABLE_MODULE
1054 LibName.A := $(LibDir)/$(LIBRARYNAME).a
1055 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
1057 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
1058 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1060 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1061 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1063 #---------------------------------------------------------
1064 # Shared Library Targets:
1065 # If the user asked for a shared library to be built
1066 # with the SHARED_LIBRARY variable, then we provide
1067 # targets for building them.
1068 #---------------------------------------------------------
1069 ifdef SHARED_LIBRARY
1071 all-local:: $(LibName.SO)
1073 ifdef EXPORTED_SYMBOL_FILE
1074 $(LibName.SO): $(NativeExportsFile)
1077 ifdef LINK_LIBS_IN_SHARED
1078 ifdef LOADABLE_MODULE
1079 SharedLibKindMessage := "Loadable Module"
1081 SharedLibKindMessage := "Shared Library"
1083 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
1084 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1086 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1087 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1089 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
1090 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1091 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1095 ifneq ($(strip $(LibName.SO)),)
1096 -$(Verb) $(RM) -f $(LibName.SO)
1101 $(Echo) Install circumvented with NO_INSTALL
1103 $(Echo) Uninstall circumvented with NO_INSTALL
1106 ifdef LOADABLE_MODULE
1107 DestSharedLib = $(DESTDIR)$(PROJ_libdir)/$(LIBRARYNAME)$(SHLIBEXT)
1109 DestSharedLib = $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1112 install-local:: $(DestSharedLib)
1114 $(DestSharedLib): $(LibName.SO) $(DESTDIR)$(PROJ_libdir)
1115 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1116 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1119 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1120 -$(Verb) $(RM) -f $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).*
1124 #---------------------------------------------------------
1125 # Bytecode Library Targets:
1126 # If the user asked for a bytecode library to be built
1127 # with the BYTECODE_LIBRARY variable, then we provide
1128 # targets for building them.
1129 #---------------------------------------------------------
1130 ifdef BYTECODE_LIBRARY
1131 ifeq ($(strip $(LLVMCC)),)
1132 $(warning Bytecode libraries require LLVM capable compiler but none is available ****)
1135 all-local:: $(LibName.BCA)
1137 ifdef EXPORTED_SYMBOL_FILE
1138 BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1140 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1141 $(LLVMToolDir)/llvm-ar
1142 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1144 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1146 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1148 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1149 $(LLVMToolDir)/llvm-ar
1150 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1152 $(Verb) $(LArchive) $@ $(ObjectsBC)
1157 ifneq ($(strip $(LibName.BCA)),)
1158 -$(Verb) $(RM) -f $(LibName.BCA)
1161 ifdef BYTECODE_DESTINATION
1162 BytecodeDestDir := $(BYTECODE_DESTINATION)
1164 BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
1167 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1169 install-bytecode-local:: $(DestBytecodeLib)
1173 $(Echo) Install circumvented with NO_INSTALL
1175 $(Echo) Uninstall circumvented with NO_INSTALL
1177 install-local:: $(DestBytecodeLib)
1179 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1180 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1181 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1184 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1185 -$(Verb) $(RM) -f $(DestBytecodeLib)
1190 #---------------------------------------------------------
1192 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1193 # building an archive.
1194 #---------------------------------------------------------
1195 ifndef NO_BUILD_ARCHIVE
1196 ifndef BUILD_ARCHIVE
1197 ifndef LOADABLE_MODULE
1203 #---------------------------------------------------------
1204 # Archive Library Targets:
1205 # If the user wanted a regular archive library built,
1206 # then we provide targets for building them.
1207 #---------------------------------------------------------
1210 all-local:: $(LibName.A)
1212 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1213 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1214 -$(Verb) $(RM) -f $@
1215 $(Verb) $(Archive) $@ $(ObjectsO)
1216 $(Verb) $(Ranlib) $@
1219 ifneq ($(strip $(LibName.A)),)
1220 -$(Verb) $(RM) -f $(LibName.A)
1225 $(Echo) Install circumvented with NO_INSTALL
1227 $(Echo) Uninstall circumvented with NO_INSTALL
1229 ifdef NO_INSTALL_ARCHIVES
1231 $(Echo) Install circumvented with NO_INSTALL
1233 $(Echo) Uninstall circumvented with NO_INSTALL
1235 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1237 install-local:: $(DestArchiveLib)
1239 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1240 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1241 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1242 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1245 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1246 -$(Verb) $(RM) -f $(DestArchiveLib)
1254 ###############################################################################
1255 # Tool Build Rules: Build executable tool based on TOOLNAME option
1256 ###############################################################################
1260 #---------------------------------------------------------
1261 # Set up variables for building a tool.
1262 #---------------------------------------------------------
1263 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1265 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1267 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1270 # TOOLALIAS is a name to symlink (or copy) the tool to.
1273 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1275 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1279 #---------------------------------------------------------
1281 #---------------------------------------------------------
1283 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1284 # not exporting all of the weak symbols from the binary. This reduces dyld
1285 # startup time by 4x on darwin in some cases.
1286 ifdef TOOL_NO_EXPORTS
1287 ifeq ($(HOST_OS),Darwin)
1289 # Tiger tools don't support this.
1290 ifneq ($(DARWIN_MAJVERS),4)
1291 LD.Flags += -Wl,-exported_symbol,_main
1295 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1296 ifneq ($(ARCH), Mips)
1297 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1302 #---------------------------------------------------------
1303 # Tool Version Info Support
1304 #---------------------------------------------------------
1306 ifeq ($(HOST_OS),Darwin)
1307 ifdef TOOL_INFO_PLIST
1309 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1311 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1313 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1314 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1315 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1316 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1317 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1318 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1324 #---------------------------------------------------------
1325 # Provide targets for building the tools
1326 #---------------------------------------------------------
1327 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1330 ifneq ($(strip $(ToolBuildPath)),)
1331 -$(Verb) $(RM) -f $(ToolBuildPath)
1333 ifneq ($(strip $(ToolAliasBuildPath)),)
1334 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1338 $(ToolBuildPath): $(ExmplDir)/.dir
1340 $(ToolBuildPath): $(ToolDir)/.dir
1343 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1344 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1345 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1346 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1347 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1350 ifneq ($(strip $(ToolAliasBuildPath)),)
1351 $(ToolAliasBuildPath): $(ToolBuildPath)
1352 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1353 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1354 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1355 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLNAME) \
1361 $(Echo) Install circumvented with NO_INSTALL
1363 $(Echo) Uninstall circumvented with NO_INSTALL
1365 DestTool = $(DESTDIR)$(PROJ_bindir)/$(TOOLEXENAME)
1367 install-local:: $(DestTool)
1369 $(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
1370 $(Echo) Installing $(BuildMode) $(DestTool)
1371 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1374 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1375 -$(Verb) $(RM) -f $(DestTool)
1377 # TOOLALIAS install.
1379 DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)
1381 install-local:: $(DestToolAlias)
1383 $(DestToolAlias): $(DestTool)
1384 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1385 $(Verb) $(RM) -f $(DestToolAlias)
1386 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1389 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1390 -$(Verb) $(RM) -f $(DestToolAlias)
1396 ###############################################################################
1397 # Object Build Rules: Build object files based on sources
1398 ###############################################################################
1400 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1401 ifeq ($(HOST_OS),HP-UX)
1402 DISABLE_AUTO_DEPENDENCIES=1
1405 # Provide rule sets for when dependency generation is enabled
1406 ifndef DISABLE_AUTO_DEPENDENCIES
1408 #---------------------------------------------------------
1409 # Create .o files in the ObjDir directory from the .cpp and .c files...
1410 #---------------------------------------------------------
1412 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1413 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1415 # If the build succeeded, move the dependency file over, otherwise
1417 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1418 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1420 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1421 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1422 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1425 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1426 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1427 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1430 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1431 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1432 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1435 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1436 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1437 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1440 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1441 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1442 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1445 #---------------------------------------------------------
1446 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1447 #---------------------------------------------------------
1449 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1450 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1452 # If the build succeeded, move the dependency file over, otherwise
1454 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1455 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1457 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1458 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1459 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1460 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1461 $(BC_DEPEND_MOVEFILE)
1463 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1464 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1465 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1466 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1467 $(BC_DEPEND_MOVEFILE)
1469 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1470 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1471 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1472 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1473 $(BC_DEPEND_MOVEFILE)
1475 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1476 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1477 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1478 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1479 $(BC_DEPEND_MOVEFILE)
1481 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1482 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1483 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1484 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1485 $(BC_DEPEND_MOVEFILE)
1487 # Provide alternate rule sets if dependencies are disabled
1490 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1491 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1492 $(Compile.CXX) $< -o $@
1494 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1495 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1496 $(Compile.CXX) $< -o $@
1498 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1499 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1500 $(Compile.CXX) $< -o $@
1502 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1503 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1504 $(Compile.C) $< -o $@
1506 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1507 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1508 $(Compile.C) $< -o $@
1510 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1511 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1512 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1514 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1515 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1516 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1518 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1519 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1520 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1522 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1523 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1524 $(BCCompile.C) $< -o $@ -S -emit-llvm
1526 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1527 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1528 $(BCCompile.C) $< -o $@ -S -emit-llvm
1533 ## Rules for building preprocessed (.i/.ii) outputs.
1534 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1535 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1536 $(Verb) $(Preprocess.CXX) $< -o $@
1538 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1539 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1540 $(Verb) $(Preprocess.CXX) $< -o $@
1542 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1543 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1544 $(Verb) $(Preprocess.CXX) $< -o $@
1546 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1547 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1548 $(Verb) $(Preprocess.C) $< -o $@
1550 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1551 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1552 $(Verb) $(Preprocess.C) $< -o $@
1555 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1556 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1557 $(Compile.CXX) $< -o $@ -S
1559 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1560 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1561 $(Compile.CXX) $< -o $@ -S
1563 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1564 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1565 $(Compile.CXX) $< -o $@ -S
1567 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1568 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1569 $(Compile.C) $< -o $@ -S
1571 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1572 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1573 $(Compile.C) $< -o $@ -S
1576 # make the C and C++ compilers strip debug info out of bytecode libraries.
1578 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1579 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1580 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1582 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1583 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1584 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1588 #---------------------------------------------------------
1589 # Provide rule to build .bc files from .ll sources,
1590 # regardless of dependencies
1591 #---------------------------------------------------------
1592 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1593 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1594 $(Verb) $(LLVMAS) $< -f -o $@
1596 ###############################################################################
1597 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1598 ###############################################################################
1601 TABLEGEN_INC_FILES_COMMON = 1
1604 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1605 TABLEGEN_INC_FILES_COMMON = 1
1608 ifdef TABLEGEN_INC_FILES_COMMON
1610 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1611 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1612 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1614 # INCFiles rule: All of the tblgen generated files are emitted to
1615 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1616 # us to only "touch" the real file if the contents of it change. IOW, if
1617 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1618 # dependencies of the .inc files are, unless the contents of the .inc file
1620 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1621 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1623 endif # TABLEGEN_INC_FILES_COMMON
1627 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1628 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1629 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1630 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1631 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1632 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1633 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1635 # All of these files depend on tblgen and the .td files.
1636 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1638 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1639 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1640 $(Echo) "Building $(<F) register names with tblgen"
1641 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1643 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1644 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1645 $(Echo) "Building $(<F) register information header with tblgen"
1646 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1648 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1649 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1650 $(Echo) "Building $(<F) register info implementation with tblgen"
1651 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1653 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1654 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1655 $(Echo) "Building $(<F) instruction names with tblgen"
1656 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1658 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1659 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1660 $(Echo) "Building $(<F) instruction information with tblgen"
1661 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1663 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1664 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1665 $(Echo) "Building $(<F) assembly writer with tblgen"
1666 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1668 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1669 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1670 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1671 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1673 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1674 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1675 $(Echo) "Building $(<F) assembly matcher with tblgen"
1676 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1678 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1679 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1680 $(Echo) "Building $(<F) code emitter with tblgen"
1681 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1683 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1684 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1685 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1686 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1688 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1689 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir
1690 $(Echo) "Building $(<F) disassembly tables with tblgen"
1691 $(Verb) $(TableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1693 $(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1694 $(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir
1695 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1696 $(Verb) $(TableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1698 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1699 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1700 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1701 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1703 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1704 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1705 $(Echo) "Building $(<F) subtarget information with tblgen"
1706 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1708 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1709 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1710 $(Echo) "Building $(<F) calling convention information with tblgen"
1711 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1713 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1714 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir
1715 $(Echo) "Building $(<F) intrinsics information with tblgen"
1716 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1718 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir
1719 $(Echo) "Building $(<F) decoder tables with tblgen"
1720 $(Verb) $(TableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1724 -$(Verb) $(RM) -f $(INCFiles)
1728 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1730 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1731 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1733 TDFiles := $(LLVMCPluginSrc) \
1734 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1736 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1737 $(TBLGEN) $(TD_COMMON)
1738 $(Echo) "Building LLVMC configuration library with tblgen"
1739 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1741 endif # LLVMC_BUILD_AUTOGENERATED_INC
1743 ###############################################################################
1744 # OTHER RULES: Other rules needed
1745 ###############################################################################
1747 # To create postscript files from dot files...
1748 ifneq ($(DOT),false)
1750 $(DOT) -Tps < $< > $@
1753 $(Echo) "Cannot build $@: The program dot is not installed"
1756 # This rules ensures that header files that are removed still have a rule for
1757 # which they can be "generated." This allows make to ignore them and
1758 # reproduce the dependency lists.
1762 # Define clean-local to clean the current directory. Note that this uses a
1763 # very conservative approach ensuring that empty variables do not cause
1764 # errors or disastrous removal.
1766 ifneq ($(strip $(ObjRootDir)),)
1767 -$(Verb) $(RM) -rf $(ObjRootDir)
1769 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1770 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1771 -$(Verb) $(RM) -f *$(SHLIBEXT)
1775 -$(Verb) $(RM) -rf Debug Release Profile
1778 ###############################################################################
1779 # DEPENDENCIES: Include the dependency files if we should
1780 ###############################################################################
1781 ifndef DISABLE_AUTO_DEPENDENCIES
1783 # If its not one of the cleaning targets
1784 ifndef IS_CLEANING_TARGET
1786 # Get the list of dependency files
1787 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1788 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1790 # Include bitcode dependency files if using bitcode libraries
1791 ifdef BYTECODE_LIBRARY
1792 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1795 -include $(DependFiles) ""
1801 ###############################################################################
1802 # CHECK: Running the test suite
1803 ###############################################################################
1806 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1807 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1808 $(EchoCmd) Running test suite ; \
1809 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1810 TESTSUITE=$(TESTSUITE) ; \
1812 $(EchoCmd) No Makefile in test directory ; \
1815 $(EchoCmd) No test directory ; \
1821 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1822 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1823 $(EchoCmd) Running test suite ; \
1824 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-dg ; \
1826 $(EchoCmd) No Makefile in test directory ; \
1829 $(EchoCmd) No test directory ; \
1833 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1834 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1835 $(EchoCmd) Running test suite ; \
1836 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1838 $(EchoCmd) No Makefile in test directory ; \
1841 $(EchoCmd) No test directory ; \
1844 ###############################################################################
1845 # UNITTESTS: Running the unittests test suite
1846 ###############################################################################
1849 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1850 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1851 $(EchoCmd) Running unittests test suite ; \
1852 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1854 $(EchoCmd) No Makefile in unittests directory ; \
1857 $(EchoCmd) No unittests directory ; \
1860 ###############################################################################
1861 # DISTRIBUTION: Handle construction of a distribution tarball
1862 ###############################################################################
1864 #------------------------------------------------------------------------
1865 # Define distribution related variables
1866 #------------------------------------------------------------------------
1867 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1868 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1869 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1870 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1871 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1872 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1873 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1874 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1875 Makefile.config.in configure autoconf
1876 DistOther := $(notdir $(wildcard \
1877 $(PROJ_SRC_DIR)/*.h \
1878 $(PROJ_SRC_DIR)/*.td \
1879 $(PROJ_SRC_DIR)/*.def \
1880 $(PROJ_SRC_DIR)/*.ll \
1881 $(PROJ_SRC_DIR)/*.in))
1882 DistSubDirs := $(SubDirs)
1883 DistSources = $(Sources) $(EXTRA_DIST)
1884 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1886 #------------------------------------------------------------------------
1887 # We MUST build distribution with OBJ_DIR != SRC_DIR
1888 #------------------------------------------------------------------------
1889 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1890 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1891 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1895 #------------------------------------------------------------------------
1896 # Prevent attempt to run dist targets from anywhere but the top level
1897 #------------------------------------------------------------------------
1899 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1900 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1903 #------------------------------------------------------------------------
1904 # Provide the top level targets
1905 #------------------------------------------------------------------------
1907 dist-gzip:: $(DistTarGZip)
1909 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1910 $(Echo) Packing gzipped distribution tar file.
1911 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1912 $(GZIP) -c > "$(DistTarGZip)"
1914 dist-bzip2:: $(DistTarBZ2)
1916 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1917 $(Echo) Packing bzipped distribution tar file.
1918 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1919 $(BZIP2) -c >$(DistTarBZ2)
1921 dist-zip:: $(DistZip)
1923 $(DistZip) : $(TopDistDir)/.makedistdir
1924 $(Echo) Packing zipped distribution file.
1925 $(Verb) rm -f $(DistZip)
1926 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1928 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1929 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1931 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1933 dist-check:: $(DistTarGZip)
1934 $(Echo) Checking distribution tar file.
1935 $(Verb) if test -d $(DistCheckDir) ; then \
1936 $(RM) -rf $(DistCheckDir) ; \
1938 $(Verb) $(MKDIR) $(DistCheckDir)
1939 $(Verb) cd $(DistCheckDir) && \
1940 $(MKDIR) $(DistCheckDir)/build && \
1941 $(MKDIR) $(DistCheckDir)/install && \
1942 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1944 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1945 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1948 $(MAKE) unittests && \
1949 $(MAKE) install && \
1950 $(MAKE) uninstall && \
1951 $(MAKE) dist-clean && \
1952 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1955 $(Echo) Cleaning distribution files
1956 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1961 #------------------------------------------------------------------------
1962 # Provide the recursive distdir target for building the distribution directory
1963 #------------------------------------------------------------------------
1964 distdir: $(DistDir)/.makedistdir
1965 $(DistDir)/.makedistdir: $(DistSources)
1966 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1967 if test -d "$(DistDir)" ; then \
1968 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1971 $(EchoCmd) Removing old $(DistDir) ; \
1972 $(RM) -rf $(DistDir); \
1973 $(EchoCmd) Making 'all' to verify build ; \
1974 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1976 $(Echo) Building Distribution Directory $(DistDir)
1977 $(Verb) $(MKDIR) $(DistDir)
1978 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1979 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1980 for file in $(DistFiles) ; do \
1982 $(PROJ_SRC_DIR)/*) \
1983 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1985 $(PROJ_SRC_ROOT)/*) \
1986 file=`echo "$$file" | \
1987 sed "s#^$$srcrootstrip/##"` \
1990 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1991 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1992 from_dir="$(PROJ_SRC_DIR)" ; \
1993 elif test -f "$$file" || test -d "$$file" ; then \
1996 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1997 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1998 to_dir="$(DistDir)/$$dir"; \
1999 $(MKDIR) "$$to_dir" ; \
2001 to_dir="$(DistDir)"; \
2003 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
2004 if test -n "$$mid_dir" ; then \
2005 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
2007 if test -d "$$from_dir/$$file"; then \
2008 if test -d "$(PROJ_SRC_DIR)/$$file" && \
2009 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
2010 cd $(PROJ_SRC_DIR) ; \
2011 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2012 ( cd $$to_dir ; $(TAR) xf - ) ; \
2013 cd $(PROJ_OBJ_DIR) ; \
2016 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2017 ( cd $$to_dir ; $(TAR) xf - ) ; \
2018 cd $(PROJ_OBJ_DIR) ; \
2020 elif test -f "$$from_dir/$$file" ; then \
2021 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
2022 elif test -L "$$from_dir/$$file" ; then \
2023 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
2024 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
2025 $(EchoCmd) "===== WARNING: Distribution Source " \
2026 "$$from_dir/$$file Not Found!" ; \
2027 elif test "$(Verb)" != '@' ; then \
2028 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
2031 $(Verb) for subdir in $(DistSubDirs) ; do \
2032 if test "$$subdir" \!= "." ; then \
2033 new_distdir="$(DistDir)/$$subdir" ; \
2034 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
2035 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
2036 DistDir="$$new_distdir" distdir ) || exit 1; \
2039 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2040 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2041 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2042 -name .svn \) -print` ;\
2043 $(MAKE) dist-hook ; \
2044 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2045 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2046 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2047 -o ! -type d ! -perm -444 -exec \
2048 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2049 || chmod -R a+r $(DistDir) ; \
2052 # This is invoked by distdir target, define it as a no-op to avoid errors if not
2058 ###############################################################################
2059 # TOP LEVEL - targets only to apply at the top level directory
2060 ###############################################################################
2064 #------------------------------------------------------------------------
2065 # Install support for the project's include files:
2066 #------------------------------------------------------------------------
2069 $(Echo) Install circumvented with NO_INSTALL
2071 $(Echo) Uninstall circumvented with NO_INSTALL
2074 $(Echo) Installing include files
2075 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2076 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2077 cd $(PROJ_SRC_ROOT)/include && \
2078 for hdr in `find . -type f '!' '(' -name '*~' \
2079 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
2080 grep -v .svn` ; do \
2081 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2082 if test \! -d "$$instdir" ; then \
2083 $(EchoCmd) Making install directory $$instdir ; \
2084 $(MKDIR) $$instdir ;\
2086 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2089 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2090 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2091 cd $(PROJ_OBJ_ROOT)/include && \
2092 for hdr in `find . -type f -print | grep -v CVS` ; do \
2093 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2099 $(Echo) Uninstalling include files
2100 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2101 cd $(PROJ_SRC_ROOT)/include && \
2102 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2103 '!' '(' -name '*~' -o -name '.#*' \
2104 -o -name '*.in' ')' -print ')' | \
2105 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2106 cd $(PROJ_SRC_ROOT)/include && \
2107 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2108 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2114 @echo searching for overlength lines in files: $(Sources)
2117 egrep -n '.{81}' $(Sources) /dev/null
2120 @echo searching for tabs in files: $(Sources)
2123 egrep -n ' ' $(Sources) /dev/null
2126 @ls -l $(LibDir) | awk '\
2127 BEGIN { sum = 0; } \
2129 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2130 @ls -l $(ToolDir) | awk '\
2131 BEGIN { sum = 0; } \
2133 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2134 #------------------------------------------------------------------------
2135 # Print out the directories used for building
2136 #------------------------------------------------------------------------
2138 $(Echo) "BuildMode : " '$(BuildMode)'
2139 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2140 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2141 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2142 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2143 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2144 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2145 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2146 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2147 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2148 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2149 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2150 $(Echo) "UserTargets : " '$(UserTargets)'
2151 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2152 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2153 $(Echo) "ObjDir : " '$(ObjDir)'
2154 $(Echo) "LibDir : " '$(LibDir)'
2155 $(Echo) "ToolDir : " '$(ToolDir)'
2156 $(Echo) "ExmplDir : " '$(ExmplDir)'
2157 $(Echo) "Sources : " '$(Sources)'
2158 $(Echo) "TDFiles : " '$(TDFiles)'
2159 $(Echo) "INCFiles : " '$(INCFiles)'
2160 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2161 $(Echo) "PreConditions: " '$(PreConditions)'
2162 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2163 $(Echo) "Compile.C : " '$(Compile.C)'
2164 $(Echo) "Archive : " '$(Archive)'
2165 $(Echo) "YaccFiles : " '$(YaccFiles)'
2166 $(Echo) "LexFiles : " '$(LexFiles)'
2167 $(Echo) "Module : " '$(Module)'
2168 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2169 $(Echo) "SubDirs : " '$(SubDirs)'
2170 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2171 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2176 # General debugging rule, use 'make dbg-print-XXX' to print the
2177 # definition, value and origin of XXX.
2179 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))