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