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 $(BUILT_SOURCES) : $(ObjMakefiles)
86 #------------------------------------------------------------------------
87 # Make sure we're not using a stale configuration
88 #------------------------------------------------------------------------
89 .PRECIOUS: $(ConfigStatusScript)
90 $(ConfigStatusScript): $(ConfigureScript)
91 $(Echo) Reconfiguring with $<
92 $(Verb) cd $(BUILD_OBJ_ROOT) && \
93 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
96 #------------------------------------------------------------------------
97 # Make sure the configuration makefile is up to date
98 #------------------------------------------------------------------------
99 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
100 $(Echo) Regenerating $@
101 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
103 #------------------------------------------------------------------------
104 # If the Makefile in the source tree has been updated, copy it over into the
105 # build tree. But, only do this if the source and object makefiles differ
106 #------------------------------------------------------------------------
107 ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
109 Makefile: $(BUILD_SRC_DIR)/Makefile
110 $(Echo) "Updating Makefile"
111 $(Verb) $(MKDIR) $(@D)
114 # Copy the Makefile.* files unless we're in the root directory which avoids
115 # the copying of Makefile.config.in or other things that should be explicitly
117 $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
119 *Makefile.rules) ;; \
121 *) $(Echo) "Updating $(@F)" ; \
128 #------------------------------------------------------------------------
129 # Set up the basic dependencies
130 #------------------------------------------------------------------------
131 $(UserTargets):: $(PreConditions)
135 clean-all:: clean-local clean-all-local
136 install:: install-local
137 uninstall:: uninstall-local
138 install-local:: all-local
139 install-bytecode:: install-bytecode-local
141 ###############################################################################
142 # VARIABLES: Set up various variables based on configuration data
143 ###############################################################################
145 #--------------------------------------------------------------------
146 # Variables derived from configuration we are building
147 #--------------------------------------------------------------------
149 ifdef ENABLE_PROFILING
151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
152 C.Flags := -O3 -DNDEBUG -pg
153 LD.Flags := -O3 -DNDEBUG -pg
155 ifdef ENABLE_OPTIMIZED
157 CXX.Flags := -O3 -DNDEBUG -finline-functions \
158 -felide-constructors -fomit-frame-pointer
159 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
160 LD.Flags := -O3 -DNDEBUG
163 CXX.Flags := -g -D_DEBUG
164 C.Flags := -g -D_DEBUG
165 LD.Flags := -g -D_DEBUG
170 CXX.Flags += $(CXXFLAGS)
172 CPP.Flags += $(CPPFLAGS)
173 LD.Flags += $(LDFLAGS)
175 LibTool.Flags := --tag=CXX
177 #--------------------------------------------------------------------
178 # Directory locations
179 #--------------------------------------------------------------------
180 ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
181 LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
182 ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
183 ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
184 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
185 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
186 LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
188 #--------------------------------------------------------------------
189 # Full Paths To Compiled Tools and Utilities
190 #--------------------------------------------------------------------
191 EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
194 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
197 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
200 BURG := $(LLVMToolDir)/burg$(EXEEXT)
203 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
206 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
209 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
212 LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
215 LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
218 #--------------------------------------------------------------------
219 # Adjust to user's request
220 #--------------------------------------------------------------------
222 # Adjust LIBTOOL flags for shared libraries, or not.
223 ifndef SHARED_LIBRARY
224 LibTool.Flags += --tag=disable-shared
226 LD.Flags += -rpath $(LibDir)
236 # Adjust settings for verbose mode
239 LibTool.Flags += --silent
240 AR.Flags += >/dev/null 2>/dev/null
241 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
243 ConfigureScriptFLAGS :=
246 # By default, strip symbol information from executable
248 Strip := $(PLATFORMSTRIPOPTS)
249 StripWarnMsg := "(without symbols)"
252 # Adjust linker flags for building an executable
255 LD.Flags += -rpath $(ExmplDir) -export-dynamic
257 LD.Flags += -rpath $(ToolDir) -export-dynamic
261 #----------------------------------------------------------
262 # Options To Invoke Tools
263 #----------------------------------------------------------
265 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
267 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
268 CPP.Flags += -I$(BUILD_OBJ_DIR) \
270 -I$(BUILD_SRC_ROOT)/include \
271 -I$(BUILD_OBJ_ROOT)/include \
272 -I$(LLVM_OBJ_ROOT)/include \
273 -I$(LLVM_SRC_ROOT)/include \
274 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
276 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
277 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
278 BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
279 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
280 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
281 BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
282 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
283 $(CompileCommonOpts) $(LD.Flags) $(Strip)
284 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
286 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
287 Burg = $(BURG) -I $(BUILD_SRC_DIR)
288 TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
289 Archive = $(AR) $(AR.Flags)
290 LArchive = $(LLVMToolDir)/llvm-ar rcsf
297 #----------------------------------------------------------
298 # Get the list of source files and compute object file
300 #----------------------------------------------------------
303 FakeSources := $(FAKE_SOURCES)
305 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
307 BaseNameSources := $(sort $(basename $(FakeSources)))
308 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
309 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
310 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
313 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
314 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
315 $(BUILD_SRC_DIR)/*.l))
317 Sources := $(SOURCES)
321 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
324 BaseNameSources := $(sort $(basename $(Sources)))
325 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
326 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
327 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
330 ###############################################################################
331 # DIRECTORIES: Handle recursive descent of directory structure
332 ###############################################################################
334 #---------------------------------------------------------
335 # Provide rules to make install dirs. This must be early
336 # in the file so they get built before dependencies
337 #---------------------------------------------------------
340 $(Verb) $(MKDIR) $(bindir)
343 $(Verb) $(MKDIR) $(libdir)
346 $(Verb) $(MKDIR) $(includedir)
349 $(Verb) $(MKDIR) $(sysconfdir)
351 # To create other directories, as needed, and timestamp their creation
353 $(Verb) $(MKDIR) $* > /dev/null
356 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
357 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
359 #---------------------------------------------------------
360 # Handle the DIRS options for sequential construction
361 #---------------------------------------------------------
366 $(RecursiveTargets)::
367 $(Verb) for dir in $(DIRS); do \
368 if [ ! -f $$dir/Makefile ]; then \
370 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
372 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
373 ($(MAKE) -C $$dir $@ ) || exit 1; \
378 #---------------------------------------------------------
379 # Handle the EXPERIMENTAL_DIRS options ensuring success
380 # after each directory is built.
381 #---------------------------------------------------------
382 ifdef EXPERIMENTAL_DIRS
383 $(RecursiveTargets)::
384 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
385 if [ ! -f $$dir/Makefile ]; then \
387 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
389 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
390 ($(MAKE) -C $$dir $@ ) || exit 0; \
395 #---------------------------------------------------------
396 # Handle the PARALLEL_DIRS options for parallel construction
397 #---------------------------------------------------------
400 SubDirs += $(PARALLEL_DIRS)
402 # Unfortunately, this list must be maintained if new recursive targets are added
403 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
404 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
405 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
406 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
407 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
408 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
410 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
413 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
415 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
417 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
418 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
422 #---------------------------------------------------------
423 # Handle the OPTIONAL_DIRS options for directores that may
425 #---------------------------------------------------------
428 SubDirs += $(OPTIONAL_DIRS)
430 $(RecursiveTargets)::
431 $(Verb) for dir in $(OPTIONAL_DIRS); do \
432 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
433 if [ ! -f $$dir/Makefile ]; then \
435 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
437 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
438 ($(MAKE) -C$$dir $@ ) || exit 1; \
444 #---------------------------------------------------------
445 # Handle the CONFIG_FILES options
446 #---------------------------------------------------------
449 install-local:: $(sysconfdir) $(CONFIG_FILES)
450 $(Echo) Installing Configuration Files To $(sysconfdir)
451 $(Verb)for file in $(CONFIG_FILES); do \
452 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
453 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
454 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
455 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
457 $(ECHO) Error: cannot find config file $${file}. ; \
462 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
463 $(Verb)for file in $(CONFIG_FILES); do \
464 $(RM) -f $(sysconfdir)/$${file} ; \
469 ###############################################################################
470 # Library Build Rules: Four ways to build a library
471 ###############################################################################
473 #---------------------------------------------------------
474 # Bytecode Module Targets:
475 # If the user set MODULE_NAME then they want to build a
476 # bytecode module from the sources. We compile all the
477 # sources and link it together into a single bytecode
479 #---------------------------------------------------------
483 Module := $(LibDir)/$(MODULE_NAME).bc
484 LinkModule := $(LLVMGCC) -shared -nostdlib
486 ifdef EXPORTED_SYMBOL_FILE
487 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
490 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
491 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
492 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
494 all-local:: $(Module)
497 ifneq ($(strip $(Module)),)
498 -$(Verb) $(RM) -f $(Module)
501 ifdef BYTECODE_DESTINATION
502 ModuleDestDir := $(BYTECODE_DESTINATION)
504 ModuleDestDir := $(BYTECODE_DESTINATION)
507 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
509 install-module:: $(DestModule)
510 install-local:: $(DestModule)
512 $(DestModule): $(ModuleDestDir) $(Module)
513 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
514 $(Verb) $(INSTALL) $(Module) $@
517 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
518 -$(Verb) $(RM) -f $(DestModule)
522 # if we're building a library ...
525 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
526 LIBRARYNAME := $(strip $(LIBRARYNAME))
527 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
528 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
529 LibName.O := $(LibDir)/$(LIBRARYNAME).o
530 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
532 #---------------------------------------------------------
533 # Shared Library Targets:
534 # If the user asked for a shared library to be built
535 # with the SHARED_LIBRARY variable, then we provide
536 # targets for building them.
537 #---------------------------------------------------------
540 all-local:: $(LibName.LA)
542 $(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
543 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
544 $(Verb) $(Link) -o $@ $(ObjectsLO)
545 $(Verb) $(LTInstall) $@ $(LibDir)
548 ifneq ($(strip $(LibName.LA)),)
549 -$(Verb) $(RM) -f $(LibName.LA)
552 DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
554 install-local:: $(DestSharedLib)
556 $(DestSharedLib): $(libdir) $(LibName.LA)
557 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
558 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
559 $(Verb) $(LIBTOOL) --finish $(libdir)
562 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
563 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
567 #---------------------------------------------------------
568 # Bytecode Library Targets:
569 # If the user asked for a bytecode library to be built
570 # with the BYTECODE_LIBRARY variable, then we provide
571 # targets for building them.
572 #---------------------------------------------------------
573 ifdef BYTECODE_LIBRARY
575 # make the C and C++ compilers strip debug info out of bytecode libraries.
576 BCCompile.C += -Wa,-strip-debug
577 BCCompile.CXX += -Wa,-strip-debug
579 all-local:: $(LibName.BCA)
581 ifdef EXPORTED_SYMBOL_FILE
582 BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
583 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
585 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
586 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
588 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
590 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
592 $(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
593 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
595 $(Verb) $(LArchive) $@ $(ObjectsBC)
600 ifneq ($(strip $(LibName.BCA)),)
601 -$(Verb) $(RM) -f $(LibName.BCA)
604 ifdef BYTECODE_DESTINATION
605 BytecodeDestDir := $(BYTECODE_DESTINATION)
607 BytecodeDestDir := $(libdir)
610 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
612 install-bytecode-local:: $(DestBytecodeLib)
614 install-local:: $(DestBytecodeLib)
616 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
617 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
618 $(Verb) $(INSTALL) $(LibName.BCA) $@
621 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
622 -$(Verb) $(RM) -f $(DestBytecodeLib)
626 #---------------------------------------------------------
627 # ReLinked Library Targets:
628 # If the user didn't explicitly forbid building a
629 # relinked then we provide targets for building them.
630 #---------------------------------------------------------
631 ifndef DONT_BUILD_RELINKED
633 all-local:: $(LibName.O)
635 $(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
636 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
637 $(Verb) $(Relink) -o $@ $(ObjectsO)
640 ifneq ($(strip $(LibName.O)),)
641 -$(Verb) $(RM) -f $(LibName.O)
644 DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
646 install-local:: $(DestRelinkedLib)
648 $(DestRelinkedLib): $(libdir) $(LibName.O)
649 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
650 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
653 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
654 -$(Verb) $(RM) -f $(DestRelinkedLib)
658 #---------------------------------------------------------
659 # Archive Library Targets:
660 # If the user wanted a regular archive library built,
661 # then we provide targets for building them.
662 #---------------------------------------------------------
665 all-local:: $(LibName.A)
667 $(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
668 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
670 $(Verb) $(Archive) $@ $(ObjectsO)
674 ifneq ($(strip $(LibName.A)),)
675 -$(Verb) $(RM) -f $(LibName.A)
678 DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
680 install-local:: $(DestArchiveLib)
682 $(DestArchiveLib): $(libdir) $(LibName.A)
683 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
684 $(Verb) $(MKDIR) $(libdir)
685 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
688 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
689 -$(Verb) $(RM) -f $(DestArchiveLib)
696 ###############################################################################
697 # Tool Build Rules: Build executable tool based on TOOLNAME option
698 ###############################################################################
702 #---------------------------------------------------------
703 # Handle the special "JIT" value for LLVM_LIBS which is a
704 # shorthand for a bunch of libraries that get the correct
705 # JIT support for a tool that runs JIT.
706 #---------------------------------------------------------
707 ifeq ($(LLVMLIBS),JIT)
709 # Make sure we can get our own symbols in the tool
712 # Generic JIT libraries
713 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
715 # You can enable the X86 JIT on a non-X86 host by setting the flag
716 # ENABLE_X86_JIT on the make command line. If not, it will still be
717 # enabled automagically on an X86 host.
722 # What the X86 JIT requires
724 JIT_LIBS += LLVMX86 LLVMSelectionDAG
727 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
728 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
729 # enabled automagically on an SparcV9 host.
730 ifeq ($(ARCH), Sparc)
731 ENABLE_SPARCV9_JIT = 1
734 # What the Sparc JIT requires
735 ifdef ENABLE_SPARCV9_JIT
736 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
737 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
738 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
739 LLVMDataStructure.a LLVMSparcV9RegAlloc
742 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
743 # ENABLE_PPC_JIT on the make command line. If not, it will still be
744 # enabled automagically on an PowerPC host.
745 ifeq ($(ARCH), PowerPC)
749 # What the PowerPC JIT requires
751 JIT_LIBS += LLVMPowerPC
754 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
755 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
756 LLVMSystem.a $(PLATFORMLIBDL)
759 #---------------------------------------------------------
760 # Set up variables for building a tool.
761 #---------------------------------------------------------
763 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
765 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
767 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
768 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
769 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
770 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
771 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
772 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
773 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
774 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
776 #---------------------------------------------------------
777 # Tell make that we need to rebuild subdirectories before
778 # we can link the tool. This affects things like LLI which
779 # has library subdirectories.
780 #---------------------------------------------------------
781 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
783 #---------------------------------------------------------
784 # Provide targets for building the tools
785 #---------------------------------------------------------
786 all-local:: $(ToolBuildPath)
789 ifneq ($(strip $(ToolBuildPath)),)
790 -$(Verb) $(RM) -f $(ToolBuildPath)
794 $(ToolBuildPath): $(ExmplDir)/.dir
796 $(ToolBuildPath): $(ToolDir)/.dir
799 $(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
800 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
801 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
802 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
803 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
805 DestTool = $(bindir)/$(TOOLNAME)
807 install-local:: $(DestTool)
809 $(DestTool): $(bindir) $(ToolBuildPath)
810 $(Echo) Installing $(BuildMode) $(DestTool)
811 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
814 $(Echo) Uninstalling $(BuildMode) $(DestTool)
815 -$(Verb) $(RM) -f $(DestTool)
819 ###############################################################################
820 # Object Build Rules: Build object files based on sources
821 ###############################################################################
823 # Provide rule sets for when dependency generation is enabled
824 ifndef DISABLE_AUTO_DEPENDENCIES
826 #---------------------------------------------------------
827 # Create .lo files in the ObjDir directory from the .cpp and .c files...
828 #---------------------------------------------------------
831 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
832 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
833 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
834 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
835 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
837 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
838 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
839 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
840 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
841 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
843 #---------------------------------------------------------
844 # Create .o files in the ObjDir directory from the .cpp and .c files...
845 #---------------------------------------------------------
848 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
849 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
850 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
851 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
852 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
854 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
855 $(Echo) "Compiling $*.c for $(BuildMode) build"
856 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
857 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
858 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
862 #---------------------------------------------------------
863 # Create .bc files in the ObjDir directory from .cpp and .c files...
864 #---------------------------------------------------------
865 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
866 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
867 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
868 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
869 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
871 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
872 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
873 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
874 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
875 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
877 # Provide alternate rule sets if dependencies are disabled
882 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
883 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
884 $(LTCompile.CXX) $< -o $@
886 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
887 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
888 $(LTCompile.C) $< -o $@
892 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
893 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
894 $(Compile.CXX) $< -o $@
896 $(ObjDir)/%.o: %.c $(ObjDir)/.dir
897 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
898 $(Compile.C) $< -o $@
901 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
902 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
903 $(BCCompile.CXX) $< -o $@
905 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
906 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
907 $(BCCompile.C) $< -o $@
911 #---------------------------------------------------------
912 # Provide rule to build .bc files from .ll sources,
913 # regardless of dependencies
914 #---------------------------------------------------------
915 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
916 $(Echo) "Compiling $*.ll for $(BuildMode) build"
917 $(Verb) $(LLVMAS) $< -f -o $@
919 ###############################################################################
920 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
921 ###############################################################################
925 TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
926 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
928 $(INCFiles) : $(TBLGEN) $(TDFiles)
930 %GenRegisterNames.inc : %.td
931 $(Echo) "Building $(<F) register names with tblgen"
932 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
934 %GenRegisterInfo.h.inc : %.td
935 $(Echo) "Building $(<F) register information header with tblgen"
936 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
938 %GenRegisterInfo.inc : %.td
939 $(Echo) "Building $(<F) register info implementation with tblgen"
940 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
942 %GenInstrNames.inc : %.td
943 $(Echo) "Building $(<F) instruction names with tblgen"
944 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
946 %GenInstrInfo.inc : %.td
947 $(Echo) "Building $(<F) instruction information with tblgen"
948 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
950 %GenAsmWriter.inc : %.td
951 $(Echo) "Building $(<F) assembly writer with tblgen"
952 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
954 %GenATTAsmWriter.inc : %.td
955 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
956 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
958 %GenIntelAsmWriter.inc : %.td
959 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
960 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
962 %GenInstrSelector.inc: %.td
963 $(Echo) "Building $(<F) instruction selector with tblgen"
964 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
966 %GenCodeEmitter.inc:: %.td
967 $(Echo) "Building $(<F) code emitter with tblgen"
968 $(Verb) $(TableGen) -gen-emitter -o $@ $<
971 -$(Verb) $(RM) -f $(INCFiles)
975 ###############################################################################
976 # LEX AND YACC: Provide rules for generating sources with lex and yacc
977 ###############################################################################
979 #---------------------------------------------------------
980 # Provide rules for generating a .cpp source file from
981 # (f)lex input sources.
982 #---------------------------------------------------------
984 LexFiles := $(filter %.l,$(Sources))
988 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
990 .PRECIOUS: $(LexOutput)
992 # Note the extra sed filtering here, used to cut down on the warnings emited
993 # by GCC. The last line is a gross hack to work around flex aparently not
994 # being able to resize the buffer on a large token input. Currently, for
995 # uninitialized string buffers in LLVM we can generate very long tokens, so
996 # this is a hack around it.
997 # FIXME. (f.e. char Buffer[10000] )
1000 $(Verb) $(FLEX) -t $< | \
1001 $(SED) 's/void yyunput/inline void yyunput/' | \
1002 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1003 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1007 -$(Verb) $(RM) -f $(LexOutput)
1008 $(Verb) $(RM) -f $(LexOutput)
1012 #---------------------------------------------------------
1013 # Provide rules for generating a .cpp and .h source files
1014 # from yacc (bison) input sources.
1015 #---------------------------------------------------------
1017 YaccFiles := $(filter %.y,$(Sources))
1018 ifneq ($(YaccFiles),)
1019 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1021 .PRECIOUS: $(YaccOutput)
1023 # Cancel built-in rules for yacc
1028 # Rule for building the bison parsers...
1030 $(Echo) "Bisoning $*.y"
1031 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1032 $(Verb) $(MV) -f $*.tab.c $*.cpp
1033 $(Verb) $(MV) -f $*.tab.h $*.h
1036 -$(Verb) $(RM) -f $(YaccOutput)
1037 $(Verb) $(RM) -f $(YaccOutput)
1040 ###############################################################################
1041 # OTHER RULES: Other rules needed
1042 ###############################################################################
1044 # To create postscript files from dot files...
1045 ifneq ($(DOT),false)
1047 $(DOT) -Tps < $< > $@
1050 $(Echo) "Cannot build $@: The program dot is not installed"
1053 # This rules ensures that header files that are removed still have a rule for
1054 # which they can be "generated." This allows make to ignore them and
1055 # reproduce the dependency lists.
1058 # Define clean-local to clean the current directory. Note that this uses a
1059 # very conservative approach ensuring that empty variables do not cause
1060 # errors or disastrous removal.
1062 ifneq ($(strip $(ObjDir)),)
1063 -$(Verb) $(RM) -rf $(ObjDir)
1065 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1066 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1067 -$(Verb) $(RM) -f *$(SHLIBEXT)
1071 -$(Verb) $(RM) -rf Debug Release Profile
1073 # Build tags database for Emacs/Xemacs:
1077 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1078 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1079 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1080 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1081 -name '*.cpp' -o -name '*.h' | \
1082 $(ETAGS) $(ETAGSFLAGS) -
1085 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1086 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1087 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1088 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1089 \( -name '*.cpp' -o -name '*.h' \) -print | \
1090 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1093 ###############################################################################
1094 # DEPENDENCIES: Include the dependency files if we should
1095 ###############################################################################
1096 ifndef DISABLE_AUTO_DEPENDENCIES
1098 # If its not one of the cleaning targets
1099 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1101 # Get the list of dependency files
1102 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1103 DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1105 -include /dev/null $(DependFiles)
1111 ###############################################################################
1112 # CHECK: Running the test suite
1113 ###############################################################################
1116 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1117 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1118 $(EchoCmd) Running test suite ; \
1119 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1120 TESTSUITE=$(TESTSUITE) ; \
1122 $(EchoCmd) No Makefile in test directory ; \
1125 $(EchoCmd) No test directory ; \
1128 ###############################################################################
1129 # DISTRIBUTION: Handle construction of a distribution tarball
1130 ###############################################################################
1132 #------------------------------------------------------------------------
1133 # Define distribution related variables
1134 #------------------------------------------------------------------------
1135 DistName := $(LLVM_TARBALL_NAME)
1136 DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1137 TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
1138 DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1139 DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1140 DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1141 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1142 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1143 Makefile.config.in configure autoconf
1144 DistOther := $(notdir $(wildcard \
1145 $(BUILD_SRC_DIR)/*.h \
1146 $(BUILD_SRC_DIR)/*.td \
1147 $(BUILD_SRC_DIR)/*.def \
1148 $(BUILD_SRC_DIR)/*.ll \
1149 $(BUILD_SRC_DIR)/*.in))
1150 DistSubDirs := $(SubDirs)
1151 DistSources = $(Sources) $(EXTRA_DIST)
1152 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1154 #------------------------------------------------------------------------
1155 # We MUST build distribution with OBJ_DIR != SRC_DIR
1156 #------------------------------------------------------------------------
1157 ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1158 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1159 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1163 #------------------------------------------------------------------------
1164 # Prevent catastrophic remove
1165 #------------------------------------------------------------------------
1166 ifeq ($(LLVM_TARBALL_NAME),)
1167 $(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1170 #------------------------------------------------------------------------
1171 # Prevent attempt to run dist targets from anywhere but the top level
1172 #------------------------------------------------------------------------
1175 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1176 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
1180 #------------------------------------------------------------------------
1181 # Provide the top level targets
1182 #------------------------------------------------------------------------
1184 dist-gzip:: $(DistTarGZip)
1186 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1187 $(Echo) Packing gzipped distribution tar file.
1188 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1189 $(GZIP) -c > "$(DistTarGZip)"
1191 dist-bzip2:: $(DistTarBZ2)
1193 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1194 $(Echo) Packing bzipped distribution tar file.
1195 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1196 $(BZIP2) -c >$(DistTarBZ2)
1198 dist-zip:: $(DistZip)
1200 $(DistZip) : $(TopDistDir)/.makedistdir
1201 $(Echo) Packing zipped distribution file.
1202 $(Verb) rm -f $(DistZip)
1203 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1205 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1206 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1208 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1210 dist-check:: $(DistTarGZip)
1211 $(Echo) Checking distribution tar file.
1212 $(Verb) if test -d $(DistCheckDir) ; then \
1213 $(RM) -rf $(DistCheckDir) ; \
1215 $(Verb) $(MKDIR) $(DistCheckDir)
1216 $(Verb) cd $(DistCheckDir) && \
1217 $(MKDIR) $(DistCheckDir)/build && \
1218 $(MKDIR) $(DistCheckDir)/install && \
1219 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1221 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1222 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1225 $(MAKE) install && \
1226 $(MAKE) uninstall && \
1229 $(MAKE) dist-clean && \
1230 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1233 $(Echo) Cleaning distribution files
1234 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1239 #------------------------------------------------------------------------
1240 # Provide the recursive distdir target for building the distribution directory
1241 #------------------------------------------------------------------------
1242 distdir: $(DistDir)/.makedistdir
1243 $(DistDir)/.makedistdir: $(DistSources)
1244 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1245 if test -d "$(DistDir)" ; then \
1246 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1249 $(EchoCmd) Removing old $(DistDir) ; \
1250 $(RM) -rf $(DistDir); \
1251 $(EchoCmd) Making 'all' to verify build ; \
1254 $(Echo) Building Distribution Directory $(DistDir)
1255 $(Verb) $(MKDIR) $(DistDir)
1256 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1257 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1258 for file in $(DistFiles) ; do \
1260 $(BUILD_SRC_DIR)/*) \
1261 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1263 $(BUILD_SRC_ROOT)/*) \
1264 file=`echo "$$file" | \
1265 sed "s#^$$srcrootstrip/##"` \
1268 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1269 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1270 from_dir="$(BUILD_SRC_DIR)" ; \
1271 elif test -f "$$file" || test -d "$$file" ; then \
1274 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1275 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1276 to_dir="$(DistDir)/$$dir"; \
1277 $(MKDIR) "$$to_dir" ; \
1279 to_dir="$(DistDir)"; \
1281 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1282 if test -n "$$mid_dir" ; then \
1283 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1285 if test -d "$$from_dir/$$file"; then \
1286 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1287 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1288 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1290 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1291 elif test -f "$$from_dir/$$file" ; then \
1292 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1293 elif test -L "$$from_dir/$$file" ; then \
1294 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1295 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1296 $(EchoCmd) "===== WARNING: Distribution Source " \
1297 "$$from_dir/$$file Not Found!" ; \
1298 elif test "$(Verb)" != '@' ; then \
1299 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1302 $(Verb) for subdir in $(DistSubDirs) ; do \
1303 if test "$$subdir" \!= "." ; then \
1304 new_distdir="$(DistDir)/$$subdir" ; \
1305 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1306 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1310 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1311 $(EchoCmd) Eliminating CVS directories from distribution ; \
1312 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1313 $(MAKE) dist-hook ; \
1314 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1315 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1316 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1317 -o ! -type d ! -perm -444 -exec \
1318 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1319 || chmod -R a+r $(DistDir) ; \
1322 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1328 ###############################################################################
1329 # TOP LEVEL - targets only to apply at the top level directory
1330 ###############################################################################
1334 #------------------------------------------------------------------------
1335 # Install support for the project's include files:
1336 #------------------------------------------------------------------------
1338 $(Echo) Installing include files
1339 $(Verb) $(MKDIR) $(includedir)
1340 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1341 cd $(BUILD_SRC_ROOT)/include && \
1342 find . -path '*/Internal' -prune -o '(' -type f \
1343 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1344 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1348 $(Echo) Uninstalling include files
1349 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1350 cd $(BUILD_SRC_ROOT)/include && \
1351 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1352 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1353 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1358 #------------------------------------------------------------------------
1359 # Print out the directories used for building
1360 #------------------------------------------------------------------------
1362 $(Echo) "BuildMode : " '$(BuildMode)'
1363 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1364 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1365 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1366 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1367 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1368 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1369 $(Echo) "libdir : " '$(libdir)'
1370 $(Echo) "bindir : " '$(bindir)'
1371 $(Echo) "sysconfdir : " '$(sysconfdir)'
1372 $(Echo) "UserTargets : " '$(UserTargets)'
1373 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1374 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1375 $(Echo) "ObjDir : " '$(ObjDir)'
1376 $(Echo) "LibDir : " '$(LibDir)'
1377 $(Echo) "ToolDir : " '$(ToolDir)'
1378 $(Echo) "ExmplDir : " '$(ExmplDir)'
1379 $(Echo) "Sources : " '$(Sources)'
1380 $(Echo) "TDFiles : " '$(TDFiles)'
1381 $(Echo) "INCFiles : " '$(INCFiles)'
1382 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1383 $(Echo) "Compile.C : " '$(Compile.C)'
1384 $(Echo) "Archive : " '$(Archive)'
1385 $(Echo) "YaccFiles : " '$(YaccFiles)'
1386 $(Echo) "LexFiles : " '$(LexFiles)'
1387 $(Echo) "Module : " '$(Module)'