Eliminate CFERuntimeLibDir make variable, this shouldn't be needed.
[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
497 #--------------------------------------------------------------------
498 # Full Paths To Compiled Tools and Utilities
499 #--------------------------------------------------------------------
500 EchoCmd  = $(ECHO) llvm[$(MAKELEVEL)]:
501 Echo     = @$(EchoCmd)
502 ifndef LLVMAS
503 LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
504 endif
505 ifndef TBLGEN
506   ifeq ($(LLVM_CROSS_COMPILING),1)
507     TBLGEN   := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
508   else
509     TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
510   endif
511 endif
512 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
513 ifndef LLVMLD
514 LLVMLD    := $(LLVMToolDir)/llvm-ld$(EXEEXT)
515 endif
516 ifndef LLVMDIS
517 LLVMDIS  := $(LLVMToolDir)/llvm-dis$(EXEEXT)
518 endif
519 ifndef LLI
520 LLI      := $(LLVMToolDir)/lli$(EXEEXT)
521 endif
522 ifndef LLC
523 LLC      := $(LLVMToolDir)/llc$(EXEEXT)
524 endif
525 ifndef LOPT
526 LOPT     := $(LLVMToolDir)/opt$(EXEEXT)
527 endif
528 ifndef LBUGPOINT
529 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
530 endif
531
532 #--------------------------------------------------------------------
533 # Adjust to user's request
534 #--------------------------------------------------------------------
535
536 ifeq ($(HOST_OS),Darwin)
537   DARWIN_VERSION := `sw_vers -productVersion`
538   # Strip a number like 10.4.7 to 10.4
539   DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
540   # Get "4" out of 10.4 for later pieces in the makefile.
541   DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
542
543   SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
544                     -dynamiclib
545   ifneq ($(ARCH),ARM)
546     SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
547   endif
548 else
549   ifeq ($(HOST_OS),Cygwin)
550     SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
551                       -Wl,--enable-auto-import -Wl,--enable-auto-image-base
552   else
553     SharedLinkOptions=-shared
554   endif
555 endif
556
557 ifeq ($(TARGET_OS),Darwin)
558   ifneq ($(ARCH),ARM)
559     TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
560   else
561     TargetCommonOpts += -marm
562   endif
563 endif
564
565 # Adjust LD.Flags depending on the kind of library that is to be built. Note
566 # that if LOADABLE_MODULE is specified then the resulting shared library can
567 # be opened with dlopen.
568 ifdef LOADABLE_MODULE
569   LD.Flags += -module
570 endif
571
572 ifdef SHARED_LIBRARY
573 ifneq ($(DARWIN_MAJVERS),4)
574   LD.Flags += $(RPATH) -Wl,$(LibDir)
575 endif
576 endif
577
578 ifdef TOOL_VERBOSE
579   C.Flags += -v
580   CXX.Flags += -v
581   LD.Flags += -v
582   VERBOSE := 1
583 endif
584
585 # Adjust settings for verbose mode
586 ifndef VERBOSE
587   Verb := @
588   AR.Flags += >/dev/null 2>/dev/null
589   ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
590 else
591   ConfigureScriptFLAGS :=
592 endif
593
594 # By default, strip symbol information from executable
595 ifndef KEEP_SYMBOLS
596   Strip := $(PLATFORMSTRIPOPTS)
597   StripWarnMsg := "(without symbols)"
598   Install.StripFlag += -s
599 endif
600
601 # Adjust linker flags for building an executable
602 ifneq ($(HOST_OS),Darwin)
603 ifneq ($(DARWIN_MAJVERS),4)
604 ifdef TOOLNAME
605 ifdef EXAMPLE_TOOL
606   LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
607 else
608   LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
609 endif
610 endif
611 endif
612 endif
613
614 #----------------------------------------------------------
615 # Options To Invoke Tools
616 #----------------------------------------------------------
617
618 ifndef NO_PEDANTIC
619 CompileCommonOpts += -pedantic -Wno-long-long
620 endif
621 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
622                      $(EXTRA_OPTIONS)
623
624 ifeq ($(HOST_OS),HP-UX)
625   CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
626 endif
627
628 # If we are building a universal binary on Mac OS/X, pass extra options.  This
629 # is useful to people that want to link the LLVM libraries into their universal
630 # apps.
631 #
632 # The following can be optionally specified:
633 #   UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
634 #      For Mac OS/X 10.4 Intel machines, the traditional one is:
635 #      UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
636 #   UNIVERSAL_ARCH can be optionally specified to be a list of architectures
637 #      to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64".  This defaults to
638 #      i386/ppc only.
639 ifdef UNIVERSAL
640   ifndef UNIVERSAL_ARCH
641     UNIVERSAL_ARCH := i386 ppc
642   endif
643   UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
644   CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
645   ifdef UNIVERSAL_SDK_PATH
646     CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
647   endif
648
649   # Building universal cannot compute dependencies automatically.
650   DISABLE_AUTO_DEPENDENCIES=1
651 else
652   ifeq ($(TARGET_OS),Darwin)
653     ifeq ($(ARCH),x86_64)
654       TargetCommonOpts = -m64
655     else
656       ifeq ($(ARCH),x86)
657         TargetCommonOpts = -m32
658       endif
659     endif
660   endif
661 endif
662
663 ifeq ($(HOST_OS),SunOS)
664 CPP.BaseFlags += -include llvm/System/Solaris.h
665 endif
666
667 ifeq ($(HOST_OS),AuroraUX)
668 CPP.BaseFlags += -include llvm/System/Solaris.h
669 endif # !HOST_OS - AuroraUX.
670
671 LD.Flags      += -L$(LibDir) -L$(LLVMLibDir)
672 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
673 # All -I flags should go here, so that they don't confuse llvm-config.
674 CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
675                  $(patsubst %,-I%/include,\
676                  $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
677                  $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
678                  $(CPP.BaseFlags)
679
680 ifeq ($(BUILD_COMPONENT), 1)
681   Compile.C     = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
682                   $(TargetCommonOpts) $(CompileCommonOpts) -c
683   Compile.CXX   = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
684                   $(CPPFLAGS) \
685                   $(TargetCommonOpts) $(CompileCommonOpts) -c
686   Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
687                   $(CompileCommonOpts) $(CXX.Flags) -E
688   Link          = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
689                   $(LDFLAGS) \
690                   $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
691 else
692   Compile.C     = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
693                   $(TargetCommonOpts) $(CompileCommonOpts) -c
694   Compile.CXX   = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
695                   $(TargetCommonOpts) $(CompileCommonOpts) -c
696   Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
697                   $(CompileCommonOpts) $(CXX.Flags) -E
698   Link          = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
699                   $(TargetCommonOpts)  $(CompileCommonOpts) $(LD.Flags) $(Strip)
700 endif
701
702 BCCompile.C   = $(LLVMGCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
703                 $(TargetCommonOpts) $(CompileCommonOpts)
704 Preprocess.C  = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
705                 $(TargetCommonOpts) $(CompileCommonOpts) -E
706
707 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
708                 $(TargetCommonOpts) $(CompileCommonOpts)
709
710 ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755
711 ScriptInstall = $(INSTALL) -m 0755
712 DataInstall   = $(INSTALL) -m 0644
713
714 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
715 # paths. In this case, the SYSPATH function (defined in
716 # Makefile.config) transforms Unix paths into Windows paths.
717 TableGen      = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
718                 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
719                 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
720                 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
721
722 Archive       = $(AR) $(AR.Flags)
723 LArchive      = $(LLVMToolDir)/llvm-ar rcsf
724 ifdef RANLIB
725 Ranlib        = $(RANLIB)
726 else
727 Ranlib        = ranlib
728 endif
729
730 AliasTool     = ln -s
731
732 #----------------------------------------------------------
733 # Get the list of source files and compute object file
734 # names from them.
735 #----------------------------------------------------------
736
737 ifndef SOURCES
738   Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
739              $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
740 else
741   Sources := $(SOURCES)
742 endif
743
744 ifdef BUILT_SOURCES
745 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
746 endif
747
748 BaseNameSources := $(sort $(basename $(Sources)))
749
750 ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
751 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
752
753 ###############################################################################
754 # DIRECTORIES: Handle recursive descent of directory structure
755 ###############################################################################
756
757 #---------------------------------------------------------
758 # Provide rules to make install dirs. This must be early
759 # in the file so they get built before dependencies
760 #---------------------------------------------------------
761
762 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
763         $(Verb) $(MKDIR) $@
764
765 # To create other directories, as needed, and timestamp their creation
766 %/.dir:
767         $(Verb) $(MKDIR) $* > /dev/null
768         $(Verb) $(DATE) > $@
769
770 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
771 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
772
773 #---------------------------------------------------------
774 # Handle the DIRS options for sequential construction
775 #---------------------------------------------------------
776
777 SubDirs :=
778 ifdef DIRS
779 SubDirs += $(DIRS)
780
781 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
782 $(RecursiveTargets)::
783         $(Verb) for dir in $(DIRS); do \
784           if [ ! -f $$dir/Makefile ]; then \
785             $(MKDIR) $$dir; \
786             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
787           fi; \
788           ($(MAKE) -C $$dir $@ ) || exit 1; \
789         done
790 else
791 $(RecursiveTargets)::
792         $(Verb) for dir in $(DIRS); do \
793           ($(MAKE) -C $$dir $@ ) || exit 1; \
794         done
795 endif
796
797 endif
798
799 #---------------------------------------------------------
800 # Handle the EXPERIMENTAL_DIRS options ensuring success
801 # after each directory is built.
802 #---------------------------------------------------------
803 ifdef EXPERIMENTAL_DIRS
804 $(RecursiveTargets)::
805         $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
806           if [ ! -f $$dir/Makefile ]; then \
807             $(MKDIR) $$dir; \
808             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
809           fi; \
810           ($(MAKE) -C $$dir $@ ) || exit 0; \
811         done
812 endif
813
814 #-----------------------------------------------------------
815 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
816 #-----------------------------------------------------------
817 ifdef OPTIONAL_PARALLEL_DIRS
818   PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
819 endif
820
821 #-----------------------------------------------------------
822 # Handle the PARALLEL_DIRS options for parallel construction
823 #-----------------------------------------------------------
824 ifdef PARALLEL_DIRS
825
826 SubDirs += $(PARALLEL_DIRS)
827
828 # Unfortunately, this list must be maintained if new recursive targets are added
829 all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
830 clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
831 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
832 install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
833 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
834 install-bytecode  :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
835 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
836
837 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
838
839 $(ParallelTargets) :
840         $(Verb) if [ ! -f $(@D)/Makefile ]; then \
841           $(MKDIR) $(@D); \
842           $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
843         fi; \
844         $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
845 endif
846
847 #---------------------------------------------------------
848 # Handle the OPTIONAL_DIRS options for directores that may
849 # or may not exist.
850 #---------------------------------------------------------
851 ifdef OPTIONAL_DIRS
852
853 SubDirs += $(OPTIONAL_DIRS)
854
855 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
856 $(RecursiveTargets)::
857         $(Verb) for dir in $(OPTIONAL_DIRS); do \
858           if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
859             if [ ! -f $$dir/Makefile ]; then \
860               $(MKDIR) $$dir; \
861               $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
862             fi; \
863             ($(MAKE) -C$$dir $@ ) || exit 1; \
864           fi \
865         done
866 else
867 $(RecursiveTargets)::
868         $(Verb) for dir in $(OPTIONAL_DIRS); do \
869           ($(MAKE) -C$$dir $@ ) || exit 1; \
870         done
871 endif
872 endif
873
874 #---------------------------------------------------------
875 # Handle the CONFIG_FILES options
876 #---------------------------------------------------------
877 ifdef CONFIG_FILES
878
879 ifdef NO_INSTALL
880 install-local::
881         $(Echo) Install circumvented with NO_INSTALL
882 uninstall-local::
883         $(Echo) UnInstall circumvented with NO_INSTALL
884 else
885 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
886         $(Echo) Installing Configuration Files To $(PROJ_etcdir)
887         $(Verb)for file in $(CONFIG_FILES); do \
888           if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
889             $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
890           elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
891             $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
892           else \
893             $(ECHO) Error: cannot find config file $${file}. ; \
894           fi \
895         done
896
897 uninstall-local::
898         $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
899         $(Verb)for file in $(CONFIG_FILES); do \
900           $(RM) -f $(PROJ_etcdir)/$${file} ; \
901         done
902 endif
903
904 endif
905
906 ###############################################################################
907 # Set up variables for building libararies
908 ###############################################################################
909
910 #---------------------------------------------------------
911 # Define various command line options pertaining to the
912 # libraries needed when linking. There are "Proj" libs
913 # (defined by the user's project) and "LLVM" libs (defined
914 # by the LLVM project).
915 #---------------------------------------------------------
916
917 ifdef USEDLIBS
918 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
919 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
920 ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
921 ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
922 endif
923
924 ifdef LLVMLIBS
925 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
926 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
927 LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
928 LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
929 endif
930
931 ifndef IS_CLEANING_TARGET
932 ifdef LINK_COMPONENTS
933
934 # If LLVM_CONFIG doesn't exist, build it.  This can happen if you do a make
935 # clean in tools, then do a make in tools (instead of at the top level).
936 $(LLVM_CONFIG):
937         @echo "*** llvm-config doesn't exist - rebuilding it."
938         @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
939
940 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
941
942 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs     $(LINK_COMPONENTS))
943 LLVMLibsPaths   += $(LLVM_CONFIG) \
944                    $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
945 endif
946 endif
947
948 ###############################################################################
949 # Library Build Rules: Four ways to build a library
950 ###############################################################################
951
952 #---------------------------------------------------------
953 # Bytecode Module Targets:
954 #   If the user set MODULE_NAME then they want to build a
955 #   bytecode module from the sources. We compile all the
956 #   sources and link it together into a single bytecode
957 #   module.
958 #---------------------------------------------------------
959
960 ifdef MODULE_NAME
961 ifeq ($(strip $(LLVMGCC)),)
962 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
963 else
964
965 Module     := $(LibDir)/$(MODULE_NAME).bc
966 LinkModule := $(LLVMLD) -r
967
968
969 ifdef EXPORTED_SYMBOL_FILE
970 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
971 endif
972
973 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
974         $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
975         $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
976
977 all-local:: $(Module)
978
979 clean-local::
980 ifneq ($(strip $(Module)),)
981         -$(Verb) $(RM) -f $(Module)
982 endif
983
984 ifdef BYTECODE_DESTINATION
985 ModuleDestDir := $(BYTECODE_DESTINATION)
986 else
987 ModuleDestDir := $(PROJ_libdir)
988 endif
989
990 ifdef NO_INSTALL
991 install-local::
992         $(Echo) Install circumvented with NO_INSTALL
993 uninstall-local::
994         $(Echo) Uninstall circumvented with NO_INSTALL
995 else
996 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
997
998 install-module:: $(DestModule)
999 install-local:: $(DestModule)
1000
1001 $(DestModule): $(ModuleDestDir) $(Module)
1002         $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1003         $(Verb) $(DataInstall) $(Module) $(DestModule)
1004
1005 uninstall-local::
1006         $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1007         -$(Verb) $(RM) -f $(DestModule)
1008 endif
1009
1010 endif
1011 endif
1012
1013 # if we're building a library ...
1014 ifdef LIBRARYNAME
1015
1016 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1017 LIBRARYNAME := $(strip $(LIBRARYNAME))
1018 ifdef LOADABLE_MODULE
1019 LibName.A  := $(LibDir)/$(LIBRARYNAME).a
1020 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
1021 else
1022 LibName.A  := $(LibDir)/lib$(LIBRARYNAME).a
1023 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1024 endif
1025 LibName.O  := $(LibDir)/$(LIBRARYNAME).o
1026 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1027
1028 #---------------------------------------------------------
1029 # Shared Library Targets:
1030 #   If the user asked for a shared library to be built
1031 #   with the SHARED_LIBRARY variable, then we provide
1032 #   targets for building them.
1033 #---------------------------------------------------------
1034 ifdef SHARED_LIBRARY
1035
1036 all-local:: $(LibName.SO)
1037
1038 ifdef LINK_LIBS_IN_SHARED
1039 ifdef LOADABLE_MODULE
1040 SharedLibKindMessage := "Loadable Module"
1041 else
1042 SharedLibKindMessage := "Shared Library"
1043 endif
1044 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
1045         $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1046           $(LIBRARYNAME)$(SHLIBEXT)
1047         $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1048           $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1049 else
1050 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
1051         $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
1052         $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1053 endif
1054
1055 clean-local::
1056 ifneq ($(strip $(LibName.SO)),)
1057         -$(Verb) $(RM) -f $(LibName.SO)
1058 endif
1059
1060 ifdef NO_INSTALL
1061 install-local::
1062         $(Echo) Install circumvented with NO_INSTALL
1063 uninstall-local::
1064         $(Echo) Uninstall circumvented with NO_INSTALL
1065 else
1066 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1067
1068 install-local:: $(DestSharedLib)
1069
1070 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
1071         $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1072         $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1073
1074 uninstall-local::
1075         $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1076         -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1077 endif
1078 endif
1079
1080 #---------------------------------------------------------
1081 # Bytecode Library Targets:
1082 #   If the user asked for a bytecode library to be built
1083 #   with the BYTECODE_LIBRARY variable, then we provide
1084 #   targets for building them.
1085 #---------------------------------------------------------
1086 ifdef BYTECODE_LIBRARY
1087 ifeq ($(strip $(LLVMGCC)),)
1088 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
1089 else
1090
1091 all-local:: $(LibName.BCA)
1092
1093 ifdef EXPORTED_SYMBOL_FILE
1094 BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1095
1096 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1097                 $(LLVMToolDir)/llvm-ar
1098         $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1099           "(internalize)"
1100         $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1101         $(Verb) $(RM) -f $@
1102         $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1103 else
1104 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1105                 $(LLVMToolDir)/llvm-ar
1106         $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1107         $(Verb) $(RM) -f $@
1108         $(Verb) $(LArchive) $@ $(ObjectsBC)
1109
1110 endif
1111
1112 clean-local::
1113 ifneq ($(strip $(LibName.BCA)),)
1114         -$(Verb) $(RM) -f $(LibName.BCA)
1115 endif
1116
1117 ifdef BYTECODE_DESTINATION
1118 BytecodeDestDir := $(BYTECODE_DESTINATION)
1119 else
1120 BytecodeDestDir := $(PROJ_libdir)
1121 endif
1122
1123 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1124
1125 install-bytecode-local:: $(DestBytecodeLib)
1126
1127 ifdef NO_INSTALL
1128 install-local::
1129         $(Echo) Install circumvented with NO_INSTALL
1130 uninstall-local::
1131         $(Echo) Uninstall circumvented with NO_INSTALL
1132 else
1133 install-local:: $(DestBytecodeLib)
1134
1135 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1136         $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1137         $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1138
1139 uninstall-local::
1140         $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1141         -$(Verb) $(RM) -f $(DestBytecodeLib)
1142 endif
1143 endif
1144 endif
1145
1146 #---------------------------------------------------------
1147 # Library Targets:
1148 #   If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1149 #   building an archive.
1150 #---------------------------------------------------------
1151 ifndef BUILD_ARCHIVE
1152 ifndef LOADABLE_MODULE
1153 BUILD_ARCHIVE = 1
1154 endif
1155 endif
1156
1157 #---------------------------------------------------------
1158 # Archive Library Targets:
1159 #   If the user wanted a regular archive library built,
1160 #   then we provide targets for building them.
1161 #---------------------------------------------------------
1162 ifdef BUILD_ARCHIVE
1163
1164 all-local:: $(LibName.A)
1165
1166 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1167         $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1168         -$(Verb) $(RM) -f $@
1169         $(Verb) $(Archive) $@ $(ObjectsO)
1170         $(Verb) $(Ranlib) $@
1171
1172 clean-local::
1173 ifneq ($(strip $(LibName.A)),)
1174         -$(Verb) $(RM) -f $(LibName.A)
1175 endif
1176
1177 ifdef NO_INSTALL
1178 install-local::
1179         $(Echo) Install circumvented with NO_INSTALL
1180 uninstall-local::
1181         $(Echo) Uninstall circumvented with NO_INSTALL
1182 else
1183 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1184
1185 install-local:: $(DestArchiveLib)
1186
1187 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1188         $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1189         $(Verb) $(MKDIR) $(PROJ_libdir)
1190         $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1191
1192 uninstall-local::
1193         $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1194         -$(Verb) $(RM) -f $(DestArchiveLib)
1195 endif
1196 endif
1197
1198 # endif LIBRARYNAME
1199 endif
1200
1201 ###############################################################################
1202 # Tool Build Rules: Build executable tool based on TOOLNAME option
1203 ###############################################################################
1204
1205 ifdef TOOLNAME
1206
1207 #---------------------------------------------------------
1208 # Set up variables for building a tool.
1209 #---------------------------------------------------------
1210 TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1211 ifdef EXAMPLE_TOOL
1212 ToolBuildPath   := $(ExmplDir)/$(TOOLEXENAME)
1213 else
1214 ToolBuildPath   := $(ToolDir)/$(TOOLEXENAME)
1215 endif
1216
1217 # TOOLALIAS is a name to symlink (or copy) the tool to.
1218 ifdef TOOLALIAS
1219 ifdef EXAMPLE_TOOL
1220 ToolAliasBuildPath   := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1221 else
1222 ToolAliasBuildPath   := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1223 endif
1224 endif
1225
1226 #---------------------------------------------------------
1227 # Prune Exports
1228 #---------------------------------------------------------
1229
1230 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1231 # not exporting all of the weak symbols from the binary.  This reduces dyld
1232 # startup time by 4x on darwin in some cases.
1233 ifdef TOOL_NO_EXPORTS
1234 ifeq ($(HOST_OS),Darwin)
1235
1236 # Tiger tools don't support this.
1237 ifneq ($(DARWIN_MAJVERS),4)
1238 LD.Flags += -Wl,-exported_symbol -Wl,_main
1239 endif
1240 endif
1241
1242 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1243   LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1244 endif
1245 endif
1246
1247
1248 #---------------------------------------------------------
1249 # Provide targets for building the tools
1250 #---------------------------------------------------------
1251 all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1252
1253 clean-local::
1254 ifneq ($(strip $(ToolBuildPath)),)
1255         -$(Verb) $(RM) -f $(ToolBuildPath)
1256 endif
1257 ifneq ($(strip $(ToolAliasBuildPath)),)
1258         -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1259 endif
1260
1261 ifdef EXAMPLE_TOOL
1262 $(ToolBuildPath): $(ExmplDir)/.dir
1263 else
1264 $(ToolBuildPath): $(ToolDir)/.dir
1265 endif
1266
1267 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1268         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1269         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1270         $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1271         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1272           $(StripWarnMsg)
1273
1274 ifneq ($(strip $(ToolAliasBuildPath)),)
1275 $(ToolAliasBuildPath): $(ToolBuildPath)
1276         $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1277         $(Verb) $(RM) -f $(ToolAliasBuildPath)
1278         $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1279         $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLNAME) \
1280           $(StripWarnMsg)
1281 endif
1282
1283 ifdef NO_INSTALL
1284 install-local::
1285         $(Echo) Install circumvented with NO_INSTALL
1286 uninstall-local::
1287         $(Echo) Uninstall circumvented with NO_INSTALL
1288 else
1289 DestTool = $(PROJ_bindir)/$(TOOLEXENAME)
1290
1291 install-local:: $(DestTool)
1292
1293 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1294         $(Echo) Installing $(BuildMode) $(DestTool)
1295         $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1296
1297 uninstall-local::
1298         $(Echo) Uninstalling $(BuildMode) $(DestTool)
1299         -$(Verb) $(RM) -f $(DestTool)
1300
1301 # TOOLALIAS install.
1302 ifdef TOOLALIAS
1303 DestToolAlias = $(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)
1304
1305 install-local:: $(DestToolAlias)
1306
1307 $(DestToolAlias): $(DestTool) $(PROJ_bindir)
1308         $(Echo) Installing $(BuildMode) $(DestToolAlias)
1309         $(Verb) $(RM) -f $(DestToolAlias)
1310         $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1311
1312 uninstall-local::
1313         $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1314         -$(Verb) $(RM) -f $(DestToolAlias)
1315 endif
1316
1317 endif
1318 endif
1319
1320 ###############################################################################
1321 # Object Build Rules: Build object files based on sources
1322 ###############################################################################
1323
1324 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1325 ifeq ($(HOST_OS),HP-UX)
1326   DISABLE_AUTO_DEPENDENCIES=1
1327 endif
1328
1329 # Provide rule sets for when dependency generation is enabled
1330 ifndef DISABLE_AUTO_DEPENDENCIES
1331
1332 #---------------------------------------------------------
1333 # Create .o files in the ObjDir directory from the .cpp and .c files...
1334 #---------------------------------------------------------
1335
1336 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1337          -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1338
1339 # If the build succeeded, move the dependency file over, otherwise
1340 # remove it.
1341 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1342                   else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1343
1344 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1345         $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1346         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1347                 $(DEPEND_MOVEFILE)
1348
1349 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1350         $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1351         $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1352                 $(DEPEND_MOVEFILE)
1353
1354 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
1355         $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1356         $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1357                 $(DEPEND_MOVEFILE)
1358
1359 #---------------------------------------------------------
1360 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1361 #---------------------------------------------------------
1362
1363 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1364         -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1365
1366 # If the build succeeded, move the dependency file over, otherwise
1367 # remove it.
1368 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1369                      else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1370
1371 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1372         $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1373         $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1374                               $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1375                 $(BC_DEPEND_MOVEFILE)
1376
1377 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1378         $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1379         $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1380                               $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1381                 $(BC_DEPEND_MOVEFILE)
1382
1383 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1384         $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1385         $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1386                               $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1387                 $(BC_DEPEND_MOVEFILE)
1388
1389 # Provide alternate rule sets if dependencies are disabled
1390 else
1391
1392 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1393         $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1394         $(Compile.CXX) $< -o $@
1395
1396 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1397         $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1398         $(Compile.CXX) $< -o $@
1399
1400 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1401         $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1402         $(Compile.C) $< -o $@
1403
1404 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1405         $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1406         $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1407
1408 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1409         $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1410         $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1411
1412 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1413         $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1414         $(BCCompile.C) $< -o $@ -S -emit-llvm
1415
1416 endif
1417
1418
1419 ## Rules for building preprocessed (.i/.ii) outputs.
1420 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1421         $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1422         $(Verb) $(Preprocess.CXX) $< -o $@
1423
1424 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1425         $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1426         $(Verb) $(Preprocess.CXX) $< -o $@
1427
1428 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1429         $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1430         $(Verb) $(Preprocess.C) $< -o $@
1431
1432
1433 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1434         $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1435         $(Compile.CXX) $< -o $@ -S
1436
1437 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1438         $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1439         $(Compile.CXX) $< -o $@ -S
1440
1441 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1442         $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1443         $(Compile.C) $< -o $@ -S
1444
1445
1446 # make the C and C++ compilers strip debug info out of bytecode libraries.
1447 ifdef DEBUG_RUNTIME
1448 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1449         $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1450         $(Verb) $(LOPT) $< -std-compile-opts -o $@
1451 else
1452 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1453         $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1454         $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1455 endif
1456
1457
1458 #---------------------------------------------------------
1459 # Provide rule to build .bc files from .ll sources,
1460 # regardless of dependencies
1461 #---------------------------------------------------------
1462 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1463         $(Echo) "Compiling $*.ll for $(BuildMode) build"
1464         $(Verb) $(LLVMAS) $< -f -o $@
1465
1466 ###############################################################################
1467 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1468 ###############################################################################
1469
1470 ifdef TARGET
1471 TABLEGEN_INC_FILES_COMMON = 1
1472 endif
1473
1474 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1475 TABLEGEN_INC_FILES_COMMON = 1
1476 endif
1477
1478 ifdef TABLEGEN_INC_FILES_COMMON
1479
1480 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1481 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1482 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1483
1484 # INCFiles rule: All of the tblgen generated files are emitted to
1485 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
1486 # us to only "touch" the real file if the contents of it change.  IOW, if
1487 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1488 # dependencies of the .inc files are, unless the contents of the .inc file
1489 # changes.
1490 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1491         $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1492
1493 endif # TABLEGEN_INC_FILES_COMMON
1494
1495 ifdef TARGET
1496
1497 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1498            $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1499            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1500            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1501            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1502            $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1503            $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1504
1505 # All of these files depend on tblgen and the .td files.
1506 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1507
1508 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1509 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1510         $(Echo) "Building $(<F) register names with tblgen"
1511         $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1512
1513 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1514 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1515         $(Echo) "Building $(<F) register information header with tblgen"
1516         $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1517
1518 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1519 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1520         $(Echo) "Building $(<F) register info implementation with tblgen"
1521         $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1522
1523 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1524 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1525         $(Echo) "Building $(<F) instruction names with tblgen"
1526         $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1527
1528 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1529 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1530         $(Echo) "Building $(<F) instruction information with tblgen"
1531         $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1532
1533 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1534 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1535         $(Echo) "Building $(<F) assembly writer with tblgen"
1536         $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1537
1538 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1539 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1540         $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1541         $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1542
1543 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1544 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1545         $(Echo) "Building $(<F) assembly matcher with tblgen"
1546         $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1547
1548 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1549 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1550         $(Echo) "Building $(<F) code emitter with tblgen"
1551         $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1552
1553 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1554 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1555         $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1556         $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1557
1558 $(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1559 $(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir
1560         $(Echo) "Building $(<F) disassembly tables with tblgen"
1561         $(Verb) $(TableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1562
1563 $(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1564 $(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir
1565         $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1566         $(Verb) $(TableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1567
1568 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1569 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1570         $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1571         $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1572
1573 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1574 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1575         $(Echo) "Building $(<F) subtarget information with tblgen"
1576         $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1577
1578 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1579 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1580         $(Echo) "Building $(<F) calling convention information with tblgen"
1581         $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1582
1583 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1584 $(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir
1585         $(Echo) "Building $(<F) intrinsics information with tblgen"
1586         $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1587
1588 clean-local::
1589         -$(Verb) $(RM) -f $(INCFiles)
1590
1591 endif # TARGET
1592
1593 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1594
1595 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1596         $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1597
1598 TDFiles := $(LLVMCPluginSrc) \
1599         $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1600
1601 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1602                                 $(TBLGEN) $(TD_COMMON)
1603         $(Echo) "Building LLVMC configuration library with tblgen"
1604         $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1605
1606 endif # LLVMC_BUILD_AUTOGENERATED_INC
1607
1608 ###############################################################################
1609 # OTHER RULES: Other rules needed
1610 ###############################################################################
1611
1612 # To create postscript files from dot files...
1613 ifneq ($(DOT),false)
1614 %.ps: %.dot
1615         $(DOT) -Tps < $< > $@
1616 else
1617 %.ps: %.dot
1618         $(Echo) "Cannot build $@: The program dot is not installed"
1619 endif
1620
1621 # This rules ensures that header files that are removed still have a rule for
1622 # which they can be "generated."  This allows make to ignore them and
1623 # reproduce the dependency lists.
1624 %.h:: ;
1625 %.hpp:: ;
1626
1627 # Define clean-local to clean the current directory. Note that this uses a
1628 # very conservative approach ensuring that empty variables do not cause
1629 # errors or disastrous removal.
1630 clean-local::
1631 ifneq ($(strip $(ObjRootDir)),)
1632         -$(Verb) $(RM) -rf $(ObjRootDir)
1633 endif
1634         -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1635 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1636         -$(Verb) $(RM) -f *$(SHLIBEXT)
1637 endif
1638
1639 clean-all-local::
1640         -$(Verb) $(RM) -rf Debug Release Profile
1641
1642
1643 ###############################################################################
1644 # DEPENDENCIES: Include the dependency files if we should
1645 ###############################################################################
1646 ifndef DISABLE_AUTO_DEPENDENCIES
1647
1648 # If its not one of the cleaning targets
1649 ifndef IS_CLEANING_TARGET
1650
1651 # Get the list of dependency files
1652 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1653 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1654
1655 # Include bitcode dependency files if using bitcode libraries
1656 ifdef BYTECODE_LIBRARY
1657 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1658 endif
1659
1660 -include $(DependFiles) ""
1661
1662 endif
1663
1664 endif
1665
1666 ###############################################################################
1667 # CHECK: Running the test suite
1668 ###############################################################################
1669
1670 check::
1671         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1672           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1673             $(EchoCmd) Running test suite ; \
1674             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1675               TESTSUITE=$(TESTSUITE) ; \
1676           else \
1677             $(EchoCmd) No Makefile in test directory ; \
1678           fi ; \
1679         else \
1680           $(EchoCmd) No test directory ; \
1681         fi
1682
1683 check-lit::
1684         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1685           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1686             $(EchoCmd) Running test suite ; \
1687             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1688           else \
1689             $(EchoCmd) No Makefile in test directory ; \
1690           fi ; \
1691         else \
1692           $(EchoCmd) No test directory ; \
1693         fi
1694
1695 check-all::
1696         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1697           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1698             $(EchoCmd) Running test suite ; \
1699             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1700           else \
1701             $(EchoCmd) No Makefile in test directory ; \
1702           fi ; \
1703         else \
1704           $(EchoCmd) No test directory ; \
1705         fi
1706
1707 ###############################################################################
1708 # UNITTESTS: Running the unittests test suite
1709 ###############################################################################
1710
1711 unittests::
1712         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1713           if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1714             $(EchoCmd) Running unittests test suite ; \
1715             $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1716           else \
1717             $(EchoCmd) No Makefile in unittests directory ; \
1718           fi ; \
1719         else \
1720           $(EchoCmd) No unittests directory ; \
1721         fi
1722
1723 ###############################################################################
1724 # DISTRIBUTION: Handle construction of a distribution tarball
1725 ###############################################################################
1726
1727 #------------------------------------------------------------------------
1728 # Define distribution related variables
1729 #------------------------------------------------------------------------
1730 DistName    := $(PROJECT_NAME)-$(PROJ_VERSION)
1731 DistDir     := $(PROJ_OBJ_ROOT)/$(DistName)
1732 TopDistDir  := $(PROJ_OBJ_ROOT)/$(DistName)
1733 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1734 DistZip     := $(PROJ_OBJ_ROOT)/$(DistName).zip
1735 DistTarBZ2  := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1736 DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1737                ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1738                Makefile.config.in configure autoconf
1739 DistOther   := $(notdir $(wildcard \
1740                $(PROJ_SRC_DIR)/*.h \
1741                $(PROJ_SRC_DIR)/*.td \
1742                $(PROJ_SRC_DIR)/*.def \
1743                $(PROJ_SRC_DIR)/*.ll \
1744                $(PROJ_SRC_DIR)/*.in))
1745 DistSubDirs := $(SubDirs)
1746 DistSources  = $(Sources) $(EXTRA_DIST)
1747 DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
1748
1749 #------------------------------------------------------------------------
1750 # We MUST build distribution with OBJ_DIR != SRC_DIR
1751 #------------------------------------------------------------------------
1752 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1753 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1754         $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1755
1756 else
1757
1758 #------------------------------------------------------------------------
1759 # Prevent attempt to run dist targets from anywhere but the top level
1760 #------------------------------------------------------------------------
1761 ifneq ($(LEVEL),.)
1762 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1763         $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1764 else
1765
1766 #------------------------------------------------------------------------
1767 # Provide the top level targets
1768 #------------------------------------------------------------------------
1769
1770 dist-gzip:: $(DistTarGZip)
1771
1772 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1773         $(Echo) Packing gzipped distribution tar file.
1774         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1775           $(GZIP) -c > "$(DistTarGZip)"
1776
1777 dist-bzip2:: $(DistTarBZ2)
1778
1779 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1780         $(Echo) Packing bzipped distribution tar file.
1781         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1782           $(BZIP2) -c >$(DistTarBZ2)
1783
1784 dist-zip:: $(DistZip)
1785
1786 $(DistZip) : $(TopDistDir)/.makedistdir
1787         $(Echo) Packing zipped distribution file.
1788         $(Verb) rm -f $(DistZip)
1789         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1790
1791 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1792         $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1793
1794 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1795
1796 dist-check:: $(DistTarGZip)
1797         $(Echo) Checking distribution tar file.
1798         $(Verb) if test -d $(DistCheckDir) ; then \
1799           $(RM) -rf $(DistCheckDir) ; \
1800         fi
1801         $(Verb) $(MKDIR) $(DistCheckDir)
1802         $(Verb) cd $(DistCheckDir) && \
1803           $(MKDIR) $(DistCheckDir)/build && \
1804           $(MKDIR) $(DistCheckDir)/install && \
1805           gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1806           cd build && \
1807           ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1808             --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1809           $(MAKE) all && \
1810           $(MAKE) check && \
1811           $(MAKE) unittests && \
1812           $(MAKE) install && \
1813           $(MAKE) uninstall && \
1814           $(MAKE) dist-clean && \
1815           $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1816
1817 dist-clean::
1818         $(Echo) Cleaning distribution files
1819         -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1820           $(DistCheckDir)
1821
1822 endif
1823
1824 #------------------------------------------------------------------------
1825 # Provide the recursive distdir target for building the distribution directory
1826 #------------------------------------------------------------------------
1827 distdir: $(DistDir)/.makedistdir
1828 $(DistDir)/.makedistdir: $(DistSources)
1829         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1830           if test -d "$(DistDir)" ; then \
1831             find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1832               exit 1 ; \
1833           fi ; \
1834           $(EchoCmd) Removing old $(DistDir) ; \
1835           $(RM) -rf $(DistDir); \
1836           $(EchoCmd) Making 'all' to verify build ; \
1837           $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1838         fi
1839         $(Echo) Building Distribution Directory $(DistDir)
1840         $(Verb) $(MKDIR) $(DistDir)
1841         $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1842         srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1843         for file in $(DistFiles) ; do \
1844           case "$$file" in \
1845             $(PROJ_SRC_DIR)/*) \
1846               file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1847               ;; \
1848             $(PROJ_SRC_ROOT)/*) \
1849               file=`echo "$$file" | \
1850                 sed "s#^$$srcrootstrip/##"` \
1851               ;; \
1852           esac; \
1853           if test -f "$(PROJ_SRC_DIR)/$$file" || \
1854              test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1855             from_dir="$(PROJ_SRC_DIR)" ; \
1856           elif test -f "$$file" || test -d "$$file" ; then \
1857             from_dir=. ; \
1858           fi ; \
1859           to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1860           if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1861             to_dir="$(DistDir)/$$dir"; \
1862             $(MKDIR) "$$to_dir" ; \
1863           else \
1864             to_dir="$(DistDir)"; \
1865           fi; \
1866           mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1867           if test -n "$$mid_dir" ; then \
1868             $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1869           fi ; \
1870           if test -d "$$from_dir/$$file"; then \
1871             if test -d "$(PROJ_SRC_DIR)/$$file" && \
1872                test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1873                cd $(PROJ_SRC_DIR) ; \
1874                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1875                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1876                cd $(PROJ_OBJ_DIR) ; \
1877             else \
1878                cd $$from_dir ; \
1879                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1880                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1881                cd $(PROJ_OBJ_DIR) ; \
1882             fi; \
1883           elif test -f "$$from_dir/$$file" ; then \
1884             $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1885           elif test -L "$$from_dir/$$file" ; then \
1886             $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1887           elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1888             $(EchoCmd) "===== WARNING: Distribution Source " \
1889               "$$from_dir/$$file Not Found!" ; \
1890           elif test "$(Verb)" != '@' ; then \
1891             $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1892           fi; \
1893         done
1894         $(Verb) for subdir in $(DistSubDirs) ; do \
1895           if test "$$subdir" \!= "." ; then \
1896             new_distdir="$(DistDir)/$$subdir" ; \
1897             test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1898             ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1899               DistDir="$$new_distdir" distdir ) || exit 1; \
1900           fi; \
1901         done
1902         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1903           $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1904           $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1905                                   -name .svn \) -print` ;\
1906           $(MAKE) dist-hook ; \
1907           $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1908             -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1909             -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1910             -o ! -type d ! -perm -444 -exec \
1911               $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1912             || chmod -R a+r $(DistDir) ; \
1913         fi
1914
1915 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1916 # defined by user.
1917 dist-hook::
1918
1919 endif
1920
1921 ###############################################################################
1922 # TOP LEVEL - targets only to apply at the top level directory
1923 ###############################################################################
1924
1925 ifeq ($(LEVEL),.)
1926
1927 #------------------------------------------------------------------------
1928 # Install support for the project's include files:
1929 #------------------------------------------------------------------------
1930 ifdef NO_INSTALL
1931 install-local::
1932         $(Echo) Install circumvented with NO_INSTALL
1933 uninstall-local::
1934         $(Echo) Uninstall circumvented with NO_INSTALL
1935 else
1936 install-local::
1937         $(Echo) Installing include files
1938         $(Verb) $(MKDIR) $(PROJ_includedir)
1939         $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1940           cd $(PROJ_SRC_ROOT)/include && \
1941           for  hdr in `find . -type f '!' '(' -name '*~' \
1942               -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1943               grep -v .svn` ; do \
1944             instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1945             if test \! -d "$$instdir" ; then \
1946               $(EchoCmd) Making install directory $$instdir ; \
1947               $(MKDIR) $$instdir ;\
1948             fi ; \
1949             $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1950           done ; \
1951         fi
1952 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1953         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1954           cd $(PROJ_OBJ_ROOT)/include && \
1955           for hdr in `find . -type f -print | grep -v CVS` ; do \
1956             $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1957           done ; \
1958         fi
1959 endif
1960
1961 uninstall-local::
1962         $(Echo) Uninstalling include files
1963         $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1964           cd $(PROJ_SRC_ROOT)/include && \
1965             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1966               '!' '(' -name '*~' -o -name '.#*' \
1967         -o -name '*.in' ')' -print ')' | \
1968         grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1969           cd $(PROJ_SRC_ROOT)/include && \
1970             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1971       -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1972         fi
1973 endif
1974 endif
1975
1976 check-line-length:
1977         @echo searching for overlength lines in files: $(Sources)
1978         @echo
1979         @echo
1980         egrep -n '.{81}' $(Sources) /dev/null
1981
1982 check-for-tabs:
1983         @echo searching for tabs in files: $(Sources)
1984         @echo
1985         @echo
1986         egrep -n '      ' $(Sources) /dev/null
1987
1988 check-footprint:
1989         @ls -l $(LibDir) | awk '\
1990           BEGIN { sum = 0; } \
1991                 { sum += $$5; } \
1992           END   { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1993         @ls -l $(ToolDir) | awk '\
1994           BEGIN { sum = 0; } \
1995                 { sum += $$5; } \
1996           END   { printf("Programs:  %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1997 #------------------------------------------------------------------------
1998 # Print out the directories used for building
1999 #------------------------------------------------------------------------
2000 printvars::
2001         $(Echo) "BuildMode    : " '$(BuildMode)'
2002         $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2003         $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2004         $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2005         $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2006         $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2007         $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2008         $(Echo) "PROJ_prefix  : " '$(PROJ_prefix)'
2009         $(Echo) "PROJ_bindir  : " '$(PROJ_bindir)'
2010         $(Echo) "PROJ_libdir  : " '$(PROJ_libdir)'
2011         $(Echo) "PROJ_etcdir  : " '$(PROJ_etcdir)'
2012         $(Echo) "PROJ_includedir  : " '$(PROJ_includedir)'
2013         $(Echo) "UserTargets  : " '$(UserTargets)'
2014         $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2015         $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2016         $(Echo) "ObjDir       : " '$(ObjDir)'
2017         $(Echo) "LibDir       : " '$(LibDir)'
2018         $(Echo) "ToolDir      : " '$(ToolDir)'
2019         $(Echo) "ExmplDir     : " '$(ExmplDir)'
2020         $(Echo) "Sources      : " '$(Sources)'
2021         $(Echo) "TDFiles      : " '$(TDFiles)'
2022         $(Echo) "INCFiles     : " '$(INCFiles)'
2023         $(Echo) "INCTMPFiles  : " '$(INCTMPFiles)'
2024         $(Echo) "PreConditions: " '$(PreConditions)'
2025         $(Echo) "Compile.CXX  : " '$(Compile.CXX)'
2026         $(Echo) "Compile.C    : " '$(Compile.C)'
2027         $(Echo) "Archive      : " '$(Archive)'
2028         $(Echo) "YaccFiles    : " '$(YaccFiles)'
2029         $(Echo) "LexFiles     : " '$(LexFiles)'
2030         $(Echo) "Module       : " '$(Module)'
2031         $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2032         $(Echo) "SubDirs      : " '$(SubDirs)'
2033         $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2034         $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2035
2036 ###
2037 # Debugging
2038
2039 # General debugging rule, use 'make dbg-print-XXX' to print the
2040 # definition, value and origin of XXX.
2041 make-print-%:
2042         $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))