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