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 $(Verb) if test -x config.status ; then \
87 $(EchoCmd) Wiping out $(BUILD_OBJ_ROOT) ; \
88 $(MKDIR) .spotless.save ; \
89 $(MV) config.status .spotless.save ; \
90 $(MV) mklib .spotless.save ; \
91 $(MV) projects .spotless.save ; \
93 $(MV) .spotless.save/config.status . ; \
94 $(MV) .spotless.save/mklib . ; \
95 $(MV) .spotless.save/projects . ; \
96 $(RM) -rf .spotless.save ; \
97 $(EchoCmd) Rebuilding configuration of $(BUILD_OBJ_ROOT) ; \
98 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
99 $(ConfigStatusScript) ; \
101 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
105 $(BUILT_SOURCES) : $(ObjMakefiles)
107 #------------------------------------------------------------------------
108 # Make sure we're not using a stale configuration
109 #------------------------------------------------------------------------
111 $(Echo) Reconfiguring $(BUILD_OBJ_ROOT)
112 $(Verb) cd $(BUILD_OBJ_ROOT) && \
113 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
114 $(ConfigStatusScript)
116 .PRECIOUS: $(ConfigStatusScript)
117 $(ConfigStatusScript): $(ConfigureScript)
118 $(Echo) Reconfiguring with $<
119 $(Verb) cd $(BUILD_OBJ_ROOT) && \
120 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
121 $(ConfigStatusScript)
123 #------------------------------------------------------------------------
124 # Make sure the configuration makefile is up to date
125 #------------------------------------------------------------------------
126 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
127 $(Echo) Regenerating $@
128 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
130 #------------------------------------------------------------------------
131 # If the Makefile in the source tree has been updated, copy it over into the
132 # build tree. But, only do this if the source and object makefiles differ
133 #------------------------------------------------------------------------
134 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
136 Makefile: $(BUILD_SRC_DIR)/Makefile
137 $(Echo) "Updating Makefile"
138 $(Verb) $(MKDIR) $(@D)
139 $(Verb) $(CP) -f $< $@
141 # Copy the Makefile.* files unless we're in the root directory which avoids
142 # the copying of Makefile.config.in or other things that should be explicitly
144 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
146 *Makefile.rules) ;; \
148 *) $(Echo) "Updating $(@F)" ; \
155 #------------------------------------------------------------------------
156 # Set up the basic dependencies
157 #------------------------------------------------------------------------
158 $(UserTargets):: $(PreConditions)
162 clean-all:: clean-local clean-all-local
163 install:: install-local
164 uninstall:: uninstall-local
165 install-local:: all-local
166 install-bytecode:: install-bytecode-local
168 ###############################################################################
169 # VARIABLES: Set up various variables based on configuration data
170 ###############################################################################
172 #--------------------------------------------------------------------
173 # Variables derived from configuration we are building
174 #--------------------------------------------------------------------
176 ifdef ENABLE_PROFILING
178 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
179 C.Flags := -O3 -DNDEBUG -pg
180 LD.Flags := -O3 -DNDEBUG -pg
182 ifdef ENABLE_OPTIMIZED
184 CXX.Flags := -O3 -DNDEBUG -finline-functions \
185 -felide-constructors -fomit-frame-pointer
186 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
187 LD.Flags := -O3 -DNDEBUG
190 CXX.Flags := -g -D_DEBUG
191 C.Flags := -g -D_DEBUG
192 LD.Flags := -g -D_DEBUG
197 CXX.Flags += $(CXXFLAGS)
199 CPP.Flags += $(CPPFLAGS)
200 LD.Flags += $(LDFLAGS)
202 LibTool.Flags := --tag=CXX
204 #--------------------------------------------------------------------
205 # Directory locations
206 #--------------------------------------------------------------------
207 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
208 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
209 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
210 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
211 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
212 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
213 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
215 #--------------------------------------------------------------------
216 # Full Paths To Compiled Tools and Utilities
217 #--------------------------------------------------------------------
218 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
221 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
224 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
227 BURG := $(LLVMToolDir)/burg$(EXEEXT)
230 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
233 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
236 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
239 LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
242 LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
245 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
248 LLI := $(LLVMToolDir)/lli$(EXEEXT)
251 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
254 #--------------------------------------------------------------------
255 # Adjust to user's request
256 #--------------------------------------------------------------------
258 # Adjust LIBTOOL flags for shared libraries, or not.
259 ifndef SHARED_LIBRARY
260 LibTool.Flags += --tag=disable-shared
262 LD.Flags += -rpath $(LibDir)
272 # Adjust settings for verbose mode
275 LibTool.Flags += --silent
276 AR.Flags += >/dev/null 2>/dev/null
277 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
279 ConfigureScriptFLAGS :=
282 # By default, strip symbol information from executable
284 Strip := $(PLATFORMSTRIPOPTS)
285 StripWarnMsg := "(without symbols)"
288 # Adjust linker flags for building an executable
291 LD.Flags += -rpath $(ExmplDir) -export-dynamic
293 LD.Flags += -rpath $(ToolDir) -export-dynamic
297 #----------------------------------------------------------
298 # Options To Invoke Tools
299 #----------------------------------------------------------
301 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
303 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
304 CPP.Flags += -I$(BUILD_OBJ_DIR) \
306 -I$(BUILD_SRC_ROOT)/include \
307 -I$(BUILD_OBJ_ROOT)/include \
308 -I$(LLVM_OBJ_ROOT)/include \
309 -I$(LLVM_SRC_ROOT)/include \
310 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
312 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
313 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
314 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
315 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
316 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
317 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
318 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
319 $(CompileCommonOpts) $(LD.Flags) $(Strip)
320 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
322 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
323 Burg = $(BURG) -I $(BUILD_SRC_DIR)
324 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
325 Archive = $(AR) $(AR.Flags)
326 LArchive = $(LLVMToolDir)/llvm-ar rcsf
333 #----------------------------------------------------------
334 # Get the list of source files and compute object file
336 #----------------------------------------------------------
339 FakeSources := $(FAKE_SOURCES)
341 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
343 BaseNameSources := $(sort $(basename $(FakeSources)))
344 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
345 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
346 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
349 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
350 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
351 $(BUILD_SRC_DIR)/*.l))
353 Sources := $(SOURCES)
357 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
360 BaseNameSources := $(sort $(basename $(Sources)))
361 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
362 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
363 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
366 ###############################################################################
367 # DIRECTORIES: Handle recursive descent of directory structure
368 ###############################################################################
370 #---------------------------------------------------------
371 # Provide rules to make install dirs. This must be early
372 # in the file so they get built before dependencies
373 #---------------------------------------------------------
376 $(Verb) $(MKDIR) $(bindir)
379 $(Verb) $(MKDIR) $(libdir)
382 $(Verb) $(MKDIR) $(includedir)
385 $(Verb) $(MKDIR) $(sysconfdir)
387 # To create other directories, as needed, and timestamp their creation
389 $(Verb) $(MKDIR) $* > /dev/null
392 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
393 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
395 #---------------------------------------------------------
396 # Handle the DIRS options for sequential construction
397 #---------------------------------------------------------
402 $(RecursiveTargets)::
403 $(Verb) for dir in $(DIRS); do \
404 if [ ! -f $$dir/Makefile ]; then \
406 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
408 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
409 ($(MAKE) -C $$dir $@ ) || exit 1; \
414 #---------------------------------------------------------
415 # Handle the EXPERIMENTAL_DIRS options ensuring success
416 # after each directory is built.
417 #---------------------------------------------------------
418 ifdef EXPERIMENTAL_DIRS
419 $(RecursiveTargets)::
420 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
421 if [ ! -f $$dir/Makefile ]; then \
423 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
425 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
426 ($(MAKE) -C $$dir $@ ) || exit 0; \
431 #---------------------------------------------------------
432 # Handle the PARALLEL_DIRS options for parallel construction
433 #---------------------------------------------------------
436 SubDirs += $(PARALLEL_DIRS)
438 # Unfortunately, this list must be maintained if new recursive targets are added
439 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
440 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
441 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
442 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
443 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
444 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
446 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
449 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
451 $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
453 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
454 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
458 #---------------------------------------------------------
459 # Handle the OPTIONAL_DIRS options for directores that may
461 #---------------------------------------------------------
464 SubDirs += $(OPTIONAL_DIRS)
466 $(RecursiveTargets)::
467 $(Verb) for dir in $(OPTIONAL_DIRS); do \
468 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
469 if [ ! -f $$dir/Makefile ]; then \
471 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
473 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
474 ($(MAKE) -C$$dir $@ ) || exit 1; \
480 #---------------------------------------------------------
481 # Handle the CONFIG_FILES options
482 #---------------------------------------------------------
485 install-local:: $(sysconfdir) $(CONFIG_FILES)
486 $(Echo) Installing Configuration Files To $(sysconfdir)
487 $(Verb)for file in $(CONFIG_FILES); do \
488 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
489 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
490 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
491 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
493 $(ECHO) Error: cannot find config file $${file}. ; \
498 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
499 $(Verb)for file in $(CONFIG_FILES); do \
500 $(RM) -f $(sysconfdir)/$${file} ; \
505 ###############################################################################
506 # Library Build Rules: Four ways to build a library
507 ###############################################################################
509 #---------------------------------------------------------
510 # Bytecode Module Targets:
511 # If the user set MODULE_NAME then they want to build a
512 # bytecode module from the sources. We compile all the
513 # sources and link it together into a single bytecode
515 #---------------------------------------------------------
519 Module := $(LibDir)/$(MODULE_NAME).bc
520 LinkModule := $(LLVMGCC) -shared -nostdlib
522 ifdef EXPORTED_SYMBOL_FILE
523 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
526 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
527 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
528 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
530 all-local:: $(Module)
533 ifneq ($(strip $(Module)),)
534 -$(Verb) $(RM) -f $(Module)
537 ifdef BYTECODE_DESTINATION
538 ModuleDestDir := $(BYTECODE_DESTINATION)
540 ModuleDestDir := $(libdir)
543 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
545 install-module:: $(DestModule)
546 install-local:: $(DestModule)
548 $(DestModule): $(ModuleDestDir) $(Module)
549 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
550 $(Verb) $(INSTALL) $(Module) $@
553 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
554 -$(Verb) $(RM) -f $(DestModule)
558 # if we're building a library ...
561 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
562 LIBRARYNAME := $(strip $(LIBRARYNAME))
563 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
564 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
565 LibName.O := $(LibDir)/$(LIBRARYNAME).o
566 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
568 #---------------------------------------------------------
569 # Shared Library Targets:
570 # If the user asked for a shared library to be built
571 # with the SHARED_LIBRARY variable, then we provide
572 # targets for building them.
573 #---------------------------------------------------------
576 all-local:: $(LibName.LA)
578 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
579 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
580 $(Verb) $(Link) -o $@ $(ObjectsLO)
581 $(Verb) $(LTInstall) $@ $(LibDir)
584 ifneq ($(strip $(LibName.LA)),)
585 -$(Verb) $(RM) -f $(LibName.LA)
588 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
590 install-local:: $(DestSharedLib)
592 $(DestSharedLib): $(libdir) $(LibName.LA)
593 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
594 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
595 $(Verb) $(LIBTOOL) --finish $(libdir)
598 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
599 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
603 #---------------------------------------------------------
604 # Bytecode Library Targets:
605 # If the user asked for a bytecode library to be built
606 # with the BYTECODE_LIBRARY variable, then we provide
607 # targets for building them.
608 #---------------------------------------------------------
609 ifdef BYTECODE_LIBRARY
611 # make the C and C++ compilers strip debug info out of bytecode libraries.
612 BCCompile.C += -Wa,-strip-debug
613 BCCompile.CXX += -Wa,-strip-debug
615 all-local:: $(LibName.BCA)
617 ifdef EXPORTED_SYMBOL_FILE
618 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
619 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
621 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
622 $(LLVMToolDir)/llvm-ar
623 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
625 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
627 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
629 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
630 $(LLVMToolDir)/llvm-ar
631 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
633 $(Verb) $(LArchive) $@ $(ObjectsBC)
638 ifneq ($(strip $(LibName.BCA)),)
639 -$(Verb) $(RM) -f $(LibName.BCA)
642 ifdef BYTECODE_DESTINATION
643 BytecodeDestDir := $(BYTECODE_DESTINATION)
645 BytecodeDestDir := $(libdir)
648 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
650 install-bytecode-local:: $(DestBytecodeLib)
652 install-local:: $(DestBytecodeLib)
654 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
655 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
656 $(Verb) $(INSTALL) $(LibName.BCA) $@
659 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
660 -$(Verb) $(RM) -f $(DestBytecodeLib)
664 #---------------------------------------------------------
665 # ReLinked Library Targets:
666 # If the user didn't explicitly forbid building a
667 # relinked then we provide targets for building them.
668 #---------------------------------------------------------
669 ifndef DONT_BUILD_RELINKED
671 all-local:: $(LibName.O)
673 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
674 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
675 $(Verb) $(Relink) -o $@ $(ObjectsO)
678 ifneq ($(strip $(LibName.O)),)
679 -$(Verb) $(RM) -f $(LibName.O)
682 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
684 install-local:: $(DestRelinkedLib)
686 $(DestRelinkedLib): $(libdir) $(LibName.O)
687 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
688 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
691 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
692 -$(Verb) $(RM) -f $(DestRelinkedLib)
696 #---------------------------------------------------------
697 # Archive Library Targets:
698 # If the user wanted a regular archive library built,
699 # then we provide targets for building them.
700 #---------------------------------------------------------
703 all-local:: $(LibName.A)
705 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
706 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
708 $(Verb) $(Archive) $@ $(ObjectsO)
712 ifneq ($(strip $(LibName.A)),)
713 -$(Verb) $(RM) -f $(LibName.A)
716 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
718 install-local:: $(DestArchiveLib)
720 $(DestArchiveLib): $(libdir) $(LibName.A)
721 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
722 $(Verb) $(MKDIR) $(libdir)
723 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
726 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
727 -$(Verb) $(RM) -f $(DestArchiveLib)
734 ###############################################################################
735 # Tool Build Rules: Build executable tool based on TOOLNAME option
736 ###############################################################################
740 #---------------------------------------------------------
741 # Handle the special "JIT" value for LLVM_LIBS which is a
742 # shorthand for a bunch of libraries that get the correct
743 # JIT support for a tool that runs JIT.
744 #---------------------------------------------------------
745 ifeq ($(LLVMLIBS),JIT)
747 # Make sure we can get our own symbols in the tool
750 # Generic JIT libraries
751 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
753 # You can enable the X86 JIT on a non-X86 host by setting the flag
754 # ENABLE_X86_JIT on the make command line. If not, it will still be
755 # enabled automagically on an X86 host.
760 # What the X86 JIT requires
765 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
766 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
767 # enabled automagically on an SparcV9 host.
768 ifeq ($(ARCH), Sparc)
769 ENABLE_SPARCV9_JIT = 1
772 # What the Sparc JIT requires
773 ifdef ENABLE_SPARCV9_JIT
774 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
775 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
776 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
777 LLVMDataStructure.a LLVMSparcV9RegAlloc
780 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
781 # ENABLE_PPC_JIT on the make command line. If not, it will still be
782 # enabled automagically on an PowerPC host.
783 ifeq ($(ARCH), PowerPC)
787 # What the PowerPC JIT requires
789 JIT_LIBS += LLVMPowerPC
792 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
793 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
794 LLVMSystem.a $(PLATFORMLIBDL)
797 #---------------------------------------------------------
798 # Set up variables for building a tool.
799 #---------------------------------------------------------
801 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
803 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
805 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
806 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
807 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
808 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
809 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
810 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
811 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
812 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
814 #---------------------------------------------------------
815 # Tell make that we need to rebuild subdirectories before
816 # we can link the tool. This affects things like LLI which
817 # has library subdirectories.
818 #---------------------------------------------------------
819 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
821 #---------------------------------------------------------
822 # Provide targets for building the tools
823 #---------------------------------------------------------
824 all-local:: $(ToolBuildPath)
827 ifneq ($(strip $(ToolBuildPath)),)
828 -$(Verb) $(RM) -f $(ToolBuildPath)
832 $(ToolBuildPath): $(ExmplDir)/.dir
834 $(ToolBuildPath): $(ToolDir)/.dir
837 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
838 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
839 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
840 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
841 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
843 DestTool = $(bindir)/$(TOOLNAME)
845 install-local:: $(DestTool)
847 $(DestTool): $(bindir) $(ToolBuildPath)
848 $(Echo) Installing $(BuildMode) $(DestTool)
849 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
852 $(Echo) Uninstalling $(BuildMode) $(DestTool)
853 -$(Verb) $(RM) -f $(DestTool)
857 ###############################################################################
858 # Object Build Rules: Build object files based on sources
859 ###############################################################################
861 # Provide rule sets for when dependency generation is enabled
862 ifndef DISABLE_AUTO_DEPENDENCIES
864 #---------------------------------------------------------
865 # Create .lo files in the ObjDir directory from the .cpp and .c files...
866 #---------------------------------------------------------
869 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
870 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
871 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
872 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
873 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
875 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
876 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
877 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
878 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
879 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
881 #---------------------------------------------------------
882 # Create .o files in the ObjDir directory from the .cpp and .c files...
883 #---------------------------------------------------------
886 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
887 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
888 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
889 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
890 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
892 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
893 $(Echo) "Compiling $*.c for $(BuildMode) build"
894 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
895 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
896 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
900 #---------------------------------------------------------
901 # Create .bc files in the ObjDir directory from .cpp and .c files...
902 #---------------------------------------------------------
903 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
904 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
905 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
906 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
907 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
909 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
910 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
911 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
912 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
913 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
915 # Provide alternate rule sets if dependencies are disabled
920 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
921 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
922 $(LTCompile.CXX) $< -o $@
924 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
925 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
926 $(LTCompile.C) $< -o $@
930 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
931 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
932 $(Compile.CXX) $< -o $@
934 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
935 $(Echo) "Compiling $*.c for $(BuildMode) build"
936 $(Compile.C) $< -o $@
939 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
940 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
941 $(BCCompile.CXX) $< -o $@
943 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
944 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
945 $(BCCompile.C) $< -o $@
949 #---------------------------------------------------------
950 # Provide rule to build .bc files from .ll sources,
951 # regardless of dependencies
952 #---------------------------------------------------------
953 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
954 $(Echo) "Compiling $*.ll for $(BuildMode) build"
955 $(Verb) $(LLVMAS) $< -f -o $@
957 ###############################################################################
958 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
959 ###############################################################################
963 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
964 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
965 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
966 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
968 # All of these files depend on tblgen and the .td files.
969 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
971 # INCFiles rule: All of the tblgen generated files are emitted to
972 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
973 # us to only "touch" the real file if the contents of it change. IOW, if
974 # tblgen is modified, all of the .inc.tmp files are regereated, but no
975 # dependencies of the .inc files are, unless the contents of the .inc file
977 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
978 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
980 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
981 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
982 $(Echo) "Building $(<F) register names with tblgen"
983 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
985 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
986 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
987 $(Echo) "Building $(<F) register information header with tblgen"
988 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
990 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
991 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
992 $(Echo) "Building $(<F) register info implementation with tblgen"
993 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
995 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
996 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
997 $(Echo) "Building $(<F) instruction names with tblgen"
998 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
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:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1006 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1007 $(Echo) "Building $(<F) assembly writer with tblgen"
1008 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1010 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1011 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1012 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1013 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1015 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1016 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1017 $(Echo) "Building $(<F) code emitter with tblgen"
1018 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1021 -$(Verb) $(RM) -f $(INCFiles)
1025 ###############################################################################
1026 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1027 ###############################################################################
1029 #---------------------------------------------------------
1030 # Provide rules for generating a .cpp source file from
1031 # (f)lex input sources.
1032 #---------------------------------------------------------
1034 LexFiles := $(filter %.l,$(Sources))
1036 ifneq ($(LexFiles),)
1038 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1040 .PRECIOUS: $(LexOutput)
1042 # Note the extra sed filtering here, used to cut down on the warnings emited
1043 # by GCC. The last line is a gross hack to work around flex aparently not
1044 # being able to resize the buffer on a large token input. Currently, for
1045 # uninitialized string buffers in LLVM we can generate very long tokens, so
1046 # this is a hack around it.
1047 # FIXME. (f.e. char Buffer[10000] )
1049 $(Echo) Flexing $*.l
1050 $(Verb) $(FLEX) -t $< | \
1051 $(SED) 's/void yyunput/inline void yyunput/' | \
1052 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1053 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1057 -$(Verb) $(RM) -f $(LexOutput)
1058 $(Verb) $(RM) -f $(LexOutput)
1062 #---------------------------------------------------------
1063 # Provide rules for generating a .cpp and .h source files
1064 # from yacc (bison) input sources.
1065 #---------------------------------------------------------
1067 YaccFiles := $(filter %.y,$(Sources))
1068 ifneq ($(YaccFiles),)
1069 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1071 .PRECIOUS: $(YaccOutput)
1073 # Cancel built-in rules for yacc
1078 # Rule for building the bison parsers...
1080 $(Echo) "Bisoning $*.y"
1081 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1082 $(Verb) $(MV) -f $*.tab.c $*.cpp
1083 $(Verb) $(MV) -f $*.tab.h $*.h
1086 -$(Verb) $(RM) -f $(YaccOutput)
1087 $(Verb) $(RM) -f $(YaccOutput)
1090 ###############################################################################
1091 # OTHER RULES: Other rules needed
1092 ###############################################################################
1094 # To create postscript files from dot files...
1095 ifneq ($(DOT),false)
1097 $(DOT) -Tps < $< > $@
1100 $(Echo) "Cannot build $@: The program dot is not installed"
1103 # This rules ensures that header files that are removed still have a rule for
1104 # which they can be "generated." This allows make to ignore them and
1105 # reproduce the dependency lists.
1108 # Define clean-local to clean the current directory. Note that this uses a
1109 # very conservative approach ensuring that empty variables do not cause
1110 # errors or disastrous removal.
1112 ifneq ($(strip $(ObjDir)),)
1113 -$(Verb) $(RM) -rf $(ObjDir)
1115 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1116 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1117 -$(Verb) $(RM) -f *$(SHLIBEXT)
1121 -$(Verb) $(RM) -rf Debug Release Profile
1123 # Build tags database for Emacs/Xemacs:
1127 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1128 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1129 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1130 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1131 -name '*.cpp' -o -name '*.h' | \
1132 $(ETAGS) $(ETAGSFLAGS) -
1135 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1136 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1137 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1138 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1139 \( -name '*.cpp' -o -name '*.h' \) -print | \
1140 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1143 ###############################################################################
1144 # DEPENDENCIES: Include the dependency files if we should
1145 ###############################################################################
1146 ifndef DISABLE_AUTO_DEPENDENCIES
1148 # If its not one of the cleaning targets
1149 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1151 # Get the list of dependency files
1152 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1153 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1155 -include /dev/null $(DependFiles)
1161 ###############################################################################
1162 # CHECK: Running the test suite
1163 ###############################################################################
1166 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1167 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1168 $(EchoCmd) Running test suite ; \
1169 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1170 TESTSUITE=$(TESTSUITE) ; \
1172 $(EchoCmd) No Makefile in test directory ; \
1175 $(EchoCmd) No test directory ; \
1178 ###############################################################################
1179 # DISTRIBUTION: Handle construction of a distribution tarball
1180 ###############################################################################
1182 #------------------------------------------------------------------------
1183 # Define distribution related variables
1184 #------------------------------------------------------------------------
1185 DistName := $(LLVM_TARBALL_NAME)
1186 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1187 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1188 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1189 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1190 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1191 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1192 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1193 Makefile.config.in configure autoconf
1194 DistOther := $(notdir $(wildcard \
1195 $(BUILD_SRC_DIR)/*.h \
1196 $(BUILD_SRC_DIR)/*.td \
1197 $(BUILD_SRC_DIR)/*.def \
1198 $(BUILD_SRC_DIR)/*.ll \
1199 $(BUILD_SRC_DIR)/*.in))
1200 DistSubDirs := $(SubDirs)
1201 DistSources = $(Sources) $(EXTRA_DIST)
1202 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1204 #------------------------------------------------------------------------
1205 # We MUST build distribution with OBJ_DIR != SRC_DIR
1206 #------------------------------------------------------------------------
1207 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1208 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1209 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1213 #------------------------------------------------------------------------
1214 # Prevent catastrophic remove
1215 #------------------------------------------------------------------------
1216 ifeq ($(LLVM_TARBALL_NAME),)
1217 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1220 #------------------------------------------------------------------------
1221 # Prevent attempt to run dist targets from anywhere but the top level
1222 #------------------------------------------------------------------------
1225 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1226 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1230 #------------------------------------------------------------------------
1231 # Provide the top level targets
1232 #------------------------------------------------------------------------
1234 dist-gzip:: $(DistTarGZip)
1236 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1237 $(Echo) Packing gzipped distribution tar file.
1238 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1239 $(GZIP) -c > "$(DistTarGZip)"
1241 dist-bzip2:: $(DistTarBZ2)
1243 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1244 $(Echo) Packing bzipped distribution tar file.
1245 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1246 $(BZIP2) -c >$(DistTarBZ2)
1248 dist-zip:: $(DistZip)
1250 $(DistZip) : $(TopDistDir)/.makedistdir
1251 $(Echo) Packing zipped distribution file.
1252 $(Verb) rm -f $(DistZip)
1253 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1255 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1256 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1258 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1260 dist-check:: $(DistTarGZip)
1261 $(Echo) Checking distribution tar file.
1262 $(Verb) if test -d $(DistCheckDir) ; then \
1263 $(RM) -rf $(DistCheckDir) ; \
1265 $(Verb) $(MKDIR) $(DistCheckDir)
1266 $(Verb) cd $(DistCheckDir) && \
1267 $(MKDIR) $(DistCheckDir)/build && \
1268 $(MKDIR) $(DistCheckDir)/install && \
1269 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1271 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1272 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1275 $(MAKE) install && \
1276 $(MAKE) uninstall && \
1279 $(MAKE) dist-clean && \
1280 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1283 $(Echo) Cleaning distribution files
1284 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1289 #------------------------------------------------------------------------
1290 # Provide the recursive distdir target for building the distribution directory
1291 #------------------------------------------------------------------------
1292 distdir: $(DistDir)/.makedistdir
1293 $(DistDir)/.makedistdir: $(DistSources)
1294 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1295 if test -d "$(DistDir)" ; then \
1296 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1299 $(EchoCmd) Removing old $(DistDir) ; \
1300 $(RM) -rf $(DistDir); \
1301 $(EchoCmd) Making 'all' to verify build ; \
1304 $(Echo) Building Distribution Directory $(DistDir)
1305 $(Verb) $(MKDIR) $(DistDir)
1306 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1307 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1308 for file in $(DistFiles) ; do \
1310 $(BUILD_SRC_DIR)/*) \
1311 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1313 $(BUILD_SRC_ROOT)/*) \
1314 file=`echo "$$file" | \
1315 sed "s#^$$srcrootstrip/##"` \
1318 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1319 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1320 from_dir="$(BUILD_SRC_DIR)" ; \
1321 elif test -f "$$file" || test -d "$$file" ; then \
1324 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1325 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1326 to_dir="$(DistDir)/$$dir"; \
1327 $(MKDIR) "$$to_dir" ; \
1329 to_dir="$(DistDir)"; \
1331 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1332 if test -n "$$mid_dir" ; then \
1333 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1335 if test -d "$$from_dir/$$file"; then \
1336 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1337 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1338 $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1340 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1341 elif test -f "$$from_dir/$$file" ; then \
1342 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1343 elif test -L "$$from_dir/$$file" ; then \
1344 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1345 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1346 $(EchoCmd) "===== WARNING: Distribution Source " \
1347 "$$from_dir/$$file Not Found!" ; \
1348 elif test "$(Verb)" != '@' ; then \
1349 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1352 $(Verb) for subdir in $(DistSubDirs) ; do \
1353 if test "$$subdir" \!= "." ; then \
1354 new_distdir="$(DistDir)/$$subdir" ; \
1355 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1356 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1360 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1361 $(EchoCmd) Eliminating CVS directories from distribution ; \
1362 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1363 $(MAKE) dist-hook ; \
1364 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1365 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1366 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1367 -o ! -type d ! -perm -444 -exec \
1368 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1369 || chmod -R a+r $(DistDir) ; \
1372 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1378 ###############################################################################
1379 # TOP LEVEL - targets only to apply at the top level directory
1380 ###############################################################################
1384 #------------------------------------------------------------------------
1385 # Install support for the project's include files:
1386 #------------------------------------------------------------------------
1388 $(Echo) Installing include files
1389 $(Verb) $(MKDIR) $(includedir)
1390 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1391 cd $(BUILD_SRC_ROOT)/include && \
1392 find . -path '*/Internal' -prune -o '(' -type f \
1393 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1394 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1398 $(Echo) Uninstalling include files
1399 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1400 cd $(BUILD_SRC_ROOT)/include && \
1401 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1402 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1403 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1408 #------------------------------------------------------------------------
1409 # Print out the directories used for building
1410 #------------------------------------------------------------------------
1412 $(Echo) "BuildMode : " '$(BuildMode)'
1413 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1414 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1415 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1416 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1417 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1418 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1419 $(Echo) "libdir : " '$(libdir)'
1420 $(Echo) "bindir : " '$(bindir)'
1421 $(Echo) "sysconfdir : " '$(sysconfdir)'
1422 $(Echo) "UserTargets : " '$(UserTargets)'
1423 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1424 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1425 $(Echo) "ObjDir : " '$(ObjDir)'
1426 $(Echo) "LibDir : " '$(LibDir)'
1427 $(Echo) "ToolDir : " '$(ToolDir)'
1428 $(Echo) "ExmplDir : " '$(ExmplDir)'
1429 $(Echo) "Sources : " '$(Sources)'
1430 $(Echo) "TDFiles : " '$(TDFiles)'
1431 $(Echo) "INCFiles : " '$(INCFiles)'
1432 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1433 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1434 $(Echo) "Compile.C : " '$(Compile.C)'
1435 $(Echo) "Archive : " '$(Archive)'
1436 $(Echo) "YaccFiles : " '$(YaccFiles)'
1437 $(Echo) "LexFiles : " '$(LexFiles)'
1438 $(Echo) "Module : " '$(Module)'