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)))
779 SourceDirs := $(sort $(dir $(Sources)))
781 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
782 ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
784 #----------------------------------------------------------
785 # For Mingw MSYS bash and Python/w32:
787 # $(ECHOPATH) prints DOSish pathstring.
788 # ex) $(ECHOPATH) /include/sys/types.h
789 # --> C:/mingw/include/sys/types.h
790 # built-in "echo" does not transform path to DOSish path.
792 # FIXME: It would not be needed when MSYS's python
794 #----------------------------------------------------------
796 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
797 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
799 ECHOPATH := $(Verb)$(ECHO)
802 ###############################################################################
803 # DIRECTORIES: Handle recursive descent of directory structure
804 ###############################################################################
806 #---------------------------------------------------------
807 # Provide rules to make install dirs. This must be early
808 # in the file so they get built before dependencies
809 #---------------------------------------------------------
811 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
814 # To create other directories, as needed, and timestamp their creation
816 $(Verb) $(MKDIR) $* > /dev/null
817 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
819 .PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
820 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
822 #---------------------------------------------------------
823 # Collect the object directories (as there may be more
824 # than one if the source code is spread across
826 #---------------------------------------------------------
828 OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
829 .PRECIOUS: $(OBJECT_DIRS)
831 #---------------------------------------------------------
832 # Handle the DIRS options for sequential construction
833 #---------------------------------------------------------
839 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
840 $(RecursiveTargets)::
841 $(Verb) for dir in $(DIRS); do \
842 if ([ ! -f $$dir/Makefile ] || \
843 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
845 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
847 ($(MAKE) -C $$dir $@ ) || exit 1; \
850 $(RecursiveTargets)::
851 $(Verb) for dir in $(DIRS); do \
852 ($(MAKE) -C $$dir $@ ) || exit 1; \
858 #---------------------------------------------------------
859 # Handle the EXPERIMENTAL_DIRS options ensuring success
860 # after each directory is built.
861 #---------------------------------------------------------
862 ifdef EXPERIMENTAL_DIRS
863 $(RecursiveTargets)::
864 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
865 if ([ ! -f $$dir/Makefile ] || \
866 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
868 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
870 ($(MAKE) -C $$dir $@ ) || exit 0; \
874 #-----------------------------------------------------------
875 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
876 #-----------------------------------------------------------
877 ifdef OPTIONAL_PARALLEL_DIRS
878 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
881 #-----------------------------------------------------------
882 # Handle the PARALLEL_DIRS options for parallel construction
883 #-----------------------------------------------------------
886 SubDirs += $(PARALLEL_DIRS)
888 # Unfortunately, this list must be maintained if new recursive targets are added
889 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
890 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
891 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
892 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
893 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
894 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
895 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
897 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
901 SD=$(PROJ_SRC_DIR)/$(@D); \
903 if [ ! -f $$SD/Makefile ]; then \
905 DD=$(notdir $(@D)); \
907 if ([ ! -f $$DD/Makefile ] || \
908 command test $$DD/Makefile -ot \
909 $$SD/Makefile ); then \
911 $(CP) $$SD/Makefile $$DD/Makefile; \
913 $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
916 #---------------------------------------------------------
917 # Handle the OPTIONAL_DIRS options for directores that may
919 #---------------------------------------------------------
922 SubDirs += $(OPTIONAL_DIRS)
924 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
925 $(RecursiveTargets)::
926 $(Verb) for dir in $(OPTIONAL_DIRS); do \
927 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
928 if ([ ! -f $$dir/Makefile ] || \
929 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
931 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
933 ($(MAKE) -C$$dir $@ ) || exit 1; \
937 $(RecursiveTargets)::
938 $(Verb) for dir in $(OPTIONAL_DIRS); do \
939 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
940 ($(MAKE) -C$$dir $@ ) || exit 1; \
946 #---------------------------------------------------------
947 # Handle the CONFIG_FILES options
948 #---------------------------------------------------------
953 $(Echo) Install circumvented with NO_INSTALL
955 $(Echo) UnInstall circumvented with NO_INSTALL
957 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
958 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
959 $(Verb)for file in $(CONFIG_FILES); do \
960 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
961 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
962 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
963 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
965 $(ECHO) Error: cannot find config file $${file}. ; \
970 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
971 $(Verb)for file in $(CONFIG_FILES); do \
972 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
978 ###############################################################################
979 # Set up variables for building libraries
980 ###############################################################################
982 #---------------------------------------------------------
983 # Define various command line options pertaining to the
984 # libraries needed when linking. There are "Proj" libs
985 # (defined by the user's project) and "LLVM" libs (defined
986 # by the LLVM project).
987 #---------------------------------------------------------
990 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
991 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
992 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
993 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
997 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
998 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
999 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1000 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1003 # Loadable module for Win32 requires all symbols resolved for linking.
1004 # Then all symbols in LLVM.dll will be available.
1005 ifeq ($(ENABLE_SHARED),1)
1006 ifdef LOADABLE_MODULE
1007 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1008 LINK_COMPONENTS += all
1013 ifndef IS_CLEANING_TARGET
1014 ifdef LINK_COMPONENTS
1016 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
1017 # clean in tools, then do a make in tools (instead of at the top level).
1019 @echo "*** llvm-config doesn't exist - rebuilding it."
1020 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1022 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1024 ifeq ($(ENABLE_SHARED), 1)
1025 # We can take the "auto-import" feature to get rid of using dllimport.
1026 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1027 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1030 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1031 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1034 ifndef NO_LLVM_CONFIG
1035 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1036 ifeq ($(LLVMConfigLibs),Error)
1037 $(error llvm-config --libs failed)
1039 LLVMLibsOptions += $(LLVMConfigLibs)
1040 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1041 ifeq ($(LLVMConfigLibfiles),Error)
1042 $(error llvm-config --libfiles failed)
1044 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1051 # Set up the library exports file.
1052 ifdef EXPORTED_SYMBOL_FILE
1054 # First, set up the native export file, which may differ from the source
1057 ifeq ($(HOST_OS),Darwin)
1058 # Darwin convention prefixes symbols with underscores.
1059 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1060 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1061 $(Verb) sed -e 's/^/_/' < $< > $@
1063 -$(Verb) $(RM) -f $(NativeExportsFile)
1065 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1066 # Gold and BFD ld require a version script rather than a plain list.
1067 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1068 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1069 $(Verb) echo "{" > $@
1070 $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || :
1071 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
1072 ifneq ($(HOST_OS),OpenBSD)
1073 $(Verb) echo " local: *;" >> $@
1075 $(Verb) echo "};" >> $@
1077 -$(Verb) $(RM) -f $(NativeExportsFile)
1079 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1080 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1081 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1082 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1083 $(Echo) Generating $(notdir $@)
1084 $(Verb) $(ECHO) "EXPORTS" > $@
1085 $(Verb) $(CAT) $< >> $@
1087 -$(Verb) $(RM) -f $(NativeExportsFile)
1089 # Default behavior: just use the exports file verbatim.
1090 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1095 # Now add the linker command-line options to use the native export file.
1098 ifeq ($(HOST_OS),Darwin)
1099 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1102 # gold, bfd ld, etc.
1103 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1104 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1108 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1109 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1110 SharedLinkOptions += $(NativeExportsFile)
1115 ###############################################################################
1116 # Library Build Rules: Four ways to build a library
1117 ###############################################################################
1119 # if we're building a library ...
1122 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1123 LIBRARYNAME := $(strip $(LIBRARYNAME))
1124 ifdef LOADABLE_MODULE
1125 BaseLibName.A := $(LIBRARYNAME).a
1126 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1128 BaseLibName.A := lib$(LIBRARYNAME).a
1129 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1131 LibName.A := $(LibDir)/$(BaseLibName.A)
1132 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1133 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1135 #---------------------------------------------------------
1136 # Shared Library Targets:
1137 # If the user asked for a shared library to be built
1138 # with the SHARED_LIBRARY variable, then we provide
1139 # targets for building them.
1140 #---------------------------------------------------------
1141 ifdef SHARED_LIBRARY
1143 all-local:: $(LibName.SO)
1145 ifdef EXPORTED_SYMBOL_FILE
1146 $(LibName.SO): $(NativeExportsFile)
1149 ifdef LINK_LIBS_IN_SHARED
1150 ifdef LOADABLE_MODULE
1151 SharedLibKindMessage := "Loadable Module"
1152 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1154 SharedLibKindMessage := "Shared Library"
1156 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1157 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1159 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1160 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1162 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1163 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1164 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1168 ifneq ($(strip $(LibName.SO)),)
1169 -$(Verb) $(RM) -f $(LibName.SO)
1174 $(Echo) Install circumvented with NO_INSTALL
1176 $(Echo) Uninstall circumvented with NO_INSTALL
1179 # Win32.DLL prefers to be located on the "PATH" of binaries.
1180 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1181 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1183 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1185 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1187 install-local:: $(DestSharedLib)
1189 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1190 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1191 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1194 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1195 -$(Verb) $(RM) -f $(DestSharedLib)
1199 #---------------------------------------------------------
1201 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1202 # building an archive.
1203 #---------------------------------------------------------
1204 ifndef NO_BUILD_ARCHIVE
1205 ifndef BUILD_ARCHIVE
1206 ifndef LOADABLE_MODULE
1212 #---------------------------------------------------------
1213 # Archive Library Targets:
1214 # If the user wanted a regular archive library built,
1215 # then we provide targets for building them.
1216 #---------------------------------------------------------
1219 all-local:: $(LibName.A)
1221 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1222 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1223 -$(Verb) $(RM) -f $@
1224 $(Verb) $(Archive) $@ $(ObjectsO)
1225 $(Verb) $(Ranlib) $@
1228 ifneq ($(strip $(LibName.A)),)
1229 -$(Verb) $(RM) -f $(LibName.A)
1234 $(Echo) Install circumvented with NO_INSTALL
1236 $(Echo) Uninstall circumvented with NO_INSTALL
1238 ifdef NO_INSTALL_ARCHIVES
1240 $(Echo) Install circumvented with NO_INSTALL
1242 $(Echo) Uninstall circumvented with NO_INSTALL
1244 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1246 install-local:: $(DestArchiveLib)
1248 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1249 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1250 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1251 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1254 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1255 -$(Verb) $(RM) -f $(DestArchiveLib)
1263 ###############################################################################
1264 # Tool Build Rules: Build executable tool based on TOOLNAME option
1265 ###############################################################################
1269 #---------------------------------------------------------
1270 # Set up variables for building a tool.
1271 #---------------------------------------------------------
1272 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1274 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1276 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1279 # TOOLALIAS is a name to symlink (or copy) the tool to.
1282 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1284 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1288 #---------------------------------------------------------
1290 #---------------------------------------------------------
1292 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1293 # not exporting all of the weak symbols from the binary. This reduces dyld
1294 # startup time by 4x on darwin in some cases.
1295 ifdef TOOL_NO_EXPORTS
1296 ifeq ($(HOST_OS),Darwin)
1298 # Tiger tools don't support this.
1299 ifneq ($(DARWIN_MAJVERS),4)
1300 LD.Flags += -Wl,-exported_symbol,_main
1304 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1305 ifneq ($(ARCH), Mips)
1306 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1311 #---------------------------------------------------------
1312 # Tool Order File Support
1313 #---------------------------------------------------------
1315 ifeq ($(HOST_OS),Darwin)
1316 ifdef TOOL_ORDER_FILE
1318 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1323 #---------------------------------------------------------
1324 # Tool Version Info Support
1325 #---------------------------------------------------------
1327 ifeq ($(HOST_OS),Darwin)
1328 ifdef TOOL_INFO_PLIST
1330 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1332 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1334 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1335 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1336 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1337 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1338 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1339 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1345 #---------------------------------------------------------
1346 # Provide targets for building the tools
1347 #---------------------------------------------------------
1348 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1351 ifneq ($(strip $(ToolBuildPath)),)
1352 -$(Verb) $(RM) -f $(ToolBuildPath)
1354 ifneq ($(strip $(ToolAliasBuildPath)),)
1355 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1359 $(ToolBuildPath): $(ExmplDir)/.dir
1361 $(ToolBuildPath): $(ToolDir)/.dir
1364 ifdef CODESIGN_TOOLS
1365 TOOL_CODESIGN_IDENTITY ?= -
1367 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1368 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1369 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1370 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1371 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1373 $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1374 $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1376 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1377 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1378 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1379 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1380 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1384 ifneq ($(strip $(ToolAliasBuildPath)),)
1385 $(ToolAliasBuildPath): $(ToolBuildPath)
1386 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1387 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1388 $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1389 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1395 $(Echo) Install circumvented with NO_INSTALL
1397 $(Echo) Uninstall circumvented with NO_INSTALL
1401 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1403 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1405 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1407 install-local:: $(DestTool)
1409 $(DestTool): $(ToolBuildPath)
1410 $(Echo) Installing $(BuildMode) $(DestTool)
1411 $(Verb) $(MKDIR) $(ToolBinDir)
1412 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1415 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1416 -$(Verb) $(RM) -f $(DestTool)
1418 # TOOLALIAS install.
1420 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1422 install-local:: $(DestToolAlias)
1424 $(DestToolAlias): $(DestTool)
1425 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1426 $(Verb) $(RM) -f $(DestToolAlias)
1427 $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1430 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1431 -$(Verb) $(RM) -f $(DestToolAlias)
1437 ###############################################################################
1438 # Object Build Rules: Build object files based on sources
1439 ###############################################################################
1441 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1442 ifeq ($(HOST_OS),HP-UX)
1443 DISABLE_AUTO_DEPENDENCIES=1
1446 COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1448 # Provide rule sets for when dependency generation is enabled
1449 ifndef DISABLE_AUTO_DEPENDENCIES
1451 #---------------------------------------------------------
1452 # Create .o files in the ObjDir directory from the .cpp and .c files...
1453 #---------------------------------------------------------
1455 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1456 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1458 # If the build succeeded, move the dependency file over, otherwise
1460 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1461 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1463 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1464 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1465 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1468 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1469 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1470 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1473 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1474 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1475 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1478 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1479 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1480 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1483 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1484 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1485 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1488 # Provide alternate rule sets if dependencies are disabled
1491 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1492 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1493 $(Compile.CXX) $< -o $@
1495 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1496 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1497 $(Compile.CXX) $< -o $@
1499 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1500 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1501 $(Compile.CXX) $< -o $@
1503 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1504 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1505 $(Compile.C) $< -o $@
1507 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1508 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1509 $(Compile.C) $< -o $@
1513 ## Rules for building preprocessed (.i/.ii) outputs.
1514 $(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1515 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1516 $(Verb) $(Preprocess.CXX) $< -o $@
1518 $(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1519 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1520 $(Verb) $(Preprocess.CXX) $< -o $@
1522 $(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1523 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1524 $(Verb) $(Preprocess.CXX) $< -o $@
1526 $(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1527 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1528 $(Verb) $(Preprocess.C) $< -o $@
1530 $(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1531 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1532 $(Verb) $(Preprocess.C) $< -o $@
1535 $(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1536 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1537 $(Compile.CXX) $< -o $@ -S
1539 $(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1540 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1541 $(Compile.CXX) $< -o $@ -S
1543 $(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1544 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1545 $(Compile.CXX) $< -o $@ -S
1547 $(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1548 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1549 $(Compile.C) $< -o $@ -S
1551 $(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1552 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1553 $(Compile.C) $< -o $@ -S
1555 ###############################################################################
1556 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1557 ###############################################################################
1560 TABLEGEN_INC_FILES_COMMON = 1
1563 ifdef TABLEGEN_INC_FILES_COMMON
1565 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1566 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1567 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1569 # INCFiles rule: All of the tblgen generated files are emitted to
1570 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1571 # us to only "touch" the real file if the contents of it change. IOW, if
1572 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1573 # dependencies of the .inc files are, unless the contents of the .inc file
1575 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1576 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1578 endif # TABLEGEN_INC_FILES_COMMON
1582 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1583 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1584 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1585 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1586 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1587 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1588 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1590 # All .inc.tmp files depend on the .td files.
1591 $(INCTMPFiles) : $(TDFiles)
1593 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1594 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1595 $(Echo) "Building $(<F) register info implementation with tblgen"
1596 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1598 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1599 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1600 $(Echo) "Building $(<F) instruction information with tblgen"
1601 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1603 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1604 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1605 $(Echo) "Building $(<F) assembly writer with tblgen"
1606 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1608 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1609 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1610 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1611 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1613 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1614 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1615 $(Echo) "Building $(<F) assembly matcher with tblgen"
1616 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1618 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1619 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1620 $(Echo) "Building $(<F) MC code emitter with tblgen"
1621 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1623 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1624 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1625 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1626 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1628 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1629 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1630 $(Echo) "Building $(<F) code emitter with tblgen"
1631 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1633 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1634 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1635 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1636 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1638 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1639 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1640 $(Echo) "Building $(<F) disassembly tables with tblgen"
1641 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1643 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1644 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1645 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1646 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1648 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1649 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1650 $(Echo) "Building $(<F) subtarget information with tblgen"
1651 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1653 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1654 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1655 $(Echo) "Building $(<F) calling convention information with tblgen"
1656 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1658 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1659 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1660 $(Echo) "Building $(<F) intrinsics information with tblgen"
1661 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1663 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1664 $(Echo) "Building $(<F) decoder tables with tblgen"
1665 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1667 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1668 $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1669 $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1672 -$(Verb) $(RM) -f $(INCFiles)
1676 ###############################################################################
1677 # OTHER RULES: Other rules needed
1678 ###############################################################################
1680 # To create postscript files from dot files...
1681 ifneq ($(DOT),false)
1683 $(DOT) -Tps < $< > $@
1686 $(Echo) "Cannot build $@: The program dot is not installed"
1689 # This rules ensures that header files that are removed still have a rule for
1690 # which they can be "generated." This allows make to ignore them and
1691 # reproduce the dependency lists.
1695 # Define clean-local to clean the current directory. Note that this uses a
1696 # very conservative approach ensuring that empty variables do not cause
1697 # errors or disastrous removal.
1699 ifneq ($(strip $(ObjRootDir)),)
1700 -$(Verb) $(RM) -rf $(ObjRootDir)
1702 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1703 -$(Verb) $(RM) -f *$(SHLIBEXT)
1707 -$(Verb) $(RM) -rf Debug Release Profile
1710 ###############################################################################
1711 # DEPENDENCIES: Include the dependency files if we should
1712 ###############################################################################
1713 ifndef DISABLE_AUTO_DEPENDENCIES
1715 # If its not one of the cleaning targets
1716 ifndef IS_CLEANING_TARGET
1718 # Get the list of dependency files
1719 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1720 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1722 -include $(DependFiles) ""
1728 ###############################################################################
1729 # CHECK: Running the test suite
1730 ###############################################################################
1733 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1734 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1735 $(EchoCmd) Running test suite ; \
1736 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1737 TESTSUITE=$(TESTSUITE) ; \
1739 $(EchoCmd) No Makefile in test directory ; \
1742 $(EchoCmd) No test directory ; \
1745 # An alias dating from when both lit and DejaGNU test runners were used.
1749 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1750 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1751 $(EchoCmd) Running test suite ; \
1752 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1754 $(EchoCmd) No Makefile in test directory ; \
1757 $(EchoCmd) No test directory ; \
1760 ###############################################################################
1761 # UNITTESTS: Running the unittests test suite
1762 ###############################################################################
1765 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1766 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1767 $(EchoCmd) Running unittests test suite ; \
1768 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1770 $(EchoCmd) No Makefile in unittests directory ; \
1773 $(EchoCmd) No unittests directory ; \
1776 ###############################################################################
1777 # DISTRIBUTION: Handle construction of a distribution tarball
1778 ###############################################################################
1780 #------------------------------------------------------------------------
1781 # Define distribution related variables
1782 #------------------------------------------------------------------------
1783 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1784 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1785 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1786 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1787 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1788 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1789 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1790 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1791 Makefile.config.in configure autoconf
1792 DistOther := $(notdir $(wildcard \
1793 $(PROJ_SRC_DIR)/*.h \
1794 $(PROJ_SRC_DIR)/*.td \
1795 $(PROJ_SRC_DIR)/*.def \
1796 $(PROJ_SRC_DIR)/*.ll \
1797 $(PROJ_SRC_DIR)/*.in))
1798 DistSubDirs := $(SubDirs)
1799 DistSources = $(Sources) $(EXTRA_DIST)
1800 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1802 #------------------------------------------------------------------------
1803 # We MUST build distribution with OBJ_DIR != SRC_DIR
1804 #------------------------------------------------------------------------
1805 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1806 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1807 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1811 #------------------------------------------------------------------------
1812 # Prevent attempt to run dist targets from anywhere but the top level
1813 #------------------------------------------------------------------------
1815 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1816 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1819 #------------------------------------------------------------------------
1820 # Provide the top level targets
1821 #------------------------------------------------------------------------
1823 dist-gzip:: $(DistTarGZip)
1825 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1826 $(Echo) Packing gzipped distribution tar file.
1827 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1828 $(GZIP) -c > "$(DistTarGZip)"
1830 dist-bzip2:: $(DistTarBZ2)
1832 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1833 $(Echo) Packing bzipped distribution tar file.
1834 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1835 $(BZIP2) -c >$(DistTarBZ2)
1837 dist-zip:: $(DistZip)
1839 $(DistZip) : $(TopDistDir)/.makedistdir
1840 $(Echo) Packing zipped distribution file.
1841 $(Verb) rm -f $(DistZip)
1842 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1844 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1845 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1847 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1849 dist-check:: $(DistTarGZip)
1850 $(Echo) Checking distribution tar file.
1851 $(Verb) if test -d $(DistCheckDir) ; then \
1852 $(RM) -rf $(DistCheckDir) ; \
1854 $(Verb) $(MKDIR) $(DistCheckDir)
1855 $(Verb) cd $(DistCheckDir) && \
1856 $(MKDIR) $(DistCheckDir)/build && \
1857 $(MKDIR) $(DistCheckDir)/install && \
1858 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1860 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1861 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1864 $(MAKE) unittests && \
1865 $(MAKE) install && \
1866 $(MAKE) uninstall && \
1867 $(MAKE) dist-clean && \
1868 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1871 $(Echo) Cleaning distribution files
1872 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1877 #------------------------------------------------------------------------
1878 # Provide the recursive distdir target for building the distribution directory
1879 #------------------------------------------------------------------------
1880 distdir: $(DistDir)/.makedistdir
1881 $(DistDir)/.makedistdir: $(DistSources)
1882 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1883 if test -d "$(DistDir)" ; then \
1884 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1887 $(EchoCmd) Removing old $(DistDir) ; \
1888 $(RM) -rf $(DistDir); \
1889 $(EchoCmd) Making 'all' to verify build ; \
1890 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1892 $(Echo) Building Distribution Directory $(DistDir)
1893 $(Verb) $(MKDIR) $(DistDir)
1894 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1895 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1896 for file in $(DistFiles) ; do \
1898 $(PROJ_SRC_DIR)/*) \
1899 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1901 $(PROJ_SRC_ROOT)/*) \
1902 file=`echo "$$file" | \
1903 sed "s#^$$srcrootstrip/##"` \
1906 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1907 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1908 from_dir="$(PROJ_SRC_DIR)" ; \
1909 elif test -f "$$file" || test -d "$$file" ; then \
1912 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1913 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1914 to_dir="$(DistDir)/$$dir"; \
1915 $(MKDIR) "$$to_dir" ; \
1917 to_dir="$(DistDir)"; \
1919 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1920 if test -n "$$mid_dir" ; then \
1921 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1923 if test -d "$$from_dir/$$file"; then \
1924 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1925 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1926 cd $(PROJ_SRC_DIR) ; \
1927 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1928 ( cd $$to_dir ; $(TAR) xf - ) ; \
1929 cd $(PROJ_OBJ_DIR) ; \
1932 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1933 ( cd $$to_dir ; $(TAR) xf - ) ; \
1934 cd $(PROJ_OBJ_DIR) ; \
1936 elif test -f "$$from_dir/$$file" ; then \
1937 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1938 elif test -L "$$from_dir/$$file" ; then \
1939 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1940 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1941 $(EchoCmd) "===== WARNING: Distribution Source " \
1942 "$$from_dir/$$file Not Found!" ; \
1943 elif test "$(Verb)" != '@' ; then \
1944 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1947 $(Verb) for subdir in $(DistSubDirs) ; do \
1948 if test "$$subdir" \!= "." ; then \
1949 new_distdir="$(DistDir)/$$subdir" ; \
1950 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1951 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1952 DistDir="$$new_distdir" distdir ) || exit 1; \
1955 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1956 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1957 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1958 -name .svn \) -print` ;\
1959 $(MAKE) dist-hook ; \
1960 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1961 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1962 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1963 -o ! -type d ! -perm -444 -exec \
1964 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1965 || chmod -R a+r $(DistDir) ; \
1968 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1974 ###############################################################################
1975 # TOP LEVEL - targets only to apply at the top level directory
1976 ###############################################################################
1980 #------------------------------------------------------------------------
1981 # Install support for the project's include files:
1982 #------------------------------------------------------------------------
1985 $(Echo) Install circumvented with NO_INSTALL
1987 $(Echo) Uninstall circumvented with NO_INSTALL
1990 $(Echo) Installing include files
1991 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
1992 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1993 cd $(PROJ_SRC_ROOT)/include && \
1994 for hdr in `find . -type f \
1995 '(' -name LICENSE.TXT \
2000 ')' -print | grep -v CVS | \
2001 grep -v .svn` ; do \
2002 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2003 if test \! -d "$$instdir" ; then \
2004 $(EchoCmd) Making install directory $$instdir ; \
2005 $(MKDIR) $$instdir ;\
2007 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2010 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2011 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2012 cd $(PROJ_OBJ_ROOT)/include && \
2013 for hdr in `find . -type f \
2014 '(' -name LICENSE.TXT \
2019 ')' -print | grep -v CVS | \
2020 grep -v .svn` ; do \
2021 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2022 if test \! -d "$$instdir" ; then \
2023 $(EchoCmd) Making install directory $$instdir ; \
2024 $(MKDIR) $$instdir ;\
2026 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2032 $(Echo) Uninstalling include files
2033 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2034 cd $(PROJ_SRC_ROOT)/include && \
2035 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2036 '!' '(' -name '*~' -o -name '.#*' \
2037 -o -name '*.in' ')' -print ')' | \
2038 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2039 cd $(PROJ_SRC_ROOT)/include && \
2040 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2041 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2047 @echo searching for overlength lines in files: $(Sources)
2050 egrep -n '.{81}' $(Sources) /dev/null
2053 @echo searching for tabs in files: $(Sources)
2056 egrep -n ' ' $(Sources) /dev/null
2059 @ls -l $(LibDir) | awk '\
2060 BEGIN { sum = 0; } \
2062 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2063 @ls -l $(ToolDir) | awk '\
2064 BEGIN { sum = 0; } \
2066 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2067 #------------------------------------------------------------------------
2068 # Print out the directories used for building
2069 #------------------------------------------------------------------------
2071 $(Echo) "BuildMode : " '$(BuildMode)'
2072 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2073 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2074 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2075 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2076 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2077 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2078 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2079 $(Echo) "PROJ_internal_prefix : " '$(PROJ_internal_prefix)'
2080 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2081 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2082 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2083 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2084 $(Echo) "UserTargets : " '$(UserTargets)'
2085 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2086 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2087 $(Echo) "ObjDir : " '$(ObjDir)'
2088 $(Echo) "LibDir : " '$(LibDir)'
2089 $(Echo) "ToolDir : " '$(ToolDir)'
2090 $(Echo) "ExmplDir : " '$(ExmplDir)'
2091 $(Echo) "Sources : " '$(Sources)'
2092 $(Echo) "TDFiles : " '$(TDFiles)'
2093 $(Echo) "INCFiles : " '$(INCFiles)'
2094 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2095 $(Echo) "PreConditions: " '$(PreConditions)'
2096 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2097 $(Echo) "Compile.C : " '$(Compile.C)'
2098 $(Echo) "Archive : " '$(Archive)'
2099 $(Echo) "YaccFiles : " '$(YaccFiles)'
2100 $(Echo) "LexFiles : " '$(LexFiles)'
2101 $(Echo) "Module : " '$(Module)'
2102 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2103 $(Echo) "SubDirs : " '$(SubDirs)'
2104 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2105 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2110 # General debugging rule, use 'make dbg-print-XXX' to print the
2111 # definition, value and origin of XXX.
2113 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))