These have been removed
[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 check install uninstall
23 LocalTargets     := all-local clean-local clean-all-local check-local \
24                     install-local printvars uninstall-local
25 TopLevelTargets  := dist dist-check dist-clean tags dist-gzip dist-bzip2 \
26                     dist-zip
27 UserTargets      := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
28 InternalTargets  := preconditions distdir dist-hook
29
30 ################################################################################
31 # INITIALIZATION: Basic things the makefile needs
32 ################################################################################
33
34 #--------------------------------------------------------------------
35 # Set the VPATH so that we can find source files.
36 #--------------------------------------------------------------------
37 VPATH=$(BUILD_SRC_DIR)
38
39 #--------------------------------------------------------------------
40 # Reset the list of suffixes we know how to build
41 #--------------------------------------------------------------------
42 .SUFFIXES:
43 .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot 
44 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
45
46 #--------------------------------------------------------------------
47 # Mark all of these targets as phony to avoid implicit rule search
48 #--------------------------------------------------------------------
49 .PHONY: $(UserTargets) $(InternalTargets)
50
51 #--------------------------------------------------------------------
52 # Make sure all the user-target rules are double colon rules and 
53 # they are defined first.
54 #--------------------------------------------------------------------
55
56 $(UserTargets)::
57
58 ################################################################################
59 # PRECONDITIONS: that which must be built/checked first
60 ################################################################################
61
62 SrcMakefiles       := $(filter %Makefile %Makefile.tests %Makefile.JIT,\
63                       $(wildcard $(BUILD_SRC_DIR)/Makefile*))
64 ObjMakefiles       := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
65 ConfigureScript    := $(LLVM_SRC_ROOT)/configure
66 ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
67 MakefileConfigIn   := $(LLVM_SRC_ROOT)/Makefile.config.in
68 MakefileConfig     := $(LLVM_OBJ_ROOT)/Makefile.config
69 PreConditions      := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
70
71 preconditions : $(PreConditions)
72
73 #------------------------------------------------------------------------
74 # Make sure the BUILT_SOURCES are built first
75 #------------------------------------------------------------------------
76 $(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
77
78 clean-local::
79 ifneq ($(strip $(BUILT_SOURCES)),)
80         -$(Verb) $(RM) -f $(BUILT_SOURCES)
81 endif
82
83 $(BUILT_SOURCES) : $(ObjMakefiles)
84
85 #------------------------------------------------------------------------
86 # Make sure we're not using a stale configuration
87 #------------------------------------------------------------------------
88 .PRECIOUS: $(ConfigStatusScript)
89 $(ConfigStatusScript): $(ConfigureScript)
90         $(Echo) Reconfiguring with $<
91         $(Verb) $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS)
92         $(Verb) $(ConfigStatusScript)
93
94 #------------------------------------------------------------------------
95 # Make sure the configuration makefile is up to date
96 #------------------------------------------------------------------------
97 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
98         $(Echo) Regenerating $@
99         $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
100
101 #------------------------------------------------------------------------
102 # If the Makefile in the source tree has been updated, copy it over into the
103 # build tree. But, only do this if the source and object makefiles differ
104 #------------------------------------------------------------------------
105 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
106
107 Makefile: $(BUILD_SRC_DIR)/Makefile
108         $(Echo) "Updating Makefile"
109         $(Verb) $(MKDIR) $(@D)
110         $(Verb) cp -f $< $@
111
112 # Copy the Makefile.* files unless we're in the root directory which avoids
113 # the copying of Makefile.config.in or other things that should be explicitly
114 # taken care of.
115 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
116         @case '$?' in \
117           *Makefile.rules) ;; \
118           *.in) ;; \
119           *) $(Echo) "Updating $(@F)" ; \
120              $(MKDIR) $(@D) ; \
121              cp -f $< $@ ;; \
122         esac
123          
124 endif
125
126 #------------------------------------------------------------------------
127 # Set up the basic dependencies
128 #------------------------------------------------------------------------
129 $(UserTargets):: $(PreConditions)
130
131 all:: all-local
132 check:: check-local
133 clean:: clean-local 
134 clean-all:: clean-local clean-all-local
135 install:: install-local
136 uninstall:: uninstall-local
137 check-local:: all-local
138 install-local:: all-local 
139
140 ###############################################################################
141 # VARIABLES: Set up various variables based on configuration data
142 ###############################################################################
143
144 #--------------------------------------------------------------------
145 # Variables derived from configuration we are building
146 #--------------------------------------------------------------------
147
148 ifdef ENABLE_PROFILING
149   BuildMode := Profile
150   CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
151   C.Flags   := -O3 -DNDEBUG -pg
152   LD.Flags  := -O3 -DNDEBUG -pg 
153 else
154   ifdef ENABLE_OPTIMIZED
155     BuildMode := Release
156     CXX.Flags  := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
157     C.Flags    := -O3 -DNDEBUG -fomit-frame-pointer
158     LD.Flags   := -O3 -DNDEBUG 
159   else
160     BuildMode := Debug
161     CXX.Flags := -g -D_DEBUG 
162     C.Flags   := -g -D_DEBUG
163     LD.Flags  := -g -D_DEBUG 
164     KEEP_SYMBOLS := 1
165   endif
166 endif
167
168 CXX.Flags += $(CXXFLAGS)
169 C.Flags   += $(CFLAGS)
170 CPP.Flags += $(CPPFLAGS)
171 LD.Flags  += $(LDFLAGS)
172 AR.Flags  := cru
173 LibTool.Flags := --tag=CXX
174
175 #--------------------------------------------------------------------
176 # Directory locations
177 #--------------------------------------------------------------------
178 ObjDir      := $(BUILD_OBJ_DIR)/$(BuildMode)
179 LibDir      := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
180 ToolDir     := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
181 ExmplDir    := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
182 LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
183 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
184 LExmplDir   := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
185
186 #--------------------------------------------------------------------
187 # Full Paths To Compiled Tools and Utilities
188 #--------------------------------------------------------------------
189 EchoCmd  := $(ECHO) llvm[$(MAKELEVEL)]:
190 Echo     := @$(EchoCmd)
191 ifndef LIBTOOL
192 LIBTOOL  := $(LLVM_OBJ_ROOT)/mklib
193 endif
194 ifndef LLVMAS
195 LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
196 endif
197 ifndef BURG
198 BURG     := $(LLVMToolDir)/burg$(EXEEXT)
199 endif
200 ifndef TBLGEN
201 TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
202 endif
203 ifndef GCCLD
204 GCCLD    := $(LLVMToolDir)/gccld$(EXEEXT)
205 endif
206 ifndef LLVMGCC
207 LLVMGCC  := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
208 endif
209 ifndef LLVMGXX
210 LLVMGXX  := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
211 endif
212
213 # Need a better way to compute this.
214 LLVMGCCLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
215
216 #--------------------------------------------------------------------
217 # Adjust to user's request
218 #--------------------------------------------------------------------
219
220 # Adjust LIBTOOL flags for shared libraries, or not.
221 ifndef SHARED_LIBRARY
222   LibTool.Flags += --tag=disable-shared
223 else
224   LD.Flags += -rpath $(LibDir)
225 endif
226
227 ifdef TOOL_VERBOSE
228   C.Flags += -v
229   CXX.Flags += -v
230   LD.Flags += -v
231   BCLinkLib.Flags += -v
232   VERBOSE := 1
233 endif
234
235 # Adjust settings for verbose mode
236 ifndef VERBOSE
237   Verb := @
238   LibTool.Flags += --silent
239   AR.Flags += >/dev/null 2>/dev/null
240   ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
241 else
242   ConfigureScriptFLAGS := 
243 endif
244
245 # By default, strip symbol information from executable
246 ifndef KEEP_SYMBOLS
247   Strip := $(PLATFORMSTRIPOPTS)
248   StripWarnMsg := "(without symbols)"
249 endif
250
251 # Adjust linker flags for building an executable
252 ifdef TOOLNAME
253 ifdef EXAMPLE_TOOL
254   LD.Flags += -rpath $(ExmplDir) -export-dynamic
255 else
256   LD.Flags += -rpath $(ToolDir) -export-dynamic
257 endif
258 endif
259
260 #----------------------------------------------------------
261 # Options To Invoke Tools
262 #----------------------------------------------------------
263
264 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
265
266 LD.Flags  += -L$(LibDir) -L$(LLVMLibDir)
267 CPP.Flags += -I$(BUILD_OBJ_DIR) \
268             -I$(BUILD_SRC_DIR) \
269             -I$(BUILD_SRC_ROOT)/include \
270             -I$(BUILD_OBJ_ROOT)/include \
271             -I$(LLVM_OBJ_ROOT)/include \
272             -I$(LLVM_SRC_ROOT)/include \
273             -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
274
275 Compile.C     = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
276 LTCompile.C   = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
277 BCCompile.C   = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
278 Compile.CXX   = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
279 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
280 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
281 Link          = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
282                 $(CompileCommonOpts) $(LD.Flags) $(Strip)
283 Relink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
284                 $(CompileCommonOpts)
285 BCLinkLib     = $(LLVMGCC) -shared -nostdlib $(BCLinkLib.Flags)
286 LTInstall     = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
287 Burg          = $(BURG) -I $(BUILD_SRC_DIR)
288 TableGen      = $(TBLGEN) -I $(BUILD_SRC_DIR)
289 Archive       = $(AR) $(AR.Flags)
290 LArchive      = $(ToolDir)/llvm-ar rcsf
291 ifdef RANLIB
292 Ranlib        = $(RANLIB)
293 else
294 Ranlib        = ranlib
295 endif
296
297 #----------------------------------------------------------
298 # Get the list of source files
299 #----------------------------------------------------------
300 ifndef SOURCES
301   Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
302              $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
303              $(BUILD_SRC_DIR)/*.l))
304 else
305   Sources := $(SOURCES)
306 endif
307
308 ifdef BUILT_SOURCES
309 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
310 endif
311
312 #----------------------------------------------------------
313 # Types of objects that can be built from sources
314 #----------------------------------------------------------
315 BaseNameSources := $(sort $(basename $(Sources)))
316 ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
317 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
318 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
319
320 ###############################################################################
321 # DIRECTORIES: Handle recursive descent of directory structure
322 ###############################################################################
323
324 #---------------------------------------------------------
325 # Provide rules to make install dirs. This must be early
326 # in the file so they get built before dependencies
327 #---------------------------------------------------------
328
329 $(bindir):
330         $(Verb) $(MKDIR) $(bindir)
331
332 $(libdir):
333         $(Verb) $(MKDIR) $(libdir)
334
335 $(bytecode_libdir):
336         $(Verb) $(MKDIR) $(bytecode_libdir)
337
338 $(sysconfdir):
339         $(Verb) $(MKDIR) $(sysconfdir)
340
341 # To create other directories, as needed, and timestamp their creation
342 %/.dir:
343         $(Verb) $(MKDIR) $* > /dev/null
344         @$(DATE) > $@
345
346 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
347 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
348
349 #---------------------------------------------------------
350 # Handle the DIRS options for sequential construction
351 #---------------------------------------------------------
352
353 SubDirs := 
354 ifdef DIRS
355 SubDirs += $(DIRS)
356 $(RecursiveTargets)::
357         $(Verb) for dir in $(DIRS); do \
358           if [ ! -f $$dir/Makefile ]; then \
359             $(MKDIR) $$dir; \
360             cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
361           fi; \
362           ($(MAKE) -C $$dir $@ ) || exit 1; \
363         done
364 endif
365
366 #---------------------------------------------------------
367 # Handle the EXPERIMENTAL_DIRS options ensuring success
368 # after each directory is built.
369 #---------------------------------------------------------
370 ifdef EXPERIMENTAL_DIRS
371 $(RecursiveTargets)::
372         $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
373           if [ ! -f $$dir/Makefile ]; then \
374             $(MKDIR) $$dir; \
375             cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
376           fi; \
377           ($(MAKE) -C $$dir $@ ) || exit 0; \
378         done
379 endif
380
381 #---------------------------------------------------------
382 # Handle the PARALLEL_DIRS options for parallel construction
383 #---------------------------------------------------------
384 ifdef PARALLEL_DIRS
385
386 SubDirs += $(PARALLEL_DIRS)
387
388 # Unfortunately, this list must be maintained if new 
389 # recursive targets are added.
390 all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
391 clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
392 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
393 check    :: $(addsuffix /.makecheck    ,$(PARALLEL_DIRS))
394 install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
395 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
396
397 Parallel_Targets := $(foreach T,$(RecursiveTargets),%/.make$(T))
398
399 $(Parallel_Targets) :
400         $(Verb) if [ ! -f $(@D)/Makefile ]; then \
401           $(MKDIR) $(@D); \
402           cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
403         fi; \
404         $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
405 endif
406
407 #---------------------------------------------------------
408 # Handle the OPTIONAL_DIRS options for directores that may
409 # or may not exist.
410 #---------------------------------------------------------
411 ifdef OPTIONAL_DIRS
412
413 SubDirs += $(OPTIONAL_DIRS)
414
415 $(RecursiveTargets)::
416         $(Verb) for dir in $(OPTIONAL_DIRS); do \
417           if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
418             if [ ! -f $$dir/Makefile ]; then \
419               $(MKDIR) $$dir; \
420               cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
421             fi; \
422             ($(MAKE) -C$$dir $@ ) || exit 1; \
423           fi \
424         done
425 endif
426
427 #---------------------------------------------------------
428 # Handle the CONFIG_FILES options
429 #---------------------------------------------------------
430 ifdef CONFIG_FILES
431
432 install-local:: $(sysconfdir) $(CONFIG_FILES)
433         $(Echo) Installing Configuration Files To $(sysconfdir)
434         $(Verb)for file in $(CONFIG_FILES); do \
435           if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
436             $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
437           elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
438             $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
439           else \
440             $(ECHO) Error: cannot find config file $${file}. ; \
441           fi \
442         done
443
444 uninstall-local::
445         $(Echo) Uninstalling Configuration Files From $(sysconfdir)
446         $(Verb)for file in $(CONFIG_FILES); do \
447           $(RM) -f $(sysconfdir)/$${file} ; \
448         done
449
450 endif
451
452 ###############################################################################
453 # Library Build Rules: Four ways to build a library
454 ###############################################################################
455
456
457 # if we're building a library ...
458 ifdef LIBRARYNAME
459
460 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
461 LIBRARYNAME := $(strip $(LIBRARYNAME))
462 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
463 LibName.A  := $(LibDir)/lib$(LIBRARYNAME).a
464 LibName.O  := $(LibDir)/$(LIBRARYNAME).o
465 LibName.BC := $(LibDir)/lib$(LIBRARYNAME).bc
466
467 #---------------------------------------------------------
468 # Shared Library Targets:
469 #   If the user asked for a shared library to be built
470 #   with the SHARED_LIBRARY variable, then we provide
471 #   targets for building them.
472 #---------------------------------------------------------
473 ifdef SHARED_LIBRARY
474
475 all-local:: $(LibName.LA)
476
477 $(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
478         $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
479         $(Verb) $(Link) -o $@ $(ObjectsLO)
480         $(Verb) $(LTInstall) $@ $(LibDir)
481
482 clean-local::
483 ifneq ($(strip $(LibName.LA)),)
484         -$(Verb) $(RM) -f $(LibName.LA)
485 endif
486
487 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
488
489 install-local:: $(DestSharedLib)
490
491 $(DestSharedLib): $(libdir) $(LibName.LA)
492         $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
493         $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
494         $(Verb) $(LIBTOOL) --finish $(libdir)
495
496 uninstall-local:: 
497         $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
498         -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
499
500 endif
501
502 #---------------------------------------------------------
503 # Bytecode Library Targets:
504 #   If the user asked for a bytecode library to be built
505 #   with the BYTECODE_LIBRARY variable, then we provide 
506 #   targets for building them.
507 #---------------------------------------------------------
508 ifdef BYTECODE_LIBRARY
509
510 ifdef EXPORTED_SYMBOL_LIST
511   BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
512 else
513   ifdef EXPORTED_SYMBOL_FILE
514     BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
515   else
516     BCLinkLib += -Xlinker -disable-internalize
517   endif
518 endif
519
520 all-local:: $(LibName.BC)
521
522 $(LibName.BC): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
523         $(Echo) Linking $(BuildMode) Bytecode Library $(notdir $@)
524         $(Verb) $(BCLinkLib) -o $@ $(ObjectsBC)
525
526 clean-local::
527 ifneq ($(strip $(LibName.BC)),)
528         -$(Verb) $(RM) -f $(LibName.BC)
529 endif
530
531 DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
532
533 install-local:: $(DestBytecodeLib)
534
535 $(DestBytecodeLib): $(bytecode_libdir) $(LibName.BC) 
536         $(Echo) Installing $(BuildMode) Bytecode Library $(DestBytecodeLib)
537         $(Verb) $(INSTALL) $(LibName.BC) $@
538
539 uninstall-local::
540         $(Echo) Uninstalling $(BuildMode) Bytecode Library $(DestBytecodeLib)
541         -$(Verb) $(RM) -f $(DestBytecodeLib)
542
543 endif
544
545 #---------------------------------------------------------
546 # ReLinked Library Targets:
547 #   If the user didn't explicitly forbid building a 
548 #   relinked then we provide targets for building them.
549 #---------------------------------------------------------
550 ifndef DONT_BUILD_RELINKED
551
552 all-local:: $(LibName.O)
553
554 $(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
555         $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
556         $(Verb) $(Relink) -o $@ $(ObjectsO)
557
558 clean-local::
559 ifneq ($(strip $(LibName.O)),)
560         -$(Verb) $(RM) -f $(LibName.O)
561 endif
562
563 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
564
565 install-local:: $(DestRelinkedLib)
566
567 $(DestRelinkedLib): $(libdir) $(LibName.O)
568         $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
569         $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
570
571 uninstall-local::
572         $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
573         -$(Verb) $(RM) -f $(DestRelinkedLib)
574
575 endif
576
577 #---------------------------------------------------------
578 # Archive Library Targets:
579 #   If the user wanted a regular archive library built, 
580 #   then we provide targets for building them.
581 #---------------------------------------------------------
582 ifdef BUILD_ARCHIVE
583
584 all-local:: $(LibName.A)
585
586 $(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
587         $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
588         -$(Verb) $(RM) -f $@
589         $(Verb) $(Archive) $@ $(ObjectsO)
590         $(Verb) $(Ranlib) $@
591
592 clean-local::
593 ifneq ($(strip $(LibName.A)),)
594         -$(Verb) $(RM) -f $(LibName.A)
595 endif
596
597 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
598
599 install-local:: $(DestArchiveLib)
600
601 $(DestArchiveLib): $(libdir) $(LibName.A)
602         $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
603         $(Verb) $(MKDIR) $(libdir)
604         $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
605
606 uninstall-local::
607         $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
608         -$(Verb) $(RM) -f $(DestArchiveLib)
609
610 endif
611
612 # endif LIBRARYNAME
613 endif 
614
615 ###############################################################################
616 # Tool Build Rules: Build executable tool based on TOOLNAME option
617 ###############################################################################
618
619 ifdef TOOLNAME
620
621 #---------------------------------------------------------
622 # Set up variables for building a tool.
623 #---------------------------------------------------------
624 ifdef EXAMPLE_TOOL
625 ToolBuildPath   := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
626 else
627 ToolBuildPath   := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
628 endif
629 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
630 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
631 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
632 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
633 ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
634 LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
635 ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
636 LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
637
638 #---------------------------------------------------------
639 # Handle optional compression libraries automatically
640 #---------------------------------------------------------
641 ExtraLibs := $(LIBS)
642 ifeq ($(HAVE_BZIP2),1)
643 ExtraLibs += -lbz2
644 endif
645 ifeq ($(HAVE_ZLIB),1)
646 ExtraLibs += -lz
647 endif
648
649 #---------------------------------------------------------
650 # Tell make that we need to rebuild subdirectories before 
651 # we can link the tool. This affects things like LLI which 
652 # has library subdirectories.
653 #---------------------------------------------------------
654 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
655
656 #---------------------------------------------------------
657 # Provide targets for building the tools
658 #---------------------------------------------------------
659 all-local:: $(ToolBuildPath)
660
661 clean-local::
662 ifneq ($(strip $(ToolBuildPath)),)
663         -$(Verb) $(RM) -f $(ToolBuildPath)
664 endif
665
666 ifdef EXAMPLE_TOOL
667 $(ToolBuildPath): $(ExmplDir)/.dir
668 else
669 $(ToolBuildPath): $(ToolDir)/.dir
670 endif
671
672 $(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
673         $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
674         $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
675           $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
676         $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg) 
677
678 DestTool = $(bindir)/$(TOOLNAME)
679
680 install-local:: $(DestTool)
681
682 $(DestTool): $(bindir) $(ToolBuildPath)
683         $(Echo) Installing $(BuildMode) $(DestTool)
684         $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
685
686 uninstall-local::
687         $(Echo) Uninstalling $(BuildMode) $(DestTool)
688         -$(Verb) $(RM) -f $(DestTool)
689
690 endif
691
692 ###############################################################################
693 # Object Build Rules: Build object files based on sources 
694 ###############################################################################
695
696 # Provide rule sets for when dependency generation is enabled
697 ifndef DISABLE_AUTO_DEPENDENCIES
698
699 #---------------------------------------------------------
700 # Create .lo files in the ObjDir directory from the .cpp and .c files...
701 #---------------------------------------------------------
702 ifdef SHARED_LIBRARY
703
704 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
705         $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
706         $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
707         then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
708         else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
709
710 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir 
711         $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
712         $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
713         then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
714         else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
715
716 #---------------------------------------------------------
717 # Create .o files in the ObjDir directory from the .cpp and .c files...
718 #---------------------------------------------------------
719 else
720
721 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
722         $(Echo) "Compiling $*.cpp for $(BuildMode) build"
723         $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
724         then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
725         else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
726
727 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
728         $(Echo) "Compiling $*.c for $(BuildMode) build"
729         $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
730         then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
731         else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
732
733 endif
734
735 #---------------------------------------------------------
736 # Create .bc files in the ObjDir directory from .cpp and .c files...
737 #---------------------------------------------------------
738 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
739         $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
740         $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
741         then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
742         else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
743
744 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir
745         $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
746         $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
747         then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
748         else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
749
750 # Provide alternate rule sets if dependencies are disabled
751 else
752
753 ifdef SHARED_LIBRARY
754
755 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir 
756         $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
757         $(LTCompile.CXX) $< -o $@ 
758
759 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir 
760         $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
761         $(LTCompile.C) $< -o $@ 
762
763 else
764
765 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
766         $(Echo) "Compiling $*.cpp for $(BuildMode) build"
767         $(Compile.CXX) $< -o $@ 
768
769 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
770         $(Echo) "Compiling $*.cpp for $(BuildMode) build"
771         $(Compile.C) $< -o $@ 
772 endif
773
774 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
775         $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
776         $(BCCompile.CXX) $< -o $@ 
777
778 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir
779         $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
780         $(BCCompile.C) $< -o $@
781
782 endif
783
784 #---------------------------------------------------------
785 # Provide rule to build .bc files from .ll sources,
786 # regardless of dependencies
787 #---------------------------------------------------------
788 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
789         $(Echo) "Compiling $*.ll for $(BuildMode) build"
790         $(Verb) $(LLVMAS) $< -f -o $@
791
792 ###############################################################################
793 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
794 ###############################################################################
795
796 ifdef TARGET
797
798 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
799 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
800
801 $(INCFiles) : $(TBLGEN) $(TDFiles)
802
803 %GenRegisterNames.inc : %.td 
804         $(Echo) "Building $(<F) register names with tblgen"
805         $(Verb) $(TableGen) -gen-register-enums -o $@ $<
806
807 %GenRegisterInfo.h.inc : %.td 
808         $(Echo) "Building $(<F) register information header with tblgen"
809         $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
810
811 %GenRegisterInfo.inc : %.td
812         $(Echo) "Building $(<F) register info implementation with tblgen"
813         $(Verb) $(TableGen) -gen-register-desc -o $@ $<
814
815 %GenInstrNames.inc : %.td
816         $(Echo) "Building $(<F) instruction names with tblgen"
817         $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
818
819 %GenInstrInfo.inc : %.td
820         $(Echo) "Building $(<F) instruction information with tblgen"
821         $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
822
823 %GenAsmWriter.inc : %.td
824         $(Echo) "Building $(<F) assembly writer with tblgen"
825         $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
826
827 %GenATTAsmWriter.inc : %.td
828         $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
829         $(Verb) $(TableGen) -gen-asm-writer -o $@ $< 
830
831 %GenIntelAsmWriter.inc : %.td
832         $(Echo) "Building $(<F) Intel assembly writer with tblgen"
833         $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $< 
834
835 %GenInstrSelector.inc: %.td
836         $(Echo) "Building $(<F) instruction selector with tblgen"
837         $(Verb) $(TableGen) -gen-instr-selector -o $@ $< 
838
839 %GenCodeEmitter.inc:: %.td
840         $(Echo) "Building $(<F) code emitter with tblgen"
841         $(Verb) $(TableGen) -gen-emitter -o $@ $<
842
843 clean-local::
844         -$(Verb) $(RM) -f $(INCFiles)
845
846 endif
847
848 ###############################################################################
849 # LEX AND YACC: Provide rules for generating sources with lex and yacc
850 ###############################################################################
851
852 #---------------------------------------------------------
853 # Provide rules for generating a .cpp source file from 
854 # (f)lex input sources. 
855 #---------------------------------------------------------
856
857 LexFiles  := $(filter %.l,$(Sources))
858
859 ifneq ($(LexFiles),)
860
861 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
862
863 .PRECIOUS: $(LexOutput)
864
865 # Note the extra sed filtering here, used to cut down on the warnings emited 
866 # by GCC.  The last line is a gross hack to work around flex aparently not 
867 # being able to resize the buffer on a large token input.  Currently, for 
868 # uninitialized string buffers in LLVM we can generate very long tokens, so 
869 # this is a hack around it.
870 # FIXME.  (f.e. char Buffer[10000] )
871 %.cpp: %.l
872         $(Echo) Flexing $<
873         $(Verb) $(FLEX) -t $< | \
874         $(SED) 's/void yyunput/inline void yyunput/' | \
875         $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
876         $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
877           > $@
878
879 clean-local::
880         -$(Verb) $(RM) -f $(LexOutput)
881         $(Verb) $(RM) -f $(LexOutput)
882
883 endif
884
885 #---------------------------------------------------------
886 # Provide rules for generating a .cpp and .h source files 
887 # from yacc (bison) input sources.
888 #---------------------------------------------------------
889
890 YaccFiles  := $(filter %.y,$(Sources))
891 ifneq ($(YaccFiles),)
892 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
893
894 .PRECIOUS: $(YaccOutput)
895
896 # Cancel built-in rules for yacc
897 %.c: %.y 
898 %.cpp: %.y
899 %.h: %.y
900
901 # Rule for building the bison parsers...
902 %.cpp %.h : %.y
903         $(Echo) "Bisoning $*.y"
904         $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c  $<
905         $(Verb) $(MV) -f $*.tab.c $*.cpp
906         $(Verb) $(MV) -f $*.tab.h $*.h
907
908 clean-local::
909         -$(Verb) $(RM) -f $(YaccOutput)
910         $(Verb) $(RM) -f $(YaccOutput)
911 endif
912
913 ###############################################################################
914 # OTHER RULES: Other rules needed
915 ###############################################################################
916
917 # To create postscript files from dot files...
918 ifneq ($(DOT),false)
919 %.ps: %.dot
920         $(DOT) -Tps < $< > $@
921 else
922 %.ps: %.dot
923         $(Echo) "Cannot build $@: The program dot is not installed"
924 endif
925
926 # This rules ensures that header files that are removed still have a rule for
927 # which they can be "generated."  This allows make to ignore them and
928 # reproduce the dependency lists.
929 %.h:: ;
930
931 # Define clean-local to clean the current directory. Note that this uses a
932 # very conservative approach ensuring that empty variables do not cause 
933 # errors or disastrous removal.
934 clean-local::
935 ifneq ($(strip $(ObjDir)),)
936         -$(Verb) $(RM) -rf $(ObjDir)
937 endif
938         -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
939 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
940         -$(Verb) $(RM) -f *$(SHLIBEXT)
941 endif
942
943 clean-all-local::
944         -$(Verb) $(RM) -rf Debug Release Profile
945
946 # Build tags database for Emacs/Xemacs:
947 tags:: TAGS CTAGS
948
949 TAGS: 
950         find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
951           $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
952           $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
953           $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
954         -name '*.cpp' -o -name '*.h' | \
955         $(ETAGS) $(ETAGSFLAGS) -
956
957 CTAGS:
958         find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
959           $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
960           $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
961           $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
962           \( -name '*.cpp' -o -name '*.h' \) -print | \
963           ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
964
965
966 ###############################################################################
967 # DEPENDENCIES: Include the dependency files if we should
968 ###############################################################################
969 ifndef DISABLE_AUTO_DEPENDENCIES
970
971 # If its not one of the cleaning targets
972 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
973
974 # Get the list of dependency files
975 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
976 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
977
978 -include /dev/null $(DependFiles)
979
980 endif
981
982 endif 
983
984 ###############################################################################
985 # DISTRIBUTION: Handle construction of a distribution tarball
986 ###############################################################################
987
988 #------------------------------------------------------------------------
989 # Define distribution related variables
990 #------------------------------------------------------------------------
991 DistName    := $(LLVM_TARBALL_NAME)
992 DistDir     := $(BUILD_OBJ_ROOT)/$(DistName)
993 TopDistDir  := $(BUILD_OBJ_ROOT)/$(DistName)
994 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
995 DistZip     := $(BUILD_OBJ_ROOT)/$(DistName).zip
996 DistTarBZ2  := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
997 DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
998                ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
999                Makefile.config.in configure autoconf
1000 DistOther   := $(notdir $(wildcard \
1001                $(BUILD_SRC_DIR)/*.h \
1002                $(BUILD_SRC_DIR)/*.td \
1003                $(BUILD_SRC_DIR)/*.def \
1004                $(BUILD_SRC_DIR)/*.ll \
1005                $(BUILD_SRC_DIR)/*.in))
1006 DistSources := $(Sources) $(EXTRA_DIST)
1007 DistSubDirs := $(SubDirs)
1008 DistFiles   := $(DistAlways) $(DistSources) $(DistOther)
1009
1010 #------------------------------------------------------------------------
1011 # We MUST build distribution with OBJ_DIR != SRC_DIR
1012 #------------------------------------------------------------------------
1013 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1014 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1015         $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1016
1017 DistCheckTop := 
1018 else
1019
1020 DistCheckTop := check
1021
1022 #------------------------------------------------------------------------
1023 # Prevent catastrophic remove
1024 #------------------------------------------------------------------------
1025 ifeq ($(LLVM_TARBALL_NAME),)
1026 $(error LLVM_TARBALL_NAME is empty.  Please rerun configure)
1027 endif
1028
1029 #------------------------------------------------------------------------
1030 # Prevent attempt to run dist targets from anywhere but the top level
1031 #------------------------------------------------------------------------
1032 ifneq ($(LEVEL),.)
1033
1034 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1035         $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1036
1037 else
1038
1039 #------------------------------------------------------------------------
1040 # Provide the top level targets
1041 #------------------------------------------------------------------------
1042
1043 dist-gzip:: $(DistTarGZip)
1044
1045 $(DistTarGZip) : distdir
1046         $(Echo) Packing gzipped distribution tar file.
1047         $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
1048
1049 dist-bzip2:: $(DistTarBZ2)
1050
1051 $(DistTarBZ2) : distdir
1052         $(Echo) Packing bzipped distribution tar file.
1053         $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
1054
1055 dist-zip:: $(DistZip)
1056
1057 $(DistZip) : distdir
1058         $(Echo) Packing zipped distribution file.
1059         $(Verb) rm -f $(DistZip)
1060         $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1061
1062 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip) 
1063         $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1064
1065 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1066
1067 dist-check:: $(DistCheckTop) $(DistTarGZip)
1068         $(Echo) Checking distribution tar file.
1069         $(Verb) if test -d $(DistCheckDir) ; then \
1070           $(RM) -rf $(DistCheckDir) ; \
1071         fi
1072         $(Verb) $(MKDIR) $(DistCheckDir)
1073         $(Verb) cd $(DistCheckDir) && \
1074           $(MKDIR) $(DistCheckDir)/build && \
1075           $(MKDIR) $(DistCheckDir)/install && \
1076           gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1077           cd build && \
1078           ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1079             --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1080           $(MAKE) check && \
1081           $(MAKE) install && \
1082           $(MAKE) uninstall && \
1083           $(MAKE) dist && \
1084           $(MAKE) clean && \
1085           $(MAKE) dist-clean && \
1086           $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1087
1088 dist-clean::
1089         $(Echo) Cleaning distribution files
1090         -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
1091
1092 endif
1093
1094 #------------------------------------------------------------------------
1095 # Provide the recursive distdir target for building the distribution directory
1096 #------------------------------------------------------------------------
1097 distdir : $(DistSources)
1098         $(Echo) Building Distribution Directory $(DistDir)
1099         $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1100           if test -d "$(DistDir)" ; then \
1101             find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1102               exit 1 ; \
1103           fi ; \
1104           $(EchoCmd) Removing $(DistDir) ; \
1105           $(RM) -rf $(DistDir); \
1106         fi
1107         $(Verb) $(MKDIR) $(DistDir) 
1108         $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1109         srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1110         for file in $(DistFiles) ; do \
1111           case "$$file" in \
1112             $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
1113             $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
1114           esac; \
1115           if test -f "$$file" || test -d "$$file" ; then \
1116             from_dir=. ; \
1117           else \
1118             from_dir=$(BUILD_SRC_DIR); \
1119           fi; \
1120           to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
1121           if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1122             to_dir="$(DistDir)/$$dir"; \
1123             $(MKDIR) "$$to_dir" ; \
1124           else \
1125             to_dir="$(DistDir)"; \
1126           fi; \
1127           mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1128           if test -n "$$mid_dir" ; then \
1129             $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1130           fi ; \
1131           if test -d "$$from_dir/$$file"; then \
1132             if test -d "$(BUILD_SRC_DIR)/$$file" && \
1133                test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1134               cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1135             fi; \
1136             cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1137           elif test -f "$$from_dir/$$file" ; then \
1138             cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1139           elif test -L "$$from_dir/$$file" ; then \
1140             cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1141           elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1142             $(EchoCmd) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1143           elif test "$(Verb)" != '@' ; then \
1144             $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1145           fi; \
1146         done
1147         $(Verb) for subdir in $(DistSubDirs) ; do \
1148           if test "$$subdir" \!= "." ; then \
1149             new_distdir="$(DistDir)/$$subdir" ; \
1150             test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1151             ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
1152           fi; \
1153         done
1154         $(Verb) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
1155         -$(Verb) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
1156           ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1157           ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1158           ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1159         || chmod -R a+r $(DistDir)
1160
1161 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1162 # defined by user.
1163 dist-hook::
1164
1165 endif
1166
1167 ###############################################################################
1168 # TOP LEVEL - targets only to apply at the top level directory
1169 ###############################################################################
1170
1171 ifeq ($(LEVEL),.)
1172
1173 #------------------------------------------------------------------------
1174 # Install support for project's include files:
1175 #------------------------------------------------------------------------
1176 install-local::
1177         $(Echo) Installing include files
1178         $(Verb) $(MKDIR) $(includedir)
1179         $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1180           cd $(BUILD_SRC_ROOT)/include && \
1181             find . -path '*/Internal' -prune -o '(' -type f \
1182               '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1183               -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1184         fi
1185
1186 uninstall-local::
1187         $(Echo) Uninstalling include files
1188         $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1189           cd $(BUILD_SRC_ROOT)/include && \
1190             $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1191               '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1192               -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1193         fi 
1194
1195 endif
1196
1197 #------------------------------------------------------------------------
1198 # Print out the directories used for building
1199 #------------------------------------------------------------------------
1200 printvars::
1201         $(Echo) "BuildMode      : " '$(BuildMode)'
1202         $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1203         $(Echo) "BUILD_SRC_DIR  : " '$(BUILD_SRC_DIR)'
1204         $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1205         $(Echo) "BUILD_OBJ_DIR  : " '$(BUILD_OBJ_DIR)'
1206         $(Echo) "LLVM_SRC_ROOT  : " '$(LLVM_SRC_ROOT)'
1207         $(Echo) "LLVM_OBJ_ROOT  : " '$(LLVM_OBJ_ROOT)'
1208         $(Echo) "libdir         : " '$(libdir)'
1209         $(Echo) "bindir         : " '$(bindir)'
1210         $(Echo) "sysconfdir     : " '$(sysconfdir)'
1211         $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1212         $(Echo) "UserTargets    : " '$(UserTargets)'
1213         $(Echo) "ObjMakefiles   : " '$(ObjMakefiles)'
1214         $(Echo) "SrcMakefiles   : " '$(SrcMakefiles)'
1215         $(Echo) "ObjDir         : " '$(ObjDir)'
1216         $(Echo) "LibDir         : " '$(LibDir)'
1217         $(Echo) "ToolDir        : " '$(ToolDir)'
1218         $(Echo) "ExmplDir       : " '$(ExmplDir)'
1219         $(Echo) "TDFiles        : " '$(TDFiles)'
1220         $(Echo) "INCFiles       : " '$(INCFiles)'
1221         $(Echo) "Compile.CXX    : " '$(Compile.CXX)'
1222         $(Echo) "Compile.C      : " '$(Compile.C)'
1223         $(Echo) "Archive        : " '$(Archive)'
1224         $(Echo) "YaccFiles      : " '$(YaccFiles)'
1225         $(Echo) "LexFiles       : " '$(LexFiles)'