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 ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT))
86 $(Echo) Wiping out $(BUILD_OBJ_ROOT) and rebuilding configuration.
87 $(Verb) if test -x config.status ; then \
88 $(MV) config.status .. ; \
91 $(MV) ../config.status . ; \
95 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
99 $(BUILT_SOURCES) : $(ObjMakefiles)
101 #------------------------------------------------------------------------
102 # Make sure we're not using a stale configuration
103 #------------------------------------------------------------------------
104 .PRECIOUS: $(ConfigStatusScript)
105 $(ConfigStatusScript): $(ConfigureScript)
106 $(Echo) Reconfiguring with $<
107 $(Verb) cd $(BUILD_OBJ_ROOT) && \
108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript)
111 #------------------------------------------------------------------------
112 # Make sure the configuration makefile is up to date
113 #------------------------------------------------------------------------
114 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
115 $(Echo) Regenerating $@
116 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
118 #------------------------------------------------------------------------
119 # If the Makefile in the source tree has been updated, copy it over into the
120 # build tree. But, only do this if the source and object makefiles differ
121 #------------------------------------------------------------------------
122 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
124 Makefile: $(BUILD_SRC_DIR)/Makefile
125 $(Echo) "Updating Makefile"
126 $(Verb) $(MKDIR) $(@D)
129 # Copy the Makefile.* files unless we're in the root directory which avoids
130 # the copying of Makefile.config.in or other things that should be explicitly
132 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
134 *Makefile.rules) ;; \
136 *) $(Echo) "Updating $(@F)" ; \
143 #------------------------------------------------------------------------
144 # Set up the basic dependencies
145 #------------------------------------------------------------------------
146 $(UserTargets):: $(PreConditions)
150 clean-all:: clean-local clean-all-local
151 install:: install-local
152 uninstall:: uninstall-local
153 install-local:: all-local
154 install-bytecode:: install-bytecode-local
156 ###############################################################################
157 # VARIABLES: Set up various variables based on configuration data
158 ###############################################################################
160 #--------------------------------------------------------------------
161 # Variables derived from configuration we are building
162 #--------------------------------------------------------------------
164 ifdef ENABLE_PROFILING
166 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
167 C.Flags := -O3 -DNDEBUG -pg
168 LD.Flags := -O3 -DNDEBUG -pg
170 ifdef ENABLE_OPTIMIZED
172 CXX.Flags := -O3 -DNDEBUG -finline-functions \
173 -felide-constructors -fomit-frame-pointer
174 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
175 LD.Flags := -O3 -DNDEBUG
178 CXX.Flags := -g -D_DEBUG
179 C.Flags := -g -D_DEBUG
180 LD.Flags := -g -D_DEBUG
185 CXX.Flags += $(CXXFLAGS)
187 CPP.Flags += $(CPPFLAGS)
188 LD.Flags += $(LDFLAGS)
190 LibTool.Flags := --tag=CXX
192 #--------------------------------------------------------------------
193 # Directory locations
194 #--------------------------------------------------------------------
195 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
196 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
197 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
198 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
199 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
200 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
201 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
203 #--------------------------------------------------------------------
204 # Full Paths To Compiled Tools and Utilities
205 #--------------------------------------------------------------------
206 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
209 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
212 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
215 BURG := $(LLVMToolDir)/burg$(EXEEXT)
218 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
221 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
224 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
227 LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
230 LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
233 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
236 LLI := $(LLVMToolDir)/lli$(EXEEXT)
239 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
242 #--------------------------------------------------------------------
243 # Adjust to user's request
244 #--------------------------------------------------------------------
246 # Adjust LIBTOOL flags for shared libraries, or not.
247 ifndef SHARED_LIBRARY
248 LibTool.Flags += --tag=disable-shared
250 LD.Flags += -rpath $(LibDir)
260 # Adjust settings for verbose mode
263 LibTool.Flags += --silent
264 AR.Flags += >/dev/null 2>/dev/null
265 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
267 ConfigureScriptFLAGS :=
270 # By default, strip symbol information from executable
272 Strip := $(PLATFORMSTRIPOPTS)
273 StripWarnMsg := "(without symbols)"
276 # Adjust linker flags for building an executable
279 LD.Flags += -rpath $(ExmplDir) -export-dynamic
281 LD.Flags += -rpath $(ToolDir) -export-dynamic
285 #----------------------------------------------------------
286 # Options To Invoke Tools
287 #----------------------------------------------------------
289 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
291 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
292 CPP.Flags += -I$(BUILD_OBJ_DIR) \
294 -I$(BUILD_SRC_ROOT)/include \
295 -I$(BUILD_OBJ_ROOT)/include \
296 -I$(LLVM_OBJ_ROOT)/include \
297 -I$(LLVM_SRC_ROOT)/include \
298 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
300 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
301 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
302 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
303 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
304 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
305 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
306 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
307 $(CompileCommonOpts) $(LD.Flags) $(Strip)
308 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
310 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
311 Burg = $(BURG) -I $(BUILD_SRC_DIR)
312 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
313 Archive = $(AR) $(AR.Flags)
314 LArchive = $(LLVMToolDir)/llvm-ar rcsf
321 #----------------------------------------------------------
322 # Get the list of source files and compute object file
324 #----------------------------------------------------------
327 FakeSources := $(FAKE_SOURCES)
329 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
331 BaseNameSources := $(sort $(basename $(FakeSources)))
332 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
333 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
334 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
337 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
338 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
339 $(BUILD_SRC_DIR)/*.l))
341 Sources := $(SOURCES)
345 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
348 BaseNameSources := $(sort $(basename $(Sources)))
349 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
350 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
351 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
354 ###############################################################################
355 # DIRECTORIES: Handle recursive descent of directory structure
356 ###############################################################################
358 #---------------------------------------------------------
359 # Provide rules to make install dirs. This must be early
360 # in the file so they get built before dependencies
361 #---------------------------------------------------------
364 $(Verb) $(MKDIR) $(bindir)
367 $(Verb) $(MKDIR) $(libdir)
370 $(Verb) $(MKDIR) $(includedir)
373 $(Verb) $(MKDIR) $(sysconfdir)
375 # To create other directories, as needed, and timestamp their creation
377 $(Verb) $(MKDIR) $* > /dev/null
380 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
381 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
383 #---------------------------------------------------------
384 # Handle the DIRS options for sequential construction
385 #---------------------------------------------------------
390 $(RecursiveTargets)::
391 $(Verb) for dir in $(DIRS); do \
392 if [ ! -f $$dir/Makefile ]; then \
394 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
396 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
397 ($(MAKE) -C $$dir $@ ) || exit 1; \
402 #---------------------------------------------------------
403 # Handle the EXPERIMENTAL_DIRS options ensuring success
404 # after each directory is built.
405 #---------------------------------------------------------
406 ifdef EXPERIMENTAL_DIRS
407 $(RecursiveTargets)::
408 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
409 if [ ! -f $$dir/Makefile ]; then \
411 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
413 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
414 ($(MAKE) -C $$dir $@ ) || exit 0; \
419 #---------------------------------------------------------
420 # Handle the PARALLEL_DIRS options for parallel construction
421 #---------------------------------------------------------
424 SubDirs += $(PARALLEL_DIRS)
426 # Unfortunately, this list must be maintained if new recursive targets are added
427 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
428 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
429 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
430 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
431 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
432 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
434 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
437 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
439 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
441 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
442 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
446 #---------------------------------------------------------
447 # Handle the OPTIONAL_DIRS options for directores that may
449 #---------------------------------------------------------
452 SubDirs += $(OPTIONAL_DIRS)
454 $(RecursiveTargets)::
455 $(Verb) for dir in $(OPTIONAL_DIRS); do \
456 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
457 if [ ! -f $$dir/Makefile ]; then \
459 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
461 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
462 ($(MAKE) -C$$dir $@ ) || exit 1; \
468 #---------------------------------------------------------
469 # Handle the CONFIG_FILES options
470 #---------------------------------------------------------
473 install-local:: $(sysconfdir) $(CONFIG_FILES)
474 $(Echo) Installing Configuration Files To $(sysconfdir)
475 $(Verb)for file in $(CONFIG_FILES); do \
476 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
477 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
478 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
479 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
481 $(ECHO) Error: cannot find config file $${file}. ; \
486 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
487 $(Verb)for file in $(CONFIG_FILES); do \
488 $(RM) -f $(sysconfdir)/$${file} ; \
493 ###############################################################################
494 # Library Build Rules: Four ways to build a library
495 ###############################################################################
497 #---------------------------------------------------------
498 # Bytecode Module Targets:
499 # If the user set MODULE_NAME then they want to build a
500 # bytecode module from the sources. We compile all the
501 # sources and link it together into a single bytecode
503 #---------------------------------------------------------
507 Module := $(LibDir)/$(MODULE_NAME).bc
508 LinkModule := $(LLVMGCC) -shared -nostdlib
510 ifdef EXPORTED_SYMBOL_FILE
511 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
514 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
515 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
516 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
518 all-local:: $(Module)
521 ifneq ($(strip $(Module)),)
522 -$(Verb) $(RM) -f $(Module)
525 ifdef BYTECODE_DESTINATION
526 ModuleDestDir := $(BYTECODE_DESTINATION)
528 ModuleDestDir := $(libdir)
531 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
533 install-module:: $(DestModule)
534 install-local:: $(DestModule)
536 $(DestModule): $(ModuleDestDir) $(Module)
537 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
538 $(Verb) $(INSTALL) $(Module) $@
541 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
542 -$(Verb) $(RM) -f $(DestModule)
546 # if we're building a library ...
549 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
550 LIBRARYNAME := $(strip $(LIBRARYNAME))
551 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
552 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
553 LibName.O := $(LibDir)/$(LIBRARYNAME).o
554 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
556 #---------------------------------------------------------
557 # Shared Library Targets:
558 # If the user asked for a shared library to be built
559 # with the SHARED_LIBRARY variable, then we provide
560 # targets for building them.
561 #---------------------------------------------------------
564 all-local:: $(LibName.LA)
566 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
567 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
568 $(Verb) $(Link) -o $@ $(ObjectsLO)
569 $(Verb) $(LTInstall) $@ $(LibDir)
572 ifneq ($(strip $(LibName.LA)),)
573 -$(Verb) $(RM) -f $(LibName.LA)
576 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
578 install-local:: $(DestSharedLib)
580 $(DestSharedLib): $(libdir) $(LibName.LA)
581 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
582 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
583 $(Verb) $(LIBTOOL) --finish $(libdir)
586 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
587 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
591 #---------------------------------------------------------
592 # Bytecode Library Targets:
593 # If the user asked for a bytecode library to be built
594 # with the BYTECODE_LIBRARY variable, then we provide
595 # targets for building them.
596 #---------------------------------------------------------
597 ifdef BYTECODE_LIBRARY
599 # make the C and C++ compilers strip debug info out of bytecode libraries.
600 BCCompile.C += -Wa,-strip-debug
601 BCCompile.CXX += -Wa,-strip-debug
603 all-local:: $(LibName.BCA)
605 ifdef EXPORTED_SYMBOL_FILE
606 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
607 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
609 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
610 $(LLVMToolDir)/llvm-ar
611 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
613 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
615 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
617 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
618 $(LLVMToolDir)/llvm-ar
619 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
621 $(Verb) $(LArchive) $@ $(ObjectsBC)
626 ifneq ($(strip $(LibName.BCA)),)
627 -$(Verb) $(RM) -f $(LibName.BCA)
630 ifdef BYTECODE_DESTINATION
631 BytecodeDestDir := $(BYTECODE_DESTINATION)
633 BytecodeDestDir := $(libdir)
636 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
638 install-bytecode-local:: $(DestBytecodeLib)
640 install-local:: $(DestBytecodeLib)
642 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
643 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
644 $(Verb) $(INSTALL) $(LibName.BCA) $@
647 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
648 -$(Verb) $(RM) -f $(DestBytecodeLib)
652 #---------------------------------------------------------
653 # ReLinked Library Targets:
654 # If the user didn't explicitly forbid building a
655 # relinked then we provide targets for building them.
656 #---------------------------------------------------------
657 ifndef DONT_BUILD_RELINKED
659 all-local:: $(LibName.O)
661 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
662 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
663 $(Verb) $(Relink) -o $@ $(ObjectsO)
666 ifneq ($(strip $(LibName.O)),)
667 -$(Verb) $(RM) -f $(LibName.O)
670 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
672 install-local:: $(DestRelinkedLib)
674 $(DestRelinkedLib): $(libdir) $(LibName.O)
675 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
676 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
679 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
680 -$(Verb) $(RM) -f $(DestRelinkedLib)
684 #---------------------------------------------------------
685 # Archive Library Targets:
686 # If the user wanted a regular archive library built,
687 # then we provide targets for building them.
688 #---------------------------------------------------------
691 all-local:: $(LibName.A)
693 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
694 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
696 $(Verb) $(Archive) $@ $(ObjectsO)
700 ifneq ($(strip $(LibName.A)),)
701 -$(Verb) $(RM) -f $(LibName.A)
704 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
706 install-local:: $(DestArchiveLib)
708 $(DestArchiveLib): $(libdir) $(LibName.A)
709 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
710 $(Verb) $(MKDIR) $(libdir)
711 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
714 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
715 -$(Verb) $(RM) -f $(DestArchiveLib)
722 ###############################################################################
723 # Tool Build Rules: Build executable tool based on TOOLNAME option
724 ###############################################################################
728 #---------------------------------------------------------
729 # Handle the special "JIT" value for LLVM_LIBS which is a
730 # shorthand for a bunch of libraries that get the correct
731 # JIT support for a tool that runs JIT.
732 #---------------------------------------------------------
733 ifeq ($(LLVMLIBS),JIT)
735 # Make sure we can get our own symbols in the tool
738 # Generic JIT libraries
739 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
741 # You can enable the X86 JIT on a non-X86 host by setting the flag
742 # ENABLE_X86_JIT on the make command line. If not, it will still be
743 # enabled automagically on an X86 host.
748 # What the X86 JIT requires
750 JIT_LIBS += LLVMX86 LLVMSelectionDAG
753 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
754 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
755 # enabled automagically on an SparcV9 host.
756 ifeq ($(ARCH), Sparc)
757 ENABLE_SPARCV9_JIT = 1
760 # What the Sparc JIT requires
761 ifdef ENABLE_SPARCV9_JIT
762 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
763 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
764 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
765 LLVMDataStructure.a LLVMSparcV9RegAlloc
768 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
769 # ENABLE_PPC_JIT on the make command line. If not, it will still be
770 # enabled automagically on an PowerPC host.
771 ifeq ($(ARCH), PowerPC)
775 # What the PowerPC JIT requires
777 JIT_LIBS += LLVMPowerPC
780 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
781 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
782 LLVMSystem.a $(PLATFORMLIBDL)
785 #---------------------------------------------------------
786 # Set up variables for building a tool.
787 #---------------------------------------------------------
789 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
791 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
793 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
794 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
795 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
796 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
797 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
798 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
799 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
800 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
802 #---------------------------------------------------------
803 # Tell make that we need to rebuild subdirectories before
804 # we can link the tool. This affects things like LLI which
805 # has library subdirectories.
806 #---------------------------------------------------------
807 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
809 #---------------------------------------------------------
810 # Provide targets for building the tools
811 #---------------------------------------------------------
812 all-local:: $(ToolBuildPath)
815 ifneq ($(strip $(ToolBuildPath)),)
816 -$(Verb) $(RM) -f $(ToolBuildPath)
820 $(ToolBuildPath): $(ExmplDir)/.dir
822 $(ToolBuildPath): $(ToolDir)/.dir
825 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
826 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
827 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
828 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
829 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
831 DestTool = $(bindir)/$(TOOLNAME)
833 install-local:: $(DestTool)
835 $(DestTool): $(bindir) $(ToolBuildPath)
836 $(Echo) Installing $(BuildMode) $(DestTool)
837 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
840 $(Echo) Uninstalling $(BuildMode) $(DestTool)
841 -$(Verb) $(RM) -f $(DestTool)
845 ###############################################################################
846 # Object Build Rules: Build object files based on sources
847 ###############################################################################
849 # Provide rule sets for when dependency generation is enabled
850 ifndef DISABLE_AUTO_DEPENDENCIES
852 #---------------------------------------------------------
853 # Create .lo files in the ObjDir directory from the .cpp and .c files...
854 #---------------------------------------------------------
857 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
858 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
859 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
860 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
861 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
863 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
864 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
865 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
866 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
867 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
869 #---------------------------------------------------------
870 # Create .o files in the ObjDir directory from the .cpp and .c files...
871 #---------------------------------------------------------
874 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
875 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
876 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
877 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
878 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
880 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
881 $(Echo) "Compiling $*.c for $(BuildMode) build"
882 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
883 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
884 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
888 #---------------------------------------------------------
889 # Create .bc files in the ObjDir directory from .cpp and .c files...
890 #---------------------------------------------------------
891 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
892 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
893 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
894 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
895 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
897 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
898 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
899 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
900 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
901 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
903 # Provide alternate rule sets if dependencies are disabled
908 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
909 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
910 $(LTCompile.CXX) $< -o $@
912 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
913 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
914 $(LTCompile.C) $< -o $@
918 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
919 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
920 $(Compile.CXX) $< -o $@
922 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
923 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
924 $(Compile.C) $< -o $@
927 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
928 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
929 $(BCCompile.CXX) $< -o $@
931 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
932 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
933 $(BCCompile.C) $< -o $@
937 #---------------------------------------------------------
938 # Provide rule to build .bc files from .ll sources,
939 # regardless of dependencies
940 #---------------------------------------------------------
941 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
942 $(Echo) "Compiling $*.ll for $(BuildMode) build"
943 $(Verb) $(LLVMAS) $< -f -o $@
945 ###############################################################################
946 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
947 ###############################################################################
951 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
952 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
953 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
954 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
956 # All of these files depend on tblgen and the .td files.
957 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
960 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
961 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
962 $(Echo) "Building $(<F) register names with tblgen"
963 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
965 $(TARGET:%=%GenRegisterNames.inc): \
966 %GenRegisterNames.inc : $(ObjDir)/%GenRegisterNames.inc.tmp
967 $(Verb) cmp -s $@ $< || cp $< $@
970 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
971 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
972 $(Echo) "Building $(<F) register information header with tblgen"
973 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
975 $(TARGET:%=%GenRegisterInfo.h.inc): \
976 %GenRegisterInfo.h.inc : $(ObjDir)/%GenRegisterInfo.h.inc.tmp
977 $(Verb) cmp -s $@ $< || cp $< $@
980 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
981 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
982 $(Echo) "Building $(<F) register info implementation with tblgen"
983 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
985 $(TARGET:%=%GenRegisterInfo.inc): \
986 %GenRegisterInfo.inc : $(ObjDir)/%GenRegisterInfo.inc.tmp
987 $(Verb) cmp -s $@ $< || cp $< $@
990 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
991 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
992 $(Echo) "Building $(<F) instruction names with tblgen"
993 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
995 $(TARGET:%=%GenInstrNames.inc): \
996 %GenInstrNames.inc : $(ObjDir)/%GenInstrNames.inc.tmp
997 $(Verb) cmp -s $@ $< || cp $< $@
1000 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1001 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1002 $(Echo) "Building $(<F) instruction information with tblgen"
1003 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1005 $(TARGET:%=%GenInstrInfo.inc): \
1006 %GenInstrInfo.inc : $(ObjDir)/%GenInstrInfo.inc.tmp
1007 $(Verb) cmp -s $@ $< || cp $< $@
1010 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1011 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1012 $(Echo) "Building $(<F) assembly writer with tblgen"
1013 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1015 $(TARGET:%=%GenAsmWriter.inc): \
1016 %GenAsmWriter.inc : $(ObjDir)/%GenAsmWriter.inc.tmp
1017 $(Verb) cmp -s $@ $< || cp $< $@
1019 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1020 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1021 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1022 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1024 $(TARGET:%=%GenAsmWriter1.inc): \
1025 %GenAsmWriter1.inc : $(ObjDir)/%GenAsmWriter1.inc.tmp
1026 $(Verb) cmp -s $@ $< || cp $< $@
1029 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1030 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1031 $(Echo) "Building $(<F) code emitter with tblgen"
1032 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1034 $(TARGET:%=%GenCodeEmitter.inc): \
1035 %GenCodeEmitter.inc : $(ObjDir)/%GenCodeEmitter.inc.tmp
1036 $(Verb) cmp -s $@ $< || cp $< $@
1039 -$(Verb) $(RM) -f $(INCFiles)
1043 ###############################################################################
1044 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1045 ###############################################################################
1047 #---------------------------------------------------------
1048 # Provide rules for generating a .cpp source file from
1049 # (f)lex input sources.
1050 #---------------------------------------------------------
1052 LexFiles := $(filter %.l,$(Sources))
1054 ifneq ($(LexFiles),)
1056 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1058 .PRECIOUS: $(LexOutput)
1060 # Note the extra sed filtering here, used to cut down on the warnings emited
1061 # by GCC. The last line is a gross hack to work around flex aparently not
1062 # being able to resize the buffer on a large token input. Currently, for
1063 # uninitialized string buffers in LLVM we can generate very long tokens, so
1064 # this is a hack around it.
1065 # FIXME. (f.e. char Buffer[10000] )
1067 $(Echo) Flexing $*.l
1068 $(Verb) $(FLEX) -t $< | \
1069 $(SED) 's/void yyunput/inline void yyunput/' | \
1070 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1071 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1075 -$(Verb) $(RM) -f $(LexOutput)
1076 $(Verb) $(RM) -f $(LexOutput)
1080 #---------------------------------------------------------
1081 # Provide rules for generating a .cpp and .h source files
1082 # from yacc (bison) input sources.
1083 #---------------------------------------------------------
1085 YaccFiles := $(filter %.y,$(Sources))
1086 ifneq ($(YaccFiles),)
1087 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1089 .PRECIOUS: $(YaccOutput)
1091 # Cancel built-in rules for yacc
1096 # Rule for building the bison parsers...
1098 $(Echo) "Bisoning $*.y"
1099 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1100 $(Verb) $(MV) -f $*.tab.c $*.cpp
1101 $(Verb) $(MV) -f $*.tab.h $*.h
1104 -$(Verb) $(RM) -f $(YaccOutput)
1105 $(Verb) $(RM) -f $(YaccOutput)
1108 ###############################################################################
1109 # OTHER RULES: Other rules needed
1110 ###############################################################################
1112 # To create postscript files from dot files...
1113 ifneq ($(DOT),false)
1115 $(DOT) -Tps < $< > $@
1118 $(Echo) "Cannot build $@: The program dot is not installed"
1121 # This rules ensures that header files that are removed still have a rule for
1122 # which they can be "generated." This allows make to ignore them and
1123 # reproduce the dependency lists.
1126 # Define clean-local to clean the current directory. Note that this uses a
1127 # very conservative approach ensuring that empty variables do not cause
1128 # errors or disastrous removal.
1130 ifneq ($(strip $(ObjDir)),)
1131 -$(Verb) $(RM) -rf $(ObjDir)
1133 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1134 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1135 -$(Verb) $(RM) -f *$(SHLIBEXT)
1139 -$(Verb) $(RM) -rf Debug Release Profile
1141 # Build tags database for Emacs/Xemacs:
1145 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1146 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1147 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1148 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1149 -name '*.cpp' -o -name '*.h' | \
1150 $(ETAGS) $(ETAGSFLAGS) -
1153 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1154 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1155 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1156 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1157 \( -name '*.cpp' -o -name '*.h' \) -print | \
1158 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1161 ###############################################################################
1162 # DEPENDENCIES: Include the dependency files if we should
1163 ###############################################################################
1164 ifndef DISABLE_AUTO_DEPENDENCIES
1166 # If its not one of the cleaning targets
1167 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1169 # Get the list of dependency files
1170 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1171 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1173 -include /dev/null $(DependFiles)
1179 ###############################################################################
1180 # CHECK: Running the test suite
1181 ###############################################################################
1184 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1185 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1186 $(EchoCmd) Running test suite ; \
1187 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1188 TESTSUITE=$(TESTSUITE) ; \
1190 $(EchoCmd) No Makefile in test directory ; \
1193 $(EchoCmd) No test directory ; \
1196 ###############################################################################
1197 # DISTRIBUTION: Handle construction of a distribution tarball
1198 ###############################################################################
1200 #------------------------------------------------------------------------
1201 # Define distribution related variables
1202 #------------------------------------------------------------------------
1203 DistName := $(LLVM_TARBALL_NAME)
1204 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1205 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1206 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1207 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1208 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1209 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1210 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1211 Makefile.config.in configure autoconf
1212 DistOther := $(notdir $(wildcard \
1213 $(BUILD_SRC_DIR)/*.h \
1214 $(BUILD_SRC_DIR)/*.td \
1215 $(BUILD_SRC_DIR)/*.def \
1216 $(BUILD_SRC_DIR)/*.ll \
1217 $(BUILD_SRC_DIR)/*.in))
1218 DistSubDirs := $(SubDirs)
1219 DistSources = $(Sources) $(EXTRA_DIST)
1220 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1222 #------------------------------------------------------------------------
1223 # We MUST build distribution with OBJ_DIR != SRC_DIR
1224 #------------------------------------------------------------------------
1225 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1226 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1227 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1231 #------------------------------------------------------------------------
1232 # Prevent catastrophic remove
1233 #------------------------------------------------------------------------
1234 ifeq ($(LLVM_TARBALL_NAME),)
1235 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1238 #------------------------------------------------------------------------
1239 # Prevent attempt to run dist targets from anywhere but the top level
1240 #------------------------------------------------------------------------
1243 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1244 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1248 #------------------------------------------------------------------------
1249 # Provide the top level targets
1250 #------------------------------------------------------------------------
1252 dist-gzip:: $(DistTarGZip)
1254 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1255 $(Echo) Packing gzipped distribution tar file.
1256 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1257 $(GZIP) -c > "$(DistTarGZip)"
1259 dist-bzip2:: $(DistTarBZ2)
1261 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1262 $(Echo) Packing bzipped distribution tar file.
1263 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1264 $(BZIP2) -c >$(DistTarBZ2)
1266 dist-zip:: $(DistZip)
1268 $(DistZip) : $(TopDistDir)/.makedistdir
1269 $(Echo) Packing zipped distribution file.
1270 $(Verb) rm -f $(DistZip)
1271 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1273 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1274 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1276 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1278 dist-check:: $(DistTarGZip)
1279 $(Echo) Checking distribution tar file.
1280 $(Verb) if test -d $(DistCheckDir) ; then \
1281 $(RM) -rf $(DistCheckDir) ; \
1283 $(Verb) $(MKDIR) $(DistCheckDir)
1284 $(Verb) cd $(DistCheckDir) && \
1285 $(MKDIR) $(DistCheckDir)/build && \
1286 $(MKDIR) $(DistCheckDir)/install && \
1287 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1289 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1290 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1293 $(MAKE) install && \
1294 $(MAKE) uninstall && \
1297 $(MAKE) dist-clean && \
1298 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1301 $(Echo) Cleaning distribution files
1302 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1307 #------------------------------------------------------------------------
1308 # Provide the recursive distdir target for building the distribution directory
1309 #------------------------------------------------------------------------
1310 distdir: $(DistDir)/.makedistdir
1311 $(DistDir)/.makedistdir: $(DistSources)
1312 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1313 if test -d "$(DistDir)" ; then \
1314 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1317 $(EchoCmd) Removing old $(DistDir) ; \
1318 $(RM) -rf $(DistDir); \
1319 $(EchoCmd) Making 'all' to verify build ; \
1322 $(Echo) Building Distribution Directory $(DistDir)
1323 $(Verb) $(MKDIR) $(DistDir)
1324 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1325 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1326 for file in $(DistFiles) ; do \
1328 $(BUILD_SRC_DIR)/*) \
1329 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1331 $(BUILD_SRC_ROOT)/*) \
1332 file=`echo "$$file" | \
1333 sed "s#^$$srcrootstrip/##"` \
1336 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1337 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1338 from_dir="$(BUILD_SRC_DIR)" ; \
1339 elif test -f "$$file" || test -d "$$file" ; then \
1342 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1343 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1344 to_dir="$(DistDir)/$$dir"; \
1345 $(MKDIR) "$$to_dir" ; \
1347 to_dir="$(DistDir)"; \
1349 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1350 if test -n "$$mid_dir" ; then \
1351 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1353 if test -d "$$from_dir/$$file"; then \
1354 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1355 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1356 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1358 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1359 elif test -f "$$from_dir/$$file" ; then \
1360 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1361 elif test -L "$$from_dir/$$file" ; then \
1362 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1363 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1364 $(EchoCmd) "===== WARNING: Distribution Source " \
1365 "$$from_dir/$$file Not Found!" ; \
1366 elif test "$(Verb)" != '@' ; then \
1367 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1370 $(Verb) for subdir in $(DistSubDirs) ; do \
1371 if test "$$subdir" \!= "." ; then \
1372 new_distdir="$(DistDir)/$$subdir" ; \
1373 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1374 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1378 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1379 $(EchoCmd) Eliminating CVS directories from distribution ; \
1380 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1381 $(MAKE) dist-hook ; \
1382 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1383 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1384 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1385 -o ! -type d ! -perm -444 -exec \
1386 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1387 || chmod -R a+r $(DistDir) ; \
1390 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1396 ###############################################################################
1397 # TOP LEVEL - targets only to apply at the top level directory
1398 ###############################################################################
1402 #------------------------------------------------------------------------
1403 # Install support for the project's include files:
1404 #------------------------------------------------------------------------
1406 $(Echo) Installing include files
1407 $(Verb) $(MKDIR) $(includedir)
1408 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1409 cd $(BUILD_SRC_ROOT)/include && \
1410 find . -path '*/Internal' -prune -o '(' -type f \
1411 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1412 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1416 $(Echo) Uninstalling include files
1417 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1418 cd $(BUILD_SRC_ROOT)/include && \
1419 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1420 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1421 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1426 #------------------------------------------------------------------------
1427 # Print out the directories used for building
1428 #------------------------------------------------------------------------
1430 $(Echo) "BuildMode : " '$(BuildMode)'
1431 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1432 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1433 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1434 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1435 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1436 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1437 $(Echo) "libdir : " '$(libdir)'
1438 $(Echo) "bindir : " '$(bindir)'
1439 $(Echo) "sysconfdir : " '$(sysconfdir)'
1440 $(Echo) "UserTargets : " '$(UserTargets)'
1441 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1442 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1443 $(Echo) "ObjDir : " '$(ObjDir)'
1444 $(Echo) "LibDir : " '$(LibDir)'
1445 $(Echo) "ToolDir : " '$(ToolDir)'
1446 $(Echo) "ExmplDir : " '$(ExmplDir)'
1447 $(Echo) "Sources : " '$(Sources)'
1448 $(Echo) "TDFiles : " '$(TDFiles)'
1449 $(Echo) "INCFiles : " '$(INCFiles)'
1450 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1451 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1452 $(Echo) "Compile.C : " '$(Compile.C)'
1453 $(Echo) "Archive : " '$(Archive)'
1454 $(Echo) "YaccFiles : " '$(YaccFiles)'
1455 $(Echo) "LexFiles : " '$(LexFiles)'
1456 $(Echo) "Module : " '$(Module)'