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