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