1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file was developed by the LLVM research group and is distributed under
6 # the University of Illinois Open Source License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
10 # This file is included by all of the LLVM makefiles. For details on how to use
11 # it properly, please see the document MakefileGuide.html in the docs directory.
13 #===-----------------------------------------------------------------------====
15 ################################################################################
16 # TARGETS: Define standard targets that can be invoked
17 ################################################################################
19 #--------------------------------------------------------------------
20 # Define the various target sets
21 #--------------------------------------------------------------------
22 RecursiveTargets := all clean clean-all install uninstall install-bytecode
23 LocalTargets := all-local clean-local clean-all-local check-local \
24 install-local printvars uninstall-local \
25 install-bytecode-local
26 TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
28 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29 InternalTargets := preconditions distdir dist-hook
31 ################################################################################
32 # INITIALIZATION: Basic things the makefile needs
33 ################################################################################
35 #--------------------------------------------------------------------
36 # Set the VPATH so that we can find source files.
37 #--------------------------------------------------------------------
38 VPATH=$(BUILD_SRC_DIR)
40 #--------------------------------------------------------------------
41 # Reset the list of suffixes we know how to build
42 #--------------------------------------------------------------------
44 .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47 #--------------------------------------------------------------------
48 # Mark all of these targets as phony to avoid implicit rule search
49 #--------------------------------------------------------------------
50 .PHONY: $(UserTargets) $(InternalTargets)
52 #--------------------------------------------------------------------
53 # Make sure all the user-target rules are double colon rules and
54 # they are defined first.
55 #--------------------------------------------------------------------
59 ################################################################################
60 # PRECONDITIONS: that which must be built/checked first
61 ################################################################################
63 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
64 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(LLVM_SRC_ROOT)/configure
67 ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
68 MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
69 MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
70 PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
72 preconditions : $(PreConditions)
74 #------------------------------------------------------------------------
75 # Make sure the BUILT_SOURCES are built first
76 #------------------------------------------------------------------------
77 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
80 ifneq ($(strip $(BUILT_SOURCES)),)
81 -$(Verb) $(RM) -f $(BUILT_SOURCES)
84 ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT))
86 $(Echo) Wiping out $(BUILD_OBJ_ROOT) and rebuilding configuration.
87 $(Verb) if test -x config.status ; then \
88 $(MV) config.status .. ; \
91 $(MV) ../config.status . ; \
95 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
99 $(BUILT_SOURCES) : $(ObjMakefiles)
101 #------------------------------------------------------------------------
102 # Make sure we're not using a stale configuration
103 #------------------------------------------------------------------------
105 $(Echo) Reconfiguring $(BUILD_OBJ_ROOT)
106 $(Verb) cd $(BUILD_OBJ_ROOT) && \
107 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
108 $(ConfigStatusScript)
110 .PRECIOUS: $(ConfigStatusScript)
111 $(ConfigStatusScript): $(ConfigureScript)
112 $(Echo) Reconfiguring with $<
113 $(Verb) cd $(BUILD_OBJ_ROOT) && \
114 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
115 $(ConfigStatusScript)
117 #------------------------------------------------------------------------
118 # Make sure the configuration makefile is up to date
119 #------------------------------------------------------------------------
120 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
121 $(Echo) Regenerating $@
122 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
124 #------------------------------------------------------------------------
125 # If the Makefile in the source tree has been updated, copy it over into the
126 # build tree. But, only do this if the source and object makefiles differ
127 #------------------------------------------------------------------------
128 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
130 Makefile: $(BUILD_SRC_DIR)/Makefile
131 $(Echo) "Updating Makefile"
132 $(Verb) $(MKDIR) $(@D)
133 $(Verb) $(CP) -f $< $@
135 # Copy the Makefile.* files unless we're in the root directory which avoids
136 # the copying of Makefile.config.in or other things that should be explicitly
138 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
140 *Makefile.rules) ;; \
142 *) $(Echo) "Updating $(@F)" ; \
149 #------------------------------------------------------------------------
150 # Set up the basic dependencies
151 #------------------------------------------------------------------------
152 $(UserTargets):: $(PreConditions)
156 clean-all:: clean-local clean-all-local
157 install:: install-local
158 uninstall:: uninstall-local
159 install-local:: all-local
160 install-bytecode:: install-bytecode-local
162 ###############################################################################
163 # VARIABLES: Set up various variables based on configuration data
164 ###############################################################################
166 #--------------------------------------------------------------------
167 # Variables derived from configuration we are building
168 #--------------------------------------------------------------------
170 ifdef ENABLE_PROFILING
172 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
173 C.Flags := -O3 -DNDEBUG -pg
174 LD.Flags := -O3 -DNDEBUG -pg
176 ifdef ENABLE_OPTIMIZED
178 CXX.Flags := -O3 -DNDEBUG -finline-functions \
179 -felide-constructors -fomit-frame-pointer
180 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
181 LD.Flags := -O3 -DNDEBUG
184 CXX.Flags := -g -D_DEBUG
185 C.Flags := -g -D_DEBUG
186 LD.Flags := -g -D_DEBUG
191 CXX.Flags += $(CXXFLAGS)
193 CPP.Flags += $(CPPFLAGS)
194 LD.Flags += $(LDFLAGS)
196 LibTool.Flags := --tag=CXX
198 #--------------------------------------------------------------------
199 # Directory locations
200 #--------------------------------------------------------------------
201 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
202 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
203 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
204 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
205 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
206 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
207 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
209 #--------------------------------------------------------------------
210 # Full Paths To Compiled Tools and Utilities
211 #--------------------------------------------------------------------
212 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
215 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
218 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
221 BURG := $(LLVMToolDir)/burg$(EXEEXT)
224 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
227 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
230 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
233 LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
236 LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
239 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
242 LLI := $(LLVMToolDir)/lli$(EXEEXT)
245 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
248 #--------------------------------------------------------------------
249 # Adjust to user's request
250 #--------------------------------------------------------------------
252 # Adjust LIBTOOL flags for shared libraries, or not.
253 ifndef SHARED_LIBRARY
254 LibTool.Flags += --tag=disable-shared
256 LD.Flags += -rpath $(LibDir)
266 # Adjust settings for verbose mode
269 LibTool.Flags += --silent
270 AR.Flags += >/dev/null 2>/dev/null
271 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
273 ConfigureScriptFLAGS :=
276 # By default, strip symbol information from executable
278 Strip := $(PLATFORMSTRIPOPTS)
279 StripWarnMsg := "(without symbols)"
282 # Adjust linker flags for building an executable
285 LD.Flags += -rpath $(ExmplDir) -export-dynamic
287 LD.Flags += -rpath $(ToolDir) -export-dynamic
291 #----------------------------------------------------------
292 # Options To Invoke Tools
293 #----------------------------------------------------------
295 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
297 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
298 CPP.Flags += -I$(BUILD_OBJ_DIR) \
300 -I$(BUILD_SRC_ROOT)/include \
301 -I$(BUILD_OBJ_ROOT)/include \
302 -I$(LLVM_OBJ_ROOT)/include \
303 -I$(LLVM_SRC_ROOT)/include \
304 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
306 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
307 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
308 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
309 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
310 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
311 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
312 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
313 $(CompileCommonOpts) $(LD.Flags) $(Strip)
314 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
316 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
317 Burg = $(BURG) -I $(BUILD_SRC_DIR)
318 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
319 Archive = $(AR) $(AR.Flags)
320 LArchive = $(LLVMToolDir)/llvm-ar rcsf
327 #----------------------------------------------------------
328 # Get the list of source files and compute object file
330 #----------------------------------------------------------
333 FakeSources := $(FAKE_SOURCES)
335 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
337 BaseNameSources := $(sort $(basename $(FakeSources)))
338 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
339 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
340 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
343 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
344 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
345 $(BUILD_SRC_DIR)/*.l))
347 Sources := $(SOURCES)
351 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
354 BaseNameSources := $(sort $(basename $(Sources)))
355 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
356 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
357 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
360 ###############################################################################
361 # DIRECTORIES: Handle recursive descent of directory structure
362 ###############################################################################
364 #---------------------------------------------------------
365 # Provide rules to make install dirs. This must be early
366 # in the file so they get built before dependencies
367 #---------------------------------------------------------
370 $(Verb) $(MKDIR) $(bindir)
373 $(Verb) $(MKDIR) $(libdir)
376 $(Verb) $(MKDIR) $(includedir)
379 $(Verb) $(MKDIR) $(sysconfdir)
381 # To create other directories, as needed, and timestamp their creation
383 $(Verb) $(MKDIR) $* > /dev/null
386 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
387 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
389 #---------------------------------------------------------
390 # Handle the DIRS options for sequential construction
391 #---------------------------------------------------------
396 $(RecursiveTargets)::
397 $(Verb) for dir in $(DIRS); do \
398 if [ ! -f $$dir/Makefile ]; then \
400 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
402 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
403 ($(MAKE) -C $$dir $@ ) || exit 1; \
408 #---------------------------------------------------------
409 # Handle the EXPERIMENTAL_DIRS options ensuring success
410 # after each directory is built.
411 #---------------------------------------------------------
412 ifdef EXPERIMENTAL_DIRS
413 $(RecursiveTargets)::
414 $(Verb) for dir in $(EXPERIMENTAL_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 0; \
425 #---------------------------------------------------------
426 # Handle the PARALLEL_DIRS options for parallel construction
427 #---------------------------------------------------------
430 SubDirs += $(PARALLEL_DIRS)
432 # Unfortunately, this list must be maintained if new recursive targets are added
433 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
434 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
435 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
436 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
437 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
438 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
440 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
443 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
445 $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
447 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
448 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
452 #---------------------------------------------------------
453 # Handle the OPTIONAL_DIRS options for directores that may
455 #---------------------------------------------------------
458 SubDirs += $(OPTIONAL_DIRS)
460 $(RecursiveTargets)::
461 $(Verb) for dir in $(OPTIONAL_DIRS); do \
462 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
463 if [ ! -f $$dir/Makefile ]; then \
465 $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
467 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
468 ($(MAKE) -C$$dir $@ ) || exit 1; \
474 #---------------------------------------------------------
475 # Handle the CONFIG_FILES options
476 #---------------------------------------------------------
479 install-local:: $(sysconfdir) $(CONFIG_FILES)
480 $(Echo) Installing Configuration Files To $(sysconfdir)
481 $(Verb)for file in $(CONFIG_FILES); do \
482 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
483 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
484 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
485 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
487 $(ECHO) Error: cannot find config file $${file}. ; \
492 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
493 $(Verb)for file in $(CONFIG_FILES); do \
494 $(RM) -f $(sysconfdir)/$${file} ; \
499 ###############################################################################
500 # Library Build Rules: Four ways to build a library
501 ###############################################################################
503 #---------------------------------------------------------
504 # Bytecode Module Targets:
505 # If the user set MODULE_NAME then they want to build a
506 # bytecode module from the sources. We compile all the
507 # sources and link it together into a single bytecode
509 #---------------------------------------------------------
513 Module := $(LibDir)/$(MODULE_NAME).bc
514 LinkModule := $(LLVMGCC) -shared -nostdlib
516 ifdef EXPORTED_SYMBOL_FILE
517 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
520 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
521 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
522 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
524 all-local:: $(Module)
527 ifneq ($(strip $(Module)),)
528 -$(Verb) $(RM) -f $(Module)
531 ifdef BYTECODE_DESTINATION
532 ModuleDestDir := $(BYTECODE_DESTINATION)
534 ModuleDestDir := $(libdir)
537 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
539 install-module:: $(DestModule)
540 install-local:: $(DestModule)
542 $(DestModule): $(ModuleDestDir) $(Module)
543 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
544 $(Verb) $(INSTALL) $(Module) $@
547 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
548 -$(Verb) $(RM) -f $(DestModule)
552 # if we're building a library ...
555 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
556 LIBRARYNAME := $(strip $(LIBRARYNAME))
557 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
558 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
559 LibName.O := $(LibDir)/$(LIBRARYNAME).o
560 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
562 #---------------------------------------------------------
563 # Shared Library Targets:
564 # If the user asked for a shared library to be built
565 # with the SHARED_LIBRARY variable, then we provide
566 # targets for building them.
567 #---------------------------------------------------------
570 all-local:: $(LibName.LA)
572 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
573 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
574 $(Verb) $(Link) -o $@ $(ObjectsLO)
575 $(Verb) $(LTInstall) $@ $(LibDir)
578 ifneq ($(strip $(LibName.LA)),)
579 -$(Verb) $(RM) -f $(LibName.LA)
582 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
584 install-local:: $(DestSharedLib)
586 $(DestSharedLib): $(libdir) $(LibName.LA)
587 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
588 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
589 $(Verb) $(LIBTOOL) --finish $(libdir)
592 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
593 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
597 #---------------------------------------------------------
598 # Bytecode Library Targets:
599 # If the user asked for a bytecode library to be built
600 # with the BYTECODE_LIBRARY variable, then we provide
601 # targets for building them.
602 #---------------------------------------------------------
603 ifdef BYTECODE_LIBRARY
605 # make the C and C++ compilers strip debug info out of bytecode libraries.
606 BCCompile.C += -Wa,-strip-debug
607 BCCompile.CXX += -Wa,-strip-debug
609 all-local:: $(LibName.BCA)
611 ifdef EXPORTED_SYMBOL_FILE
612 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
613 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
615 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
616 $(LLVMToolDir)/llvm-ar
617 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
619 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
621 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
623 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
624 $(LLVMToolDir)/llvm-ar
625 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
627 $(Verb) $(LArchive) $@ $(ObjectsBC)
632 ifneq ($(strip $(LibName.BCA)),)
633 -$(Verb) $(RM) -f $(LibName.BCA)
636 ifdef BYTECODE_DESTINATION
637 BytecodeDestDir := $(BYTECODE_DESTINATION)
639 BytecodeDestDir := $(libdir)
642 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
644 install-bytecode-local:: $(DestBytecodeLib)
646 install-local:: $(DestBytecodeLib)
648 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
649 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
650 $(Verb) $(INSTALL) $(LibName.BCA) $@
653 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
654 -$(Verb) $(RM) -f $(DestBytecodeLib)
658 #---------------------------------------------------------
659 # ReLinked Library Targets:
660 # If the user didn't explicitly forbid building a
661 # relinked then we provide targets for building them.
662 #---------------------------------------------------------
663 ifndef DONT_BUILD_RELINKED
665 all-local:: $(LibName.O)
667 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
668 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
669 $(Verb) $(Relink) -o $@ $(ObjectsO)
672 ifneq ($(strip $(LibName.O)),)
673 -$(Verb) $(RM) -f $(LibName.O)
676 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
678 install-local:: $(DestRelinkedLib)
680 $(DestRelinkedLib): $(libdir) $(LibName.O)
681 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
682 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
685 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
686 -$(Verb) $(RM) -f $(DestRelinkedLib)
690 #---------------------------------------------------------
691 # Archive Library Targets:
692 # If the user wanted a regular archive library built,
693 # then we provide targets for building them.
694 #---------------------------------------------------------
697 all-local:: $(LibName.A)
699 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
700 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
702 $(Verb) $(Archive) $@ $(ObjectsO)
706 ifneq ($(strip $(LibName.A)),)
707 -$(Verb) $(RM) -f $(LibName.A)
710 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
712 install-local:: $(DestArchiveLib)
714 $(DestArchiveLib): $(libdir) $(LibName.A)
715 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
716 $(Verb) $(MKDIR) $(libdir)
717 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
720 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
721 -$(Verb) $(RM) -f $(DestArchiveLib)
728 ###############################################################################
729 # Tool Build Rules: Build executable tool based on TOOLNAME option
730 ###############################################################################
734 #---------------------------------------------------------
735 # Handle the special "JIT" value for LLVM_LIBS which is a
736 # shorthand for a bunch of libraries that get the correct
737 # JIT support for a tool that runs JIT.
738 #---------------------------------------------------------
739 ifeq ($(LLVMLIBS),JIT)
741 # Make sure we can get our own symbols in the tool
744 # Generic JIT libraries
745 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
747 # You can enable the X86 JIT on a non-X86 host by setting the flag
748 # ENABLE_X86_JIT on the make command line. If not, it will still be
749 # enabled automagically on an X86 host.
754 # What the X86 JIT requires
756 JIT_LIBS += LLVMX86 LLVMSelectionDAG
759 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
760 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
761 # enabled automagically on an SparcV9 host.
762 ifeq ($(ARCH), Sparc)
763 ENABLE_SPARCV9_JIT = 1
766 # What the Sparc JIT requires
767 ifdef ENABLE_SPARCV9_JIT
768 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
769 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
770 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
771 LLVMDataStructure.a LLVMSparcV9RegAlloc
774 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
775 # ENABLE_PPC_JIT on the make command line. If not, it will still be
776 # enabled automagically on an PowerPC host.
777 ifeq ($(ARCH), PowerPC)
781 # What the PowerPC JIT requires
783 JIT_LIBS += LLVMPowerPC
786 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
787 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
788 LLVMSystem.a $(PLATFORMLIBDL)
791 #---------------------------------------------------------
792 # Set up variables for building a tool.
793 #---------------------------------------------------------
795 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
797 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
799 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
800 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
801 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
802 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
803 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
804 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
805 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
806 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
808 #---------------------------------------------------------
809 # Tell make that we need to rebuild subdirectories before
810 # we can link the tool. This affects things like LLI which
811 # has library subdirectories.
812 #---------------------------------------------------------
813 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
815 #---------------------------------------------------------
816 # Provide targets for building the tools
817 #---------------------------------------------------------
818 all-local:: $(ToolBuildPath)
821 ifneq ($(strip $(ToolBuildPath)),)
822 -$(Verb) $(RM) -f $(ToolBuildPath)
826 $(ToolBuildPath): $(ExmplDir)/.dir
828 $(ToolBuildPath): $(ToolDir)/.dir
831 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
832 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
833 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
834 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
835 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
837 DestTool = $(bindir)/$(TOOLNAME)
839 install-local:: $(DestTool)
841 $(DestTool): $(bindir) $(ToolBuildPath)
842 $(Echo) Installing $(BuildMode) $(DestTool)
843 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
846 $(Echo) Uninstalling $(BuildMode) $(DestTool)
847 -$(Verb) $(RM) -f $(DestTool)
851 ###############################################################################
852 # Object Build Rules: Build object files based on sources
853 ###############################################################################
855 # Provide rule sets for when dependency generation is enabled
856 ifndef DISABLE_AUTO_DEPENDENCIES
858 #---------------------------------------------------------
859 # Create .lo files in the ObjDir directory from the .cpp and .c files...
860 #---------------------------------------------------------
863 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
864 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
865 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
866 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
867 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
869 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
870 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
871 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
872 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
873 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
875 #---------------------------------------------------------
876 # Create .o files in the ObjDir directory from the .cpp and .c files...
877 #---------------------------------------------------------
880 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
881 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
882 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
883 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
884 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
886 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
887 $(Echo) "Compiling $*.c for $(BuildMode) build"
888 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
889 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
890 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
894 #---------------------------------------------------------
895 # Create .bc files in the ObjDir directory from .cpp and .c files...
896 #---------------------------------------------------------
897 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
898 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
899 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
900 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
901 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
903 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
904 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
905 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
906 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
907 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
909 # Provide alternate rule sets if dependencies are disabled
914 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
915 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
916 $(LTCompile.CXX) $< -o $@
918 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
919 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
920 $(LTCompile.C) $< -o $@
924 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
925 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
926 $(Compile.CXX) $< -o $@
928 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
929 $(Echo) "Compiling $*.c for $(BuildMode) build"
930 $(Compile.C) $< -o $@
933 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
934 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
935 $(BCCompile.CXX) $< -o $@
937 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
938 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
939 $(BCCompile.C) $< -o $@
943 #---------------------------------------------------------
944 # Provide rule to build .bc files from .ll sources,
945 # regardless of dependencies
946 #---------------------------------------------------------
947 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
948 $(Echo) "Compiling $*.ll for $(BuildMode) build"
949 $(Verb) $(LLVMAS) $< -f -o $@
951 ###############################################################################
952 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
953 ###############################################################################
957 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
958 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
959 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
960 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
962 # All of these files depend on tblgen and the .td files.
963 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
965 # INCFiles rule: All of the tblgen generated files are emitted to
966 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
967 # us to only "touch" the real file if the contents of it change. IOW, if
968 # tblgen is modified, all of the .inc.tmp files are regereated, but no
969 # dependencies of the .inc files are, unless the contents of the .inc file
971 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
972 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
974 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
975 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
976 $(Echo) "Building $(<F) register names with tblgen"
977 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
979 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
980 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
981 $(Echo) "Building $(<F) register information header with tblgen"
982 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
984 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
985 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
986 $(Echo) "Building $(<F) register info implementation with tblgen"
987 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
989 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
990 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
991 $(Echo) "Building $(<F) instruction names with tblgen"
992 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
994 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
995 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
996 $(Echo) "Building $(<F) instruction information with tblgen"
997 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
999 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1000 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1001 $(Echo) "Building $(<F) assembly writer with tblgen"
1002 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1004 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1005 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1006 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1007 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1009 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1010 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1011 $(Echo) "Building $(<F) code emitter with tblgen"
1012 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1015 -$(Verb) $(RM) -f $(INCFiles)
1019 ###############################################################################
1020 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1021 ###############################################################################
1023 #---------------------------------------------------------
1024 # Provide rules for generating a .cpp source file from
1025 # (f)lex input sources.
1026 #---------------------------------------------------------
1028 LexFiles := $(filter %.l,$(Sources))
1030 ifneq ($(LexFiles),)
1032 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1034 .PRECIOUS: $(LexOutput)
1036 # Note the extra sed filtering here, used to cut down on the warnings emited
1037 # by GCC. The last line is a gross hack to work around flex aparently not
1038 # being able to resize the buffer on a large token input. Currently, for
1039 # uninitialized string buffers in LLVM we can generate very long tokens, so
1040 # this is a hack around it.
1041 # FIXME. (f.e. char Buffer[10000] )
1043 $(Echo) Flexing $*.l
1044 $(Verb) $(FLEX) -t $< | \
1045 $(SED) 's/void yyunput/inline void yyunput/' | \
1046 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1047 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1051 -$(Verb) $(RM) -f $(LexOutput)
1052 $(Verb) $(RM) -f $(LexOutput)
1056 #---------------------------------------------------------
1057 # Provide rules for generating a .cpp and .h source files
1058 # from yacc (bison) input sources.
1059 #---------------------------------------------------------
1061 YaccFiles := $(filter %.y,$(Sources))
1062 ifneq ($(YaccFiles),)
1063 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1065 .PRECIOUS: $(YaccOutput)
1067 # Cancel built-in rules for yacc
1072 # Rule for building the bison parsers...
1074 $(Echo) "Bisoning $*.y"
1075 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1076 $(Verb) $(MV) -f $*.tab.c $*.cpp
1077 $(Verb) $(MV) -f $*.tab.h $*.h
1080 -$(Verb) $(RM) -f $(YaccOutput)
1081 $(Verb) $(RM) -f $(YaccOutput)
1084 ###############################################################################
1085 # OTHER RULES: Other rules needed
1086 ###############################################################################
1088 # To create postscript files from dot files...
1089 ifneq ($(DOT),false)
1091 $(DOT) -Tps < $< > $@
1094 $(Echo) "Cannot build $@: The program dot is not installed"
1097 # This rules ensures that header files that are removed still have a rule for
1098 # which they can be "generated." This allows make to ignore them and
1099 # reproduce the dependency lists.
1102 # Define clean-local to clean the current directory. Note that this uses a
1103 # very conservative approach ensuring that empty variables do not cause
1104 # errors or disastrous removal.
1106 ifneq ($(strip $(ObjDir)),)
1107 -$(Verb) $(RM) -rf $(ObjDir)
1109 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1110 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1111 -$(Verb) $(RM) -f *$(SHLIBEXT)
1115 -$(Verb) $(RM) -rf Debug Release Profile
1117 # Build tags database for Emacs/Xemacs:
1121 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1122 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1123 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1124 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1125 -name '*.cpp' -o -name '*.h' | \
1126 $(ETAGS) $(ETAGSFLAGS) -
1129 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1130 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1131 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1132 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1133 \( -name '*.cpp' -o -name '*.h' \) -print | \
1134 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1137 ###############################################################################
1138 # DEPENDENCIES: Include the dependency files if we should
1139 ###############################################################################
1140 ifndef DISABLE_AUTO_DEPENDENCIES
1142 # If its not one of the cleaning targets
1143 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1145 # Get the list of dependency files
1146 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1147 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1149 -include /dev/null $(DependFiles)
1155 ###############################################################################
1156 # CHECK: Running the test suite
1157 ###############################################################################
1160 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1161 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1162 $(EchoCmd) Running test suite ; \
1163 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1164 TESTSUITE=$(TESTSUITE) ; \
1166 $(EchoCmd) No Makefile in test directory ; \
1169 $(EchoCmd) No test directory ; \
1172 ###############################################################################
1173 # DISTRIBUTION: Handle construction of a distribution tarball
1174 ###############################################################################
1176 #------------------------------------------------------------------------
1177 # Define distribution related variables
1178 #------------------------------------------------------------------------
1179 DistName := $(LLVM_TARBALL_NAME)
1180 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1181 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1182 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1183 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1184 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1185 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1186 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1187 Makefile.config.in configure autoconf
1188 DistOther := $(notdir $(wildcard \
1189 $(BUILD_SRC_DIR)/*.h \
1190 $(BUILD_SRC_DIR)/*.td \
1191 $(BUILD_SRC_DIR)/*.def \
1192 $(BUILD_SRC_DIR)/*.ll \
1193 $(BUILD_SRC_DIR)/*.in))
1194 DistSubDirs := $(SubDirs)
1195 DistSources = $(Sources) $(EXTRA_DIST)
1196 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1198 #------------------------------------------------------------------------
1199 # We MUST build distribution with OBJ_DIR != SRC_DIR
1200 #------------------------------------------------------------------------
1201 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1202 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1203 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1207 #------------------------------------------------------------------------
1208 # Prevent catastrophic remove
1209 #------------------------------------------------------------------------
1210 ifeq ($(LLVM_TARBALL_NAME),)
1211 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1214 #------------------------------------------------------------------------
1215 # Prevent attempt to run dist targets from anywhere but the top level
1216 #------------------------------------------------------------------------
1219 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1220 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1224 #------------------------------------------------------------------------
1225 # Provide the top level targets
1226 #------------------------------------------------------------------------
1228 dist-gzip:: $(DistTarGZip)
1230 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1231 $(Echo) Packing gzipped distribution tar file.
1232 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1233 $(GZIP) -c > "$(DistTarGZip)"
1235 dist-bzip2:: $(DistTarBZ2)
1237 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1238 $(Echo) Packing bzipped distribution tar file.
1239 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1240 $(BZIP2) -c >$(DistTarBZ2)
1242 dist-zip:: $(DistZip)
1244 $(DistZip) : $(TopDistDir)/.makedistdir
1245 $(Echo) Packing zipped distribution file.
1246 $(Verb) rm -f $(DistZip)
1247 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1249 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1250 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1252 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1254 dist-check:: $(DistTarGZip)
1255 $(Echo) Checking distribution tar file.
1256 $(Verb) if test -d $(DistCheckDir) ; then \
1257 $(RM) -rf $(DistCheckDir) ; \
1259 $(Verb) $(MKDIR) $(DistCheckDir)
1260 $(Verb) cd $(DistCheckDir) && \
1261 $(MKDIR) $(DistCheckDir)/build && \
1262 $(MKDIR) $(DistCheckDir)/install && \
1263 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1265 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1266 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1269 $(MAKE) install && \
1270 $(MAKE) uninstall && \
1273 $(MAKE) dist-clean && \
1274 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1277 $(Echo) Cleaning distribution files
1278 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1283 #------------------------------------------------------------------------
1284 # Provide the recursive distdir target for building the distribution directory
1285 #------------------------------------------------------------------------
1286 distdir: $(DistDir)/.makedistdir
1287 $(DistDir)/.makedistdir: $(DistSources)
1288 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1289 if test -d "$(DistDir)" ; then \
1290 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1293 $(EchoCmd) Removing old $(DistDir) ; \
1294 $(RM) -rf $(DistDir); \
1295 $(EchoCmd) Making 'all' to verify build ; \
1298 $(Echo) Building Distribution Directory $(DistDir)
1299 $(Verb) $(MKDIR) $(DistDir)
1300 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1301 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1302 for file in $(DistFiles) ; do \
1304 $(BUILD_SRC_DIR)/*) \
1305 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1307 $(BUILD_SRC_ROOT)/*) \
1308 file=`echo "$$file" | \
1309 sed "s#^$$srcrootstrip/##"` \
1312 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1313 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1314 from_dir="$(BUILD_SRC_DIR)" ; \
1315 elif test -f "$$file" || test -d "$$file" ; then \
1318 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1319 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1320 to_dir="$(DistDir)/$$dir"; \
1321 $(MKDIR) "$$to_dir" ; \
1323 to_dir="$(DistDir)"; \
1325 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1326 if test -n "$$mid_dir" ; then \
1327 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1329 if test -d "$$from_dir/$$file"; then \
1330 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1331 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1332 $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1334 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1335 elif test -f "$$from_dir/$$file" ; then \
1336 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1337 elif test -L "$$from_dir/$$file" ; then \
1338 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1339 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1340 $(EchoCmd) "===== WARNING: Distribution Source " \
1341 "$$from_dir/$$file Not Found!" ; \
1342 elif test "$(Verb)" != '@' ; then \
1343 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1346 $(Verb) for subdir in $(DistSubDirs) ; do \
1347 if test "$$subdir" \!= "." ; then \
1348 new_distdir="$(DistDir)/$$subdir" ; \
1349 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1350 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1354 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1355 $(EchoCmd) Eliminating CVS directories from distribution ; \
1356 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1357 $(MAKE) dist-hook ; \
1358 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1359 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1360 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1361 -o ! -type d ! -perm -444 -exec \
1362 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1363 || chmod -R a+r $(DistDir) ; \
1366 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1372 ###############################################################################
1373 # TOP LEVEL - targets only to apply at the top level directory
1374 ###############################################################################
1378 #------------------------------------------------------------------------
1379 # Install support for the project's include files:
1380 #------------------------------------------------------------------------
1382 $(Echo) Installing include files
1383 $(Verb) $(MKDIR) $(includedir)
1384 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1385 cd $(BUILD_SRC_ROOT)/include && \
1386 find . -path '*/Internal' -prune -o '(' -type f \
1387 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1388 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1392 $(Echo) Uninstalling include files
1393 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1394 cd $(BUILD_SRC_ROOT)/include && \
1395 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1396 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1397 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1402 #------------------------------------------------------------------------
1403 # Print out the directories used for building
1404 #------------------------------------------------------------------------
1406 $(Echo) "BuildMode : " '$(BuildMode)'
1407 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1408 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1409 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1410 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1411 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1412 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1413 $(Echo) "libdir : " '$(libdir)'
1414 $(Echo) "bindir : " '$(bindir)'
1415 $(Echo) "sysconfdir : " '$(sysconfdir)'
1416 $(Echo) "UserTargets : " '$(UserTargets)'
1417 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1418 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1419 $(Echo) "ObjDir : " '$(ObjDir)'
1420 $(Echo) "LibDir : " '$(LibDir)'
1421 $(Echo) "ToolDir : " '$(ToolDir)'
1422 $(Echo) "ExmplDir : " '$(ExmplDir)'
1423 $(Echo) "Sources : " '$(Sources)'
1424 $(Echo) "TDFiles : " '$(TDFiles)'
1425 $(Echo) "INCFiles : " '$(INCFiles)'
1426 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1427 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1428 $(Echo) "Compile.C : " '$(Compile.C)'
1429 $(Echo) "Archive : " '$(Archive)'
1430 $(Echo) "YaccFiles : " '$(YaccFiles)'
1431 $(Echo) "LexFiles : " '$(LexFiles)'
1432 $(Echo) "Module : " '$(Module)'