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