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 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
221 LLI := $(LLVMToolDir)/lli$(EXEEXT)
224 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
227 #--------------------------------------------------------------------
228 # Adjust to user's request
229 #--------------------------------------------------------------------
231 # Adjust LIBTOOL flags for shared libraries, or not.
232 ifndef SHARED_LIBRARY
233 LibTool.Flags += --tag=disable-shared
235 LD.Flags += -rpath $(LibDir)
245 # Adjust settings for verbose mode
248 LibTool.Flags += --silent
249 AR.Flags += >/dev/null 2>/dev/null
250 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
252 ConfigureScriptFLAGS :=
255 # By default, strip symbol information from executable
257 Strip := $(PLATFORMSTRIPOPTS)
258 StripWarnMsg := "(without symbols)"
261 # Adjust linker flags for building an executable
264 LD.Flags += -rpath $(ExmplDir) -export-dynamic
266 LD.Flags += -rpath $(ToolDir) -export-dynamic
270 #----------------------------------------------------------
271 # Options To Invoke Tools
272 #----------------------------------------------------------
274 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
276 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
277 CPP.Flags += -I$(BUILD_OBJ_DIR) \
279 -I$(BUILD_SRC_ROOT)/include \
280 -I$(BUILD_OBJ_ROOT)/include \
281 -I$(LLVM_OBJ_ROOT)/include \
282 -I$(LLVM_SRC_ROOT)/include \
283 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
285 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
286 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
287 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
288 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
289 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
290 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
291 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
292 $(CompileCommonOpts) $(LD.Flags) $(Strip)
293 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
295 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
296 Burg = $(BURG) -I $(BUILD_SRC_DIR)
297 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
298 Archive = $(AR) $(AR.Flags)
299 LArchive = $(LLVMToolDir)/llvm-ar rcsf
306 #----------------------------------------------------------
307 # Get the list of source files and compute object file
309 #----------------------------------------------------------
312 FakeSources := $(FAKE_SOURCES)
314 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
316 BaseNameSources := $(sort $(basename $(FakeSources)))
317 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
318 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
319 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
322 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
323 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
324 $(BUILD_SRC_DIR)/*.l))
326 Sources := $(SOURCES)
330 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
333 BaseNameSources := $(sort $(basename $(Sources)))
334 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
335 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
336 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
339 ###############################################################################
340 # DIRECTORIES: Handle recursive descent of directory structure
341 ###############################################################################
343 #---------------------------------------------------------
344 # Provide rules to make install dirs. This must be early
345 # in the file so they get built before dependencies
346 #---------------------------------------------------------
349 $(Verb) $(MKDIR) $(bindir)
352 $(Verb) $(MKDIR) $(libdir)
355 $(Verb) $(MKDIR) $(includedir)
358 $(Verb) $(MKDIR) $(sysconfdir)
360 # To create other directories, as needed, and timestamp their creation
362 $(Verb) $(MKDIR) $* > /dev/null
365 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
366 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
368 #---------------------------------------------------------
369 # Handle the DIRS options for sequential construction
370 #---------------------------------------------------------
375 $(RecursiveTargets)::
376 $(Verb) for dir in $(DIRS); do \
377 if [ ! -f $$dir/Makefile ]; then \
379 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
381 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
382 ($(MAKE) -C $$dir $@ ) || exit 1; \
387 #---------------------------------------------------------
388 # Handle the EXPERIMENTAL_DIRS options ensuring success
389 # after each directory is built.
390 #---------------------------------------------------------
391 ifdef EXPERIMENTAL_DIRS
392 $(RecursiveTargets)::
393 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
394 if [ ! -f $$dir/Makefile ]; then \
396 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
398 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
399 ($(MAKE) -C $$dir $@ ) || exit 0; \
404 #---------------------------------------------------------
405 # Handle the PARALLEL_DIRS options for parallel construction
406 #---------------------------------------------------------
409 SubDirs += $(PARALLEL_DIRS)
411 # Unfortunately, this list must be maintained if new recursive targets are added
412 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
413 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
414 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
415 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
416 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
417 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
419 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
422 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
424 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
426 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
427 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
431 #---------------------------------------------------------
432 # Handle the OPTIONAL_DIRS options for directores that may
434 #---------------------------------------------------------
437 SubDirs += $(OPTIONAL_DIRS)
439 $(RecursiveTargets)::
440 $(Verb) for dir in $(OPTIONAL_DIRS); do \
441 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
442 if [ ! -f $$dir/Makefile ]; then \
444 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
446 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
447 ($(MAKE) -C$$dir $@ ) || exit 1; \
453 #---------------------------------------------------------
454 # Handle the CONFIG_FILES options
455 #---------------------------------------------------------
458 install-local:: $(sysconfdir) $(CONFIG_FILES)
459 $(Echo) Installing Configuration Files To $(sysconfdir)
460 $(Verb)for file in $(CONFIG_FILES); do \
461 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
462 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
463 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
464 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
466 $(ECHO) Error: cannot find config file $${file}. ; \
471 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
472 $(Verb)for file in $(CONFIG_FILES); do \
473 $(RM) -f $(sysconfdir)/$${file} ; \
478 ###############################################################################
479 # Library Build Rules: Four ways to build a library
480 ###############################################################################
482 #---------------------------------------------------------
483 # Bytecode Module Targets:
484 # If the user set MODULE_NAME then they want to build a
485 # bytecode module from the sources. We compile all the
486 # sources and link it together into a single bytecode
488 #---------------------------------------------------------
492 Module := $(LibDir)/$(MODULE_NAME).bc
493 LinkModule := $(LLVMGCC) -shared -nostdlib
495 ifdef EXPORTED_SYMBOL_FILE
496 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
499 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
500 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
501 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
503 all-local:: $(Module)
506 ifneq ($(strip $(Module)),)
507 -$(Verb) $(RM) -f $(Module)
510 ifdef BYTECODE_DESTINATION
511 ModuleDestDir := $(BYTECODE_DESTINATION)
513 ModuleDestDir := $(libdir)
516 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
518 install-module:: $(DestModule)
519 install-local:: $(DestModule)
521 $(DestModule): $(ModuleDestDir) $(Module)
522 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
523 $(Verb) $(INSTALL) $(Module) $@
526 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
527 -$(Verb) $(RM) -f $(DestModule)
531 # if we're building a library ...
534 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
535 LIBRARYNAME := $(strip $(LIBRARYNAME))
536 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
537 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
538 LibName.O := $(LibDir)/$(LIBRARYNAME).o
539 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
541 #---------------------------------------------------------
542 # Shared Library Targets:
543 # If the user asked for a shared library to be built
544 # with the SHARED_LIBRARY variable, then we provide
545 # targets for building them.
546 #---------------------------------------------------------
549 all-local:: $(LibName.LA)
551 $(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
552 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
553 $(Verb) $(Link) -o $@ $(ObjectsLO)
554 $(Verb) $(LTInstall) $@ $(LibDir)
557 ifneq ($(strip $(LibName.LA)),)
558 -$(Verb) $(RM) -f $(LibName.LA)
561 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
563 install-local:: $(DestSharedLib)
565 $(DestSharedLib): $(libdir) $(LibName.LA)
566 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
567 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
568 $(Verb) $(LIBTOOL) --finish $(libdir)
571 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
572 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
576 #---------------------------------------------------------
577 # Bytecode Library Targets:
578 # If the user asked for a bytecode library to be built
579 # with the BYTECODE_LIBRARY variable, then we provide
580 # targets for building them.
581 #---------------------------------------------------------
582 ifdef BYTECODE_LIBRARY
584 # make the C and C++ compilers strip debug info out of bytecode libraries.
585 BCCompile.C += -Wa,-strip-debug
586 BCCompile.CXX += -Wa,-strip-debug
588 all-local:: $(LibName.BCA)
590 ifdef EXPORTED_SYMBOL_FILE
591 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
592 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
594 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
595 $(LLVMToolDir)/llvm-ar
596 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
598 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
600 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
602 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir \
603 $(LLVMToolDir)/llvm-ar
604 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
606 $(Verb) $(LArchive) $@ $(ObjectsBC)
611 ifneq ($(strip $(LibName.BCA)),)
612 -$(Verb) $(RM) -f $(LibName.BCA)
615 ifdef BYTECODE_DESTINATION
616 BytecodeDestDir := $(BYTECODE_DESTINATION)
618 BytecodeDestDir := $(libdir)
621 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
623 install-bytecode-local:: $(DestBytecodeLib)
625 install-local:: $(DestBytecodeLib)
627 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
628 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
629 $(Verb) $(INSTALL) $(LibName.BCA) $@
632 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
633 -$(Verb) $(RM) -f $(DestBytecodeLib)
637 #---------------------------------------------------------
638 # ReLinked Library Targets:
639 # If the user didn't explicitly forbid building a
640 # relinked then we provide targets for building them.
641 #---------------------------------------------------------
642 ifndef DONT_BUILD_RELINKED
644 all-local:: $(LibName.O)
646 $(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
647 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
648 $(Verb) $(Relink) -o $@ $(ObjectsO)
651 ifneq ($(strip $(LibName.O)),)
652 -$(Verb) $(RM) -f $(LibName.O)
655 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
657 install-local:: $(DestRelinkedLib)
659 $(DestRelinkedLib): $(libdir) $(LibName.O)
660 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
661 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
664 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
665 -$(Verb) $(RM) -f $(DestRelinkedLib)
669 #---------------------------------------------------------
670 # Archive Library Targets:
671 # If the user wanted a regular archive library built,
672 # then we provide targets for building them.
673 #---------------------------------------------------------
676 all-local:: $(LibName.A)
678 $(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
679 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
681 $(Verb) $(Archive) $@ $(ObjectsO)
685 ifneq ($(strip $(LibName.A)),)
686 -$(Verb) $(RM) -f $(LibName.A)
689 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
691 install-local:: $(DestArchiveLib)
693 $(DestArchiveLib): $(libdir) $(LibName.A)
694 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
695 $(Verb) $(MKDIR) $(libdir)
696 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
699 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
700 -$(Verb) $(RM) -f $(DestArchiveLib)
707 ###############################################################################
708 # Tool Build Rules: Build executable tool based on TOOLNAME option
709 ###############################################################################
713 #---------------------------------------------------------
714 # Handle the special "JIT" value for LLVM_LIBS which is a
715 # shorthand for a bunch of libraries that get the correct
716 # JIT support for a tool that runs JIT.
717 #---------------------------------------------------------
718 ifeq ($(LLVMLIBS),JIT)
720 # Make sure we can get our own symbols in the tool
723 # Generic JIT libraries
724 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
726 # You can enable the X86 JIT on a non-X86 host by setting the flag
727 # ENABLE_X86_JIT on the make command line. If not, it will still be
728 # enabled automagically on an X86 host.
733 # What the X86 JIT requires
735 JIT_LIBS += LLVMX86 LLVMSelectionDAG
738 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
739 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
740 # enabled automagically on an SparcV9 host.
741 ifeq ($(ARCH), Sparc)
742 ENABLE_SPARCV9_JIT = 1
745 # What the Sparc JIT requires
746 ifdef ENABLE_SPARCV9_JIT
747 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
748 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
749 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
750 LLVMDataStructure.a LLVMSparcV9RegAlloc
753 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
754 # ENABLE_PPC_JIT on the make command line. If not, it will still be
755 # enabled automagically on an PowerPC host.
756 ifeq ($(ARCH), PowerPC)
760 # What the PowerPC JIT requires
762 JIT_LIBS += LLVMPowerPC
765 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
766 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
767 LLVMSystem.a $(PLATFORMLIBDL)
770 #---------------------------------------------------------
771 # Set up variables for building a tool.
772 #---------------------------------------------------------
774 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
776 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
778 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
779 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
780 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
781 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
782 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
783 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
784 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
785 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
787 #---------------------------------------------------------
788 # Tell make that we need to rebuild subdirectories before
789 # we can link the tool. This affects things like LLI which
790 # has library subdirectories.
791 #---------------------------------------------------------
792 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
794 #---------------------------------------------------------
795 # Provide targets for building the tools
796 #---------------------------------------------------------
797 all-local:: $(ToolBuildPath)
800 ifneq ($(strip $(ToolBuildPath)),)
801 -$(Verb) $(RM) -f $(ToolBuildPath)
805 $(ToolBuildPath): $(ExmplDir)/.dir
807 $(ToolBuildPath): $(ToolDir)/.dir
810 $(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
811 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
812 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
813 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
814 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
816 DestTool = $(bindir)/$(TOOLNAME)
818 install-local:: $(DestTool)
820 $(DestTool): $(bindir) $(ToolBuildPath)
821 $(Echo) Installing $(BuildMode) $(DestTool)
822 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
825 $(Echo) Uninstalling $(BuildMode) $(DestTool)
826 -$(Verb) $(RM) -f $(DestTool)
830 ###############################################################################
831 # Object Build Rules: Build object files based on sources
832 ###############################################################################
834 # Provide rule sets for when dependency generation is enabled
835 ifndef DISABLE_AUTO_DEPENDENCIES
837 #---------------------------------------------------------
838 # Create .lo files in the ObjDir directory from the .cpp and .c files...
839 #---------------------------------------------------------
842 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
843 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
844 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
845 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
846 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
848 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
849 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
850 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
851 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
852 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
854 #---------------------------------------------------------
855 # Create .o files in the ObjDir directory from the .cpp and .c files...
856 #---------------------------------------------------------
859 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
860 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
861 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
862 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
863 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
865 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
866 $(Echo) "Compiling $*.c for $(BuildMode) build"
867 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
868 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
869 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
873 #---------------------------------------------------------
874 # Create .bc files in the ObjDir directory from .cpp and .c files...
875 #---------------------------------------------------------
876 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
877 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
878 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
879 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
880 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
882 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
883 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
884 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
885 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
886 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
888 # Provide alternate rule sets if dependencies are disabled
893 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
894 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
895 $(LTCompile.CXX) $< -o $@
897 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
898 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
899 $(LTCompile.C) $< -o $@
903 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
904 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
905 $(Compile.CXX) $< -o $@
907 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
908 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
909 $(Compile.C) $< -o $@
912 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
913 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
914 $(BCCompile.CXX) $< -o $@
916 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
917 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
918 $(BCCompile.C) $< -o $@
922 #---------------------------------------------------------
923 # Provide rule to build .bc files from .ll sources,
924 # regardless of dependencies
925 #---------------------------------------------------------
926 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
927 $(Echo) "Compiling $*.ll for $(BuildMode) build"
928 $(Verb) $(LLVMAS) $< -f -o $@
930 ###############################################################################
931 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
932 ###############################################################################
936 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
937 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
939 $(INCFiles) : $(TBLGEN) $(TDFiles)
941 $(TARGET)GenRegisterNames.inc : $(TARGET).td
942 $(Echo) "Building $(<F) register names with tblgen"
943 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
945 $(TARGET)GenRegisterInfo.h.inc : $(TARGET).td
946 $(Echo) "Building $(<F) register information header with tblgen"
947 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
949 $(TARGET)GenRegisterInfo.inc : $(TARGET).td
950 $(Echo) "Building $(<F) register info implementation with tblgen"
951 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
953 $(TARGET)GenInstrNames.inc : $(TARGET).td
954 $(Echo) "Building $(<F) instruction names with tblgen"
955 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
957 $(TARGET)GenInstrInfo.inc : $(TARGET).td
958 $(Echo) "Building $(<F) instruction information with tblgen"
959 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
961 $(TARGET)GenAsmWriter.inc : $(TARGET).td
962 $(Echo) "Building $(<F) assembly writer with tblgen"
963 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
965 $(TARGET)GenATTAsmWriter.inc : $(TARGET).td
966 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
967 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
969 $(TARGET)GenIntelAsmWriter.inc : $(TARGET).td
970 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
971 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
973 $(TARGET)GenInstrSelector.inc: $(TARGET).td
974 $(Echo) "Building $(<F) instruction selector with tblgen"
975 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
977 $(TARGET)GenCodeEmitter.inc: $(TARGET).td
978 $(Echo) "Building $(<F) code emitter with tblgen"
979 $(Verb) $(TableGen) -gen-emitter -o $@ $<
982 -$(Verb) $(RM) -f $(INCFiles)
986 ###############################################################################
987 # LEX AND YACC: Provide rules for generating sources with lex and yacc
988 ###############################################################################
990 #---------------------------------------------------------
991 # Provide rules for generating a .cpp source file from
992 # (f)lex input sources.
993 #---------------------------------------------------------
995 LexFiles := $(filter %.l,$(Sources))
999 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1001 .PRECIOUS: $(LexOutput)
1003 # Note the extra sed filtering here, used to cut down on the warnings emited
1004 # by GCC. The last line is a gross hack to work around flex aparently not
1005 # being able to resize the buffer on a large token input. Currently, for
1006 # uninitialized string buffers in LLVM we can generate very long tokens, so
1007 # this is a hack around it.
1008 # FIXME. (f.e. char Buffer[10000] )
1010 $(Echo) Flexing $*.l
1011 $(Verb) $(FLEX) -t $< | \
1012 $(SED) 's/void yyunput/inline void yyunput/' | \
1013 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1014 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1018 -$(Verb) $(RM) -f $(LexOutput)
1019 $(Verb) $(RM) -f $(LexOutput)
1023 #---------------------------------------------------------
1024 # Provide rules for generating a .cpp and .h source files
1025 # from yacc (bison) input sources.
1026 #---------------------------------------------------------
1028 YaccFiles := $(filter %.y,$(Sources))
1029 ifneq ($(YaccFiles),)
1030 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1032 .PRECIOUS: $(YaccOutput)
1034 # Cancel built-in rules for yacc
1039 # Rule for building the bison parsers...
1041 $(Echo) "Bisoning $*.y"
1042 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1043 $(Verb) $(MV) -f $*.tab.c $*.cpp
1044 $(Verb) $(MV) -f $*.tab.h $*.h
1047 -$(Verb) $(RM) -f $(YaccOutput)
1048 $(Verb) $(RM) -f $(YaccOutput)
1051 ###############################################################################
1052 # OTHER RULES: Other rules needed
1053 ###############################################################################
1055 # To create postscript files from dot files...
1056 ifneq ($(DOT),false)
1058 $(DOT) -Tps < $< > $@
1061 $(Echo) "Cannot build $@: The program dot is not installed"
1064 # This rules ensures that header files that are removed still have a rule for
1065 # which they can be "generated." This allows make to ignore them and
1066 # reproduce the dependency lists.
1069 # Define clean-local to clean the current directory. Note that this uses a
1070 # very conservative approach ensuring that empty variables do not cause
1071 # errors or disastrous removal.
1073 ifneq ($(strip $(ObjDir)),)
1074 -$(Verb) $(RM) -rf $(ObjDir)
1076 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1077 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1078 -$(Verb) $(RM) -f *$(SHLIBEXT)
1082 -$(Verb) $(RM) -rf Debug Release Profile
1084 # Build tags database for Emacs/Xemacs:
1088 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1089 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1090 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1091 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1092 -name '*.cpp' -o -name '*.h' | \
1093 $(ETAGS) $(ETAGSFLAGS) -
1096 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1097 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1098 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1099 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1100 \( -name '*.cpp' -o -name '*.h' \) -print | \
1101 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1104 ###############################################################################
1105 # DEPENDENCIES: Include the dependency files if we should
1106 ###############################################################################
1107 ifndef DISABLE_AUTO_DEPENDENCIES
1109 # If its not one of the cleaning targets
1110 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1112 # Get the list of dependency files
1113 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1114 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1116 -include /dev/null $(DependFiles)
1122 ###############################################################################
1123 # CHECK: Running the test suite
1124 ###############################################################################
1127 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1128 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1129 $(EchoCmd) Running test suite ; \
1130 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1131 TESTSUITE=$(TESTSUITE) ; \
1133 $(EchoCmd) No Makefile in test directory ; \
1136 $(EchoCmd) No test directory ; \
1139 ###############################################################################
1140 # DISTRIBUTION: Handle construction of a distribution tarball
1141 ###############################################################################
1143 #------------------------------------------------------------------------
1144 # Define distribution related variables
1145 #------------------------------------------------------------------------
1146 DistName := $(LLVM_TARBALL_NAME)
1147 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1148 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1149 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1150 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1151 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1152 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1153 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1154 Makefile.config.in configure autoconf
1155 DistOther := $(notdir $(wildcard \
1156 $(BUILD_SRC_DIR)/*.h \
1157 $(BUILD_SRC_DIR)/*.td \
1158 $(BUILD_SRC_DIR)/*.def \
1159 $(BUILD_SRC_DIR)/*.ll \
1160 $(BUILD_SRC_DIR)/*.in))
1161 DistSubDirs := $(SubDirs)
1162 DistSources = $(Sources) $(EXTRA_DIST)
1163 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1165 #------------------------------------------------------------------------
1166 # We MUST build distribution with OBJ_DIR != SRC_DIR
1167 #------------------------------------------------------------------------
1168 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1169 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1170 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1174 #------------------------------------------------------------------------
1175 # Prevent catastrophic remove
1176 #------------------------------------------------------------------------
1177 ifeq ($(LLVM_TARBALL_NAME),)
1178 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1181 #------------------------------------------------------------------------
1182 # Prevent attempt to run dist targets from anywhere but the top level
1183 #------------------------------------------------------------------------
1186 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1187 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1191 #------------------------------------------------------------------------
1192 # Provide the top level targets
1193 #------------------------------------------------------------------------
1195 dist-gzip:: $(DistTarGZip)
1197 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1198 $(Echo) Packing gzipped distribution tar file.
1199 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1200 $(GZIP) -c > "$(DistTarGZip)"
1202 dist-bzip2:: $(DistTarBZ2)
1204 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1205 $(Echo) Packing bzipped distribution tar file.
1206 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1207 $(BZIP2) -c >$(DistTarBZ2)
1209 dist-zip:: $(DistZip)
1211 $(DistZip) : $(TopDistDir)/.makedistdir
1212 $(Echo) Packing zipped distribution file.
1213 $(Verb) rm -f $(DistZip)
1214 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1216 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1217 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1219 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1221 dist-check:: $(DistTarGZip)
1222 $(Echo) Checking distribution tar file.
1223 $(Verb) if test -d $(DistCheckDir) ; then \
1224 $(RM) -rf $(DistCheckDir) ; \
1226 $(Verb) $(MKDIR) $(DistCheckDir)
1227 $(Verb) cd $(DistCheckDir) && \
1228 $(MKDIR) $(DistCheckDir)/build && \
1229 $(MKDIR) $(DistCheckDir)/install && \
1230 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1232 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1233 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1236 $(MAKE) install && \
1237 $(MAKE) uninstall && \
1240 $(MAKE) dist-clean && \
1241 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1244 $(Echo) Cleaning distribution files
1245 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1250 #------------------------------------------------------------------------
1251 # Provide the recursive distdir target for building the distribution directory
1252 #------------------------------------------------------------------------
1253 distdir: $(DistDir)/.makedistdir
1254 $(DistDir)/.makedistdir: $(DistSources)
1255 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1256 if test -d "$(DistDir)" ; then \
1257 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1260 $(EchoCmd) Removing old $(DistDir) ; \
1261 $(RM) -rf $(DistDir); \
1262 $(EchoCmd) Making 'all' to verify build ; \
1265 $(Echo) Building Distribution Directory $(DistDir)
1266 $(Verb) $(MKDIR) $(DistDir)
1267 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1268 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1269 for file in $(DistFiles) ; do \
1271 $(BUILD_SRC_DIR)/*) \
1272 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1274 $(BUILD_SRC_ROOT)/*) \
1275 file=`echo "$$file" | \
1276 sed "s#^$$srcrootstrip/##"` \
1279 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1280 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1281 from_dir="$(BUILD_SRC_DIR)" ; \
1282 elif test -f "$$file" || test -d "$$file" ; then \
1285 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1286 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1287 to_dir="$(DistDir)/$$dir"; \
1288 $(MKDIR) "$$to_dir" ; \
1290 to_dir="$(DistDir)"; \
1292 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1293 if test -n "$$mid_dir" ; then \
1294 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1296 if test -d "$$from_dir/$$file"; then \
1297 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1298 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1299 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1301 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1302 elif test -f "$$from_dir/$$file" ; then \
1303 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1304 elif test -L "$$from_dir/$$file" ; then \
1305 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1306 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1307 $(EchoCmd) "===== WARNING: Distribution Source " \
1308 "$$from_dir/$$file Not Found!" ; \
1309 elif test "$(Verb)" != '@' ; then \
1310 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1313 $(Verb) for subdir in $(DistSubDirs) ; do \
1314 if test "$$subdir" \!= "." ; then \
1315 new_distdir="$(DistDir)/$$subdir" ; \
1316 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1317 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1321 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1322 $(EchoCmd) Eliminating CVS directories from distribution ; \
1323 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1324 $(MAKE) dist-hook ; \
1325 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1326 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1327 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1328 -o ! -type d ! -perm -444 -exec \
1329 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1330 || chmod -R a+r $(DistDir) ; \
1333 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1339 ###############################################################################
1340 # TOP LEVEL - targets only to apply at the top level directory
1341 ###############################################################################
1345 #------------------------------------------------------------------------
1346 # Install support for the project's include files:
1347 #------------------------------------------------------------------------
1349 $(Echo) Installing include files
1350 $(Verb) $(MKDIR) $(includedir)
1351 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1352 cd $(BUILD_SRC_ROOT)/include && \
1353 find . -path '*/Internal' -prune -o '(' -type f \
1354 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1355 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1359 $(Echo) Uninstalling include files
1360 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1361 cd $(BUILD_SRC_ROOT)/include && \
1362 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1363 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1364 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1369 #------------------------------------------------------------------------
1370 # Print out the directories used for building
1371 #------------------------------------------------------------------------
1373 $(Echo) "BuildMode : " '$(BuildMode)'
1374 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1375 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1376 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1377 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1378 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1379 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1380 $(Echo) "libdir : " '$(libdir)'
1381 $(Echo) "bindir : " '$(bindir)'
1382 $(Echo) "sysconfdir : " '$(sysconfdir)'
1383 $(Echo) "UserTargets : " '$(UserTargets)'
1384 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1385 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1386 $(Echo) "ObjDir : " '$(ObjDir)'
1387 $(Echo) "LibDir : " '$(LibDir)'
1388 $(Echo) "ToolDir : " '$(ToolDir)'
1389 $(Echo) "ExmplDir : " '$(ExmplDir)'
1390 $(Echo) "Sources : " '$(Sources)'
1391 $(Echo) "TDFiles : " '$(TDFiles)'
1392 $(Echo) "INCFiles : " '$(INCFiles)'
1393 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1394 $(Echo) "Compile.C : " '$(Compile.C)'
1395 $(Echo) "Archive : " '$(Archive)'
1396 $(Echo) "YaccFiles : " '$(YaccFiles)'
1397 $(Echo) "LexFiles : " '$(LexFiles)'
1398 $(Echo) "Module : " '$(Module)'