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 := $(BUILD_SRC_ROOT)/configure
67 ConfigStatusScript := $(BUILD_OBJ_ROOT)/config.status
68 LConfigStatusScript:= $(LLVM_OBJ_ROOT)/config.status
69 MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
70 MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
71 PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
73 preconditions : $(PreConditions)
75 #------------------------------------------------------------------------
76 # Make sure the BUILT_SOURCES are built first
77 #------------------------------------------------------------------------
78 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
81 ifneq ($(strip $(BUILT_SOURCES)),)
82 -$(Verb) $(RM) -f $(BUILT_SOURCES)
85 ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT))
87 $(Verb) if test -x config.status ; then \
88 $(EchoCmd) Wiping out $(BUILD_OBJ_ROOT) ; \
89 $(MKDIR) .spotless.save ; \
90 $(MV) config.status .spotless.save ; \
91 $(MV) mklib .spotless.save ; \
92 $(MV) projects .spotless.save ; \
94 $(MV) .spotless.save/config.status . ; \
95 $(MV) .spotless.save/mklib . ; \
96 $(MV) .spotless.save/projects . ; \
97 $(RM) -rf .spotless.save ; \
98 $(EchoCmd) Rebuilding configuration of $(BUILD_OBJ_ROOT) ; \
99 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
100 $(ConfigStatusScript) ; \
102 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
106 $(BUILT_SOURCES) : $(ObjMakefiles)
108 #------------------------------------------------------------------------
109 # Make sure we're not using a stale configuration
110 #------------------------------------------------------------------------
112 $(Echo) Reconfiguring $(BUILD_OBJ_ROOT)
113 $(Verb) cd $(BUILD_OBJ_ROOT) && \
114 if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \
115 $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \
117 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
118 $(ConfigStatusScript)
120 .PRECIOUS: $(ConfigStatusScript)
121 $(ConfigStatusScript): $(ConfigureScript)
122 $(Echo) Reconfiguring with $<
123 $(Verb) cd $(BUILD_OBJ_ROOT) && \
124 if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \
125 $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \
127 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
128 $(ConfigStatusScript)
130 #------------------------------------------------------------------------
131 # Make sure the configuration makefile is up to date
132 #------------------------------------------------------------------------
133 $(MakefileConfig): $(MakefileConfigIn) $(LConfigStatusScript)
134 $(Echo) Regenerating $@
135 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(LConfigStatusScript) Makefile.config
137 #------------------------------------------------------------------------
138 # If the Makefile in the source tree has been updated, copy it over into the
139 # build tree. But, only do this if the source and object makefiles differ
140 #------------------------------------------------------------------------
141 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
143 Makefile: $(BUILD_SRC_DIR)/Makefile
144 $(Echo) "Updating Makefile"
145 $(Verb) $(MKDIR) $(@D)
146 $(Verb) $(CP) -f $< $@
148 # Copy the Makefile.* files unless we're in the root directory which avoids
149 # the copying of Makefile.config.in or other things that should be explicitly
151 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
153 *Makefile.rules) ;; \
155 *) $(Echo) "Updating $(@F)" ; \
162 #------------------------------------------------------------------------
163 # Set up the basic dependencies
164 #------------------------------------------------------------------------
165 $(UserTargets):: $(PreConditions)
169 clean-all:: clean-local clean-all-local
170 install:: install-local
171 uninstall:: uninstall-local
172 install-local:: all-local
173 install-bytecode:: install-bytecode-local
175 ###############################################################################
176 # VARIABLES: Set up various variables based on configuration data
177 ###############################################################################
179 #--------------------------------------------------------------------
180 # Variables derived from configuration we are building
181 #--------------------------------------------------------------------
183 ifdef ENABLE_PROFILING
185 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
186 C.Flags := -O3 -DNDEBUG -pg
187 LD.Flags := -O3 -DNDEBUG -pg
189 ifdef ENABLE_OPTIMIZED
191 CXX.Flags := -O3 -DNDEBUG -finline-functions \
192 -felide-constructors -fomit-frame-pointer
193 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
194 LD.Flags := -O3 -DNDEBUG
197 CXX.Flags := -g -D_DEBUG
198 C.Flags := -g -D_DEBUG
199 LD.Flags := -g -D_DEBUG
204 CXX.Flags += $(CXXFLAGS)
206 CPP.Flags += $(CPPFLAGS)
207 LD.Flags += $(LDFLAGS)
209 LibTool.Flags := --tag=CXX
211 #--------------------------------------------------------------------
212 # Directory locations
213 #--------------------------------------------------------------------
214 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
215 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
216 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
217 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
218 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
219 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
220 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
221 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
223 #--------------------------------------------------------------------
224 # Full Paths To Compiled Tools and Utilities
225 #--------------------------------------------------------------------
226 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
229 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
232 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
235 BURG := $(LLVMToolDir)/burg$(EXEEXT)
238 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
241 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
244 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
247 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
250 LLI := $(LLVMToolDir)/lli$(EXEEXT)
253 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
255 LLVMGCCWITHPATH := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCC)
256 LLVMGXXWITHPATH := PATH=$(LLVMToolDir):$(PATH) $(LLVMGXX)
258 #--------------------------------------------------------------------
259 # Adjust to user's request
260 #--------------------------------------------------------------------
262 # Adjust LIBTOOL flags for shared libraries, or not.
263 ifndef SHARED_LIBRARY
264 LibTool.Flags += --tag=disable-shared
266 LD.Flags += -rpath $(LibDir)
276 # Adjust settings for verbose mode
279 LibTool.Flags += --silent
280 AR.Flags += >/dev/null 2>/dev/null
281 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
283 ConfigureScriptFLAGS :=
286 # By default, strip symbol information from executable
288 Strip := $(PLATFORMSTRIPOPTS)
289 StripWarnMsg := "(without symbols)"
292 # Adjust linker flags for building an executable
295 LD.Flags += -rpath $(ExmplDir) -export-dynamic
297 LD.Flags += -rpath $(ToolDir) -export-dynamic
301 #----------------------------------------------------------
302 # Options To Invoke Tools
303 #----------------------------------------------------------
305 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
307 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
308 CPP.Flags += -I$(BUILD_OBJ_DIR) \
310 -I$(BUILD_SRC_ROOT)/include \
311 -I$(BUILD_OBJ_ROOT)/include \
312 -I$(LLVM_OBJ_ROOT)/include \
313 -I$(LLVM_SRC_ROOT)/include \
314 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
316 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
317 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
318 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
320 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
321 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
322 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
324 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
325 $(CompileCommonOpts) $(LD.Flags) $(Strip)
326 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
328 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
329 Burg = $(BURG) -I $(BUILD_SRC_DIR)
330 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
331 Archive = $(AR) $(AR.Flags)
332 LArchive = $(LLVMToolDir)/llvm-ar rcsf
339 #----------------------------------------------------------
340 # Get the list of source files and compute object file
342 #----------------------------------------------------------
345 FakeSources := $(FAKE_SOURCES)
347 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
349 BaseNameSources := $(sort $(basename $(FakeSources)))
350 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
351 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
352 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
355 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
356 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
357 $(BUILD_SRC_DIR)/*.l))
359 Sources := $(SOURCES)
363 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
366 BaseNameSources := $(sort $(basename $(Sources)))
367 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
368 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
369 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
372 ###############################################################################
373 # DIRECTORIES: Handle recursive descent of directory structure
374 ###############################################################################
376 #---------------------------------------------------------
377 # Provide rules to make install dirs. This must be early
378 # in the file so they get built before dependencies
379 #---------------------------------------------------------
382 $(Verb) $(MKDIR) $(bindir)
385 $(Verb) $(MKDIR) $(libdir)
388 $(Verb) $(MKDIR) $(includedir)
391 $(Verb) $(MKDIR) $(sysconfdir)
393 # To create other directories, as needed, and timestamp their creation
395 $(Verb) $(MKDIR) $* > /dev/null
398 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
399 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
401 #---------------------------------------------------------
402 # Handle the DIRS options for sequential construction
403 #---------------------------------------------------------
408 $(RecursiveTargets)::
409 $(Verb) for dir in $(DIRS); do \
410 if [ ! -f $$dir/Makefile ]; then \
412 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
414 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
415 ($(MAKE) -C $$dir $@ ) || exit 1; \
420 #---------------------------------------------------------
421 # Handle the EXPERIMENTAL_DIRS options ensuring success
422 # after each directory is built.
423 #---------------------------------------------------------
424 ifdef EXPERIMENTAL_DIRS
425 $(RecursiveTargets)::
426 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
427 if [ ! -f $$dir/Makefile ]; then \
429 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
431 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
432 ($(MAKE) -C $$dir $@ ) || exit 0; \
437 #---------------------------------------------------------
438 # Handle the PARALLEL_DIRS options for parallel construction
439 #---------------------------------------------------------
442 SubDirs += $(PARALLEL_DIRS)
444 # Unfortunately, this list must be maintained if new recursive targets are added
445 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
446 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
447 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
448 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
449 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
450 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
452 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
455 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
457 $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
459 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
460 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
464 #---------------------------------------------------------
465 # Handle the OPTIONAL_DIRS options for directores that may
467 #---------------------------------------------------------
470 SubDirs += $(OPTIONAL_DIRS)
472 $(RecursiveTargets)::
473 $(Verb) for dir in $(OPTIONAL_DIRS); do \
474 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
475 if [ ! -f $$dir/Makefile ]; then \
477 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
479 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
480 ($(MAKE) -C$$dir $@ ) || exit 1; \
486 #---------------------------------------------------------
487 # Handle the CONFIG_FILES options
488 #---------------------------------------------------------
491 install-local:: $(sysconfdir) $(CONFIG_FILES)
492 $(Echo) Installing Configuration Files To $(sysconfdir)
493 $(Verb)for file in $(CONFIG_FILES); do \
494 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
495 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
496 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
497 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
499 $(ECHO) Error: cannot find config file $${file}. ; \
504 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
505 $(Verb)for file in $(CONFIG_FILES); do \
506 $(RM) -f $(sysconfdir)/$${file} ; \
511 ###############################################################################
512 # Library Build Rules: Four ways to build a library
513 ###############################################################################
515 #---------------------------------------------------------
516 # Bytecode Module Targets:
517 # If the user set MODULE_NAME then they want to build a
518 # bytecode module from the sources. We compile all the
519 # sources and link it together into a single bytecode
521 #---------------------------------------------------------
525 Module := $(LibDir)/$(MODULE_NAME).bc
526 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
528 ifdef EXPORTED_SYMBOL_FILE
529 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
532 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
533 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
534 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
536 all-local:: $(Module)
539 ifneq ($(strip $(Module)),)
540 -$(Verb) $(RM) -f $(Module)
543 ifdef BYTECODE_DESTINATION
544 ModuleDestDir := $(BYTECODE_DESTINATION)
546 ModuleDestDir := $(libdir)
549 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
551 install-module:: $(DestModule)
552 install-local:: $(DestModule)
554 $(DestModule): $(ModuleDestDir) $(Module)
555 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
556 $(Verb) $(INSTALL) $(Module) $@
559 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
560 -$(Verb) $(RM) -f $(DestModule)
564 # if we're building a library ...
567 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
568 LIBRARYNAME := $(strip $(LIBRARYNAME))
569 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
570 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
571 LibName.O := $(LibDir)/$(LIBRARYNAME).o
572 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
574 #---------------------------------------------------------
575 # Shared Library Targets:
576 # If the user asked for a shared library to be built
577 # with the SHARED_LIBRARY variable, then we provide
578 # targets for building them.
579 #---------------------------------------------------------
582 all-local:: $(LibName.LA)
584 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
585 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
586 $(Verb) $(Link) -o $@ $(ObjectsLO)
587 $(Verb) $(LTInstall) $@ $(LibDir)
590 ifneq ($(strip $(LibName.LA)),)
591 -$(Verb) $(RM) -f $(LibName.LA)
594 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
596 install-local:: $(DestSharedLib)
598 $(DestSharedLib): $(libdir) $(LibName.LA)
599 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
600 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
601 $(Verb) $(LIBTOOL) --finish $(libdir)
604 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
605 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
609 #---------------------------------------------------------
610 # Bytecode Library Targets:
611 # If the user asked for a bytecode library to be built
612 # with the BYTECODE_LIBRARY variable, then we provide
613 # targets for building them.
614 #---------------------------------------------------------
615 ifdef BYTECODE_LIBRARY
617 # make the C and C++ compilers strip debug info out of bytecode libraries.
618 BCCompile.C += -Wa,-strip-debug
619 BCCompile.CXX += -Wa,-strip-debug
621 all-local:: $(LibName.BCA)
623 ifdef EXPORTED_SYMBOL_FILE
624 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
625 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
627 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
628 $(LLVMToolDir)/llvm-ar
629 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
631 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
633 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
635 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
636 $(LLVMToolDir)/llvm-ar
637 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
639 $(Verb) $(LArchive) $@ $(ObjectsBC)
644 ifneq ($(strip $(LibName.BCA)),)
645 -$(Verb) $(RM) -f $(LibName.BCA)
648 ifdef BYTECODE_DESTINATION
649 BytecodeDestDir := $(BYTECODE_DESTINATION)
651 BytecodeDestDir := $(libdir)
654 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
656 install-bytecode-local:: $(DestBytecodeLib)
658 install-local:: $(DestBytecodeLib)
660 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
661 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
662 $(Verb) $(INSTALL) $(LibName.BCA) $@
665 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
666 -$(Verb) $(RM) -f $(DestBytecodeLib)
670 #---------------------------------------------------------
671 # ReLinked Library Targets:
672 # If the user didn't explicitly forbid building a
673 # relinked then we provide targets for building them.
674 #---------------------------------------------------------
675 ifndef DONT_BUILD_RELINKED
677 all-local:: $(LibName.O)
679 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
680 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
681 $(Verb) $(Relink) -o $@ $(ObjectsO)
684 ifneq ($(strip $(LibName.O)),)
685 -$(Verb) $(RM) -f $(LibName.O)
688 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
690 install-local:: $(DestRelinkedLib)
692 $(DestRelinkedLib): $(libdir) $(LibName.O)
693 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
694 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
697 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
698 -$(Verb) $(RM) -f $(DestRelinkedLib)
702 #---------------------------------------------------------
703 # Archive Library Targets:
704 # If the user wanted a regular archive library built,
705 # then we provide targets for building them.
706 #---------------------------------------------------------
709 all-local:: $(LibName.A)
711 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
712 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
714 $(Verb) $(Archive) $@ $(ObjectsO)
718 ifneq ($(strip $(LibName.A)),)
719 -$(Verb) $(RM) -f $(LibName.A)
722 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
724 install-local:: $(DestArchiveLib)
726 $(DestArchiveLib): $(libdir) $(LibName.A)
727 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
728 $(Verb) $(MKDIR) $(libdir)
729 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
732 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
733 -$(Verb) $(RM) -f $(DestArchiveLib)
740 ###############################################################################
741 # Tool Build Rules: Build executable tool based on TOOLNAME option
742 ###############################################################################
746 #---------------------------------------------------------
747 # Handle the special "JIT" value for LLVM_LIBS which is a
748 # shorthand for a bunch of libraries that get the correct
749 # JIT support for a tool that runs JIT.
750 #---------------------------------------------------------
751 ifeq ($(LLVMLIBS),JIT)
753 # Make sure we can get our own symbols in the tool
756 # Generic JIT libraries
757 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
759 # You can enable the X86 JIT on a non-X86 host by setting the flag
760 # ENABLE_X86_JIT on the make command line. If not, it will still be
761 # enabled automagically on an X86 host.
766 # What the X86 JIT requires
771 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
772 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
773 # enabled automagically on an SparcV9 host.
774 ifeq ($(ARCH), Sparc)
775 ENABLE_SPARCV9_JIT = 1
778 # What the Sparc JIT requires
779 ifdef ENABLE_SPARCV9_JIT
780 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
781 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
782 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
783 LLVMDataStructure.a LLVMSparcV9RegAlloc
786 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
787 # ENABLE_PPC_JIT on the make command line. If not, it will still be
788 # enabled automagically on an PowerPC host.
789 ifeq ($(ARCH), PowerPC)
793 # What the PowerPC JIT requires
795 JIT_LIBS += LLVMPowerPC
798 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
799 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
800 LLVMSystem.a $(PLATFORMLIBDL)
803 #---------------------------------------------------------
804 # Set up variables for building a tool.
805 #---------------------------------------------------------
807 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
809 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
811 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
812 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
813 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
814 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
815 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
816 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
817 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
818 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
820 #---------------------------------------------------------
821 # Tell make that we need to rebuild subdirectories before
822 # we can link the tool. This affects things like LLI which
823 # has library subdirectories.
824 #---------------------------------------------------------
825 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
827 #---------------------------------------------------------
828 # Provide targets for building the tools
829 #---------------------------------------------------------
830 all-local:: $(ToolBuildPath)
833 ifneq ($(strip $(ToolBuildPath)),)
834 -$(Verb) $(RM) -f $(ToolBuildPath)
838 $(ToolBuildPath): $(ExmplDir)/.dir
840 $(ToolBuildPath): $(ToolDir)/.dir
843 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
844 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
845 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
846 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
847 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
849 DestTool = $(bindir)/$(TOOLNAME)
851 install-local:: $(DestTool)
853 $(DestTool): $(bindir) $(ToolBuildPath)
854 $(Echo) Installing $(BuildMode) $(DestTool)
855 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
858 $(Echo) Uninstalling $(BuildMode) $(DestTool)
859 -$(Verb) $(RM) -f $(DestTool)
863 ###############################################################################
864 # Object Build Rules: Build object files based on sources
865 ###############################################################################
867 # Provide rule sets for when dependency generation is enabled
868 ifndef DISABLE_AUTO_DEPENDENCIES
870 #---------------------------------------------------------
871 # Create .lo files in the ObjDir directory from the .cpp and .c files...
872 #---------------------------------------------------------
875 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
876 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
877 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
878 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
879 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
881 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
882 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
883 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
884 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
885 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
887 #---------------------------------------------------------
888 # Create .o files in the ObjDir directory from the .cpp and .c files...
889 #---------------------------------------------------------
892 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
893 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
894 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
895 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
896 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
898 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
899 $(Echo) "Compiling $*.c for $(BuildMode) build"
900 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
901 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
902 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
906 #---------------------------------------------------------
907 # Create .bc files in the ObjDir directory from .cpp and .c files...
908 #---------------------------------------------------------
909 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
910 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
911 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
912 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
913 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
915 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
916 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
917 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
918 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
919 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
921 # Provide alternate rule sets if dependencies are disabled
926 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
927 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
928 $(LTCompile.CXX) $< -o $@
930 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
931 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
932 $(LTCompile.C) $< -o $@
936 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
937 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
938 $(Compile.CXX) $< -o $@
940 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
941 $(Echo) "Compiling $*.c for $(BuildMode) build"
942 $(Compile.C) $< -o $@
945 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
946 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
947 $(BCCompile.CXX) $< -o $@
949 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
950 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
951 $(BCCompile.C) $< -o $@
955 #---------------------------------------------------------
956 # Provide rule to build .bc files from .ll sources,
957 # regardless of dependencies
958 #---------------------------------------------------------
959 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
960 $(Echo) "Compiling $*.ll for $(BuildMode) build"
961 $(Verb) $(LLVMAS) $< -f -o $@
963 ###############################################################################
964 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
965 ###############################################################################
969 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
970 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
971 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
972 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
974 # All of these files depend on tblgen and the .td files.
975 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
977 # INCFiles rule: All of the tblgen generated files are emitted to
978 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
979 # us to only "touch" the real file if the contents of it change. IOW, if
980 # tblgen is modified, all of the .inc.tmp files are regereated, but no
981 # dependencies of the .inc files are, unless the contents of the .inc file
983 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
984 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
986 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
987 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
988 $(Echo) "Building $(<F) register names with tblgen"
989 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
991 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
992 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
993 $(Echo) "Building $(<F) register information header with tblgen"
994 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
996 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
997 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
998 $(Echo) "Building $(<F) register info implementation with tblgen"
999 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1001 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1002 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1003 $(Echo) "Building $(<F) instruction names with tblgen"
1004 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1006 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1007 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1008 $(Echo) "Building $(<F) instruction information with tblgen"
1009 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1011 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1012 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1013 $(Echo) "Building $(<F) assembly writer with tblgen"
1014 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1016 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1017 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1018 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1019 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1021 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1022 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1023 $(Echo) "Building $(<F) code emitter with tblgen"
1024 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1027 -$(Verb) $(RM) -f $(INCFiles)
1031 ###############################################################################
1032 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1033 ###############################################################################
1035 #---------------------------------------------------------
1036 # Provide rules for generating a .cpp source file from
1037 # (f)lex input sources.
1038 #---------------------------------------------------------
1040 LexFiles := $(filter %.l,$(Sources))
1042 ifneq ($(LexFiles),)
1044 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1046 .PRECIOUS: $(LexOutput)
1048 # Note the extra sed filtering here, used to cut down on the warnings emited
1049 # by GCC. The last line is a gross hack to work around flex aparently not
1050 # being able to resize the buffer on a large token input. Currently, for
1051 # uninitialized string buffers in LLVM we can generate very long tokens, so
1052 # this is a hack around it.
1053 # FIXME. (f.e. char Buffer[10000] )
1055 $(Echo) Flexing $*.l
1056 $(Verb) $(FLEX) -t $< | \
1057 $(SED) 's/void yyunput/inline void yyunput/' | \
1058 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1059 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1063 -$(Verb) $(RM) -f $(LexOutput)
1064 $(Verb) $(RM) -f $(LexOutput)
1068 #---------------------------------------------------------
1069 # Provide rules for generating a .cpp and .h source files
1070 # from yacc (bison) input sources.
1071 #---------------------------------------------------------
1073 YaccFiles := $(filter %.y,$(Sources))
1074 ifneq ($(YaccFiles),)
1075 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1077 .PRECIOUS: $(YaccOutput)
1079 # Cancel built-in rules for yacc
1084 # Rule for building the bison parsers...
1086 $(Echo) "Bisoning $*.y"
1087 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1088 $(Verb) $(MV) -f $*.tab.c $*.cpp
1089 $(Verb) $(MV) -f $*.tab.h $*.h
1092 -$(Verb) $(RM) -f $(YaccOutput)
1093 $(Verb) $(RM) -f $(YaccOutput)
1096 ###############################################################################
1097 # OTHER RULES: Other rules needed
1098 ###############################################################################
1100 # To create postscript files from dot files...
1101 ifneq ($(DOT),false)
1103 $(DOT) -Tps < $< > $@
1106 $(Echo) "Cannot build $@: The program dot is not installed"
1109 # This rules ensures that header files that are removed still have a rule for
1110 # which they can be "generated." This allows make to ignore them and
1111 # reproduce the dependency lists.
1114 # Define clean-local to clean the current directory. Note that this uses a
1115 # very conservative approach ensuring that empty variables do not cause
1116 # errors or disastrous removal.
1118 ifneq ($(strip $(ObjDir)),)
1119 -$(Verb) $(RM) -rf $(ObjDir)
1121 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1122 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1123 -$(Verb) $(RM) -f *$(SHLIBEXT)
1127 -$(Verb) $(RM) -rf Debug Release Profile
1129 # Build tags database for Emacs/Xemacs:
1133 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1134 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1135 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1136 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1137 -name '*.cpp' -o -name '*.h' | \
1138 $(ETAGS) $(ETAGSFLAGS) -
1141 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1142 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1143 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1144 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1145 \( -name '*.cpp' -o -name '*.h' \) -print | \
1146 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1149 ###############################################################################
1150 # DEPENDENCIES: Include the dependency files if we should
1151 ###############################################################################
1152 ifndef DISABLE_AUTO_DEPENDENCIES
1154 # If its not one of the cleaning targets
1155 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1157 # Get the list of dependency files
1158 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1159 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1161 -include /dev/null $(DependFiles)
1167 ###############################################################################
1168 # CHECK: Running the test suite
1169 ###############################################################################
1172 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1173 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1174 $(EchoCmd) Running test suite ; \
1175 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1176 TESTSUITE=$(TESTSUITE) ; \
1178 $(EchoCmd) No Makefile in test directory ; \
1181 $(EchoCmd) No test directory ; \
1184 ###############################################################################
1185 # DISTRIBUTION: Handle construction of a distribution tarball
1186 ###############################################################################
1188 #------------------------------------------------------------------------
1189 # Define distribution related variables
1190 #------------------------------------------------------------------------
1191 DistName := $(LLVM_TARBALL_NAME)
1192 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1193 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1194 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1195 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1196 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1197 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1198 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1199 Makefile.config.in configure autoconf
1200 DistOther := $(notdir $(wildcard \
1201 $(BUILD_SRC_DIR)/*.h \
1202 $(BUILD_SRC_DIR)/*.td \
1203 $(BUILD_SRC_DIR)/*.def \
1204 $(BUILD_SRC_DIR)/*.ll \
1205 $(BUILD_SRC_DIR)/*.in))
1206 DistSubDirs := $(SubDirs)
1207 DistSources = $(Sources) $(EXTRA_DIST)
1208 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1210 #------------------------------------------------------------------------
1211 # We MUST build distribution with OBJ_DIR != SRC_DIR
1212 #------------------------------------------------------------------------
1213 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1214 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1215 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1219 #------------------------------------------------------------------------
1220 # Prevent catastrophic remove
1221 #------------------------------------------------------------------------
1222 ifeq ($(LLVM_TARBALL_NAME),)
1223 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1226 #------------------------------------------------------------------------
1227 # Prevent attempt to run dist targets from anywhere but the top level
1228 #------------------------------------------------------------------------
1231 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1232 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1236 #------------------------------------------------------------------------
1237 # Provide the top level targets
1238 #------------------------------------------------------------------------
1240 dist-gzip:: $(DistTarGZip)
1242 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1243 $(Echo) Packing gzipped distribution tar file.
1244 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1245 $(GZIP) -c > "$(DistTarGZip)"
1247 dist-bzip2:: $(DistTarBZ2)
1249 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1250 $(Echo) Packing bzipped distribution tar file.
1251 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1252 $(BZIP2) -c >$(DistTarBZ2)
1254 dist-zip:: $(DistZip)
1256 $(DistZip) : $(TopDistDir)/.makedistdir
1257 $(Echo) Packing zipped distribution file.
1258 $(Verb) rm -f $(DistZip)
1259 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1261 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1262 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1264 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1266 dist-check:: $(DistTarGZip)
1267 $(Echo) Checking distribution tar file.
1268 $(Verb) if test -d $(DistCheckDir) ; then \
1269 $(RM) -rf $(DistCheckDir) ; \
1271 $(Verb) $(MKDIR) $(DistCheckDir)
1272 $(Verb) cd $(DistCheckDir) && \
1273 $(MKDIR) $(DistCheckDir)/build && \
1274 $(MKDIR) $(DistCheckDir)/install && \
1275 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1277 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1278 --srcdir=../$(DistName) && \
1281 $(MAKE) install && \
1282 $(MAKE) uninstall && \
1285 $(MAKE) dist-clean && \
1286 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1289 $(Echo) Cleaning distribution files
1290 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1295 #------------------------------------------------------------------------
1296 # Provide the recursive distdir target for building the distribution directory
1297 #------------------------------------------------------------------------
1298 distdir: $(DistDir)/.makedistdir
1299 $(DistDir)/.makedistdir: $(DistSources)
1300 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1301 if test -d "$(DistDir)" ; then \
1302 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1305 $(EchoCmd) Removing old $(DistDir) ; \
1306 $(RM) -rf $(DistDir); \
1307 $(EchoCmd) Making 'all' to verify build ; \
1310 $(Echo) Building Distribution Directory $(DistDir)
1311 $(Verb) $(MKDIR) $(DistDir)
1312 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1313 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1314 for file in $(DistFiles) ; do \
1316 $(BUILD_SRC_DIR)/*) \
1317 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1319 $(BUILD_SRC_ROOT)/*) \
1320 file=`echo "$$file" | \
1321 sed "s#^$$srcrootstrip/##"` \
1324 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1325 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1326 from_dir="$(BUILD_SRC_DIR)" ; \
1327 elif test -f "$$file" || test -d "$$file" ; then \
1330 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1331 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1332 to_dir="$(DistDir)/$$dir"; \
1333 $(MKDIR) "$$to_dir" ; \
1335 to_dir="$(DistDir)"; \
1337 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1338 if test -n "$$mid_dir" ; then \
1339 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1341 if test -d "$$from_dir/$$file"; then \
1342 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1343 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1344 $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1346 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1347 elif test -f "$$from_dir/$$file" ; then \
1348 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1349 elif test -L "$$from_dir/$$file" ; then \
1350 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1351 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1352 $(EchoCmd) "===== WARNING: Distribution Source " \
1353 "$$from_dir/$$file Not Found!" ; \
1354 elif test "$(Verb)" != '@' ; then \
1355 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1358 $(Verb) for subdir in $(DistSubDirs) ; do \
1359 if test "$$subdir" \!= "." ; then \
1360 new_distdir="$(DistDir)/$$subdir" ; \
1361 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1362 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1366 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1367 $(EchoCmd) Eliminating CVS directories from distribution ; \
1368 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1369 $(MAKE) dist-hook ; \
1370 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1371 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1372 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1373 -o ! -type d ! -perm -444 -exec \
1374 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1375 || chmod -R a+r $(DistDir) ; \
1378 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1384 ###############################################################################
1385 # TOP LEVEL - targets only to apply at the top level directory
1386 ###############################################################################
1390 #------------------------------------------------------------------------
1391 # Install support for the project's include files:
1392 #------------------------------------------------------------------------
1394 $(Echo) Installing include files
1395 $(Verb) $(MKDIR) $(includedir)
1396 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1397 cd $(BUILD_SRC_ROOT)/include && \
1398 find . -path '*/Internal' -prune -o '(' -type f \
1399 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1400 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1404 $(Echo) Uninstalling include files
1405 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1406 cd $(BUILD_SRC_ROOT)/include && \
1407 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1408 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1409 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1414 #------------------------------------------------------------------------
1415 # Print out the directories used for building
1416 #------------------------------------------------------------------------
1418 $(Echo) "BuildMode : " '$(BuildMode)'
1419 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1420 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1421 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1422 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1423 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1424 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1425 $(Echo) "libdir : " '$(libdir)'
1426 $(Echo) "bindir : " '$(bindir)'
1427 $(Echo) "sysconfdir : " '$(sysconfdir)'
1428 $(Echo) "UserTargets : " '$(UserTargets)'
1429 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1430 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1431 $(Echo) "ObjDir : " '$(ObjDir)'
1432 $(Echo) "LibDir : " '$(LibDir)'
1433 $(Echo) "ToolDir : " '$(ToolDir)'
1434 $(Echo) "ExmplDir : " '$(ExmplDir)'
1435 $(Echo) "Sources : " '$(Sources)'
1436 $(Echo) "TDFiles : " '$(TDFiles)'
1437 $(Echo) "INCFiles : " '$(INCFiles)'
1438 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1439 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1440 $(Echo) "Compile.C : " '$(Compile.C)'
1441 $(Echo) "Archive : " '$(Archive)'
1442 $(Echo) "YaccFiles : " '$(YaccFiles)'
1443 $(Echo) "LexFiles : " '$(LexFiles)'
1444 $(Echo) "Module : " '$(Module)'