[ARM] Handling for coprocessor instructions that are undefined starting from ARMv8...
[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
780 ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
781
782 #----------------------------------------------------------
783 # For Mingw MSYS bash and Python/w32:
784 #
785 # $(ECHOPATH) prints DOSish pathstring.
786 #   ex) $(ECHOPATH) /include/sys/types.h
787 #   --> C:/mingw/include/sys/types.h
788 # built-in "echo" does not transform path to DOSish path.
789 #
790 # FIXME: It would not be needed when MSYS's python
791 # were provided.
792 #----------------------------------------------------------
793
794 ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
795   ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
796 else
797   ECHOPATH := $(Verb)$(ECHO)
798 endif
799
800 ###############################################################################
801 # DIRECTORIES: Handle recursive descent of directory structure
802 ###############################################################################
803
804 #---------------------------------------------------------
805 # Provide rules to make install dirs. This must be early
806 # in the file so they get built before dependencies
807 #---------------------------------------------------------
808
809 $(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
810         $(Verb) $(MKDIR) $@
811
812 # To create other directories, as needed, and timestamp their creation
813 %/.dir:
814         $(Verb) $(MKDIR) $* > /dev/null
815         $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
816
817 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
818 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
819
820 #---------------------------------------------------------
821 # Handle the DIRS options for sequential construction
822 #---------------------------------------------------------
823
824 SubDirs :=
825 ifdef DIRS
826 SubDirs += $(DIRS)
827
828 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
829 $(RecursiveTargets)::
830         $(Verb) for dir in $(DIRS); do \
831           if ([ ! -f $$dir/Makefile ] || \
832               command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
833             $(MKDIR) $$dir; \
834             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
835           fi; \
836           ($(MAKE) -C $$dir $@ ) || exit 1; \
837         done
838 else
839 $(RecursiveTargets)::
840         $(Verb) for dir in $(DIRS); do \
841           ($(MAKE) -C $$dir $@ ) || exit 1; \
842         done
843 endif
844
845 endif
846
847 #---------------------------------------------------------
848 # Handle the EXPERIMENTAL_DIRS options ensuring success
849 # after each directory is built.
850 #---------------------------------------------------------
851 ifdef EXPERIMENTAL_DIRS
852 $(RecursiveTargets)::
853         $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
854           if ([ ! -f $$dir/Makefile ] || \
855               command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
856             $(MKDIR) $$dir; \
857             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
858           fi; \
859           ($(MAKE) -C $$dir $@ ) || exit 0; \
860         done
861 endif
862
863 #-----------------------------------------------------------
864 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
865 #-----------------------------------------------------------
866 ifdef OPTIONAL_PARALLEL_DIRS
867   PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
868 endif
869
870 #-----------------------------------------------------------
871 # Handle the PARALLEL_DIRS options for parallel construction
872 #-----------------------------------------------------------
873 ifdef PARALLEL_DIRS
874
875 SubDirs += $(PARALLEL_DIRS)
876
877 # Unfortunately, this list must be maintained if new recursive targets are added
878 all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
879 clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
880 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
881 install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
882 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
883 install-bytecode  :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
884 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
885
886 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
887
888 $(ParallelTargets) :
889         $(Verb) \
890           SD=$(PROJ_SRC_DIR)/$(@D); \
891           DD=$(@D); \
892           if [ ! -f $$SD/Makefile ]; then \
893             SD=$(@D); \
894             DD=$(notdir $(@D)); \
895           fi; \
896           if ([ ! -f $$DD/Makefile ] || \
897                     command test $$DD/Makefile -ot \
898                       $$SD/Makefile ); then \
899           $(MKDIR) $$DD; \
900           $(CP) $$SD/Makefile $$DD/Makefile; \
901         fi; \
902         $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
903 endif
904
905 #---------------------------------------------------------
906 # Handle the OPTIONAL_DIRS options for directores that may
907 # or may not exist.
908 #---------------------------------------------------------
909 ifdef OPTIONAL_DIRS
910
911 SubDirs += $(OPTIONAL_DIRS)
912
913 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
914 $(RecursiveTargets)::
915         $(Verb) for dir in $(OPTIONAL_DIRS); do \
916           if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
917             if ([ ! -f $$dir/Makefile ] || \
918                 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
919               $(MKDIR) $$dir; \
920               $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
921             fi; \
922             ($(MAKE) -C$$dir $@ ) || exit 1; \
923           fi \
924         done
925 else
926 $(RecursiveTargets)::
927         $(Verb) for dir in $(OPTIONAL_DIRS); do \
928           if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
929             ($(MAKE) -C$$dir $@ ) || exit 1; \
930           fi \
931         done
932 endif
933 endif
934
935 #---------------------------------------------------------
936 # Handle the CONFIG_FILES options
937 #---------------------------------------------------------
938 ifdef CONFIG_FILES
939
940 ifdef NO_INSTALL
941 install-local::
942         $(Echo) Install circumvented with NO_INSTALL
943 uninstall-local::
944         $(Echo) UnInstall circumvented with NO_INSTALL
945 else
946 install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
947         $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
948         $(Verb)for file in $(CONFIG_FILES); do \
949           if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
950             $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
951           elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
952             $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
953           else \
954             $(ECHO) Error: cannot find config file $${file}. ; \
955           fi \
956         done
957
958 uninstall-local::
959         $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
960         $(Verb)for file in $(CONFIG_FILES); do \
961           $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
962         done
963 endif
964
965 endif
966
967 ###############################################################################
968 # Set up variables for building libraries
969 ###############################################################################
970
971 #---------------------------------------------------------
972 # Define various command line options pertaining to the
973 # libraries needed when linking. There are "Proj" libs
974 # (defined by the user's project) and "LLVM" libs (defined
975 # by the LLVM project).
976 #---------------------------------------------------------
977
978 ifdef USEDLIBS
979 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
980 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
981 ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
982 ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
983 endif
984
985 ifdef LLVMLIBS
986 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
987 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
988 LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
989 LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
990 endif
991
992 # Loadable module for Win32 requires all symbols resolved for linking.
993 # Then all symbols in LLVM.dll will be available.
994 ifeq ($(ENABLE_SHARED),1)
995   ifdef LOADABLE_MODULE
996     ifneq (,$(filter $(HOST_OS),Cygwin MingW))
997       LINK_COMPONENTS += all
998     endif
999   endif
1000 endif
1001
1002 ifndef IS_CLEANING_TARGET
1003 ifdef LINK_COMPONENTS
1004
1005 # If LLVM_CONFIG doesn't exist, build it.  This can happen if you do a make
1006 # clean in tools, then do a make in tools (instead of at the top level).
1007 $(LLVM_CONFIG):
1008         @echo "*** llvm-config doesn't exist - rebuilding it."
1009         @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1010
1011 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1012
1013 ifeq ($(ENABLE_SHARED), 1)
1014 # We can take the "auto-import" feature to get rid of using dllimport.
1015 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1016 LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1017                    -L $(SharedLibDir)
1018 endif
1019 LLVMLibsOptions += -lLLVM-$(LLVMVersion)
1020 LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
1021 else
1022
1023 ifndef NO_LLVM_CONFIG
1024 LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1025 ifeq ($(LLVMConfigLibs),Error)
1026 $(error llvm-config --libs failed)
1027 endif
1028 LLVMLibsOptions += $(LLVMConfigLibs)
1029 LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1030 ifeq ($(LLVMConfigLibfiles),Error)
1031 $(error llvm-config --libfiles failed)
1032 endif
1033 LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1034 endif
1035
1036 endif
1037 endif
1038 endif
1039
1040 # Set up the library exports file.
1041 ifdef EXPORTED_SYMBOL_FILE
1042
1043 # First, set up the native export file, which may differ from the source
1044 # export file.
1045
1046 ifeq ($(HOST_OS),Darwin)
1047 # Darwin convention prefixes symbols with underscores.
1048 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1049 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1050         $(Verb) sed -e 's/^/_/' < $< > $@
1051 clean-local::
1052         -$(Verb) $(RM) -f $(NativeExportsFile)
1053 else
1054 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1055 # Gold and BFD ld require a version script rather than a plain list.
1056 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1057 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1058         $(Verb) echo "{" > $@
1059         $(Verb) grep -q '[[:alnum:]_]' $< && echo "  global:" >> $@ || :
1060         $(Verb) sed -e 's/$$/;/' -e 's/^/    /' < $< >> $@
1061 ifneq ($(HOST_OS),OpenBSD)
1062         $(Verb) echo "  local: *;" >> $@
1063 endif
1064         $(Verb) echo "};" >> $@
1065 clean-local::
1066         -$(Verb) $(RM) -f $(NativeExportsFile)
1067 else
1068 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1069 # GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1070 NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1071 $(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1072         $(Echo) Generating $(notdir $@)
1073         $(Verb) $(ECHO) "EXPORTS" > $@
1074         $(Verb) $(CAT) $< >> $@
1075 clean-local::
1076         -$(Verb) $(RM) -f $(NativeExportsFile)
1077 else
1078 # Default behavior: just use the exports file verbatim.
1079 NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1080 endif
1081 endif
1082 endif
1083
1084 # Now add the linker command-line options to use the native export file.
1085
1086 # Darwin
1087 ifeq ($(HOST_OS),Darwin)
1088 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1089 endif
1090
1091 # gold, bfd ld, etc.
1092 ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1093 LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1094 endif
1095
1096 # Windows
1097 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1098 # LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1099 SharedLinkOptions += $(NativeExportsFile)
1100 endif
1101
1102 endif
1103
1104 ###############################################################################
1105 # Library Build Rules: Four ways to build a library
1106 ###############################################################################
1107
1108 # if we're building a library ...
1109 ifdef LIBRARYNAME
1110
1111 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1112 LIBRARYNAME := $(strip $(LIBRARYNAME))
1113 ifdef LOADABLE_MODULE
1114 BaseLibName.A  := $(LIBRARYNAME).a
1115 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1116 else
1117 BaseLibName.A  := lib$(LIBRARYNAME).a
1118 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1119 endif
1120 LibName.A  := $(LibDir)/$(BaseLibName.A)
1121 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1122 LibName.O  := $(LibDir)/$(LIBRARYNAME).o
1123
1124 #---------------------------------------------------------
1125 # Shared Library Targets:
1126 #   If the user asked for a shared library to be built
1127 #   with the SHARED_LIBRARY variable, then we provide
1128 #   targets for building them.
1129 #---------------------------------------------------------
1130 ifdef SHARED_LIBRARY
1131
1132 all-local:: $(LibName.SO)
1133
1134 ifdef EXPORTED_SYMBOL_FILE
1135 $(LibName.SO): $(NativeExportsFile)
1136 endif
1137
1138 ifdef LINK_LIBS_IN_SHARED
1139 ifdef LOADABLE_MODULE
1140 SharedLibKindMessage := "Loadable Module"
1141 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1142 else
1143 SharedLibKindMessage := "Shared Library"
1144 endif
1145 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1146         $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1147           $(notdir $@)
1148         $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1149           $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1150 else
1151 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1152         $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1153         $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1154 endif
1155
1156 clean-local::
1157 ifneq ($(strip $(LibName.SO)),)
1158         -$(Verb) $(RM) -f $(LibName.SO)
1159 endif
1160
1161 ifdef NO_INSTALL
1162 install-local::
1163         $(Echo) Install circumvented with NO_INSTALL
1164 uninstall-local::
1165         $(Echo) Uninstall circumvented with NO_INSTALL
1166 else
1167
1168 # Win32.DLL prefers to be located on the "PATH" of binaries.
1169 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1170 DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1171 else
1172 DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1173 endif
1174 DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1175
1176 install-local:: $(DestSharedLib)
1177
1178 $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1179         $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1180         $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1181
1182 uninstall-local::
1183         $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1184         -$(Verb) $(RM) -f $(DestSharedLib)
1185 endif
1186 endif
1187
1188 #---------------------------------------------------------
1189 # Library Targets:
1190 #   If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1191 #   building an archive.
1192 #---------------------------------------------------------
1193 ifndef NO_BUILD_ARCHIVE
1194 ifndef BUILD_ARCHIVE
1195 ifndef LOADABLE_MODULE
1196 BUILD_ARCHIVE = 1
1197 endif
1198 endif
1199 endif
1200
1201 #---------------------------------------------------------
1202 # Archive Library Targets:
1203 #   If the user wanted a regular archive library built,
1204 #   then we provide targets for building them.
1205 #---------------------------------------------------------
1206 ifdef BUILD_ARCHIVE
1207
1208 all-local:: $(LibName.A)
1209
1210 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1211         $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1212         -$(Verb) $(RM) -f $@
1213         $(Verb) $(Archive) $@ $(ObjectsO)
1214         $(Verb) $(Ranlib) $@
1215
1216 clean-local::
1217 ifneq ($(strip $(LibName.A)),)
1218         -$(Verb) $(RM) -f $(LibName.A)
1219 endif
1220
1221 ifdef NO_INSTALL
1222 install-local::
1223         $(Echo) Install circumvented with NO_INSTALL
1224 uninstall-local::
1225         $(Echo) Uninstall circumvented with NO_INSTALL
1226 else
1227 ifdef NO_INSTALL_ARCHIVES
1228 install-local::
1229         $(Echo) Install circumvented with NO_INSTALL
1230 uninstall-local::
1231         $(Echo) Uninstall circumvented with NO_INSTALL
1232 else
1233 DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1234
1235 install-local:: $(DestArchiveLib)
1236
1237 $(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1238         $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1239         $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1240         $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1241
1242 uninstall-local::
1243         $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1244         -$(Verb) $(RM) -f $(DestArchiveLib)
1245 endif
1246 endif
1247 endif
1248
1249 # endif LIBRARYNAME
1250 endif
1251
1252 ###############################################################################
1253 # Tool Build Rules: Build executable tool based on TOOLNAME option
1254 ###############################################################################
1255
1256 ifdef TOOLNAME
1257
1258 #---------------------------------------------------------
1259 # Set up variables for building a tool.
1260 #---------------------------------------------------------
1261 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1262 ifdef EXAMPLE_TOOL
1263 ToolBuildPath   := $(ExmplDir)/$(TOOLEXENAME)
1264 else
1265 ToolBuildPath   := $(ToolDir)/$(TOOLEXENAME)
1266 endif
1267
1268 # TOOLALIAS is a name to symlink (or copy) the tool to.
1269 ifdef TOOLALIAS
1270 ifdef EXAMPLE_TOOL
1271 ToolAliasBuildPath   := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1272 else
1273 ToolAliasBuildPath   := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1274 endif
1275 endif
1276
1277 #---------------------------------------------------------
1278 # Prune Exports
1279 #---------------------------------------------------------
1280
1281 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1282 # not exporting all of the weak symbols from the binary.  This reduces dyld
1283 # startup time by 4x on darwin in some cases.
1284 ifdef TOOL_NO_EXPORTS
1285 ifeq ($(HOST_OS),Darwin)
1286
1287 # Tiger tools don't support this.
1288 ifneq ($(DARWIN_MAJVERS),4)
1289 LD.Flags += -Wl,-exported_symbol,_main
1290 endif
1291 endif
1292
1293 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1294 ifneq ($(ARCH), Mips)
1295   LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1296 endif
1297 endif
1298 endif
1299
1300 #---------------------------------------------------------
1301 # Tool Order File Support
1302 #---------------------------------------------------------
1303
1304 ifeq ($(HOST_OS),Darwin)
1305 ifdef TOOL_ORDER_FILE
1306
1307 LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1308
1309 endif
1310 endif
1311
1312 #---------------------------------------------------------
1313 # Tool Version Info Support
1314 #---------------------------------------------------------
1315
1316 ifeq ($(HOST_OS),Darwin)
1317 ifdef TOOL_INFO_PLIST
1318
1319 LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1320
1321 $(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1322
1323 $(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1324         $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1325         $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1326                    -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1327                    -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1328                  -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1329                    $< > $@
1330
1331 endif
1332 endif
1333
1334 #---------------------------------------------------------
1335 # Provide targets for building the tools
1336 #---------------------------------------------------------
1337 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1338
1339 clean-local::
1340 ifneq ($(strip $(ToolBuildPath)),)
1341         -$(Verb) $(RM) -f $(ToolBuildPath)
1342 endif
1343 ifneq ($(strip $(ToolAliasBuildPath)),)
1344         -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1345 endif
1346
1347 ifdef EXAMPLE_TOOL
1348 $(ToolBuildPath): $(ExmplDir)/.dir
1349 else
1350 $(ToolBuildPath): $(ToolDir)/.dir
1351 endif
1352
1353 ifdef CODESIGN_TOOLS
1354 TOOL_CODESIGN_IDENTITY ?= -
1355
1356 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1357         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1358         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1359         $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1360         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1361           $(StripWarnMsg)
1362         $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1363         $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1364 else
1365 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1366         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1367         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1368         $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1369         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1370           $(StripWarnMsg)
1371 endif
1372
1373 ifneq ($(strip $(ToolAliasBuildPath)),)
1374 $(ToolAliasBuildPath): $(ToolBuildPath)
1375         $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1376         $(Verb) $(RM) -f $(ToolAliasBuildPath)
1377         $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1378         $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1379           $(StripWarnMsg)
1380 endif
1381
1382 ifdef NO_INSTALL
1383 install-local::
1384         $(Echo) Install circumvented with NO_INSTALL
1385 uninstall-local::
1386         $(Echo) Uninstall circumvented with NO_INSTALL
1387 else
1388
1389 ifdef INTERNAL_TOOL
1390 ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1391 else
1392 ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1393 endif
1394 DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1395
1396 install-local:: $(DestTool)
1397
1398 $(DestTool): $(ToolBuildPath)
1399         $(Echo) Installing $(BuildMode) $(DestTool)
1400         $(Verb) $(MKDIR) $(ToolBinDir)
1401         $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1402
1403 uninstall-local::
1404         $(Echo) Uninstalling $(BuildMode) $(DestTool)
1405         -$(Verb) $(RM) -f $(DestTool)
1406
1407 # TOOLALIAS install.
1408 ifdef TOOLALIAS
1409 DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1410
1411 install-local:: $(DestToolAlias)
1412
1413 $(DestToolAlias): $(DestTool)
1414         $(Echo) Installing $(BuildMode) $(DestToolAlias)
1415         $(Verb) $(RM) -f $(DestToolAlias)
1416         $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1417
1418 uninstall-local::
1419         $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1420         -$(Verb) $(RM) -f $(DestToolAlias)
1421 endif
1422
1423 endif
1424 endif
1425
1426 ###############################################################################
1427 # Object Build Rules: Build object files based on sources
1428 ###############################################################################
1429
1430 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1431 ifeq ($(HOST_OS),HP-UX)
1432   DISABLE_AUTO_DEPENDENCIES=1
1433 endif
1434
1435 # Provide rule sets for when dependency generation is enabled
1436 ifndef DISABLE_AUTO_DEPENDENCIES
1437
1438 #---------------------------------------------------------
1439 # Create .o files in the ObjDir directory from the .cpp and .c files...
1440 #---------------------------------------------------------
1441
1442 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1443          -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1444
1445 # If the build succeeded, move the dependency file over, otherwise
1446 # remove it.
1447 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1448                   else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1449
1450 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1451         $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1452         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1453                 $(DEPEND_MOVEFILE)
1454
1455 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1456         $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1457         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1458                 $(DEPEND_MOVEFILE)
1459
1460 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1461         $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1462         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1463                 $(DEPEND_MOVEFILE)
1464
1465 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1466         $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1467         $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1468                 $(DEPEND_MOVEFILE)
1469
1470 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1471         $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1472         $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1473                 $(DEPEND_MOVEFILE)
1474
1475 # Provide alternate rule sets if dependencies are disabled
1476 else
1477
1478 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1479         $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1480         $(Compile.CXX) $< -o $@
1481
1482 $(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1483         $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1484         $(Compile.CXX) $< -o $@
1485
1486 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1487         $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1488         $(Compile.CXX) $< -o $@
1489
1490 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1491         $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1492         $(Compile.C) $< -o $@
1493
1494 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1495         $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1496         $(Compile.C) $< -o $@
1497 endif
1498
1499
1500 ## Rules for building preprocessed (.i/.ii) outputs.
1501 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1502         $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1503         $(Verb) $(Preprocess.CXX) $< -o $@
1504
1505 $(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1506         $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1507         $(Verb) $(Preprocess.CXX) $< -o $@
1508
1509 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1510         $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1511         $(Verb) $(Preprocess.CXX) $< -o $@
1512
1513 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1514         $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1515         $(Verb) $(Preprocess.C) $< -o $@
1516
1517 $(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1518         $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1519         $(Verb) $(Preprocess.C) $< -o $@
1520
1521
1522 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1523         $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1524         $(Compile.CXX) $< -o $@ -S
1525
1526 $(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1527         $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1528         $(Compile.CXX) $< -o $@ -S
1529
1530 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1531         $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1532         $(Compile.CXX) $< -o $@ -S
1533
1534 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1535         $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1536         $(Compile.C) $< -o $@ -S
1537
1538 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1539         $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1540         $(Compile.C) $< -o $@ -S
1541
1542 ###############################################################################
1543 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1544 ###############################################################################
1545
1546 ifdef TARGET
1547 TABLEGEN_INC_FILES_COMMON = 1
1548 endif
1549
1550 ifdef TABLEGEN_INC_FILES_COMMON
1551
1552 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1553 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1554 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1555
1556 # INCFiles rule: All of the tblgen generated files are emitted to
1557 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
1558 # us to only "touch" the real file if the contents of it change.  IOW, if
1559 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1560 # dependencies of the .inc files are, unless the contents of the .inc file
1561 # changes.
1562 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1563         $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1564
1565 endif # TABLEGEN_INC_FILES_COMMON
1566
1567 ifdef TARGET
1568
1569 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1570            $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1571            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1572            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1573            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1574            $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1575            $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1576
1577 # All .inc.tmp files depend on the .td files.
1578 $(INCTMPFiles) : $(TDFiles)
1579
1580 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1581 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1582         $(Echo) "Building $(<F) register info implementation with tblgen"
1583         $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1584
1585 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1586 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1587         $(Echo) "Building $(<F) instruction information with tblgen"
1588         $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1589
1590 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1591 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1592         $(Echo) "Building $(<F) assembly writer with tblgen"
1593         $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1594
1595 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1596 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1597         $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1598         $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1599
1600 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1601 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1602         $(Echo) "Building $(<F) assembly matcher with tblgen"
1603         $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1604
1605 $(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1606 $(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1607         $(Echo) "Building $(<F) MC code emitter with tblgen"
1608         $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1609
1610 $(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1611 $(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1612         $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1613         $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1614
1615 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1616 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1617         $(Echo) "Building $(<F) code emitter with tblgen"
1618         $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1619
1620 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1621 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1622         $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1623         $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1624
1625 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1626 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1627         $(Echo) "Building $(<F) disassembly tables with tblgen"
1628         $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1629
1630 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1631 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1632         $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1633         $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1634
1635 $(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1636 $(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1637         $(Echo) "Building $(<F) subtarget information with tblgen"
1638         $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1639
1640 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1641 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1642         $(Echo) "Building $(<F) calling convention information with tblgen"
1643         $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1644
1645 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1646 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1647         $(Echo) "Building $(<F) intrinsics information with tblgen"
1648         $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1649
1650 $(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1651         $(Echo) "Building $(<F) decoder tables with tblgen"
1652         $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1653
1654 $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1655         $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1656         $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1657
1658 clean-local::
1659         -$(Verb) $(RM) -f $(INCFiles)
1660
1661 endif # TARGET
1662
1663 ###############################################################################
1664 # OTHER RULES: Other rules needed
1665 ###############################################################################
1666
1667 # To create postscript files from dot files...
1668 ifneq ($(DOT),false)
1669 %.ps: %.dot
1670         $(DOT) -Tps < $< > $@
1671 else
1672 %.ps: %.dot
1673         $(Echo) "Cannot build $@: The program dot is not installed"
1674 endif
1675
1676 # This rules ensures that header files that are removed still have a rule for
1677 # which they can be "generated."  This allows make to ignore them and
1678 # reproduce the dependency lists.
1679 %.h:: ;
1680 %.hpp:: ;
1681
1682 # Define clean-local to clean the current directory. Note that this uses a
1683 # very conservative approach ensuring that empty variables do not cause
1684 # errors or disastrous removal.
1685 clean-local::
1686 ifneq ($(strip $(ObjRootDir)),)
1687         -$(Verb) $(RM) -rf $(ObjRootDir)
1688 endif
1689 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1690         -$(Verb) $(RM) -f *$(SHLIBEXT)
1691 endif
1692
1693 clean-all-local::
1694         -$(Verb) $(RM) -rf Debug Release Profile
1695
1696
1697 ###############################################################################
1698 # DEPENDENCIES: Include the dependency files if we should
1699 ###############################################################################
1700 ifndef DISABLE_AUTO_DEPENDENCIES
1701
1702 # If its not one of the cleaning targets
1703 ifndef IS_CLEANING_TARGET
1704
1705 # Get the list of dependency files
1706 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1707 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1708
1709 -include $(DependFiles) ""
1710
1711 endif
1712
1713 endif
1714
1715 ###############################################################################
1716 # CHECK: Running the test suite
1717 ###############################################################################
1718
1719 check:: all
1720         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1721           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1722             $(EchoCmd) Running test suite ; \
1723             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1724               TESTSUITE=$(TESTSUITE) ; \
1725           else \
1726             $(EchoCmd) No Makefile in test directory ; \
1727           fi ; \
1728         else \
1729           $(EchoCmd) No test directory ; \
1730         fi
1731
1732 # An alias dating from when both lit and DejaGNU test runners were used.
1733 check-lit:: check
1734
1735 check-all::
1736         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1737           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1738             $(EchoCmd) Running test suite ; \
1739             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1740           else \
1741             $(EchoCmd) No Makefile in test directory ; \
1742           fi ; \
1743         else \
1744           $(EchoCmd) No test directory ; \
1745         fi
1746
1747 ###############################################################################
1748 # UNITTESTS: Running the unittests test suite
1749 ###############################################################################
1750
1751 unittests::
1752         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1753           if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1754             $(EchoCmd) Running unittests test suite ; \
1755             $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1756           else \
1757             $(EchoCmd) No Makefile in unittests directory ; \
1758           fi ; \
1759         else \
1760           $(EchoCmd) No unittests directory ; \
1761         fi
1762
1763 ###############################################################################
1764 # DISTRIBUTION: Handle construction of a distribution tarball
1765 ###############################################################################
1766
1767 #------------------------------------------------------------------------
1768 # Define distribution related variables
1769 #------------------------------------------------------------------------
1770 DistName    := $(PROJECT_NAME)-$(PROJ_VERSION)
1771 DistDir     := $(PROJ_OBJ_ROOT)/$(DistName)
1772 TopDistDir  := $(PROJ_OBJ_ROOT)/$(DistName)
1773 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1774 DistZip     := $(PROJ_OBJ_ROOT)/$(DistName).zip
1775 DistTarBZ2  := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1776 DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1777                ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1778                Makefile.config.in configure autoconf
1779 DistOther   := $(notdir $(wildcard \
1780                $(PROJ_SRC_DIR)/*.h \
1781                $(PROJ_SRC_DIR)/*.td \
1782                $(PROJ_SRC_DIR)/*.def \
1783                $(PROJ_SRC_DIR)/*.ll \
1784                $(PROJ_SRC_DIR)/*.in))
1785 DistSubDirs := $(SubDirs)
1786 DistSources  = $(Sources) $(EXTRA_DIST)
1787 DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
1788
1789 #------------------------------------------------------------------------
1790 # We MUST build distribution with OBJ_DIR != SRC_DIR
1791 #------------------------------------------------------------------------
1792 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1793 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1794         $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1795
1796 else
1797
1798 #------------------------------------------------------------------------
1799 # Prevent attempt to run dist targets from anywhere but the top level
1800 #------------------------------------------------------------------------
1801 ifneq ($(LEVEL),.)
1802 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1803         $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1804 else
1805
1806 #------------------------------------------------------------------------
1807 # Provide the top level targets
1808 #------------------------------------------------------------------------
1809
1810 dist-gzip:: $(DistTarGZip)
1811
1812 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1813         $(Echo) Packing gzipped distribution tar file.
1814         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1815           $(GZIP) -c > "$(DistTarGZip)"
1816
1817 dist-bzip2:: $(DistTarBZ2)
1818
1819 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1820         $(Echo) Packing bzipped distribution tar file.
1821         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1822           $(BZIP2) -c >$(DistTarBZ2)
1823
1824 dist-zip:: $(DistZip)
1825
1826 $(DistZip) : $(TopDistDir)/.makedistdir
1827         $(Echo) Packing zipped distribution file.
1828         $(Verb) rm -f $(DistZip)
1829         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1830
1831 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1832         $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1833
1834 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1835
1836 dist-check:: $(DistTarGZip)
1837         $(Echo) Checking distribution tar file.
1838         $(Verb) if test -d $(DistCheckDir) ; then \
1839           $(RM) -rf $(DistCheckDir) ; \
1840         fi
1841         $(Verb) $(MKDIR) $(DistCheckDir)
1842         $(Verb) cd $(DistCheckDir) && \
1843           $(MKDIR) $(DistCheckDir)/build && \
1844           $(MKDIR) $(DistCheckDir)/install && \
1845           gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1846           cd build && \
1847           ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1848             --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1849           $(MAKE) all && \
1850           $(MAKE) check && \
1851           $(MAKE) unittests && \
1852           $(MAKE) install && \
1853           $(MAKE) uninstall && \
1854           $(MAKE) dist-clean && \
1855           $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1856
1857 dist-clean::
1858         $(Echo) Cleaning distribution files
1859         -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1860           $(DistCheckDir)
1861
1862 endif
1863
1864 #------------------------------------------------------------------------
1865 # Provide the recursive distdir target for building the distribution directory
1866 #------------------------------------------------------------------------
1867 distdir: $(DistDir)/.makedistdir
1868 $(DistDir)/.makedistdir: $(DistSources)
1869         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1870           if test -d "$(DistDir)" ; then \
1871             find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1872               exit 1 ; \
1873           fi ; \
1874           $(EchoCmd) Removing old $(DistDir) ; \
1875           $(RM) -rf $(DistDir); \
1876           $(EchoCmd) Making 'all' to verify build ; \
1877           $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1878         fi
1879         $(Echo) Building Distribution Directory $(DistDir)
1880         $(Verb) $(MKDIR) $(DistDir)
1881         $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1882         srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1883         for file in $(DistFiles) ; do \
1884           case "$$file" in \
1885             $(PROJ_SRC_DIR)/*) \
1886               file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1887               ;; \
1888             $(PROJ_SRC_ROOT)/*) \
1889               file=`echo "$$file" | \
1890                 sed "s#^$$srcrootstrip/##"` \
1891               ;; \
1892           esac; \
1893           if test -f "$(PROJ_SRC_DIR)/$$file" || \
1894              test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1895             from_dir="$(PROJ_SRC_DIR)" ; \
1896           elif test -f "$$file" || test -d "$$file" ; then \
1897             from_dir=. ; \
1898           fi ; \
1899           to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1900           if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1901             to_dir="$(DistDir)/$$dir"; \
1902             $(MKDIR) "$$to_dir" ; \
1903           else \
1904             to_dir="$(DistDir)"; \
1905           fi; \
1906           mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1907           if test -n "$$mid_dir" ; then \
1908             $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1909           fi ; \
1910           if test -d "$$from_dir/$$file"; then \
1911             if test -d "$(PROJ_SRC_DIR)/$$file" && \
1912                test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1913                cd $(PROJ_SRC_DIR) ; \
1914                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1915                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1916                cd $(PROJ_OBJ_DIR) ; \
1917             else \
1918                cd $$from_dir ; \
1919                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1920                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1921                cd $(PROJ_OBJ_DIR) ; \
1922             fi; \
1923           elif test -f "$$from_dir/$$file" ; then \
1924             $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1925           elif test -L "$$from_dir/$$file" ; then \
1926             $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1927           elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1928             $(EchoCmd) "===== WARNING: Distribution Source " \
1929               "$$from_dir/$$file Not Found!" ; \
1930           elif test "$(Verb)" != '@' ; then \
1931             $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1932           fi; \
1933         done
1934         $(Verb) for subdir in $(DistSubDirs) ; do \
1935           if test "$$subdir" \!= "." ; then \
1936             new_distdir="$(DistDir)/$$subdir" ; \
1937             test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1938             ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1939               DistDir="$$new_distdir" distdir ) || exit 1; \
1940           fi; \
1941         done
1942         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1943           $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1944           $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1945                                   -name .svn \) -print` ;\
1946           $(MAKE) dist-hook ; \
1947           $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1948             -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1949             -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1950             -o ! -type d ! -perm -444 -exec \
1951               $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1952             || chmod -R a+r $(DistDir) ; \
1953         fi
1954
1955 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1956 # defined by user.
1957 dist-hook::
1958
1959 endif
1960
1961 ###############################################################################
1962 # TOP LEVEL - targets only to apply at the top level directory
1963 ###############################################################################
1964
1965 ifeq ($(LEVEL),.)
1966
1967 #------------------------------------------------------------------------
1968 # Install support for the project's include files:
1969 #------------------------------------------------------------------------
1970 ifdef NO_INSTALL
1971 install-local::
1972         $(Echo) Install circumvented with NO_INSTALL
1973 uninstall-local::
1974         $(Echo) Uninstall circumvented with NO_INSTALL
1975 else
1976 install-local::
1977         $(Echo) Installing include files
1978         $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
1979         $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1980           cd $(PROJ_SRC_ROOT)/include && \
1981           for hdr in `find . -type f \
1982               '(' -name LICENSE.TXT \
1983                -o -name '*.def' \
1984                -o -name '*.h' \
1985                -o -name '*.inc' \
1986                -o -name '*.td' \
1987               ')' -print | grep -v CVS | \
1988               grep -v .svn` ; do \
1989             instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
1990             if test \! -d "$$instdir" ; then \
1991               $(EchoCmd) Making install directory $$instdir ; \
1992               $(MKDIR) $$instdir ;\
1993             fi ; \
1994             $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
1995           done ; \
1996         fi
1997 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1998         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1999           cd $(PROJ_OBJ_ROOT)/include && \
2000           for hdr in `find . -type f \
2001               '(' -name LICENSE.TXT \
2002                -o -name '*.def' \
2003                -o -name '*.h' \
2004                -o -name '*.inc' \
2005                -o -name '*.td' \
2006               ')' -print | grep -v CVS | \
2007               grep -v .svn` ; do \
2008             instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2009             if test \! -d "$$instdir" ; then \
2010               $(EchoCmd) Making install directory $$instdir ; \
2011               $(MKDIR) $$instdir ;\
2012             fi ; \
2013             $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2014           done ; \
2015         fi
2016 endif
2017
2018 uninstall-local::
2019         $(Echo) Uninstalling include files
2020         $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2021           cd $(PROJ_SRC_ROOT)/include && \
2022             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2023               '!' '(' -name '*~' -o -name '.#*' \
2024         -o -name '*.in' ')' -print ')' | \
2025         grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2026           cd $(PROJ_SRC_ROOT)/include && \
2027             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2028       -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2029         fi
2030 endif
2031 endif
2032
2033 check-line-length:
2034         @echo searching for overlength lines in files: $(Sources)
2035         @echo
2036         @echo
2037         egrep -n '.{81}' $(Sources) /dev/null
2038
2039 check-for-tabs:
2040         @echo searching for tabs in files: $(Sources)
2041         @echo
2042         @echo
2043         egrep -n '      ' $(Sources) /dev/null
2044
2045 check-footprint:
2046         @ls -l $(LibDir) | awk '\
2047           BEGIN { sum = 0; } \
2048                 { sum += $$5; } \
2049           END   { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2050         @ls -l $(ToolDir) | awk '\
2051           BEGIN { sum = 0; } \
2052                 { sum += $$5; } \
2053           END   { printf("Programs:  %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2054 #------------------------------------------------------------------------
2055 # Print out the directories used for building
2056 #------------------------------------------------------------------------
2057 printvars::
2058         $(Echo) "BuildMode    : " '$(BuildMode)'
2059         $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2060         $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2061         $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2062         $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2063         $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2064         $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2065         $(Echo) "PROJ_prefix  : " '$(PROJ_prefix)'
2066         $(Echo) "PROJ_internal_prefix  : " '$(PROJ_internal_prefix)'
2067         $(Echo) "PROJ_bindir  : " '$(PROJ_bindir)'
2068         $(Echo) "PROJ_libdir  : " '$(PROJ_libdir)'
2069         $(Echo) "PROJ_etcdir  : " '$(PROJ_etcdir)'
2070         $(Echo) "PROJ_includedir  : " '$(PROJ_includedir)'
2071         $(Echo) "UserTargets  : " '$(UserTargets)'
2072         $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2073         $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2074         $(Echo) "ObjDir       : " '$(ObjDir)'
2075         $(Echo) "LibDir       : " '$(LibDir)'
2076         $(Echo) "ToolDir      : " '$(ToolDir)'
2077         $(Echo) "ExmplDir     : " '$(ExmplDir)'
2078         $(Echo) "Sources      : " '$(Sources)'
2079         $(Echo) "TDFiles      : " '$(TDFiles)'
2080         $(Echo) "INCFiles     : " '$(INCFiles)'
2081         $(Echo) "INCTMPFiles  : " '$(INCTMPFiles)'
2082         $(Echo) "PreConditions: " '$(PreConditions)'
2083         $(Echo) "Compile.CXX  : " '$(Compile.CXX)'
2084         $(Echo) "Compile.C    : " '$(Compile.C)'
2085         $(Echo) "Archive      : " '$(Archive)'
2086         $(Echo) "YaccFiles    : " '$(YaccFiles)'
2087         $(Echo) "LexFiles     : " '$(LexFiles)'
2088         $(Echo) "Module       : " '$(Module)'
2089         $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2090         $(Echo) "SubDirs      : " '$(SubDirs)'
2091         $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2092         $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2093
2094 ###
2095 # Debugging
2096
2097 # General debugging rule, use 'make dbg-print-XXX' to print the
2098 # definition, value and origin of XXX.
2099 make-print-%:
2100         $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))