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))/
219 LLVMGCCStdCXXLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libstdc++.a))/
221 #--------------------------------------------------------------------
222 # Adjust to user's request
223 #--------------------------------------------------------------------
225 # Adjust LIBTOOL flags for shared libraries, or not.
226 ifndef SHARED_LIBRARY
227 LibTool.Flags += --tag=disable-shared
229 LD.Flags += -rpath $(LibDir)
240 # Adjust settings for verbose mode
243 LibTool.Flags += --silent
244 AR.Flags += >/dev/null 2>/dev/null
245 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
247 ConfigureScriptFLAGS :=
250 # By default, strip symbol information from executable
252 Strip := $(PLATFORMSTRIPOPTS)
253 StripWarnMsg := "(without symbols)"
256 # Adjust linker flags for building an executable
259 LD.Flags += -rpath $(ExmplDir) -export-dynamic
261 LD.Flags += -rpath $(ToolDir) -export-dynamic
265 #----------------------------------------------------------
266 # Options To Invoke Tools
267 #----------------------------------------------------------
269 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
271 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
272 CPP.Flags += -I$(BUILD_OBJ_DIR) \
274 -I$(BUILD_SRC_ROOT)/include \
275 -I$(BUILD_OBJ_ROOT)/include \
276 -I$(LLVM_OBJ_ROOT)/include \
277 -I$(LLVM_SRC_ROOT)/include \
278 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
280 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
281 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
282 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
283 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
284 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
285 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
286 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
287 $(CompileCommonOpts) $(LD.Flags) $(Strip)
288 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
290 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
291 Burg = $(BURG) -I $(BUILD_SRC_DIR)
292 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
293 Archive = $(AR) $(AR.Flags)
294 LArchive = $(LLVMToolDir)/llvm-ar rcsf
301 #----------------------------------------------------------
302 # Get the list of source files and compute object file
304 #----------------------------------------------------------
307 FakeSources := $(FAKE_SOURCES)
309 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
311 BaseNameSources := $(sort $(basename $(FakeSources)))
312 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
313 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
314 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
317 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
318 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
319 $(BUILD_SRC_DIR)/*.l))
321 Sources := $(SOURCES)
325 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
328 BaseNameSources := $(sort $(basename $(Sources)))
329 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
330 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
331 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
334 ###############################################################################
335 # DIRECTORIES: Handle recursive descent of directory structure
336 ###############################################################################
338 #---------------------------------------------------------
339 # Provide rules to make install dirs. This must be early
340 # in the file so they get built before dependencies
341 #---------------------------------------------------------
344 $(Verb) $(MKDIR) $(bindir)
347 $(Verb) $(MKDIR) $(libdir)
350 $(Verb) $(MKDIR) $(bytecode_libdir)
353 $(Verb) $(MKDIR) $(sysconfdir)
355 # To create other directories, as needed, and timestamp their creation
357 $(Verb) $(MKDIR) $* > /dev/null
360 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
361 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
363 #---------------------------------------------------------
364 # Handle the DIRS options for sequential construction
365 #---------------------------------------------------------
370 $(RecursiveTargets)::
371 $(Verb) for dir in $(DIRS); do \
372 if [ ! -f $$dir/Makefile ]; then \
374 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
376 ($(MAKE) -C $$dir $@ ) || exit 1; \
380 #---------------------------------------------------------
381 # Handle the EXPERIMENTAL_DIRS options ensuring success
382 # after each directory is built.
383 #---------------------------------------------------------
384 ifdef EXPERIMENTAL_DIRS
385 $(RecursiveTargets)::
386 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
387 if [ ! -f $$dir/Makefile ]; then \
389 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
391 ($(MAKE) -C $$dir $@ ) || exit 0; \
395 #---------------------------------------------------------
396 # Handle the PARALLEL_DIRS options for parallel construction
397 #---------------------------------------------------------
400 SubDirs += $(PARALLEL_DIRS)
402 # Unfortunately, this list must be maintained if new recursive targets are added
403 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
404 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
405 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
406 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
407 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
408 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
410 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
413 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
415 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
417 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
420 #---------------------------------------------------------
421 # Handle the OPTIONAL_DIRS options for directores that may
423 #---------------------------------------------------------
426 SubDirs += $(OPTIONAL_DIRS)
428 $(RecursiveTargets)::
429 $(Verb) for dir in $(OPTIONAL_DIRS); do \
430 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
431 if [ ! -f $$dir/Makefile ]; then \
433 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
435 ($(MAKE) -C$$dir $@ ) || exit 1; \
440 #---------------------------------------------------------
441 # Handle the CONFIG_FILES options
442 #---------------------------------------------------------
445 install-local:: $(sysconfdir) $(CONFIG_FILES)
446 $(Echo) Installing Configuration Files To $(sysconfdir)
447 $(Verb)for file in $(CONFIG_FILES); do \
448 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
449 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
450 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
451 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
453 $(ECHO) Error: cannot find config file $${file}. ; \
458 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
459 $(Verb)for file in $(CONFIG_FILES); do \
460 $(RM) -f $(sysconfdir)/$${file} ; \
465 ###############################################################################
466 # Library Build Rules: Four ways to build a library
467 ###############################################################################
469 #---------------------------------------------------------
470 # Bytecode Module Targets:
471 # If the user set MODULE_NAME then they want to build a
472 # bytecode module from the sources. We compile all the
473 # sources and link it together into a single bytecode
475 #---------------------------------------------------------
479 Module := $(LibDir)/$(MODULE_NAME).bc
480 LinkModule := $(LLVMGCC) -shared -nostdlib
482 ifdef EXPORTED_SYMBOL_FILE
483 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
486 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
487 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
488 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
490 all-local:: $(Module)
493 ifneq ($(strip $(Module)),)
494 -$(Verb) $(RM) -f $(Module)
497 DestModule := $(bytecode_libdir)/$(MODULE_NAME).bc
499 install-local:: $(DestModule)
501 $(DestModule): $(bytecode_libdir) $(Module)
502 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
503 $(Verb) $(INSTALL) $(Module) $@
506 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
507 -$(Verb) $(RM) -f $(DestModule)
511 # if we're building a library ...
514 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
515 LIBRARYNAME := $(strip $(LIBRARYNAME))
516 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
517 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
518 LibName.O := $(LibDir)/$(LIBRARYNAME).o
519 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
521 #---------------------------------------------------------
522 # Shared Library Targets:
523 # If the user asked for a shared library to be built
524 # with the SHARED_LIBRARY variable, then we provide
525 # targets for building them.
526 #---------------------------------------------------------
529 all-local:: $(LibName.LA)
531 $(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
532 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
533 $(Verb) $(Link) -o $@ $(ObjectsLO)
534 $(Verb) $(LTInstall) $@ $(LibDir)
537 ifneq ($(strip $(LibName.LA)),)
538 -$(Verb) $(RM) -f $(LibName.LA)
541 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
543 install-local:: $(DestSharedLib)
545 $(DestSharedLib): $(libdir) $(LibName.LA)
546 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
547 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
548 $(Verb) $(LIBTOOL) --finish $(libdir)
551 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
552 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
556 #---------------------------------------------------------
557 # Bytecode Library Targets:
558 # If the user asked for a bytecode library to be built
559 # with the BYTECODE_LIBRARY variable, then we provide
560 # targets for building them.
561 #---------------------------------------------------------
562 ifdef BYTECODE_LIBRARY
564 # make the C and C++ compilers strip debug info out of bytecode libraries.
565 BCCompile.C += -Wa,-strip-debug
566 BCCompile.CXX += -Wa,-strip-debug
568 all-local:: $(LibName.BCA)
570 ifdef EXPORTED_SYMBOL_FILE
571 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
572 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
574 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
575 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
577 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
578 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
580 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
581 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
582 $(Verb) $(LArchive) $@ $(ObjectsBC)
587 ifneq ($(strip $(LibName.BCA)),)
588 -$(Verb) $(RM) -f $(LibName.BCA)
591 DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
593 install-bytecode-local:: $(DestBytecodeLib)
595 install-local:: $(DestBytecodeLib)
597 $(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
598 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
599 $(Verb) $(INSTALL) $(LibName.BCA) $@
602 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
603 -$(Verb) $(RM) -f $(DestBytecodeLib)
607 #---------------------------------------------------------
608 # ReLinked Library Targets:
609 # If the user didn't explicitly forbid building a
610 # relinked then we provide targets for building them.
611 #---------------------------------------------------------
612 ifndef DONT_BUILD_RELINKED
614 all-local:: $(LibName.O)
616 $(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
617 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
618 $(Verb) $(Relink) -o $@ $(ObjectsO)
621 ifneq ($(strip $(LibName.O)),)
622 -$(Verb) $(RM) -f $(LibName.O)
625 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
627 install-local:: $(DestRelinkedLib)
629 $(DestRelinkedLib): $(libdir) $(LibName.O)
630 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
631 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
634 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
635 -$(Verb) $(RM) -f $(DestRelinkedLib)
639 #---------------------------------------------------------
640 # Archive Library Targets:
641 # If the user wanted a regular archive library built,
642 # then we provide targets for building them.
643 #---------------------------------------------------------
646 all-local:: $(LibName.A)
648 $(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
649 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
651 $(Verb) $(Archive) $@ $(ObjectsO)
655 ifneq ($(strip $(LibName.A)),)
656 -$(Verb) $(RM) -f $(LibName.A)
659 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
661 install-local:: $(DestArchiveLib)
663 $(DestArchiveLib): $(libdir) $(LibName.A)
664 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
665 $(Verb) $(MKDIR) $(libdir)
666 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
669 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
670 -$(Verb) $(RM) -f $(DestArchiveLib)
677 ###############################################################################
678 # Tool Build Rules: Build executable tool based on TOOLNAME option
679 ###############################################################################
683 #---------------------------------------------------------
684 # Handle the special "JIT" value for LLVM_LIBS which is a
685 # shorthand for a bunch of libraries that get the correct
686 # JIT support for a tool that runs JIT.
687 #---------------------------------------------------------
688 ifeq ($(LLVMLIBS),JIT)
690 # Make sure we can get our own symbols in the tool
693 # Generic JIT libraries
694 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
696 # You can enable the X86 JIT on a non-X86 host by setting the flag
697 # ENABLE_X86_JIT on the make command line. If not, it will still be
698 # enabled automagically on an X86 host.
703 # What the X86 JIT requires
705 JIT_LIBS += LLVMX86 LLVMSelectionDAG
708 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
709 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
710 # enabled automagically on an SparcV9 host.
711 ifeq ($(ARCH), Sparc)
712 ENABLE_SPARCV9_JIT = 1
715 # What the Sparc JIT requires
716 ifdef ENABLE_SPARCV9_JIT
717 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
718 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
719 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
720 LLVMDataStructure.a LLVMSparcV9RegAlloc
723 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
724 # ENABLE_PPC_JIT on the make command line. If not, it will still be
725 # enabled automagically on an PowerPC host.
726 ifeq ($(ARCH), PowerPC)
730 # What the PowerPC JIT requires
732 JIT_LIBS += LLVMPowerPC
735 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
736 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
737 LLVMSystem.a $(PLATFORMLIBDL)
740 #---------------------------------------------------------
741 # Set up variables for building a tool.
742 #---------------------------------------------------------
744 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
746 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
748 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
749 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
750 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
751 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
752 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
753 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
754 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
755 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
757 #---------------------------------------------------------
758 # Tell make that we need to rebuild subdirectories before
759 # we can link the tool. This affects things like LLI which
760 # has library subdirectories.
761 #---------------------------------------------------------
762 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
764 #---------------------------------------------------------
765 # Provide targets for building the tools
766 #---------------------------------------------------------
767 all-local:: $(ToolBuildPath)
770 ifneq ($(strip $(ToolBuildPath)),)
771 -$(Verb) $(RM) -f $(ToolBuildPath)
775 $(ToolBuildPath): $(ExmplDir)/.dir
777 $(ToolBuildPath): $(ToolDir)/.dir
780 $(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
781 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
782 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
783 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
784 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
786 DestTool = $(bindir)/$(TOOLNAME)
788 install-local:: $(DestTool)
790 $(DestTool): $(bindir) $(ToolBuildPath)
791 $(Echo) Installing $(BuildMode) $(DestTool)
792 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
795 $(Echo) Uninstalling $(BuildMode) $(DestTool)
796 -$(Verb) $(RM) -f $(DestTool)
800 ###############################################################################
801 # Object Build Rules: Build object files based on sources
802 ###############################################################################
804 # Provide rule sets for when dependency generation is enabled
805 ifndef DISABLE_AUTO_DEPENDENCIES
807 #---------------------------------------------------------
808 # Create .lo files in the ObjDir directory from the .cpp and .c files...
809 #---------------------------------------------------------
812 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
813 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
814 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
815 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
816 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
818 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
819 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
820 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
821 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
822 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
824 #---------------------------------------------------------
825 # Create .o files in the ObjDir directory from the .cpp and .c files...
826 #---------------------------------------------------------
829 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
830 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
831 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
832 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
833 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
835 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
836 $(Echo) "Compiling $*.c for $(BuildMode) build"
837 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
838 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
839 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
843 #---------------------------------------------------------
844 # Create .bc files in the ObjDir directory from .cpp and .c files...
845 #---------------------------------------------------------
846 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
847 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
848 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
849 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
850 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
852 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
853 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
854 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
855 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
856 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
858 # Provide alternate rule sets if dependencies are disabled
863 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
864 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
865 $(LTCompile.CXX) $< -o $@
867 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
868 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
869 $(LTCompile.C) $< -o $@
873 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
874 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
875 $(Compile.CXX) $< -o $@
877 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
878 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
879 $(Compile.C) $< -o $@
882 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
883 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
884 $(BCCompile.CXX) $< -o $@
886 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
887 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
888 $(BCCompile.C) $< -o $@
892 #---------------------------------------------------------
893 # Provide rule to build .bc files from .ll sources,
894 # regardless of dependencies
895 #---------------------------------------------------------
896 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
897 $(Echo) "Compiling $*.ll for $(BuildMode) build"
898 $(Verb) $(LLVMAS) $< -f -o $@
900 ###############################################################################
901 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
902 ###############################################################################
906 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
907 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
909 $(INCFiles) : $(TBLGEN) $(TDFiles)
911 %GenRegisterNames.inc : %.td
912 $(Echo) "Building $(<F) register names with tblgen"
913 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
915 %GenRegisterInfo.h.inc : %.td
916 $(Echo) "Building $(<F) register information header with tblgen"
917 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
919 %GenRegisterInfo.inc : %.td
920 $(Echo) "Building $(<F) register info implementation with tblgen"
921 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
923 %GenInstrNames.inc : %.td
924 $(Echo) "Building $(<F) instruction names with tblgen"
925 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
927 %GenInstrInfo.inc : %.td
928 $(Echo) "Building $(<F) instruction information with tblgen"
929 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
931 %GenAsmWriter.inc : %.td
932 $(Echo) "Building $(<F) assembly writer with tblgen"
933 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
935 %GenATTAsmWriter.inc : %.td
936 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
937 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
939 %GenIntelAsmWriter.inc : %.td
940 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
941 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
943 %GenInstrSelector.inc: %.td
944 $(Echo) "Building $(<F) instruction selector with tblgen"
945 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
947 %GenCodeEmitter.inc:: %.td
948 $(Echo) "Building $(<F) code emitter with tblgen"
949 $(Verb) $(TableGen) -gen-emitter -o $@ $<
952 -$(Verb) $(RM) -f $(INCFiles)
956 ###############################################################################
957 # LEX AND YACC: Provide rules for generating sources with lex and yacc
958 ###############################################################################
960 #---------------------------------------------------------
961 # Provide rules for generating a .cpp source file from
962 # (f)lex input sources.
963 #---------------------------------------------------------
965 LexFiles := $(filter %.l,$(Sources))
969 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
971 .PRECIOUS: $(LexOutput)
973 # Note the extra sed filtering here, used to cut down on the warnings emited
974 # by GCC. The last line is a gross hack to work around flex aparently not
975 # being able to resize the buffer on a large token input. Currently, for
976 # uninitialized string buffers in LLVM we can generate very long tokens, so
977 # this is a hack around it.
978 # FIXME. (f.e. char Buffer[10000] )
981 $(Verb) $(FLEX) -t $< | \
982 $(SED) 's/void yyunput/inline void yyunput/' | \
983 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
984 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
988 -$(Verb) $(RM) -f $(LexOutput)
989 $(Verb) $(RM) -f $(LexOutput)
993 #---------------------------------------------------------
994 # Provide rules for generating a .cpp and .h source files
995 # from yacc (bison) input sources.
996 #---------------------------------------------------------
998 YaccFiles := $(filter %.y,$(Sources))
999 ifneq ($(YaccFiles),)
1000 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1002 .PRECIOUS: $(YaccOutput)
1004 # Cancel built-in rules for yacc
1009 # Rule for building the bison parsers...
1011 $(Echo) "Bisoning $*.y"
1012 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1013 $(Verb) $(MV) -f $*.tab.c $*.cpp
1014 $(Verb) $(MV) -f $*.tab.h $*.h
1017 -$(Verb) $(RM) -f $(YaccOutput)
1018 $(Verb) $(RM) -f $(YaccOutput)
1021 ###############################################################################
1022 # OTHER RULES: Other rules needed
1023 ###############################################################################
1025 # To create postscript files from dot files...
1026 ifneq ($(DOT),false)
1028 $(DOT) -Tps < $< > $@
1031 $(Echo) "Cannot build $@: The program dot is not installed"
1034 # This rules ensures that header files that are removed still have a rule for
1035 # which they can be "generated." This allows make to ignore them and
1036 # reproduce the dependency lists.
1039 # Define clean-local to clean the current directory. Note that this uses a
1040 # very conservative approach ensuring that empty variables do not cause
1041 # errors or disastrous removal.
1043 ifneq ($(strip $(ObjDir)),)
1044 -$(Verb) $(RM) -rf $(ObjDir)
1046 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1047 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1048 -$(Verb) $(RM) -f *$(SHLIBEXT)
1052 -$(Verb) $(RM) -rf Debug Release Profile
1054 # Build tags database for Emacs/Xemacs:
1058 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1059 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1060 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1061 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1062 -name '*.cpp' -o -name '*.h' | \
1063 $(ETAGS) $(ETAGSFLAGS) -
1066 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1067 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1068 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1069 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1070 \( -name '*.cpp' -o -name '*.h' \) -print | \
1071 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1074 ###############################################################################
1075 # DEPENDENCIES: Include the dependency files if we should
1076 ###############################################################################
1077 ifndef DISABLE_AUTO_DEPENDENCIES
1079 # If its not one of the cleaning targets
1080 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1082 # Get the list of dependency files
1083 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1084 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1086 -include /dev/null $(DependFiles)
1092 ###############################################################################
1093 # DISTRIBUTION: Handle construction of a distribution tarball
1094 ###############################################################################
1096 #------------------------------------------------------------------------
1097 # Define distribution related variables
1098 #------------------------------------------------------------------------
1099 DistName := $(LLVM_TARBALL_NAME)
1100 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1101 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1102 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1103 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1104 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1105 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1106 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1107 Makefile.config.in configure autoconf
1108 DistOther := $(notdir $(wildcard \
1109 $(BUILD_SRC_DIR)/*.h \
1110 $(BUILD_SRC_DIR)/*.td \
1111 $(BUILD_SRC_DIR)/*.def \
1112 $(BUILD_SRC_DIR)/*.ll \
1113 $(BUILD_SRC_DIR)/*.in))
1114 DistSubDirs := $(SubDirs)
1115 DistSources = $(Sources) $(EXTRA_DIST)
1116 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1118 #------------------------------------------------------------------------
1119 # We MUST build distribution with OBJ_DIR != SRC_DIR
1120 #------------------------------------------------------------------------
1121 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1122 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1123 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1127 #------------------------------------------------------------------------
1128 # Prevent catastrophic remove
1129 #------------------------------------------------------------------------
1130 ifeq ($(LLVM_TARBALL_NAME),)
1131 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1134 #------------------------------------------------------------------------
1135 # Prevent attempt to run dist targets from anywhere but the top level
1136 #------------------------------------------------------------------------
1139 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1140 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1144 #------------------------------------------------------------------------
1145 # Provide the top level targets
1146 #------------------------------------------------------------------------
1148 dist-gzip:: $(DistTarGZip)
1150 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1151 $(Echo) Packing gzipped distribution tar file.
1152 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1153 $(GZIP) -c > "$(DistTarGZip)"
1155 dist-bzip2:: $(DistTarBZ2)
1157 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1158 $(Echo) Packing bzipped distribution tar file.
1159 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1160 $(BZIP2) -c >$(DistTarBZ2)
1162 dist-zip:: $(DistZip)
1164 $(DistZip) : $(TopDistDir)/.makedistdir
1165 $(Echo) Packing zipped distribution file.
1166 $(Verb) rm -f $(DistZip)
1167 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1169 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1170 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1172 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1174 dist-check:: $(DistTarGZip)
1175 $(Echo) Checking distribution tar file.
1176 $(Verb) if test -d $(DistCheckDir) ; then \
1177 $(RM) -rf $(DistCheckDir) ; \
1179 $(Verb) $(MKDIR) $(DistCheckDir)
1180 $(Verb) cd $(DistCheckDir) && \
1181 $(MKDIR) $(DistCheckDir)/build && \
1182 $(MKDIR) $(DistCheckDir)/install && \
1183 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1185 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1186 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1189 $(MAKE) install && \
1190 $(MAKE) uninstall && \
1193 $(MAKE) dist-clean && \
1194 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1197 $(Echo) Cleaning distribution files
1198 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1203 #------------------------------------------------------------------------
1204 # Provide the recursive distdir target for building the distribution directory
1205 #------------------------------------------------------------------------
1206 distdir: $(DistDir)/.makedistdir
1207 $(DistDir)/.makedistdir: $(DistSources)
1208 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1209 if test -d "$(DistDir)" ; then \
1210 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1213 $(EchoCmd) Removing old $(DistDir) ; \
1214 $(RM) -rf $(DistDir); \
1215 $(EchoCmd) Making 'all' to be sure. ; \
1218 $(Echo) Building Distribution Directory $(DistDir)
1219 $(Verb) $(MKDIR) $(DistDir)
1220 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1221 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1222 for file in $(DistFiles) ; do \
1224 $(BUILD_SRC_DIR)/*) \
1225 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1227 $(BUILD_SRC_ROOT)/*) \
1228 file=`echo "$$file" | \
1229 sed "s#^$$srcrootstrip/##"` \
1232 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1233 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1234 from_dir="$(BUILD_SRC_DIR)" ; \
1235 elif test -f "$$file" || test -d "$$file" ; then \
1238 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1239 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1240 to_dir="$(DistDir)/$$dir"; \
1241 $(MKDIR) "$$to_dir" ; \
1243 to_dir="$(DistDir)"; \
1245 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1246 if test -n "$$mid_dir" ; then \
1247 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1249 if test -d "$$from_dir/$$file"; then \
1250 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1251 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1252 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1254 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1255 elif test -f "$$from_dir/$$file" ; then \
1256 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1257 elif test -L "$$from_dir/$$file" ; then \
1258 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1259 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1260 $(EchoCmd) "===== WARNING: Distribution Source " \
1261 "$$from_dir/$$file Not Found!" ; \
1262 elif test "$(Verb)" != '@' ; then \
1263 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1266 $(Verb) for subdir in $(DistSubDirs) ; do \
1267 if test "$$subdir" \!= "." ; then \
1268 new_distdir="$(DistDir)/$$subdir" ; \
1269 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1270 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1274 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1275 $(EchoCmd) Eliminating CVS directories from distribution ; \
1276 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1277 $(MAKE) dist-hook ; \
1278 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1279 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1280 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1281 -o ! -type d ! -perm -444 -exec \
1282 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1283 || chmod -R a+r $(DistDir) ; \
1286 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1292 ###############################################################################
1293 # TOP LEVEL - targets only to apply at the top level directory
1294 ###############################################################################
1298 #------------------------------------------------------------------------
1299 # Install support for project's include files:
1300 #------------------------------------------------------------------------
1302 $(Echo) Installing include files
1303 $(Verb) $(MKDIR) $(includedir)
1304 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1305 cd $(BUILD_SRC_ROOT)/include && \
1306 find . -path '*/Internal' -prune -o '(' -type f \
1307 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1308 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1312 $(Echo) Uninstalling include files
1313 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1314 cd $(BUILD_SRC_ROOT)/include && \
1315 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1316 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1317 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1322 #------------------------------------------------------------------------
1323 # Print out the directories used for building
1324 #------------------------------------------------------------------------
1326 $(Echo) "BuildMode : " '$(BuildMode)'
1327 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1328 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1329 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1330 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1331 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1332 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1333 $(Echo) "libdir : " '$(libdir)'
1334 $(Echo) "bindir : " '$(bindir)'
1335 $(Echo) "sysconfdir : " '$(sysconfdir)'
1336 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1337 $(Echo) "UserTargets : " '$(UserTargets)'
1338 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1339 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1340 $(Echo) "ObjDir : " '$(ObjDir)'
1341 $(Echo) "LibDir : " '$(LibDir)'
1342 $(Echo) "ToolDir : " '$(ToolDir)'
1343 $(Echo) "ExmplDir : " '$(ExmplDir)'
1344 $(Echo) "Sources : " '$(Sources)'
1345 $(Echo) "TDFiles : " '$(TDFiles)'
1346 $(Echo) "INCFiles : " '$(INCFiles)'
1347 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1348 $(Echo) "Compile.C : " '$(Compile.C)'
1349 $(Echo) "Archive : " '$(Archive)'
1350 $(Echo) "YaccFiles : " '$(YaccFiles)'
1351 $(Echo) "LexFiles : " '$(LexFiles)'
1352 $(Echo) "Module : " '$(Module)'