1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file was developed by the LLVM research group and is distributed under
6 # the University of Illinois Open Source License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
10 # This file is included by all of the LLVM makefiles. For details on how to use
11 # it properly, please see the document MakefileGuide.html in the docs directory.
13 #===-----------------------------------------------------------------------====
15 ################################################################################
16 # TARGETS: Define standard targets that can be invoked
17 ################################################################################
19 #--------------------------------------------------------------------
20 # Define the various target sets
21 #--------------------------------------------------------------------
22 RecursiveTargets := all clean clean-all install uninstall install-bytecode
23 LocalTargets := all-local clean-local clean-all-local check-local \
24 install-local printvars uninstall-local \
25 install-bytecode-local
26 TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
28 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29 InternalTargets := preconditions distdir dist-hook
31 ################################################################################
32 # INITIALIZATION: Basic things the makefile needs
33 ################################################################################
35 #--------------------------------------------------------------------
36 # Set the VPATH so that we can find source files.
37 #--------------------------------------------------------------------
38 VPATH=$(BUILD_SRC_DIR)
40 #--------------------------------------------------------------------
41 # Reset the list of suffixes we know how to build
42 #--------------------------------------------------------------------
44 .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47 #--------------------------------------------------------------------
48 # Mark all of these targets as phony to avoid implicit rule search
49 #--------------------------------------------------------------------
50 .PHONY: $(UserTargets) $(InternalTargets)
52 #--------------------------------------------------------------------
53 # Make sure all the user-target rules are double colon rules and
54 # they are defined first.
55 #--------------------------------------------------------------------
59 ################################################################################
60 # PRECONDITIONS: that which must be built/checked first
61 ################################################################################
63 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
64 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(BUILD_SRC_ROOT)/configure
67 ConfigStatusScript := $(BUILD_OBJ_ROOT)/config.status
68 LConfigStatusScript:= $(LLVM_OBJ_ROOT)/config.status
69 MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
70 MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
71 PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
73 preconditions : $(PreConditions)
75 #------------------------------------------------------------------------
76 # Make sure the BUILT_SOURCES are built first
77 #------------------------------------------------------------------------
78 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
81 ifneq ($(strip $(BUILT_SOURCES)),)
82 -$(Verb) $(RM) -f $(BUILT_SOURCES)
85 ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT))
87 $(Verb) if test -x config.status ; then \
88 $(EchoCmd) Wiping out $(BUILD_OBJ_ROOT) ; \
89 $(MKDIR) .spotless.save ; \
90 $(MV) config.status .spotless.save ; \
91 $(MV) mklib .spotless.save ; \
92 $(MV) projects .spotless.save ; \
94 $(MV) .spotless.save/config.status . ; \
95 $(MV) .spotless.save/mklib . ; \
96 $(MV) .spotless.save/projects . ; \
97 $(RM) -rf .spotless.save ; \
98 $(EchoCmd) Rebuilding configuration of $(BUILD_OBJ_ROOT) ; \
99 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
100 $(ConfigStatusScript) ; \
102 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
106 $(BUILT_SOURCES) : $(ObjMakefiles)
108 #------------------------------------------------------------------------
109 # Make sure we're not using a stale configuration
110 #------------------------------------------------------------------------
112 $(Echo) Reconfiguring $(BUILD_OBJ_ROOT)
113 $(Verb) cd $(BUILD_OBJ_ROOT) && \
114 if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \
115 $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \
117 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
118 $(ConfigStatusScript)
120 .PRECIOUS: $(ConfigStatusScript)
121 $(ConfigStatusScript): $(ConfigureScript)
122 $(Echo) Reconfiguring with $<
123 $(Verb) cd $(BUILD_OBJ_ROOT) && \
124 if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \
125 $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \
127 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
128 $(ConfigStatusScript)
130 #------------------------------------------------------------------------
131 # Make sure the configuration makefile is up to date
132 #------------------------------------------------------------------------
133 $(MakefileConfig): $(MakefileConfigIn) $(LConfigStatusScript)
134 $(Echo) Regenerating $@
135 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(LConfigStatusScript) Makefile.config
137 #------------------------------------------------------------------------
138 # If the Makefile in the source tree has been updated, copy it over into the
139 # build tree. But, only do this if the source and object makefiles differ
140 #------------------------------------------------------------------------
141 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
143 Makefile: $(BUILD_SRC_DIR)/Makefile
144 $(Echo) "Updating Makefile"
145 $(Verb) $(MKDIR) $(@D)
146 $(Verb) $(CP) -f $< $@
148 # Copy the Makefile.* files unless we're in the root directory which avoids
149 # the copying of Makefile.config.in or other things that should be explicitly
151 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
153 *Makefile.rules) ;; \
155 *) $(Echo) "Updating $(@F)" ; \
162 #------------------------------------------------------------------------
163 # Set up the basic dependencies
164 #------------------------------------------------------------------------
165 $(UserTargets):: $(PreConditions)
169 clean-all:: clean-local clean-all-local
170 install:: install-local
171 uninstall:: uninstall-local
172 install-local:: all-local
173 install-bytecode:: install-bytecode-local
175 ###############################################################################
176 # VARIABLES: Set up various variables based on configuration data
177 ###############################################################################
179 #--------------------------------------------------------------------
180 # Variables derived from configuration we are building
181 #--------------------------------------------------------------------
184 ifdef ENABLE_PROFILING
186 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
187 C.Flags := -O3 -DNDEBUG -pg
188 LD.Flags := -O3 -DNDEBUG -pg
190 ifdef ENABLE_OPTIMIZED
192 # Don't use -fomit-frame-pointer on FreeBSD
193 ifneq ($(OS),FreeBSD)
194 OmitFramePointer := -fomit-frame-pointer
196 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \
198 C.Flags := -O3 -DNDEBUG $(OmitFramePointer)
199 LD.Flags := -O3 -DNDEBUG
202 CXX.Flags := -g -D_DEBUG
203 C.Flags := -g -D_DEBUG
204 LD.Flags := -g -D_DEBUG
209 CXX.Flags += $(CXXFLAGS)
211 CPP.Flags += $(CPPFLAGS)
212 LD.Flags += $(LDFLAGS)
214 LibTool.Flags := --tag=CXX
216 #--------------------------------------------------------------------
217 # Directory locations
218 #--------------------------------------------------------------------
219 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
220 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
221 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
222 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
223 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
224 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
225 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
226 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
228 #--------------------------------------------------------------------
229 # Full Paths To Compiled Tools and Utilities
230 #--------------------------------------------------------------------
231 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
234 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
237 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
240 BURG := $(LLVMToolDir)/burg$(EXEEXT)
243 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
246 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
249 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
252 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
255 LLI := $(LLVMToolDir)/lli$(EXEEXT)
258 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
260 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
261 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
263 #--------------------------------------------------------------------
264 # Adjust to user's request
265 #--------------------------------------------------------------------
267 # Adjust LIBTOOL flags for shared libraries, or not.
268 ifndef SHARED_LIBRARY
269 LibTool.Flags += --tag=disable-shared
271 LD.Flags += -rpath $(LibDir)
281 # Adjust settings for verbose mode
284 LibTool.Flags += --silent
285 AR.Flags += >/dev/null 2>/dev/null
286 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
288 ConfigureScriptFLAGS :=
291 # By default, strip symbol information from executable
293 Strip := $(PLATFORMSTRIPOPTS)
294 StripWarnMsg := "(without symbols)"
297 # Adjust linker flags for building an executable
300 LD.Flags += -rpath $(ExmplDir) -export-dynamic
302 LD.Flags += -rpath $(ToolDir) -export-dynamic
306 #----------------------------------------------------------
307 # Options To Invoke Tools
308 #----------------------------------------------------------
310 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
312 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
313 CPP.Flags += -I$(BUILD_OBJ_DIR) \
315 -I$(BUILD_SRC_ROOT)/include \
316 -I$(BUILD_OBJ_ROOT)/include \
317 -I$(LLVM_OBJ_ROOT)/include \
318 -I$(LLVM_SRC_ROOT)/include \
319 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
321 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
322 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
323 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
325 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
326 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
327 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
329 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
330 $(CompileCommonOpts) $(LD.Flags) $(Strip)
331 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
333 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
334 Burg = $(BURG) -I $(BUILD_SRC_DIR)
335 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
336 Archive = $(AR) $(AR.Flags)
337 LArchive = $(LLVMToolDir)/llvm-ar rcsf
344 #----------------------------------------------------------
345 # Get the list of source files and compute object file
347 #----------------------------------------------------------
350 FakeSources := $(FAKE_SOURCES)
352 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
354 BaseNameSources := $(sort $(basename $(FakeSources)))
355 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
356 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
357 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
360 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
361 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
362 $(BUILD_SRC_DIR)/*.l))
364 Sources := $(SOURCES)
368 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
371 BaseNameSources := $(sort $(basename $(Sources)))
372 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
373 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
374 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
377 ###############################################################################
378 # DIRECTORIES: Handle recursive descent of directory structure
379 ###############################################################################
381 #---------------------------------------------------------
382 # Provide rules to make install dirs. This must be early
383 # in the file so they get built before dependencies
384 #---------------------------------------------------------
387 $(Verb) $(MKDIR) $(bindir)
390 $(Verb) $(MKDIR) $(libdir)
393 $(Verb) $(MKDIR) $(includedir)
396 $(Verb) $(MKDIR) $(sysconfdir)
398 # To create other directories, as needed, and timestamp their creation
400 $(Verb) $(MKDIR) $* > /dev/null
403 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
404 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
406 #---------------------------------------------------------
407 # Handle the DIRS options for sequential construction
408 #---------------------------------------------------------
413 $(RecursiveTargets)::
414 $(Verb) for dir in $(DIRS); do \
415 if [ ! -f $$dir/Makefile ]; then \
417 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
419 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
420 ($(MAKE) -C $$dir $@ ) || exit 1; \
425 #---------------------------------------------------------
426 # Handle the EXPERIMENTAL_DIRS options ensuring success
427 # after each directory is built.
428 #---------------------------------------------------------
429 ifdef EXPERIMENTAL_DIRS
430 $(RecursiveTargets)::
431 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
432 if [ ! -f $$dir/Makefile ]; then \
434 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
436 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
437 ($(MAKE) -C $$dir $@ ) || exit 0; \
442 #---------------------------------------------------------
443 # Handle the PARALLEL_DIRS options for parallel construction
444 #---------------------------------------------------------
447 SubDirs += $(PARALLEL_DIRS)
449 # Unfortunately, this list must be maintained if new recursive targets are added
450 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
451 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
452 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
453 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
454 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
455 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
457 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
460 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
462 $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
464 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
465 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
469 #---------------------------------------------------------
470 # Handle the OPTIONAL_DIRS options for directores that may
472 #---------------------------------------------------------
475 SubDirs += $(OPTIONAL_DIRS)
477 $(RecursiveTargets)::
478 $(Verb) for dir in $(OPTIONAL_DIRS); do \
479 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
480 if [ ! -f $$dir/Makefile ]; then \
482 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
484 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
485 ($(MAKE) -C$$dir $@ ) || exit 1; \
491 #---------------------------------------------------------
492 # Handle the CONFIG_FILES options
493 #---------------------------------------------------------
496 install-local:: $(sysconfdir) $(CONFIG_FILES)
497 $(Echo) Installing Configuration Files To $(sysconfdir)
498 $(Verb)for file in $(CONFIG_FILES); do \
499 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
500 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
501 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
502 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
504 $(ECHO) Error: cannot find config file $${file}. ; \
509 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
510 $(Verb)for file in $(CONFIG_FILES); do \
511 $(RM) -f $(sysconfdir)/$${file} ; \
516 ###############################################################################
517 # Library Build Rules: Four ways to build a library
518 ###############################################################################
520 #---------------------------------------------------------
521 # Bytecode Module Targets:
522 # If the user set MODULE_NAME then they want to build a
523 # bytecode module from the sources. We compile all the
524 # sources and link it together into a single bytecode
526 #---------------------------------------------------------
530 Module := $(LibDir)/$(MODULE_NAME).bc
531 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
533 ifdef EXPORTED_SYMBOL_FILE
534 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
537 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
538 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
539 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
541 all-local:: $(Module)
544 ifneq ($(strip $(Module)),)
545 -$(Verb) $(RM) -f $(Module)
548 ifdef BYTECODE_DESTINATION
549 ModuleDestDir := $(BYTECODE_DESTINATION)
551 ModuleDestDir := $(libdir)
554 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
556 install-module:: $(DestModule)
557 install-local:: $(DestModule)
559 $(DestModule): $(ModuleDestDir) $(Module)
560 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
561 $(Verb) $(INSTALL) $(Module) $@
564 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
565 -$(Verb) $(RM) -f $(DestModule)
569 # if we're building a library ...
572 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
573 LIBRARYNAME := $(strip $(LIBRARYNAME))
574 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
575 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
576 LibName.O := $(LibDir)/$(LIBRARYNAME).o
577 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
579 #---------------------------------------------------------
580 # Shared Library Targets:
581 # If the user asked for a shared library to be built
582 # with the SHARED_LIBRARY variable, then we provide
583 # targets for building them.
584 #---------------------------------------------------------
587 all-local:: $(LibName.LA)
589 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
590 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
591 $(Verb) $(Link) -o $@ $(ObjectsLO)
592 $(Verb) $(LTInstall) $@ $(LibDir)
595 ifneq ($(strip $(LibName.LA)),)
596 -$(Verb) $(RM) -f $(LibName.LA)
599 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
601 install-local:: $(DestSharedLib)
603 $(DestSharedLib): $(libdir) $(LibName.LA)
604 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
605 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
606 $(Verb) $(LIBTOOL) --finish $(libdir)
609 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
610 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
614 #---------------------------------------------------------
615 # Bytecode Library Targets:
616 # If the user asked for a bytecode library to be built
617 # with the BYTECODE_LIBRARY variable, then we provide
618 # targets for building them.
619 #---------------------------------------------------------
620 ifdef BYTECODE_LIBRARY
622 # make the C and C++ compilers strip debug info out of bytecode libraries.
623 BCCompile.C += -Wa,-strip-debug
624 BCCompile.CXX += -Wa,-strip-debug
626 all-local:: $(LibName.BCA)
628 ifdef EXPORTED_SYMBOL_FILE
629 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
630 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
632 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
633 $(LLVMToolDir)/llvm-ar
634 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
636 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
638 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
640 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
641 $(LLVMToolDir)/llvm-ar
642 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
644 $(Verb) $(LArchive) $@ $(ObjectsBC)
649 ifneq ($(strip $(LibName.BCA)),)
650 -$(Verb) $(RM) -f $(LibName.BCA)
653 ifdef BYTECODE_DESTINATION
654 BytecodeDestDir := $(BYTECODE_DESTINATION)
656 BytecodeDestDir := $(libdir)
659 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
661 install-bytecode-local:: $(DestBytecodeLib)
663 install-local:: $(DestBytecodeLib)
665 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
666 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
667 $(Verb) $(INSTALL) $(LibName.BCA) $@
670 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
671 -$(Verb) $(RM) -f $(DestBytecodeLib)
675 #---------------------------------------------------------
676 # ReLinked Library Targets:
677 # If the user didn't explicitly forbid building a
678 # relinked then we provide targets for building them.
679 #---------------------------------------------------------
680 ifndef DONT_BUILD_RELINKED
682 all-local:: $(LibName.O)
684 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
685 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
686 $(Verb) $(Relink) -o $@ $(ObjectsO)
689 ifneq ($(strip $(LibName.O)),)
690 -$(Verb) $(RM) -f $(LibName.O)
693 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
695 install-local:: $(DestRelinkedLib)
697 $(DestRelinkedLib): $(libdir) $(LibName.O)
698 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
699 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
702 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
703 -$(Verb) $(RM) -f $(DestRelinkedLib)
707 #---------------------------------------------------------
708 # Archive Library Targets:
709 # If the user wanted a regular archive library built,
710 # then we provide targets for building them.
711 #---------------------------------------------------------
714 all-local:: $(LibName.A)
716 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
717 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
719 $(Verb) $(Archive) $@ $(ObjectsO)
723 ifneq ($(strip $(LibName.A)),)
724 -$(Verb) $(RM) -f $(LibName.A)
727 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
729 install-local:: $(DestArchiveLib)
731 $(DestArchiveLib): $(libdir) $(LibName.A)
732 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
733 $(Verb) $(MKDIR) $(libdir)
734 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
737 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
738 -$(Verb) $(RM) -f $(DestArchiveLib)
745 ###############################################################################
746 # Tool Build Rules: Build executable tool based on TOOLNAME option
747 ###############################################################################
751 #---------------------------------------------------------
752 # Handle the special "JIT" value for LLVM_LIBS which is a
753 # shorthand for a bunch of libraries that get the correct
754 # JIT support for a tool that runs JIT.
755 #---------------------------------------------------------
756 ifeq ($(LLVMLIBS),JIT)
758 # Make sure we can get our own symbols in the tool
761 # Generic JIT libraries
762 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
764 # You can enable the X86 JIT on a non-X86 host by setting the flag
765 # ENABLE_X86_JIT on the make command line. If not, it will still be
766 # enabled automagically on an X86 host.
771 # What the X86 JIT requires
776 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
777 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
778 # enabled automagically on an SparcV9 host.
779 ifeq ($(ARCH), Sparc)
780 ENABLE_SPARCV9_JIT = 1
783 # What the Sparc JIT requires
784 ifdef ENABLE_SPARCV9_JIT
785 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
786 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
787 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
788 LLVMDataStructure.a LLVMSparcV9RegAlloc
791 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
792 # ENABLE_PPC_JIT on the make command line. If not, it will still be
793 # enabled automagically on an PowerPC host.
794 ifeq ($(ARCH), PowerPC)
798 # What the PowerPC JIT requires
800 JIT_LIBS += LLVMPowerPC
803 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
804 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
805 LLVMSystem.a $(PLATFORMLIBDL)
808 #---------------------------------------------------------
809 # Set up variables for building a tool.
810 #---------------------------------------------------------
812 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
814 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
816 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
817 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
818 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
819 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
820 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
821 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
822 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
823 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
825 #---------------------------------------------------------
826 # Tell make that we need to rebuild subdirectories before
827 # we can link the tool. This affects things like LLI which
828 # has library subdirectories.
829 #---------------------------------------------------------
830 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
832 #---------------------------------------------------------
833 # Provide targets for building the tools
834 #---------------------------------------------------------
835 all-local:: $(ToolBuildPath)
838 ifneq ($(strip $(ToolBuildPath)),)
839 -$(Verb) $(RM) -f $(ToolBuildPath)
843 $(ToolBuildPath): $(ExmplDir)/.dir
845 $(ToolBuildPath): $(ToolDir)/.dir
848 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
849 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
850 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
851 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
852 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
854 DestTool = $(bindir)/$(TOOLNAME)
856 install-local:: $(DestTool)
858 $(DestTool): $(bindir) $(ToolBuildPath)
859 $(Echo) Installing $(BuildMode) $(DestTool)
860 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
863 $(Echo) Uninstalling $(BuildMode) $(DestTool)
864 -$(Verb) $(RM) -f $(DestTool)
868 ###############################################################################
869 # Object Build Rules: Build object files based on sources
870 ###############################################################################
872 # Provide rule sets for when dependency generation is enabled
873 ifndef DISABLE_AUTO_DEPENDENCIES
875 #---------------------------------------------------------
876 # Create .lo files in the ObjDir directory from the .cpp and .c files...
877 #---------------------------------------------------------
880 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
881 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
882 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
883 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
884 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
886 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
887 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
888 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
889 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
890 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
892 #---------------------------------------------------------
893 # Create .o files in the ObjDir directory from the .cpp and .c files...
894 #---------------------------------------------------------
897 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
898 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
899 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
900 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
901 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
903 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
904 $(Echo) "Compiling $*.c for $(BuildMode) build"
905 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
906 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
907 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
911 #---------------------------------------------------------
912 # Create .bc files in the ObjDir directory from .cpp and .c files...
913 #---------------------------------------------------------
914 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
915 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
916 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
917 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
918 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
920 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
921 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
922 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
923 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
924 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
926 # Provide alternate rule sets if dependencies are disabled
931 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
932 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
933 $(LTCompile.CXX) $< -o $@
935 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
936 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
937 $(LTCompile.C) $< -o $@
941 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
942 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
943 $(Compile.CXX) $< -o $@
945 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
946 $(Echo) "Compiling $*.c for $(BuildMode) build"
947 $(Compile.C) $< -o $@
950 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
951 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
952 $(BCCompile.CXX) $< -o $@
954 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
955 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
956 $(BCCompile.C) $< -o $@
960 #---------------------------------------------------------
961 # Provide rule to build .bc files from .ll sources,
962 # regardless of dependencies
963 #---------------------------------------------------------
964 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
965 $(Echo) "Compiling $*.ll for $(BuildMode) build"
966 $(Verb) $(LLVMAS) $< -f -o $@
968 ###############################################################################
969 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
970 ###############################################################################
974 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
975 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
976 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
977 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
979 # All of these files depend on tblgen and the .td files.
980 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
982 # INCFiles rule: All of the tblgen generated files are emitted to
983 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
984 # us to only "touch" the real file if the contents of it change. IOW, if
985 # tblgen is modified, all of the .inc.tmp files are regereated, but no
986 # dependencies of the .inc files are, unless the contents of the .inc file
988 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
989 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
991 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
992 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
993 $(Echo) "Building $(<F) register names with tblgen"
994 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
996 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
997 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
998 $(Echo) "Building $(<F) register information header with tblgen"
999 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
1001 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1002 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1003 $(Echo) "Building $(<F) register info implementation with tblgen"
1004 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1006 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1007 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1008 $(Echo) "Building $(<F) instruction names with tblgen"
1009 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1011 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1012 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1013 $(Echo) "Building $(<F) instruction information with tblgen"
1014 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1016 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1017 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1018 $(Echo) "Building $(<F) assembly writer with tblgen"
1019 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1021 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1022 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1023 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1024 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1026 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1027 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1028 $(Echo) "Building $(<F) code emitter with tblgen"
1029 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1032 -$(Verb) $(RM) -f $(INCFiles)
1036 ###############################################################################
1037 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1038 ###############################################################################
1040 #---------------------------------------------------------
1041 # Provide rules for generating a .cpp source file from
1042 # (f)lex input sources.
1043 #---------------------------------------------------------
1045 LexFiles := $(filter %.l,$(Sources))
1047 ifneq ($(LexFiles),)
1049 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1051 .PRECIOUS: $(LexOutput)
1053 # Note the extra sed filtering here, used to cut down on the warnings emited
1054 # by GCC. The last line is a gross hack to work around flex aparently not
1055 # being able to resize the buffer on a large token input. Currently, for
1056 # uninitialized string buffers in LLVM we can generate very long tokens, so
1057 # this is a hack around it.
1058 # FIXME. (f.e. char Buffer[10000] )
1060 $(Echo) Flexing $*.l
1061 $(Verb) $(FLEX) -t $< | \
1062 $(SED) 's/void yyunput/inline void yyunput/' | \
1063 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1064 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1068 -$(Verb) $(RM) -f $(LexOutput)
1069 $(Verb) $(RM) -f $(LexOutput)
1073 #---------------------------------------------------------
1074 # Provide rules for generating a .cpp and .h source files
1075 # from yacc (bison) input sources.
1076 #---------------------------------------------------------
1078 YaccFiles := $(filter %.y,$(Sources))
1079 ifneq ($(YaccFiles),)
1080 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1082 .PRECIOUS: $(YaccOutput)
1084 # Cancel built-in rules for yacc
1089 # Rule for building the bison parsers...
1091 $(Echo) "Bisoning $*.y"
1092 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1093 $(Verb) $(MV) -f $*.tab.c $*.cpp
1094 $(Verb) $(MV) -f $*.tab.h $*.h
1097 -$(Verb) $(RM) -f $(YaccOutput)
1098 $(Verb) $(RM) -f $(YaccOutput)
1101 ###############################################################################
1102 # OTHER RULES: Other rules needed
1103 ###############################################################################
1105 # To create postscript files from dot files...
1106 ifneq ($(DOT),false)
1108 $(DOT) -Tps < $< > $@
1111 $(Echo) "Cannot build $@: The program dot is not installed"
1114 # This rules ensures that header files that are removed still have a rule for
1115 # which they can be "generated." This allows make to ignore them and
1116 # reproduce the dependency lists.
1119 # Define clean-local to clean the current directory. Note that this uses a
1120 # very conservative approach ensuring that empty variables do not cause
1121 # errors or disastrous removal.
1123 ifneq ($(strip $(ObjDir)),)
1124 -$(Verb) $(RM) -rf $(ObjDir)
1126 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1127 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1128 -$(Verb) $(RM) -f *$(SHLIBEXT)
1132 -$(Verb) $(RM) -rf Debug Release Profile
1134 # Build tags database for Emacs/Xemacs:
1138 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1139 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1140 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1141 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1142 -name '*.cpp' -o -name '*.h' | \
1143 $(ETAGS) $(ETAGSFLAGS) -
1146 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1147 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1148 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1149 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1150 \( -name '*.cpp' -o -name '*.h' \) -print | \
1151 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1154 ###############################################################################
1155 # DEPENDENCIES: Include the dependency files if we should
1156 ###############################################################################
1157 ifndef DISABLE_AUTO_DEPENDENCIES
1159 # If its not one of the cleaning targets
1160 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1162 # Get the list of dependency files
1163 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1164 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1166 -include /dev/null $(DependFiles)
1172 ###############################################################################
1173 # CHECK: Running the test suite
1174 ###############################################################################
1177 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1178 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1179 $(EchoCmd) Running test suite ; \
1180 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1181 TESTSUITE=$(TESTSUITE) ; \
1183 $(EchoCmd) No Makefile in test directory ; \
1186 $(EchoCmd) No test directory ; \
1189 ###############################################################################
1190 # DISTRIBUTION: Handle construction of a distribution tarball
1191 ###############################################################################
1193 #------------------------------------------------------------------------
1194 # Define distribution related variables
1195 #------------------------------------------------------------------------
1196 DistName := $(LLVM_TARBALL_NAME)
1197 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1198 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1199 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1200 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1201 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1202 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1203 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1204 Makefile.config.in configure autoconf
1205 DistOther := $(notdir $(wildcard \
1206 $(BUILD_SRC_DIR)/*.h \
1207 $(BUILD_SRC_DIR)/*.td \
1208 $(BUILD_SRC_DIR)/*.def \
1209 $(BUILD_SRC_DIR)/*.ll \
1210 $(BUILD_SRC_DIR)/*.in))
1211 DistSubDirs := $(SubDirs)
1212 DistSources = $(Sources) $(EXTRA_DIST)
1213 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1215 #------------------------------------------------------------------------
1216 # We MUST build distribution with OBJ_DIR != SRC_DIR
1217 #------------------------------------------------------------------------
1218 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1219 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1220 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1224 #------------------------------------------------------------------------
1225 # Prevent catastrophic remove
1226 #------------------------------------------------------------------------
1227 ifeq ($(LLVM_TARBALL_NAME),)
1228 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1231 #------------------------------------------------------------------------
1232 # Prevent attempt to run dist targets from anywhere but the top level
1233 #------------------------------------------------------------------------
1236 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1237 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1241 #------------------------------------------------------------------------
1242 # Provide the top level targets
1243 #------------------------------------------------------------------------
1245 dist-gzip:: $(DistTarGZip)
1247 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1248 $(Echo) Packing gzipped distribution tar file.
1249 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1250 $(GZIP) -c > "$(DistTarGZip)"
1252 dist-bzip2:: $(DistTarBZ2)
1254 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1255 $(Echo) Packing bzipped distribution tar file.
1256 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1257 $(BZIP2) -c >$(DistTarBZ2)
1259 dist-zip:: $(DistZip)
1261 $(DistZip) : $(TopDistDir)/.makedistdir
1262 $(Echo) Packing zipped distribution file.
1263 $(Verb) rm -f $(DistZip)
1264 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1266 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1267 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1269 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1271 dist-check:: $(DistTarGZip)
1272 $(Echo) Checking distribution tar file.
1273 $(Verb) if test -d $(DistCheckDir) ; then \
1274 $(RM) -rf $(DistCheckDir) ; \
1276 $(Verb) $(MKDIR) $(DistCheckDir)
1277 $(Verb) cd $(DistCheckDir) && \
1278 $(MKDIR) $(DistCheckDir)/build && \
1279 $(MKDIR) $(DistCheckDir)/install && \
1280 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1282 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1283 --srcdir=../$(DistName) && \
1286 $(MAKE) install && \
1287 $(MAKE) uninstall && \
1290 $(MAKE) dist-clean && \
1291 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1294 $(Echo) Cleaning distribution files
1295 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1300 #------------------------------------------------------------------------
1301 # Provide the recursive distdir target for building the distribution directory
1302 #------------------------------------------------------------------------
1303 distdir: $(DistDir)/.makedistdir
1304 $(DistDir)/.makedistdir: $(DistSources)
1305 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1306 if test -d "$(DistDir)" ; then \
1307 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1310 $(EchoCmd) Removing old $(DistDir) ; \
1311 $(RM) -rf $(DistDir); \
1312 $(EchoCmd) Making 'all' to verify build ; \
1315 $(Echo) Building Distribution Directory $(DistDir)
1316 $(Verb) $(MKDIR) $(DistDir)
1317 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1318 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1319 for file in $(DistFiles) ; do \
1321 $(BUILD_SRC_DIR)/*) \
1322 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1324 $(BUILD_SRC_ROOT)/*) \
1325 file=`echo "$$file" | \
1326 sed "s#^$$srcrootstrip/##"` \
1329 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1330 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1331 from_dir="$(BUILD_SRC_DIR)" ; \
1332 elif test -f "$$file" || test -d "$$file" ; then \
1335 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1336 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1337 to_dir="$(DistDir)/$$dir"; \
1338 $(MKDIR) "$$to_dir" ; \
1340 to_dir="$(DistDir)"; \
1342 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1343 if test -n "$$mid_dir" ; then \
1344 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1346 if test -d "$$from_dir/$$file"; then \
1347 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1348 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1349 $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1351 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1352 elif test -f "$$from_dir/$$file" ; then \
1353 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1354 elif test -L "$$from_dir/$$file" ; then \
1355 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1356 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1357 $(EchoCmd) "===== WARNING: Distribution Source " \
1358 "$$from_dir/$$file Not Found!" ; \
1359 elif test "$(Verb)" != '@' ; then \
1360 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1363 $(Verb) for subdir in $(DistSubDirs) ; do \
1364 if test "$$subdir" \!= "." ; then \
1365 new_distdir="$(DistDir)/$$subdir" ; \
1366 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1367 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1371 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1372 $(EchoCmd) Eliminating CVS directories from distribution ; \
1373 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1374 $(MAKE) dist-hook ; \
1375 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1376 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1377 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1378 -o ! -type d ! -perm -444 -exec \
1379 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1380 || chmod -R a+r $(DistDir) ; \
1383 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1389 ###############################################################################
1390 # TOP LEVEL - targets only to apply at the top level directory
1391 ###############################################################################
1395 #------------------------------------------------------------------------
1396 # Install support for the project's include files:
1397 #------------------------------------------------------------------------
1399 $(Echo) Installing include files
1400 $(Verb) $(MKDIR) $(includedir)
1401 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1402 cd $(BUILD_SRC_ROOT)/include && \
1403 find . -path '*/Internal' -prune -o '(' -type f \
1404 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1405 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1409 $(Echo) Uninstalling include files
1410 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1411 cd $(BUILD_SRC_ROOT)/include && \
1412 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1413 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1414 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1419 #------------------------------------------------------------------------
1420 # Print out the directories used for building
1421 #------------------------------------------------------------------------
1423 $(Echo) "BuildMode : " '$(BuildMode)'
1424 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1425 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1426 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1427 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1428 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1429 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1430 $(Echo) "libdir : " '$(libdir)'
1431 $(Echo) "bindir : " '$(bindir)'
1432 $(Echo) "sysconfdir : " '$(sysconfdir)'
1433 $(Echo) "UserTargets : " '$(UserTargets)'
1434 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1435 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1436 $(Echo) "ObjDir : " '$(ObjDir)'
1437 $(Echo) "LibDir : " '$(LibDir)'
1438 $(Echo) "ToolDir : " '$(ToolDir)'
1439 $(Echo) "ExmplDir : " '$(ExmplDir)'
1440 $(Echo) "Sources : " '$(Sources)'
1441 $(Echo) "TDFiles : " '$(TDFiles)'
1442 $(Echo) "INCFiles : " '$(INCFiles)'
1443 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1444 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1445 $(Echo) "Compile.C : " '$(Compile.C)'
1446 $(Echo) "Archive : " '$(Archive)'
1447 $(Echo) "YaccFiles : " '$(YaccFiles)'
1448 $(Echo) "LexFiles : " '$(LexFiles)'
1449 $(Echo) "Module : " '$(Module)'