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 if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \
114 $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \
116 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
117 $(ConfigStatusScript)
119 .PRECIOUS: $(ConfigStatusScript)
120 $(ConfigStatusScript): $(ConfigureScript)
121 $(Echo) Reconfiguring with $<
122 $(Verb) cd $(BUILD_OBJ_ROOT) && \
123 if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \
124 $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \
126 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
127 $(ConfigStatusScript)
129 #------------------------------------------------------------------------
130 # Make sure the configuration makefile is up to date
131 #------------------------------------------------------------------------
132 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
133 $(Echo) Regenerating $@
134 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
136 #------------------------------------------------------------------------
137 # If the Makefile in the source tree has been updated, copy it over into the
138 # build tree. But, only do this if the source and object makefiles differ
139 #------------------------------------------------------------------------
140 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
142 Makefile: $(BUILD_SRC_DIR)/Makefile
143 $(Echo) "Updating Makefile"
144 $(Verb) $(MKDIR) $(@D)
145 $(Verb) $(CP) -f $< $@
147 # Copy the Makefile.* files unless we're in the root directory which avoids
148 # the copying of Makefile.config.in or other things that should be explicitly
150 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
152 *Makefile.rules) ;; \
154 *) $(Echo) "Updating $(@F)" ; \
161 #------------------------------------------------------------------------
162 # Set up the basic dependencies
163 #------------------------------------------------------------------------
164 $(UserTargets):: $(PreConditions)
168 clean-all:: clean-local clean-all-local
169 install:: install-local
170 uninstall:: uninstall-local
171 install-local:: all-local
172 install-bytecode:: install-bytecode-local
174 ###############################################################################
175 # VARIABLES: Set up various variables based on configuration data
176 ###############################################################################
178 #--------------------------------------------------------------------
179 # Variables derived from configuration we are building
180 #--------------------------------------------------------------------
182 ifdef ENABLE_PROFILING
184 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
185 C.Flags := -O3 -DNDEBUG -pg
186 LD.Flags := -O3 -DNDEBUG -pg
188 ifdef ENABLE_OPTIMIZED
190 CXX.Flags := -O3 -DNDEBUG -finline-functions \
191 -felide-constructors -fomit-frame-pointer
192 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
193 LD.Flags := -O3 -DNDEBUG
196 CXX.Flags := -g -D_DEBUG
197 C.Flags := -g -D_DEBUG
198 LD.Flags := -g -D_DEBUG
203 CXX.Flags += $(CXXFLAGS)
205 CPP.Flags += $(CPPFLAGS)
206 LD.Flags += $(LDFLAGS)
208 LibTool.Flags := --tag=CXX
210 #--------------------------------------------------------------------
211 # Directory locations
212 #--------------------------------------------------------------------
213 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
214 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
215 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
216 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
217 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
218 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
219 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
220 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
222 #--------------------------------------------------------------------
223 # Full Paths To Compiled Tools and Utilities
224 #--------------------------------------------------------------------
225 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
228 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
231 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
234 BURG := $(LLVMToolDir)/burg$(EXEEXT)
237 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
240 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
243 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
246 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
249 LLI := $(LLVMToolDir)/lli$(EXEEXT)
252 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
254 LLVMGCCWITHPATH := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCC)
255 LLVMGXXWITHPATH := PATH=$(LLVMToolDir):$(PATH) $(LLVMGXX)
257 #--------------------------------------------------------------------
258 # Adjust to user's request
259 #--------------------------------------------------------------------
261 # Adjust LIBTOOL flags for shared libraries, or not.
262 ifndef SHARED_LIBRARY
263 LibTool.Flags += --tag=disable-shared
265 LD.Flags += -rpath $(LibDir)
275 # Adjust settings for verbose mode
278 LibTool.Flags += --silent
279 AR.Flags += >/dev/null 2>/dev/null
280 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
282 ConfigureScriptFLAGS :=
285 # By default, strip symbol information from executable
287 Strip := $(PLATFORMSTRIPOPTS)
288 StripWarnMsg := "(without symbols)"
291 # Adjust linker flags for building an executable
294 LD.Flags += -rpath $(ExmplDir) -export-dynamic
296 LD.Flags += -rpath $(ToolDir) -export-dynamic
300 #----------------------------------------------------------
301 # Options To Invoke Tools
302 #----------------------------------------------------------
304 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
306 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
307 CPP.Flags += -I$(BUILD_OBJ_DIR) \
309 -I$(BUILD_SRC_ROOT)/include \
310 -I$(BUILD_OBJ_ROOT)/include \
311 -I$(LLVM_OBJ_ROOT)/include \
312 -I$(LLVM_SRC_ROOT)/include \
313 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
315 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
316 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
317 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
319 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
320 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
321 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
323 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
324 $(CompileCommonOpts) $(LD.Flags) $(Strip)
325 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
327 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
328 Burg = $(BURG) -I $(BUILD_SRC_DIR)
329 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
330 Archive = $(AR) $(AR.Flags)
331 LArchive = $(LLVMToolDir)/llvm-ar rcsf
338 #----------------------------------------------------------
339 # Get the list of source files and compute object file
341 #----------------------------------------------------------
344 FakeSources := $(FAKE_SOURCES)
346 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
348 BaseNameSources := $(sort $(basename $(FakeSources)))
349 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
350 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
351 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
354 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
355 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
356 $(BUILD_SRC_DIR)/*.l))
358 Sources := $(SOURCES)
362 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
365 BaseNameSources := $(sort $(basename $(Sources)))
366 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
367 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
368 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
371 ###############################################################################
372 # DIRECTORIES: Handle recursive descent of directory structure
373 ###############################################################################
375 #---------------------------------------------------------
376 # Provide rules to make install dirs. This must be early
377 # in the file so they get built before dependencies
378 #---------------------------------------------------------
381 $(Verb) $(MKDIR) $(bindir)
384 $(Verb) $(MKDIR) $(libdir)
387 $(Verb) $(MKDIR) $(includedir)
390 $(Verb) $(MKDIR) $(sysconfdir)
392 # To create other directories, as needed, and timestamp their creation
394 $(Verb) $(MKDIR) $* > /dev/null
397 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
398 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
400 #---------------------------------------------------------
401 # Handle the DIRS options for sequential construction
402 #---------------------------------------------------------
407 $(RecursiveTargets)::
408 $(Verb) for dir in $(DIRS); do \
409 if [ ! -f $$dir/Makefile ]; then \
411 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
413 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
414 ($(MAKE) -C $$dir $@ ) || exit 1; \
419 #---------------------------------------------------------
420 # Handle the EXPERIMENTAL_DIRS options ensuring success
421 # after each directory is built.
422 #---------------------------------------------------------
423 ifdef EXPERIMENTAL_DIRS
424 $(RecursiveTargets)::
425 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
426 if [ ! -f $$dir/Makefile ]; then \
428 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
430 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
431 ($(MAKE) -C $$dir $@ ) || exit 0; \
436 #---------------------------------------------------------
437 # Handle the PARALLEL_DIRS options for parallel construction
438 #---------------------------------------------------------
441 SubDirs += $(PARALLEL_DIRS)
443 # Unfortunately, this list must be maintained if new recursive targets are added
444 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
445 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
446 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
447 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
448 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
449 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
451 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
454 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
456 $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
458 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
459 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
463 #---------------------------------------------------------
464 # Handle the OPTIONAL_DIRS options for directores that may
466 #---------------------------------------------------------
469 SubDirs += $(OPTIONAL_DIRS)
471 $(RecursiveTargets)::
472 $(Verb) for dir in $(OPTIONAL_DIRS); do \
473 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
474 if [ ! -f $$dir/Makefile ]; then \
476 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
478 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
479 ($(MAKE) -C$$dir $@ ) || exit 1; \
485 #---------------------------------------------------------
486 # Handle the CONFIG_FILES options
487 #---------------------------------------------------------
490 install-local:: $(sysconfdir) $(CONFIG_FILES)
491 $(Echo) Installing Configuration Files To $(sysconfdir)
492 $(Verb)for file in $(CONFIG_FILES); do \
493 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
494 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
495 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
496 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
498 $(ECHO) Error: cannot find config file $${file}. ; \
503 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
504 $(Verb)for file in $(CONFIG_FILES); do \
505 $(RM) -f $(sysconfdir)/$${file} ; \
510 ###############################################################################
511 # Library Build Rules: Four ways to build a library
512 ###############################################################################
514 #---------------------------------------------------------
515 # Bytecode Module Targets:
516 # If the user set MODULE_NAME then they want to build a
517 # bytecode module from the sources. We compile all the
518 # sources and link it together into a single bytecode
520 #---------------------------------------------------------
524 Module := $(LibDir)/$(MODULE_NAME).bc
525 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
527 ifdef EXPORTED_SYMBOL_FILE
528 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
531 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
532 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
533 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
535 all-local:: $(Module)
538 ifneq ($(strip $(Module)),)
539 -$(Verb) $(RM) -f $(Module)
542 ifdef BYTECODE_DESTINATION
543 ModuleDestDir := $(BYTECODE_DESTINATION)
545 ModuleDestDir := $(libdir)
548 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
550 install-module:: $(DestModule)
551 install-local:: $(DestModule)
553 $(DestModule): $(ModuleDestDir) $(Module)
554 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
555 $(Verb) $(INSTALL) $(Module) $@
558 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
559 -$(Verb) $(RM) -f $(DestModule)
563 # if we're building a library ...
566 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
567 LIBRARYNAME := $(strip $(LIBRARYNAME))
568 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
569 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
570 LibName.O := $(LibDir)/$(LIBRARYNAME).o
571 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
573 #---------------------------------------------------------
574 # Shared Library Targets:
575 # If the user asked for a shared library to be built
576 # with the SHARED_LIBRARY variable, then we provide
577 # targets for building them.
578 #---------------------------------------------------------
581 all-local:: $(LibName.LA)
583 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
584 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
585 $(Verb) $(Link) -o $@ $(ObjectsLO)
586 $(Verb) $(LTInstall) $@ $(LibDir)
589 ifneq ($(strip $(LibName.LA)),)
590 -$(Verb) $(RM) -f $(LibName.LA)
593 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
595 install-local:: $(DestSharedLib)
597 $(DestSharedLib): $(libdir) $(LibName.LA)
598 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
599 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
600 $(Verb) $(LIBTOOL) --finish $(libdir)
603 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
604 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
608 #---------------------------------------------------------
609 # Bytecode Library Targets:
610 # If the user asked for a bytecode library to be built
611 # with the BYTECODE_LIBRARY variable, then we provide
612 # targets for building them.
613 #---------------------------------------------------------
614 ifdef BYTECODE_LIBRARY
616 # make the C and C++ compilers strip debug info out of bytecode libraries.
617 BCCompile.C += -Wa,-strip-debug
618 BCCompile.CXX += -Wa,-strip-debug
620 all-local:: $(LibName.BCA)
622 ifdef EXPORTED_SYMBOL_FILE
623 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
624 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
626 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
627 $(LLVMToolDir)/llvm-ar
628 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
630 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
632 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
634 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
635 $(LLVMToolDir)/llvm-ar
636 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
638 $(Verb) $(LArchive) $@ $(ObjectsBC)
643 ifneq ($(strip $(LibName.BCA)),)
644 -$(Verb) $(RM) -f $(LibName.BCA)
647 ifdef BYTECODE_DESTINATION
648 BytecodeDestDir := $(BYTECODE_DESTINATION)
650 BytecodeDestDir := $(libdir)
653 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
655 install-bytecode-local:: $(DestBytecodeLib)
657 install-local:: $(DestBytecodeLib)
659 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
660 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
661 $(Verb) $(INSTALL) $(LibName.BCA) $@
664 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
665 -$(Verb) $(RM) -f $(DestBytecodeLib)
669 #---------------------------------------------------------
670 # ReLinked Library Targets:
671 # If the user didn't explicitly forbid building a
672 # relinked then we provide targets for building them.
673 #---------------------------------------------------------
674 ifndef DONT_BUILD_RELINKED
676 all-local:: $(LibName.O)
678 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
679 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
680 $(Verb) $(Relink) -o $@ $(ObjectsO)
683 ifneq ($(strip $(LibName.O)),)
684 -$(Verb) $(RM) -f $(LibName.O)
687 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
689 install-local:: $(DestRelinkedLib)
691 $(DestRelinkedLib): $(libdir) $(LibName.O)
692 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
693 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
696 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
697 -$(Verb) $(RM) -f $(DestRelinkedLib)
701 #---------------------------------------------------------
702 # Archive Library Targets:
703 # If the user wanted a regular archive library built,
704 # then we provide targets for building them.
705 #---------------------------------------------------------
708 all-local:: $(LibName.A)
710 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
711 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
713 $(Verb) $(Archive) $@ $(ObjectsO)
717 ifneq ($(strip $(LibName.A)),)
718 -$(Verb) $(RM) -f $(LibName.A)
721 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
723 install-local:: $(DestArchiveLib)
725 $(DestArchiveLib): $(libdir) $(LibName.A)
726 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
727 $(Verb) $(MKDIR) $(libdir)
728 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
731 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
732 -$(Verb) $(RM) -f $(DestArchiveLib)
739 ###############################################################################
740 # Tool Build Rules: Build executable tool based on TOOLNAME option
741 ###############################################################################
745 #---------------------------------------------------------
746 # Handle the special "JIT" value for LLVM_LIBS which is a
747 # shorthand for a bunch of libraries that get the correct
748 # JIT support for a tool that runs JIT.
749 #---------------------------------------------------------
750 ifeq ($(LLVMLIBS),JIT)
752 # Make sure we can get our own symbols in the tool
755 # Generic JIT libraries
756 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
758 # You can enable the X86 JIT on a non-X86 host by setting the flag
759 # ENABLE_X86_JIT on the make command line. If not, it will still be
760 # enabled automagically on an X86 host.
765 # What the X86 JIT requires
770 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
771 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
772 # enabled automagically on an SparcV9 host.
773 ifeq ($(ARCH), Sparc)
774 ENABLE_SPARCV9_JIT = 1
777 # What the Sparc JIT requires
778 ifdef ENABLE_SPARCV9_JIT
779 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
780 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
781 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
782 LLVMDataStructure.a LLVMSparcV9RegAlloc
785 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
786 # ENABLE_PPC_JIT on the make command line. If not, it will still be
787 # enabled automagically on an PowerPC host.
788 ifeq ($(ARCH), PowerPC)
792 # What the PowerPC JIT requires
794 JIT_LIBS += LLVMPowerPC
797 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
798 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
799 LLVMSystem.a $(PLATFORMLIBDL)
802 #---------------------------------------------------------
803 # Set up variables for building a tool.
804 #---------------------------------------------------------
806 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
808 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
810 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
811 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
812 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
813 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
814 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
815 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
816 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
817 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
819 #---------------------------------------------------------
820 # Tell make that we need to rebuild subdirectories before
821 # we can link the tool. This affects things like LLI which
822 # has library subdirectories.
823 #---------------------------------------------------------
824 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
826 #---------------------------------------------------------
827 # Provide targets for building the tools
828 #---------------------------------------------------------
829 all-local:: $(ToolBuildPath)
832 ifneq ($(strip $(ToolBuildPath)),)
833 -$(Verb) $(RM) -f $(ToolBuildPath)
837 $(ToolBuildPath): $(ExmplDir)/.dir
839 $(ToolBuildPath): $(ToolDir)/.dir
842 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
843 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
844 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
845 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
846 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
848 DestTool = $(bindir)/$(TOOLNAME)
850 install-local:: $(DestTool)
852 $(DestTool): $(bindir) $(ToolBuildPath)
853 $(Echo) Installing $(BuildMode) $(DestTool)
854 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
857 $(Echo) Uninstalling $(BuildMode) $(DestTool)
858 -$(Verb) $(RM) -f $(DestTool)
862 ###############################################################################
863 # Object Build Rules: Build object files based on sources
864 ###############################################################################
866 # Provide rule sets for when dependency generation is enabled
867 ifndef DISABLE_AUTO_DEPENDENCIES
869 #---------------------------------------------------------
870 # Create .lo files in the ObjDir directory from the .cpp and .c files...
871 #---------------------------------------------------------
874 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
875 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
876 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
877 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
878 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
880 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
881 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
882 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
883 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
884 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
886 #---------------------------------------------------------
887 # Create .o files in the ObjDir directory from the .cpp and .c files...
888 #---------------------------------------------------------
891 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
892 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
893 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
894 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
895 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
897 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
898 $(Echo) "Compiling $*.c for $(BuildMode) build"
899 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
900 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
901 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
905 #---------------------------------------------------------
906 # Create .bc files in the ObjDir directory from .cpp and .c files...
907 #---------------------------------------------------------
908 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
909 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
910 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
911 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
912 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
914 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
915 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
916 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
917 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
918 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
920 # Provide alternate rule sets if dependencies are disabled
925 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
926 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
927 $(LTCompile.CXX) $< -o $@
929 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
930 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
931 $(LTCompile.C) $< -o $@
935 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
936 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
937 $(Compile.CXX) $< -o $@
939 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
940 $(Echo) "Compiling $*.c for $(BuildMode) build"
941 $(Compile.C) $< -o $@
944 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
945 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
946 $(BCCompile.CXX) $< -o $@
948 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
949 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
950 $(BCCompile.C) $< -o $@
954 #---------------------------------------------------------
955 # Provide rule to build .bc files from .ll sources,
956 # regardless of dependencies
957 #---------------------------------------------------------
958 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
959 $(Echo) "Compiling $*.ll for $(BuildMode) build"
960 $(Verb) $(LLVMAS) $< -f -o $@
962 ###############################################################################
963 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
964 ###############################################################################
968 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
969 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
970 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
971 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
973 # All of these files depend on tblgen and the .td files.
974 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
976 # INCFiles rule: All of the tblgen generated files are emitted to
977 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
978 # us to only "touch" the real file if the contents of it change. IOW, if
979 # tblgen is modified, all of the .inc.tmp files are regereated, but no
980 # dependencies of the .inc files are, unless the contents of the .inc file
982 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
983 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
985 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
986 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
987 $(Echo) "Building $(<F) register names with tblgen"
988 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
990 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
991 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
992 $(Echo) "Building $(<F) register information header with tblgen"
993 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
995 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
996 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
997 $(Echo) "Building $(<F) register info implementation with tblgen"
998 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1000 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1001 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1002 $(Echo) "Building $(<F) instruction names with tblgen"
1003 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1005 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1006 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1007 $(Echo) "Building $(<F) instruction information with tblgen"
1008 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1010 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1011 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1012 $(Echo) "Building $(<F) assembly writer with tblgen"
1013 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1015 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1016 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1017 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1018 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1020 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1021 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1022 $(Echo) "Building $(<F) code emitter with tblgen"
1023 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1026 -$(Verb) $(RM) -f $(INCFiles)
1030 ###############################################################################
1031 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1032 ###############################################################################
1034 #---------------------------------------------------------
1035 # Provide rules for generating a .cpp source file from
1036 # (f)lex input sources.
1037 #---------------------------------------------------------
1039 LexFiles := $(filter %.l,$(Sources))
1041 ifneq ($(LexFiles),)
1043 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1045 .PRECIOUS: $(LexOutput)
1047 # Note the extra sed filtering here, used to cut down on the warnings emited
1048 # by GCC. The last line is a gross hack to work around flex aparently not
1049 # being able to resize the buffer on a large token input. Currently, for
1050 # uninitialized string buffers in LLVM we can generate very long tokens, so
1051 # this is a hack around it.
1052 # FIXME. (f.e. char Buffer[10000] )
1054 $(Echo) Flexing $*.l
1055 $(Verb) $(FLEX) -t $< | \
1056 $(SED) 's/void yyunput/inline void yyunput/' | \
1057 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1058 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1062 -$(Verb) $(RM) -f $(LexOutput)
1063 $(Verb) $(RM) -f $(LexOutput)
1067 #---------------------------------------------------------
1068 # Provide rules for generating a .cpp and .h source files
1069 # from yacc (bison) input sources.
1070 #---------------------------------------------------------
1072 YaccFiles := $(filter %.y,$(Sources))
1073 ifneq ($(YaccFiles),)
1074 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1076 .PRECIOUS: $(YaccOutput)
1078 # Cancel built-in rules for yacc
1083 # Rule for building the bison parsers...
1085 $(Echo) "Bisoning $*.y"
1086 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1087 $(Verb) $(MV) -f $*.tab.c $*.cpp
1088 $(Verb) $(MV) -f $*.tab.h $*.h
1091 -$(Verb) $(RM) -f $(YaccOutput)
1092 $(Verb) $(RM) -f $(YaccOutput)
1095 ###############################################################################
1096 # OTHER RULES: Other rules needed
1097 ###############################################################################
1099 # To create postscript files from dot files...
1100 ifneq ($(DOT),false)
1102 $(DOT) -Tps < $< > $@
1105 $(Echo) "Cannot build $@: The program dot is not installed"
1108 # This rules ensures that header files that are removed still have a rule for
1109 # which they can be "generated." This allows make to ignore them and
1110 # reproduce the dependency lists.
1113 # Define clean-local to clean the current directory. Note that this uses a
1114 # very conservative approach ensuring that empty variables do not cause
1115 # errors or disastrous removal.
1117 ifneq ($(strip $(ObjDir)),)
1118 -$(Verb) $(RM) -rf $(ObjDir)
1120 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1121 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1122 -$(Verb) $(RM) -f *$(SHLIBEXT)
1126 -$(Verb) $(RM) -rf Debug Release Profile
1128 # Build tags database for Emacs/Xemacs:
1132 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1133 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1134 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1135 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1136 -name '*.cpp' -o -name '*.h' | \
1137 $(ETAGS) $(ETAGSFLAGS) -
1140 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1141 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1142 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1143 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1144 \( -name '*.cpp' -o -name '*.h' \) -print | \
1145 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1148 ###############################################################################
1149 # DEPENDENCIES: Include the dependency files if we should
1150 ###############################################################################
1151 ifndef DISABLE_AUTO_DEPENDENCIES
1153 # If its not one of the cleaning targets
1154 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1156 # Get the list of dependency files
1157 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1158 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1160 -include /dev/null $(DependFiles)
1166 ###############################################################################
1167 # CHECK: Running the test suite
1168 ###############################################################################
1171 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1172 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1173 $(EchoCmd) Running test suite ; \
1174 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1175 TESTSUITE=$(TESTSUITE) ; \
1177 $(EchoCmd) No Makefile in test directory ; \
1180 $(EchoCmd) No test directory ; \
1183 ###############################################################################
1184 # DISTRIBUTION: Handle construction of a distribution tarball
1185 ###############################################################################
1187 #------------------------------------------------------------------------
1188 # Define distribution related variables
1189 #------------------------------------------------------------------------
1190 DistName := $(LLVM_TARBALL_NAME)
1191 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1192 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1193 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1194 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1195 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1196 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1197 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1198 Makefile.config.in configure autoconf
1199 DistOther := $(notdir $(wildcard \
1200 $(BUILD_SRC_DIR)/*.h \
1201 $(BUILD_SRC_DIR)/*.td \
1202 $(BUILD_SRC_DIR)/*.def \
1203 $(BUILD_SRC_DIR)/*.ll \
1204 $(BUILD_SRC_DIR)/*.in))
1205 DistSubDirs := $(SubDirs)
1206 DistSources = $(Sources) $(EXTRA_DIST)
1207 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1209 #------------------------------------------------------------------------
1210 # We MUST build distribution with OBJ_DIR != SRC_DIR
1211 #------------------------------------------------------------------------
1212 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1213 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1214 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1218 #------------------------------------------------------------------------
1219 # Prevent catastrophic remove
1220 #------------------------------------------------------------------------
1221 ifeq ($(LLVM_TARBALL_NAME),)
1222 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1225 #------------------------------------------------------------------------
1226 # Prevent attempt to run dist targets from anywhere but the top level
1227 #------------------------------------------------------------------------
1230 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1231 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1235 #------------------------------------------------------------------------
1236 # Provide the top level targets
1237 #------------------------------------------------------------------------
1239 dist-gzip:: $(DistTarGZip)
1241 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1242 $(Echo) Packing gzipped distribution tar file.
1243 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1244 $(GZIP) -c > "$(DistTarGZip)"
1246 dist-bzip2:: $(DistTarBZ2)
1248 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1249 $(Echo) Packing bzipped distribution tar file.
1250 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1251 $(BZIP2) -c >$(DistTarBZ2)
1253 dist-zip:: $(DistZip)
1255 $(DistZip) : $(TopDistDir)/.makedistdir
1256 $(Echo) Packing zipped distribution file.
1257 $(Verb) rm -f $(DistZip)
1258 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1260 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1261 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1263 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1265 dist-check:: $(DistTarGZip)
1266 $(Echo) Checking distribution tar file.
1267 $(Verb) if test -d $(DistCheckDir) ; then \
1268 $(RM) -rf $(DistCheckDir) ; \
1270 $(Verb) $(MKDIR) $(DistCheckDir)
1271 $(Verb) cd $(DistCheckDir) && \
1272 $(MKDIR) $(DistCheckDir)/build && \
1273 $(MKDIR) $(DistCheckDir)/install && \
1274 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1276 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1277 --srcdir=../$(DistName) && \
1280 $(MAKE) install && \
1281 $(MAKE) uninstall && \
1284 $(MAKE) dist-clean && \
1285 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1288 $(Echo) Cleaning distribution files
1289 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1294 #------------------------------------------------------------------------
1295 # Provide the recursive distdir target for building the distribution directory
1296 #------------------------------------------------------------------------
1297 distdir: $(DistDir)/.makedistdir
1298 $(DistDir)/.makedistdir: $(DistSources)
1299 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1300 if test -d "$(DistDir)" ; then \
1301 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1304 $(EchoCmd) Removing old $(DistDir) ; \
1305 $(RM) -rf $(DistDir); \
1306 $(EchoCmd) Making 'all' to verify build ; \
1309 $(Echo) Building Distribution Directory $(DistDir)
1310 $(Verb) $(MKDIR) $(DistDir)
1311 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1312 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1313 for file in $(DistFiles) ; do \
1315 $(BUILD_SRC_DIR)/*) \
1316 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1318 $(BUILD_SRC_ROOT)/*) \
1319 file=`echo "$$file" | \
1320 sed "s#^$$srcrootstrip/##"` \
1323 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1324 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1325 from_dir="$(BUILD_SRC_DIR)" ; \
1326 elif test -f "$$file" || test -d "$$file" ; then \
1329 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1330 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1331 to_dir="$(DistDir)/$$dir"; \
1332 $(MKDIR) "$$to_dir" ; \
1334 to_dir="$(DistDir)"; \
1336 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1337 if test -n "$$mid_dir" ; then \
1338 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1340 if test -d "$$from_dir/$$file"; then \
1341 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1342 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1343 $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1345 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1346 elif test -f "$$from_dir/$$file" ; then \
1347 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1348 elif test -L "$$from_dir/$$file" ; then \
1349 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1350 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1351 $(EchoCmd) "===== WARNING: Distribution Source " \
1352 "$$from_dir/$$file Not Found!" ; \
1353 elif test "$(Verb)" != '@' ; then \
1354 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1357 $(Verb) for subdir in $(DistSubDirs) ; do \
1358 if test "$$subdir" \!= "." ; then \
1359 new_distdir="$(DistDir)/$$subdir" ; \
1360 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1361 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1365 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1366 $(EchoCmd) Eliminating CVS directories from distribution ; \
1367 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1368 $(MAKE) dist-hook ; \
1369 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1370 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1371 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1372 -o ! -type d ! -perm -444 -exec \
1373 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1374 || chmod -R a+r $(DistDir) ; \
1377 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1383 ###############################################################################
1384 # TOP LEVEL - targets only to apply at the top level directory
1385 ###############################################################################
1389 #------------------------------------------------------------------------
1390 # Install support for the project's include files:
1391 #------------------------------------------------------------------------
1393 $(Echo) Installing include files
1394 $(Verb) $(MKDIR) $(includedir)
1395 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1396 cd $(BUILD_SRC_ROOT)/include && \
1397 find . -path '*/Internal' -prune -o '(' -type f \
1398 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1399 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1403 $(Echo) Uninstalling include files
1404 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1405 cd $(BUILD_SRC_ROOT)/include && \
1406 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1407 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1408 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1413 #------------------------------------------------------------------------
1414 # Print out the directories used for building
1415 #------------------------------------------------------------------------
1417 $(Echo) "BuildMode : " '$(BuildMode)'
1418 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1419 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1420 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1421 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1422 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1423 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1424 $(Echo) "libdir : " '$(libdir)'
1425 $(Echo) "bindir : " '$(bindir)'
1426 $(Echo) "sysconfdir : " '$(sysconfdir)'
1427 $(Echo) "UserTargets : " '$(UserTargets)'
1428 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1429 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1430 $(Echo) "ObjDir : " '$(ObjDir)'
1431 $(Echo) "LibDir : " '$(LibDir)'
1432 $(Echo) "ToolDir : " '$(ToolDir)'
1433 $(Echo) "ExmplDir : " '$(ExmplDir)'
1434 $(Echo) "Sources : " '$(Sources)'
1435 $(Echo) "TDFiles : " '$(TDFiles)'
1436 $(Echo) "INCFiles : " '$(INCFiles)'
1437 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1438 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1439 $(Echo) "Compile.C : " '$(Compile.C)'
1440 $(Echo) "Archive : " '$(Archive)'
1441 $(Echo) "YaccFiles : " '$(YaccFiles)'
1442 $(Echo) "LexFiles : " '$(LexFiles)'
1443 $(Echo) "Module : " '$(Module)'