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 #--------------------------------------------------------------------
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 $(PROJ_SRC_DIR)/Makefile*))
65 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66 ConfigureScript := $(PROJ_SRC_ROOT)/configure
67 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73 ifneq ($(MakefileCommonIn),)
74 PreConditions += $(MakefileCommon)
76 ifneq ($(MakefileConfigIn),)
77 PreConditions += $(MakefileConfig)
80 preconditions : $(PreConditions)
82 #------------------------------------------------------------------------
83 # Make sure the BUILT_SOURCES are built first
84 #------------------------------------------------------------------------
85 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
88 ifneq ($(strip $(BUILT_SOURCES)),)
89 -$(Verb) $(RM) -f $(BUILT_SOURCES)
92 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
94 $(Verb) if test -x config.status ; then \
95 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
96 $(MKDIR) .spotless.save ; \
97 $(MV) config.status .spotless.save ; \
98 $(MV) mklib .spotless.save ; \
99 $(MV) projects .spotless.save ; \
101 $(MV) .spotless.save/config.status . ; \
102 $(MV) .spotless.save/mklib . ; \
103 $(MV) .spotless.save/projects . ; \
104 $(RM) -rf .spotless.save ; \
105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
113 $(BUILT_SOURCES) : $(ObjMakefiles)
115 #------------------------------------------------------------------------
116 # Make sure we're not using a stale configuration
117 #------------------------------------------------------------------------
119 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
120 $(Verb) cd $(PROJ_OBJ_ROOT) && \
121 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
122 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
124 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
125 $(ConfigStatusScript)
127 .PRECIOUS: $(ConfigStatusScript)
128 $(ConfigStatusScript): $(ConfigureScript)
129 $(Echo) Reconfiguring with $<
130 $(Verb) cd $(PROJ_OBJ_ROOT) && \
131 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
132 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
134 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
135 $(ConfigStatusScript)
137 #------------------------------------------------------------------------
138 # Make sure the configuration makefile is up to date
139 #------------------------------------------------------------------------
140 ifneq ($(MakefileConfigIn),)
141 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
142 $(Echo) Regenerating $@
143 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
146 ifneq ($(MakefileCommonIn),)
147 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
148 $(Echo) Regenerating $@
149 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
152 #------------------------------------------------------------------------
153 # If the Makefile in the source tree has been updated, copy it over into the
154 # build tree. But, only do this if the source and object makefiles differ
155 #------------------------------------------------------------------------
156 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
158 Makefile: $(PROJ_SRC_DIR)/Makefile
159 $(Echo) "Updating Makefile"
160 $(Verb) $(MKDIR) $(@D)
161 $(Verb) $(CP) -f $< $@
163 # Copy the Makefile.* files unless we're in the root directory which avoids
164 # the copying of Makefile.config.in or other things that should be explicitly
166 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
168 *Makefile.rules) ;; \
170 *) $(Echo) "Updating $(@F)" ; \
177 #------------------------------------------------------------------------
178 # Set up the basic dependencies
179 #------------------------------------------------------------------------
180 $(UserTargets):: $(PreConditions)
184 clean-all:: clean-local clean-all-local
185 install:: install-local
186 uninstall:: uninstall-local
187 install-local:: all-local
188 install-bytecode:: install-bytecode-local
190 ###############################################################################
191 # VARIABLES: Set up various variables based on configuration data
192 ###############################################################################
194 #--------------------------------------------------------------------
195 # Variables derived from configuration we are building
196 #--------------------------------------------------------------------
199 ifdef ENABLE_PROFILING
201 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
202 C.Flags := -O3 -DNDEBUG -pg
203 LD.Flags := -O3 -DNDEBUG -pg
205 ifdef ENABLE_OPTIMIZED
207 # Don't use -fomit-frame-pointer on FreeBSD
208 ifneq ($(OS),FreeBSD)
209 OmitFramePointer := -fomit-frame-pointer
211 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \
213 C.Flags := -O3 -DNDEBUG $(OmitFramePointer)
214 LD.Flags := -O3 -DNDEBUG
217 CXX.Flags := -g -D_DEBUG
218 C.Flags := -g -D_DEBUG
219 LD.Flags := -g -D_DEBUG
224 CXX.Flags += $(CXXFLAGS)
226 CPP.Flags += $(CPPFLAGS)
227 LD.Flags += $(LDFLAGS)
229 LibTool.Flags := --tag=CXX
231 #--------------------------------------------------------------------
232 # Directory locations
233 #--------------------------------------------------------------------
234 ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
235 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
236 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
237 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
238 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
239 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
240 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
241 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
243 #--------------------------------------------------------------------
244 # Full Paths To Compiled Tools and Utilities
245 #--------------------------------------------------------------------
246 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
249 LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
252 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
255 BURG := $(LLVMToolDir)/burg$(EXEEXT)
258 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
261 GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
264 GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
267 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
270 LLI := $(LLVMToolDir)/lli$(EXEEXT)
273 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
275 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
276 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
278 #--------------------------------------------------------------------
279 # Adjust to user's request
280 #--------------------------------------------------------------------
282 # Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
283 # to be built. Note that if LOADABLE_MODULE is specified then the resulting
284 # shared library can be opened with dlopen
286 LD.Flags += -rpath $(LibDir)
287 ifdef LOADABLE_MODULE
291 LibTool.Flags += --tag=disable-shared
301 # Adjust settings for verbose mode
304 LibTool.Flags += --silent
305 AR.Flags += >/dev/null 2>/dev/null
306 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
308 ConfigureScriptFLAGS :=
311 # By default, strip symbol information from executable
313 Strip := $(PLATFORMSTRIPOPTS)
314 StripWarnMsg := "(without symbols)"
317 # Adjust linker flags for building an executable
320 LD.Flags += -rpath $(ExmplDir) -export-dynamic
322 LD.Flags += -rpath $(ToolDir) -export-dynamic
326 #----------------------------------------------------------
327 # Options To Invoke Tools
328 #----------------------------------------------------------
330 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
332 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
333 CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
334 -I$(PROJ_OBJ_ROOT)/include \
335 -I$(PROJ_SRC_ROOT)/include \
336 -I$(LLVM_OBJ_ROOT)/include \
337 -I$(LLVM_SRC_ROOT)/include \
338 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
340 Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
341 LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
342 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
344 Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
345 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
346 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
348 Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
349 $(CompileCommonOpts) $(LD.Flags) $(Strip)
350 Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
352 LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
353 Burg = $(BURG) -I $(PROJ_SRC_DIR)
354 TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR)
355 Archive = $(AR) $(AR.Flags)
356 LArchive = $(LLVMToolDir)/llvm-ar rcsf
363 #----------------------------------------------------------
364 # Get the list of source files and compute object file
366 #----------------------------------------------------------
369 FakeSources := $(FAKE_SOURCES)
371 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
373 BaseNameSources := $(sort $(basename $(FakeSources)))
374 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
375 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
376 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
379 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
380 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
381 $(PROJ_SRC_DIR)/*.l))
383 Sources := $(SOURCES)
387 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
390 BaseNameSources := $(sort $(basename $(Sources)))
391 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
392 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
393 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
396 ###############################################################################
397 # DIRECTORIES: Handle recursive descent of directory structure
398 ###############################################################################
400 #---------------------------------------------------------
401 # Provide rules to make install dirs. This must be early
402 # in the file so they get built before dependencies
403 #---------------------------------------------------------
406 $(Verb) $(MKDIR) $(PROJ_bindir)
409 $(Verb) $(MKDIR) $(PROJ_libdir)
412 $(Verb) $(MKDIR) $(PROJ_includedir)
415 $(Verb) $(MKDIR) $(PROJ_etcdir)
417 # To create other directories, as needed, and timestamp their creation
419 $(Verb) $(MKDIR) $* > /dev/null
422 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
423 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
425 #---------------------------------------------------------
426 # Handle the DIRS options for sequential construction
427 #---------------------------------------------------------
432 $(RecursiveTargets)::
433 $(Verb) for dir in $(DIRS); do \
434 if [ ! -f $$dir/Makefile ]; then \
436 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
438 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
439 ($(MAKE) -C $$dir $@ ) || exit 1; \
444 #---------------------------------------------------------
445 # Handle the EXPERIMENTAL_DIRS options ensuring success
446 # after each directory is built.
447 #---------------------------------------------------------
448 ifdef EXPERIMENTAL_DIRS
449 $(RecursiveTargets)::
450 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
451 if [ ! -f $$dir/Makefile ]; then \
453 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
455 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
456 ($(MAKE) -C $$dir $@ ) || exit 0; \
461 #---------------------------------------------------------
462 # Handle the PARALLEL_DIRS options for parallel construction
463 #---------------------------------------------------------
466 SubDirs += $(PARALLEL_DIRS)
468 # Unfortunately, this list must be maintained if new recursive targets are added
469 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
470 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
471 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
472 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
473 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
474 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
476 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
479 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
481 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
483 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
484 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
488 #---------------------------------------------------------
489 # Handle the OPTIONAL_DIRS options for directores that may
491 #---------------------------------------------------------
494 SubDirs += $(OPTIONAL_DIRS)
496 $(RecursiveTargets)::
497 $(Verb) for dir in $(OPTIONAL_DIRS); do \
498 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
499 if [ ! -f $$dir/Makefile ]; then \
501 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
503 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
504 ($(MAKE) -C$$dir $@ ) || exit 1; \
510 #---------------------------------------------------------
511 # Handle the CONFIG_FILES options
512 #---------------------------------------------------------
515 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
516 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
517 $(Verb)for file in $(CONFIG_FILES); do \
518 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
519 $(INSTALL) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
520 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
521 $(INSTALL) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
523 $(ECHO) Error: cannot find config file $${file}. ; \
528 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
529 $(Verb)for file in $(CONFIG_FILES); do \
530 $(RM) -f $(PROJ_etcdir)/$${file} ; \
535 ###############################################################################
536 # Library Build Rules: Four ways to build a library
537 ###############################################################################
539 #---------------------------------------------------------
540 # Bytecode Module Targets:
541 # If the user set MODULE_NAME then they want to build a
542 # bytecode module from the sources. We compile all the
543 # sources and link it together into a single bytecode
545 #---------------------------------------------------------
549 Module := $(LibDir)/$(MODULE_NAME).bc
550 LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
552 ifdef EXPORTED_SYMBOL_FILE
553 LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
556 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
557 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
558 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
560 all-local:: $(Module)
563 ifneq ($(strip $(Module)),)
564 -$(Verb) $(RM) -f $(Module)
567 ifdef BYTECODE_DESTINATION
568 ModuleDestDir := $(BYTECODE_DESTINATION)
570 ModuleDestDir := $(PROJ_libdir)
573 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
575 install-module:: $(DestModule)
576 install-local:: $(DestModule)
578 $(DestModule): $(ModuleDestDir) $(Module)
579 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
580 $(Verb) $(INSTALL) $(Module) $@
583 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
584 -$(Verb) $(RM) -f $(DestModule)
588 # if we're building a library ...
591 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
592 LIBRARYNAME := $(strip $(LIBRARYNAME))
593 ifdef LOADABLE_MODULE
594 LibName.LA := $(LibDir)/$(LIBRARYNAME).la
596 LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
598 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
599 LibName.O := $(LibDir)/$(LIBRARYNAME).o
600 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
602 #---------------------------------------------------------
603 # Shared Library Targets:
604 # If the user asked for a shared library to be built
605 # with the SHARED_LIBRARY variable, then we provide
606 # targets for building them.
607 #---------------------------------------------------------
610 all-local:: $(LibName.LA)
612 $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
613 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
614 $(Verb) $(Link) -o $@ $(ObjectsLO)
615 $(Verb) $(LTInstall) $@ $(LibDir)
618 ifneq ($(strip $(LibName.LA)),)
619 -$(Verb) $(RM) -f $(LibName.LA)
622 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
624 install-local:: $(DestSharedLib)
626 $(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
627 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
628 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
629 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
632 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
633 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
637 #---------------------------------------------------------
638 # Bytecode Library Targets:
639 # If the user asked for a bytecode library to be built
640 # with the BYTECODE_LIBRARY variable, then we provide
641 # targets for building them.
642 #---------------------------------------------------------
643 ifdef BYTECODE_LIBRARY
645 # make the C and C++ compilers strip debug info out of bytecode libraries.
646 BCCompile.C += -Wa,-strip-debug
647 BCCompile.CXX += -Wa,-strip-debug
649 all-local:: $(LibName.BCA)
651 ifdef EXPORTED_SYMBOL_FILE
652 BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
653 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
655 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
656 $(LLVMToolDir)/llvm-ar
657 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
659 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
661 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
663 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
664 $(LLVMToolDir)/llvm-ar
665 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
667 $(Verb) $(LArchive) $@ $(ObjectsBC)
672 ifneq ($(strip $(LibName.BCA)),)
673 -$(Verb) $(RM) -f $(LibName.BCA)
676 ifdef BYTECODE_DESTINATION
677 BytecodeDestDir := $(BYTECODE_DESTINATION)
679 BytecodeDestDir := $(PROJ_libdir)
682 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
684 install-bytecode-local:: $(DestBytecodeLib)
686 install-local:: $(DestBytecodeLib)
688 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
689 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
690 $(Verb) $(INSTALL) $(LibName.BCA) $@
693 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
694 -$(Verb) $(RM) -f $(DestBytecodeLib)
698 #---------------------------------------------------------
699 # ReLinked Library Targets:
700 # If the user didn't explicitly forbid building a
701 # relinked then we provide targets for building them.
702 #---------------------------------------------------------
703 ifndef DONT_BUILD_RELINKED
705 all-local:: $(LibName.O)
707 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
708 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
709 $(Verb) $(Relink) -o $@ $(ObjectsO)
712 ifneq ($(strip $(LibName.O)),)
713 -$(Verb) $(RM) -f $(LibName.O)
716 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
718 install-local:: $(DestRelinkedLib)
720 $(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
721 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
722 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
725 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
726 -$(Verb) $(RM) -f $(DestRelinkedLib)
730 #---------------------------------------------------------
731 # Archive Library Targets:
732 # If the user wanted a regular archive library built,
733 # then we provide targets for building them.
734 #---------------------------------------------------------
737 all-local:: $(LibName.A)
739 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
740 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
742 $(Verb) $(Archive) $@ $(ObjectsO)
746 ifneq ($(strip $(LibName.A)),)
747 -$(Verb) $(RM) -f $(LibName.A)
750 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
752 install-local:: $(DestArchiveLib)
754 $(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
755 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
756 $(Verb) $(MKDIR) $(PROJ_libdir)
757 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
760 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
761 -$(Verb) $(RM) -f $(DestArchiveLib)
768 ###############################################################################
769 # Tool Build Rules: Build executable tool based on TOOLNAME option
770 ###############################################################################
774 #---------------------------------------------------------
775 # Handle the special "JIT" value for LLVM_LIBS which is a
776 # shorthand for a bunch of libraries that get the correct
777 # JIT support for a tool that runs JIT.
778 #---------------------------------------------------------
779 ifeq ($(LLVMLIBS),JIT)
781 # Make sure we can get our own symbols in the tool
784 # Generic JIT libraries
785 JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
787 # You can enable the X86 JIT on a non-X86 host by setting the flag
788 # ENABLE_X86_JIT on the make command line. If not, it will still be
789 # enabled automagically on an X86 host.
794 # What the X86 JIT requires
796 JIT_LIBS += LLVMX86 LLVMSelectionDAG
799 # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
800 # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
801 # enabled automagically on an SparcV9 host.
802 ifeq ($(ARCH), Sparc)
803 ENABLE_SPARCV9_JIT = 1
806 # What the Sparc JIT requires
807 ifdef ENABLE_SPARCV9_JIT
808 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
809 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
810 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
811 LLVMDataStructure.a LLVMSparcV9RegAlloc
814 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
815 # ENABLE_PPC_JIT on the make command line. If not, it will still be
816 # enabled automagically on an PowerPC host.
817 ifeq ($(ARCH), PowerPC)
821 # What the PowerPC JIT requires
823 JIT_LIBS += LLVMPowerPC
826 LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
827 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
828 LLVMSystem.a $(PLATFORMLIBDL)
831 #---------------------------------------------------------
832 # Set up variables for building a tool.
833 #---------------------------------------------------------
835 ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
837 ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
839 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
840 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
841 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
842 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
843 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
844 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
845 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
846 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
848 #---------------------------------------------------------
849 # Tell make that we need to rebuild subdirectories before
850 # we can link the tool. This affects things like LLI which
851 # has library subdirectories.
852 #---------------------------------------------------------
853 $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
855 #---------------------------------------------------------
856 # Provide targets for building the tools
857 #---------------------------------------------------------
858 all-local:: $(ToolBuildPath)
861 ifneq ($(strip $(ToolBuildPath)),)
862 -$(Verb) $(RM) -f $(ToolBuildPath)
866 $(ToolBuildPath): $(ExmplDir)/.dir
868 $(ToolBuildPath): $(ToolDir)/.dir
871 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
872 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
873 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
874 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
875 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
877 DestTool = $(PROJ_bindir)/$(TOOLNAME)
879 install-local:: $(DestTool)
881 $(DestTool): $(PROJ_bindir) $(ToolBuildPath)
882 $(Echo) Installing $(BuildMode) $(DestTool)
883 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
886 $(Echo) Uninstalling $(BuildMode) $(DestTool)
887 -$(Verb) $(RM) -f $(DestTool)
891 ###############################################################################
892 # Object Build Rules: Build object files based on sources
893 ###############################################################################
895 # Provide rule sets for when dependency generation is enabled
896 ifndef DISABLE_AUTO_DEPENDENCIES
898 #---------------------------------------------------------
899 # Create .lo files in the ObjDir directory from the .cpp and .c files...
900 #---------------------------------------------------------
903 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
904 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
905 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
906 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
907 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
909 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
910 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
911 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
912 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
913 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
915 #---------------------------------------------------------
916 # Create .o files in the ObjDir directory from the .cpp and .c files...
917 #---------------------------------------------------------
920 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
921 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
922 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
923 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
924 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
926 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
927 $(Echo) "Compiling $*.c for $(BuildMode) build"
928 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
929 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
930 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
934 #---------------------------------------------------------
935 # Create .bc files in the ObjDir directory from .cpp and .c files...
936 #---------------------------------------------------------
937 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
938 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
939 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
940 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
941 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
943 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
944 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
945 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
946 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
947 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
949 # Provide alternate rule sets if dependencies are disabled
954 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
955 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
956 $(LTCompile.CXX) $< -o $@
958 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
959 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
960 $(LTCompile.C) $< -o $@
964 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
965 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
966 $(Compile.CXX) $< -o $@
968 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
969 $(Echo) "Compiling $*.c for $(BuildMode) build"
970 $(Compile.C) $< -o $@
973 $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
974 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
975 $(BCCompile.CXX) $< -o $@
977 $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
978 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
979 $(BCCompile.C) $< -o $@
983 #---------------------------------------------------------
984 # Provide rule to build .bc files from .ll sources,
985 # regardless of dependencies
986 #---------------------------------------------------------
987 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
988 $(Echo) "Compiling $*.ll for $(BuildMode) build"
989 $(Verb) $(LLVMAS) $< -f -o $@
991 ###############################################################################
992 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
993 ###############################################################################
997 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
998 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
999 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1000 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1002 # All of these files depend on tblgen and the .td files.
1003 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1005 # INCFiles rule: All of the tblgen generated files are emitted to
1006 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1007 # us to only "touch" the real file if the contents of it change. IOW, if
1008 # tblgen is modified, all of the .inc.tmp files are regereated, but no
1009 # dependencies of the .inc files are, unless the contents of the .inc file
1011 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1012 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1014 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1015 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1016 $(Echo) "Building $(<F) register names with tblgen"
1017 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
1019 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1020 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1021 $(Echo) "Building $(<F) register information header with tblgen"
1022 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
1024 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1025 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1026 $(Echo) "Building $(<F) register info implementation with tblgen"
1027 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
1029 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1030 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1031 $(Echo) "Building $(<F) instruction names with tblgen"
1032 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
1034 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1035 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1036 $(Echo) "Building $(<F) instruction information with tblgen"
1037 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
1039 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1040 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1041 $(Echo) "Building $(<F) assembly writer with tblgen"
1042 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
1044 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1045 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1046 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1047 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
1049 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1050 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1051 $(Echo) "Building $(<F) code emitter with tblgen"
1052 $(Verb) $(TableGen) -gen-emitter -o $@ $<
1055 -$(Verb) $(RM) -f $(INCFiles)
1059 ###############################################################################
1060 # LEX AND YACC: Provide rules for generating sources with lex and yacc
1061 ###############################################################################
1063 #---------------------------------------------------------
1064 # Provide rules for generating a .cpp source file from
1065 # (f)lex input sources.
1066 #---------------------------------------------------------
1068 LexFiles := $(filter %.l,$(Sources))
1070 ifneq ($(LexFiles),)
1072 LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
1074 .PRECIOUS: $(LexOutput)
1076 # Note the extra sed filtering here, used to cut down on the warnings emited
1077 # by GCC. The last line is a gross hack to work around flex aparently not
1078 # being able to resize the buffer on a large token input. Currently, for
1079 # uninitialized string buffers in LLVM we can generate very long tokens, so
1080 # this is a hack around it.
1081 # FIXME. (f.e. char Buffer[10000] )
1083 $(Echo) Flexing $*.l
1084 $(Verb) $(FLEX) -t $< | \
1085 $(SED) 's/void yyunput/inline void yyunput/' | \
1086 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1087 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
1091 -$(Verb) $(RM) -f $(LexOutput)
1092 $(Verb) $(RM) -f $(LexOutput)
1096 #---------------------------------------------------------
1097 # Provide rules for generating a .cpp and .h source files
1098 # from yacc (bison) input sources.
1099 #---------------------------------------------------------
1101 YaccFiles := $(filter %.y,$(Sources))
1102 ifneq ($(YaccFiles),)
1103 YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
1105 .PRECIOUS: $(YaccOutput)
1107 # Cancel built-in rules for yacc
1112 # Rule for building the bison parsers...
1114 $(Echo) "Bisoning $*.y"
1115 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1116 $(Verb) $(MV) -f $*.tab.c $*.cpp
1117 $(Verb) $(MV) -f $*.tab.h $*.h
1120 -$(Verb) $(RM) -f $(YaccOutput)
1121 $(Verb) $(RM) -f $(YaccOutput)
1124 ###############################################################################
1125 # OTHER RULES: Other rules needed
1126 ###############################################################################
1128 # To create postscript files from dot files...
1129 ifneq ($(DOT),false)
1131 $(DOT) -Tps < $< > $@
1134 $(Echo) "Cannot build $@: The program dot is not installed"
1137 # This rules ensures that header files that are removed still have a rule for
1138 # which they can be "generated." This allows make to ignore them and
1139 # reproduce the dependency lists.
1142 # Define clean-local to clean the current directory. Note that this uses a
1143 # very conservative approach ensuring that empty variables do not cause
1144 # errors or disastrous removal.
1146 ifneq ($(strip $(ObjDir)),)
1147 -$(Verb) $(RM) -rf $(ObjDir)
1149 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1150 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1151 -$(Verb) $(RM) -f *$(SHLIBEXT)
1155 -$(Verb) $(RM) -rf Debug Release Profile
1157 # Build tags database for Emacs/Xemacs:
1161 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1162 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1163 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1164 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1165 -name '*.cpp' -o -name '*.h' | \
1166 $(ETAGS) $(ETAGSFLAGS) -
1169 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1170 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1171 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1172 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
1173 \( -name '*.cpp' -o -name '*.h' \) -print | \
1174 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
1177 ###############################################################################
1178 # DEPENDENCIES: Include the dependency files if we should
1179 ###############################################################################
1180 ifndef DISABLE_AUTO_DEPENDENCIES
1182 # If its not one of the cleaning targets
1183 ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
1185 # Get the list of dependency files
1186 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1187 DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
1189 -include /dev/null $(DependFiles)
1195 ###############################################################################
1196 # CHECK: Running the test suite
1197 ###############################################################################
1200 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1201 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1202 $(EchoCmd) Running test suite ; \
1203 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1204 TESTSUITE=$(TESTSUITE) ; \
1206 $(EchoCmd) No Makefile in test directory ; \
1209 $(EchoCmd) No test directory ; \
1212 ###############################################################################
1213 # DISTRIBUTION: Handle construction of a distribution tarball
1214 ###############################################################################
1216 #------------------------------------------------------------------------
1217 # Define distribution related variables
1218 #------------------------------------------------------------------------
1219 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1220 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1221 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1222 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1223 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1224 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1225 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1226 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1227 Makefile.config.in configure autoconf
1228 DistOther := $(notdir $(wildcard \
1229 $(PROJ_SRC_DIR)/*.h \
1230 $(PROJ_SRC_DIR)/*.td \
1231 $(PROJ_SRC_DIR)/*.def \
1232 $(PROJ_SRC_DIR)/*.ll \
1233 $(PROJ_SRC_DIR)/*.in))
1234 DistSubDirs := $(SubDirs)
1235 DistSources = $(Sources) $(EXTRA_DIST)
1236 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1238 #------------------------------------------------------------------------
1239 # We MUST build distribution with OBJ_DIR != SRC_DIR
1240 #------------------------------------------------------------------------
1241 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1242 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1243 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1247 #------------------------------------------------------------------------
1248 # Prevent attempt to run dist targets from anywhere but the top level
1249 #------------------------------------------------------------------------
1251 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1252 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1255 #------------------------------------------------------------------------
1256 # Provide the top level targets
1257 #------------------------------------------------------------------------
1259 dist-gzip:: $(DistTarGZip)
1261 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1262 $(Echo) Packing gzipped distribution tar file.
1263 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1264 $(GZIP) -c > "$(DistTarGZip)"
1266 dist-bzip2:: $(DistTarBZ2)
1268 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1269 $(Echo) Packing bzipped distribution tar file.
1270 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1271 $(BZIP2) -c >$(DistTarBZ2)
1273 dist-zip:: $(DistZip)
1275 $(DistZip) : $(TopDistDir)/.makedistdir
1276 $(Echo) Packing zipped distribution file.
1277 $(Verb) rm -f $(DistZip)
1278 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1280 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1281 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1283 DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1285 dist-check:: $(DistTarGZip)
1286 $(Echo) Checking distribution tar file.
1287 $(Verb) if test -d $(DistCheckDir) ; then \
1288 $(RM) -rf $(DistCheckDir) ; \
1290 $(Verb) $(MKDIR) $(DistCheckDir)
1291 $(Verb) cd $(DistCheckDir) && \
1292 $(MKDIR) $(DistCheckDir)/build && \
1293 $(MKDIR) $(DistCheckDir)/install && \
1294 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1296 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1297 --srcdir=../$(DistName) && \
1300 $(MAKE) install && \
1301 $(MAKE) uninstall && \
1304 $(MAKE) dist-clean && \
1305 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1308 $(Echo) Cleaning distribution files
1309 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1314 #------------------------------------------------------------------------
1315 # Provide the recursive distdir target for building the distribution directory
1316 #------------------------------------------------------------------------
1317 distdir: $(DistDir)/.makedistdir
1318 $(DistDir)/.makedistdir: $(DistSources)
1319 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1320 if test -d "$(DistDir)" ; then \
1321 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1324 $(EchoCmd) Removing old $(DistDir) ; \
1325 $(RM) -rf $(DistDir); \
1326 $(EchoCmd) Making 'all' to verify build ; \
1329 $(Echo) Building Distribution Directory $(DistDir)
1330 $(Verb) $(MKDIR) $(DistDir)
1331 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1332 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1333 for file in $(DistFiles) ; do \
1335 $(PROJ_SRC_DIR)/*) \
1336 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1338 $(PROJ_SRC_ROOT)/*) \
1339 file=`echo "$$file" | \
1340 sed "s#^$$srcrootstrip/##"` \
1343 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1344 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1345 from_dir="$(PROJ_SRC_DIR)" ; \
1346 elif test -f "$$file" || test -d "$$file" ; then \
1349 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1350 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1351 to_dir="$(DistDir)/$$dir"; \
1352 $(MKDIR) "$$to_dir" ; \
1354 to_dir="$(DistDir)"; \
1356 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1357 if test -n "$$mid_dir" ; then \
1358 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1360 if test -d "$$from_dir/$$file"; then \
1361 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1362 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1363 $(CP) -pR "$(PROJ_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1365 $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \
1366 elif test -f "$$from_dir/$$file" ; then \
1367 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1368 elif test -L "$$from_dir/$$file" ; then \
1369 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1370 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1371 $(EchoCmd) "===== WARNING: Distribution Source " \
1372 "$$from_dir/$$file Not Found!" ; \
1373 elif test "$(Verb)" != '@' ; then \
1374 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1377 $(Verb) for subdir in $(DistSubDirs) ; do \
1378 if test "$$subdir" \!= "." ; then \
1379 new_distdir="$(DistDir)/$$subdir" ; \
1380 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1381 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1385 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1386 $(EchoCmd) Eliminating CVS directories from distribution ; \
1387 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1388 $(MAKE) dist-hook ; \
1389 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1390 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1391 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1392 -o ! -type d ! -perm -444 -exec \
1393 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1394 || chmod -R a+r $(DistDir) ; \
1397 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1403 ###############################################################################
1404 # TOP LEVEL - targets only to apply at the top level directory
1405 ###############################################################################
1409 #------------------------------------------------------------------------
1410 # Install support for the project's include files:
1411 #------------------------------------------------------------------------
1413 $(Echo) Installing include files
1414 $(Verb) $(MKDIR) $(PROJ_includedir)
1415 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1416 cd $(PROJ_SRC_ROOT)/include && \
1417 find . -path '*/Internal' -prune -o '(' -type f \
1418 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1419 -print ')' | grep -v CVS | pax -rwdvpe $(PROJ_includedir) ; \
1423 $(Echo) Uninstalling include files
1424 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1425 cd $(PROJ_SRC_ROOT)/include && \
1426 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1427 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1428 -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1433 #------------------------------------------------------------------------
1434 # Print out the directories used for building
1435 #------------------------------------------------------------------------
1437 $(Echo) "BuildMode : " '$(BuildMode)'
1438 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1439 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1440 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1441 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1442 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1443 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1444 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1445 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1446 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1447 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1448 $(Echo) "UserTargets : " '$(UserTargets)'
1449 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1450 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1451 $(Echo) "ObjDir : " '$(ObjDir)'
1452 $(Echo) "LibDir : " '$(LibDir)'
1453 $(Echo) "ToolDir : " '$(ToolDir)'
1454 $(Echo) "ExmplDir : " '$(ExmplDir)'
1455 $(Echo) "Sources : " '$(Sources)'
1456 $(Echo) "TDFiles : " '$(TDFiles)'
1457 $(Echo) "INCFiles : " '$(INCFiles)'
1458 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1459 $(Echo) "Preconditions: " '$(Preconditions)'
1460 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1461 $(Echo) "Compile.C : " '$(Compile.C)'
1462 $(Echo) "Archive : " '$(Archive)'
1463 $(Echo) "YaccFiles : " '$(YaccFiles)'
1464 $(Echo) "LexFiles : " '$(LexFiles)'
1465 $(Echo) "Module : " '$(Module)'