]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - Makefile.rules
DwarfDebug: Only unique retained types instead of all types.
[opencl/llvm.git] / Makefile.rules
1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===------------------------------------------------------------------------===#
9 #
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.
12 #
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 \
23                     unitcheck
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 \
28                     dist-zip unittests
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 #--------------------------------------------------------------------
39 VPATH=$(PROJ_SRC_DIR)
41 #--------------------------------------------------------------------
42 # Reset the list of suffixes we know how to build.
43 #--------------------------------------------------------------------
44 .SUFFIXES:
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 #--------------------------------------------------------------------
58 $(UserTargets)::
60 #------------------------------------------------------------------------
61 # LLVMBuild Integration
62 #------------------------------------------------------------------------
63 #
64 # We use llvm-build to generate all the data required by the Makefile based
65 # build system in one swoop:
66 #
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
69 #    project.
70 #
71 #  - We generate the library table used by llvm-config.
72 #
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)
93 endif
95 # The rule to create the LLVMBuild Makefile fragment as well as the llvm-config
96 # library table.
97 #
98 # Note that this target gets its real dependencies generated for us by
99 # llvm-build.
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.
126 ifeq ($(LEVEL),.)
127 LLVMBUILD_INCLUDE_DEPENDENCIES := 1
129 # Clean the generated makefile fragment at the top-level.
130 clean-local::
131         -$(Verb) $(RM) -f $(LLVMBuildMakeFrags)
132 endif
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)
151 endif
153 ifneq ($(MakefileConfigIn),)
154 PreConditions      += $(MakefileConfig)
155 endif
157 preconditions: $(PreConditions)
159 #------------------------------------------------------------------------
160 # Make sure the BUILT_SOURCES are built first
161 #------------------------------------------------------------------------
162 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
164 clean-all-local::
165 ifneq ($(strip $(BUILT_SOURCES)),)
166         -$(Verb) $(RM) -f $(BUILT_SOURCES)
167 endif
169 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
170 spotless:
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 ; \
177           $(RM) -rf * ; \
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) ; \
185         else \
186           $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
187         fi
188 else
189 spotless:
190         $(EchoCmd) "spotless target not supported for objdir == srcdir"
191 endif
193 $(BUILT_SOURCES) : $(ObjMakefiles)
195 #------------------------------------------------------------------------
196 # Make sure we're not using a stale configuration
197 #------------------------------------------------------------------------
198 reconfigure:
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
218 endif
220 ifneq ($(MakefileCommonIn),)
221 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
222         $(Echo) Regenerating $@
223         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
224 endif
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 #------------------------------------------------------------------------
230 ifndef PROJ_MAKEFILE
231 PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
232 endif
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
243 # taken care of.
244 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
245         @case '$?' in \
246           *Makefile.rules) ;; \
247           *.in) ;; \
248           *) $(EchoCmd) "Updating $(@F)" ; \
249              $(MKDIR) $(@D) ; \
250              $(CP) -f $< $@ ;; \
251         esac
253 endif
255 #------------------------------------------------------------------------
256 # Set up the basic dependencies
257 #------------------------------------------------------------------------
258 $(UserTargets):: $(PreConditions)
260 all:: all-local
261 clean:: clean-local
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))),)
274   IS_CLEANING_TARGET=1
275 endif
277 #--------------------------------------------------------------------
278 # Variables derived from configuration we are building
279 #--------------------------------------------------------------------
281 CPP.Defines :=
282 ifeq ($(ENABLE_OPTIMIZED),1)
283   BuildMode := Release
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
287   endif
289   CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
290   C.Flags   += $(OPTIMIZE_OPTION) $(OmitFramePointer)
291   LD.Flags  += $(OPTIMIZE_OPTION)
292   ifdef DEBUG_SYMBOLS
293     BuildMode := $(BuildMode)+Debug
294     CXX.Flags += -g
295     C.Flags   += -g
296     KEEP_SYMBOLS := 1
297   endif
298 else
299   ifdef NO_DEBUG_SYMBOLS
300     BuildMode := Unoptimized
301     CXX.Flags +=
302     C.Flags   +=
303     KEEP_SYMBOLS := 1
304   else
305     BuildMode := Debug
306     ifeq ($(ENABLE_SPLIT_DWARF), 1)
307     CXX.Flags += -gsplit-dwarf
308     C.Flags   += -gsplit-dwarf
309     else
310     CXX.Flags += -g
311     C.Flags   += -g
312     endif
313     KEEP_SYMBOLS := 1
314   endif
315 endif
317 ifeq ($(ENABLE_LIBCPP),1)
318   CXX.Flags +=  -stdlib=libc++
319   LD.Flags +=  -stdlib=libc++
320 endif
322 ifeq ($(ENABLE_CXX1Y),1)
323   CXX.Flags += -std=c++1y
324 else
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
329  else
330     CXX.Flags += -std=c++11
331  endif
332 endif
334 ifeq ($(ENABLE_WERROR),1)
335   CXX.Flags += -Werror
336   C.Flags += -Werror
337 endif
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
344   KEEP_SYMBOLS := 1
345 endif
347 ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
348     CXX.Flags += -fvisibility-inlines-hidden
349 endif
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
354   REQUIRES_RTTI := 1
355 endif
357 # IF REQUIRES_EH=1 is specified then don't disable exceptions
358 ifndef REQUIRES_EH
359   CXX.Flags += -fno-exceptions
360 else
361   # If the library requires EH, it also requires RTTI.
362   REQUIRES_RTTI := 1
363 endif
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))
369 endif
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
374 endif
376 ifeq ($(ENABLE_COVERAGE),1)
377   BuildMode := $(BuildMode)+Coverage
378   CXX.Flags += -ftest-coverage -fprofile-arcs
379   C.Flags   += -ftest-coverage -fprofile-arcs
380 endif
382 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
383 # then disable assertions by defining the appropriate preprocessor symbols.
384 ifeq ($(DISABLE_ASSERTIONS),1)
385   CPP.Defines += -DNDEBUG
386 else
387   BuildMode := $(BuildMode)+Asserts
388   CPP.Defines += -D_DEBUG
389 endif
391 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
392 # configured), then enable expensive checks by defining the
393 # appropriate preprocessor symbols.
394 ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
395   BuildMode := $(BuildMode)+Checks
396   CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
397 endif
399 # LOADABLE_MODULE implies several other things so we force them to be
400 # defined/on.
401 ifdef LOADABLE_MODULE
402   SHARED_LIBRARY := 1
403   LINK_LIBS_IN_SHARED := 1
404 endif
406 ifdef SHARED_LIBRARY
407   ENABLE_PIC := 1
408   PIC_FLAG = "(PIC)"
409 endif
411 ifeq ($(ENABLE_PIC),1)
412   ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
413     # Nothing. Win32 defaults to PIC and warns when given -fPIC
414   else
415     ifeq ($(HOST_OS),Darwin)
416       # Common symbols not allowed in dylib files
417       CXX.Flags += -fno-common
418       C.Flags   += -fno-common
419     else
420       # Linux and others; pass -fPIC
421       CXX.Flags += -fPIC
422       C.Flags   += -fPIC
423     endif
424   endif
425 else
426   ifeq ($(HOST_OS),Darwin)
427       CXX.Flags += -mdynamic-no-pic
428       C.Flags   += -mdynamic-no-pic
429   endif
430 endif
432 # Support makefile variable to disable any kind of timestamp/non-deterministic
433 # info from being used in the build.
434 ifeq ($(ENABLE_TIMESTAMPS),1)
435   DOTDIR_TIMESTAMP_COMMAND := $(DATE)
436 else
437   DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
438 endif
440 ifeq ($(HOST_OS),MingW)
441   # Work around PR4957
442   CPP.Defines += -D__NO_CTYPE_INLINE
443   ifeq ($(LLVM_CROSS_COMPILING),1)
444     # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
445     ifdef TOOLNAME
446       LD.Flags += -Wl,--allow-multiple-definition
447     endif
448   endif
449 endif
451 CXX.Flags     += -Woverloaded-virtual
452 CPP.BaseFlags += $(CPP.Defines)
453 AR.Flags      := cru
455 # Make Floating point IEEE compliant on Alpha.
456 ifeq ($(ARCH),Alpha)
457   CXX.Flags     += -mieee
458   CPP.BaseFlags += -mieee
459 ifeq ($(ENABLE_PIC),0)
460   CXX.Flags     += -fPIC
461   CPP.BaseFlags += -fPIC
462 endif
464   LD.Flags += -Wl,--no-relax
465 endif
467 # GNU ld/PECOFF accepts but ignores them below;
468 #   --version-script
469 #   --export-dynamic
470 #   --rpath
471 # FIXME: autoconf should be aware of them.
472 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
473   HAVE_LINK_VERSION_SCRIPT := 0
474   RPATH :=
475   RDYNAMIC := -Wl,--export-all-symbols
476 endif
478 #--------------------------------------------------------------------
479 # Directory locations
480 #--------------------------------------------------------------------
481 TargetMode :=
482 ifeq ($(LLVM_CROSS_COMPILING),1)
483   BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
484 endif
486 ObjRootDir  := $(PROJ_OBJ_DIR)/$(BuildMode)
487 ObjDir      := $(ObjRootDir)
488 LibDir      := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
489 ToolDir     := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
490 ExmplDir    := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
491 LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
492 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
493 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
495 #--------------------------------------------------------------------
496 # Locations of shared libraries
497 #--------------------------------------------------------------------
499 SharedPrefix     := lib
500 SharedLibDir     := $(LibDir)
501 LLVMSharedLibDir := $(LLVMLibDir)
503 # Win32.DLL prefers to be located on the "PATH" of binaries.
504 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
505   SharedLibDir     := $(ToolDir)
506   LLVMSharedLibDir := $(LLVMToolDir)
508   ifeq ($(HOST_OS),Cygwin)
509     SharedPrefix  := cyg
510   else
511     SharedPrefix  :=
512   endif
513 endif
515 #--------------------------------------------------------------------
516 # Full Paths To Compiled Tools and Utilities
517 #--------------------------------------------------------------------
518 EchoCmd  := $(ECHO) llvm[$(MAKELEVEL)]:
519 ifdef BUILD_DIRS_ONLY
520 EchoCmd  := $(EchoCmd) "(build tools)":
521 endif
523 Echo     := @$(EchoCmd)
524 ifndef LLVMAS
525 LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
526 endif
527 ifndef LLVM_TBLGEN
528   ifeq ($(LLVM_CROSS_COMPILING),1)
529     LLVM_TBLGEN   := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
530   else
531     LLVM_TBLGEN   := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
532   endif
533 endif
534 ifeq ($(LLVM_CROSS_COMPILING),1)
535   LLVM_CONFIG := $(BuildLLVMToolDir)/llvm-config$(BUILD_EXEEXT)
536 else
537   LLVM_CONFIG := $(LLVMToolDir)/llvm-config$(EXEEXT)
538 endif
539 ifndef LLVMDIS
540 LLVMDIS  := $(LLVMToolDir)/llvm-dis$(EXEEXT)
541 endif
542 ifndef LLI
543 LLI      := $(LLVMToolDir)/lli$(EXEEXT)
544 endif
545 ifndef LLC
546 LLC      := $(LLVMToolDir)/llc$(EXEEXT)
547 endif
548 ifndef LOPT
549 LOPT     := $(LLVMToolDir)/opt$(EXEEXT)
550 endif
551 ifndef LBUGPOINT
552 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
553 endif
554 ifndef LLVMLINK
555 LLVMLINK      := $(LLVMToolDir)/llvm-link$(EXEEXT)
556 endif
558 #--------------------------------------------------------------------
559 # Adjust to user's request
560 #--------------------------------------------------------------------
562 ifeq ($(HOST_OS),Darwin)
563  ifdef MACOSX_DEPLOYMENT_TARGET
564   DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
565  else
566   DARWIN_VERSION := `sw_vers -productVersion`
567  endif
568   # Strip a number like 10.4.7 to 10.4
569   DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/')
570   # Get "4" out of 10.4 for later pieces in the makefile.
571   DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/')
573   LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
574   SharedLinkOptions := -dynamiclib
575   ifdef DEPLOYMENT_TARGET
576     SharedLinkOptions += $(DEPLOYMENT_TARGET)
577   else
578     ifneq ($(ARCH),ARM)
579       SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
580     endif
581   endif
582 else
583   SharedLinkOptions=-shared
584 endif
586 ifeq ($(TARGET_OS),Darwin)
587   ifdef DEPLOYMENT_TARGET
588     TargetCommonOpts += $(DEPLOYMENT_TARGET)
589   else
590     ifneq ($(ARCH),ARM)
591       TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
592     endif
593   endif
594 endif
596 ifdef SHARED_LIBRARY
597 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
598 ifneq ($(HOST_OS),Darwin)
599   LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
600 else
601   LD.Flags += -Wl,-install_name  -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
602 endif
603 endif
604 endif
606 ifdef TOOL_VERBOSE
607   C.Flags += -v
608   CXX.Flags += -v
609   LD.Flags += -v
610   VERBOSE := 1
611 endif
613 # Adjust settings for verbose mode
614 ifndef VERBOSE
615   Verb := @
616   AR.Flags += >/dev/null 2>/dev/null
617   ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
618 else
619   ConfigureScriptFLAGS :=
620 endif
622 # By default, strip symbol information from executable
623 ifndef KEEP_SYMBOLS
624   Strip := $(PLATFORMSTRIPOPTS)
625   StripWarnMsg := "(without symbols)"
626   Install.StripFlag += -s
627 endif
629 # By default, strip dead symbols at link time
630 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
631 ifneq ($(HOST_OS),Darwin)
632 ifneq ($(HOST_ARCH),Mips)
633   CXX.Flags += -ffunction-sections -fdata-sections
634 endif
635 endif
636 endif
637 ifndef NO_DEAD_STRIP
638   ifeq ($(HOST_OS),Darwin)
639     LD.Flags += -Wl,-dead_strip
640   else
641     ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
642       LD.Flags += -Wl,--gc-sections
643     endif
644   endif
645 endif
647 # Adjust linker flags for building an executable
648 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
649   ifndef TOOL_NO_EXPORTS
650     LD.Flags += $(RDYNAMIC)
651   endif
652   ifneq ($(HOST_OS), Darwin)
653     ifdef TOOLNAME
654       LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
655     endif
656   else
657     ifneq ($(DARWIN_MAJVERS),4)
658       LD.Flags += $(RPATH) -Wl,@executable_path/../lib
659     endif
660     ifeq ($(RC_XBS),YES)
661       TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
662       LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
663     endif
664   endif
665 endif
668 #----------------------------------------------------------
669 # Options To Invoke Tools
670 #----------------------------------------------------------
672 ifdef EXTRA_LD_OPTIONS
673 LD.Flags += $(EXTRA_LD_OPTIONS)
674 endif
676 ifndef NO_PEDANTIC
677 CompileCommonOpts += -pedantic -Wno-long-long
678 endif
679 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
680                      $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
681                      $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
682                      $(NO_MISSING_FIELD_INITIALIZERS)
683 # Enable cast-qual for C++; the workaround is to use const_cast.
684 CXX.Flags += -Wcast-qual
686 ifeq ($(HOST_OS),HP-UX)
687   CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
688 endif
690 # If we are building a universal binary on Mac OS X, pass extra options.  This
691 # is useful to people that want to link the LLVM libraries into their universal
692 # apps.
694 # The following can be optionally specified:
695 #   UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
696 #      For Mac OS X 10.4 Intel machines, the traditional one is:
697 #      UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
698 #   UNIVERSAL_ARCH can be optionally specified to be a list of architectures
699 #      to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64".  This defaults to
700 #      i386/ppc only.
701 ifdef UNIVERSAL
702   ifndef UNIVERSAL_ARCH
703     UNIVERSAL_ARCH := i386 ppc
704   endif
705   UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
706   TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
707   ifdef UNIVERSAL_SDK_PATH
708     TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
709   endif
711   # Building universal cannot compute dependencies automatically.
712   DISABLE_AUTO_DEPENDENCIES=1
713 else
714   ifeq ($(TARGET_OS),Darwin)
715     ifeq ($(ARCH),x86_64)
716       TargetCommonOpts = -m64
717     else
718       ifeq ($(ARCH),x86)
719         TargetCommonOpts = -m32
720       endif
721     endif
722   endif
723 endif
725 ifeq ($(HOST_OS),SunOS)
726 CPP.BaseFlags += -include llvm/Support/Solaris.h
727 endif
729 ifeq ($(HOST_OS),AuroraUX)
730 CPP.BaseFlags += -include llvm/Support/Solaris.h
731 endif # !HOST_OS - AuroraUX.
733 # On Windows, SharedLibDir != LibDir. The order is important.
734 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
735   LD.Flags    += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
736 else
737   LD.Flags    += -L$(LibDir) -L$(LLVMLibDir)
738 endif
740 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
741 # All -I flags should go here, so that they don't confuse llvm-config.
742 CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
743                  $(patsubst %,-I%/include,\
744                  $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
745                  $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
746                  $(CPP.BaseFlags)
748 ifeq ($(INCLUDE_BUILD_DIR),1)
749   CPP.Flags   += -I$(ObjDir)
750 endif
752 # SHOW_DIAGNOSTICS support.
753 ifeq ($(SHOW_DIAGNOSTICS),1)
754   Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
755                           CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
756 else
757   Compile.Wrapper :=
758 endif
760 Compile.C     = $(Compile.Wrapper) \
761                   $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
762                 $(TargetCommonOpts) $(CompileCommonOpts) -c
763 Compile.CXX   = $(Compile.Wrapper) \
764                   $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
765                 $(TargetCommonOpts) $(CompileCommonOpts) -c
766 Preprocess.CXX= $(Compile.Wrapper) \
767                   $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
768                 $(CompileCommonOpts) $(CXX.Flags) -E
769 Link          = $(Compile.Wrapper) \
770                   $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
771                 $(TargetCommonOpts) $(Strip)
773 Preprocess.C  = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
774                 $(TargetCommonOpts) $(CompileCommonOpts) -E
776 ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755
777 ScriptInstall = $(INSTALL) -m 0755
778 DataInstall   = $(INSTALL) -m 0644
780 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
781 # paths. In this case, the SYSPATH function (defined in
782 # Makefile.config) transforms Unix paths into Windows paths.
783 TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
784                 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
785                 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
786                 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
787 LLVMTableGen  = $(LLVM_TBLGEN) $(TableGen.Flags)
789 Archive       = $(AR) $(AR.Flags)
790 ifdef RANLIB
791 Ranlib        = $(RANLIB)
792 else
793 Ranlib        = ranlib
794 endif
796 AliasTool     = ln -sf
798 #----------------------------------------------------------
799 # Get the list of source files and compute object file
800 # names from them.
801 #----------------------------------------------------------
803 ifndef SOURCES
804   Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
805              $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
806 else
807   Sources := $(SOURCES)
808 endif
810 ifdef BUILT_SOURCES
811 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
812 endif
814 BaseNameSources := $(sort $(basename $(Sources)))
815 SourceDirs := $(sort $(dir $(Sources)))
817 ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
818 ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
820 #----------------------------------------------------------
821 # For Mingw MSYS bash and Python/w32:
823 # $(ECHOPATH) prints DOSish pathstring.
824 #   ex) $(ECHOPATH) /include/sys/types.h
825 #   --> C:/mingw/include/sys/types.h
826 # built-in "echo" does not transform path to DOSish path.
828 # FIXME: It would not be needed when MSYS's python
829 # were provided.
830 #----------------------------------------------------------
832 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
833   ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
834 else
835   ECHOPATH := $(Verb)$(ECHO)
836 endif
838 ###############################################################################
839 # DIRECTORIES: Handle recursive descent of directory structure
840 ###############################################################################
842 #---------------------------------------------------------
843 # Provide rules to make install dirs. This must be early
844 # in the file so they get built before dependencies
845 #---------------------------------------------------------
847 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
848         $(Verb) $(MKDIR) $@
850 # To create other directories, as needed, and timestamp their creation
851 %/.dir:
852         $(Verb) $(MKDIR) $* > /dev/null
853         $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
855 .PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
856 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
858 #---------------------------------------------------------
859 # Collect the object directories (as there may be more
860 # than one if the source code is spread across
861 # subdirectories).
862 #---------------------------------------------------------
864 OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
865 .PRECIOUS: $(OBJECT_DIRS)
867 #---------------------------------------------------------
868 # Handle the DIRS options for sequential construction
869 #---------------------------------------------------------
871 SubDirs :=
872 ifdef DIRS
873 SubDirs += $(DIRS)
875 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
876 $(RecursiveTargets)::
877         $(Verb) for dir in $(DIRS); do \
878           if ([ ! -f $$dir/Makefile ] || \
879               command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
880             $(MKDIR) $$dir; \
881             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
882           fi; \
883           ($(MAKE) -C $$dir $@ ) || exit 1; \
884         done
885 else
886 $(RecursiveTargets)::
887         $(Verb) for dir in $(DIRS); do \
888           ($(MAKE) -C $$dir $@ ) || exit 1; \
889         done
890 endif
892 endif
894 #---------------------------------------------------------
895 # Handle the EXPERIMENTAL_DIRS options ensuring success
896 # after each directory is built.
897 #---------------------------------------------------------
898 ifdef EXPERIMENTAL_DIRS
899 $(RecursiveTargets)::
900         $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
901           if ([ ! -f $$dir/Makefile ] || \
902               command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
903             $(MKDIR) $$dir; \
904             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
905           fi; \
906           ($(MAKE) -C $$dir $@ ) || exit 0; \
907         done
908 endif
910 #-----------------------------------------------------------
911 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
912 #-----------------------------------------------------------
913 ifdef OPTIONAL_PARALLEL_DIRS
914   PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
915 endif
917 #-----------------------------------------------------------
918 # Handle the PARALLEL_DIRS options for parallel construction
919 #-----------------------------------------------------------
920 ifdef PARALLEL_DIRS
922 SubDirs += $(PARALLEL_DIRS)
924 # Unfortunately, this list must be maintained if new recursive targets are added
925 all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
926 clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
927 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
928 install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
929 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
930 install-bytecode  :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
931 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
933 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
935 $(ParallelTargets) :
936         $(Verb) \
937           SD=$(PROJ_SRC_DIR)/$(@D); \
938           DD=$(@D); \
939           if [ ! -f $$SD/Makefile ]; then \
940             SD=$(@D); \
941             DD=$(notdir $(@D)); \
942           fi; \
943           if ([ ! -f $$DD/Makefile ] || \
944                     command test $$DD/Makefile -ot \
945                       $$SD/Makefile ); then \
946           $(MKDIR) $$DD; \
947           $(CP) $$SD/Makefile $$DD/Makefile; \
948         fi; \
949         $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
950 endif
952 #---------------------------------------------------------
953 # Handle the OPTIONAL_DIRS options for directores that may
954 # or may not exist.
955 #---------------------------------------------------------
956 ifdef OPTIONAL_DIRS
958 SubDirs += $(OPTIONAL_DIRS)
960 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
961 $(RecursiveTargets)::
962         $(Verb) for dir in $(OPTIONAL_DIRS); do \
963           if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
964             if ([ ! -f $$dir/Makefile ] || \
965                 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
966               $(MKDIR) $$dir; \
967               $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
968             fi; \
969             ($(MAKE) -C$$dir $@ ) || exit 1; \
970           fi \
971         done
972 else
973 $(RecursiveTargets)::
974         $(Verb) for dir in $(OPTIONAL_DIRS); do \
975           if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
976             ($(MAKE) -C$$dir $@ ) || exit 1; \
977           fi \
978         done
979 endif
980 endif
982 #---------------------------------------------------------
983 # Handle the CONFIG_FILES options
984 #---------------------------------------------------------
985 ifdef CONFIG_FILES
987 ifdef NO_INSTALL
988 install-local::
989         $(Echo) Install circumvented with NO_INSTALL
990 uninstall-local::
991         $(Echo) UnInstall circumvented with NO_INSTALL
992 else
993 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
994         $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
995         $(Verb)for file in $(CONFIG_FILES); do \
996           if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
997             $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
998           elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
999             $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
1000           else \
1001             $(ECHO) Error: cannot find config file $${file}. ; \
1002           fi \
1003         done
1005 uninstall-local::
1006         $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
1007         $(Verb)for file in $(CONFIG_FILES); do \
1008           $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
1009         done
1010 endif
1012 endif
1014 ###############################################################################
1015 # Set up variables for building libraries
1016 ###############################################################################
1018 #---------------------------------------------------------
1019 # Define various command line options pertaining to the
1020 # libraries needed when linking. There are "Proj" libs
1021 # (defined by the user's project) and "LLVM" libs (defined
1022 # by the LLVM project).
1023 #---------------------------------------------------------
1025 ifdef USEDLIBS
1026 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1027 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
1028 ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1029 ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1030 endif
1032 ifdef LLVMLIBS
1033 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1034 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1035 LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1036 LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1037 endif
1039 # Loadable module for Win32 requires all symbols resolved for linking.
1040 # Then all symbols in LLVM.dll will be available.
1041 ifeq ($(ENABLE_SHARED),1)
1042   ifdef LOADABLE_MODULE
1043     ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1044       LINK_COMPONENTS += all
1045     endif
1046   endif
1047 endif
1049 ifndef IS_CLEANING_TARGET
1050 ifdef LINK_COMPONENTS
1052 # If LLVM_CONFIG doesn't exist, build it.  This can happen if you do a make
1053 # clean in tools, then do a make in tools (instead of at the top level).
1054 $(LLVM_CONFIG):
1055         @echo "*** llvm-config doesn't exist - rebuilding it."
1056         @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1058 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1060 ifeq ($(ENABLE_SHARED), 1)
1061 # We can take the "auto-import" feature to get rid of using dllimport.
1062 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1063 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1064                    -L $(SharedLibDir)
1065 endif
1066 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1067 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1068 else
1070 ifndef NO_LLVM_CONFIG
1071 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1072 ifeq ($(LLVMConfigLibs),Error)
1073 $(error llvm-config --libs failed)
1074 endif
1075 LLVMLibsOptions += $(LLVMConfigLibs)
1076 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1077 ifeq ($(LLVMConfigLibfiles),Error)
1078 $(error llvm-config --libfiles failed)
1079 endif
1080 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1081 endif
1083 endif
1084 endif
1085 endif
1087 # Set up the library exports file.
1088 ifdef EXPORTED_SYMBOL_FILE
1090 # First, set up the native export file, which may differ from the source
1091 # export file.
1093 ifeq ($(HOST_OS),Darwin)
1094 # Darwin convention prefixes symbols with underscores.
1095 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1096 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1097         $(Verb) sed -e 's/^/_/' < $< > $@
1098 clean-local::
1099         -$(Verb) $(RM) -f $(NativeExportsFile)
1100 else
1101 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1102 # Gold and BFD ld require a version script rather than a plain list.
1103 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1104 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1105         $(Verb) echo "{" > $@
1106         $(Verb) grep -q '[[:alnum:]_]' $< && echo "  global:" >> $@ || :
1107         $(Verb) sed -e 's/$$/;/' -e 's/^/    /' < $< >> $@
1108 ifneq ($(HOST_OS),OpenBSD)
1109         $(Verb) echo "  local: *;" >> $@
1110 endif
1111         $(Verb) echo "};" >> $@
1112 clean-local::
1113         -$(Verb) $(RM) -f $(NativeExportsFile)
1114 else
1115 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1116 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1117 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1118 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1119         $(Echo) Generating $(notdir $@)
1120         $(Verb) $(ECHO) "EXPORTS" > $@
1121         $(Verb) $(CAT) $< >> $@
1122 clean-local::
1123         -$(Verb) $(RM) -f $(NativeExportsFile)
1124 else
1125 # Default behavior: just use the exports file verbatim.
1126 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1127 endif
1128 endif
1129 endif
1131 # Now add the linker command-line options to use the native export file.
1133 # Darwin
1134 ifeq ($(HOST_OS),Darwin)
1135 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1136 endif
1138 # gold, bfd ld, etc.
1139 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1140 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1141 endif
1143 # Windows
1144 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1145 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1146 SharedLinkOptions += $(NativeExportsFile)
1147 endif
1149 endif
1151 ###############################################################################
1152 # Library Build Rules: Four ways to build a library
1153 ###############################################################################
1155 # if we're building a library ...
1156 ifdef LIBRARYNAME
1158 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1159 LIBRARYNAME := $(strip $(LIBRARYNAME))
1160 LIBRARYALIASNAME := $(strip $(LIBRARYALIASNAME))
1161 ifdef LOADABLE_MODULE
1162 BaseLibName.A  := $(LIBRARYNAME).a
1163 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1164 BaseAliasName.SO := $(LIBRARYALIASNAME)$(SHLIBEXT)
1165 else
1166 BaseLibName.A  := lib$(LIBRARYNAME).a
1167 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1168 BaseAliasName.SO := $(SharedPrefix)$(LIBRARYALIASNAME)$(SHLIBEXT)
1169 endif
1170 LibName.A  := $(LibDir)/$(BaseLibName.A)
1171 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1172 AliasName.SO := $(SharedLibDir)/$(BaseAliasName.SO)
1173 LibName.O  := $(LibDir)/$(LIBRARYNAME).o
1175 #---------------------------------------------------------
1176 # Shared Library Targets:
1177 #   If the user asked for a shared library to be built
1178 #   with the SHARED_LIBRARY variable, then we provide
1179 #   targets for building them.
1180 #---------------------------------------------------------
1181 ifdef SHARED_LIBRARY
1183 all-local:: $(LibName.SO)
1185 ifdef EXPORTED_SYMBOL_FILE
1186 $(LibName.SO): $(NativeExportsFile)
1187 endif
1189 ifdef LINK_LIBS_IN_SHARED
1190 ifdef LOADABLE_MODULE
1191 SharedLibKindMessage := "Loadable Module"
1192 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1193 else
1194 SharedLibKindMessage := "Shared Library"
1195 endif
1196 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1197         $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1198           $(notdir $@)
1199         $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1200           $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1201 else
1202 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1203         $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1204         $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1205 endif
1207 clean-local::
1208 ifneq ($(strip $(LibName.SO)),)
1209         -$(Verb) $(RM) -f $(LibName.SO)
1210 endif
1212 ifdef NO_INSTALL
1213 install-local::
1214         $(Echo) Install circumvented with NO_INSTALL
1215 uninstall-local::
1216         $(Echo) Uninstall circumvented with NO_INSTALL
1217 else
1219 # Win32.DLL prefers to be located on the "PATH" of binaries.
1220 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1221 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1222 else
1223 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1224 endif
1225 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1226 DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO)
1228 install-local:: $(DestSharedLib)
1230 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1231         $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1232         $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1233 ifdef SHARED_ALIAS
1234         $(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias)
1235         $(Verb) $(AliasTool) $(DestSharedLib) $(DestSharedAlias)
1236 endif
1238 uninstall-local::
1239         $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1240         -$(Verb) $(RM) -f $(DestSharedLib)
1241 endif
1242 endif
1244 #---------------------------------------------------------
1245 # Library Targets:
1246 #   If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1247 #   building an archive.
1248 #---------------------------------------------------------
1249 ifndef NO_BUILD_ARCHIVE
1250 ifndef BUILD_ARCHIVE
1251 ifndef LOADABLE_MODULE
1252 BUILD_ARCHIVE = 1
1253 endif
1254 endif
1255 endif
1257 #---------------------------------------------------------
1258 # Archive Library Targets:
1259 #   If the user wanted a regular archive library built,
1260 #   then we provide targets for building them.
1261 #---------------------------------------------------------
1262 ifdef BUILD_ARCHIVE
1264 all-local:: $(LibName.A)
1266 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1267         $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1268         -$(Verb) $(RM) -f $@
1269         $(Verb) $(Archive) $@ $(ObjectsO)
1270         $(Verb) $(Ranlib) $@
1272 clean-local::
1273 ifneq ($(strip $(LibName.A)),)
1274         -$(Verb) $(RM) -f $(LibName.A)
1275 endif
1277 ifdef NO_INSTALL
1278 install-local::
1279         $(Echo) Install circumvented with NO_INSTALL
1280 uninstall-local::
1281         $(Echo) Uninstall circumvented with NO_INSTALL
1282 else
1283 ifdef NO_INSTALL_ARCHIVES
1284 install-local::
1285         $(Echo) Install circumvented with NO_INSTALL
1286 uninstall-local::
1287         $(Echo) Uninstall circumvented with NO_INSTALL
1288 else
1289 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1291 install-local:: $(DestArchiveLib)
1293 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1294         $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1295         $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1296         $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1298 uninstall-local::
1299         $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1300         -$(Verb) $(RM) -f $(DestArchiveLib)
1301 endif
1302 endif
1303 endif
1305 # endif LIBRARYNAME
1306 endif
1308 ###############################################################################
1309 # Tool Build Rules: Build executable tool based on TOOLNAME option
1310 ###############################################################################
1312 ifdef TOOLNAME
1314 #---------------------------------------------------------
1315 # Set up variables for building a tool.
1316 #---------------------------------------------------------
1317 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1318 ifdef EXAMPLE_TOOL
1319 ToolBuildPath   := $(ExmplDir)/$(TOOLEXENAME)
1320 else
1321 ToolBuildPath   := $(ToolDir)/$(TOOLEXENAME)
1322 endif
1324 # TOOLALIAS is a name to symlink (or copy) the tool to.
1325 ifdef TOOLALIAS
1326 ifdef EXAMPLE_TOOL
1327 ToolAliasBuildPath   := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1328 else
1329 ToolAliasBuildPath   := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1330 endif
1331 endif
1333 #---------------------------------------------------------
1334 # Prune Exports
1335 #---------------------------------------------------------
1337 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1338 # not exporting all of the weak symbols from the binary.  This reduces dyld
1339 # startup time by 4x on darwin in some cases.
1340 ifdef TOOL_NO_EXPORTS
1341 ifeq ($(HOST_OS),Darwin)
1343 # Tiger tools don't support this.
1344 ifneq ($(DARWIN_MAJVERS),4)
1345 LD.Flags += -Wl,-exported_symbol,_main
1346 endif
1347 endif
1349 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1350 ifneq ($(ARCH), Mips)
1351   LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1352 endif
1353 endif
1354 endif
1356 #---------------------------------------------------------
1357 # Tool Order File Support
1358 #---------------------------------------------------------
1360 ifeq ($(HOST_OS),Darwin)
1361 ifdef TOOL_ORDER_FILE
1363 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1365 endif
1366 endif
1368 #---------------------------------------------------------
1369 # Tool Version Info Support
1370 #---------------------------------------------------------
1372 ifeq ($(HOST_OS),Darwin)
1373 ifdef TOOL_INFO_PLIST
1375 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1377 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1379 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1380         $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1381         $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1382                    -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1383                    -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1384                  -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1385                    $< > $@
1387 endif
1388 endif
1390 #---------------------------------------------------------
1391 # Provide targets for building the tools
1392 #---------------------------------------------------------
1393 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1395 clean-local::
1396 ifneq ($(strip $(ToolBuildPath)),)
1397         -$(Verb) $(RM) -f $(ToolBuildPath)
1398 endif
1399 ifneq ($(strip $(ToolAliasBuildPath)),)
1400         -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1401 endif
1403 ifdef EXAMPLE_TOOL
1404 $(ToolBuildPath): $(ExmplDir)/.dir
1405 else
1406 $(ToolBuildPath): $(ToolDir)/.dir
1407 endif
1409 ifdef CODESIGN_TOOLS
1410 TOOL_CODESIGN_IDENTITY ?= -
1412 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1413         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1414         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1415         $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1416         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1417           $(StripWarnMsg)
1418         $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1419         $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1420 else
1421 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1422         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1423         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1424         $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1425         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1426           $(StripWarnMsg)
1427 endif
1429 ifneq ($(strip $(ToolAliasBuildPath)),)
1430 $(ToolAliasBuildPath): $(ToolBuildPath)
1431         $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1432         $(Verb) $(RM) -f $(ToolAliasBuildPath)
1433         $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1434         $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1435           $(StripWarnMsg)
1436 endif
1438 ifdef NO_INSTALL
1439 install-local::
1440         $(Echo) Install circumvented with NO_INSTALL
1441 uninstall-local::
1442         $(Echo) Uninstall circumvented with NO_INSTALL
1443 else
1445 ifdef INTERNAL_TOOL
1446 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1447 else
1448 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1449 endif
1450 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1452 install-local:: $(DestTool)
1454 $(DestTool): $(ToolBuildPath)
1455         $(Echo) Installing $(BuildMode) $(DestTool)
1456         $(Verb) $(MKDIR) $(ToolBinDir)
1457         $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1459 uninstall-local::
1460         $(Echo) Uninstalling $(BuildMode) $(DestTool)
1461         -$(Verb) $(RM) -f $(DestTool)
1463 # TOOLALIAS install.
1464 ifdef TOOLALIAS
1465 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1467 install-local:: $(DestToolAlias)
1469 $(DestToolAlias): $(DestTool)
1470         $(Echo) Installing $(BuildMode) $(DestToolAlias)
1471         $(Verb) $(RM) -f $(DestToolAlias)
1472         $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1474 uninstall-local::
1475         $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1476         -$(Verb) $(RM) -f $(DestToolAlias)
1477 endif
1479 endif
1480 endif
1482 ###############################################################################
1483 # Object Build Rules: Build object files based on sources
1484 ###############################################################################
1486 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1487 ifeq ($(HOST_OS),HP-UX)
1488   DISABLE_AUTO_DEPENDENCIES=1
1489 endif
1491 COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1493 # Provide rule sets for when dependency generation is enabled
1494 ifndef DISABLE_AUTO_DEPENDENCIES
1496 #---------------------------------------------------------
1497 # Create .o files in the ObjDir directory from the .cpp and .c files...
1498 #---------------------------------------------------------
1500 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1501          -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1503 # If the build succeeded, move the dependency file over, otherwise
1504 # remove it.
1505 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1506                   else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1508 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1509         $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1510         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1511                 $(DEPEND_MOVEFILE)
1513 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1514         $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1515         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1516                 $(DEPEND_MOVEFILE)
1518 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1519         $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1520         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1521                 $(DEPEND_MOVEFILE)
1523 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1524         $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1525         $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1526                 $(DEPEND_MOVEFILE)
1528 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1529         $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1530         $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1531                 $(DEPEND_MOVEFILE)
1533 # Provide alternate rule sets if dependencies are disabled
1534 else
1536 $(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1537         $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1538         $(Compile.CXX) $< -o $@
1540 $(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1541         $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1542         $(Compile.CXX) $< -o $@
1544 $(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1545         $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1546         $(Compile.CXX) $< -o $@
1548 $(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1549         $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1550         $(Compile.C) $< -o $@
1552 $(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1553         $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1554         $(Compile.C) $< -o $@
1555 endif
1558 ## Rules for building preprocessed (.i/.ii) outputs.
1559 $(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1560         $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1561         $(Verb) $(Preprocess.CXX) $< -o $@
1563 $(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1564         $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1565         $(Verb) $(Preprocess.CXX) $< -o $@
1567 $(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1568         $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1569         $(Verb) $(Preprocess.CXX) $< -o $@
1571 $(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1572         $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1573         $(Verb) $(Preprocess.C) $< -o $@
1575 $(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1576         $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1577         $(Verb) $(Preprocess.C) $< -o $@
1580 $(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1581         $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1582         $(Compile.CXX) $< -o $@ -S
1584 $(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1585         $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1586         $(Compile.CXX) $< -o $@ -S
1588 $(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1589         $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1590         $(Compile.CXX) $< -o $@ -S
1592 $(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1593         $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1594         $(Compile.C) $< -o $@ -S
1596 $(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1597         $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1598         $(Compile.C) $< -o $@ -S
1600 ###############################################################################
1601 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1602 ###############################################################################
1604 ifdef TARGET
1605 TABLEGEN_INC_FILES_COMMON = 1
1606 endif
1608 ifdef TABLEGEN_INC_FILES_COMMON
1610 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1611 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1612 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1614 # INCFiles rule: All of the tblgen generated files are emitted to
1615 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
1616 # us to only "touch" the real file if the contents of it change.  IOW, if
1617 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1618 # dependencies of the .inc files are, unless the contents of the .inc file
1619 # changes.
1620 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1621         $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1623 endif # TABLEGEN_INC_FILES_COMMON
1625 ifdef TARGET
1627 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1628            $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1629            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1630            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1631            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1632            $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1633            $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1635 # All .inc.tmp files depend on the .td files.
1636 $(INCTMPFiles) : $(TDFiles)
1638 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1639 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1640         $(Echo) "Building $(<F) register info implementation with tblgen"
1641         $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1643 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1644 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1645         $(Echo) "Building $(<F) instruction information with tblgen"
1646         $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1648 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1649 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1650         $(Echo) "Building $(<F) assembly writer with tblgen"
1651         $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1653 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1654 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1655         $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1656         $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1658 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1659 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1660         $(Echo) "Building $(<F) assembly matcher with tblgen"
1661         $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1663 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1664 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1665         $(Echo) "Building $(<F) MC code emitter with tblgen"
1666         $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1668 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1669 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1670         $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1671         $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1673 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1674 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1675         $(Echo) "Building $(<F) code emitter with tblgen"
1676         $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1678 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1679 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1680         $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1681         $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1683 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1684 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1685         $(Echo) "Building $(<F) disassembly tables with tblgen"
1686         $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1688 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1689 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1690         $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1691         $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1693 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1694 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1695         $(Echo) "Building $(<F) subtarget information with tblgen"
1696         $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1698 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1699 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1700         $(Echo) "Building $(<F) calling convention information with tblgen"
1701         $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1703 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1704 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1705         $(Echo) "Building $(<F) intrinsics information with tblgen"
1706         $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1708 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1709         $(Echo) "Building $(<F) decoder tables with tblgen"
1710         $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1712 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1713         $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1714         $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1716 clean-local::
1717         -$(Verb) $(RM) -f $(INCFiles)
1719 endif # TARGET
1721 ###############################################################################
1722 # OTHER RULES: Other rules needed
1723 ###############################################################################
1725 # To create postscript files from dot files...
1726 ifneq ($(DOT),false)
1727 %.ps: %.dot
1728         $(DOT) -Tps < $< > $@
1729 else
1730 %.ps: %.dot
1731         $(Echo) "Cannot build $@: The program dot is not installed"
1732 endif
1734 # This rules ensures that header files that are removed still have a rule for
1735 # which they can be "generated."  This allows make to ignore them and
1736 # reproduce the dependency lists.
1737 %.h:: ;
1738 %.hpp:: ;
1740 # Define clean-local to clean the current directory. Note that this uses a
1741 # very conservative approach ensuring that empty variables do not cause
1742 # errors or disastrous removal.
1743 clean-local::
1744 ifneq ($(strip $(ObjRootDir)),)
1745         -$(Verb) $(RM) -rf $(ObjRootDir)
1746 endif
1747 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1748         -$(Verb) $(RM) -f *$(SHLIBEXT)
1749 endif
1751 clean-all-local::
1752         -$(Verb) $(RM) -rf Debug Release Profile
1755 ###############################################################################
1756 # DEPENDENCIES: Include the dependency files if we should
1757 ###############################################################################
1758 ifndef DISABLE_AUTO_DEPENDENCIES
1760 # If its not one of the cleaning targets
1761 ifndef IS_CLEANING_TARGET
1763 # Get the list of dependency files
1764 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1765 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1767 -include $(DependFiles) ""
1769 endif
1771 endif
1773 ###############################################################################
1774 # CHECK: Running the test suite
1775 ###############################################################################
1777 check:: all
1778         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1779           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1780             $(EchoCmd) Running test suite ; \
1781             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1782               TESTSUITE=$(TESTSUITE) ; \
1783           else \
1784             $(EchoCmd) No Makefile in test directory ; \
1785           fi ; \
1786         else \
1787           $(EchoCmd) No test directory ; \
1788         fi
1790 # An alias dating from when both lit and DejaGNU test runners were used.
1791 check-lit:: check
1793 check-all::
1794         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1795           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1796             $(EchoCmd) Running test suite ; \
1797             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1798           else \
1799             $(EchoCmd) No Makefile in test directory ; \
1800           fi ; \
1801         else \
1802           $(EchoCmd) No test directory ; \
1803         fi
1805 ###############################################################################
1806 # UNITTESTS: Running the unittests test suite
1807 ###############################################################################
1809 unittests::
1810         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1811           if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1812             $(EchoCmd) Running unittests test suite ; \
1813             $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1814           else \
1815             $(EchoCmd) No Makefile in unittests directory ; \
1816           fi ; \
1817         else \
1818           $(EchoCmd) No unittests directory ; \
1819         fi
1821 ###############################################################################
1822 # DISTRIBUTION: Handle construction of a distribution tarball
1823 ###############################################################################
1825 #------------------------------------------------------------------------
1826 # Define distribution related variables
1827 #------------------------------------------------------------------------
1828 DistName    := $(PROJECT_NAME)-$(PROJ_VERSION)
1829 DistDir     := $(PROJ_OBJ_ROOT)/$(DistName)
1830 TopDistDir  := $(PROJ_OBJ_ROOT)/$(DistName)
1831 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1832 DistZip     := $(PROJ_OBJ_ROOT)/$(DistName).zip
1833 DistTarBZ2  := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1834 DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1835                ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1836                Makefile.config.in configure autoconf
1837 DistOther   := $(notdir $(wildcard \
1838                $(PROJ_SRC_DIR)/*.h \
1839                $(PROJ_SRC_DIR)/*.td \
1840                $(PROJ_SRC_DIR)/*.def \
1841                $(PROJ_SRC_DIR)/*.ll \
1842                $(PROJ_SRC_DIR)/*.in))
1843 DistSubDirs := $(SubDirs)
1844 DistSources  = $(Sources) $(EXTRA_DIST)
1845 DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
1847 #------------------------------------------------------------------------
1848 # We MUST build distribution with OBJ_DIR != SRC_DIR
1849 #------------------------------------------------------------------------
1850 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1851 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1852         $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1854 else
1856 #------------------------------------------------------------------------
1857 # Prevent attempt to run dist targets from anywhere but the top level
1858 #------------------------------------------------------------------------
1859 ifneq ($(LEVEL),.)
1860 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1861         $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1862 else
1864 #------------------------------------------------------------------------
1865 # Provide the top level targets
1866 #------------------------------------------------------------------------
1868 dist-gzip:: $(DistTarGZip)
1870 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1871         $(Echo) Packing gzipped distribution tar file.
1872         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1873           $(GZIP) -c > "$(DistTarGZip)"
1875 dist-bzip2:: $(DistTarBZ2)
1877 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1878         $(Echo) Packing bzipped distribution tar file.
1879         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1880           $(BZIP2) -c >$(DistTarBZ2)
1882 dist-zip:: $(DistZip)
1884 $(DistZip) : $(TopDistDir)/.makedistdir
1885         $(Echo) Packing zipped distribution file.
1886         $(Verb) rm -f $(DistZip)
1887         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1889 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1890         $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1892 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1894 dist-check:: $(DistTarGZip)
1895         $(Echo) Checking distribution tar file.
1896         $(Verb) if test -d $(DistCheckDir) ; then \
1897           $(RM) -rf $(DistCheckDir) ; \
1898         fi
1899         $(Verb) $(MKDIR) $(DistCheckDir)
1900         $(Verb) cd $(DistCheckDir) && \
1901           $(MKDIR) $(DistCheckDir)/build && \
1902           $(MKDIR) $(DistCheckDir)/install && \
1903           gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1904           cd build && \
1905           ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1906             --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1907           $(MAKE) all && \
1908           $(MAKE) check && \
1909           $(MAKE) unittests && \
1910           $(MAKE) install && \
1911           $(MAKE) uninstall && \
1912           $(MAKE) dist-clean && \
1913           $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1915 dist-clean::
1916         $(Echo) Cleaning distribution files
1917         -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1918           $(DistCheckDir)
1920 endif
1922 #------------------------------------------------------------------------
1923 # Provide the recursive distdir target for building the distribution directory
1924 #------------------------------------------------------------------------
1925 distdir: $(DistDir)/.makedistdir
1926 $(DistDir)/.makedistdir: $(DistSources)
1927         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1928           if test -d "$(DistDir)" ; then \
1929             find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1930               exit 1 ; \
1931           fi ; \
1932           $(EchoCmd) Removing old $(DistDir) ; \
1933           $(RM) -rf $(DistDir); \
1934           $(EchoCmd) Making 'all' to verify build ; \
1935           $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1936         fi
1937         $(Echo) Building Distribution Directory $(DistDir)
1938         $(Verb) $(MKDIR) $(DistDir)
1939         $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1940         srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1941         for file in $(DistFiles) ; do \
1942           case "$$file" in \
1943             $(PROJ_SRC_DIR)/*) \
1944               file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1945               ;; \
1946             $(PROJ_SRC_ROOT)/*) \
1947               file=`echo "$$file" | \
1948                 sed "s#^$$srcrootstrip/##"` \
1949               ;; \
1950           esac; \
1951           if test -f "$(PROJ_SRC_DIR)/$$file" || \
1952              test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1953             from_dir="$(PROJ_SRC_DIR)" ; \
1954           elif test -f "$$file" || test -d "$$file" ; then \
1955             from_dir=. ; \
1956           fi ; \
1957           to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1958           if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1959             to_dir="$(DistDir)/$$dir"; \
1960             $(MKDIR) "$$to_dir" ; \
1961           else \
1962             to_dir="$(DistDir)"; \
1963           fi; \
1964           mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1965           if test -n "$$mid_dir" ; then \
1966             $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1967           fi ; \
1968           if test -d "$$from_dir/$$file"; then \
1969             if test -d "$(PROJ_SRC_DIR)/$$file" && \
1970                test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1971                cd $(PROJ_SRC_DIR) ; \
1972                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1973                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1974                cd $(PROJ_OBJ_DIR) ; \
1975             else \
1976                cd $$from_dir ; \
1977                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1978                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1979                cd $(PROJ_OBJ_DIR) ; \
1980             fi; \
1981           elif test -f "$$from_dir/$$file" ; then \
1982             $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1983           elif test -L "$$from_dir/$$file" ; then \
1984             $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1985           elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1986             $(EchoCmd) "===== WARNING: Distribution Source " \
1987               "$$from_dir/$$file Not Found!" ; \
1988           elif test "$(Verb)" != '@' ; then \
1989             $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1990           fi; \
1991         done
1992         $(Verb) for subdir in $(DistSubDirs) ; do \
1993           if test "$$subdir" \!= "." ; then \
1994             new_distdir="$(DistDir)/$$subdir" ; \
1995             test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1996             ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1997               DistDir="$$new_distdir" distdir ) || exit 1; \
1998           fi; \
1999         done
2000         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2001           $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2002           $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2003                                   -name .svn \) -print` ;\
2004           $(MAKE) dist-hook ; \
2005           $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2006             -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2007             -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2008             -o ! -type d ! -perm -444 -exec \
2009               $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2010             || chmod -R a+r $(DistDir) ; \
2011         fi
2013 # This is invoked by distdir target, define it as a no-op to avoid errors if not
2014 # defined by user.
2015 dist-hook::
2017 endif
2019 ###############################################################################
2020 # TOP LEVEL - targets only to apply at the top level directory
2021 ###############################################################################
2023 ifeq ($(LEVEL),.)
2025 #------------------------------------------------------------------------
2026 # Install support for the project's include files:
2027 #------------------------------------------------------------------------
2028 ifdef NO_INSTALL
2029 install-local::
2030         $(Echo) Install circumvented with NO_INSTALL
2031 uninstall-local::
2032         $(Echo) Uninstall circumvented with NO_INSTALL
2033 else
2034 install-local::
2035         $(Echo) Installing include files
2036         $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2037         $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2038           cd $(PROJ_SRC_ROOT)/include && \
2039           for hdr in `find . -type f \
2040               '(' -name LICENSE.TXT \
2041                -o -name '*.def' \
2042                -o -name '*.h' \
2043                -o -name '*.inc' \
2044                -o -name '*.td' \
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 ;\
2051             fi ; \
2052             $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2053           done ; \
2054         fi
2055 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2056         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2057           cd $(PROJ_OBJ_ROOT)/include && \
2058           for hdr in `find . -type f \
2059               '(' -name LICENSE.TXT \
2060                -o -name '*.def' \
2061                -o -name '*.h' \
2062                -o -name '*.inc' \
2063                -o -name '*.td' \
2064               ')' -print | grep -v CVS | \
2065               grep -v .svn` ; do \
2066             instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2067             if test \! -d "$$instdir" ; then \
2068               $(EchoCmd) Making install directory $$instdir ; \
2069               $(MKDIR) $$instdir ;\
2070             fi ; \
2071             $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2072           done ; \
2073         fi
2074 endif
2076 uninstall-local::
2077         $(Echo) Uninstalling include files
2078         $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2079           cd $(PROJ_SRC_ROOT)/include && \
2080             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2081               '!' '(' -name '*~' -o -name '.#*' \
2082         -o -name '*.in' ')' -print ')' | \
2083         grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2084           cd $(PROJ_SRC_ROOT)/include && \
2085             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2086       -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2087         fi
2088 endif
2089 endif
2091 check-line-length:
2092         @echo searching for overlength lines in files: $(Sources)
2093         @echo
2094         @echo
2095         egrep -n '.{81}' $(Sources) /dev/null
2097 check-for-tabs:
2098         @echo searching for tabs in files: $(Sources)
2099         @echo
2100         @echo
2101         egrep -n '      ' $(Sources) /dev/null
2103 check-footprint:
2104         @ls -l $(LibDir) | awk '\
2105           BEGIN { sum = 0; } \
2106                 { sum += $$5; } \
2107           END   { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2108         @ls -l $(ToolDir) | awk '\
2109           BEGIN { sum = 0; } \
2110                 { sum += $$5; } \
2111           END   { printf("Programs:  %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2112 #------------------------------------------------------------------------
2113 # Print out the directories used for building
2114 #------------------------------------------------------------------------
2115 printvars::
2116         $(Echo) "BuildMode    : " '$(BuildMode)'
2117         $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2118         $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2119         $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2120         $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2121         $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2122         $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2123         $(Echo) "PROJ_prefix  : " '$(PROJ_prefix)'
2124         $(Echo) "PROJ_internal_prefix  : " '$(PROJ_internal_prefix)'
2125         $(Echo) "PROJ_bindir  : " '$(PROJ_bindir)'
2126         $(Echo) "PROJ_libdir  : " '$(PROJ_libdir)'
2127         $(Echo) "PROJ_etcdir  : " '$(PROJ_etcdir)'
2128         $(Echo) "PROJ_includedir  : " '$(PROJ_includedir)'
2129         $(Echo) "UserTargets  : " '$(UserTargets)'
2130         $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2131         $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2132         $(Echo) "ObjDir       : " '$(ObjDir)'
2133         $(Echo) "LibDir       : " '$(LibDir)'
2134         $(Echo) "ToolDir      : " '$(ToolDir)'
2135         $(Echo) "ExmplDir     : " '$(ExmplDir)'
2136         $(Echo) "Sources      : " '$(Sources)'
2137         $(Echo) "TDFiles      : " '$(TDFiles)'
2138         $(Echo) "INCFiles     : " '$(INCFiles)'
2139         $(Echo) "INCTMPFiles  : " '$(INCTMPFiles)'
2140         $(Echo) "PreConditions: " '$(PreConditions)'
2141         $(Echo) "Compile.CXX  : " '$(Compile.CXX)'
2142         $(Echo) "Compile.C    : " '$(Compile.C)'
2143         $(Echo) "Archive      : " '$(Archive)'
2144         $(Echo) "YaccFiles    : " '$(YaccFiles)'
2145         $(Echo) "LexFiles     : " '$(LexFiles)'
2146         $(Echo) "Module       : " '$(Module)'
2147         $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2148         $(Echo) "SubDirs      : " '$(SubDirs)'
2149         $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2150         $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2152 ###
2153 # Debugging
2155 # General debugging rule, use 'make dbg-print-XXX' to print the
2156 # definition, value and origin of XXX.
2157 make-print-%:
2158         $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))