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 LLVMBuildCMakeFrag := $(PROJ_OBJ_ROOT)/LLVMBuild.cmake
82 LLVMBuildCMakeExportsFrag := $(PROJ_OBJ_ROOT)/cmake/modules/LLVMBuildExports.cmake
83 LLVMBuildMakeFrags := \
84 $(LLVMBuildMakeFrag) \
85 $(LLVMBuildCMakeFrag) \
86 $(LLVMBuildCMakeExportsFrag)
87 LLVMConfigLibraryDependenciesInc := \
88 $(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc
90 # This is for temporary backwards compatibility.
91 ifndef TARGET_NATIVE_ARCH
92 TARGET_NATIVE_ARCH := $(ARCH)
95 # The rule to create the LLVMBuild Makefile fragment as well as the llvm-config
98 # Note that this target gets its real dependencies generated for us by
101 # We include a dependency on this Makefile to ensure that changes to the
102 # generation command get picked up.
103 $(LLVMBuildMakeFrags): $(PROJ_SRC_ROOT)/Makefile.rules \
104 $(PROJ_OBJ_ROOT)/Makefile.config
105 $(Echo) Constructing LLVMBuild project information.
106 $(Verb)$(PYTHON) $(LLVMBuildTool) \
107 --native-target "$(TARGET_NATIVE_ARCH)" \
108 --enable-targets "$(TARGETS_TO_BUILD)" \
109 --enable-optional-components "$(OPTIONAL_COMPONENTS)" \
110 --write-library-table $(LLVMConfigLibraryDependenciesInc) \
111 --write-make-fragment $(LLVMBuildMakeFrag) \
112 --write-cmake-fragment $(LLVMBuildCMakeFrag) \
113 --write-cmake-exports-fragment $(LLVMBuildCMakeExportsFrag)
115 # For completeness, let Make know how the extra files are generated.
116 $(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrags)
118 # Include the generated Makefile fragment.
120 # We currently only include the dependencies for the fragment itself if we are
121 # at the top-level. Otherwise, recursive invocations would ends up doing
122 # substantially more redundant stat'ing.
124 # This means that we won't properly regenerate things for developers used to
125 # building from a subdirectory, but that is always somewhat unreliable.
127 LLVMBUILD_INCLUDE_DEPENDENCIES := 1
129 # Clean the generated makefile fragment at the top-level.
131 -$(Verb) $(RM) -f $(LLVMBuildMakeFrags)
133 -include $(LLVMBuildMakeFrag)
135 ################################################################################
136 # PRECONDITIONS: that which must be built/checked first
137 ################################################################################
139 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
140 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
141 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
142 ConfigureScript := $(PROJ_SRC_ROOT)/configure
143 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
144 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
145 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
146 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
147 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
148 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
149 ifneq ($(MakefileCommonIn),)
150 PreConditions += $(MakefileCommon)
153 ifneq ($(MakefileConfigIn),)
154 PreConditions += $(MakefileConfig)
157 preconditions: $(PreConditions)
159 #------------------------------------------------------------------------
160 # Make sure the BUILT_SOURCES are built first
161 #------------------------------------------------------------------------
162 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
165 ifneq ($(strip $(BUILT_SOURCES)),)
166 -$(Verb) $(RM) -f $(BUILT_SOURCES)
169 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
171 $(Verb) if test -x config.status ; then \
172 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
173 $(MKDIR) .spotless.save ; \
174 $(MV) config.status .spotless.save ; \
175 $(MV) mklib .spotless.save ; \
176 $(MV) projects .spotless.save ; \
178 $(MV) .spotless.save/config.status . ; \
179 $(MV) .spotless.save/mklib . ; \
180 $(MV) .spotless.save/projects . ; \
181 $(RM) -rf .spotless.save ; \
182 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
183 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
184 $(ConfigStatusScript) ; \
186 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
190 $(EchoCmd) "spotless target not supported for objdir == srcdir"
193 $(BUILT_SOURCES) : $(ObjMakefiles)
195 #------------------------------------------------------------------------
196 # Make sure we're not using a stale configuration
197 #------------------------------------------------------------------------
199 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
200 $(Verb) cd $(PROJ_OBJ_ROOT) && \
201 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
202 $(ConfigStatusScript)
204 .PRECIOUS: $(ConfigStatusScript)
205 $(ConfigStatusScript): $(ConfigureScript)
206 $(Echo) Reconfiguring with $<
207 $(Verb) cd $(PROJ_OBJ_ROOT) && \
208 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
209 $(ConfigStatusScript)
211 #------------------------------------------------------------------------
212 # Make sure the configuration makefile is up to date
213 #------------------------------------------------------------------------
214 ifneq ($(MakefileConfigIn),)
215 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
216 $(Echo) Regenerating $@
217 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
220 ifneq ($(MakefileCommonIn),)
221 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
222 $(Echo) Regenerating $@
223 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
226 #------------------------------------------------------------------------
227 # If the Makefile in the source tree has been updated, copy it over into the
228 # build tree. But, only do this if the source and object makefiles differ
229 #------------------------------------------------------------------------
231 PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
234 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
236 Makefile: $(PROJ_MAKEFILE) $(ExtraMakefiles)
237 $(Echo) "Updating Makefile"
238 $(Verb) $(MKDIR) $(@D)
239 $(Verb) $(CP) -f $< $@
241 # Copy the Makefile.* files unless we're in the root directory which avoids
242 # the copying of Makefile.config.in or other things that should be explicitly
244 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
246 *Makefile.rules) ;; \
248 *) $(EchoCmd) "Updating $(@F)" ; \
255 #------------------------------------------------------------------------
256 # Set up the basic dependencies
257 #------------------------------------------------------------------------
258 $(UserTargets):: $(PreConditions)
262 clean-all:: clean-local clean-all-local
263 install:: install-local
264 uninstall:: uninstall-local
265 install-local:: all-local
266 install-bytecode:: install-bytecode-local
268 ###############################################################################
269 # VARIABLES: Set up various variables based on configuration data
270 ###############################################################################
272 # Variable for if this make is for a "cleaning" target
273 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
277 #--------------------------------------------------------------------
278 # Variables derived from configuration we are building
279 #--------------------------------------------------------------------
282 ifeq ($(ENABLE_OPTIMIZED),1)
284 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
285 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
286 OmitFramePointer := -fomit-frame-pointer
289 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
290 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
291 LD.Flags += $(OPTIMIZE_OPTION)
293 BuildMode := $(BuildMode)+Debug
299 ifdef NO_DEBUG_SYMBOLS
300 BuildMode := Unoptimized
306 ifeq ($(ENABLE_SPLIT_DWARF), 1)
307 CXX.Flags += -gsplit-dwarf
308 C.Flags += -gsplit-dwarf
317 ifeq ($(ENABLE_LIBCPP),1)
318 CXX.Flags += -stdlib=libc++
319 LD.Flags += -stdlib=libc++
322 ifeq ($(ENABLE_CXX11),1)
323 CXX.Flags += -std=c++11
326 ifeq ($(ENABLE_WERROR),1)
331 ifeq ($(ENABLE_PROFILING),1)
332 BuildMode := $(BuildMode)+Profile
333 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
334 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
335 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg
339 ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
340 CXX.Flags += -fvisibility-inlines-hidden
343 ifdef ENABLE_EXPENSIVE_CHECKS
344 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
345 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
349 # IF REQUIRES_EH=1 is specified then don't disable exceptions
351 CXX.Flags += -fno-exceptions
353 # If the library requires EH, it also requires RTTI.
357 ifdef REQUIRES_FRAME_POINTER
358 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
359 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
360 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
363 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
364 ifneq ($(REQUIRES_RTTI), 1)
365 CXX.Flags += -fno-rtti
368 ifeq ($(ENABLE_COVERAGE),1)
369 BuildMode := $(BuildMode)+Coverage
370 CXX.Flags += -ftest-coverage -fprofile-arcs
371 C.Flags += -ftest-coverage -fprofile-arcs
374 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
375 # then disable assertions by defining the appropriate preprocessor symbols.
376 ifeq ($(DISABLE_ASSERTIONS),1)
377 CPP.Defines += -DNDEBUG
379 BuildMode := $(BuildMode)+Asserts
380 CPP.Defines += -D_DEBUG
383 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
384 # configured), then enable expensive checks by defining the
385 # appropriate preprocessor symbols.
386 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
387 BuildMode := $(BuildMode)+Checks
388 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
391 # LOADABLE_MODULE implies several other things so we force them to be
393 ifdef LOADABLE_MODULE
395 LINK_LIBS_IN_SHARED := 1
403 ifeq ($(ENABLE_PIC),1)
404 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
405 # Nothing. Win32 defaults to PIC and warns when given -fPIC
407 ifeq ($(HOST_OS),Darwin)
408 # Common symbols not allowed in dylib files
409 CXX.Flags += -fno-common
410 C.Flags += -fno-common
412 # Linux and others; pass -fPIC
418 ifeq ($(HOST_OS),Darwin)
419 CXX.Flags += -mdynamic-no-pic
420 C.Flags += -mdynamic-no-pic
424 # Support makefile variable to disable any kind of timestamp/non-deterministic
425 # info from being used in the build.
426 ifeq ($(ENABLE_TIMESTAMPS),1)
427 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
429 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
432 ifeq ($(HOST_OS),MingW)
434 CPP.Defines += -D__NO_CTYPE_INLINE
435 ifeq ($(LLVM_CROSS_COMPILING),1)
436 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
438 LD.Flags += -Wl,--allow-multiple-definition
443 CXX.Flags += -Woverloaded-virtual
444 CPP.BaseFlags += $(CPP.Defines)
447 # Make Floating point IEEE compliant on Alpha.
450 CPP.BaseFlags += -mieee
451 ifeq ($(ENABLE_PIC),0)
453 CPP.BaseFlags += -fPIC
456 LD.Flags += -Wl,--no-relax
459 # GNU ld/PECOFF accepts but ignores them below;
463 # FIXME: autoconf should be aware of them.
464 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
465 HAVE_LINK_VERSION_SCRIPT := 0
467 RDYNAMIC := -Wl,--export-all-symbols
470 #--------------------------------------------------------------------
471 # Directory locations
472 #--------------------------------------------------------------------
474 ifeq ($(LLVM_CROSS_COMPILING),1)
475 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
478 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
479 ObjDir := $(ObjRootDir)
480 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
481 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
482 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
483 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
484 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
485 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
487 #--------------------------------------------------------------------
488 # Locations of shared libraries
489 #--------------------------------------------------------------------
492 SharedLibDir := $(LibDir)
493 LLVMSharedLibDir := $(LLVMLibDir)
495 # Win32.DLL prefers to be located on the "PATH" of binaries.
496 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
497 SharedLibDir := $(ToolDir)
498 LLVMSharedLibDir := $(LLVMToolDir)
500 ifeq ($(HOST_OS),Cygwin)
507 #--------------------------------------------------------------------
508 # Full Paths To Compiled Tools and Utilities
509 #--------------------------------------------------------------------
510 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
511 ifdef BUILD_DIRS_ONLY
512 EchoCmd := $(EchoCmd) "(build tools)":
517 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
520 ifeq ($(LLVM_CROSS_COMPILING),1)
521 LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
523 LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
526 ifeq ($(LLVM_CROSS_COMPILING),1)
527 LLVM_CONFIG := $(BuildLLVMToolDir)/llvm-config$(BUILD_EXEEXT)
529 LLVM_CONFIG := $(LLVMToolDir)/llvm-config$(EXEEXT)
532 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
535 LLI := $(LLVMToolDir)/lli$(EXEEXT)
538 LLC := $(LLVMToolDir)/llc$(EXEEXT)
541 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
544 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
547 LLVMLINK := $(LLVMToolDir)/llvm-link$(EXEEXT)
550 #--------------------------------------------------------------------
551 # Adjust to user's request
552 #--------------------------------------------------------------------
554 ifeq ($(HOST_OS),Darwin)
555 ifdef MACOSX_DEPLOYMENT_TARGET
556 DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
558 DARWIN_VERSION := `sw_vers -productVersion`
560 # Strip a number like 10.4.7 to 10.4
561 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/')
562 # Get "4" out of 10.4 for later pieces in the makefile.
563 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/')
565 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
566 SharedLinkOptions := -dynamiclib
567 ifdef DEPLOYMENT_TARGET
568 SharedLinkOptions += $(DEPLOYMENT_TARGET)
571 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
575 SharedLinkOptions=-shared
578 ifeq ($(TARGET_OS),Darwin)
579 ifdef DEPLOYMENT_TARGET
580 TargetCommonOpts += $(DEPLOYMENT_TARGET)
583 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
589 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
590 ifneq ($(HOST_OS),Darwin)
591 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
603 # Adjust settings for verbose mode
606 AR.Flags += >/dev/null 2>/dev/null
607 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
609 ConfigureScriptFLAGS :=
612 # By default, strip symbol information from executable
614 Strip := $(PLATFORMSTRIPOPTS)
615 StripWarnMsg := "(without symbols)"
616 Install.StripFlag += -s
619 # By default, strip dead symbols at link time
620 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
621 ifneq ($(HOST_OS),Darwin)
622 ifneq ($(HOST_ARCH),Mips)
623 CXX.Flags += -ffunction-sections -fdata-sections
628 ifeq ($(HOST_OS),Darwin)
629 LD.Flags += -Wl,-dead_strip
631 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
632 LD.Flags += -Wl,--gc-sections
637 # Adjust linker flags for building an executable
638 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
639 ifndef TOOL_NO_EXPORTS
640 LD.Flags += $(RDYNAMIC)
642 ifneq ($(HOST_OS), Darwin)
644 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
647 ifneq ($(DARWIN_MAJVERS),4)
648 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
651 TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
652 LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
658 #----------------------------------------------------------
659 # Options To Invoke Tools
660 #----------------------------------------------------------
662 ifdef EXTRA_LD_OPTIONS
663 LD.Flags += $(EXTRA_LD_OPTIONS)
667 CompileCommonOpts += -pedantic -Wno-long-long
669 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
670 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
671 $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
672 $(NO_MISSING_FIELD_INITIALIZERS)
673 # Enable cast-qual for C++; the workaround is to use const_cast.
674 CXX.Flags += -Wcast-qual
676 ifeq ($(HOST_OS),HP-UX)
677 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
680 # If we are building a universal binary on Mac OS/X, pass extra options. This
681 # is useful to people that want to link the LLVM libraries into their universal
684 # The following can be optionally specified:
685 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
686 # For Mac OS/X 10.4 Intel machines, the traditional one is:
687 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
688 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
689 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
692 ifndef UNIVERSAL_ARCH
693 UNIVERSAL_ARCH := i386 ppc
695 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
696 TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
697 ifdef UNIVERSAL_SDK_PATH
698 TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
701 # Building universal cannot compute dependencies automatically.
702 DISABLE_AUTO_DEPENDENCIES=1
704 ifeq ($(TARGET_OS),Darwin)
705 ifeq ($(ARCH),x86_64)
706 TargetCommonOpts = -m64
709 TargetCommonOpts = -m32
715 ifeq ($(HOST_OS),SunOS)
716 CPP.BaseFlags += -include llvm/Support/Solaris.h
719 ifeq ($(HOST_OS),AuroraUX)
720 CPP.BaseFlags += -include llvm/Support/Solaris.h
721 endif # !HOST_OS - AuroraUX.
723 # On Windows, SharedLibDir != LibDir. The order is important.
724 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
725 LD.Flags += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
727 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
730 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
731 # All -I flags should go here, so that they don't confuse llvm-config.
732 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
733 $(patsubst %,-I%/include,\
734 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
735 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
738 ifeq ($(INCLUDE_BUILD_DIR),1)
739 CPP.Flags += -I$(ObjDir)
742 # SHOW_DIAGNOSTICS support.
743 ifeq ($(SHOW_DIAGNOSTICS),1)
744 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
745 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
750 Compile.C = $(Compile.Wrapper) \
751 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
752 $(TargetCommonOpts) $(CompileCommonOpts) -c
753 Compile.CXX = $(Compile.Wrapper) \
754 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
755 $(TargetCommonOpts) $(CompileCommonOpts) -c
756 Preprocess.CXX= $(Compile.Wrapper) \
757 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
758 $(CompileCommonOpts) $(CXX.Flags) -E
759 Link = $(Compile.Wrapper) \
760 $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
761 $(TargetCommonOpts) $(Strip)
763 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
764 $(TargetCommonOpts) $(CompileCommonOpts) -E
766 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
767 ScriptInstall = $(INSTALL) -m 0755
768 DataInstall = $(INSTALL) -m 0644
770 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
771 # paths. In this case, the SYSPATH function (defined in
772 # Makefile.config) transforms Unix paths into Windows paths.
773 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
774 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
775 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
776 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
777 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
779 Archive = $(AR) $(AR.Flags)
788 #----------------------------------------------------------
789 # Get the list of source files and compute object file
791 #----------------------------------------------------------
794 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
795 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
797 Sources := $(SOURCES)
801 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
804 BaseNameSources := $(sort $(basename $(Sources)))
805 SourceDirs := $(sort $(dir $(Sources)))
807 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
808 ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
810 #----------------------------------------------------------
811 # For Mingw MSYS bash and Python/w32:
813 # $(ECHOPATH) prints DOSish pathstring.
814 # ex) $(ECHOPATH) /include/sys/types.h
815 # --> C:/mingw/include/sys/types.h
816 # built-in "echo" does not transform path to DOSish path.
818 # FIXME: It would not be needed when MSYS's python
820 #----------------------------------------------------------
822 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
823 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
825 ECHOPATH := $(Verb)$(ECHO)
828 ###############################################################################
829 # DIRECTORIES: Handle recursive descent of directory structure
830 ###############################################################################
832 #---------------------------------------------------------
833 # Provide rules to make install dirs. This must be early
834 # in the file so they get built before dependencies
835 #---------------------------------------------------------
837 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
840 # To create other directories, as needed, and timestamp their creation
842 $(Verb) $(MKDIR) $* > /dev/null
843 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
845 .PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
846 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
848 #---------------------------------------------------------
849 # Collect the object directories (as there may be more
850 # than one if the source code is spread across
852 #---------------------------------------------------------
854 OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
855 .PRECIOUS: $(OBJECT_DIRS)
857 #---------------------------------------------------------
858 # Handle the DIRS options for sequential construction
859 #---------------------------------------------------------
865 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
866 $(RecursiveTargets)::
867 $(Verb) for dir in $(DIRS); do \
868 if ([ ! -f $$dir/Makefile ] || \
869 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
871 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
873 ($(MAKE) -C $$dir $@ ) || exit 1; \
876 $(RecursiveTargets)::
877 $(Verb) for dir in $(DIRS); do \
878 ($(MAKE) -C $$dir $@ ) || exit 1; \
884 #---------------------------------------------------------
885 # Handle the EXPERIMENTAL_DIRS options ensuring success
886 # after each directory is built.
887 #---------------------------------------------------------
888 ifdef EXPERIMENTAL_DIRS
889 $(RecursiveTargets)::
890 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
891 if ([ ! -f $$dir/Makefile ] || \
892 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
894 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
896 ($(MAKE) -C $$dir $@ ) || exit 0; \
900 #-----------------------------------------------------------
901 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
902 #-----------------------------------------------------------
903 ifdef OPTIONAL_PARALLEL_DIRS
904 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
907 #-----------------------------------------------------------
908 # Handle the PARALLEL_DIRS options for parallel construction
909 #-----------------------------------------------------------
912 SubDirs += $(PARALLEL_DIRS)
914 # Unfortunately, this list must be maintained if new recursive targets are added
915 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
916 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
917 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
918 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
919 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
920 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
921 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
923 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
927 SD=$(PROJ_SRC_DIR)/$(@D); \
929 if [ ! -f $$SD/Makefile ]; then \
931 DD=$(notdir $(@D)); \
933 if ([ ! -f $$DD/Makefile ] || \
934 command test $$DD/Makefile -ot \
935 $$SD/Makefile ); then \
937 $(CP) $$SD/Makefile $$DD/Makefile; \
939 $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
942 #---------------------------------------------------------
943 # Handle the OPTIONAL_DIRS options for directores that may
945 #---------------------------------------------------------
948 SubDirs += $(OPTIONAL_DIRS)
950 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
951 $(RecursiveTargets)::
952 $(Verb) for dir in $(OPTIONAL_DIRS); do \
953 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
954 if ([ ! -f $$dir/Makefile ] || \
955 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
957 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
959 ($(MAKE) -C$$dir $@ ) || exit 1; \
963 $(RecursiveTargets)::
964 $(Verb) for dir in $(OPTIONAL_DIRS); do \
965 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
966 ($(MAKE) -C$$dir $@ ) || exit 1; \
972 #---------------------------------------------------------
973 # Handle the CONFIG_FILES options
974 #---------------------------------------------------------
979 $(Echo) Install circumvented with NO_INSTALL
981 $(Echo) UnInstall circumvented with NO_INSTALL
983 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
984 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
985 $(Verb)for file in $(CONFIG_FILES); do \
986 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
987 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
988 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
989 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
991 $(ECHO) Error: cannot find config file $${file}. ; \
996 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
997 $(Verb)for file in $(CONFIG_FILES); do \
998 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
1004 ###############################################################################
1005 # Set up variables for building libraries
1006 ###############################################################################
1008 #---------------------------------------------------------
1009 # Define various command line options pertaining to the
1010 # libraries needed when linking. There are "Proj" libs
1011 # (defined by the user's project) and "LLVM" libs (defined
1012 # by the LLVM project).
1013 #---------------------------------------------------------
1016 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1017 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
1018 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1019 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1023 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1024 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1025 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1026 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1029 # Loadable module for Win32 requires all symbols resolved for linking.
1030 # Then all symbols in LLVM.dll will be available.
1031 ifeq ($(ENABLE_SHARED),1)
1032 ifdef LOADABLE_MODULE
1033 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1034 LINK_COMPONENTS += all
1039 ifndef IS_CLEANING_TARGET
1040 ifdef LINK_COMPONENTS
1042 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
1043 # clean in tools, then do a make in tools (instead of at the top level).
1045 @echo "*** llvm-config doesn't exist - rebuilding it."
1046 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1048 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1050 ifeq ($(ENABLE_SHARED), 1)
1051 # We can take the "auto-import" feature to get rid of using dllimport.
1052 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1053 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1056 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1057 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1060 ifndef NO_LLVM_CONFIG
1061 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1062 ifeq ($(LLVMConfigLibs),Error)
1063 $(error llvm-config --libs failed)
1065 LLVMLibsOptions += $(LLVMConfigLibs)
1066 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1067 ifeq ($(LLVMConfigLibfiles),Error)
1068 $(error llvm-config --libfiles failed)
1070 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1077 # Set up the library exports file.
1078 ifdef EXPORTED_SYMBOL_FILE
1080 # First, set up the native export file, which may differ from the source
1083 ifeq ($(HOST_OS),Darwin)
1084 # Darwin convention prefixes symbols with underscores.
1085 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1086 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1087 $(Verb) sed -e 's/^/_/' < $< > $@
1089 -$(Verb) $(RM) -f $(NativeExportsFile)
1091 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1092 # Gold and BFD ld require a version script rather than a plain list.
1093 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1094 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1095 $(Verb) echo "{" > $@
1096 $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || :
1097 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
1098 ifneq ($(HOST_OS),OpenBSD)
1099 $(Verb) echo " local: *;" >> $@
1101 $(Verb) echo "};" >> $@
1103 -$(Verb) $(RM) -f $(NativeExportsFile)
1105 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1106 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1107 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1108 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1109 $(Echo) Generating $(notdir $@)
1110 $(Verb) $(ECHO) "EXPORTS" > $@
1111 $(Verb) $(CAT) $< >> $@
1113 -$(Verb) $(RM) -f $(NativeExportsFile)
1115 # Default behavior: just use the exports file verbatim.
1116 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1121 # Now add the linker command-line options to use the native export file.
1124 ifeq ($(HOST_OS),Darwin)
1125 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1128 # gold, bfd ld, etc.
1129 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1130 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1134 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1135 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1136 SharedLinkOptions += $(NativeExportsFile)
1141 ###############################################################################
1142 # Library Build Rules: Four ways to build a library
1143 ###############################################################################
1145 # if we're building a library ...
1148 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1149 LIBRARYNAME := $(strip $(LIBRARYNAME))
1150 ifdef LOADABLE_MODULE
1151 BaseLibName.A := $(LIBRARYNAME).a
1152 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1154 BaseLibName.A := lib$(LIBRARYNAME).a
1155 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1157 LibName.A := $(LibDir)/$(BaseLibName.A)
1158 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1159 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1161 #---------------------------------------------------------
1162 # Shared Library Targets:
1163 # If the user asked for a shared library to be built
1164 # with the SHARED_LIBRARY variable, then we provide
1165 # targets for building them.
1166 #---------------------------------------------------------
1167 ifdef SHARED_LIBRARY
1169 all-local:: $(LibName.SO)
1171 ifdef EXPORTED_SYMBOL_FILE
1172 $(LibName.SO): $(NativeExportsFile)
1175 ifdef LINK_LIBS_IN_SHARED
1176 ifdef LOADABLE_MODULE
1177 SharedLibKindMessage := "Loadable Module"
1178 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1180 SharedLibKindMessage := "Shared Library"
1182 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1183 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1185 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1186 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1188 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1189 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1190 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1194 ifneq ($(strip $(LibName.SO)),)
1195 -$(Verb) $(RM) -f $(LibName.SO)
1200 $(Echo) Install circumvented with NO_INSTALL
1202 $(Echo) Uninstall circumvented with NO_INSTALL
1205 # Win32.DLL prefers to be located on the "PATH" of binaries.
1206 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1207 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1209 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1211 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1213 install-local:: $(DestSharedLib)
1215 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1216 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1217 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1220 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1221 -$(Verb) $(RM) -f $(DestSharedLib)
1225 #---------------------------------------------------------
1227 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1228 # building an archive.
1229 #---------------------------------------------------------
1230 ifndef NO_BUILD_ARCHIVE
1231 ifndef BUILD_ARCHIVE
1232 ifndef LOADABLE_MODULE
1238 #---------------------------------------------------------
1239 # Archive Library Targets:
1240 # If the user wanted a regular archive library built,
1241 # then we provide targets for building them.
1242 #---------------------------------------------------------
1245 all-local:: $(LibName.A)
1247 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1248 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1249 -$(Verb) $(RM) -f $@
1250 $(Verb) $(Archive) $@ $(ObjectsO)
1251 $(Verb) $(Ranlib) $@
1254 ifneq ($(strip $(LibName.A)),)
1255 -$(Verb) $(RM) -f $(LibName.A)
1260 $(Echo) Install circumvented with NO_INSTALL
1262 $(Echo) Uninstall circumvented with NO_INSTALL
1264 ifdef NO_INSTALL_ARCHIVES
1266 $(Echo) Install circumvented with NO_INSTALL
1268 $(Echo) Uninstall circumvented with NO_INSTALL
1270 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1272 install-local:: $(DestArchiveLib)
1274 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1275 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1276 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1277 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1280 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1281 -$(Verb) $(RM) -f $(DestArchiveLib)
1289 ###############################################################################
1290 # Tool Build Rules: Build executable tool based on TOOLNAME option
1291 ###############################################################################
1295 #---------------------------------------------------------
1296 # Set up variables for building a tool.
1297 #---------------------------------------------------------
1298 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1300 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1302 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1305 # TOOLALIAS is a name to symlink (or copy) the tool to.
1308 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1310 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1314 #---------------------------------------------------------
1316 #---------------------------------------------------------
1318 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1319 # not exporting all of the weak symbols from the binary. This reduces dyld
1320 # startup time by 4x on darwin in some cases.
1321 ifdef TOOL_NO_EXPORTS
1322 ifeq ($(HOST_OS),Darwin)
1324 # Tiger tools don't support this.
1325 ifneq ($(DARWIN_MAJVERS),4)
1326 LD.Flags += -Wl,-exported_symbol,_main
1330 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1331 ifneq ($(ARCH), Mips)
1332 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1337 #---------------------------------------------------------
1338 # Tool Order File Support
1339 #---------------------------------------------------------
1341 ifeq ($(HOST_OS),Darwin)
1342 ifdef TOOL_ORDER_FILE
1344 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1349 #---------------------------------------------------------
1350 # Tool Version Info Support
1351 #---------------------------------------------------------
1353 ifeq ($(HOST_OS),Darwin)
1354 ifdef TOOL_INFO_PLIST
1356 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1358 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1360 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1361 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1362 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1363 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1364 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1365 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1371 #---------------------------------------------------------
1372 # Provide targets for building the tools
1373 #---------------------------------------------------------
1374 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1377 ifneq ($(strip $(ToolBuildPath)),)
1378 -$(Verb) $(RM) -f $(ToolBuildPath)
1380 ifneq ($(strip $(ToolAliasBuildPath)),)
1381 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1385 $(ToolBuildPath): $(ExmplDir)/.dir
1387 $(ToolBuildPath): $(ToolDir)/.dir
1390 ifdef CODESIGN_TOOLS
1391 TOOL_CODESIGN_IDENTITY ?= -
1393 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1394 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1395 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1396 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1397 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1399 $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1400 $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1402 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1403 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1404 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1405 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1406 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1410 ifneq ($(strip $(ToolAliasBuildPath)),)
1411 $(ToolAliasBuildPath): $(ToolBuildPath)
1412 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1413 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1414 $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1415 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1421 $(Echo) Install circumvented with NO_INSTALL
1423 $(Echo) Uninstall circumvented with NO_INSTALL
1427 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1429 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1431 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1433 install-local:: $(DestTool)
1435 $(DestTool): $(ToolBuildPath)
1436 $(Echo) Installing $(BuildMode) $(DestTool)
1437 $(Verb) $(MKDIR) $(ToolBinDir)
1438 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1441 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1442 -$(Verb) $(RM) -f $(DestTool)
1444 # TOOLALIAS install.
1446 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1448 install-local:: $(DestToolAlias)
1450 $(DestToolAlias): $(DestTool)
1451 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1452 $(Verb) $(RM) -f $(DestToolAlias)
1453 $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1456 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1457 -$(Verb) $(RM) -f $(DestToolAlias)
1463 ###############################################################################
1464 # Object Build Rules: Build object files based on sources
1465 ###############################################################################
1467 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1468 ifeq ($(HOST_OS),HP-UX)
1469 DISABLE_AUTO_DEPENDENCIES=1
1472 COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1474 # Provide rule sets for when dependency generation is enabled
1475 ifndef DISABLE_AUTO_DEPENDENCIES
1477 #---------------------------------------------------------
1478 # Create .o files in the ObjDir directory from the .cpp and .c files...
1479 #---------------------------------------------------------
1481 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1482 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1484 # If the build succeeded, move the dependency file over, otherwise
1486 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1487 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1489 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1490 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1491 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1494 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1495 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1496 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1499 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1500 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1501 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1504 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1505 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1506 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1509 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1510 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1511 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1514 # Provide alternate rule sets if dependencies are disabled
1517 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1518 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1519 $(Compile.CXX) $< -o $@
1521 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1522 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1523 $(Compile.CXX) $< -o $@
1525 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1526 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1527 $(Compile.CXX) $< -o $@
1529 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1530 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1531 $(Compile.C) $< -o $@
1533 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1534 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1535 $(Compile.C) $< -o $@
1539 ## Rules for building preprocessed (.i/.ii) outputs.
1540 $(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1541 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1542 $(Verb) $(Preprocess.CXX) $< -o $@
1544 $(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1545 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1546 $(Verb) $(Preprocess.CXX) $< -o $@
1548 $(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1549 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1550 $(Verb) $(Preprocess.CXX) $< -o $@
1552 $(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1553 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1554 $(Verb) $(Preprocess.C) $< -o $@
1556 $(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1557 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1558 $(Verb) $(Preprocess.C) $< -o $@
1561 $(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1562 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1563 $(Compile.CXX) $< -o $@ -S
1565 $(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1566 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1567 $(Compile.CXX) $< -o $@ -S
1569 $(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1570 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1571 $(Compile.CXX) $< -o $@ -S
1573 $(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1574 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1575 $(Compile.C) $< -o $@ -S
1577 $(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1578 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1579 $(Compile.C) $< -o $@ -S
1581 ###############################################################################
1582 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1583 ###############################################################################
1586 TABLEGEN_INC_FILES_COMMON = 1
1589 ifdef TABLEGEN_INC_FILES_COMMON
1591 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1592 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1593 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1595 # INCFiles rule: All of the tblgen generated files are emitted to
1596 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1597 # us to only "touch" the real file if the contents of it change. IOW, if
1598 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1599 # dependencies of the .inc files are, unless the contents of the .inc file
1601 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1602 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1604 endif # TABLEGEN_INC_FILES_COMMON
1608 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1609 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1610 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1611 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1612 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1613 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1614 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1616 # All .inc.tmp files depend on the .td files.
1617 $(INCTMPFiles) : $(TDFiles)
1619 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1620 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1621 $(Echo) "Building $(<F) register info implementation with tblgen"
1622 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1624 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1625 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1626 $(Echo) "Building $(<F) instruction information with tblgen"
1627 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1629 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1630 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1631 $(Echo) "Building $(<F) assembly writer with tblgen"
1632 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1634 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1635 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1636 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1637 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1639 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1640 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1641 $(Echo) "Building $(<F) assembly matcher with tblgen"
1642 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1644 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1645 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1646 $(Echo) "Building $(<F) MC code emitter with tblgen"
1647 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1649 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1650 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1651 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1652 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1654 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1655 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1656 $(Echo) "Building $(<F) code emitter with tblgen"
1657 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1659 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1660 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1661 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1662 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1664 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1665 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1666 $(Echo) "Building $(<F) disassembly tables with tblgen"
1667 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1669 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1670 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1671 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1672 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1674 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1675 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1676 $(Echo) "Building $(<F) subtarget information with tblgen"
1677 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1679 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1680 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1681 $(Echo) "Building $(<F) calling convention information with tblgen"
1682 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1684 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1685 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1686 $(Echo) "Building $(<F) intrinsics information with tblgen"
1687 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1689 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1690 $(Echo) "Building $(<F) decoder tables with tblgen"
1691 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1693 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1694 $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1695 $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1698 -$(Verb) $(RM) -f $(INCFiles)
1702 ###############################################################################
1703 # OTHER RULES: Other rules needed
1704 ###############################################################################
1706 # To create postscript files from dot files...
1707 ifneq ($(DOT),false)
1709 $(DOT) -Tps < $< > $@
1712 $(Echo) "Cannot build $@: The program dot is not installed"
1715 # This rules ensures that header files that are removed still have a rule for
1716 # which they can be "generated." This allows make to ignore them and
1717 # reproduce the dependency lists.
1721 # Define clean-local to clean the current directory. Note that this uses a
1722 # very conservative approach ensuring that empty variables do not cause
1723 # errors or disastrous removal.
1725 ifneq ($(strip $(ObjRootDir)),)
1726 -$(Verb) $(RM) -rf $(ObjRootDir)
1728 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1729 -$(Verb) $(RM) -f *$(SHLIBEXT)
1733 -$(Verb) $(RM) -rf Debug Release Profile
1736 ###############################################################################
1737 # DEPENDENCIES: Include the dependency files if we should
1738 ###############################################################################
1739 ifndef DISABLE_AUTO_DEPENDENCIES
1741 # If its not one of the cleaning targets
1742 ifndef IS_CLEANING_TARGET
1744 # Get the list of dependency files
1745 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1746 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1748 -include $(DependFiles) ""
1754 ###############################################################################
1755 # CHECK: Running the test suite
1756 ###############################################################################
1759 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1760 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1761 $(EchoCmd) Running test suite ; \
1762 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1763 TESTSUITE=$(TESTSUITE) ; \
1765 $(EchoCmd) No Makefile in test directory ; \
1768 $(EchoCmd) No test directory ; \
1771 # An alias dating from when both lit and DejaGNU test runners were used.
1775 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1776 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1777 $(EchoCmd) Running test suite ; \
1778 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1780 $(EchoCmd) No Makefile in test directory ; \
1783 $(EchoCmd) No test directory ; \
1786 ###############################################################################
1787 # UNITTESTS: Running the unittests test suite
1788 ###############################################################################
1791 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1792 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1793 $(EchoCmd) Running unittests test suite ; \
1794 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1796 $(EchoCmd) No Makefile in unittests directory ; \
1799 $(EchoCmd) No unittests directory ; \
1802 ###############################################################################
1803 # DISTRIBUTION: Handle construction of a distribution tarball
1804 ###############################################################################
1806 #------------------------------------------------------------------------
1807 # Define distribution related variables
1808 #------------------------------------------------------------------------
1809 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1810 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1811 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1812 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1813 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1814 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1815 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1816 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1817 Makefile.config.in configure autoconf
1818 DistOther := $(notdir $(wildcard \
1819 $(PROJ_SRC_DIR)/*.h \
1820 $(PROJ_SRC_DIR)/*.td \
1821 $(PROJ_SRC_DIR)/*.def \
1822 $(PROJ_SRC_DIR)/*.ll \
1823 $(PROJ_SRC_DIR)/*.in))
1824 DistSubDirs := $(SubDirs)
1825 DistSources = $(Sources) $(EXTRA_DIST)
1826 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1828 #------------------------------------------------------------------------
1829 # We MUST build distribution with OBJ_DIR != SRC_DIR
1830 #------------------------------------------------------------------------
1831 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1832 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1833 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1837 #------------------------------------------------------------------------
1838 # Prevent attempt to run dist targets from anywhere but the top level
1839 #------------------------------------------------------------------------
1841 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1842 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1845 #------------------------------------------------------------------------
1846 # Provide the top level targets
1847 #------------------------------------------------------------------------
1849 dist-gzip:: $(DistTarGZip)
1851 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1852 $(Echo) Packing gzipped distribution tar file.
1853 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1854 $(GZIP) -c > "$(DistTarGZip)"
1856 dist-bzip2:: $(DistTarBZ2)
1858 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1859 $(Echo) Packing bzipped distribution tar file.
1860 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1861 $(BZIP2) -c >$(DistTarBZ2)
1863 dist-zip:: $(DistZip)
1865 $(DistZip) : $(TopDistDir)/.makedistdir
1866 $(Echo) Packing zipped distribution file.
1867 $(Verb) rm -f $(DistZip)
1868 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1870 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1871 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1873 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1875 dist-check:: $(DistTarGZip)
1876 $(Echo) Checking distribution tar file.
1877 $(Verb) if test -d $(DistCheckDir) ; then \
1878 $(RM) -rf $(DistCheckDir) ; \
1880 $(Verb) $(MKDIR) $(DistCheckDir)
1881 $(Verb) cd $(DistCheckDir) && \
1882 $(MKDIR) $(DistCheckDir)/build && \
1883 $(MKDIR) $(DistCheckDir)/install && \
1884 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1886 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1887 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1890 $(MAKE) unittests && \
1891 $(MAKE) install && \
1892 $(MAKE) uninstall && \
1893 $(MAKE) dist-clean && \
1894 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1897 $(Echo) Cleaning distribution files
1898 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1903 #------------------------------------------------------------------------
1904 # Provide the recursive distdir target for building the distribution directory
1905 #------------------------------------------------------------------------
1906 distdir: $(DistDir)/.makedistdir
1907 $(DistDir)/.makedistdir: $(DistSources)
1908 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1909 if test -d "$(DistDir)" ; then \
1910 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1913 $(EchoCmd) Removing old $(DistDir) ; \
1914 $(RM) -rf $(DistDir); \
1915 $(EchoCmd) Making 'all' to verify build ; \
1916 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1918 $(Echo) Building Distribution Directory $(DistDir)
1919 $(Verb) $(MKDIR) $(DistDir)
1920 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1921 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1922 for file in $(DistFiles) ; do \
1924 $(PROJ_SRC_DIR)/*) \
1925 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1927 $(PROJ_SRC_ROOT)/*) \
1928 file=`echo "$$file" | \
1929 sed "s#^$$srcrootstrip/##"` \
1932 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1933 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1934 from_dir="$(PROJ_SRC_DIR)" ; \
1935 elif test -f "$$file" || test -d "$$file" ; then \
1938 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1939 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1940 to_dir="$(DistDir)/$$dir"; \
1941 $(MKDIR) "$$to_dir" ; \
1943 to_dir="$(DistDir)"; \
1945 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1946 if test -n "$$mid_dir" ; then \
1947 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1949 if test -d "$$from_dir/$$file"; then \
1950 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1951 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1952 cd $(PROJ_SRC_DIR) ; \
1953 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1954 ( cd $$to_dir ; $(TAR) xf - ) ; \
1955 cd $(PROJ_OBJ_DIR) ; \
1958 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1959 ( cd $$to_dir ; $(TAR) xf - ) ; \
1960 cd $(PROJ_OBJ_DIR) ; \
1962 elif test -f "$$from_dir/$$file" ; then \
1963 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1964 elif test -L "$$from_dir/$$file" ; then \
1965 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1966 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1967 $(EchoCmd) "===== WARNING: Distribution Source " \
1968 "$$from_dir/$$file Not Found!" ; \
1969 elif test "$(Verb)" != '@' ; then \
1970 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1973 $(Verb) for subdir in $(DistSubDirs) ; do \
1974 if test "$$subdir" \!= "." ; then \
1975 new_distdir="$(DistDir)/$$subdir" ; \
1976 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1977 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1978 DistDir="$$new_distdir" distdir ) || exit 1; \
1981 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1982 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1983 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1984 -name .svn \) -print` ;\
1985 $(MAKE) dist-hook ; \
1986 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1987 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1988 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1989 -o ! -type d ! -perm -444 -exec \
1990 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1991 || chmod -R a+r $(DistDir) ; \
1994 # This is invoked by distdir target, define it as a no-op to avoid errors if not
2000 ###############################################################################
2001 # TOP LEVEL - targets only to apply at the top level directory
2002 ###############################################################################
2006 #------------------------------------------------------------------------
2007 # Install support for the project's include files:
2008 #------------------------------------------------------------------------
2011 $(Echo) Install circumvented with NO_INSTALL
2013 $(Echo) Uninstall circumvented with NO_INSTALL
2016 $(Echo) Installing include files
2017 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2018 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2019 cd $(PROJ_SRC_ROOT)/include && \
2020 for hdr in `find . -type f \
2021 '(' -name LICENSE.TXT \
2026 ')' -print | grep -v CVS | \
2027 grep -v .svn` ; do \
2028 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2029 if test \! -d "$$instdir" ; then \
2030 $(EchoCmd) Making install directory $$instdir ; \
2031 $(MKDIR) $$instdir ;\
2033 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2036 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2037 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2038 cd $(PROJ_OBJ_ROOT)/include && \
2039 for hdr in `find . -type f \
2040 '(' -name LICENSE.TXT \
2045 ')' -print | grep -v CVS | \
2046 grep -v .svn` ; do \
2047 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2048 if test \! -d "$$instdir" ; then \
2049 $(EchoCmd) Making install directory $$instdir ; \
2050 $(MKDIR) $$instdir ;\
2052 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2058 $(Echo) Uninstalling include files
2059 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2060 cd $(PROJ_SRC_ROOT)/include && \
2061 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2062 '!' '(' -name '*~' -o -name '.#*' \
2063 -o -name '*.in' ')' -print ')' | \
2064 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2065 cd $(PROJ_SRC_ROOT)/include && \
2066 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2067 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2073 @echo searching for overlength lines in files: $(Sources)
2076 egrep -n '.{81}' $(Sources) /dev/null
2079 @echo searching for tabs in files: $(Sources)
2082 egrep -n ' ' $(Sources) /dev/null
2085 @ls -l $(LibDir) | awk '\
2086 BEGIN { sum = 0; } \
2088 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2089 @ls -l $(ToolDir) | awk '\
2090 BEGIN { sum = 0; } \
2092 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2093 #------------------------------------------------------------------------
2094 # Print out the directories used for building
2095 #------------------------------------------------------------------------
2097 $(Echo) "BuildMode : " '$(BuildMode)'
2098 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2099 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2100 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2101 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2102 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2103 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2104 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2105 $(Echo) "PROJ_internal_prefix : " '$(PROJ_internal_prefix)'
2106 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2107 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2108 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2109 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2110 $(Echo) "UserTargets : " '$(UserTargets)'
2111 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2112 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2113 $(Echo) "ObjDir : " '$(ObjDir)'
2114 $(Echo) "LibDir : " '$(LibDir)'
2115 $(Echo) "ToolDir : " '$(ToolDir)'
2116 $(Echo) "ExmplDir : " '$(ExmplDir)'
2117 $(Echo) "Sources : " '$(Sources)'
2118 $(Echo) "TDFiles : " '$(TDFiles)'
2119 $(Echo) "INCFiles : " '$(INCFiles)'
2120 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2121 $(Echo) "PreConditions: " '$(PreConditions)'
2122 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2123 $(Echo) "Compile.C : " '$(Compile.C)'
2124 $(Echo) "Archive : " '$(Archive)'
2125 $(Echo) "YaccFiles : " '$(YaccFiles)'
2126 $(Echo) "LexFiles : " '$(LexFiles)'
2127 $(Echo) "Module : " '$(Module)'
2128 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2129 $(Echo) "SubDirs : " '$(SubDirs)'
2130 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2131 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2136 # General debugging rule, use 'make dbg-print-XXX' to print the
2137 # definition, value and origin of XXX.
2139 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))