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