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_CXX1Y),1)
323 CXX.Flags += -std=c++1y
325 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
326 # MinGW and Cygwin are a bit stricter and lack things like
327 # 'strdup', 'stricmp', etc in c++11 mode.
328 CXX.Flags += -std=gnu++11
330 CXX.Flags += -std=c++11
334 ifeq ($(ENABLE_WERROR),1)
339 ifeq ($(ENABLE_PROFILING),1)
340 BuildMode := $(BuildMode)+Profile
341 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
342 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
343 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg
347 ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
348 CXX.Flags += -fvisibility-inlines-hidden
351 ifdef ENABLE_EXPENSIVE_CHECKS
352 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
353 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
357 # IF REQUIRES_EH=1 is specified then don't disable exceptions
359 CXX.Flags += -fno-exceptions
361 # If the library requires EH, it also requires RTTI.
365 ifdef REQUIRES_FRAME_POINTER
366 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
367 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
368 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
371 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
372 ifneq ($(REQUIRES_RTTI), 1)
373 CXX.Flags += -fno-rtti
376 ifeq ($(ENABLE_COVERAGE),1)
377 BuildMode := $(BuildMode)+Coverage
378 CXX.Flags += -ftest-coverage -fprofile-arcs
379 C.Flags += -ftest-coverage -fprofile-arcs
380 LD.Flags += -ftest-coverage -fprofile-arcs
383 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
384 # then disable assertions by defining the appropriate preprocessor symbols.
385 ifeq ($(DISABLE_ASSERTIONS),1)
386 CPP.Defines += -DNDEBUG
388 BuildMode := $(BuildMode)+Asserts
389 CPP.Defines += -D_DEBUG
392 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
393 # configured), then enable expensive checks by defining the
394 # appropriate preprocessor symbols.
395 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
396 BuildMode := $(BuildMode)+Checks
397 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
400 # LOADABLE_MODULE implies several other things so we force them to be
402 ifdef LOADABLE_MODULE
404 LINK_LIBS_IN_SHARED := 1
412 ifeq ($(ENABLE_PIC),1)
413 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
414 # Nothing. Win32 defaults to PIC and warns when given -fPIC
416 ifeq ($(HOST_OS),Darwin)
417 # Common symbols not allowed in dylib files
418 CXX.Flags += -fno-common
419 C.Flags += -fno-common
421 # Linux and others; pass -fPIC
427 ifeq ($(HOST_OS),Darwin)
428 CXX.Flags += -mdynamic-no-pic
429 C.Flags += -mdynamic-no-pic
433 # Support makefile variable to disable any kind of timestamp/non-deterministic
434 # info from being used in the build.
435 ifeq ($(ENABLE_TIMESTAMPS),1)
436 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
438 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
441 ifeq ($(HOST_OS),MingW)
443 CPP.Defines += -D__NO_CTYPE_INLINE
444 ifeq ($(LLVM_CROSS_COMPILING),1)
445 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
447 LD.Flags += -Wl,--allow-multiple-definition
452 CXX.Flags += -Woverloaded-virtual
453 CPP.BaseFlags += $(CPP.Defines)
456 # Make Floating point IEEE compliant on Alpha.
459 CPP.BaseFlags += -mieee
460 ifeq ($(ENABLE_PIC),0)
462 CPP.BaseFlags += -fPIC
465 LD.Flags += -Wl,--no-relax
468 # GNU ld/PECOFF accepts but ignores them below;
472 # FIXME: autoconf should be aware of them.
473 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
474 HAVE_LINK_VERSION_SCRIPT := 0
476 RDYNAMIC := -Wl,--export-all-symbols
479 #--------------------------------------------------------------------
480 # Directory locations
481 #--------------------------------------------------------------------
483 ifeq ($(LLVM_CROSS_COMPILING),1)
484 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
487 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
488 ObjDir := $(ObjRootDir)
489 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
490 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
491 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
492 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
493 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
494 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
496 #--------------------------------------------------------------------
497 # Locations of shared libraries
498 #--------------------------------------------------------------------
501 SharedLibDir := $(LibDir)
502 LLVMSharedLibDir := $(LLVMLibDir)
504 # Win32.DLL prefers to be located on the "PATH" of binaries.
505 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
506 SharedLibDir := $(ToolDir)
507 LLVMSharedLibDir := $(LLVMToolDir)
509 ifeq ($(HOST_OS),Cygwin)
516 #--------------------------------------------------------------------
517 # Full Paths To Compiled Tools and Utilities
518 #--------------------------------------------------------------------
519 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
520 ifdef BUILD_DIRS_ONLY
521 EchoCmd := $(EchoCmd) "(build tools)":
526 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
529 ifeq ($(LLVM_CROSS_COMPILING),1)
530 LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
532 LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
535 ifeq ($(LLVM_CROSS_COMPILING),1)
536 LLVM_CONFIG := $(BuildLLVMToolDir)/llvm-config$(BUILD_EXEEXT)
538 LLVM_CONFIG := $(LLVMToolDir)/llvm-config$(EXEEXT)
541 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
544 LLI := $(LLVMToolDir)/lli$(EXEEXT)
547 LLC := $(LLVMToolDir)/llc$(EXEEXT)
550 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
553 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
556 LLVMLINK := $(LLVMToolDir)/llvm-link$(EXEEXT)
559 #--------------------------------------------------------------------
560 # Adjust to user's request
561 #--------------------------------------------------------------------
563 ifeq ($(HOST_OS),Darwin)
564 ifdef MACOSX_DEPLOYMENT_TARGET
565 DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
567 DARWIN_VERSION := `sw_vers -productVersion`
569 # Strip a number like 10.4.7 to 10.4
570 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/')
571 # Get "4" out of 10.4 for later pieces in the makefile.
572 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/')
574 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
575 SharedLinkOptions := -dynamiclib
576 ifdef DEPLOYMENT_TARGET
577 SharedLinkOptions += $(DEPLOYMENT_TARGET)
580 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
584 SharedLinkOptions=-shared
587 ifeq ($(TARGET_OS),Darwin)
588 ifdef DEPLOYMENT_TARGET
589 TargetCommonOpts += $(DEPLOYMENT_TARGET)
592 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
598 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
599 ifneq ($(HOST_OS),Darwin)
600 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
602 LD.Flags += -Wl,-install_name -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
614 # Adjust settings for verbose mode
617 AR.Flags += >/dev/null 2>/dev/null
618 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
620 ConfigureScriptFLAGS :=
623 # By default, strip symbol information from executable
625 Strip := $(PLATFORMSTRIPOPTS)
626 StripWarnMsg := "(without symbols)"
627 Install.StripFlag += -s
630 # By default, strip dead symbols at link time
631 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
632 ifneq ($(HOST_OS),Darwin)
633 ifneq ($(HOST_ARCH),Mips)
634 CXX.Flags += -ffunction-sections -fdata-sections
639 ifeq ($(HOST_OS),Darwin)
640 LD.Flags += -Wl,-dead_strip
642 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
643 LD.Flags += -Wl,--gc-sections
648 # Adjust linker flags for building an executable
649 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
650 ifndef TOOL_NO_EXPORTS
651 LD.Flags += $(RDYNAMIC)
653 ifneq ($(HOST_OS), Darwin)
655 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
658 ifneq ($(DARWIN_MAJVERS),4)
659 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
662 TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
663 LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
669 #----------------------------------------------------------
670 # Options To Invoke Tools
671 #----------------------------------------------------------
673 ifdef EXTRA_LD_OPTIONS
674 LD.Flags += $(EXTRA_LD_OPTIONS)
678 CompileCommonOpts += -pedantic -Wno-long-long
680 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
681 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
682 $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
683 $(NO_MISSING_FIELD_INITIALIZERS)
684 # Enable cast-qual for C++; the workaround is to use const_cast.
685 CXX.Flags += -Wcast-qual
687 ifeq ($(HOST_OS),HP-UX)
688 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
691 # If we are building a universal binary on Mac OS X, pass extra options. This
692 # is useful to people that want to link the LLVM libraries into their universal
695 # The following can be optionally specified:
696 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
697 # For Mac OS X 10.4 Intel machines, the traditional one is:
698 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
699 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
700 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
703 ifndef UNIVERSAL_ARCH
704 UNIVERSAL_ARCH := i386 ppc
706 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
707 TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
708 ifdef UNIVERSAL_SDK_PATH
709 TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
712 # Building universal cannot compute dependencies automatically.
713 DISABLE_AUTO_DEPENDENCIES=1
715 ifeq ($(TARGET_OS),Darwin)
716 ifeq ($(ARCH),x86_64)
717 TargetCommonOpts = -m64
720 TargetCommonOpts = -m32
726 ifeq ($(HOST_OS),SunOS)
727 CPP.BaseFlags += -include llvm/Support/Solaris.h
730 # On Windows, SharedLibDir != LibDir. The order is important.
731 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
732 LD.Flags += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
734 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
737 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
738 # All -I flags should go here, so that they don't confuse llvm-config.
739 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
740 $(patsubst %,-I%/include,\
741 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
742 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
745 ifeq ($(INCLUDE_BUILD_DIR),1)
746 CPP.Flags += -I$(ObjDir)
749 # SHOW_DIAGNOSTICS support.
750 ifeq ($(SHOW_DIAGNOSTICS),1)
751 Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
752 CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
757 Compile.C = $(Compile.Wrapper) \
758 $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
759 $(TargetCommonOpts) $(CompileCommonOpts) -c
760 Compile.CXX = $(Compile.Wrapper) \
761 $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
762 $(TargetCommonOpts) $(CompileCommonOpts) -c
763 Preprocess.CXX= $(Compile.Wrapper) \
764 $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
765 $(CompileCommonOpts) $(CXX.Flags) -E
766 Link = $(Compile.Wrapper) \
767 $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
768 $(TargetCommonOpts) $(Strip)
770 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
771 $(TargetCommonOpts) $(CompileCommonOpts) -E
773 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
774 ScriptInstall = $(INSTALL) -m 0755
775 DataInstall = $(INSTALL) -m 0644
777 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
778 # paths. In this case, the SYSPATH function (defined in
779 # Makefile.config) transforms Unix paths into Windows paths.
780 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
781 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
782 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
783 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
784 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
786 Archive = $(AR) $(AR.Flags)
795 #----------------------------------------------------------
796 # Get the list of source files and compute object file
798 #----------------------------------------------------------
801 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
802 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
804 Sources := $(SOURCES)
808 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
811 BaseNameSources := $(sort $(basename $(Sources)))
812 SourceDirs := $(sort $(dir $(Sources)))
814 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
815 ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
817 #----------------------------------------------------------
818 # For Mingw MSYS bash and Python/w32:
820 # $(ECHOPATH) prints DOSish pathstring.
821 # ex) $(ECHOPATH) /include/sys/types.h
822 # --> C:/mingw/include/sys/types.h
823 # built-in "echo" does not transform path to DOSish path.
825 # FIXME: It would not be needed when MSYS's python
827 #----------------------------------------------------------
829 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
830 ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
832 ECHOPATH := $(Verb)$(ECHO)
835 ###############################################################################
836 # DIRECTORIES: Handle recursive descent of directory structure
837 ###############################################################################
839 #---------------------------------------------------------
840 # Provide rules to make install dirs. This must be early
841 # in the file so they get built before dependencies
842 #---------------------------------------------------------
844 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
847 # To create other directories, as needed, and timestamp their creation
849 $(Verb) $(MKDIR) $* > /dev/null
850 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
852 .PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
853 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
855 #---------------------------------------------------------
856 # Collect the object directories (as there may be more
857 # than one if the source code is spread across
859 #---------------------------------------------------------
861 OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
862 .PRECIOUS: $(OBJECT_DIRS)
864 #---------------------------------------------------------
865 # Handle the DIRS options for sequential construction
866 #---------------------------------------------------------
872 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
873 $(RecursiveTargets)::
874 $(Verb) for dir in $(DIRS); do \
875 if ([ ! -f $$dir/Makefile ] || \
876 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
878 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
880 ($(MAKE) -C $$dir $@ ) || exit 1; \
883 $(RecursiveTargets)::
884 $(Verb) for dir in $(DIRS); do \
885 ($(MAKE) -C $$dir $@ ) || exit 1; \
891 #---------------------------------------------------------
892 # Handle the EXPERIMENTAL_DIRS options ensuring success
893 # after each directory is built.
894 #---------------------------------------------------------
895 ifdef EXPERIMENTAL_DIRS
896 $(RecursiveTargets)::
897 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
898 if ([ ! -f $$dir/Makefile ] || \
899 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
901 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
903 ($(MAKE) -C $$dir $@ ) || exit 0; \
907 #-----------------------------------------------------------
908 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
909 #-----------------------------------------------------------
910 ifdef OPTIONAL_PARALLEL_DIRS
911 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
914 #-----------------------------------------------------------
915 # Handle the PARALLEL_DIRS options for parallel construction
916 #-----------------------------------------------------------
919 SubDirs += $(PARALLEL_DIRS)
921 # Unfortunately, this list must be maintained if new recursive targets are added
922 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
923 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
924 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
925 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
926 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
927 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
928 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
930 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
934 SD=$(PROJ_SRC_DIR)/$(@D); \
936 if [ ! -f $$SD/Makefile ]; then \
938 DD=$(notdir $(@D)); \
940 if ([ ! -f $$DD/Makefile ] || \
941 command test $$DD/Makefile -ot \
942 $$SD/Makefile ); then \
944 $(CP) $$SD/Makefile $$DD/Makefile; \
946 $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
949 #---------------------------------------------------------
950 # Handle the OPTIONAL_DIRS options for directores that may
952 #---------------------------------------------------------
955 SubDirs += $(OPTIONAL_DIRS)
957 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
958 $(RecursiveTargets)::
959 $(Verb) for dir in $(OPTIONAL_DIRS); do \
960 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
961 if ([ ! -f $$dir/Makefile ] || \
962 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
964 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
966 ($(MAKE) -C$$dir $@ ) || exit 1; \
970 $(RecursiveTargets)::
971 $(Verb) for dir in $(OPTIONAL_DIRS); do \
972 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
973 ($(MAKE) -C$$dir $@ ) || exit 1; \
979 #---------------------------------------------------------
980 # Handle the CONFIG_FILES options
981 #---------------------------------------------------------
986 $(Echo) Install circumvented with NO_INSTALL
988 $(Echo) UnInstall circumvented with NO_INSTALL
990 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
991 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
992 $(Verb)for file in $(CONFIG_FILES); do \
993 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
994 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
995 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
996 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
998 $(ECHO) Error: cannot find config file $${file}. ; \
1003 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
1004 $(Verb)for file in $(CONFIG_FILES); do \
1005 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
1011 ###############################################################################
1012 # Set up variables for building libraries
1013 ###############################################################################
1015 #---------------------------------------------------------
1016 # Define various command line options pertaining to the
1017 # libraries needed when linking. There are "Proj" libs
1018 # (defined by the user's project) and "LLVM" libs (defined
1019 # by the LLVM project).
1020 #---------------------------------------------------------
1023 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1024 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
1025 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1026 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1030 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1031 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1032 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1033 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1036 # Loadable module for Win32 requires all symbols resolved for linking.
1037 # Then all symbols in LLVM.dll will be available.
1038 ifeq ($(ENABLE_SHARED),1)
1039 ifdef LOADABLE_MODULE
1040 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1041 LINK_COMPONENTS += all
1046 ifndef IS_CLEANING_TARGET
1047 ifdef LINK_COMPONENTS
1049 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
1050 # clean in tools, then do a make in tools (instead of at the top level).
1052 @echo "*** llvm-config doesn't exist - rebuilding it."
1053 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1055 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1057 ifeq ($(ENABLE_SHARED), 1)
1058 # We can take the "auto-import" feature to get rid of using dllimport.
1059 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1060 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1063 LLVM_SO_NAME = LLVM-$(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)$(LLVM_VERSION_SUFFIX)
1064 LLVMLibsOptions += -l$(LLVM_SO_NAME)
1065 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)$(LLVM_SO_NAME)$(SHLIBEXT)
1068 ifndef NO_LLVM_CONFIG
1069 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1070 ifeq ($(LLVMConfigLibs),Error)
1071 $(error llvm-config --libs failed)
1073 LLVMLibsOptions += $(LLVMConfigLibs)
1074 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1075 ifeq ($(LLVMConfigLibfiles),Error)
1076 $(error llvm-config --libfiles failed)
1078 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1085 # Set up the library exports file.
1086 ifdef EXPORTED_SYMBOL_FILE
1088 # First, set up the native export file, which may differ from the source
1091 ifeq ($(HOST_OS),Darwin)
1092 # Darwin convention prefixes symbols with underscores.
1093 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1094 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1095 $(Verb) sed -e 's/^/_/' < $< > $@
1097 -$(Verb) $(RM) -f $(NativeExportsFile)
1099 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1100 # Gold and BFD ld require a version script rather than a plain list.
1101 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1102 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1103 $(Verb) echo "{" > $@
1104 $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || :
1105 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
1106 ifneq ($(HOST_OS),OpenBSD)
1107 $(Verb) echo " local: *;" >> $@
1109 $(Verb) echo "};" >> $@
1111 -$(Verb) $(RM) -f $(NativeExportsFile)
1113 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1114 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1115 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1116 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1117 $(Echo) Generating $(notdir $@)
1118 $(Verb) $(ECHO) "EXPORTS" > $@
1119 $(Verb) $(CAT) $< >> $@
1121 -$(Verb) $(RM) -f $(NativeExportsFile)
1123 # Default behavior: just use the exports file verbatim.
1124 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1129 # Now add the linker command-line options to use the native export file.
1132 ifeq ($(HOST_OS),Darwin)
1133 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1136 # gold, bfd ld, etc.
1137 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1138 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1142 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1143 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1144 SharedLinkOptions += $(NativeExportsFile)
1149 ###############################################################################
1150 # Library Build Rules: Four ways to build a library
1151 ###############################################################################
1153 # if we're building a library ...
1156 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1157 LIBRARYNAME := $(strip $(LIBRARYNAME))
1158 LIBRARYALIASNAME := $(strip $(LIBRARYALIASNAME))
1159 ifdef LOADABLE_MODULE
1160 BaseLibName.A := $(LIBRARYNAME).a
1161 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1162 BaseAliasName.SO := $(LIBRARYALIASNAME)$(SHLIBEXT)
1164 BaseLibName.A := lib$(LIBRARYNAME).a
1165 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1166 BaseAliasName.SO := $(SharedPrefix)$(LIBRARYALIASNAME)$(SHLIBEXT)
1168 LibName.A := $(LibDir)/$(BaseLibName.A)
1169 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1170 AliasName.SO := $(SharedLibDir)/$(BaseAliasName.SO)
1171 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1173 #---------------------------------------------------------
1174 # Shared Library Targets:
1175 # If the user asked for a shared library to be built
1176 # with the SHARED_LIBRARY variable, then we provide
1177 # targets for building them.
1178 #---------------------------------------------------------
1179 ifdef SHARED_LIBRARY
1181 all-local:: $(AliasName.SO)
1183 $(AliasName.SO): $(LibName.SO)
1185 $(Verb) $(AliasTool) $(BaseLibName.SO) $(AliasName.SO)
1188 ifdef EXPORTED_SYMBOL_FILE
1189 $(LibName.SO): $(NativeExportsFile)
1192 ifdef LINK_LIBS_IN_SHARED
1193 ifdef LOADABLE_MODULE
1194 SharedLibKindMessage := "Loadable Module"
1195 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1197 SharedLibKindMessage := "Shared Library"
1199 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1200 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1202 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1203 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1205 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1206 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1207 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1211 ifneq ($(strip $(LibName.SO)),)
1212 -$(Verb) $(RM) -f $(LibName.SO)
1217 $(Echo) Install circumvented with NO_INSTALL
1219 $(Echo) Uninstall circumvented with NO_INSTALL
1222 # Win32.DLL prefers to be located on the "PATH" of binaries.
1223 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1224 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1226 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1228 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1229 DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO)
1231 install-local:: $(DestSharedLib)
1233 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1234 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1235 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1237 $(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias)
1238 $(Verb) $(AliasTool) $(BaseLibName.SO) $(DestSharedAlias)
1242 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1243 -$(Verb) $(RM) -f $(DestSharedLib)
1245 -$(Verb) $(RM) -f $(DestSharedAlias)
1250 #---------------------------------------------------------
1252 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1253 # building an archive.
1254 #---------------------------------------------------------
1255 ifndef NO_BUILD_ARCHIVE
1256 ifndef BUILD_ARCHIVE
1257 ifndef LOADABLE_MODULE
1263 #---------------------------------------------------------
1264 # Archive Library Targets:
1265 # If the user wanted a regular archive library built,
1266 # then we provide targets for building them.
1267 #---------------------------------------------------------
1270 all-local:: $(LibName.A)
1272 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1273 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1274 -$(Verb) $(RM) -f $@
1275 $(Verb) $(Archive) $@ $(ObjectsO)
1276 $(Verb) $(Ranlib) $@
1279 ifneq ($(strip $(LibName.A)),)
1280 -$(Verb) $(RM) -f $(LibName.A)
1285 $(Echo) Install circumvented with NO_INSTALL
1287 $(Echo) Uninstall circumvented with NO_INSTALL
1289 ifdef NO_INSTALL_ARCHIVES
1291 $(Echo) Install circumvented with NO_INSTALL
1293 $(Echo) Uninstall circumvented with NO_INSTALL
1295 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1297 install-local:: $(DestArchiveLib)
1299 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1300 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1301 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1302 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1305 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1306 -$(Verb) $(RM) -f $(DestArchiveLib)
1314 ###############################################################################
1315 # Tool Build Rules: Build executable tool based on TOOLNAME option
1316 ###############################################################################
1320 #---------------------------------------------------------
1321 # Set up variables for building a tool.
1322 #---------------------------------------------------------
1323 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1325 ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
1327 ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1330 # TOOLALIAS is a name to symlink (or copy) the tool to.
1333 ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1335 ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1339 #---------------------------------------------------------
1341 #---------------------------------------------------------
1343 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1344 # not exporting all of the weak symbols from the binary. This reduces dyld
1345 # startup time by 4x on darwin in some cases.
1346 ifdef TOOL_NO_EXPORTS
1347 ifeq ($(HOST_OS),Darwin)
1349 # Tiger tools don't support this.
1350 ifneq ($(DARWIN_MAJVERS),4)
1351 LD.Flags += -Wl,-exported_symbol,_main
1355 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1356 ifneq ($(ARCH), Mips)
1357 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1362 #---------------------------------------------------------
1363 # Tool Order File Support
1364 #---------------------------------------------------------
1366 ifeq ($(HOST_OS),Darwin)
1367 ifdef TOOL_ORDER_FILE
1369 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1374 #---------------------------------------------------------
1375 # Tool Version Info Support
1376 #---------------------------------------------------------
1378 ifeq ($(HOST_OS),Darwin)
1379 ifdef TOOL_INFO_PLIST
1381 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1383 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1385 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1386 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1387 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1388 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1389 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1390 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1396 #---------------------------------------------------------
1397 # Provide targets for building the tools
1398 #---------------------------------------------------------
1399 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1402 ifneq ($(strip $(ToolBuildPath)),)
1403 -$(Verb) $(RM) -f $(ToolBuildPath)
1405 ifneq ($(strip $(ToolAliasBuildPath)),)
1406 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1410 $(ToolBuildPath): $(ExmplDir)/.dir
1412 $(ToolBuildPath): $(ToolDir)/.dir
1415 ifdef CODESIGN_TOOLS
1416 TOOL_CODESIGN_IDENTITY ?= -
1418 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1419 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1420 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1421 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1422 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1424 $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1425 $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1427 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1428 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1429 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1430 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1431 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1435 ifneq ($(strip $(ToolAliasBuildPath)),)
1436 $(ToolAliasBuildPath): $(ToolBuildPath)
1437 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1438 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1439 $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1440 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1446 $(Echo) Install circumvented with NO_INSTALL
1448 $(Echo) Uninstall circumvented with NO_INSTALL
1452 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1454 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1456 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1458 install-local:: $(DestTool)
1460 $(DestTool): $(ToolBuildPath)
1461 $(Echo) Installing $(BuildMode) $(DestTool)
1462 $(Verb) $(MKDIR) $(ToolBinDir)
1463 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1466 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1467 -$(Verb) $(RM) -f $(DestTool)
1469 # TOOLALIAS install.
1471 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1473 install-local:: $(DestToolAlias)
1475 $(DestToolAlias): $(DestTool)
1476 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1477 $(Verb) $(RM) -f $(DestToolAlias)
1478 $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1481 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1482 -$(Verb) $(RM) -f $(DestToolAlias)
1488 ###############################################################################
1489 # Object Build Rules: Build object files based on sources
1490 ###############################################################################
1492 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1493 ifeq ($(HOST_OS),HP-UX)
1494 DISABLE_AUTO_DEPENDENCIES=1
1497 COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1499 # Provide rule sets for when dependency generation is enabled
1500 ifndef DISABLE_AUTO_DEPENDENCIES
1502 #---------------------------------------------------------
1503 # Create .o files in the ObjDir directory from the .cpp and .c files...
1504 #---------------------------------------------------------
1506 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1507 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1509 # If the build succeeded, move the dependency file over, otherwise
1511 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1512 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1514 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1515 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1516 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1519 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1520 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1521 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1524 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1525 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1526 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1529 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1530 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1531 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1534 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1535 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1536 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1539 # Provide alternate rule sets if dependencies are disabled
1542 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1543 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1544 $(Compile.CXX) $< -o $@
1546 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1547 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1548 $(Compile.CXX) $< -o $@
1550 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1551 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1552 $(Compile.CXX) $< -o $@
1554 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1555 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1556 $(Compile.C) $< -o $@
1558 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1559 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1560 $(Compile.C) $< -o $@
1564 ## Rules for building preprocessed (.i/.ii) outputs.
1565 $(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1566 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1567 $(Verb) $(Preprocess.CXX) $< -o $@
1569 $(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1570 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1571 $(Verb) $(Preprocess.CXX) $< -o $@
1573 $(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1574 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1575 $(Verb) $(Preprocess.CXX) $< -o $@
1577 $(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1578 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1579 $(Verb) $(Preprocess.C) $< -o $@
1581 $(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1582 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1583 $(Verb) $(Preprocess.C) $< -o $@
1586 $(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1587 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1588 $(Compile.CXX) $< -o $@ -S
1590 $(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1591 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1592 $(Compile.CXX) $< -o $@ -S
1594 $(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1595 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1596 $(Compile.CXX) $< -o $@ -S
1598 $(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1599 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1600 $(Compile.C) $< -o $@ -S
1602 $(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1603 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1604 $(Compile.C) $< -o $@ -S
1606 ###############################################################################
1607 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1608 ###############################################################################
1611 TABLEGEN_INC_FILES_COMMON = 1
1614 ifdef TABLEGEN_INC_FILES_COMMON
1616 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1617 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1618 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1620 # INCFiles rule: All of the tblgen generated files are emitted to
1621 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1622 # us to only "touch" the real file if the contents of it change. IOW, if
1623 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1624 # dependencies of the .inc files are, unless the contents of the .inc file
1626 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1627 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1629 endif # TABLEGEN_INC_FILES_COMMON
1633 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1634 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1635 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1636 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1637 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1638 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1639 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1641 # All .inc.tmp files depend on the .td files.
1642 $(INCTMPFiles) : $(TDFiles)
1644 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1645 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1646 $(Echo) "Building $(<F) register info implementation with tblgen"
1647 $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1649 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1650 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1651 $(Echo) "Building $(<F) instruction information with tblgen"
1652 $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1654 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1655 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1656 $(Echo) "Building $(<F) assembly writer with tblgen"
1657 $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1659 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1660 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1661 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1662 $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1664 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1665 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1666 $(Echo) "Building $(<F) assembly matcher with tblgen"
1667 $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1669 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1670 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1671 $(Echo) "Building $(<F) MC code emitter with tblgen"
1672 $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1674 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1675 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1676 $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1677 $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1679 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1680 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1681 $(Echo) "Building $(<F) code emitter with tblgen"
1682 $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1684 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1685 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1686 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1687 $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1689 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1690 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1691 $(Echo) "Building $(<F) disassembly tables with tblgen"
1692 $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1694 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1695 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1696 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1697 $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1699 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1700 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1701 $(Echo) "Building $(<F) subtarget information with tblgen"
1702 $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1704 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1705 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1706 $(Echo) "Building $(<F) calling convention information with tblgen"
1707 $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1709 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1710 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1711 $(Echo) "Building $(<F) intrinsics information with tblgen"
1712 $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1714 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1715 $(Echo) "Building $(<F) decoder tables with tblgen"
1716 $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1718 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1719 $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1720 $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1722 # Dump all the records to <target>.td.expanded. This is useful for debugging.
1723 $(TARGET:%=%.td.expanded): \
1724 %.td.expanded : %.td $(LLVM_TBLGEN) $(TDFiles)
1725 $(Echo) "Building a fully expanded version of $(<F)"
1726 $(Verb) $(LLVMTableGen) -o $(call SYSPATH, $@) $<
1729 -$(Verb) $(RM) -f $(INCFiles) $(TARGET).td.expanded
1733 ###############################################################################
1734 # OTHER RULES: Other rules needed
1735 ###############################################################################
1737 # To create postscript files from dot files...
1738 ifneq ($(DOT),false)
1740 $(DOT) -Tps < $< > $@
1743 $(Echo) "Cannot build $@: The program dot is not installed"
1746 # This rules ensures that header files that are removed still have a rule for
1747 # which they can be "generated." This allows make to ignore them and
1748 # reproduce the dependency lists.
1752 # Define clean-local to clean the current directory. Note that this uses a
1753 # very conservative approach ensuring that empty variables do not cause
1754 # errors or disastrous removal.
1756 ifneq ($(strip $(ObjRootDir)),)
1757 -$(Verb) $(RM) -rf $(ObjRootDir)
1759 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1760 -$(Verb) $(RM) -f *$(SHLIBEXT)
1764 -$(Verb) $(RM) -rf Debug Release Profile
1767 ###############################################################################
1768 # DEPENDENCIES: Include the dependency files if we should
1769 ###############################################################################
1770 ifndef DISABLE_AUTO_DEPENDENCIES
1772 # If its not one of the cleaning targets
1773 ifndef IS_CLEANING_TARGET
1775 # Get the list of dependency files
1776 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1777 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1779 -include $(DependFiles) ""
1785 ###############################################################################
1786 # CHECK: Running the test suite
1787 ###############################################################################
1790 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1791 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1792 $(EchoCmd) Running test suite ; \
1793 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1794 TESTSUITE=$(TESTSUITE) ; \
1796 $(EchoCmd) No Makefile in test directory ; \
1799 $(EchoCmd) No test directory ; \
1802 # An alias dating from when both lit and DejaGNU test runners were used.
1806 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1807 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1808 $(EchoCmd) Running test suite ; \
1809 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1811 $(EchoCmd) No Makefile in test directory ; \
1814 $(EchoCmd) No test directory ; \
1817 ###############################################################################
1818 # UNITTESTS: Running the unittests test suite
1819 ###############################################################################
1822 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1823 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1824 $(EchoCmd) Running unittests test suite ; \
1825 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1827 $(EchoCmd) No Makefile in unittests directory ; \
1830 $(EchoCmd) No unittests directory ; \
1833 ###############################################################################
1834 # DISTRIBUTION: Handle construction of a distribution tarball
1835 ###############################################################################
1837 #------------------------------------------------------------------------
1838 # Define distribution related variables
1839 #------------------------------------------------------------------------
1840 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1841 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1842 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1843 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1844 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1845 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1846 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1847 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1848 Makefile.config.in configure autoconf
1849 DistOther := $(notdir $(wildcard \
1850 $(PROJ_SRC_DIR)/*.h \
1851 $(PROJ_SRC_DIR)/*.td \
1852 $(PROJ_SRC_DIR)/*.def \
1853 $(PROJ_SRC_DIR)/*.ll \
1854 $(PROJ_SRC_DIR)/*.in))
1855 DistSubDirs := $(SubDirs)
1856 DistSources = $(Sources) $(EXTRA_DIST)
1857 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1859 #------------------------------------------------------------------------
1860 # We MUST build distribution with OBJ_DIR != SRC_DIR
1861 #------------------------------------------------------------------------
1862 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1863 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1864 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1868 #------------------------------------------------------------------------
1869 # Prevent attempt to run dist targets from anywhere but the top level
1870 #------------------------------------------------------------------------
1872 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1873 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1876 #------------------------------------------------------------------------
1877 # Provide the top level targets
1878 #------------------------------------------------------------------------
1880 dist-gzip:: $(DistTarGZip)
1882 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1883 $(Echo) Packing gzipped distribution tar file.
1884 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1885 $(GZIP) -c > "$(DistTarGZip)"
1887 dist-bzip2:: $(DistTarBZ2)
1889 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1890 $(Echo) Packing bzipped distribution tar file.
1891 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1892 $(BZIP2) -c >$(DistTarBZ2)
1894 dist-zip:: $(DistZip)
1896 $(DistZip) : $(TopDistDir)/.makedistdir
1897 $(Echo) Packing zipped distribution file.
1898 $(Verb) rm -f $(DistZip)
1899 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1901 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1902 $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1904 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1906 dist-check:: $(DistTarGZip)
1907 $(Echo) Checking distribution tar file.
1908 $(Verb) if test -d $(DistCheckDir) ; then \
1909 $(RM) -rf $(DistCheckDir) ; \
1911 $(Verb) $(MKDIR) $(DistCheckDir)
1912 $(Verb) cd $(DistCheckDir) && \
1913 $(MKDIR) $(DistCheckDir)/build && \
1914 $(MKDIR) $(DistCheckDir)/install && \
1915 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1917 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1918 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1921 $(MAKE) unittests && \
1922 $(MAKE) install && \
1923 $(MAKE) uninstall && \
1924 $(MAKE) dist-clean && \
1925 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1928 $(Echo) Cleaning distribution files
1929 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1934 #------------------------------------------------------------------------
1935 # Provide the recursive distdir target for building the distribution directory
1936 #------------------------------------------------------------------------
1937 distdir: $(DistDir)/.makedistdir
1938 $(DistDir)/.makedistdir: $(DistSources)
1939 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1940 if test -d "$(DistDir)" ; then \
1941 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1944 $(EchoCmd) Removing old $(DistDir) ; \
1945 $(RM) -rf $(DistDir); \
1946 $(EchoCmd) Making 'all' to verify build ; \
1947 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1949 $(Echo) Building Distribution Directory $(DistDir)
1950 $(Verb) $(MKDIR) $(DistDir)
1951 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1952 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1953 for file in $(DistFiles) ; do \
1955 $(PROJ_SRC_DIR)/*) \
1956 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1958 $(PROJ_SRC_ROOT)/*) \
1959 file=`echo "$$file" | \
1960 sed "s#^$$srcrootstrip/##"` \
1963 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1964 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1965 from_dir="$(PROJ_SRC_DIR)" ; \
1966 elif test -f "$$file" || test -d "$$file" ; then \
1969 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1970 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1971 to_dir="$(DistDir)/$$dir"; \
1972 $(MKDIR) "$$to_dir" ; \
1974 to_dir="$(DistDir)"; \
1976 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1977 if test -n "$$mid_dir" ; then \
1978 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1980 if test -d "$$from_dir/$$file"; then \
1981 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1982 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1983 cd $(PROJ_SRC_DIR) ; \
1984 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1985 ( cd $$to_dir ; $(TAR) xf - ) ; \
1986 cd $(PROJ_OBJ_DIR) ; \
1989 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1990 ( cd $$to_dir ; $(TAR) xf - ) ; \
1991 cd $(PROJ_OBJ_DIR) ; \
1993 elif test -f "$$from_dir/$$file" ; then \
1994 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1995 elif test -L "$$from_dir/$$file" ; then \
1996 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1997 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1998 $(EchoCmd) "===== WARNING: Distribution Source " \
1999 "$$from_dir/$$file Not Found!" ; \
2000 elif test "$(Verb)" != '@' ; then \
2001 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
2004 $(Verb) for subdir in $(DistSubDirs) ; do \
2005 if test "$$subdir" \!= "." ; then \
2006 new_distdir="$(DistDir)/$$subdir" ; \
2007 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
2008 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
2009 DistDir="$$new_distdir" distdir ) || exit 1; \
2012 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2013 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2014 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2015 -name .svn \) -print` ;\
2016 $(MAKE) dist-hook ; \
2017 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2018 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2019 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2020 -o ! -type d ! -perm -444 -exec \
2021 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2022 || chmod -R a+r $(DistDir) ; \
2025 # This is invoked by distdir target, define it as a no-op to avoid errors if not
2031 ###############################################################################
2032 # TOP LEVEL - targets only to apply at the top level directory
2033 ###############################################################################
2037 #------------------------------------------------------------------------
2038 # Install support for the project's include files:
2039 #------------------------------------------------------------------------
2042 $(Echo) Install circumvented with NO_INSTALL
2044 $(Echo) Uninstall circumvented with NO_INSTALL
2047 $(Echo) Installing include files
2048 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2049 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2050 cd $(PROJ_SRC_ROOT)/include && \
2051 for hdr in `find . -type f \
2052 '(' -name LICENSE.TXT \
2057 ')' -print | grep -v CVS | \
2058 grep -v .svn` ; do \
2059 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2060 if test \! -d "$$instdir" ; then \
2061 $(EchoCmd) Making install directory $$instdir ; \
2062 $(MKDIR) $$instdir ;\
2064 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2067 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2068 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2069 cd $(PROJ_OBJ_ROOT)/include && \
2070 for hdr in `find . -type f \
2071 '(' -name LICENSE.TXT \
2076 ')' -print | grep -v CVS | \
2077 grep -v .svn` ; do \
2078 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2079 if test \! -d "$$instdir" ; then \
2080 $(EchoCmd) Making install directory $$instdir ; \
2081 $(MKDIR) $$instdir ;\
2083 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2089 $(Echo) Uninstalling include files
2090 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2091 cd $(PROJ_SRC_ROOT)/include && \
2092 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2093 '!' '(' -name '*~' -o -name '.#*' \
2094 -o -name '*.in' ')' -print ')' | \
2095 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2096 cd $(PROJ_SRC_ROOT)/include && \
2097 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2098 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2104 @echo searching for overlength lines in files: $(Sources)
2107 egrep -n '.{81}' $(Sources) /dev/null
2110 @echo searching for tabs in files: $(Sources)
2113 egrep -n ' ' $(Sources) /dev/null
2116 @ls -l $(LibDir) | awk '\
2117 BEGIN { sum = 0; } \
2119 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2120 @ls -l $(ToolDir) | awk '\
2121 BEGIN { sum = 0; } \
2123 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2124 #------------------------------------------------------------------------
2125 # Print out the directories used for building
2126 #------------------------------------------------------------------------
2128 $(Echo) "BuildMode : " '$(BuildMode)'
2129 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2130 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2131 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2132 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2133 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2134 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2135 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2136 $(Echo) "PROJ_internal_prefix : " '$(PROJ_internal_prefix)'
2137 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2138 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2139 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
2140 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
2141 $(Echo) "UserTargets : " '$(UserTargets)'
2142 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2143 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2144 $(Echo) "ObjDir : " '$(ObjDir)'
2145 $(Echo) "LibDir : " '$(LibDir)'
2146 $(Echo) "ToolDir : " '$(ToolDir)'
2147 $(Echo) "ExmplDir : " '$(ExmplDir)'
2148 $(Echo) "Sources : " '$(Sources)'
2149 $(Echo) "TDFiles : " '$(TDFiles)'
2150 $(Echo) "INCFiles : " '$(INCFiles)'
2151 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
2152 $(Echo) "PreConditions: " '$(PreConditions)'
2153 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2154 $(Echo) "Compile.C : " '$(Compile.C)'
2155 $(Echo) "Archive : " '$(Archive)'
2156 $(Echo) "YaccFiles : " '$(YaccFiles)'
2157 $(Echo) "LexFiles : " '$(LexFiles)'
2158 $(Echo) "Module : " '$(Module)'
2159 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2160 $(Echo) "SubDirs : " '$(SubDirs)'
2161 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2162 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2167 # General debugging rule, use 'make dbg-print-XXX' to print the
2168 # definition, value and origin of XXX.
2170 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))