1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
10 # This file is included by all of the LLVM makefiles. For details on how to use
11 # it properly, please see the document MakefileGuide.html in the docs directory.
13 #===-----------------------------------------------------------------------====#
15 ################################################################################
16 # TARGETS: Define standard targets that can be invoked
17 ################################################################################
19 #--------------------------------------------------------------------
20 # Define the various target sets
21 #--------------------------------------------------------------------
22 RecursiveTargets := all clean clean-all install uninstall install-bytecode \
24 LocalTargets := all-local clean-local clean-all-local check-local \
25 install-local printvars uninstall-local \
26 install-bytecode-local
27 TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
29 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30 InternalTargets := preconditions distdir dist-hook
32 ################################################################################
33 # INITIALIZATION: Basic things the makefile needs
34 ################################################################################
36 #--------------------------------------------------------------------
37 # Set the VPATH so that we can find source files.
38 #--------------------------------------------------------------------
41 #--------------------------------------------------------------------
42 # Reset the list of suffixes we know how to build.
43 #--------------------------------------------------------------------
45 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .td .ps .dot .m .mm
46 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
48 #--------------------------------------------------------------------
49 # Mark all of these targets as phony to avoid implicit rule search
50 #--------------------------------------------------------------------
51 .PHONY: $(UserTargets) $(InternalTargets)
53 #--------------------------------------------------------------------
54 # Make sure all the user-target rules are double colon rules and
55 # they are defined first.
56 #--------------------------------------------------------------------
60 #------------------------------------------------------------------------
61 # LLVMBuild Integration
62 #------------------------------------------------------------------------
64 # We use llvm-build to generate all the data required by the Makefile based
65 # build system in one swoop:
67 # - We generate a file (a Makefile fragment) in the object root which contains
68 # all the definitions that are required by Makefiles across the entire
71 # - We generate the library table used by llvm-config.
73 # - We generate the dependencies for the Makefile fragment, so that we will
74 # automatically reconfigure outselves.
76 # The path to the llvm-build tool itself.
77 LLVMBuildTool := $(PROJ_SRC_ROOT)/utils/llvm-build/llvm-build
79 # The files we are going to generate using llvm-build.
80 LLVMBuildMakeFrag := $(PROJ_OBJ_ROOT)/Makefile.llvmbuild
81 LLVMConfigLibraryDependenciesInc := \
82 $(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc
84 # This is for temporary backwards compatibility.
85 ifndef TARGET_NATIVE_ARCH
86 TARGET_NATIVE_ARCH := $(ARCH)
89 # The rule to create the LLVMBuild Makefile fragment as well as the llvm-config
92 # Note that this target gets its real dependencies generated for us by
95 # We include a dependency on this Makefile to ensure that changes to the
96 # generation command get picked up.
97 $(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \
98 $(PROJ_OBJ_ROOT)/Makefile.config
99 $(Echo) Constructing LLVMBuild project information.
100 $(Verb)$(PYTHON) $(LLVMBuildTool) \
101 --native-target "$(TARGET_NATIVE_ARCH)" \
102 --enable-targets "$(TARGETS_TO_BUILD)" \
103 --enable-optional-components "$(OPTIONAL_COMPONENTS)" \
104 --write-library-table $(LLVMConfigLibraryDependenciesInc) \
105 --write-make-fragment $(LLVMBuildMakeFrag)
107 # For completeness, let Make know how the extra files are generated.
108 $(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrag)
110 # Include the generated Makefile fragment.
112 # We currently only include the dependencies for the fragment itself if we are
113 # at the top-level. Otherwise, recursive invocations would ends up doing
114 # substantially more redundant stat'ing.
116 # This means that we won't properly regenerate things for developers used to
117 # building from a subdirectory, but that is always somewhat unreliable.
119 LLVMBUILD_INCLUDE_DEPENDENCIES := 1
121 # Clean the generated makefile fragment at the top-level.
123 -$(Verb) $(RM) -f $(LLVMBuildMakeFrag)
125 -include $(LLVMBuildMakeFrag)
127 ################################################################################
128 # PRECONDITIONS: that which must be built/checked first
129 ################################################################################
131 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
132 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
133 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
134 ConfigureScript := $(PROJ_SRC_ROOT)/configure
135 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
136 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
137 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
138 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
139 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
140 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
141 ifneq ($(MakefileCommonIn),)
142 PreConditions += $(MakefileCommon)
145 ifneq ($(MakefileConfigIn),)
146 PreConditions += $(MakefileConfig)
149 preconditions: $(PreConditions)
151 #------------------------------------------------------------------------
152 # Make sure the BUILT_SOURCES are built first
153 #------------------------------------------------------------------------
154 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
157 ifneq ($(strip $(BUILT_SOURCES)),)
158 -$(Verb) $(RM) -f $(BUILT_SOURCES)
161 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
163 $(Verb) if test -x config.status ; then \
164 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
165 $(MKDIR) .spotless.save ; \
166 $(MV) config.status .spotless.save ; \
167 $(MV) mklib .spotless.save ; \
168 $(MV) projects .spotless.save ; \
170 $(MV) .spotless.save/config.status . ; \
171 $(MV) .spotless.save/mklib . ; \
172 $(MV) .spotless.save/projects . ; \
173 $(RM) -rf .spotless.save ; \
174 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
175 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
176 $(ConfigStatusScript) ; \
178 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
182 $(EchoCmd) "spotless target not supported for objdir == srcdir"
185 $(BUILT_SOURCES) : $(ObjMakefiles)
187 #------------------------------------------------------------------------
188 # Make sure we're not using a stale configuration
189 #------------------------------------------------------------------------
191 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
192 $(Verb) cd $(PROJ_OBJ_ROOT) && \
193 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
194 $(ConfigStatusScript)
196 .PRECIOUS: $(ConfigStatusScript)
197 $(ConfigStatusScript): $(ConfigureScript)
198 $(Echo) Reconfiguring with $<
199 $(Verb) cd $(PROJ_OBJ_ROOT) && \
200 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
201 $(ConfigStatusScript)
203 #------------------------------------------------------------------------
204 # Make sure the configuration makefile is up to date
205 #------------------------------------------------------------------------
206 ifneq ($(MakefileConfigIn),)
207 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
208 $(Echo) Regenerating $@
209 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
212 ifneq ($(MakefileCommonIn),)
213 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
214 $(Echo) Regenerating $@
215 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
218 #------------------------------------------------------------------------
219 # If the Makefile in the source tree has been updated, copy it over into the
220 # build tree. But, only do this if the source and object makefiles differ
221 #------------------------------------------------------------------------
223 PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
226 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
228 Makefile: $(PROJ_MAKEFILE) $(ExtraMakefiles)
229 $(Echo) "Updating Makefile"
230 $(Verb) $(MKDIR) $(@D)
231 $(Verb) $(CP) -f $< $@
233 # Copy the Makefile.* files unless we're in the root directory which avoids
234 # the copying of Makefile.config.in or other things that should be explicitly
236 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
238 *Makefile.rules) ;; \
240 *) $(EchoCmd) "Updating $(@F)" ; \
247 #------------------------------------------------------------------------
248 # Set up the basic dependencies
249 #------------------------------------------------------------------------
250 $(UserTargets):: $(PreConditions)
254 clean-all:: clean-local clean-all-local
255 install:: install-local
256 uninstall:: uninstall-local
257 install-local:: all-local
258 install-bytecode:: install-bytecode-local
260 ###############################################################################
261 # VARIABLES: Set up various variables based on configuration data
262 ###############################################################################
264 # Variable for if this make is for a "cleaning" target
265 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
269 #--------------------------------------------------------------------
270 # Variables derived from configuration we are building
271 #--------------------------------------------------------------------
274 ifeq ($(ENABLE_OPTIMIZED),1)
276 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
277 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
278 OmitFramePointer := -fomit-frame-pointer
281 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
282 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
283 LD.Flags += $(OPTIMIZE_OPTION)
285 BuildMode := $(BuildMode)+Debug
291 ifdef NO_DEBUG_SYMBOLS
292 BuildMode := Unoptimized
298 ifeq ($(ENABLE_SPLIT_DWARF), 1)
299 CXX.Flags += -gsplit-dwarf
300 C.Flags += -gsplit-dwarf
309 ifeq ($(ENABLE_LIBCPP),1)
310 CXX.Flags += -stdlib=libc++
311 LD.Flags += -stdlib=libc++
314 ifeq ($(ENABLE_CXX11),1)
315 CXX.Flags += -std=c++11
318 ifeq ($(ENABLE_WERROR),1)
323 ifeq ($(ENABLE_PROFILING),1)
324 BuildMode := $(BuildMode)+Profile
325 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
326 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
327 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg
331 ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
332 CXX.Flags += -fvisibility-inlines-hidden
335 ifdef ENABLE_EXPENSIVE_CHECKS
336 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
337 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
341 # IF REQUIRES_EH=1 is specified then don't disable exceptions
343 CXX.Flags += -fno-exceptions
345 # If the library requires EH, it also requires RTTI.
349 ifdef REQUIRES_FRAME_POINTER
350 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
351 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
352 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
355 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
356 ifneq ($(REQUIRES_RTTI), 1)
357 CXX.Flags += -fno-rtti
360 ifeq ($(ENABLE_COVERAGE),1)
361 BuildMode := $(BuildMode)+Coverage
362 CXX.Flags += -ftest-coverage -fprofile-arcs
363 C.Flags += -ftest-coverage -fprofile-arcs
366 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
367 # then disable assertions by defining the appropriate preprocessor symbols.
368 ifeq ($(DISABLE_ASSERTIONS),1)
369 CPP.Defines += -DNDEBUG
371 BuildMode := $(BuildMode)+Asserts
372 CPP.Defines += -D_DEBUG
375 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
376 # configured), then enable expensive checks by defining the
377 # appropriate preprocessor symbols.
378 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
379 BuildMode := $(BuildMode)+Checks
380 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
383 # LOADABLE_MODULE implies several other things so we force them to be
385 ifdef LOADABLE_MODULE
387 LINK_LIBS_IN_SHARED := 1
395 ifeq ($(ENABLE_PIC),1)
396 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
397 # Nothing. Win32 defaults to PIC and warns when given -fPIC
399 ifeq ($(HOST_OS),Darwin)
400 # Common symbols not allowed in dylib files
401 CXX.Flags += -fno-common
402 C.Flags += -fno-common
404 # Linux and others; pass -fPIC
410 ifeq ($(HOST_OS),Darwin)
411 CXX.Flags += -mdynamic-no-pic
412 C.Flags += -mdynamic-no-pic
416 # Support makefile variable to disable any kind of timestamp/non-deterministic
417 # info from being used in the build.
418 ifeq ($(ENABLE_TIMESTAMPS),1)
419 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
421 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
424 ifeq ($(HOST_OS),MingW)
426 CPP.Defines += -D__NO_CTYPE_INLINE
427 ifeq ($(LLVM_CROSS_COMPILING),1)
428 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
430 LD.Flags += -Wl,--allow-multiple-definition
435 CXX.Flags += -Woverloaded-virtual
436 CPP.BaseFlags += $(CPP.Defines)
439 # Make Floating point IEEE compliant on Alpha.
442 CPP.BaseFlags += -mieee
443 ifeq ($(ENABLE_PIC),0)
445 CPP.BaseFlags += -fPIC
448 LD.Flags += -Wl,--no-relax
451 # GNU ld/PECOFF accepts but ignores them below;
455 # FIXME: autoconf should be aware of them.
456 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
457 HAVE_LINK_VERSION_SCRIPT := 0
459 RDYNAMIC := -Wl,--export-all-symbols
462 #--------------------------------------------------------------------
463 # Directory locations
464 #--------------------------------------------------------------------
466 ifeq ($(LLVM_CROSS_COMPILING),1)
467 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
470 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
471 ObjDir := $(ObjRootDir)
472 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
473 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
474 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
475 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
476 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
477 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
479 #--------------------------------------------------------------------
480 # Locations of shared libraries
481 #--------------------------------------------------------------------
484 SharedLibDir := $(LibDir)
485 LLVMSharedLibDir := $(LLVMLibDir)
487 # Win32.DLL prefers to be located on the "PATH" of binaries.
488 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
489 SharedLibDir := $(ToolDir)
490 LLVMSharedLibDir := $(LLVMToolDir)
492 ifeq ($(HOST_OS),Cygwin)
499 #--------------------------------------------------------------------
500 # Full Paths To Compiled Tools and Utilities
501 #--------------------------------------------------------------------
502 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
503 ifdef BUILD_DIRS_ONLY
504 EchoCmd := $(EchoCmd) "(build tools)":
509 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
512 ifeq ($(LLVM_CROSS_COMPILING),1)
513 LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
515 LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
518 ifeq ($(LLVM_CROSS_COMPILING),1)
519 LLVM_CONFIG := $(BuildLLVMToolDir)/llvm-config$(BUILD_EXEEXT)
521 LLVM_CONFIG := $(LLVMToolDir)/llvm-config$(EXEEXT)
524 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
527 LLI := $(LLVMToolDir)/lli$(EXEEXT)
530 LLC := $(LLVMToolDir)/llc$(EXEEXT)
533 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
536 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
539 LLVMLINK := $(LLVMToolDir)/llvm-link$(EXEEXT)
542 #--------------------------------------------------------------------
543 # Adjust to user's request
544 #--------------------------------------------------------------------
546 ifeq ($(HOST_OS),Darwin)
547 ifdef MACOSX_DEPLOYMENT_TARGET
548 DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
550 DARWIN_VERSION := `sw_vers -productVersion`
552 # Strip a number like 10.4.7 to 10.4
553 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
554 # Get "4" out of 10.4 for later pieces in the makefile.
555 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
557 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
558 SharedLinkOptions := -dynamiclib
559 ifdef DEPLOYMENT_TARGET
560 SharedLinkOptions += $(DEPLOYMENT_TARGET)
563 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
567 SharedLinkOptions=-shared
570 ifeq ($(TARGET_OS),Darwin)
571 ifdef DEPLOYMENT_TARGET
572 TargetCommonOpts += $(DEPLOYMENT_TARGET)
575 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
581 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
582 ifneq ($(HOST_OS),Darwin)
583 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
595 # Adjust settings for verbose mode
598 AR.Flags += >/dev/null 2>/dev/null
599 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
601 ConfigureScriptFLAGS :=
604 # By default, strip symbol information from executable
606 Strip := $(PLATFORMSTRIPOPTS)
607 StripWarnMsg := "(without symbols)"
608 Install.StripFlag += -s
611 # Adjust linker flags for building an executable
612 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
613 ifndef TOOL_NO_EXPORTS
614 LD.Flags += $(RDYNAMIC)
616 ifneq ($(HOST_OS), Darwin)
618 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
621 ifneq ($(DARWIN_MAJVERS),4)
622 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
625 TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
626 LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
632 #----------------------------------------------------------
633 # Options To Invoke Tools
634 #----------------------------------------------------------
636 ifdef EXTRA_LD_OPTIONS
637 LD.Flags += $(EXTRA_LD_OPTIONS)
641 CompileCommonOpts += -pedantic -Wno-long-long
643 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
644 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
645 $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
646 $(NO_MISSING_FIELD_INITIALIZERS)
647 # Enable cast-qual for C++; the workaround is to use const_cast.
648 CXX.Flags += -Wcast-qual
650 ifeq ($(HOST_OS),HP-UX)
651 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
654 # If we are building a universal binary on Mac OS/X, pass extra options. This
655 # is useful to people that want to link the LLVM libraries into their universal
658 # The following can be optionally specified:
659 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
660 # For Mac OS/X 10.4 Intel machines, the traditional one is:
661 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
662 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
663 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
666 ifndef UNIVERSAL_ARCH
667 UNIVERSAL_ARCH := i386 ppc
669 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
670 TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
671 ifdef UNIVERSAL_SDK_PATH
672 TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
675 # Building universal cannot compute dependencies automatically.
676 DISABLE_AUTO_DEPENDENCIES=1
678 ifeq ($(TARGET_OS),Darwin)
679 ifeq ($(ARCH),x86_64)
680 TargetCommonOpts = -m64
683 TargetCommonOpts = -m32
689 ifeq ($(HOST_OS),SunOS)
690 CPP.BaseFlags += -include llvm/Support/Solaris.h
693 ifeq ($(HOST_OS),AuroraUX)
694 CPP.BaseFlags += -include llvm/Support/Solaris.h
695 endif # !HOST_OS - AuroraUX.
697 # On Windows, SharedLibDir != LibDir. The order is important.
698 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
699 LD.Flags += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
701 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
704 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
705 # All -I flags should go here, so that they don't confuse llvm-config.
706 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
707 $(patsubst %,-I%/include,\
708 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
709 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
712 ifeq ($(INCLUDE_BUILD_DIR),1)
713 CPP.Flags += -I$(ObjDir)
716 # SHOW_DIAGNOSTICS support.
717 ifeq ($(SHOW_DIAGNOSTICS),1)
718 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
719 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
724 Compile.C = $(Compile.Wrapper) \
725 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
726 $(TargetCommonOpts) $(CompileCommonOpts) -c
727 Compile.CXX = $(Compile.Wrapper) \
728 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
729 $(TargetCommonOpts) $(CompileCommonOpts) -c
730 Preprocess.CXX= $(Compile.Wrapper) \
731 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
732 $(CompileCommonOpts) $(CXX.Flags) -E
733 Link = $(Compile.Wrapper) \
734 $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
735 $(TargetCommonOpts) $(Strip)
737 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
738 $(TargetCommonOpts) $(CompileCommonOpts) -E
740 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
741 ScriptInstall = $(INSTALL) -m 0755
742 DataInstall = $(INSTALL) -m 0644
744 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
745 # paths. In this case, the SYSPATH function (defined in
746 # Makefile.config) transforms Unix paths into Windows paths.
747 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
748 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
749 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
750 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
751 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
753 Archive = $(AR) $(AR.Flags)
762 #----------------------------------------------------------
763 # Get the list of source files and compute object file
765 #----------------------------------------------------------
768 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
769 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
771 Sources := $(SOURCES)
775 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
778 BaseNameSources := $(sort $(basename $(Sources)))
780 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
782 #----------------------------------------------------------
783 # For Mingw MSYS bash and Python/w32:
785 # $(ECHOPATH) prints DOSish pathstring.
786 # ex) $(ECHOPATH) /include/sys/types.h
787 # --> C:/mingw/include/sys/types.h
788 # built-in "echo" does not transform path to DOSish path.
790 # FIXME: It would not be needed when MSYS's python
792 #----------------------------------------------------------
794 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
795 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
797 ECHOPATH := $(Verb)$(ECHO)
800 ###############################################################################
801 # DIRECTORIES: Handle recursive descent of directory structure
802 ###############################################################################
804 #---------------------------------------------------------
805 # Provide rules to make install dirs. This must be early
806 # in the file so they get built before dependencies
807 #---------------------------------------------------------
809 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
812 # To create other directories, as needed, and timestamp their creation
814 $(Verb) $(MKDIR) $* > /dev/null
815 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
817 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
818 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
820 #---------------------------------------------------------
821 # Handle the DIRS options for sequential construction
822 #---------------------------------------------------------
828 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
829 $(RecursiveTargets)::
830 $(Verb) for dir in $(DIRS); do \
831 if ([ ! -f $$dir/Makefile ] || \
832 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
834 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
836 ($(MAKE) -C $$dir $@ ) || exit 1; \
839 $(RecursiveTargets)::
840 $(Verb) for dir in $(DIRS); do \
841 ($(MAKE) -C $$dir $@ ) || exit 1; \
847 #---------------------------------------------------------
848 # Handle the EXPERIMENTAL_DIRS options ensuring success
849 # after each directory is built.
850 #---------------------------------------------------------
851 ifdef EXPERIMENTAL_DIRS
852 $(RecursiveTargets)::
853 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
854 if ([ ! -f $$dir/Makefile ] || \
855 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
857 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
859 ($(MAKE) -C $$dir $@ ) || exit 0; \
863 #-----------------------------------------------------------
864 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
865 #-----------------------------------------------------------
866 ifdef OPTIONAL_PARALLEL_DIRS
867 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
870 #-----------------------------------------------------------
871 # Handle the PARALLEL_DIRS options for parallel construction
872 #-----------------------------------------------------------
875 SubDirs += $(PARALLEL_DIRS)
877 # Unfortunately, this list must be maintained if new recursive targets are added
878 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
879 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
880 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
881 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
882 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
883 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
884 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
886 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
890 SD=$(PROJ_SRC_DIR)/$(@D); \
892 if [ ! -f $$SD/Makefile ]; then \
894 DD=$(notdir $(@D)); \
896 if ([ ! -f $$DD/Makefile ] || \
897 command test $$DD/Makefile -ot \
898 $$SD/Makefile ); then \
900 $(CP) $$SD/Makefile $$DD/Makefile; \
902 $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
905 #---------------------------------------------------------
906 # Handle the OPTIONAL_DIRS options for directores that may
908 #---------------------------------------------------------
911 SubDirs += $(OPTIONAL_DIRS)
913 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
914 $(RecursiveTargets)::
915 $(Verb) for dir in $(OPTIONAL_DIRS); do \
916 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
917 if ([ ! -f $$dir/Makefile ] || \
918 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
920 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
922 ($(MAKE) -C$$dir $@ ) || exit 1; \
926 $(RecursiveTargets)::
927 $(Verb) for dir in $(OPTIONAL_DIRS); do \
928 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
929 ($(MAKE) -C$$dir $@ ) || exit 1; \
935 #---------------------------------------------------------
936 # Handle the CONFIG_FILES options
937 #---------------------------------------------------------
942 $(Echo) Install circumvented with NO_INSTALL
944 $(Echo) UnInstall circumvented with NO_INSTALL
946 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
947 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
948 $(Verb)for file in $(CONFIG_FILES); do \
949 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
950 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
951 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
952 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
954 $(ECHO) Error: cannot find config file $${file}. ; \
959 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
960 $(Verb)for file in $(CONFIG_FILES); do \
961 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
967 ###############################################################################
968 # Set up variables for building libraries
969 ###############################################################################
971 #---------------------------------------------------------
972 # Define various command line options pertaining to the
973 # libraries needed when linking. There are "Proj" libs
974 # (defined by the user's project) and "LLVM" libs (defined
975 # by the LLVM project).
976 #---------------------------------------------------------
979 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
980 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
981 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
982 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
986 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
987 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
988 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
989 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
992 # Loadable module for Win32 requires all symbols resolved for linking.
993 # Then all symbols in LLVM.dll will be available.
994 ifeq ($(ENABLE_SHARED),1)
995 ifdef LOADABLE_MODULE
996 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
997 LINK_COMPONENTS += all
1002 ifndef IS_CLEANING_TARGET
1003 ifdef LINK_COMPONENTS
1005 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
1006 # clean in tools, then do a make in tools (instead of at the top level).
1008 @echo "*** llvm-config doesn't exist - rebuilding it."
1009 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1011 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1013 ifeq ($(ENABLE_SHARED), 1)
1014 # We can take the "auto-import" feature to get rid of using dllimport.
1015 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1016 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1019 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1020 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1023 ifndef NO_LLVM_CONFIG
1024 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1025 ifeq ($(LLVMConfigLibs),Error)
1026 $(error llvm-config --libs failed)
1028 LLVMLibsOptions += $(LLVMConfigLibs)
1029 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1030 ifeq ($(LLVMConfigLibfiles),Error)
1031 $(error llvm-config --libfiles failed)
1033 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1040 # Set up the library exports file.
1041 ifdef EXPORTED_SYMBOL_FILE
1043 # First, set up the native export file, which may differ from the source
1046 ifeq ($(HOST_OS),Darwin)
1047 # Darwin convention prefixes symbols with underscores.
1048 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1049 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1050 $(Verb) sed -e 's/^/_/' < $< > $@
1052 -$(Verb) $(RM) -f $(NativeExportsFile)
1054 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1055 # Gold and BFD ld require a version script rather than a plain list.
1056 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1057 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1058 $(Verb) echo "{" > $@
1059 $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || :
1060 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
1061 ifneq ($(HOST_OS),OpenBSD)
1062 $(Verb) echo " local: *;" >> $@
1064 $(Verb) echo "};" >> $@
1066 -$(Verb) $(RM) -f $(NativeExportsFile)
1068 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1069 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1070 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1071 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1072 $(Echo) Generating $(notdir $@)
1073 $(Verb) $(ECHO) "EXPORTS" > $@
1074 $(Verb) $(CAT) $< >> $@
1076 -$(Verb) $(RM) -f $(NativeExportsFile)
1078 # Default behavior: just use the exports file verbatim.
1079 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1084 # Now add the linker command-line options to use the native export file.
1087 ifeq ($(HOST_OS),Darwin)
1088 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1091 # gold, bfd ld, etc.
1092 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1093 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1097 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1098 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1099 SharedLinkOptions += $(NativeExportsFile)
1104 ###############################################################################
1105 # Library Build Rules: Four ways to build a library
1106 ###############################################################################
1108 # if we're building a library ...
1111 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1112 LIBRARYNAME := $(strip $(LIBRARYNAME))
1113 ifdef LOADABLE_MODULE
1114 BaseLibName.A := $(LIBRARYNAME).a
1115 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1117 BaseLibName.A := lib$(LIBRARYNAME).a
1118 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1120 LibName.A := $(LibDir)/$(BaseLibName.A)
1121 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1122 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1124 #---------------------------------------------------------
1125 # Shared Library Targets:
1126 # If the user asked for a shared library to be built
1127 # with the SHARED_LIBRARY variable, then we provide
1128 # targets for building them.
1129 #---------------------------------------------------------
1130 ifdef SHARED_LIBRARY
1132 all-local:: $(LibName.SO)
1134 ifdef EXPORTED_SYMBOL_FILE
1135 $(LibName.SO): $(NativeExportsFile)
1138 ifdef LINK_LIBS_IN_SHARED
1139 ifdef LOADABLE_MODULE
1140 SharedLibKindMessage := "Loadable Module"
1141 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1143 SharedLibKindMessage := "Shared Library"
1145 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1146 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1148 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1149 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1151 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1152 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1153 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1157 ifneq ($(strip $(LibName.SO)),)
1158 -$(Verb) $(RM) -f $(LibName.SO)
1163 $(Echo) Install circumvented with NO_INSTALL
1165 $(Echo) Uninstall circumvented with NO_INSTALL
1168 # Win32.DLL prefers to be located on the "PATH" of binaries.
1169 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1170 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1172 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1174 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1176 install-local:: $(DestSharedLib)
1178 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1179 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1180 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1183 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1184 -$(Verb) $(RM) -f $(DestSharedLib)
1188 #---------------------------------------------------------
1190 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1191 # building an archive.
1192 #---------------------------------------------------------
1193 ifndef NO_BUILD_ARCHIVE
1194 ifndef BUILD_ARCHIVE
1195 ifndef LOADABLE_MODULE
1201 #---------------------------------------------------------
1202 # Archive Library Targets:
1203 # If the user wanted a regular archive library built,
1204 # then we provide targets for building them.
1205 #---------------------------------------------------------
1208 all-local:: $(LibName.A)
1210 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1211 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1212 -$(Verb) $(RM) -f $@
1213 $(Verb) $(Archive) $@ $(ObjectsO)
1214 $(Verb) $(Ranlib) $@
1217 ifneq ($(strip $(LibName.A)),)
1218 -$(Verb) $(RM) -f $(LibName.A)
1223 $(Echo) Install circumvented with NO_INSTALL
1225 $(Echo) Uninstall circumvented with NO_INSTALL
1227 ifdef NO_INSTALL_ARCHIVES
1229 $(Echo) Install circumvented with NO_INSTALL
1231 $(Echo) Uninstall circumvented with NO_INSTALL
1233 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1235 install-local:: $(DestArchiveLib)
1237 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1238 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1239 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1240 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1243 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1244 -$(Verb) $(RM) -f $(DestArchiveLib)
1252 ###############################################################################
1253 # Tool Build Rules: Build executable tool based on TOOLNAME option
1254 ###############################################################################
1258 #---------------------------------------------------------
1259 # Set up variables for building a tool.
1260 #---------------------------------------------------------
1261 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1263 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1265 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1268 # TOOLALIAS is a name to symlink (or copy) the tool to.
1271 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1273 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1277 #---------------------------------------------------------
1279 #---------------------------------------------------------
1281 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1282 # not exporting all of the weak symbols from the binary. This reduces dyld
1283 # startup time by 4x on darwin in some cases.
1284 ifdef TOOL_NO_EXPORTS
1285 ifeq ($(HOST_OS),Darwin)
1287 # Tiger tools don't support this.
1288 ifneq ($(DARWIN_MAJVERS),4)
1289 LD.Flags += -Wl,-exported_symbol,_main
1293 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1294 ifneq ($(ARCH), Mips)
1295 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1300 #---------------------------------------------------------
1301 # Tool Order File Support
1302 #---------------------------------------------------------
1304 ifeq ($(HOST_OS),Darwin)
1305 ifdef TOOL_ORDER_FILE
1307 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1312 #---------------------------------------------------------
1313 # Tool Version Info Support
1314 #---------------------------------------------------------
1316 ifeq ($(HOST_OS),Darwin)
1317 ifdef TOOL_INFO_PLIST
1319 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1321 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1323 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1324 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1325 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1326 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1327 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1328 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1334 #---------------------------------------------------------
1335 # Provide targets for building the tools
1336 #---------------------------------------------------------
1337 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1340 ifneq ($(strip $(ToolBuildPath)),)
1341 -$(Verb) $(RM) -f $(ToolBuildPath)
1343 ifneq ($(strip $(ToolAliasBuildPath)),)
1344 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1348 $(ToolBuildPath): $(ExmplDir)/.dir
1350 $(ToolBuildPath): $(ToolDir)/.dir
1353 ifdef CODESIGN_TOOLS
1354 TOOL_CODESIGN_IDENTITY ?= -
1356 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1357 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1358 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1359 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1360 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1362 $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1363 $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1365 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1366 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1367 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1368 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1369 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1373 ifneq ($(strip $(ToolAliasBuildPath)),)
1374 $(ToolAliasBuildPath): $(ToolBuildPath)
1375 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1376 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1377 $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1378 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1384 $(Echo) Install circumvented with NO_INSTALL
1386 $(Echo) Uninstall circumvented with NO_INSTALL
1390 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1392 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1394 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1396 install-local:: $(DestTool)
1398 $(DestTool): $(ToolBuildPath)
1399 $(Echo) Installing $(BuildMode) $(DestTool)
1400 $(Verb) $(MKDIR) $(ToolBinDir)
1401 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1404 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1405 -$(Verb) $(RM) -f $(DestTool)
1407 # TOOLALIAS install.
1409 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1411 install-local:: $(DestToolAlias)
1413 $(DestToolAlias): $(DestTool)
1414 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1415 $(Verb) $(RM) -f $(DestToolAlias)
1416 $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1419 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1420 -$(Verb) $(RM) -f $(DestToolAlias)
1426 ###############################################################################
1427 # Object Build Rules: Build object files based on sources
1428 ###############################################################################
1430 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1431 ifeq ($(HOST_OS),HP-UX)
1432 DISABLE_AUTO_DEPENDENCIES=1
1435 # Provide rule sets for when dependency generation is enabled
1436 ifndef DISABLE_AUTO_DEPENDENCIES
1438 #---------------------------------------------------------
1439 # Create .o files in the ObjDir directory from the .cpp and .c files...
1440 #---------------------------------------------------------
1442 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1443 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1445 # If the build succeeded, move the dependency file over, otherwise
1447 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1448 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1450 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1451 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1452 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1455 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1456 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1457 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1460 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1461 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1462 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1465 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1466 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1467 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1470 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1471 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1472 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1475 # Provide alternate rule sets if dependencies are disabled
1478 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1479 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1480 $(Compile.CXX) $< -o $@
1482 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1483 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1484 $(Compile.CXX) $< -o $@
1486 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1487 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1488 $(Compile.CXX) $< -o $@
1490 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1491 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1492 $(Compile.C) $< -o $@
1494 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1495 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1496 $(Compile.C) $< -o $@
1500 ## Rules for building preprocessed (.i/.ii) outputs.
1501 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1502 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1503 $(Verb) $(Preprocess.CXX) $< -o $@
1505 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1506 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1507 $(Verb) $(Preprocess.CXX) $< -o $@
1509 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1510 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1511 $(Verb) $(Preprocess.CXX) $< -o $@
1513 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1514 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1515 $(Verb) $(Preprocess.C) $< -o $@
1517 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1518 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1519 $(Verb) $(Preprocess.C) $< -o $@
1522 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1523 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1524 $(Compile.CXX) $< -o $@ -S
1526 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1527 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1528 $(Compile.CXX) $< -o $@ -S
1530 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1531 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1532 $(Compile.CXX) $< -o $@ -S
1534 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1535 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1536 $(Compile.C) $< -o $@ -S
1538 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1539 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1540 $(Compile.C) $< -o $@ -S
1542 ###############################################################################
1543 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1544 ###############################################################################
1547 TABLEGEN_INC_FILES_COMMON = 1
1550 ifdef TABLEGEN_INC_FILES_COMMON
1552 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1553 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1554 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1556 # INCFiles rule: All of the tblgen generated files are emitted to
1557 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1558 # us to only "touch" the real file if the contents of it change. IOW, if
1559 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1560 # dependencies of the .inc files are, unless the contents of the .inc file
1562 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1563 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1565 endif # TABLEGEN_INC_FILES_COMMON
1569 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1570 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1571 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1572 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1573 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1574 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1575 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1577 # All .inc.tmp files depend on the .td files.
1578 $(INCTMPFiles) : $(TDFiles)
1580 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1581 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1582 $(Echo) "Building $(<F) register info implementation with tblgen"
1583 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1585 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1586 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1587 $(Echo) "Building $(<F) instruction information with tblgen"
1588 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1590 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1591 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1592 $(Echo) "Building $(<F) assembly writer with tblgen"
1593 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1595 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1596 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1597 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1598 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1600 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1601 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1602 $(Echo) "Building $(<F) assembly matcher with tblgen"
1603 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1605 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1606 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1607 $(Echo) "Building $(<F) MC code emitter with tblgen"
1608 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1610 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1611 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1612 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1613 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1615 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1616 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1617 $(Echo) "Building $(<F) code emitter with tblgen"
1618 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1620 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1621 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1622 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1623 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1625 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1626 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1627 $(Echo) "Building $(<F) disassembly tables with tblgen"
1628 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1630 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1631 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1632 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1633 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1635 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1636 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1637 $(Echo) "Building $(<F) subtarget information with tblgen"
1638 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1640 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1641 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1642 $(Echo) "Building $(<F) calling convention information with tblgen"
1643 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1645 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1646 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1647 $(Echo) "Building $(<F) intrinsics information with tblgen"
1648 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1650 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1651 $(Echo) "Building $(<F) decoder tables with tblgen"
1652 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1654 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1655 $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1656 $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1659 -$(Verb) $(RM) -f $(INCFiles)
1663 ###############################################################################
1664 # OTHER RULES: Other rules needed
1665 ###############################################################################
1667 # To create postscript files from dot files...
1668 ifneq ($(DOT),false)
1670 $(DOT) -Tps < $< > $@
1673 $(Echo) "Cannot build $@: The program dot is not installed"
1676 # This rules ensures that header files that are removed still have a rule for
1677 # which they can be "generated." This allows make to ignore them and
1678 # reproduce the dependency lists.
1682 # Define clean-local to clean the current directory. Note that this uses a
1683 # very conservative approach ensuring that empty variables do not cause
1684 # errors or disastrous removal.
1686 ifneq ($(strip $(ObjRootDir)),)
1687 -$(Verb) $(RM) -rf $(ObjRootDir)
1689 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1690 -$(Verb) $(RM) -f *$(SHLIBEXT)
1694 -$(Verb) $(RM) -rf Debug Release Profile
1697 ###############################################################################
1698 # DEPENDENCIES: Include the dependency files if we should
1699 ###############################################################################
1700 ifndef DISABLE_AUTO_DEPENDENCIES
1702 # If its not one of the cleaning targets
1703 ifndef IS_CLEANING_TARGET
1705 # Get the list of dependency files
1706 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1707 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1709 -include $(DependFiles) ""
1715 ###############################################################################
1716 # CHECK: Running the test suite
1717 ###############################################################################
1720 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1721 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1722 $(EchoCmd) Running test suite ; \
1723 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1724 TESTSUITE=$(TESTSUITE) ; \
1726 $(EchoCmd) No Makefile in test directory ; \
1729 $(EchoCmd) No test directory ; \
1732 # An alias dating from when both lit and DejaGNU test runners were used.
1736 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1737 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1738 $(EchoCmd) Running test suite ; \
1739 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1741 $(EchoCmd) No Makefile in test directory ; \
1744 $(EchoCmd) No test directory ; \
1747 ###############################################################################
1748 # UNITTESTS: Running the unittests test suite
1749 ###############################################################################
1752 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1753 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1754 $(EchoCmd) Running unittests test suite ; \
1755 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1757 $(EchoCmd) No Makefile in unittests directory ; \
1760 $(EchoCmd) No unittests directory ; \
1763 ###############################################################################
1764 # DISTRIBUTION: Handle construction of a distribution tarball
1765 ###############################################################################
1767 #------------------------------------------------------------------------
1768 # Define distribution related variables
1769 #------------------------------------------------------------------------
1770 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1771 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1772 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1773 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1774 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1775 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1776 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1777 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1778 Makefile.config.in configure autoconf
1779 DistOther := $(notdir $(wildcard \
1780 $(PROJ_SRC_DIR)/*.h \
1781 $(PROJ_SRC_DIR)/*.td \
1782 $(PROJ_SRC_DIR)/*.def \
1783 $(PROJ_SRC_DIR)/*.ll \
1784 $(PROJ_SRC_DIR)/*.in))
1785 DistSubDirs := $(SubDirs)
1786 DistSources = $(Sources) $(EXTRA_DIST)
1787 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1789 #------------------------------------------------------------------------
1790 # We MUST build distribution with OBJ_DIR != SRC_DIR
1791 #------------------------------------------------------------------------
1792 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1793 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1794 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1798 #------------------------------------------------------------------------
1799 # Prevent attempt to run dist targets from anywhere but the top level
1800 #------------------------------------------------------------------------
1802 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1803 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1806 #------------------------------------------------------------------------
1807 # Provide the top level targets
1808 #------------------------------------------------------------------------
1810 dist-gzip:: $(DistTarGZip)
1812 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1813 $(Echo) Packing gzipped distribution tar file.
1814 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1815 $(GZIP) -c > "$(DistTarGZip)"
1817 dist-bzip2:: $(DistTarBZ2)
1819 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1820 $(Echo) Packing bzipped distribution tar file.
1821 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1822 $(BZIP2) -c >$(DistTarBZ2)
1824 dist-zip:: $(DistZip)
1826 $(DistZip) : $(TopDistDir)/.makedistdir
1827 $(Echo) Packing zipped distribution file.
1828 $(Verb) rm -f $(DistZip)
1829 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1831 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1832 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1834 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1836 dist-check:: $(DistTarGZip)
1837 $(Echo) Checking distribution tar file.
1838 $(Verb) if test -d $(DistCheckDir) ; then \
1839 $(RM) -rf $(DistCheckDir) ; \
1841 $(Verb) $(MKDIR) $(DistCheckDir)
1842 $(Verb) cd $(DistCheckDir) && \
1843 $(MKDIR) $(DistCheckDir)/build && \
1844 $(MKDIR) $(DistCheckDir)/install && \
1845 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1847 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1848 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1851 $(MAKE) unittests && \
1852 $(MAKE) install && \
1853 $(MAKE) uninstall && \
1854 $(MAKE) dist-clean && \
1855 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1858 $(Echo) Cleaning distribution files
1859 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1864 #------------------------------------------------------------------------
1865 # Provide the recursive distdir target for building the distribution directory
1866 #------------------------------------------------------------------------
1867 distdir: $(DistDir)/.makedistdir
1868 $(DistDir)/.makedistdir: $(DistSources)
1869 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1870 if test -d "$(DistDir)" ; then \
1871 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1874 $(EchoCmd) Removing old $(DistDir) ; \
1875 $(RM) -rf $(DistDir); \
1876 $(EchoCmd) Making 'all' to verify build ; \
1877 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1879 $(Echo) Building Distribution Directory $(DistDir)
1880 $(Verb) $(MKDIR) $(DistDir)
1881 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1882 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1883 for file in $(DistFiles) ; do \
1885 $(PROJ_SRC_DIR)/*) \
1886 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1888 $(PROJ_SRC_ROOT)/*) \
1889 file=`echo "$$file" | \
1890 sed "s#^$$srcrootstrip/##"` \
1893 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1894 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1895 from_dir="$(PROJ_SRC_DIR)" ; \
1896 elif test -f "$$file" || test -d "$$file" ; then \
1899 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1900 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1901 to_dir="$(DistDir)/$$dir"; \
1902 $(MKDIR) "$$to_dir" ; \
1904 to_dir="$(DistDir)"; \
1906 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1907 if test -n "$$mid_dir" ; then \
1908 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1910 if test -d "$$from_dir/$$file"; then \
1911 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1912 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1913 cd $(PROJ_SRC_DIR) ; \
1914 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1915 ( cd $$to_dir ; $(TAR) xf - ) ; \
1916 cd $(PROJ_OBJ_DIR) ; \
1919 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1920 ( cd $$to_dir ; $(TAR) xf - ) ; \
1921 cd $(PROJ_OBJ_DIR) ; \
1923 elif test -f "$$from_dir/$$file" ; then \
1924 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1925 elif test -L "$$from_dir/$$file" ; then \
1926 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1927 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1928 $(EchoCmd) "===== WARNING: Distribution Source " \
1929 "$$from_dir/$$file Not Found!" ; \
1930 elif test "$(Verb)" != '@' ; then \
1931 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1934 $(Verb) for subdir in $(DistSubDirs) ; do \
1935 if test "$$subdir" \!= "." ; then \
1936 new_distdir="$(DistDir)/$$subdir" ; \
1937 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1938 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1939 DistDir="$$new_distdir" distdir ) || exit 1; \
1942 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1943 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1944 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1945 -name .svn \) -print` ;\
1946 $(MAKE) dist-hook ; \
1947 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1948 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1949 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1950 -o ! -type d ! -perm -444 -exec \
1951 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1952 || chmod -R a+r $(DistDir) ; \
1955 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1961 ###############################################################################
1962 # TOP LEVEL - targets only to apply at the top level directory
1963 ###############################################################################
1967 #------------------------------------------------------------------------
1968 # Install support for the project's include files:
1969 #------------------------------------------------------------------------
1972 $(Echo) Install circumvented with NO_INSTALL
1974 $(Echo) Uninstall circumvented with NO_INSTALL
1977 $(Echo) Installing include files
1978 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
1979 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1980 cd $(PROJ_SRC_ROOT)/include && \
1981 for hdr in `find . -type f \
1982 '(' -name LICENSE.TXT \
1987 ')' -print | grep -v CVS | \
1988 grep -v .svn` ; do \
1989 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
1990 if test \! -d "$$instdir" ; then \
1991 $(EchoCmd) Making install directory $$instdir ; \
1992 $(MKDIR) $$instdir ;\
1994 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
1997 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1998 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1999 cd $(PROJ_OBJ_ROOT)/include && \
2000 for hdr in `find . -type f \
2001 '(' -name LICENSE.TXT \
2006 ')' -print | grep -v CVS | \
2007 grep -v .svn` ; do \
2008 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2009 if test \! -d "$$instdir" ; then \
2010 $(EchoCmd) Making install directory $$instdir ; \
2011 $(MKDIR) $$instdir ;\
2013 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2019 $(Echo) Uninstalling include files
2020 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2021 cd $(PROJ_SRC_ROOT)/include && \
2022 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2023 '!' '(' -name '*~' -o -name '.#*' \
2024 -o -name '*.in' ')' -print ')' | \
2025 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2026 cd $(PROJ_SRC_ROOT)/include && \
2027 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2028 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2034 @echo searching for overlength lines in files: $(Sources)
2037 egrep -n '.{81}' $(Sources) /dev/null
2040 @echo searching for tabs in files: $(Sources)
2043 egrep -n ' ' $(Sources) /dev/null
2046 @ls -l $(LibDir) | awk '\
2047 BEGIN { sum = 0; } \
2049 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2050 @ls -l $(ToolDir) | awk '\
2051 BEGIN { sum = 0; } \
2053 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2054 #------------------------------------------------------------------------
2055 # Print out the directories used for building
2056 #------------------------------------------------------------------------
2058 $(Echo) "BuildMode : " '$(BuildMode)'
2059 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2060 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2061 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2062 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2063 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2064 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2065 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2066 $(Echo) "PROJ_internal_prefix : " '$(PROJ_internal_prefix)'
2067 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2068 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2069 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2070 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2071 $(Echo) "UserTargets : " '$(UserTargets)'
2072 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2073 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2074 $(Echo) "ObjDir : " '$(ObjDir)'
2075 $(Echo) "LibDir : " '$(LibDir)'
2076 $(Echo) "ToolDir : " '$(ToolDir)'
2077 $(Echo) "ExmplDir : " '$(ExmplDir)'
2078 $(Echo) "Sources : " '$(Sources)'
2079 $(Echo) "TDFiles : " '$(TDFiles)'
2080 $(Echo) "INCFiles : " '$(INCFiles)'
2081 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2082 $(Echo) "PreConditions: " '$(PreConditions)'
2083 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2084 $(Echo) "Compile.C : " '$(Compile.C)'
2085 $(Echo) "Archive : " '$(Archive)'
2086 $(Echo) "YaccFiles : " '$(YaccFiles)'
2087 $(Echo) "LexFiles : " '$(LexFiles)'
2088 $(Echo) "Module : " '$(Module)'
2089 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2090 $(Echo) "SubDirs : " '$(SubDirs)'
2091 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2092 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2097 # General debugging rule, use 'make dbg-print-XXX' to print the
2098 # definition, value and origin of XXX.
2100 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))