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 check-local \
24 install-local printvars uninstall-local \
25 install-bytecode-local
26 TopLevelTargets := check 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 \
158 -felide-constructors -fomit-frame-pointer
159 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
160 LD.Flags := -O3 -DNDEBUG
163 CXX.Flags := -g -D_DEBUG
164 C.Flags := -g -D_DEBUG
165 LD.Flags := -g -D_DEBUG
170 CXX.Flags += $(CXXFLAGS)
172 CPP.Flags += $(CPPFLAGS)
173 LD.Flags += $(LDFLAGS)
175 LibTool.Flags := --tag=CXX
177 #--------------------------------------------------------------------
178 # Directory locations
179 #--------------------------------------------------------------------
180 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
181 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
182 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
183 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
184 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
185 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
186 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
188 #--------------------------------------------------------------------
189 # Full Paths To Compiled Tools and Utilities
190 #--------------------------------------------------------------------
191 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
194 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
197 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
200 BURG := $(LLVMToolDir)/burg$(EXEEXT)
203 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
206 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
209 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
212 LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
215 LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
218 #--------------------------------------------------------------------
219 # Adjust to user's request
220 #--------------------------------------------------------------------
222 # Adjust LIBTOOL flags for shared libraries, or not.
223 ifndef SHARED_LIBRARY
224 LibTool.Flags += --tag=disable-shared
226 LD.Flags += -rpath $(LibDir)
237 # Adjust settings for verbose mode
240 LibTool.Flags += --silent
241 AR.Flags += >/dev/null 2>/dev/null
242 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
244 ConfigureScriptFLAGS :=
247 # By default, strip symbol information from executable
249 Strip := $(PLATFORMSTRIPOPTS)
250 StripWarnMsg := "(without symbols)"
253 # Adjust linker flags for building an executable
256 LD.Flags += -rpath $(ExmplDir) -export-dynamic
258 LD.Flags += -rpath $(ToolDir) -export-dynamic
262 #----------------------------------------------------------
263 # Options To Invoke Tools
264 #----------------------------------------------------------
266 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
268 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
269 CPP.Flags += -I$(BUILD_OBJ_DIR) \
271 -I$(BUILD_SRC_ROOT)/include \
272 -I$(BUILD_OBJ_ROOT)/include \
273 -I$(LLVM_OBJ_ROOT)/include \
274 -I$(LLVM_SRC_ROOT)/include \
275 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
277 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
278 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
279 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
280 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
281 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
282 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
283 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
284 $(CompileCommonOpts) $(LD.Flags) $(Strip)
285 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
287 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
288 Burg = $(BURG) -I $(BUILD_SRC_DIR)
289 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
290 Archive = $(AR) $(AR.Flags)
291 LArchive = $(LLVMToolDir)/llvm-ar rcsf
298 #----------------------------------------------------------
299 # Get the list of source files and compute object file
301 #----------------------------------------------------------
304 FakeSources := $(FAKE_SOURCES)
306 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
308 BaseNameSources := $(sort $(basename $(FakeSources)))
309 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
310 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
311 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
314 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
315 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
316 $(BUILD_SRC_DIR)/*.l))
318 Sources := $(SOURCES)
322 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
325 BaseNameSources := $(sort $(basename $(Sources)))
326 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
327 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
328 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
331 ###############################################################################
332 # DIRECTORIES: Handle recursive descent of directory structure
333 ###############################################################################
335 #---------------------------------------------------------
336 # Provide rules to make install dirs. This must be early
337 # in the file so they get built before dependencies
338 #---------------------------------------------------------
341 $(Verb) $(MKDIR) $(bindir)
344 $(Verb) $(MKDIR) $(libdir)
347 $(Verb) $(MKDIR) $(bytecode_libdir)
350 $(Verb) $(MKDIR) $(sysconfdir)
352 # To create other directories, as needed, and timestamp their creation
354 $(Verb) $(MKDIR) $* > /dev/null
357 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
358 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
360 #---------------------------------------------------------
361 # Handle the DIRS options for sequential construction
362 #---------------------------------------------------------
367 $(RecursiveTargets)::
368 $(Verb) for dir in $(DIRS); do \
369 if [ ! -f $$dir/Makefile ]; then \
371 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
373 ($(MAKE) -C $$dir $@ ) || exit 1; \
377 #---------------------------------------------------------
378 # Handle the EXPERIMENTAL_DIRS options ensuring success
379 # after each directory is built.
380 #---------------------------------------------------------
381 ifdef EXPERIMENTAL_DIRS
382 $(RecursiveTargets)::
383 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
384 if [ ! -f $$dir/Makefile ]; then \
386 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
388 ($(MAKE) -C $$dir $@ ) || exit 0; \
392 #---------------------------------------------------------
393 # Handle the PARALLEL_DIRS options for parallel construction
394 #---------------------------------------------------------
397 SubDirs += $(PARALLEL_DIRS)
399 # Unfortunately, this list must be maintained if new recursive targets are added
400 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
401 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
402 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
403 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
404 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
405 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
407 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
410 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
412 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
414 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
417 #---------------------------------------------------------
418 # Handle the OPTIONAL_DIRS options for directores that may
420 #---------------------------------------------------------
423 SubDirs += $(OPTIONAL_DIRS)
425 $(RecursiveTargets)::
426 $(Verb) for dir in $(OPTIONAL_DIRS); do \
427 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
428 if [ ! -f $$dir/Makefile ]; then \
430 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
432 ($(MAKE) -C$$dir $@ ) || exit 1; \
437 #---------------------------------------------------------
438 # Handle the CONFIG_FILES options
439 #---------------------------------------------------------
442 install-local:: $(sysconfdir) $(CONFIG_FILES)
443 $(Echo) Installing Configuration Files To $(sysconfdir)
444 $(Verb)for file in $(CONFIG_FILES); do \
445 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
446 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
447 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
448 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
450 $(ECHO) Error: cannot find config file $${file}. ; \
455 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
456 $(Verb)for file in $(CONFIG_FILES); do \
457 $(RM) -f $(sysconfdir)/$${file} ; \
462 ###############################################################################
463 # Library Build Rules: Four ways to build a library
464 ###############################################################################
466 #---------------------------------------------------------
467 # Bytecode Module Targets:
468 # If the user set MODULE_NAME then they want to build a
469 # bytecode module from the sources. We compile all the
470 # sources and link it together into a single bytecode
472 #---------------------------------------------------------
476 Module := $(LibDir)/$(MODULE_NAME).bc
477 LinkModule := $(LLVMGCC) -shared -nostdlib
479 ifdef EXPORTED_SYMBOL_FILE
480 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
483 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
484 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
485 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
487 all-local:: $(Module)
490 ifneq ($(strip $(Module)),)
491 -$(Verb) $(RM) -f $(Module)
494 DestModule := $(bytecode_libdir)/$(MODULE_NAME).bc
496 install-local:: $(DestModule)
498 $(DestModule): $(bytecode_libdir) $(Module)
499 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
500 $(Verb) $(INSTALL) $(Module) $@
503 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
504 -$(Verb) $(RM) -f $(DestModule)
508 # if we're building a library ...
511 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
512 LIBRARYNAME := $(strip $(LIBRARYNAME))
513 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
514 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
515 LibName.O := $(LibDir)/$(LIBRARYNAME).o
516 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
518 #---------------------------------------------------------
519 # Shared Library Targets:
520 # If the user asked for a shared library to be built
521 # with the SHARED_LIBRARY variable, then we provide
522 # targets for building them.
523 #---------------------------------------------------------
526 all-local:: $(LibName.LA)
528 $(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
529 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
530 $(Verb) $(Link) -o $@ $(ObjectsLO)
531 $(Verb) $(LTInstall) $@ $(LibDir)
534 ifneq ($(strip $(LibName.LA)),)
535 -$(Verb) $(RM) -f $(LibName.LA)
538 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
540 install-local:: $(DestSharedLib)
542 $(DestSharedLib): $(libdir) $(LibName.LA)
543 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
544 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
545 $(Verb) $(LIBTOOL) --finish $(libdir)
548 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
549 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
553 #---------------------------------------------------------
554 # Bytecode Library Targets:
555 # If the user asked for a bytecode library to be built
556 # with the BYTECODE_LIBRARY variable, then we provide
557 # targets for building them.
558 #---------------------------------------------------------
559 ifdef BYTECODE_LIBRARY
561 # make the C and C++ compilers strip debug info out of bytecode libraries.
562 BCCompile.C += -Wa,-strip-debug
563 BCCompile.CXX += -Wa,-strip-debug
565 all-local:: $(LibName.BCA)
567 ifdef EXPORTED_SYMBOL_FILE
568 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
569 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
571 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
572 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
574 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
575 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
577 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
578 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
579 $(Verb) $(LArchive) $@ $(ObjectsBC)
584 ifneq ($(strip $(LibName.BCA)),)
585 -$(Verb) $(RM) -f $(LibName.BCA)
588 DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
590 install-bytecode-local:: $(DestBytecodeLib)
592 install-local:: $(DestBytecodeLib)
594 $(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
595 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
596 $(Verb) $(INSTALL) $(LibName.BCA) $@
599 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
600 -$(Verb) $(RM) -f $(DestBytecodeLib)
604 #---------------------------------------------------------
605 # ReLinked Library Targets:
606 # If the user didn't explicitly forbid building a
607 # relinked then we provide targets for building them.
608 #---------------------------------------------------------
609 ifndef DONT_BUILD_RELINKED
611 all-local:: $(LibName.O)
613 $(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
614 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
615 $(Verb) $(Relink) -o $@ $(ObjectsO)
618 ifneq ($(strip $(LibName.O)),)
619 -$(Verb) $(RM) -f $(LibName.O)
622 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
624 install-local:: $(DestRelinkedLib)
626 $(DestRelinkedLib): $(libdir) $(LibName.O)
627 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
628 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
631 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
632 -$(Verb) $(RM) -f $(DestRelinkedLib)
636 #---------------------------------------------------------
637 # Archive Library Targets:
638 # If the user wanted a regular archive library built,
639 # then we provide targets for building them.
640 #---------------------------------------------------------
643 all-local:: $(LibName.A)
645 $(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
646 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
648 $(Verb) $(Archive) $@ $(ObjectsO)
652 ifneq ($(strip $(LibName.A)),)
653 -$(Verb) $(RM) -f $(LibName.A)
656 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
658 install-local:: $(DestArchiveLib)
660 $(DestArchiveLib): $(libdir) $(LibName.A)
661 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
662 $(Verb) $(MKDIR) $(libdir)
663 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
666 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
667 -$(Verb) $(RM) -f $(DestArchiveLib)
674 ###############################################################################
675 # Tool Build Rules: Build executable tool based on TOOLNAME option
676 ###############################################################################
680 #---------------------------------------------------------
681 # Handle the special "JIT" value for LLVM_LIBS which is a
682 # shorthand for a bunch of libraries that get the correct
683 # JIT support for a tool that runs JIT.
684 #---------------------------------------------------------
685 ifeq ($(LLVMLIBS),JIT)
687 # Make sure we can get our own symbols in the tool
690 # Generic JIT libraries
691 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
693 # You can enable the X86 JIT on a non-X86 host by setting the flag
694 # ENABLE_X86_JIT on the make command line. If not, it will still be
695 # enabled automagically on an X86 host.
700 # What the X86 JIT requires
702 JIT_LIBS += LLVMX86 LLVMSelectionDAG
705 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
706 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
707 # enabled automagically on an SparcV9 host.
708 ifeq ($(ARCH), Sparc)
709 ENABLE_SPARCV9_JIT = 1
712 # What the Sparc JIT requires
713 ifdef ENABLE_SPARCV9_JIT
714 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
715 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
716 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
717 LLVMDataStructure.a LLVMSparcV9RegAlloc
720 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
721 # ENABLE_PPC_JIT on the make command line. If not, it will still be
722 # enabled automagically on an PowerPC host.
723 ifeq ($(ARCH), PowerPC)
727 # What the PowerPC JIT requires
729 JIT_LIBS += LLVMPowerPC
732 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
733 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
734 LLVMSystem.a $(PLATFORMLIBDL)
737 #---------------------------------------------------------
738 # Set up variables for building a tool.
739 #---------------------------------------------------------
741 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
743 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
745 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
746 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
747 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
748 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
749 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
750 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
751 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
752 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
754 #---------------------------------------------------------
755 # Tell make that we need to rebuild subdirectories before
756 # we can link the tool. This affects things like LLI which
757 # has library subdirectories.
758 #---------------------------------------------------------
759 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
761 #---------------------------------------------------------
762 # Provide targets for building the tools
763 #---------------------------------------------------------
764 all-local:: $(ToolBuildPath)
767 ifneq ($(strip $(ToolBuildPath)),)
768 -$(Verb) $(RM) -f $(ToolBuildPath)
772 $(ToolBuildPath): $(ExmplDir)/.dir
774 $(ToolBuildPath): $(ToolDir)/.dir
777 $(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
778 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
779 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
780 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
781 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
783 DestTool = $(bindir)/$(TOOLNAME)
785 install-local:: $(DestTool)
787 $(DestTool): $(bindir) $(ToolBuildPath)
788 $(Echo) Installing $(BuildMode) $(DestTool)
789 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
792 $(Echo) Uninstalling $(BuildMode) $(DestTool)
793 -$(Verb) $(RM) -f $(DestTool)
797 ###############################################################################
798 # Object Build Rules: Build object files based on sources
799 ###############################################################################
801 # Provide rule sets for when dependency generation is enabled
802 ifndef DISABLE_AUTO_DEPENDENCIES
804 #---------------------------------------------------------
805 # Create .lo files in the ObjDir directory from the .cpp and .c files...
806 #---------------------------------------------------------
809 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
810 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
811 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
812 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
813 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
815 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
816 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
817 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
818 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
819 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
821 #---------------------------------------------------------
822 # Create .o files in the ObjDir directory from the .cpp and .c files...
823 #---------------------------------------------------------
826 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
827 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
828 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
829 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
830 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
832 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
833 $(Echo) "Compiling $*.c for $(BuildMode) build"
834 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
835 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
836 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
840 #---------------------------------------------------------
841 # Create .bc files in the ObjDir directory from .cpp and .c files...
842 #---------------------------------------------------------
843 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
844 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
845 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
846 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
847 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
849 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
850 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
851 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
852 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
853 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
855 # Provide alternate rule sets if dependencies are disabled
860 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
861 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
862 $(LTCompile.CXX) $< -o $@
864 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
865 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
866 $(LTCompile.C) $< -o $@
870 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
871 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
872 $(Compile.CXX) $< -o $@
874 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
875 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
876 $(Compile.C) $< -o $@
879 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
880 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
881 $(BCCompile.CXX) $< -o $@
883 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
884 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
885 $(BCCompile.C) $< -o $@
889 #---------------------------------------------------------
890 # Provide rule to build .bc files from .ll sources,
891 # regardless of dependencies
892 #---------------------------------------------------------
893 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
894 $(Echo) "Compiling $*.ll for $(BuildMode) build"
895 $(Verb) $(LLVMAS) $< -f -o $@
897 ###############################################################################
898 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
899 ###############################################################################
903 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
904 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
906 $(INCFiles) : $(TBLGEN) $(TDFiles)
908 %GenRegisterNames.inc : %.td
909 $(Echo) "Building $(<F) register names with tblgen"
910 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
912 %GenRegisterInfo.h.inc : %.td
913 $(Echo) "Building $(<F) register information header with tblgen"
914 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
916 %GenRegisterInfo.inc : %.td
917 $(Echo) "Building $(<F) register info implementation with tblgen"
918 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
920 %GenInstrNames.inc : %.td
921 $(Echo) "Building $(<F) instruction names with tblgen"
922 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
924 %GenInstrInfo.inc : %.td
925 $(Echo) "Building $(<F) instruction information with tblgen"
926 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
928 %GenAsmWriter.inc : %.td
929 $(Echo) "Building $(<F) assembly writer with tblgen"
930 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
932 %GenATTAsmWriter.inc : %.td
933 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
934 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
936 %GenIntelAsmWriter.inc : %.td
937 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
938 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
940 %GenInstrSelector.inc: %.td
941 $(Echo) "Building $(<F) instruction selector with tblgen"
942 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
944 %GenCodeEmitter.inc:: %.td
945 $(Echo) "Building $(<F) code emitter with tblgen"
946 $(Verb) $(TableGen) -gen-emitter -o $@ $<
949 -$(Verb) $(RM) -f $(INCFiles)
953 ###############################################################################
954 # LEX AND YACC: Provide rules for generating sources with lex and yacc
955 ###############################################################################
957 #---------------------------------------------------------
958 # Provide rules for generating a .cpp source file from
959 # (f)lex input sources.
960 #---------------------------------------------------------
962 LexFiles := $(filter %.l,$(Sources))
966 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
968 .PRECIOUS: $(LexOutput)
970 # Note the extra sed filtering here, used to cut down on the warnings emited
971 # by GCC. The last line is a gross hack to work around flex aparently not
972 # being able to resize the buffer on a large token input. Currently, for
973 # uninitialized string buffers in LLVM we can generate very long tokens, so
974 # this is a hack around it.
975 # FIXME. (f.e. char Buffer[10000] )
978 $(Verb) $(FLEX) -t $< | \
979 $(SED) 's/void yyunput/inline void yyunput/' | \
980 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
981 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
985 -$(Verb) $(RM) -f $(LexOutput)
986 $(Verb) $(RM) -f $(LexOutput)
990 #---------------------------------------------------------
991 # Provide rules for generating a .cpp and .h source files
992 # from yacc (bison) input sources.
993 #---------------------------------------------------------
995 YaccFiles := $(filter %.y,$(Sources))
996 ifneq ($(YaccFiles),)
997 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
999 .PRECIOUS: $(YaccOutput)
1001 # Cancel built-in rules for yacc
1006 # Rule for building the bison parsers...
1008 $(Echo) "Bisoning $*.y"
1009 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1010 $(Verb) $(MV) -f $*.tab.c $*.cpp
1011 $(Verb) $(MV) -f $*.tab.h $*.h
1014 -$(Verb) $(RM) -f $(YaccOutput)
1015 $(Verb) $(RM) -f $(YaccOutput)
1018 ###############################################################################
1019 # OTHER RULES: Other rules needed
1020 ###############################################################################
1022 # To create postscript files from dot files...
1023 ifneq ($(DOT),false)
1025 $(DOT) -Tps < $< > $@
1028 $(Echo) "Cannot build $@: The program dot is not installed"
1031 # This rules ensures that header files that are removed still have a rule for
1032 # which they can be "generated." This allows make to ignore them and
1033 # reproduce the dependency lists.
1036 # Define clean-local to clean the current directory. Note that this uses a
1037 # very conservative approach ensuring that empty variables do not cause
1038 # errors or disastrous removal.
1040 ifneq ($(strip $(ObjDir)),)
1041 -$(Verb) $(RM) -rf $(ObjDir)
1043 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1044 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1045 -$(Verb) $(RM) -f *$(SHLIBEXT)
1049 -$(Verb) $(RM) -rf Debug Release Profile
1051 # Build tags database for Emacs/Xemacs:
1055 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1056 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1057 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1058 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1059 -name '*.cpp' -o -name '*.h' | \
1060 $(ETAGS) $(ETAGSFLAGS) -
1063 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1064 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1065 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1066 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1067 \( -name '*.cpp' -o -name '*.h' \) -print | \
1068 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1071 ###############################################################################
1072 # DEPENDENCIES: Include the dependency files if we should
1073 ###############################################################################
1074 ifndef DISABLE_AUTO_DEPENDENCIES
1076 # If its not one of the cleaning targets
1077 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1079 # Get the list of dependency files
1080 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1081 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1083 -include /dev/null $(DependFiles)
1089 ###############################################################################
1090 # CHECK: Running the test suite
1091 ###############################################################################
1094 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1095 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1096 $(EchoCmd) Running test suite ; \
1097 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1098 TESTSUITE=$(TESTSUITE) ; \
1100 $(EchoCmd) No Makefile in test directory ; \
1103 $(EchoCmd) No test directory ; \
1106 ###############################################################################
1107 # DISTRIBUTION: Handle construction of a distribution tarball
1108 ###############################################################################
1110 #------------------------------------------------------------------------
1111 # Define distribution related variables
1112 #------------------------------------------------------------------------
1113 DistName := $(LLVM_TARBALL_NAME)
1114 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1115 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1116 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1117 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1118 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1119 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1120 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1121 Makefile.config.in configure autoconf
1122 DistOther := $(notdir $(wildcard \
1123 $(BUILD_SRC_DIR)/*.h \
1124 $(BUILD_SRC_DIR)/*.td \
1125 $(BUILD_SRC_DIR)/*.def \
1126 $(BUILD_SRC_DIR)/*.ll \
1127 $(BUILD_SRC_DIR)/*.in))
1128 DistSubDirs := $(SubDirs)
1129 DistSources = $(Sources) $(EXTRA_DIST)
1130 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1132 #------------------------------------------------------------------------
1133 # We MUST build distribution with OBJ_DIR != SRC_DIR
1134 #------------------------------------------------------------------------
1135 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1136 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1137 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1141 #------------------------------------------------------------------------
1142 # Prevent catastrophic remove
1143 #------------------------------------------------------------------------
1144 ifeq ($(LLVM_TARBALL_NAME),)
1145 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1148 #------------------------------------------------------------------------
1149 # Prevent attempt to run dist targets from anywhere but the top level
1150 #------------------------------------------------------------------------
1153 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1154 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1158 #------------------------------------------------------------------------
1159 # Provide the top level targets
1160 #------------------------------------------------------------------------
1162 dist-gzip:: $(DistTarGZip)
1164 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1165 $(Echo) Packing gzipped distribution tar file.
1166 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1167 $(GZIP) -c > "$(DistTarGZip)"
1169 dist-bzip2:: $(DistTarBZ2)
1171 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1172 $(Echo) Packing bzipped distribution tar file.
1173 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1174 $(BZIP2) -c >$(DistTarBZ2)
1176 dist-zip:: $(DistZip)
1178 $(DistZip) : $(TopDistDir)/.makedistdir
1179 $(Echo) Packing zipped distribution file.
1180 $(Verb) rm -f $(DistZip)
1181 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1183 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1184 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1186 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1188 dist-check:: $(DistTarGZip)
1189 $(Echo) Checking distribution tar file.
1190 $(Verb) if test -d $(DistCheckDir) ; then \
1191 $(RM) -rf $(DistCheckDir) ; \
1193 $(Verb) $(MKDIR) $(DistCheckDir)
1194 $(Verb) cd $(DistCheckDir) && \
1195 $(MKDIR) $(DistCheckDir)/build && \
1196 $(MKDIR) $(DistCheckDir)/install && \
1197 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1199 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1200 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1203 $(MAKE) install && \
1204 $(MAKE) uninstall && \
1207 $(MAKE) dist-clean && \
1208 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1211 $(Echo) Cleaning distribution files
1212 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1217 #------------------------------------------------------------------------
1218 # Provide the recursive distdir target for building the distribution directory
1219 #------------------------------------------------------------------------
1220 distdir: $(DistDir)/.makedistdir
1221 $(DistDir)/.makedistdir: $(DistSources)
1222 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1223 if test -d "$(DistDir)" ; then \
1224 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1227 $(EchoCmd) Removing old $(DistDir) ; \
1228 $(RM) -rf $(DistDir); \
1229 $(EchoCmd) Making 'all' to verify build ; \
1232 $(Echo) Building Distribution Directory $(DistDir)
1233 $(Verb) $(MKDIR) $(DistDir)
1234 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1235 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1236 for file in $(DistFiles) ; do \
1238 $(BUILD_SRC_DIR)/*) \
1239 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1241 $(BUILD_SRC_ROOT)/*) \
1242 file=`echo "$$file" | \
1243 sed "s#^$$srcrootstrip/##"` \
1246 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1247 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1248 from_dir="$(BUILD_SRC_DIR)" ; \
1249 elif test -f "$$file" || test -d "$$file" ; then \
1252 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1253 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1254 to_dir="$(DistDir)/$$dir"; \
1255 $(MKDIR) "$$to_dir" ; \
1257 to_dir="$(DistDir)"; \
1259 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1260 if test -n "$$mid_dir" ; then \
1261 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1263 if test -d "$$from_dir/$$file"; then \
1264 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1265 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1266 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1268 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1269 elif test -f "$$from_dir/$$file" ; then \
1270 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1271 elif test -L "$$from_dir/$$file" ; then \
1272 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1273 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1274 $(EchoCmd) "===== WARNING: Distribution Source " \
1275 "$$from_dir/$$file Not Found!" ; \
1276 elif test "$(Verb)" != '@' ; then \
1277 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1280 $(Verb) for subdir in $(DistSubDirs) ; do \
1281 if test "$$subdir" \!= "." ; then \
1282 new_distdir="$(DistDir)/$$subdir" ; \
1283 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1284 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1288 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1289 $(EchoCmd) Eliminating CVS directories from distribution ; \
1290 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1291 $(MAKE) dist-hook ; \
1292 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1293 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1294 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1295 -o ! -type d ! -perm -444 -exec \
1296 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1297 || chmod -R a+r $(DistDir) ; \
1300 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1306 ###############################################################################
1307 # TOP LEVEL - targets only to apply at the top level directory
1308 ###############################################################################
1312 #------------------------------------------------------------------------
1313 # Install support for the project's include files:
1314 #------------------------------------------------------------------------
1316 $(Echo) Installing include files
1317 $(Verb) $(MKDIR) $(includedir)
1318 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1319 cd $(BUILD_SRC_ROOT)/include && \
1320 find . -path '*/Internal' -prune -o '(' -type f \
1321 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1322 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1326 $(Echo) Uninstalling include files
1327 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1328 cd $(BUILD_SRC_ROOT)/include && \
1329 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1330 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1331 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1336 #------------------------------------------------------------------------
1337 # Print out the directories used for building
1338 #------------------------------------------------------------------------
1340 $(Echo) "BuildMode : " '$(BuildMode)'
1341 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1342 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1343 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1344 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1345 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1346 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1347 $(Echo) "libdir : " '$(libdir)'
1348 $(Echo) "bindir : " '$(bindir)'
1349 $(Echo) "sysconfdir : " '$(sysconfdir)'
1350 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1351 $(Echo) "UserTargets : " '$(UserTargets)'
1352 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1353 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1354 $(Echo) "ObjDir : " '$(ObjDir)'
1355 $(Echo) "LibDir : " '$(LibDir)'
1356 $(Echo) "ToolDir : " '$(ToolDir)'
1357 $(Echo) "ExmplDir : " '$(ExmplDir)'
1358 $(Echo) "Sources : " '$(Sources)'
1359 $(Echo) "TDFiles : " '$(TDFiles)'
1360 $(Echo) "INCFiles : " '$(INCFiles)'
1361 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1362 $(Echo) "Compile.C : " '$(Compile.C)'
1363 $(Echo) "Archive : " '$(Archive)'
1364 $(Echo) "YaccFiles : " '$(YaccFiles)'
1365 $(Echo) "LexFiles : " '$(LexFiles)'
1366 $(Echo) "Module : " '$(Module)'