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