1 #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # 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 unittests
26 TopLevelTargets := check dist dist-check dist-clean 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 .cc .h .hpp .o .a .bc .td .ps .dot .ll
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)
77 ifneq ($(MakefileConfigIn),)
78 PreConditions += $(MakefileConfig)
81 preconditions: $(PreConditions)
83 #------------------------------------------------------------------------
84 # Make sure the BUILT_SOURCES are built first
85 #------------------------------------------------------------------------
86 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
89 ifneq ($(strip $(BUILT_SOURCES)),)
90 -$(Verb) $(RM) -f $(BUILT_SOURCES)
93 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
95 $(Verb) if test -x config.status ; then \
96 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
97 $(MKDIR) .spotless.save ; \
98 $(MV) config.status .spotless.save ; \
99 $(MV) mklib .spotless.save ; \
100 $(MV) projects .spotless.save ; \
102 $(MV) .spotless.save/config.status . ; \
103 $(MV) .spotless.save/mklib . ; \
104 $(MV) .spotless.save/projects . ; \
105 $(RM) -rf .spotless.save ; \
106 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
107 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
108 $(ConfigStatusScript) ; \
110 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
114 $(EchoCmd) "spotless target not supported for objdir == srcdir"
117 $(BUILT_SOURCES) : $(ObjMakefiles)
119 #------------------------------------------------------------------------
120 # Make sure we're not using a stale configuration
121 #------------------------------------------------------------------------
123 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
124 $(Verb) cd $(PROJ_OBJ_ROOT) && \
125 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
126 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
128 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
129 $(ConfigStatusScript)
131 .PRECIOUS: $(ConfigStatusScript)
132 $(ConfigStatusScript): $(ConfigureScript)
133 $(Echo) Reconfiguring with $<
134 $(Verb) cd $(PROJ_OBJ_ROOT) && \
135 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
136 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
138 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
139 $(ConfigStatusScript)
141 #------------------------------------------------------------------------
142 # Make sure the configuration makefile is up to date
143 #------------------------------------------------------------------------
144 ifneq ($(MakefileConfigIn),)
145 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
146 $(Echo) Regenerating $@
147 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
150 ifneq ($(MakefileCommonIn),)
151 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
152 $(Echo) Regenerating $@
153 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
156 #------------------------------------------------------------------------
157 # If the Makefile in the source tree has been updated, copy it over into the
158 # build tree. But, only do this if the source and object makefiles differ
159 #------------------------------------------------------------------------
160 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
162 Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
163 $(Echo) "Updating Makefile"
164 $(Verb) $(MKDIR) $(@D)
165 $(Verb) $(CP) -f $< $@
167 # Copy the Makefile.* files unless we're in the root directory which avoids
168 # the copying of Makefile.config.in or other things that should be explicitly
170 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
172 *Makefile.rules) ;; \
174 *) $(EchoCmd) "Updating $(@F)" ; \
181 #------------------------------------------------------------------------
182 # Set up the basic dependencies
183 #------------------------------------------------------------------------
184 $(UserTargets):: $(PreConditions)
188 clean-all:: clean-local clean-all-local
189 install:: install-local
190 uninstall:: uninstall-local
191 install-local:: all-local
192 install-bytecode:: install-bytecode-local
194 ###############################################################################
195 # LLVMC: Provide rules for compiling llvmc plugins
196 ###############################################################################
200 LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
203 # Build a dynamic library if the user runs `make` directly from the plugin
205 ifndef LLVMC_BUILTIN_PLUGIN
210 ifneq ($(BUILT_SOURCES),)
211 LLVMC_BUILD_AUTOGENERATED_INC=1
216 ###############################################################################
217 # VARIABLES: Set up various variables based on configuration data
218 ###############################################################################
220 # Variable for if this make is for a "cleaning" target
221 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
225 #--------------------------------------------------------------------
226 # Variables derived from configuration we are building
227 #--------------------------------------------------------------------
230 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
231 # this can be overridden on the make command line.
232 ifndef OPTIMIZE_OPTION
234 OPTIMIZE_OPTION := -O3
236 OPTIMIZE_OPTION := -O2
240 ifeq ($(ENABLE_OPTIMIZED),1)
242 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
243 ifneq ($(OS),FreeBSD)
245 OmitFramePointer := -fomit-frame-pointer
249 # Darwin requires -fstrict-aliasing to be explicitly enabled.
250 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
251 # with -fstrict-aliasing and ipa-type-escape radr://6756684
253 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
255 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
256 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
257 LD.Flags += $(OPTIMIZE_OPTION)
266 ifeq ($(ENABLE_PROFILING),1)
267 BuildMode := $(BuildMode)+Profile
268 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
269 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
270 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
274 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
275 # CXX.Flags += -fvisibility-inlines-hidden
278 # IF REQUIRES_EH=1 is specified then don't disable exceptions
280 CXX.Flags += -fno-exceptions
283 # IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
285 # CXX.Flags += -fno-rtti
288 ifdef ENABLE_COVERAGE
289 BuildMode := $(BuildMode)+Coverage
290 # These only go to .NoRelink because otherwise we will end up
291 # linking -lgcov into the .o libraries that get built.
292 CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs
293 C.Flags.NoRelink += -ftest-coverage -fprofile-arcs
296 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
297 # then disable assertions by defining the appropriate preprocessor symbols.
298 ifdef DISABLE_ASSERTIONS
299 # Indicate that assertions are turned off using a minus sign
300 BuildMode := $(BuildMode)-Asserts
301 CPP.Defines += -DNDEBUG
303 CPP.Defines += -D_DEBUG
306 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
307 # configured), then enable expensive checks by defining the
308 # appropriate preprocessor symbols.
309 ifdef ENABLE_EXPENSIVE_CHECKS
310 BuildMode := $(BuildMode)+Checks
311 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
314 # LOADABLE_MODULE implies several other things so we force them to be
316 ifdef LOADABLE_MODULE
318 DONT_BUILD_RELINKED := 1
319 LINK_LIBS_IN_SHARED := 1
327 ifeq ($(ENABLE_PIC),1)
328 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
329 # Nothing. Win32 defaults to PIC and warns when given -fPIC
332 # Common symbols not allowed in dylib files
333 CXX.Flags += -fno-common
334 C.Flags += -fno-common
336 # Linux and others; pass -fPIC
343 CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
345 CPP.Defines += $(CPPFLAGS)
346 CPP.BaseFlags += $(CPP.Defines)
347 LD.Flags += $(LDFLAGS)
350 # Make Floating point IEEE compliant on Alpha.
353 CPP.BaseFlags += -mieee
354 ifeq ($(ENABLE_PIC),0)
356 CPP.BaseFlags += -fPIC
361 LD.Flags += -Wl,--no-relax
364 #--------------------------------------------------------------------
365 # Directory locations
366 #--------------------------------------------------------------------
368 ifeq ($(LLVM_CROSS_COMPILING),1)
369 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
372 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
373 ObjDir := $(ObjRootDir)
374 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
375 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
376 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
377 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
378 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
379 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
380 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
382 #--------------------------------------------------------------------
383 # Full Paths To Compiled Tools and Utilities
384 #--------------------------------------------------------------------
385 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
388 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
391 ifeq ($(LLVM_CROSS_COMPILING),1)
392 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
394 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
397 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
399 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
402 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
405 LLI := $(LLVMToolDir)/lli$(EXEEXT)
408 LLC := $(LLVMToolDir)/llc$(EXEEXT)
411 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
414 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
417 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
419 ifeq ($(LLVMGCC_MAJVERS),3)
420 UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest."
421 UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1)
422 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
423 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
427 LLVMGCCWITHPATH := $(LLVMGCC)
428 LLVMGXXWITHPATH := $(LLVMGXX)
431 #--------------------------------------------------------------------
432 # Adjust to user's request
433 #--------------------------------------------------------------------
436 DARWIN_VERSION := `sw_vers -productVersion`
437 # Strip a number like 10.4.7 to 10.4
438 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
439 # Get "4" out of 10.4 for later pieces in the makefile.
440 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
442 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
443 -dynamiclib -mmacosx-version-min=$(DARWIN_VERSION)
444 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
447 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
448 -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
449 -Wl,--enable-runtime-pseudo-relocs
451 SharedLinkOptions=-shared
455 # Adjust LD.Flags depending on the kind of library that is to be built. Note
456 # that if LOADABLE_MODULE is specified then the resulting shared library can
457 # be opened with dlopen.
458 ifdef LOADABLE_MODULE
463 ifneq ($(DARWIN_MAJVERS),4)
464 LD.Flags += $(RPATH) -Wl,$(LibDir)
475 # Adjust settings for verbose mode
478 AR.Flags += >/dev/null 2>/dev/null
479 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
481 ConfigureScriptFLAGS :=
484 # By default, strip symbol information from executable
486 Strip := $(PLATFORMSTRIPOPTS)
487 StripWarnMsg := "(without symbols)"
488 Install.StripFlag += -s
491 # Adjust linker flags for building an executable
493 ifneq ($(DARWIN_MAJVERS),4)
496 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
498 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
504 #----------------------------------------------------------
505 # Options To Invoke Tools
506 #----------------------------------------------------------
508 CompileCommonOpts += -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
509 -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
512 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
515 # If we are building a universal binary on Mac OS/X, pass extra options. This
516 # is useful to people that want to link the LLVM libraries into their universal
519 # The following can be optionally specified:
520 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
521 # For Mac OS/X 10.4 Intel machines, the traditional one is:
522 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
523 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
524 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
527 ifndef UNIVERSAL_ARCH
528 UNIVERSAL_ARCH := i386 ppc
530 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
531 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
532 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS)
533 ifdef UNIVERSAL_SDK_PATH
534 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
535 Relink.Flags += -isysroot $(UNIVERSAL_SDK_PATH)
538 # Building universal cannot compute dependencies automatically.
539 DISABLE_AUTO_DEPENDENCIES=1
542 ifeq ($(ARCH),x86_64)
543 TargetCommonOpts = -m64
546 TargetCommonOpts = -m32
553 CPP.BaseFlags += -include llvm/System/Solaris.h
556 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
557 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
558 # All -I flags should go here, so that they don't confuse llvm-config.
559 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
560 $(patsubst %,-I%/include,\
561 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
562 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
565 ifeq ($(BUILD_COMPONENT), 1)
566 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
567 $(TargetCommonOpts) $(CompileCommonOpts) -c
568 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
569 $(TargetCommonOpts) $(CompileCommonOpts) -c
570 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(TargetCommonOpts) \
571 $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
572 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
573 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
574 Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
575 $(CompileCommonOpts) $(Relink.Flags)
577 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
578 $(TargetCommonOpts) $(CompileCommonOpts) -c
579 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
580 $(TargetCommonOpts) $(CompileCommonOpts) -c
581 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) \
582 $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
583 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
584 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
585 Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
586 $(CompileCommonOpts) $(Relink.Flags)
589 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) \
590 $(TargetCommonOpts) $(CompileCommonOpts)
591 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) \
592 $(TargetCommonOpts) $(CompileCommonOpts) -E
594 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
595 $(TargetCommonOpts) $(CompileCommonOpts)
597 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
598 ScriptInstall = $(INSTALL) -m 0755
599 DataInstall = $(INSTALL) -m 0644
601 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
602 # paths. In this case, the SYSPATH function (defined in
603 # Makefile.config) transforms Unix paths into Windows paths.
604 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
605 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
606 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
607 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
609 Archive = $(AR) $(AR.Flags)
610 LArchive = $(LLVMToolDir)/llvm-ar rcsf
617 #----------------------------------------------------------
618 # Get the list of source files and compute object file
620 #----------------------------------------------------------
623 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
624 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
626 Sources := $(SOURCES)
630 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
633 BaseNameSources := $(sort $(basename $(Sources)))
635 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
636 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
638 ###############################################################################
639 # DIRECTORIES: Handle recursive descent of directory structure
640 ###############################################################################
642 #---------------------------------------------------------
643 # Provide rules to make install dirs. This must be early
644 # in the file so they get built before dependencies
645 #---------------------------------------------------------
647 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
650 # To create other directories, as needed, and timestamp their creation
652 $(Verb) $(MKDIR) $* > /dev/null
655 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
656 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
658 #---------------------------------------------------------
659 # Handle the DIRS options for sequential construction
660 #---------------------------------------------------------
666 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
667 $(RecursiveTargets)::
668 $(Verb) for dir in $(DIRS); do \
669 if [ ! -f $$dir/Makefile ]; then \
671 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
673 ($(MAKE) -C $$dir $@ ) || exit 1; \
676 $(RecursiveTargets)::
677 $(Verb) for dir in $(DIRS); do \
678 ($(MAKE) -C $$dir $@ ) || exit 1; \
684 #---------------------------------------------------------
685 # Handle the EXPERIMENTAL_DIRS options ensuring success
686 # after each directory is built.
687 #---------------------------------------------------------
688 ifdef EXPERIMENTAL_DIRS
689 $(RecursiveTargets)::
690 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
691 if [ ! -f $$dir/Makefile ]; then \
693 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
695 ($(MAKE) -C $$dir $@ ) || exit 0; \
699 #-----------------------------------------------------------
700 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
701 #-----------------------------------------------------------
702 ifdef OPTIONAL_PARALLEL_DIRS
703 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
706 #-----------------------------------------------------------
707 # Handle the PARALLEL_DIRS options for parallel construction
708 #-----------------------------------------------------------
711 SubDirs += $(PARALLEL_DIRS)
713 # Unfortunately, this list must be maintained if new recursive targets are added
714 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
715 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
716 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
717 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
718 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
719 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
721 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
724 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
726 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
728 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
731 #---------------------------------------------------------
732 # Handle the OPTIONAL_DIRS options for directores that may
734 #---------------------------------------------------------
737 SubDirs += $(OPTIONAL_DIRS)
739 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
740 $(RecursiveTargets)::
741 $(Verb) for dir in $(OPTIONAL_DIRS); do \
742 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
743 if [ ! -f $$dir/Makefile ]; then \
745 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
747 ($(MAKE) -C$$dir $@ ) || exit 1; \
751 $(RecursiveTargets)::
752 $(Verb) for dir in $(OPTIONAL_DIRS); do \
753 ($(MAKE) -C$$dir $@ ) || exit 1; \
758 #---------------------------------------------------------
759 # Handle the CONFIG_FILES options
760 #---------------------------------------------------------
765 $(Echo) Install circumvented with NO_INSTALL
767 $(Echo) UnInstall circumvented with NO_INSTALL
769 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
770 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
771 $(Verb)for file in $(CONFIG_FILES); do \
772 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
773 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
774 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
775 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
777 $(ECHO) Error: cannot find config file $${file}. ; \
782 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
783 $(Verb)for file in $(CONFIG_FILES); do \
784 $(RM) -f $(PROJ_etcdir)/$${file} ; \
790 ###############################################################################
791 # Set up variables for building libararies
792 ###############################################################################
794 #---------------------------------------------------------
795 # Define various command line options pertaining to the
796 # libraries needed when linking. There are "Proj" libs
797 # (defined by the user's project) and "LLVM" libs (defined
798 # by the LLVM project).
799 #---------------------------------------------------------
802 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
803 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
804 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
805 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
809 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
810 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
811 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
812 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
815 ifndef IS_CLEANING_TARGET
816 ifdef LINK_COMPONENTS
818 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
819 # clean in tools, then do a make in tools (instead of at the top level).
821 @echo "*** llvm-config doesn't exist - rebuilding it."
822 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
824 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
826 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
827 LLVMLibsPaths += $(LLVM_CONFIG) \
828 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
832 ###############################################################################
833 # Library Build Rules: Four ways to build a library
834 ###############################################################################
836 #---------------------------------------------------------
837 # Bytecode Module Targets:
838 # If the user set MODULE_NAME then they want to build a
839 # bytecode module from the sources. We compile all the
840 # sources and link it together into a single bytecode
842 #---------------------------------------------------------
845 ifeq ($(strip $(LLVMGCC)),)
846 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
849 Module := $(LibDir)/$(MODULE_NAME).bc
850 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
853 ifdef EXPORTED_SYMBOL_FILE
854 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
857 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
858 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
859 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
861 all-local:: $(Module)
864 ifneq ($(strip $(Module)),)
865 -$(Verb) $(RM) -f $(Module)
868 ifdef BYTECODE_DESTINATION
869 ModuleDestDir := $(BYTECODE_DESTINATION)
871 ModuleDestDir := $(PROJ_libdir)
876 $(Echo) Install circumvented with NO_INSTALL
878 $(Echo) Uninstall circumvented with NO_INSTALL
880 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
882 install-module:: $(DestModule)
883 install-local:: $(DestModule)
885 $(DestModule): $(ModuleDestDir) $(Module)
886 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
887 $(Verb) $(DataInstall) $(Module) $(DestModule)
890 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
891 -$(Verb) $(RM) -f $(DestModule)
897 # if we're building a library ...
900 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
901 LIBRARYNAME := $(strip $(LIBRARYNAME))
902 ifdef LOADABLE_MODULE
903 LibName.A := $(LibDir)/$(LIBRARYNAME).a
904 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
906 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
907 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
909 LibName.O := $(LibDir)/$(LIBRARYNAME).o
910 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
912 #---------------------------------------------------------
913 # Shared Library Targets:
914 # If the user asked for a shared library to be built
915 # with the SHARED_LIBRARY variable, then we provide
916 # targets for building them.
917 #---------------------------------------------------------
920 all-local:: $(LibName.SO)
922 ifdef LINK_LIBS_IN_SHARED
923 ifdef LOADABLE_MODULE
924 SharedLibKindMessage := "Loadable Module"
926 SharedLibKindMessage := "Shared Library"
928 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
929 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
930 $(LIBRARYNAME)$(SHLIBEXT)
931 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
932 $(ProjLibsOptions) $(LLVMLibsOptions)
934 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
935 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
936 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
940 ifneq ($(strip $(LibName.SO)),)
941 -$(Verb) $(RM) -f $(LibName.SO)
946 $(Echo) Install circumvented with NO_INSTALL
948 $(Echo) Uninstall circumvented with NO_INSTALL
950 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
952 install-local:: $(DestSharedLib)
954 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
955 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
956 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
959 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
960 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
964 #---------------------------------------------------------
965 # Bytecode Library Targets:
966 # If the user asked for a bytecode library to be built
967 # with the BYTECODE_LIBRARY variable, then we provide
968 # targets for building them.
969 #---------------------------------------------------------
970 ifdef BYTECODE_LIBRARY
971 ifeq ($(strip $(LLVMGCC)),)
972 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
975 all-local:: $(LibName.BCA)
977 ifdef EXPORTED_SYMBOL_FILE
978 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
979 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
981 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
982 $(LLVMToolDir)/llvm-ar
983 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
985 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
987 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
989 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
990 $(LLVMToolDir)/llvm-ar
991 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
993 $(Verb) $(LArchive) $@ $(ObjectsBC)
998 ifneq ($(strip $(LibName.BCA)),)
999 -$(Verb) $(RM) -f $(LibName.BCA)
1002 ifdef BYTECODE_DESTINATION
1003 BytecodeDestDir := $(BYTECODE_DESTINATION)
1005 BytecodeDestDir := $(PROJ_libdir)
1008 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
1010 install-bytecode-local:: $(DestBytecodeLib)
1014 $(Echo) Install circumvented with NO_INSTALL
1016 $(Echo) Uninstall circumvented with NO_INSTALL
1018 install-local:: $(DestBytecodeLib)
1020 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1021 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1022 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1025 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1026 -$(Verb) $(RM) -f $(DestBytecodeLib)
1031 #---------------------------------------------------------
1032 # ReLinked Library Targets:
1033 # If the user explicitly requests a relinked library with
1034 # BUILD_RELINKED, provide it. Otherwise, if they specify
1035 # neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
1037 #---------------------------------------------------------
1038 ifndef BUILD_ARCHIVE
1039 ifndef DONT_BUILD_RELINKED
1044 ifdef BUILD_RELINKED
1046 all-local:: $(LibName.O)
1048 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
1049 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
1050 $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
1053 ifneq ($(strip $(LibName.O)),)
1054 -$(Verb) $(RM) -f $(LibName.O)
1059 $(Echo) Install circumvented with NO_INSTALL
1061 $(Echo) Uninstall circumvented with NO_INSTALL
1063 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
1065 install-local:: $(DestRelinkedLib)
1067 $(DestRelinkedLib): $(LibName.O) $(PROJ_libdir)
1068 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
1069 $(Verb) $(INSTALL) $(LibName.O) $(DestRelinkedLib)
1072 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
1073 -$(Verb) $(RM) -f $(DestRelinkedLib)
1077 #---------------------------------------------------------
1078 # Archive Library Targets:
1079 # If the user wanted a regular archive library built,
1080 # then we provide targets for building them.
1081 #---------------------------------------------------------
1084 all-local:: $(LibName.A)
1086 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1087 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1088 -$(Verb) $(RM) -f $@
1089 $(Verb) $(Archive) $@ $(ObjectsO)
1090 $(Verb) $(Ranlib) $@
1093 ifneq ($(strip $(LibName.A)),)
1094 -$(Verb) $(RM) -f $(LibName.A)
1099 $(Echo) Install circumvented with NO_INSTALL
1101 $(Echo) Uninstall circumvented with NO_INSTALL
1103 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1105 install-local:: $(DestArchiveLib)
1107 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1108 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1109 $(Verb) $(MKDIR) $(PROJ_libdir)
1110 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1113 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1114 -$(Verb) $(RM) -f $(DestArchiveLib)
1121 ###############################################################################
1122 # Tool Build Rules: Build executable tool based on TOOLNAME option
1123 ###############################################################################
1127 #---------------------------------------------------------
1128 # Set up variables for building a tool.
1129 #---------------------------------------------------------
1131 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1133 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1136 #---------------------------------------------------------
1138 #---------------------------------------------------------
1140 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1141 # not exporting all of the weak symbols from the binary. This reduces dyld
1142 # startup time by 4x on darwin in some cases.
1143 ifdef TOOL_NO_EXPORTS
1146 # Tiger tools don't support this.
1147 ifneq ($(DARWIN_MAJVERS),4)
1148 LD.Flags += -Wl,-exported_symbol -Wl,_main
1152 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
1153 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1158 #---------------------------------------------------------
1159 # Provide targets for building the tools
1160 #---------------------------------------------------------
1161 all-local:: $(ToolBuildPath)
1164 ifneq ($(strip $(ToolBuildPath)),)
1165 -$(Verb) $(RM) -f $(ToolBuildPath)
1169 $(ToolBuildPath): $(ExmplDir)/.dir
1171 $(ToolBuildPath): $(ToolDir)/.dir
1174 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1175 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1176 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1177 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1178 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1183 $(Echo) Install circumvented with NO_INSTALL
1185 $(Echo) Uninstall circumvented with NO_INSTALL
1187 DestTool = $(PROJ_bindir)/$(TOOLNAME)
1189 install-local:: $(DestTool)
1191 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1192 $(Echo) Installing $(BuildMode) $(DestTool)
1193 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1196 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1197 -$(Verb) $(RM) -f $(DestTool)
1201 ###############################################################################
1202 # Object Build Rules: Build object files based on sources
1203 ###############################################################################
1205 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1207 DISABLE_AUTO_DEPENDENCIES=1
1210 # Provide rule sets for when dependency generation is enabled
1211 ifndef DISABLE_AUTO_DEPENDENCIES
1213 #---------------------------------------------------------
1214 # Create .o files in the ObjDir directory from the .cpp and .c files...
1215 #---------------------------------------------------------
1217 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1218 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1220 # If the build succeeded, move the dependency file over. If it failed, put an
1222 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1223 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1225 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1226 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1227 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1230 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1231 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1232 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1235 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1236 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1237 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1240 #---------------------------------------------------------
1241 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1242 #---------------------------------------------------------
1244 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1245 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1246 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1247 $< -o $@ -S -emit-llvm ; \
1248 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1249 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1250 $(call UPGRADE_MSG,$@)
1251 $(call UPGRADE_LL,$@)
1253 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1254 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1255 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1256 $< -o $@ -S -emit-llvm ; \
1257 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1258 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1259 $(call UPGRADE_MSG,$@)
1260 $(call UPGRADE_LL,$@)
1262 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1263 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1264 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1265 $< -o $@ -S -emit-llvm ; \
1266 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1267 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1268 $(call UPGRADE_MSG,$@)
1269 $(call UPGRADE_LL,$@)
1271 # Provide alternate rule sets if dependencies are disabled
1274 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1275 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1276 $(Compile.CXX) $< -o $@
1278 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1279 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1280 $(Compile.CXX) $< -o $@
1282 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1283 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1284 $(Compile.C) $< -o $@
1286 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1287 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1288 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1289 $(call UPGRADE_MSG,$@)
1290 $(call UPGRADE_LL,$@)
1292 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1293 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1294 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1295 $(call UPGRADE_MSG,$@)
1296 $(call UPGRADE_LL,$@)
1298 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1299 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1300 $(BCCompile.C) $< -o $@ -S -emit-llvm
1301 $(call UPGRADE_MSG,@)
1302 $(call UPGRADE_LL,@)
1307 ## Rules for building preprocessed (.i/.ii) outputs.
1308 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1309 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1310 $(Verb) $(Preprocess.CXX) $< -o $@
1312 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1313 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1314 $(Verb) $(Preprocess.CXX) $< -o $@
1316 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1317 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1318 $(Verb) $(Preprocess.C) $< -o $@
1321 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1322 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1323 $(Compile.CXX) $< -o $@ -S
1325 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1326 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1327 $(Compile.CXX) $< -o $@ -S
1329 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1330 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1331 $(Compile.C) $< -o $@ -S
1334 # make the C and C++ compilers strip debug info out of bytecode libraries.
1336 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1337 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1338 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
1340 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1341 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1342 $(Verb) $(LLVMAS) $< -o - | \
1343 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
1347 #---------------------------------------------------------
1348 # Provide rule to build .bc files from .ll sources,
1349 # regardless of dependencies
1350 #---------------------------------------------------------
1351 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1352 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1353 $(Verb) $(LLVMAS) $< -f -o $@
1355 ###############################################################################
1356 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1357 ###############################################################################
1360 TABLEGEN_INC_FILES_COMMON = 1
1363 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1364 TABLEGEN_INC_FILES_COMMON = 1
1367 ifdef TABLEGEN_INC_FILES_COMMON
1369 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1370 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1371 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1373 # INCFiles rule: All of the tblgen generated files are emitted to
1374 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1375 # us to only "touch" the real file if the contents of it change. IOW, if
1376 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1377 # dependencies of the .inc files are, unless the contents of the .inc file
1379 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1380 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1382 endif # TABLEGEN_INC_FILES_COMMON
1386 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1387 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1388 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1389 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1390 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1391 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1392 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1394 # All of these files depend on tblgen and the .td files.
1395 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1397 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1398 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1399 $(Echo) "Building $(<F) register names with tblgen"
1400 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1402 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1403 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1404 $(Echo) "Building $(<F) register information header with tblgen"
1405 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1407 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1408 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1409 $(Echo) "Building $(<F) register info implementation with tblgen"
1410 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1412 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1413 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1414 $(Echo) "Building $(<F) instruction names with tblgen"
1415 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1417 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1418 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1419 $(Echo) "Building $(<F) instruction information with tblgen"
1420 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1422 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1423 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1424 $(Echo) "Building $(<F) assembly writer with tblgen"
1425 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1427 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1428 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1429 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1430 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1432 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1433 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1434 $(Echo) "Building $(<F) code emitter with tblgen"
1435 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1437 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1438 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1439 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1440 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1442 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1443 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1444 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1445 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1447 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1448 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1449 $(Echo) "Building $(<F) subtarget information with tblgen"
1450 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1452 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1453 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1454 $(Echo) "Building $(<F) calling convention information with tblgen"
1455 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1457 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1458 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1459 $(Echo) "Building $(<F) calling convention information with tblgen"
1460 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1463 -$(Verb) $(RM) -f $(INCFiles)
1467 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1469 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1470 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1472 TDFiles := $(LLVMCPluginSrc) \
1473 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1475 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1476 $(TBLGEN) $(TD_COMMON)
1477 $(Echo) "Building LLVMC configuration library with tblgen"
1478 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1480 endif # LLVMC_BUILD_AUTOGENERATED_INC
1482 ###############################################################################
1483 # OTHER RULES: Other rules needed
1484 ###############################################################################
1486 # To create postscript files from dot files...
1487 ifneq ($(DOT),false)
1489 $(DOT) -Tps < $< > $@
1492 $(Echo) "Cannot build $@: The program dot is not installed"
1495 # This rules ensures that header files that are removed still have a rule for
1496 # which they can be "generated." This allows make to ignore them and
1497 # reproduce the dependency lists.
1501 # Define clean-local to clean the current directory. Note that this uses a
1502 # very conservative approach ensuring that empty variables do not cause
1503 # errors or disastrous removal.
1505 ifneq ($(strip $(ObjRootDir)),)
1506 -$(Verb) $(RM) -rf $(ObjRootDir)
1508 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1509 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1510 -$(Verb) $(RM) -f *$(SHLIBEXT)
1514 -$(Verb) $(RM) -rf Debug Release Profile
1517 ###############################################################################
1518 # DEPENDENCIES: Include the dependency files if we should
1519 ###############################################################################
1520 ifndef DISABLE_AUTO_DEPENDENCIES
1522 # If its not one of the cleaning targets
1523 ifndef IS_CLEANING_TARGET
1525 # Get the list of dependency files
1526 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1527 DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1529 -include $(DependFiles) ""
1535 ###############################################################################
1536 # CHECK: Running the test suite
1537 ###############################################################################
1540 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1541 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1542 $(EchoCmd) Running test suite ; \
1543 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1544 TESTSUITE=$(TESTSUITE) ; \
1546 $(EchoCmd) No Makefile in test directory ; \
1549 $(EchoCmd) No test directory ; \
1552 ###############################################################################
1553 # UNITTESTS: Running the unittests test suite
1554 ###############################################################################
1557 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1558 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1559 $(EchoCmd) Running unittests test suite ; \
1560 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1562 $(EchoCmd) No Makefile in unittests directory ; \
1565 $(EchoCmd) No unittests directory ; \
1568 ###############################################################################
1569 # DISTRIBUTION: Handle construction of a distribution tarball
1570 ###############################################################################
1572 #------------------------------------------------------------------------
1573 # Define distribution related variables
1574 #------------------------------------------------------------------------
1575 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1576 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1577 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1578 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1579 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1580 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1581 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1582 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1583 Makefile.config.in configure autoconf
1584 DistOther := $(notdir $(wildcard \
1585 $(PROJ_SRC_DIR)/*.h \
1586 $(PROJ_SRC_DIR)/*.td \
1587 $(PROJ_SRC_DIR)/*.def \
1588 $(PROJ_SRC_DIR)/*.ll \
1589 $(PROJ_SRC_DIR)/*.in))
1590 DistSubDirs := $(SubDirs)
1591 DistSources = $(Sources) $(EXTRA_DIST)
1592 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1594 #------------------------------------------------------------------------
1595 # We MUST build distribution with OBJ_DIR != SRC_DIR
1596 #------------------------------------------------------------------------
1597 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1598 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1599 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1603 #------------------------------------------------------------------------
1604 # Prevent attempt to run dist targets from anywhere but the top level
1605 #------------------------------------------------------------------------
1607 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1608 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1611 #------------------------------------------------------------------------
1612 # Provide the top level targets
1613 #------------------------------------------------------------------------
1615 dist-gzip:: $(DistTarGZip)
1617 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1618 $(Echo) Packing gzipped distribution tar file.
1619 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1620 $(GZIP) -c > "$(DistTarGZip)"
1622 dist-bzip2:: $(DistTarBZ2)
1624 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1625 $(Echo) Packing bzipped distribution tar file.
1626 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1627 $(BZIP2) -c >$(DistTarBZ2)
1629 dist-zip:: $(DistZip)
1631 $(DistZip) : $(TopDistDir)/.makedistdir
1632 $(Echo) Packing zipped distribution file.
1633 $(Verb) rm -f $(DistZip)
1634 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1636 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1637 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1639 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1641 dist-check:: $(DistTarGZip)
1642 $(Echo) Checking distribution tar file.
1643 $(Verb) if test -d $(DistCheckDir) ; then \
1644 $(RM) -rf $(DistCheckDir) ; \
1646 $(Verb) $(MKDIR) $(DistCheckDir)
1647 $(Verb) cd $(DistCheckDir) && \
1648 $(MKDIR) $(DistCheckDir)/build && \
1649 $(MKDIR) $(DistCheckDir)/install && \
1650 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1652 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1653 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1656 $(MAKE) unittests && \
1657 $(MAKE) install && \
1658 $(MAKE) uninstall && \
1659 $(MAKE) dist-clean && \
1660 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1663 $(Echo) Cleaning distribution files
1664 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1669 #------------------------------------------------------------------------
1670 # Provide the recursive distdir target for building the distribution directory
1671 #------------------------------------------------------------------------
1672 distdir: $(DistDir)/.makedistdir
1673 $(DistDir)/.makedistdir: $(DistSources)
1674 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1675 if test -d "$(DistDir)" ; then \
1676 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1679 $(EchoCmd) Removing old $(DistDir) ; \
1680 $(RM) -rf $(DistDir); \
1681 $(EchoCmd) Making 'all' to verify build ; \
1682 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1684 $(Echo) Building Distribution Directory $(DistDir)
1685 $(Verb) $(MKDIR) $(DistDir)
1686 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1687 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1688 for file in $(DistFiles) ; do \
1690 $(PROJ_SRC_DIR)/*) \
1691 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1693 $(PROJ_SRC_ROOT)/*) \
1694 file=`echo "$$file" | \
1695 sed "s#^$$srcrootstrip/##"` \
1698 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1699 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1700 from_dir="$(PROJ_SRC_DIR)" ; \
1701 elif test -f "$$file" || test -d "$$file" ; then \
1704 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1705 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1706 to_dir="$(DistDir)/$$dir"; \
1707 $(MKDIR) "$$to_dir" ; \
1709 to_dir="$(DistDir)"; \
1711 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1712 if test -n "$$mid_dir" ; then \
1713 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1715 if test -d "$$from_dir/$$file"; then \
1716 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1717 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1718 cd $(PROJ_SRC_DIR) ; \
1719 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1720 ( cd $$to_dir ; $(TAR) xf - ) ; \
1721 cd $(PROJ_OBJ_DIR) ; \
1724 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1725 ( cd $$to_dir ; $(TAR) xf - ) ; \
1726 cd $(PROJ_OBJ_DIR) ; \
1728 elif test -f "$$from_dir/$$file" ; then \
1729 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1730 elif test -L "$$from_dir/$$file" ; then \
1731 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1732 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1733 $(EchoCmd) "===== WARNING: Distribution Source " \
1734 "$$from_dir/$$file Not Found!" ; \
1735 elif test "$(Verb)" != '@' ; then \
1736 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1739 $(Verb) for subdir in $(DistSubDirs) ; do \
1740 if test "$$subdir" \!= "." ; then \
1741 new_distdir="$(DistDir)/$$subdir" ; \
1742 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1743 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1744 DistDir="$$new_distdir" distdir ) || exit 1; \
1747 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1748 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1749 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1750 -name .svn \) -print` ;\
1751 $(MAKE) dist-hook ; \
1752 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1753 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1754 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1755 -o ! -type d ! -perm -444 -exec \
1756 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1757 || chmod -R a+r $(DistDir) ; \
1760 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1766 ###############################################################################
1767 # TOP LEVEL - targets only to apply at the top level directory
1768 ###############################################################################
1772 #------------------------------------------------------------------------
1773 # Install support for the project's include files:
1774 #------------------------------------------------------------------------
1777 $(Echo) Install circumvented with NO_INSTALL
1779 $(Echo) Uninstall circumvented with NO_INSTALL
1782 $(Echo) Installing include files
1783 $(Verb) $(MKDIR) $(PROJ_includedir)
1784 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1785 cd $(PROJ_SRC_ROOT)/include && \
1786 for hdr in `find . -type f '!' '(' -name '*~' \
1787 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1788 grep -v .svn` ; do \
1789 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1790 if test \! -d "$$instdir" ; then \
1791 $(EchoCmd) Making install directory $$instdir ; \
1792 $(MKDIR) $$instdir ;\
1794 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1797 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1798 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1799 cd $(PROJ_OBJ_ROOT)/include && \
1800 for hdr in `find . -type f -print | grep -v CVS` ; do \
1801 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1807 $(Echo) Uninstalling include files
1808 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1809 cd $(PROJ_SRC_ROOT)/include && \
1810 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1811 '!' '(' -name '*~' -o -name '.#*' \
1812 -o -name '*.in' ')' -print ')' | \
1813 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1814 cd $(PROJ_SRC_ROOT)/include && \
1815 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1816 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1822 @echo searching for overlength lines in files: $(Sources)
1825 egrep -n '.{81}' $(Sources) /dev/null
1828 @echo searching for tabs in files: $(Sources)
1831 egrep -n ' ' $(Sources) /dev/null
1834 @ls -l $(LibDir) | awk '\
1835 BEGIN { sum = 0; } \
1837 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1838 @ls -l $(ToolDir) | awk '\
1839 BEGIN { sum = 0; } \
1841 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1842 #------------------------------------------------------------------------
1843 # Print out the directories used for building
1844 #------------------------------------------------------------------------
1846 $(Echo) "BuildMode : " '$(BuildMode)'
1847 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1848 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1849 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1850 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1851 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1852 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1853 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1854 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1855 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1856 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1857 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1858 $(Echo) "UserTargets : " '$(UserTargets)'
1859 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1860 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1861 $(Echo) "ObjDir : " '$(ObjDir)'
1862 $(Echo) "LibDir : " '$(LibDir)'
1863 $(Echo) "ToolDir : " '$(ToolDir)'
1864 $(Echo) "ExmplDir : " '$(ExmplDir)'
1865 $(Echo) "Sources : " '$(Sources)'
1866 $(Echo) "TDFiles : " '$(TDFiles)'
1867 $(Echo) "INCFiles : " '$(INCFiles)'
1868 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1869 $(Echo) "PreConditions: " '$(PreConditions)'
1870 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1871 $(Echo) "Compile.C : " '$(Compile.C)'
1872 $(Echo) "Archive : " '$(Archive)'
1873 $(Echo) "YaccFiles : " '$(YaccFiles)'
1874 $(Echo) "LexFiles : " '$(LexFiles)'
1875 $(Echo) "Module : " '$(Module)'
1876 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1877 $(Echo) "SubDirs : " '$(SubDirs)'
1878 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1879 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1884 # General debugging rule, use 'make dbg-print-XXX' to print the
1885 # definition, value and origin of XXX.
1887 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))