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