Don't attempt to update LLVM configured header files from a build in a
[oota-llvm.git] / Makefile.rules
1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file was developed by the LLVM research group and is distributed under
6 # the University of Illinois Open Source 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 LocalTargets     := all-local clean-local clean-all-local check-local \
24                     install-local printvars uninstall-local \
25                     install-bytecode-local
26 TopLevelTargets  := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
27                     dist-zip
28 UserTargets      := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29 InternalTargets  := preconditions distdir dist-hook
30
31 FilesToConfig := \
32   include/llvm/Config/config.h \
33   include/llvm/Support/DataTypes.h \
34   include/llvm/ADT/hash_map \
35   include/llvm/ADT/hash_set \
36   include/llvm/ADT/iterator
37
38 ################################################################################
39 # INITIALIZATION: Basic things the makefile needs
40 ################################################################################
41
42 #--------------------------------------------------------------------
43 # Set the VPATH so that we can find source files.
44 #--------------------------------------------------------------------
45 VPATH=$(PROJ_SRC_DIR)
46
47 #--------------------------------------------------------------------
48 # Reset the list of suffixes we know how to build
49 #--------------------------------------------------------------------
50 .SUFFIXES:
51 .SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot 
52 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
53
54 #--------------------------------------------------------------------
55 # Mark all of these targets as phony to avoid implicit rule search
56 #--------------------------------------------------------------------
57 .PHONY: $(UserTargets) $(InternalTargets)
58
59 #--------------------------------------------------------------------
60 # Make sure all the user-target rules are double colon rules and 
61 # they are defined first.
62 #--------------------------------------------------------------------
63
64 $(UserTargets)::
65
66 ################################################################################
67 # PRECONDITIONS: that which must be built/checked first
68 ################################################################################
69
70 SrcMakefiles       := $(filter %Makefile %Makefile.tests,\
71                       $(wildcard $(PROJ_SRC_DIR)/Makefile*))
72 ObjMakefiles       := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
73 ConfigureScript    := $(PROJ_SRC_ROOT)/configure
74 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
75 MakefileConfigIn   := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
76 MakefileCommonIn   := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
77 MakefileConfig     := $(PROJ_OBJ_ROOT)/Makefile.config
78 MakefileCommon     := $(PROJ_OBJ_ROOT)/Makefile.common
79 PreConditions      := $(ConfigStatusScript) $(ObjMakefiles)
80 ifneq ($(MakefileCommonIn),)
81 PreConditions      += $(MakefileCommon)
82 endif
83 ifneq ($(MakefileConfigIn),)
84 PreConditions      += $(MakefileConfig)
85 endif
86
87 FilesToConfigPATH  := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
88 PreConditions      += $(FilesToConfigPATH)
89
90 preconditions : $(PreConditions)
91
92 #------------------------------------------------------------------------
93 # Make sure the BUILT_SOURCES are built first
94 #------------------------------------------------------------------------
95 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
96
97 clean-local::
98 ifneq ($(strip $(BUILT_SOURCES)),)
99         -$(Verb) $(RM) -f $(BUILT_SOURCES)
100 endif
101
102 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
103 spotless:
104         $(Verb) if test -x config.status ; then \
105           $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
106           $(MKDIR) .spotless.save ; \
107           $(MV) config.status .spotless.save ; \
108           $(MV) mklib  .spotless.save ; \
109           $(MV) projects  .spotless.save ; \
110           $(RM) -rf * ; \
111           $(MV) .spotless.save/config.status . ; \
112           $(MV) .spotless.save/mklib . ; \
113           $(MV) .spotless.save/projects . ; \
114           $(RM) -rf .spotless.save ; \
115           $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
116           $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
117           $(ConfigStatusScript) ; \
118         else \
119           $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
120         fi
121 endif
122
123 $(BUILT_SOURCES) : $(ObjMakefiles)
124
125 #------------------------------------------------------------------------
126 # Make sure we're not using a stale configuration
127 #------------------------------------------------------------------------
128 reconfigure:
129         $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
130         $(Verb) cd $(PROJ_OBJ_ROOT) && \
131           if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
132             $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
133           fi ; \
134           $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
135           $(ConfigStatusScript)
136
137 .PRECIOUS: $(ConfigStatusScript)
138 $(ConfigStatusScript): $(ConfigureScript)
139         $(Echo) Reconfiguring with $<
140         $(Verb) cd $(PROJ_OBJ_ROOT) && \
141           if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
142             $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
143           fi ; \
144           $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
145           $(ConfigStatusScript)
146
147 #------------------------------------------------------------------------
148 # If we're buildilng LLVM, then make sure the generated headers are Up2Dt
149 #------------------------------------------------------------------------
150 ifeq ($(LLVM_OBJ_ROOT),$(PROJ_OBJ_ROOT))
151 .PRECIOUS: $(FilesToConfigPATH)
152 $(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in 
153         $(Echo) Regenerating $*
154         $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
155 endif
156
157 #------------------------------------------------------------------------
158 # Make sure the configuration makefile is up to date
159 #------------------------------------------------------------------------
160 ifneq ($(MakefileConfigIn),)
161 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
162         $(Echo) Regenerating $@
163         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
164 endif
165
166 ifneq ($(MakefileCommonIn),)
167 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
168         $(Echo) Regenerating $@
169         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
170 endif
171
172 #------------------------------------------------------------------------
173 # If the Makefile in the source tree has been updated, copy it over into the
174 # build tree. But, only do this if the source and object makefiles differ
175 #------------------------------------------------------------------------
176 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
177
178 Makefile: $(PROJ_SRC_DIR)/Makefile
179         $(Echo) "Updating Makefile"
180         $(Verb) $(MKDIR) $(@D)
181         $(Verb) $(CP) -f $< $@
182
183 # Copy the Makefile.* files unless we're in the root directory which avoids
184 # the copying of Makefile.config.in or other things that should be explicitly
185 # taken care of.
186 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
187         @case '$?' in \
188           *Makefile.rules) ;; \
189           *.in) ;; \
190           *) $(Echo) "Updating $(@F)" ; \
191              $(MKDIR) $(@D) ; \
192              $(CP) -f $< $@ ;; \
193         esac
194          
195 endif
196
197 #------------------------------------------------------------------------
198 # Set up the basic dependencies
199 #------------------------------------------------------------------------
200 $(UserTargets):: $(PreConditions)
201
202 all:: all-local
203 clean:: clean-local 
204 clean-all:: clean-local clean-all-local
205 install:: install-local
206 uninstall:: uninstall-local
207 install-local:: all-local 
208 install-bytecode:: install-bytecode-local
209
210 ###############################################################################
211 # VARIABLES: Set up various variables based on configuration data
212 ###############################################################################
213
214 #--------------------------------------------------------------------
215 # Variables derived from configuration we are building
216 #--------------------------------------------------------------------
217
218
219 ifdef ENABLE_PROFILING
220   BuildMode := Profile
221   CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
222   C.Flags   := -O3 -DNDEBUG -pg
223   LD.Flags  := -O3 -DNDEBUG -pg 
224 else
225   ifdef ENABLE_OPTIMIZED
226     BuildMode := Release
227     # Don't use -fomit-frame-pointer on FreeBSD
228     ifneq ($(OS),FreeBSD)
229       OmitFramePointer := -fomit-frame-pointer
230     endif
231     CXX.Flags  := -O3 -DNDEBUG -finline-functions -felide-constructors \
232                   $(OmitFramePointer)
233     C.Flags    := -O3 -DNDEBUG $(OmitFramePointer)
234     LD.Flags   := -O3 -DNDEBUG 
235   else
236     BuildMode := Debug
237     CXX.Flags := -g -D_DEBUG
238     C.Flags   := -g -D_DEBUG
239     LD.Flags  := -g -D_DEBUG 
240     KEEP_SYMBOLS := 1
241   endif
242 endif
243
244 CXX.Flags += $(CXXFLAGS)
245 C.Flags   += $(CFLAGS)
246 CPP.Flags += $(CPPFLAGS)
247 LD.Flags  += $(LDFLAGS)
248 AR.Flags  := cru
249 LibTool.Flags := --tag=CXX
250
251 #Make Floating point ieee complient on alpha
252 ifeq ($(ARCH),Alpha)
253   CXX.Flags += -mieee
254   CPP.Flags += -mieee
255 endif
256
257 #--------------------------------------------------------------------
258 # Directory locations
259 #--------------------------------------------------------------------
260 ObjDir      := $(PROJ_OBJ_DIR)/$(BuildMode)
261 LibDir      := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
262 ToolDir     := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
263 ExmplDir    := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
264 LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
265 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
266 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
267 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
268
269 #--------------------------------------------------------------------
270 # Full Paths To Compiled Tools and Utilities
271 #--------------------------------------------------------------------
272 EchoCmd  = $(ECHO) llvm[$(MAKELEVEL)]:
273 Echo     = @$(EchoCmd)
274 ifndef LIBTOOL
275 LIBTOOL  := $(LLVM_OBJ_ROOT)/mklib
276 endif
277 ifndef LLVMAS
278 LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
279 endif
280 ifndef BURG
281 BURG     := $(LLVMToolDir)/burg$(EXEEXT)
282 endif
283 ifndef TBLGEN
284 TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
285 endif
286 ifndef GCCAS
287 GCCAS    := $(LLVMToolDir)/gccas$(EXEEXT)
288 endif
289 ifndef GCCLD
290 GCCLD    := $(LLVMToolDir)/gccld$(EXEEXT)
291 endif
292 ifndef LDIS
293 LLVMDIS  := $(LLVMToolDir)/llvm-dis$(EXEEXT)
294 endif
295 ifndef LLI
296 LLI      := $(LLVMToolDir)/lli$(EXEEXT)
297 endif
298 ifndef LLC
299 LLC      := $(LLVMToolDir)/llc$(EXEEXT)
300 endif
301 ifndef LOPT
302 LOPT     := $(LLVMToolDir)/opt$(EXEEXT)
303 endif
304 ifndef LBUGPOINT
305 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
306 endif
307
308 LLVMGCCWITHPATH  := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
309 LLVMGXXWITHPATH  := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
310
311 #--------------------------------------------------------------------
312 # Adjust to user's request
313 #--------------------------------------------------------------------
314
315 # Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
316 # to be built. Note that if LOADABLE_MODULE is specified then the resulting
317 # shared library can be opened with dlopen
318 ifdef SHARED_LIBRARY
319   LD.Flags += -rpath $(LibDir)
320   ifdef LOADABLE_MODULE
321     LD.Flags += -module
322   endif
323 else
324   LibTool.Flags += --tag=disable-shared
325 endif
326
327 ifdef TOOL_VERBOSE
328   C.Flags += -v
329   CXX.Flags += -v
330   LD.Flags += -v
331   VERBOSE := 1
332 endif
333
334 # Adjust settings for verbose mode
335 ifndef VERBOSE
336   Verb := @
337   LibTool.Flags += --silent
338   AR.Flags += >/dev/null 2>/dev/null
339   ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
340 else
341   ConfigureScriptFLAGS := 
342 endif
343
344 # By default, strip symbol information from executable
345 ifndef KEEP_SYMBOLS
346   Strip := $(PLATFORMSTRIPOPTS)
347   StripWarnMsg := "(without symbols)"
348   Install.StripFlag += -s
349 endif
350
351 # Adjust linker flags for building an executable
352 ifdef TOOLNAME
353 ifdef EXAMPLE_TOOL
354   LD.Flags += -rpath $(ExmplDir) -export-dynamic
355 else
356   LD.Flags += -rpath $(ToolDir) -export-dynamic
357 endif
358 endif
359
360 #----------------------------------------------------------
361 # Options To Invoke Tools
362 #----------------------------------------------------------
363
364 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
365
366 ifeq ($(OS),HP-UX)
367   CompileCommonOpts += -D_REENTRANT -D_HPUX_SOURCE
368 endif
369
370 LD.Flags  += -L$(LibDir) -L$(LLVMLibDir) 
371 CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
372              -I$(PROJ_OBJ_ROOT)/include \
373              -I$(PROJ_SRC_ROOT)/include \
374              -I$(LLVM_OBJ_ROOT)/include \
375              -I$(LLVM_SRC_ROOT)/include \
376              -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
377
378 Compile.C     = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
379 LTCompile.C   = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
380 BCCompile.C   = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
381                 $(C.Flags) -c
382 Compile.CXX   = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
383 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
384 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
385                 $(CXX.Flags) -c
386 Link          = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
387                 $(CompileCommonOpts) $(LD.Flags) $(Strip)
388 Relink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
389                 $(CompileCommonOpts)
390 LTInstall     = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
391                 $(Install.Flags)
392 ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755 
393 DataInstall   = $(INSTALL) -m 0644
394 Burg          = $(BURG) -I $(PROJ_SRC_DIR)
395 TableGen      = $(TBLGEN) -I $(PROJ_SRC_DIR)
396 Archive       = $(AR) $(AR.Flags)
397 LArchive      = $(LLVMToolDir)/llvm-ar rcsf
398 ifdef RANLIB
399 Ranlib        = $(RANLIB)
400 else
401 Ranlib        = ranlib
402 endif
403
404 #----------------------------------------------------------
405 # Get the list of source files and compute object file 
406 # names from them. 
407 #----------------------------------------------------------
408 ifdef FAKE_SOURCES
409   Sources :=
410   FakeSources := $(FAKE_SOURCES)
411   ifdef BUILT_SOURCES
412   FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
413   endif
414   BaseNameSources := $(sort $(basename $(FakeSources)))
415   ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
416   ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
417   ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
418 else
419   ifndef SOURCES
420     Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
421                $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
422                $(PROJ_SRC_DIR)/*.l))
423   else
424     Sources := $(SOURCES)
425   endif 
426
427   ifdef BUILT_SOURCES
428   Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
429   endif
430
431   BaseNameSources := $(sort $(basename $(Sources)))
432   ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
433   ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
434   ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
435 endif
436
437 ###############################################################################
438 # DIRECTORIES: Handle recursive descent of directory structure
439 ###############################################################################
440
441 #---------------------------------------------------------
442 # Provide rules to make install dirs. This must be early
443 # in the file so they get built before dependencies
444 #---------------------------------------------------------
445
446 $(PROJ_bindir): $(PROJ_bindir)/.dir
447 $(PROJ_libdir): $(PROJ_libdir)/.dir
448 $(PROJ_includedir): $(PROJ_includedir)/.dir
449 $(PROJ_etcdir): $(PROJ_etcdir)/.dir
450
451 # To create other directories, as needed, and timestamp their creation
452 %/.dir:
453         $(Verb) $(MKDIR) $* > /dev/null
454         $(Verb) $(DATE) > $@
455
456 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
457 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
458
459 #---------------------------------------------------------
460 # Handle the DIRS options for sequential construction
461 #---------------------------------------------------------
462
463 SubDirs := 
464 ifdef DIRS
465 SubDirs += $(DIRS)
466 $(RecursiveTargets)::
467         $(Verb) for dir in $(DIRS); do \
468           if [ ! -f $$dir/Makefile ]; then \
469             $(MKDIR) $$dir; \
470             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
471           fi; \
472           if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
473             ($(MAKE) -C $$dir $@ ) || exit 1; \
474           fi ; \
475         done
476 endif
477
478 #---------------------------------------------------------
479 # Handle the EXPERIMENTAL_DIRS options ensuring success
480 # after each directory is built.
481 #---------------------------------------------------------
482 ifdef EXPERIMENTAL_DIRS
483 $(RecursiveTargets)::
484         $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
485           if [ ! -f $$dir/Makefile ]; then \
486             $(MKDIR) $$dir; \
487             $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
488           fi; \
489           if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
490             ($(MAKE) -C $$dir $@ ) || exit 0; \
491           fi ; \
492         done
493 endif
494
495 #---------------------------------------------------------
496 # Handle the PARALLEL_DIRS options for parallel construction
497 #---------------------------------------------------------
498 ifdef PARALLEL_DIRS
499
500 SubDirs += $(PARALLEL_DIRS)
501
502 # Unfortunately, this list must be maintained if new recursive targets are added
503 all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
504 clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
505 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
506 install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
507 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
508 install-bytecode  :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
509
510 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
511
512 $(ParallelTargets) :
513         $(Verb) if [ ! -f $(@D)/Makefile ]; then \
514           $(MKDIR) $(@D); \
515           $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
516         fi; \
517         if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
518           $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
519         fi
520 endif
521
522 #---------------------------------------------------------
523 # Handle the OPTIONAL_DIRS options for directores that may
524 # or may not exist.
525 #---------------------------------------------------------
526 ifdef OPTIONAL_DIRS
527
528 SubDirs += $(OPTIONAL_DIRS)
529
530 $(RecursiveTargets)::
531         $(Verb) for dir in $(OPTIONAL_DIRS); do \
532           if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
533             if [ ! -f $$dir/Makefile ]; then \
534               $(MKDIR) $$dir; \
535               $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
536             fi; \
537             if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
538               ($(MAKE) -C$$dir $@ ) || exit 1; \
539             fi ; \
540           fi \
541         done
542 endif
543
544 #---------------------------------------------------------
545 # Handle the CONFIG_FILES options
546 #---------------------------------------------------------
547 ifdef CONFIG_FILES
548
549 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
550         $(Echo) Installing Configuration Files To $(PROJ_etcdir)
551         $(Verb)for file in $(CONFIG_FILES); do \
552           if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
553             $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
554           elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
555             $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
556           else \
557             $(ECHO) Error: cannot find config file $${file}. ; \
558           fi \
559         done
560
561 uninstall-local::
562         $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
563         $(Verb)for file in $(CONFIG_FILES); do \
564           $(RM) -f $(PROJ_etcdir)/$${file} ; \
565         done
566
567 endif
568
569 ###############################################################################
570 # Set up variables for building libararies
571 ###############################################################################
572
573 #---------------------------------------------------------
574 # Handle the special "JIT" value for LLVM_LIBS which is a
575 # shorthand for a bunch of libraries that get the correct
576 # JIT support for a library or a tool that runs JIT.
577 #---------------------------------------------------------
578 ifeq ($(LLVMLIBS),JIT)
579
580 # Make sure we can get our own symbols in the tool
581 Link += -dlopen self
582
583 # Generic JIT libraries
584 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
585
586 # You can enable the X86 JIT on a non-X86 host by setting the flag
587 # ENABLE_X86_JIT on the make command line. If not, it will still be
588 # enabled automagically on an X86 host.
589 ifeq ($(ARCH), x86)
590   ENABLE_X86_JIT = 1
591 endif
592
593 # What the X86 JIT requires
594 ifdef ENABLE_X86_JIT
595   JIT_LIBS += LLVMX86 LLVMSelectionDAG
596 endif
597
598 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
599 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
600 # enabled automagically on an SparcV9 host.
601 ifeq ($(ARCH), Sparc)
602   ENABLE_SPARCV9_JIT = 1
603 endif
604
605 # What the Sparc JIT requires
606 ifdef ENABLE_SPARCV9_JIT
607   JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
608               LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
609               LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
610               LLVMDataStructure.a LLVMSparcV9RegAlloc
611 endif
612
613 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
614 # ENABLE_PPC_JIT on the make command line. If not, it will still be
615 # enabled automagically on an PowerPC host.
616 ifeq ($(ARCH), PowerPC)
617   ENABLE_PPC_JIT = 1
618 endif
619
620 # What the PowerPC JIT requires
621 ifdef ENABLE_PPC_JIT
622   JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
623 endif
624
625 # You can enable the Alpha JIT on a non-Alpha host by setting the flag
626 # ENABLE_ALPHA_JIT on the make command line. If not, it will still be
627 # enabled automagically on an Alpha host.
628 ifeq ($(ARCH), Alpha)
629   ENABLE_ALPHA_JIT = 1
630 endif
631
632 # What the Alpha JIT requires
633 ifdef ENABLE_ALPHA_JIT
634   JIT_LIBS += LLVMAlpha LLVMSelectionDAG
635 endif
636
637 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
638             LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
639             LLVMSystem.a $(PLATFORMLIBDL)
640 endif
641
642 #---------------------------------------------------------
643 # Define various command line options pertaining to the
644 # libraries needed when linking. There are "Proj" libs 
645 # (defined by the user's project) and "LLVM" libs (defined 
646 # by the # LLVM project).
647 #---------------------------------------------------------
648 # Some versions of gcc on Alpha produce too many symbols, so use a .a file
649 ifeq ($(ARCH),Alpha)
650 USEDLIBS :=  $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
651 LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
652 endif
653
654 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
655 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
656 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
657 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
658 ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
659 LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
660 ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
661 LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
662
663 ###############################################################################
664 # Library Build Rules: Four ways to build a library
665 ###############################################################################
666
667 #---------------------------------------------------------
668 # Bytecode Module Targets:
669 #   If the user set MODULE_NAME then they want to build a
670 #   bytecode module from the sources. We compile all the
671 #   sources and link it together into a single bytecode
672 #   module.
673 #---------------------------------------------------------
674
675 ifdef MODULE_NAME
676 ifeq ($(strip $(LLVMGCC)),)
677 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
678 else
679
680 Module     := $(LibDir)/$(MODULE_NAME).bc
681 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
682
683 ifdef EXPORTED_SYMBOL_FILE
684 LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
685 endif
686
687 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
688         $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
689         $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
690
691 all-local:: $(Module)
692
693 clean-local::
694 ifneq ($(strip $(Module)),)
695         -$(Verb) $(RM) -f $(Module)
696 endif
697
698 ifdef BYTECODE_DESTINATION
699 ModuleDestDir := $(BYTECODE_DESTINATION)
700 else
701 ModuleDestDir := $(PROJ_libdir)
702 endif
703
704 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
705
706 install-module:: $(DestModule)
707 install-local:: $(DestModule)
708
709 $(DestModule): $(ModuleDestDir) $(Module) 
710         $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
711         $(Verb) $(DataInstall) $(Module) $(DestModule)
712
713 uninstall-local::
714         $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
715         -$(Verb) $(RM) -f $(DestModule)
716
717 endif
718 endif
719
720 # if we're building a library ...
721 ifdef LIBRARYNAME
722
723 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
724 LIBRARYNAME := $(strip $(LIBRARYNAME))
725 ifdef LOADABLE_MODULE
726 LibName.LA := $(LibDir)/$(LIBRARYNAME).la
727 else
728 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
729 endif
730 LibName.A  := $(LibDir)/lib$(LIBRARYNAME).a
731 LibName.O  := $(LibDir)/$(LIBRARYNAME).o
732 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
733
734 #---------------------------------------------------------
735 # Shared Library Targets:
736 #   If the user asked for a shared library to be built
737 #   with the SHARED_LIBRARY variable, then we provide
738 #   targets for building them.
739 #---------------------------------------------------------
740 ifdef SHARED_LIBRARY
741
742 all-local:: $(LibName.LA)
743
744 ifdef LINK_LIBS_IN_SHARED
745 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
746         $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
747         $(Verb) $(Link) -o $@ $(ObjectsLO) \
748          $(ProjLibsOptions) $(LLVMLibsOptions)
749         $(Verb) $(LTInstall) $@ $(LibDir)
750 else
751 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
752         $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
753         $(Verb) $(Link) -o $@ $(ObjectsLO)
754         $(Verb) $(LTInstall) $@ $(LibDir)
755 endif
756
757 clean-local::
758 ifneq ($(strip $(LibName.LA)),)
759         -$(Verb) $(RM) -f $(LibName.LA)
760 endif
761
762 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
763
764 install-local:: $(DestSharedLib)
765
766 $(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
767         $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
768         $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
769         $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
770
771 uninstall-local:: 
772         $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
773         -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
774
775 endif
776
777 #---------------------------------------------------------
778 # Bytecode Library Targets:
779 #   If the user asked for a bytecode library to be built
780 #   with the BYTECODE_LIBRARY variable, then we provide 
781 #   targets for building them.
782 #---------------------------------------------------------
783 ifdef BYTECODE_LIBRARY
784 ifeq ($(strip $(LLVMGCC)),)
785 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
786 else
787
788 # make the C and C++ compilers strip debug info out of bytecode libraries.
789 BCCompile.C += -Wa,-strip-debug
790 BCCompile.CXX += -Wa,-strip-debug
791
792 all-local:: $(LibName.BCA)
793
794 ifdef EXPORTED_SYMBOL_FILE
795 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
796             -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
797
798 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
799                 $(LLVMToolDir)/llvm-ar
800         $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
801           "(internalize)"
802         $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
803         $(Verb) $(RM) -f $@
804         $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
805 else
806 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
807                 $(LLVMToolDir)/llvm-ar
808         $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
809         $(Verb) $(RM) -f $@
810         $(Verb) $(LArchive) $@ $(ObjectsBC)
811
812 endif
813
814 clean-local::
815 ifneq ($(strip $(LibName.BCA)),)
816         -$(Verb) $(RM) -f $(LibName.BCA)
817 endif
818
819 ifdef BYTECODE_DESTINATION
820 BytecodeDestDir := $(BYTECODE_DESTINATION)
821 else
822 BytecodeDestDir := $(PROJ_libdir)
823 endif
824
825 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
826
827 install-bytecode-local:: $(DestBytecodeLib)
828
829 install-local:: $(DestBytecodeLib)
830
831 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA) 
832         $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
833         $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
834
835 uninstall-local::
836         $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
837         -$(Verb) $(RM) -f $(DestBytecodeLib)
838
839 endif
840 endif
841
842 #---------------------------------------------------------
843 # ReLinked Library Targets:
844 #   If the user didn't explicitly forbid building a 
845 #   relinked then we provide targets for building them.
846 #---------------------------------------------------------
847 ifndef DONT_BUILD_RELINKED
848
849 all-local:: $(LibName.O)
850
851 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
852         $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
853         $(Verb) $(Relink) -o $@ $(ObjectsO)
854
855 clean-local::
856 ifneq ($(strip $(LibName.O)),)
857         -$(Verb) $(RM) -f $(LibName.O)
858 endif
859
860 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
861
862 install-local:: $(DestRelinkedLib)
863
864 $(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
865         $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
866         $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
867
868 uninstall-local::
869         $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
870         -$(Verb) $(RM) -f $(DestRelinkedLib)
871
872 endif
873
874 #---------------------------------------------------------
875 # Archive Library Targets:
876 #   If the user wanted a regular archive library built, 
877 #   then we provide targets for building them.
878 #---------------------------------------------------------
879 ifdef BUILD_ARCHIVE
880
881 all-local:: $(LibName.A)
882
883 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
884         $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
885         -$(Verb) $(RM) -f $@
886         $(Verb) $(Archive) $@ $(ObjectsO)
887         $(Verb) $(Ranlib) $@
888
889 clean-local::
890 ifneq ($(strip $(LibName.A)),)
891         -$(Verb) $(RM) -f $(LibName.A)
892 endif
893
894 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
895
896 install-local:: $(DestArchiveLib)
897
898 $(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
899         $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
900         $(Verb) $(MKDIR) $(PROJ_libdir)
901         $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
902
903 uninstall-local::
904         $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
905         -$(Verb) $(RM) -f $(DestArchiveLib)
906
907 endif
908
909 # endif LIBRARYNAME
910 endif 
911
912 ###############################################################################
913 # Tool Build Rules: Build executable tool based on TOOLNAME option
914 ###############################################################################
915
916 ifdef TOOLNAME
917
918 #---------------------------------------------------------
919 # Set up variables for building a tool.
920 #---------------------------------------------------------
921 ifdef EXAMPLE_TOOL
922 ToolBuildPath   := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
923 else
924 ToolBuildPath   := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
925 endif
926
927 #---------------------------------------------------------
928 # Tell make that we need to rebuild subdirectories before 
929 # we can link the tool. This affects things like LLI which 
930 # has library subdirectories.
931 #---------------------------------------------------------
932 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
933
934 #---------------------------------------------------------
935 # Provide targets for building the tools
936 #---------------------------------------------------------
937 all-local:: $(ToolBuildPath)
938
939 clean-local::
940 ifneq ($(strip $(ToolBuildPath)),)
941         -$(Verb) $(RM) -f $(ToolBuildPath)
942 endif
943
944 ifdef EXAMPLE_TOOL
945 $(ToolBuildPath): $(ExmplDir)/.dir
946 else
947 $(ToolBuildPath): $(ToolDir)/.dir
948 endif
949
950 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
951         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
952         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
953           $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
954         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg) 
955
956 DestTool = $(PROJ_bindir)/$(TOOLNAME)
957
958 install-local:: $(DestTool)
959
960 $(DestTool): $(PROJ_bindir) $(ToolBuildPath)
961         $(Echo) Installing $(BuildMode) $(DestTool)
962         $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
963
964 uninstall-local::
965         $(Echo) Uninstalling $(BuildMode) $(DestTool)
966         -$(Verb) $(RM) -f $(DestTool)
967
968 endif
969
970 ###############################################################################
971 # Object Build Rules: Build object files based on sources 
972 ###############################################################################
973
974 # Provide rule sets for when dependency generation is enabled
975 ifndef DISABLE_AUTO_DEPENDENCIES
976
977 #---------------------------------------------------------
978 # Create .lo files in the ObjDir directory from the .cpp and .c files...
979 #---------------------------------------------------------
980 ifdef SHARED_LIBRARY
981
982 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
983         $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
984         $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
985         then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
986         else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
987
988 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
989         $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
990         $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
991         then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
992         else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
993
994 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
995         $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
996         $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
997         then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
998         else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
999
1000 #---------------------------------------------------------
1001 # Create .o files in the ObjDir directory from the .cpp and .c files...
1002 #---------------------------------------------------------
1003 else
1004
1005 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1006         $(Echo) "Compiling $*.cpp for $(BuildMode) build"
1007         $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1008         then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1009         else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1010
1011 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1012         $(Echo) "Compiling $*.cc for $(BuildMode) build"
1013         $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1014         then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1015         else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1016
1017 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1018         $(Echo) "Compiling $*.c for $(BuildMode) build"
1019         $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1020         then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1021         else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
1022
1023 endif
1024
1025 #---------------------------------------------------------
1026 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1027 #---------------------------------------------------------
1028 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1029         $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1030         $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1031         then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1032         else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1033
1034 $(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1035         $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1036         $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1037         then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1038         else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1039
1040 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1041         $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1042         $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
1043         then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1044         else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1045
1046 # Provide alternate rule sets if dependencies are disabled
1047 else
1048
1049 ifdef SHARED_LIBRARY
1050
1051 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1052         $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
1053         $(LTCompile.CXX) $< -o $@ 
1054
1055 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1056         $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1057         $(LTCompile.CXX) $< -o $@ 
1058
1059 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1060         $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
1061         $(LTCompile.C) $< -o $@ 
1062
1063 else
1064
1065 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1066         $(Echo) "Compiling $*.cpp for $(BuildMode) build"
1067         $(Compile.CXX) $< -o $@ 
1068
1069 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1070         $(Echo) "Compiling $*.cc for $(BuildMode) build"
1071         $(Compile.CXX) $< -o $@ 
1072
1073 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1074         $(Echo) "Compiling $*.c for $(BuildMode) build"
1075         $(Compile.C) $< -o $@ 
1076 endif
1077
1078 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1079         $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1080         $(BCCompile.CXX) $< -o $@ 
1081
1082 $(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1083         $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1084         $(BCCompile.CXX) $< -o $@ 
1085
1086 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1087         $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1088         $(BCCompile.C) $< -o $@
1089
1090 endif
1091
1092 #---------------------------------------------------------
1093 # Provide rule to build .bc files from .ll sources,
1094 # regardless of dependencies
1095 #---------------------------------------------------------
1096 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1097         $(Echo) "Compiling $*.ll for $(BuildMode) build"
1098         $(Verb) $(LLVMAS) $< -f -o $@
1099
1100 ###############################################################################
1101 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1102 ###############################################################################
1103
1104 ifdef TARGET
1105
1106 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
1107 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1108 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1109 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1110
1111 # All of these files depend on tblgen and the .td files.
1112 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1113
1114 # INCFiles rule: All of the tblgen generated files are emitted to 
1115 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
1116 # us to only "touch" the real file if the contents of it change.  IOW, if
1117 # tblgen is modified, all of the .inc.tmp files are regereated, but no
1118 # dependencies of the .inc files are, unless the contents of the .inc file
1119 # changes.
1120 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1121         $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1122
1123 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1124 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1125         $(Echo) "Building $(<F) register names with tblgen"
1126         $(Verb) $(TableGen) -gen-register-enums -o $@ $<
1127
1128 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1129 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1130         $(Echo) "Building $(<F) register information header with tblgen"
1131         $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
1132
1133 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1134 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1135         $(Echo) "Building $(<F) register info implementation with tblgen"
1136         $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1137
1138 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1139 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1140         $(Echo) "Building $(<F) instruction names with tblgen"
1141         $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1142
1143 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1144 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1145         $(Echo) "Building $(<F) instruction information with tblgen"
1146         $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1147
1148 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1149 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1150         $(Echo) "Building $(<F) assembly writer with tblgen"
1151         $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1152
1153 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1154 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1155         $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1156         $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $< 
1157
1158 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1159 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1160         $(Echo) "Building $(<F) code emitter with tblgen"
1161         $(Verb) $(TableGen) -gen-emitter -o $@ $<
1162
1163 clean-local::
1164         -$(Verb) $(RM) -f $(INCFiles)
1165
1166 endif
1167
1168 ###############################################################################
1169 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1170 ###############################################################################
1171
1172 #---------------------------------------------------------
1173 # Provide rules for generating a .cpp source file from 
1174 # (f)lex input sources. 
1175 #---------------------------------------------------------
1176
1177 LexFiles  := $(filter %.l,$(Sources))
1178
1179 ifneq ($(LexFiles),)
1180
1181 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1182
1183 .PRECIOUS: $(LexOutput)
1184
1185 # Note the extra sed filtering here, used to cut down on the warnings emited 
1186 # by GCC.  The last line is a gross hack to work around flex aparently not 
1187 # being able to resize the buffer on a large token input.  Currently, for 
1188 # uninitialized string buffers in LLVM we can generate very long tokens, so 
1189 # this is a hack around it.
1190 # FIXME.  (f.e. char Buffer[10000] )
1191 %.cpp: %.l
1192         $(Echo) Flexing $*.l
1193         $(Verb) $(FLEX) -t $< | \
1194         $(SED) 's/void yyunput/inline void yyunput/' | \
1195         $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1196         $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1197           > $@
1198
1199 clean-local::
1200         -$(Verb) $(RM) -f $(LexOutput)
1201         $(Verb) $(RM) -f $(LexOutput)
1202
1203 endif
1204
1205 #---------------------------------------------------------
1206 # Provide rules for generating a .cpp and .h source files 
1207 # from yacc (bison) input sources.
1208 #---------------------------------------------------------
1209
1210 YaccFiles  := $(filter %.y,$(Sources))
1211 ifneq ($(YaccFiles),)
1212 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1213
1214 .PRECIOUS: $(YaccOutput)
1215
1216 # Cancel built-in rules for yacc
1217 %.c: %.y 
1218 %.cpp: %.y
1219 %.h: %.y
1220
1221 # Rule for building the bison parsers...
1222 %.cpp %.h : %.y
1223         $(Echo) "Bisoning $*.y"
1224         $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c  $<
1225         $(Verb) $(MV) -f $*.tab.c $*.cpp
1226         $(Verb) $(MV) -f $*.tab.h $*.h
1227
1228 clean-local::
1229         -$(Verb) $(RM) -f $(YaccOutput)
1230         $(Verb) $(RM) -f $(YaccOutput)
1231 endif
1232
1233 ###############################################################################
1234 # OTHER RULES: Other rules needed
1235 ###############################################################################
1236
1237 # To create postscript files from dot files...
1238 ifneq ($(DOT),false)
1239 %.ps: %.dot
1240         $(DOT) -Tps < $< > $@
1241 else
1242 %.ps: %.dot
1243         $(Echo) "Cannot build $@: The program dot is not installed"
1244 endif
1245
1246 # This rules ensures that header files that are removed still have a rule for
1247 # which they can be "generated."  This allows make to ignore them and
1248 # reproduce the dependency lists.
1249 %.h:: ;
1250 %.hpp:: ;
1251
1252 # Define clean-local to clean the current directory. Note that this uses a
1253 # very conservative approach ensuring that empty variables do not cause 
1254 # errors or disastrous removal.
1255 clean-local::
1256 ifneq ($(strip $(ObjDir)),)
1257         -$(Verb) $(RM) -rf $(ObjDir)
1258 endif
1259         -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1260 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1261         -$(Verb) $(RM) -f *$(SHLIBEXT)
1262 endif
1263
1264 clean-all-local::
1265         -$(Verb) $(RM) -rf Debug Release Profile
1266
1267 # Build tags database for Emacs/Xemacs:
1268 tags:: TAGS CTAGS
1269
1270 TAGS: 
1271         find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1272           $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1273           $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1274           $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1275         -name '*.cpp' -o -name '*.h' | \
1276         $(ETAGS) $(ETAGSFLAGS) -
1277
1278 CTAGS:
1279         find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1280           $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1281           $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1282           $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1283           \( -name '*.cpp' -o -name '*.h' \) -print | \
1284           ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
1285
1286
1287 ###############################################################################
1288 # DEPENDENCIES: Include the dependency files if we should
1289 ###############################################################################
1290 ifndef DISABLE_AUTO_DEPENDENCIES
1291
1292 # If its not one of the cleaning targets
1293 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1294
1295 # Get the list of dependency files
1296 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1297 DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1298
1299 -include /dev/null $(DependFiles)
1300
1301 endif
1302
1303 endif 
1304
1305 ###############################################################################
1306 # CHECK: Running the test suite
1307 ###############################################################################
1308
1309 check::
1310         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1311           if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1312             $(EchoCmd) Running test suite ; \
1313             $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1314               TESTSUITE=$(TESTSUITE) ; \
1315           else \
1316             $(EchoCmd) No Makefile in test directory ; \
1317           fi ; \
1318         else \
1319           $(EchoCmd) No test directory ; \
1320         fi
1321
1322 ###############################################################################
1323 # DISTRIBUTION: Handle construction of a distribution tarball
1324 ###############################################################################
1325
1326 #------------------------------------------------------------------------
1327 # Define distribution related variables
1328 #------------------------------------------------------------------------
1329 DistName    := $(PROJECT_NAME)-$(PROJ_VERSION)
1330 DistDir     := $(PROJ_OBJ_ROOT)/$(DistName)
1331 TopDistDir  := $(PROJ_OBJ_ROOT)/$(DistName)
1332 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1333 DistZip     := $(PROJ_OBJ_ROOT)/$(DistName).zip
1334 DistTarBZ2  := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1335 DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1336                ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1337                Makefile.config.in configure autoconf
1338 DistOther   := $(notdir $(wildcard \
1339                $(PROJ_SRC_DIR)/*.h \
1340                $(PROJ_SRC_DIR)/*.td \
1341                $(PROJ_SRC_DIR)/*.def \
1342                $(PROJ_SRC_DIR)/*.ll \
1343                $(PROJ_SRC_DIR)/*.in))
1344 DistSubDirs := $(SubDirs)
1345 DistSources  = $(Sources) $(EXTRA_DIST)
1346 DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
1347
1348 #------------------------------------------------------------------------
1349 # We MUST build distribution with OBJ_DIR != SRC_DIR
1350 #------------------------------------------------------------------------
1351 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1352 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1353         $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1354
1355 else
1356
1357 #------------------------------------------------------------------------
1358 # Prevent attempt to run dist targets from anywhere but the top level
1359 #------------------------------------------------------------------------
1360 ifneq ($(LEVEL),.)
1361 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1362         $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1363 else
1364
1365 #------------------------------------------------------------------------
1366 # Provide the top level targets
1367 #------------------------------------------------------------------------
1368
1369 dist-gzip:: $(DistTarGZip)
1370
1371 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1372         $(Echo) Packing gzipped distribution tar file.
1373         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1374           $(GZIP) -c > "$(DistTarGZip)"
1375
1376 dist-bzip2:: $(DistTarBZ2)
1377
1378 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1379         $(Echo) Packing bzipped distribution tar file.
1380         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1381           $(BZIP2) -c >$(DistTarBZ2)
1382
1383 dist-zip:: $(DistZip)
1384
1385 $(DistZip) : $(TopDistDir)/.makedistdir
1386         $(Echo) Packing zipped distribution file.
1387         $(Verb) rm -f $(DistZip)
1388         $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1389
1390 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip) 
1391         $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1392
1393 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1394
1395 dist-check:: $(DistTarGZip)
1396         $(Echo) Checking distribution tar file.
1397         $(Verb) if test -d $(DistCheckDir) ; then \
1398           $(RM) -rf $(DistCheckDir) ; \
1399         fi
1400         $(Verb) $(MKDIR) $(DistCheckDir)
1401         $(Verb) cd $(DistCheckDir) && \
1402           $(MKDIR) $(DistCheckDir)/build && \
1403           $(MKDIR) $(DistCheckDir)/install && \
1404           gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1405           cd build && \
1406           ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1407             --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1408           $(MAKE) all && \
1409           $(MAKE) check && \
1410           $(MAKE) install && \
1411           $(MAKE) uninstall && \
1412           $(MAKE) dist && \
1413           $(MAKE) clean && \
1414           $(MAKE) dist-clean && \
1415           $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1416
1417 dist-clean::
1418         $(Echo) Cleaning distribution files
1419         -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1420           $(DistCheckDir)
1421
1422 endif
1423
1424 #------------------------------------------------------------------------
1425 # Provide the recursive distdir target for building the distribution directory
1426 #------------------------------------------------------------------------
1427 distdir: $(DistDir)/.makedistdir
1428 $(DistDir)/.makedistdir: $(DistSources)
1429         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1430           if test -d "$(DistDir)" ; then \
1431             find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1432               exit 1 ; \
1433           fi ; \
1434           $(EchoCmd) Removing old $(DistDir) ; \
1435           $(RM) -rf $(DistDir); \
1436           $(EchoCmd) Making 'all' to verify build ; \
1437           $(MAKE) all ; \
1438         fi
1439         $(Echo) Building Distribution Directory $(DistDir)
1440         $(Verb) $(MKDIR) $(DistDir) 
1441         $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1442         srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1443         for file in $(DistFiles) ; do \
1444           case "$$file" in \
1445             $(PROJ_SRC_DIR)/*) \
1446               file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1447               ;; \
1448             $(PROJ_SRC_ROOT)/*) \
1449               file=`echo "$$file" | \
1450                 sed "s#^$$srcrootstrip/##"` \
1451               ;; \
1452           esac; \
1453           if test -f "$(PROJ_SRC_DIR)/$$file" || \
1454              test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1455             from_dir="$(PROJ_SRC_DIR)" ; \
1456           elif test -f "$$file" || test -d "$$file" ; then \
1457             from_dir=. ; \
1458           fi ; \
1459           to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1460           if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1461             to_dir="$(DistDir)/$$dir"; \
1462             $(MKDIR) "$$to_dir" ; \
1463           else \
1464             to_dir="$(DistDir)"; \
1465           fi; \
1466           mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1467           if test -n "$$mid_dir" ; then \
1468             $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1469           fi ; \
1470           if test -d "$$from_dir/$$file"; then \
1471             if test -d "$(PROJ_SRC_DIR)/$$file" && \
1472                test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1473                cd $(PROJ_SRC_DIR) ; \
1474                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1475                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1476                cd $(PROJ_OBJ_DIR) ; \
1477             else \
1478                cd $$from_dir ; \
1479                $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1480                  ( cd $$to_dir ; $(TAR) xf - ) ; \
1481                cd $(PROJ_OBJ_DIR) ; \
1482             fi; \
1483           elif test -f "$$from_dir/$$file" ; then \
1484             $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1485           elif test -L "$$from_dir/$$file" ; then \
1486             $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1487           elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1488             $(EchoCmd) "===== WARNING: Distribution Source " \
1489               "$$from_dir/$$file Not Found!" ; \
1490           elif test "$(Verb)" != '@' ; then \
1491             $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1492           fi; \
1493         done
1494         $(Verb) for subdir in $(DistSubDirs) ; do \
1495           if test "$$subdir" \!= "." ; then \
1496             new_distdir="$(DistDir)/$$subdir" ; \
1497             test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1498             ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1499             exit 1; \
1500           fi; \
1501         done
1502         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1503           $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1504           $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o -name .svn \) -print` ;\
1505           $(MAKE) dist-hook ; \
1506           $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1507             -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1508             -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1509             -o ! -type d ! -perm -444 -exec \
1510               $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1511             || chmod -R a+r $(DistDir) ; \
1512         fi
1513
1514 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1515 # defined by user.
1516 dist-hook::
1517
1518 endif
1519
1520 ###############################################################################
1521 # TOP LEVEL - targets only to apply at the top level directory
1522 ###############################################################################
1523
1524 ifeq ($(LEVEL),.)
1525
1526 #------------------------------------------------------------------------
1527 # Install support for the project's include files:
1528 #------------------------------------------------------------------------
1529 install-local::
1530         $(Echo) Installing include files
1531         $(Verb) $(MKDIR) $(PROJ_includedir)
1532         $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1533           cd $(PROJ_SRC_ROOT)/include && \
1534           for  hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1535               -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
1536             instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1537             if test \! -d "$$instdir" ; then \
1538               $(EchoCmd) Making install directory $$instdir ; \
1539               $(MKDIR) $$instdir ;\
1540             fi ; \
1541             $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1542           done ; \
1543         fi
1544         $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1545           cd $(PROJ_OBJ_ROOT)/include && \
1546           for hdr in `find . -type f -print` ; do \
1547             $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1548           done ; \
1549         fi
1550
1551 uninstall-local::
1552         $(Echo) Uninstalling include files
1553         $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1554           cd $(PROJ_SRC_ROOT)/include && \
1555             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1556               '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \
1557               -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1558           cd $(PROJ_SRC_ROOT)/include && \
1559             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \
1560             | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1561         fi
1562
1563 endif
1564
1565 #------------------------------------------------------------------------
1566 # Print out the directories used for building
1567 #------------------------------------------------------------------------
1568 printvars::
1569         $(Echo) "BuildMode    : " '$(BuildMode)'
1570         $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1571         $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1572         $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1573         $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1574         $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1575         $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1576         $(Echo) "PROJ_prefix  : " '$(PROJ_prefix)'
1577         $(Echo) "PROJ_bindir  : " '$(PROJ_bindir)'
1578         $(Echo) "PROJ_libdir  : " '$(PROJ_libdir)'
1579         $(Echo) "PROJ_etcdir  : " '$(PROJ_etcdir)'
1580         $(Echo) "PROJ_includedir  : " '$(PROJ_includedir)'
1581         $(Echo) "UserTargets  : " '$(UserTargets)'
1582         $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1583         $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1584         $(Echo) "ObjDir       : " '$(ObjDir)'
1585         $(Echo) "LibDir       : " '$(LibDir)'
1586         $(Echo) "ToolDir      : " '$(ToolDir)'
1587         $(Echo) "ExmplDir     : " '$(ExmplDir)'
1588         $(Echo) "Sources      : " '$(Sources)'
1589         $(Echo) "TDFiles      : " '$(TDFiles)'
1590         $(Echo) "INCFiles     : " '$(INCFiles)'
1591         $(Echo) "INCTMPFiles  : " '$(INCTMPFiles)'
1592         $(Echo) "PreConditions: " '$(PreConditions)'
1593         $(Echo) "Compile.CXX  : " '$(Compile.CXX)'
1594         $(Echo) "Compile.C    : " '$(Compile.C)'
1595         $(Echo) "Archive      : " '$(Archive)'
1596         $(Echo) "YaccFiles    : " '$(YaccFiles)'
1597         $(Echo) "LexFiles     : " '$(LexFiles)'
1598         $(Echo) "Module       : " '$(Module)'
1599         $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'