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