1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
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.
8 #===------------------------------------------------------------------------===#
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.
13 #===-----------------------------------------------------------------------====
15 ################################################################################
16 # TARGETS: Define standard targets that can be invoked
17 ################################################################################
19 #--------------------------------------------------------------------
20 # Define the various target sets
21 #--------------------------------------------------------------------
22 RecursiveTargets := all clean clean-all install uninstall install-bytecode
23 LocalTargets := all-local clean-local clean-all-local \
24 install-local printvars uninstall-local \
25 install-bytecode-local
26 TopLevelTargets := dist dist-check dist-clean tags dist-gzip dist-bzip2 \
28 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29 InternalTargets := preconditions distdir dist-hook
31 ################################################################################
32 # INITIALIZATION: Basic things the makefile needs
33 ################################################################################
35 #--------------------------------------------------------------------
36 # Set the VPATH so that we can find source files.
37 #--------------------------------------------------------------------
38 VPATH=$(BUILD_SRC_DIR)
40 #--------------------------------------------------------------------
41 # Reset the list of suffixes we know how to build
42 #--------------------------------------------------------------------
44 .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47 #--------------------------------------------------------------------
48 # Mark all of these targets as phony to avoid implicit rule search
49 #--------------------------------------------------------------------
50 .PHONY: $(UserTargets) $(InternalTargets)
52 #--------------------------------------------------------------------
53 # Make sure all the user-target rules are double colon rules and
54 # they are defined first.
55 #--------------------------------------------------------------------
59 ################################################################################
60 # PRECONDITIONS: that which must be built/checked first
61 ################################################################################
63 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
64 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(LLVM_SRC_ROOT)/configure
67 ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
68 MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
69 MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
70 PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
72 preconditions : $(PreConditions)
74 #------------------------------------------------------------------------
75 # Make sure the BUILT_SOURCES are built first
76 #------------------------------------------------------------------------
77 $(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
80 ifneq ($(strip $(BUILT_SOURCES)),)
81 -$(Verb) $(RM) -f $(BUILT_SOURCES)
84 $(BUILT_SOURCES) : $(ObjMakefiles)
86 #------------------------------------------------------------------------
87 # Make sure we're not using a stale configuration
88 #------------------------------------------------------------------------
89 .PRECIOUS: $(ConfigStatusScript)
90 $(ConfigStatusScript): $(ConfigureScript)
91 $(Echo) Reconfiguring with $<
92 $(Verb) cd $(BUILD_OBJ_ROOT) && \
93 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
96 #------------------------------------------------------------------------
97 # Make sure the configuration makefile is up to date
98 #------------------------------------------------------------------------
99 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
100 $(Echo) Regenerating $@
101 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
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))
109 Makefile: $(BUILD_SRC_DIR)/Makefile
110 $(Echo) "Updating Makefile"
111 $(Verb) $(MKDIR) $(@D)
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
117 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
119 *Makefile.rules) ;; \
121 *) $(Echo) "Updating $(@F)" ; \
128 #------------------------------------------------------------------------
129 # Set up the basic dependencies
130 #------------------------------------------------------------------------
131 $(UserTargets):: $(PreConditions)
135 clean-all:: clean-local clean-all-local
136 install:: install-local
137 uninstall:: uninstall-local
138 install-local:: all-local
139 install-bytecode:: install-bytecode-local
141 ###############################################################################
142 # VARIABLES: Set up various variables based on configuration data
143 ###############################################################################
145 #--------------------------------------------------------------------
146 # Variables derived from configuration we are building
147 #--------------------------------------------------------------------
149 ifdef ENABLE_PROFILING
151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
152 C.Flags := -O3 -DNDEBUG -pg
153 LD.Flags := -O3 -DNDEBUG -pg
155 ifdef ENABLE_OPTIMIZED
157 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
158 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
159 LD.Flags := -O3 -DNDEBUG
162 CXX.Flags := -g -D_DEBUG
163 C.Flags := -g -D_DEBUG
164 LD.Flags := -g -D_DEBUG
169 CXX.Flags += $(CXXFLAGS)
171 CPP.Flags += $(CPPFLAGS)
172 LD.Flags += $(LDFLAGS)
174 LibTool.Flags := --tag=CXX
176 #--------------------------------------------------------------------
177 # Directory locations
178 #--------------------------------------------------------------------
179 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
180 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
181 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
182 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
183 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
184 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
185 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
187 #--------------------------------------------------------------------
188 # Full Paths To Compiled Tools and Utilities
189 #--------------------------------------------------------------------
190 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
193 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
196 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
199 BURG := $(LLVMToolDir)/burg$(EXEEXT)
202 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
205 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
208 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
211 LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
214 LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
217 # Need a better way to compute this.
218 LLVMGCCLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
220 #--------------------------------------------------------------------
221 # Adjust to user's request
222 #--------------------------------------------------------------------
224 # Adjust LIBTOOL flags for shared libraries, or not.
225 ifndef SHARED_LIBRARY
226 LibTool.Flags += --tag=disable-shared
228 LD.Flags += -rpath $(LibDir)
239 # Adjust settings for verbose mode
242 LibTool.Flags += --silent
243 AR.Flags += >/dev/null 2>/dev/null
244 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
246 ConfigureScriptFLAGS :=
249 # By default, strip symbol information from executable
251 Strip := $(PLATFORMSTRIPOPTS)
252 StripWarnMsg := "(without symbols)"
255 # Adjust linker flags for building an executable
258 LD.Flags += -rpath $(ExmplDir) -export-dynamic
260 LD.Flags += -rpath $(ToolDir) -export-dynamic
264 #----------------------------------------------------------
265 # Options To Invoke Tools
266 #----------------------------------------------------------
268 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
270 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
271 CPP.Flags += -I$(BUILD_OBJ_DIR) \
273 -I$(BUILD_SRC_ROOT)/include \
274 -I$(BUILD_OBJ_ROOT)/include \
275 -I$(LLVM_OBJ_ROOT)/include \
276 -I$(LLVM_SRC_ROOT)/include \
277 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
279 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
280 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
281 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
282 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
283 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
284 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
285 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
286 $(CompileCommonOpts) $(LD.Flags) $(Strip)
287 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
289 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
290 Burg = $(BURG) -I $(BUILD_SRC_DIR)
291 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
292 Archive = $(AR) $(AR.Flags)
293 LArchive = $(LLVMToolDir)/llvm-ar rcsf
300 #----------------------------------------------------------
301 # Get the list of source files and compute object file
303 #----------------------------------------------------------
306 FakeSources := $(FAKE_SOURCES)
308 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
310 BaseNameSources := $(sort $(basename $(FakeSources)))
311 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
312 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
313 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
316 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
317 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
318 $(BUILD_SRC_DIR)/*.l))
320 Sources := $(SOURCES)
324 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
327 BaseNameSources := $(sort $(basename $(Sources)))
328 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
329 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
330 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
333 ###############################################################################
334 # DIRECTORIES: Handle recursive descent of directory structure
335 ###############################################################################
337 #---------------------------------------------------------
338 # Provide rules to make install dirs. This must be early
339 # in the file so they get built before dependencies
340 #---------------------------------------------------------
343 $(Verb) $(MKDIR) $(bindir)
346 $(Verb) $(MKDIR) $(libdir)
349 $(Verb) $(MKDIR) $(bytecode_libdir)
352 $(Verb) $(MKDIR) $(sysconfdir)
354 # To create other directories, as needed, and timestamp their creation
356 $(Verb) $(MKDIR) $* > /dev/null
359 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
360 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
362 #---------------------------------------------------------
363 # Handle the DIRS options for sequential construction
364 #---------------------------------------------------------
369 $(RecursiveTargets)::
370 $(Verb) for dir in $(DIRS); do \
371 if [ ! -f $$dir/Makefile ]; then \
373 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
375 ($(MAKE) -C $$dir $@ ) || exit 1; \
379 #---------------------------------------------------------
380 # Handle the EXPERIMENTAL_DIRS options ensuring success
381 # after each directory is built.
382 #---------------------------------------------------------
383 ifdef EXPERIMENTAL_DIRS
384 $(RecursiveTargets)::
385 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
386 if [ ! -f $$dir/Makefile ]; then \
388 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
390 ($(MAKE) -C $$dir $@ ) || exit 0; \
394 #---------------------------------------------------------
395 # Handle the PARALLEL_DIRS options for parallel construction
396 #---------------------------------------------------------
399 SubDirs += $(PARALLEL_DIRS)
401 # Unfortunately, this list must be maintained if new recursive targets are added
402 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
403 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
404 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
405 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
406 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
407 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
409 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
412 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
414 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
416 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
419 #---------------------------------------------------------
420 # Handle the OPTIONAL_DIRS options for directores that may
422 #---------------------------------------------------------
425 SubDirs += $(OPTIONAL_DIRS)
427 $(RecursiveTargets)::
428 $(Verb) for dir in $(OPTIONAL_DIRS); do \
429 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
430 if [ ! -f $$dir/Makefile ]; then \
432 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
434 ($(MAKE) -C$$dir $@ ) || exit 1; \
439 #---------------------------------------------------------
440 # Handle the CONFIG_FILES options
441 #---------------------------------------------------------
444 install-local:: $(sysconfdir) $(CONFIG_FILES)
445 $(Echo) Installing Configuration Files To $(sysconfdir)
446 $(Verb)for file in $(CONFIG_FILES); do \
447 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
448 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
449 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
450 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
452 $(ECHO) Error: cannot find config file $${file}. ; \
457 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
458 $(Verb)for file in $(CONFIG_FILES); do \
459 $(RM) -f $(sysconfdir)/$${file} ; \
464 ###############################################################################
465 # Library Build Rules: Four ways to build a library
466 ###############################################################################
468 #---------------------------------------------------------
469 # Bytecode Module Targets:
470 # If the user set MODULE_NAME then they want to build a
471 # bytecode module from the sources. We compile all the
472 # sources and link it together into a single bytecode
474 #---------------------------------------------------------
478 Module := $(LibDir)/$(MODULE_NAME).bc
479 LinkModule := $(LLVMGCC) -shared -nostdlib
481 ifdef EXPORTED_SYMBOL_FILE
482 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
485 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
486 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
487 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
489 all-local:: $(Module)
492 ifneq ($(strip $(Module)),)
493 -$(Verb) $(RM) -f $(Module)
496 DestModule := $(bytecode_libdir)/$(MODULE_NAME).bc
498 install-local:: $(DestModule)
500 $(DestModule): $(bytecode_libdir) $(Module)
501 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
502 $(Verb) $(INSTALL) $(Module) $@
505 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
506 -$(Verb) $(RM) -f $(DestModule)
510 # if we're building a library ...
513 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
514 LIBRARYNAME := $(strip $(LIBRARYNAME))
515 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
516 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
517 LibName.O := $(LibDir)/$(LIBRARYNAME).o
518 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
520 #---------------------------------------------------------
521 # Shared Library Targets:
522 # If the user asked for a shared library to be built
523 # with the SHARED_LIBRARY variable, then we provide
524 # targets for building them.
525 #---------------------------------------------------------
528 all-local:: $(LibName.LA)
530 $(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
531 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
532 $(Verb) $(Link) -o $@ $(ObjectsLO)
533 $(Verb) $(LTInstall) $@ $(LibDir)
536 ifneq ($(strip $(LibName.LA)),)
537 -$(Verb) $(RM) -f $(LibName.LA)
540 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
542 install-local:: $(DestSharedLib)
544 $(DestSharedLib): $(libdir) $(LibName.LA)
545 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
546 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
547 $(Verb) $(LIBTOOL) --finish $(libdir)
550 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
551 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
555 #---------------------------------------------------------
556 # Bytecode Library Targets:
557 # If the user asked for a bytecode library to be built
558 # with the BYTECODE_LIBRARY variable, then we provide
559 # targets for building them.
560 #---------------------------------------------------------
561 ifdef BYTECODE_LIBRARY
563 # make the C and C++ compilers strip debug info out of bytecode libraries.
564 BCCompile.C += -Wa,-strip-debug
565 BCCompile.CXX += -Wa,-strip-debug
567 all-local:: $(LibName.BCA)
569 ifdef EXPORTED_SYMBOL_FILE
570 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
571 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
573 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
574 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
576 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
577 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
579 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
580 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
581 $(Verb) $(LArchive) $@ $(ObjectsBC)
586 ifneq ($(strip $(LibName.BCA)),)
587 -$(Verb) $(RM) -f $(LibName.BCA)
590 DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
592 install-bytecode-local:: $(DestBytecodeLib)
594 install-local:: $(DestBytecodeLib)
596 $(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
597 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
598 $(Verb) $(INSTALL) $(LibName.BCA) $@
601 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
602 -$(Verb) $(RM) -f $(DestBytecodeLib)
606 #---------------------------------------------------------
607 # ReLinked Library Targets:
608 # If the user didn't explicitly forbid building a
609 # relinked then we provide targets for building them.
610 #---------------------------------------------------------
611 ifndef DONT_BUILD_RELINKED
613 all-local:: $(LibName.O)
615 $(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
616 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
617 $(Verb) $(Relink) -o $@ $(ObjectsO)
620 ifneq ($(strip $(LibName.O)),)
621 -$(Verb) $(RM) -f $(LibName.O)
624 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
626 install-local:: $(DestRelinkedLib)
628 $(DestRelinkedLib): $(libdir) $(LibName.O)
629 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
630 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
633 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
634 -$(Verb) $(RM) -f $(DestRelinkedLib)
638 #---------------------------------------------------------
639 # Archive Library Targets:
640 # If the user wanted a regular archive library built,
641 # then we provide targets for building them.
642 #---------------------------------------------------------
645 all-local:: $(LibName.A)
647 $(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
648 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
650 $(Verb) $(Archive) $@ $(ObjectsO)
654 ifneq ($(strip $(LibName.A)),)
655 -$(Verb) $(RM) -f $(LibName.A)
658 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
660 install-local:: $(DestArchiveLib)
662 $(DestArchiveLib): $(libdir) $(LibName.A)
663 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
664 $(Verb) $(MKDIR) $(libdir)
665 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
668 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
669 -$(Verb) $(RM) -f $(DestArchiveLib)
676 ###############################################################################
677 # Tool Build Rules: Build executable tool based on TOOLNAME option
678 ###############################################################################
682 #---------------------------------------------------------
683 # Handle the special "JIT" value for LLVM_LIBS which is a
684 # shorthand for a bunch of libraries that get the correct
685 # JIT support for a tool that runs JIT.
686 #---------------------------------------------------------
687 ifeq ($(LLVMLIBS),JIT)
689 # Make sure we can get our own symbols in the tool
692 # Generic JIT libraries
693 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
695 # You can enable the X86 JIT on a non-X86 host by setting the flag
696 # ENABLE_X86_JIT on the make command line. If not, it will still be
697 # enabled automagically on an X86 host.
702 # What the X86 JIT requires
704 JIT_LIBS += LLVMX86 LLVMSelectionDAG
707 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
708 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
709 # enabled automagically on an SparcV9 host.
710 ifeq ($(ARCH), Sparc)
711 ENABLE_SPARCV9_JIT = 1
714 # What the Sparc JIT requires
715 ifdef ENABLE_SPARCV9_JIT
716 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
717 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
718 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
719 LLVMDataStructure.a LLVMSparcV9RegAlloc
722 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
723 # ENABLE_PPC_JIT on the make command line. If not, it will still be
724 # enabled automagically on an PowerPC host.
725 ifeq ($(ARCH), PowerPC)
729 # What the PowerPC JIT requires
731 JIT_LIBS += LLVMPowerPC
734 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
735 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
736 LLVMSystem.a $(PLATFORMLIBDL)
739 #---------------------------------------------------------
740 # Set up variables for building a tool.
741 #---------------------------------------------------------
743 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
745 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
747 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
748 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
749 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
750 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
751 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
752 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
753 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
754 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
756 #---------------------------------------------------------
757 # Tell make that we need to rebuild subdirectories before
758 # we can link the tool. This affects things like LLI which
759 # has library subdirectories.
760 #---------------------------------------------------------
761 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
763 #---------------------------------------------------------
764 # Provide targets for building the tools
765 #---------------------------------------------------------
766 all-local:: $(ToolBuildPath)
769 ifneq ($(strip $(ToolBuildPath)),)
770 -$(Verb) $(RM) -f $(ToolBuildPath)
774 $(ToolBuildPath): $(ExmplDir)/.dir
776 $(ToolBuildPath): $(ToolDir)/.dir
779 $(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
780 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
781 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
782 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
783 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
785 DestTool = $(bindir)/$(TOOLNAME)
787 install-local:: $(DestTool)
789 $(DestTool): $(bindir) $(ToolBuildPath)
790 $(Echo) Installing $(BuildMode) $(DestTool)
791 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
794 $(Echo) Uninstalling $(BuildMode) $(DestTool)
795 -$(Verb) $(RM) -f $(DestTool)
799 ###############################################################################
800 # Object Build Rules: Build object files based on sources
801 ###############################################################################
803 # Provide rule sets for when dependency generation is enabled
804 ifndef DISABLE_AUTO_DEPENDENCIES
806 #---------------------------------------------------------
807 # Create .lo files in the ObjDir directory from the .cpp and .c files...
808 #---------------------------------------------------------
811 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
812 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
813 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
814 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
815 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
817 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
818 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
819 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
820 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
821 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
823 #---------------------------------------------------------
824 # Create .o files in the ObjDir directory from the .cpp and .c files...
825 #---------------------------------------------------------
828 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
829 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
830 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
831 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
832 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
834 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
835 $(Echo) "Compiling $*.c for $(BuildMode) build"
836 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
837 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
838 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
842 #---------------------------------------------------------
843 # Create .bc files in the ObjDir directory from .cpp and .c files...
844 #---------------------------------------------------------
845 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
846 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
847 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
848 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
849 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
851 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
852 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
853 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
854 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
855 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
857 # Provide alternate rule sets if dependencies are disabled
862 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
863 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
864 $(LTCompile.CXX) $< -o $@
866 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
867 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
868 $(LTCompile.C) $< -o $@
872 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
873 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
874 $(Compile.CXX) $< -o $@
876 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
877 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
878 $(Compile.C) $< -o $@
881 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
882 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
883 $(BCCompile.CXX) $< -o $@
885 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
886 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
887 $(BCCompile.C) $< -o $@
891 #---------------------------------------------------------
892 # Provide rule to build .bc files from .ll sources,
893 # regardless of dependencies
894 #---------------------------------------------------------
895 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
896 $(Echo) "Compiling $*.ll for $(BuildMode) build"
897 $(Verb) $(LLVMAS) $< -f -o $@
899 ###############################################################################
900 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
901 ###############################################################################
905 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
906 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
908 $(INCFiles) : $(TBLGEN) $(TDFiles)
910 %GenRegisterNames.inc : %.td
911 $(Echo) "Building $(<F) register names with tblgen"
912 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
914 %GenRegisterInfo.h.inc : %.td
915 $(Echo) "Building $(<F) register information header with tblgen"
916 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
918 %GenRegisterInfo.inc : %.td
919 $(Echo) "Building $(<F) register info implementation with tblgen"
920 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
922 %GenInstrNames.inc : %.td
923 $(Echo) "Building $(<F) instruction names with tblgen"
924 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
926 %GenInstrInfo.inc : %.td
927 $(Echo) "Building $(<F) instruction information with tblgen"
928 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
930 %GenAsmWriter.inc : %.td
931 $(Echo) "Building $(<F) assembly writer with tblgen"
932 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
934 %GenATTAsmWriter.inc : %.td
935 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
936 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
938 %GenIntelAsmWriter.inc : %.td
939 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
940 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
942 %GenInstrSelector.inc: %.td
943 $(Echo) "Building $(<F) instruction selector with tblgen"
944 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
946 %GenCodeEmitter.inc:: %.td
947 $(Echo) "Building $(<F) code emitter with tblgen"
948 $(Verb) $(TableGen) -gen-emitter -o $@ $<
951 -$(Verb) $(RM) -f $(INCFiles)
955 ###############################################################################
956 # LEX AND YACC: Provide rules for generating sources with lex and yacc
957 ###############################################################################
959 #---------------------------------------------------------
960 # Provide rules for generating a .cpp source file from
961 # (f)lex input sources.
962 #---------------------------------------------------------
964 LexFiles := $(filter %.l,$(Sources))
968 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
970 .PRECIOUS: $(LexOutput)
972 # Note the extra sed filtering here, used to cut down on the warnings emited
973 # by GCC. The last line is a gross hack to work around flex aparently not
974 # being able to resize the buffer on a large token input. Currently, for
975 # uninitialized string buffers in LLVM we can generate very long tokens, so
976 # this is a hack around it.
977 # FIXME. (f.e. char Buffer[10000] )
980 $(Verb) $(FLEX) -t $< | \
981 $(SED) 's/void yyunput/inline void yyunput/' | \
982 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
983 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
987 -$(Verb) $(RM) -f $(LexOutput)
988 $(Verb) $(RM) -f $(LexOutput)
992 #---------------------------------------------------------
993 # Provide rules for generating a .cpp and .h source files
994 # from yacc (bison) input sources.
995 #---------------------------------------------------------
997 YaccFiles := $(filter %.y,$(Sources))
998 ifneq ($(YaccFiles),)
999 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1001 .PRECIOUS: $(YaccOutput)
1003 # Cancel built-in rules for yacc
1008 # Rule for building the bison parsers...
1010 $(Echo) "Bisoning $*.y"
1011 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1012 $(Verb) $(MV) -f $*.tab.c $*.cpp
1013 $(Verb) $(MV) -f $*.tab.h $*.h
1016 -$(Verb) $(RM) -f $(YaccOutput)
1017 $(Verb) $(RM) -f $(YaccOutput)
1020 ###############################################################################
1021 # OTHER RULES: Other rules needed
1022 ###############################################################################
1024 # To create postscript files from dot files...
1025 ifneq ($(DOT),false)
1027 $(DOT) -Tps < $< > $@
1030 $(Echo) "Cannot build $@: The program dot is not installed"
1033 # This rules ensures that header files that are removed still have a rule for
1034 # which they can be "generated." This allows make to ignore them and
1035 # reproduce the dependency lists.
1038 # Define clean-local to clean the current directory. Note that this uses a
1039 # very conservative approach ensuring that empty variables do not cause
1040 # errors or disastrous removal.
1042 ifneq ($(strip $(ObjDir)),)
1043 -$(Verb) $(RM) -rf $(ObjDir)
1045 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1046 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1047 -$(Verb) $(RM) -f *$(SHLIBEXT)
1051 -$(Verb) $(RM) -rf Debug Release Profile
1053 # Build tags database for Emacs/Xemacs:
1057 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1058 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1059 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1060 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1061 -name '*.cpp' -o -name '*.h' | \
1062 $(ETAGS) $(ETAGSFLAGS) -
1065 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1066 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1067 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1068 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1069 \( -name '*.cpp' -o -name '*.h' \) -print | \
1070 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1073 ###############################################################################
1074 # DEPENDENCIES: Include the dependency files if we should
1075 ###############################################################################
1076 ifndef DISABLE_AUTO_DEPENDENCIES
1078 # If its not one of the cleaning targets
1079 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1081 # Get the list of dependency files
1082 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1083 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1085 -include /dev/null $(DependFiles)
1091 ###############################################################################
1092 # DISTRIBUTION: Handle construction of a distribution tarball
1093 ###############################################################################
1095 #------------------------------------------------------------------------
1096 # Define distribution related variables
1097 #------------------------------------------------------------------------
1098 DistName := $(LLVM_TARBALL_NAME)
1099 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1100 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1101 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1102 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1103 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1104 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1105 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1106 Makefile.config.in configure autoconf
1107 DistOther := $(notdir $(wildcard \
1108 $(BUILD_SRC_DIR)/*.h \
1109 $(BUILD_SRC_DIR)/*.td \
1110 $(BUILD_SRC_DIR)/*.def \
1111 $(BUILD_SRC_DIR)/*.ll \
1112 $(BUILD_SRC_DIR)/*.in))
1113 DistSubDirs := $(SubDirs)
1114 DistSources = $(Sources) $(EXTRA_DIST)
1115 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1117 #------------------------------------------------------------------------
1118 # We MUST build distribution with OBJ_DIR != SRC_DIR
1119 #------------------------------------------------------------------------
1120 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1121 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1122 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1126 #------------------------------------------------------------------------
1127 # Prevent catastrophic remove
1128 #------------------------------------------------------------------------
1129 ifeq ($(LLVM_TARBALL_NAME),)
1130 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1133 #------------------------------------------------------------------------
1134 # Prevent attempt to run dist targets from anywhere but the top level
1135 #------------------------------------------------------------------------
1138 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1139 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1143 #------------------------------------------------------------------------
1144 # Provide the top level targets
1145 #------------------------------------------------------------------------
1147 dist-gzip:: $(DistTarGZip)
1149 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1150 $(Echo) Packing gzipped distribution tar file.
1151 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1152 $(GZIP) -c > "$(DistTarGZip)"
1154 dist-bzip2:: $(DistTarBZ2)
1156 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1157 $(Echo) Packing bzipped distribution tar file.
1158 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1159 $(BZIP2) -c >$(DistTarBZ2)
1161 dist-zip:: $(DistZip)
1163 $(DistZip) : $(TopDistDir)/.makedistdir
1164 $(Echo) Packing zipped distribution file.
1165 $(Verb) rm -f $(DistZip)
1166 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1168 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1169 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1171 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1173 dist-check:: $(DistTarGZip)
1174 $(Echo) Checking distribution tar file.
1175 $(Verb) if test -d $(DistCheckDir) ; then \
1176 $(RM) -rf $(DistCheckDir) ; \
1178 $(Verb) $(MKDIR) $(DistCheckDir)
1179 $(Verb) cd $(DistCheckDir) && \
1180 $(MKDIR) $(DistCheckDir)/build && \
1181 $(MKDIR) $(DistCheckDir)/install && \
1182 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1184 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1185 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1188 $(MAKE) install && \
1189 $(MAKE) uninstall && \
1192 $(MAKE) dist-clean && \
1193 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1196 $(Echo) Cleaning distribution files
1197 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1202 #------------------------------------------------------------------------
1203 # Provide the recursive distdir target for building the distribution directory
1204 #------------------------------------------------------------------------
1205 distdir: $(DistDir)/.makedistdir
1206 $(DistDir)/.makedistdir: $(DistSources)
1207 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1208 if test -d "$(DistDir)" ; then \
1209 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1212 $(EchoCmd) Removing old $(DistDir) ; \
1213 $(RM) -rf $(DistDir); \
1214 $(EchoCmd) Making 'all' to be sure. ; \
1217 $(Echo) Building Distribution Directory $(DistDir)
1218 $(Verb) $(MKDIR) $(DistDir)
1219 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1220 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1221 for file in $(DistFiles) ; do \
1223 $(BUILD_SRC_DIR)/*) \
1224 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1226 $(BUILD_SRC_ROOT)/*) \
1227 file=`echo "$$file" | \
1228 sed "s#^$$srcrootstrip/##"` \
1231 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1232 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1233 from_dir="$(BUILD_SRC_DIR)" ; \
1234 elif test -f "$$file" || test -d "$$file" ; then \
1237 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1238 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1239 to_dir="$(DistDir)/$$dir"; \
1240 $(MKDIR) "$$to_dir" ; \
1242 to_dir="$(DistDir)"; \
1244 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1245 if test -n "$$mid_dir" ; then \
1246 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1248 if test -d "$$from_dir/$$file"; then \
1249 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1250 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1251 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1253 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1254 elif test -f "$$from_dir/$$file" ; then \
1255 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1256 elif test -L "$$from_dir/$$file" ; then \
1257 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1258 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1259 $(EchoCmd) "===== WARNING: Distribution Source " \
1260 "$$from_dir/$$file Not Found!" ; \
1261 elif test "$(Verb)" != '@' ; then \
1262 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1265 $(Verb) for subdir in $(DistSubDirs) ; do \
1266 if test "$$subdir" \!= "." ; then \
1267 new_distdir="$(DistDir)/$$subdir" ; \
1268 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1269 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1273 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1274 $(EchoCmd) Eliminating CVS directories from distribution ; \
1275 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1276 $(MAKE) dist-hook ; \
1277 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1278 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1279 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1280 -o ! -type d ! -perm -444 -exec \
1281 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1282 || chmod -R a+r $(DistDir) ; \
1285 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1291 ###############################################################################
1292 # TOP LEVEL - targets only to apply at the top level directory
1293 ###############################################################################
1297 #------------------------------------------------------------------------
1298 # Install support for project's include files:
1299 #------------------------------------------------------------------------
1301 $(Echo) Installing include files
1302 $(Verb) $(MKDIR) $(includedir)
1303 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1304 cd $(BUILD_SRC_ROOT)/include && \
1305 find . -path '*/Internal' -prune -o '(' -type f \
1306 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1307 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1311 $(Echo) Uninstalling include files
1312 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1313 cd $(BUILD_SRC_ROOT)/include && \
1314 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1315 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1316 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1321 #------------------------------------------------------------------------
1322 # Print out the directories used for building
1323 #------------------------------------------------------------------------
1325 $(Echo) "BuildMode : " '$(BuildMode)'
1326 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1327 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1328 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1329 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1330 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1331 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1332 $(Echo) "libdir : " '$(libdir)'
1333 $(Echo) "bindir : " '$(bindir)'
1334 $(Echo) "sysconfdir : " '$(sysconfdir)'
1335 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1336 $(Echo) "UserTargets : " '$(UserTargets)'
1337 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1338 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1339 $(Echo) "ObjDir : " '$(ObjDir)'
1340 $(Echo) "LibDir : " '$(LibDir)'
1341 $(Echo) "ToolDir : " '$(ToolDir)'
1342 $(Echo) "ExmplDir : " '$(ExmplDir)'
1343 $(Echo) "Sources : " '$(Sources)'
1344 $(Echo) "TDFiles : " '$(TDFiles)'
1345 $(Echo) "INCFiles : " '$(INCFiles)'
1346 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1347 $(Echo) "Compile.C : " '$(Compile.C)'
1348 $(Echo) "Archive : " '$(Archive)'
1349 $(Echo) "YaccFiles : " '$(YaccFiles)'
1350 $(Echo) "LexFiles : " '$(LexFiles)'
1351 $(Echo) "Module : " '$(Module)'