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