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 # Avoid -O3 on Darwin, there are unresolved issues with
233 # -fstrict-aliasing and ipa-type-escape radr://6756684
234 ifeq ($(OS), $(filter $(OS), MingW Darwin))
235 OPTIMIZE_OPTION := -O2
237 OPTIMIZE_OPTION := -O3
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.
251 EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
253 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
254 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
255 LD.Flags += $(OPTIMIZE_OPTION)
264 ifeq ($(ENABLE_PROFILING),1)
265 BuildMode := $(BuildMode)+Profile
266 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
267 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
268 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
272 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
273 # CXX.Flags += -fvisibility-inlines-hidden
276 # IF REQUIRES_EH=1 is specified then don't disable exceptions
278 CXX.Flags += -fno-exceptions
281 # IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
283 # CXX.Flags += -fno-rtti
286 ifdef ENABLE_COVERAGE
287 BuildMode := $(BuildMode)+Coverage
288 # These only go to .NoRelink because otherwise we will end up
289 # linking -lgcov into the .o libraries that get built.
290 CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs
291 C.Flags.NoRelink += -ftest-coverage -fprofile-arcs
294 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
295 # then disable assertions by defining the appropriate preprocessor symbols.
296 ifdef DISABLE_ASSERTIONS
297 # Indicate that assertions are turned off using a minus sign
298 BuildMode := $(BuildMode)-Asserts
299 CPP.Defines += -DNDEBUG
301 CPP.Defines += -D_DEBUG
304 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
305 # configured), then enable expensive checks by defining the
306 # appropriate preprocessor symbols.
307 ifdef ENABLE_EXPENSIVE_CHECKS
308 BuildMode := $(BuildMode)+Checks
309 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
312 # LOADABLE_MODULE implies several other things so we force them to be
314 ifdef LOADABLE_MODULE
316 DONT_BUILD_RELINKED := 1
317 LINK_LIBS_IN_SHARED := 1
325 ifeq ($(ENABLE_PIC),1)
326 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
327 # Nothing. Win32 defaults to PIC and warns when given -fPIC
330 # Common symbols not allowed in dylib files
331 CXX.Flags += -fno-common
332 C.Flags += -fno-common
334 # Linux and others; pass -fPIC
341 CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
343 CPP.Defines += $(CPPFLAGS)
344 CPP.BaseFlags += $(CPP.Defines)
345 LD.Flags += $(LDFLAGS)
348 # Make Floating point IEEE compliant on Alpha.
351 CPP.BaseFlags += -mieee
352 ifeq ($(ENABLE_PIC),0)
354 CPP.BaseFlags += -fPIC
359 LD.Flags += -Wl,--no-relax
362 #--------------------------------------------------------------------
363 # Directory locations
364 #--------------------------------------------------------------------
366 ifeq ($(LLVM_CROSS_COMPILING),1)
367 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
370 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
371 ObjDir := $(ObjRootDir)
372 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
373 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
374 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
375 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
376 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
377 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
378 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
380 #--------------------------------------------------------------------
381 # Full Paths To Compiled Tools and Utilities
382 #--------------------------------------------------------------------
383 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
386 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
389 ifeq ($(LLVM_CROSS_COMPILING),1)
390 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
392 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
395 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
397 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
400 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
403 LLI := $(LLVMToolDir)/lli$(EXEEXT)
406 LLC := $(LLVMToolDir)/llc$(EXEEXT)
409 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
412 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
415 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
417 ifeq ($(LLVMGCC_MAJVERS),3)
418 UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest."
419 UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1)
420 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
421 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
425 LLVMGCCWITHPATH := $(LLVMGCC)
426 LLVMGXXWITHPATH := $(LLVMGXX)
429 #--------------------------------------------------------------------
430 # Adjust to user's request
431 #--------------------------------------------------------------------
434 DARWIN_VERSION := `sw_vers -productVersion`
435 # Strip a number like 10.4.7 to 10.4
436 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
437 # Get "4" out of 10.4 for later pieces in the makefile.
438 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
440 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
441 -dynamiclib -mmacosx-version-min=$(DARWIN_VERSION)
442 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
445 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
446 -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
447 -Wl,--enable-runtime-pseudo-relocs
449 SharedLinkOptions=-shared
453 # Adjust LD.Flags depending on the kind of library that is to be built. Note
454 # that if LOADABLE_MODULE is specified then the resulting shared library can
455 # be opened with dlopen.
456 ifdef LOADABLE_MODULE
461 ifneq ($(DARWIN_MAJVERS),4)
462 LD.Flags += $(RPATH) -Wl,$(LibDir)
473 # Adjust settings for verbose mode
476 AR.Flags += >/dev/null 2>/dev/null
477 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
479 ConfigureScriptFLAGS :=
482 # By default, strip symbol information from executable
484 Strip := $(PLATFORMSTRIPOPTS)
485 StripWarnMsg := "(without symbols)"
486 Install.StripFlag += -s
489 # Adjust linker flags for building an executable
491 ifneq ($(DARWIN_MAJVERS),4)
494 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
496 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
502 #----------------------------------------------------------
503 # Options To Invoke Tools
504 #----------------------------------------------------------
506 CompileCommonOpts += -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
507 -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
510 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
513 # If we are building a universal binary on Mac OS/X, pass extra options. This
514 # is useful to people that want to link the LLVM libraries into their universal
517 # The following can be optionally specified:
518 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
519 # For Mac OS/X 10.4 Intel machines, the traditional one is:
520 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
521 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
522 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
525 ifndef UNIVERSAL_ARCH
526 UNIVERSAL_ARCH := i386 ppc
528 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
529 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
530 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS)
531 ifdef UNIVERSAL_SDK_PATH
532 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
533 Relink.Flags += -isysroot $(UNIVERSAL_SDK_PATH)
536 # Building universal cannot compute dependencies automatically.
537 DISABLE_AUTO_DEPENDENCIES=1
540 ifeq ($(ARCH),x86_64)
541 TargetCommonOpts = -m64
544 TargetCommonOpts = -m32
551 CPP.BaseFlags += -include llvm/System/Solaris.h
554 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
555 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
556 # All -I flags should go here, so that they don't confuse llvm-config.
557 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
558 $(patsubst %,-I%/include,\
559 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
560 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
563 ifeq ($(BUILD_COMPONENT), 1)
564 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
565 $(TargetCommonOpts) $(CompileCommonOpts) -c
566 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
567 $(TargetCommonOpts) $(CompileCommonOpts) -c
568 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(TargetCommonOpts) \
569 $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
570 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
571 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
572 Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
573 $(CompileCommonOpts) $(Relink.Flags)
575 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
576 $(TargetCommonOpts) $(CompileCommonOpts) -c
577 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
578 $(TargetCommonOpts) $(CompileCommonOpts) -c
579 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) \
580 $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E
581 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
582 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
583 Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \
584 $(CompileCommonOpts) $(Relink.Flags)
587 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) \
588 $(TargetCommonOpts) $(CompileCommonOpts)
589 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) \
590 $(TargetCommonOpts) $(CompileCommonOpts) -E
592 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
593 $(TargetCommonOpts) $(CompileCommonOpts)
595 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
596 ScriptInstall = $(INSTALL) -m 0755
597 DataInstall = $(INSTALL) -m 0644
599 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
600 # paths. In this case, the SYSPATH function (defined in
601 # Makefile.config) transforms Unix paths into Windows paths.
602 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
603 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
604 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
605 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
607 Archive = $(AR) $(AR.Flags)
608 LArchive = $(LLVMToolDir)/llvm-ar rcsf
615 #----------------------------------------------------------
616 # Get the list of source files and compute object file
618 #----------------------------------------------------------
621 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
622 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
624 Sources := $(SOURCES)
628 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
631 BaseNameSources := $(sort $(basename $(Sources)))
633 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
634 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
636 ###############################################################################
637 # DIRECTORIES: Handle recursive descent of directory structure
638 ###############################################################################
640 #---------------------------------------------------------
641 # Provide rules to make install dirs. This must be early
642 # in the file so they get built before dependencies
643 #---------------------------------------------------------
645 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
648 # To create other directories, as needed, and timestamp their creation
650 $(Verb) $(MKDIR) $* > /dev/null
653 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
654 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
656 #---------------------------------------------------------
657 # Handle the DIRS options for sequential construction
658 #---------------------------------------------------------
664 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
665 $(RecursiveTargets)::
666 $(Verb) for dir in $(DIRS); do \
667 if [ ! -f $$dir/Makefile ]; then \
669 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
671 ($(MAKE) -C $$dir $@ ) || exit 1; \
674 $(RecursiveTargets)::
675 $(Verb) for dir in $(DIRS); do \
676 ($(MAKE) -C $$dir $@ ) || exit 1; \
682 #---------------------------------------------------------
683 # Handle the EXPERIMENTAL_DIRS options ensuring success
684 # after each directory is built.
685 #---------------------------------------------------------
686 ifdef EXPERIMENTAL_DIRS
687 $(RecursiveTargets)::
688 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
689 if [ ! -f $$dir/Makefile ]; then \
691 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
693 ($(MAKE) -C $$dir $@ ) || exit 0; \
697 #-----------------------------------------------------------
698 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
699 #-----------------------------------------------------------
700 ifdef OPTIONAL_PARALLEL_DIRS
701 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
704 #-----------------------------------------------------------
705 # Handle the PARALLEL_DIRS options for parallel construction
706 #-----------------------------------------------------------
709 SubDirs += $(PARALLEL_DIRS)
711 # Unfortunately, this list must be maintained if new recursive targets are added
712 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
713 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
714 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
715 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
716 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
717 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
719 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
722 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
724 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
726 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
729 #---------------------------------------------------------
730 # Handle the OPTIONAL_DIRS options for directores that may
732 #---------------------------------------------------------
735 SubDirs += $(OPTIONAL_DIRS)
737 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
738 $(RecursiveTargets)::
739 $(Verb) for dir in $(OPTIONAL_DIRS); do \
740 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
741 if [ ! -f $$dir/Makefile ]; then \
743 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
745 ($(MAKE) -C$$dir $@ ) || exit 1; \
749 $(RecursiveTargets)::
750 $(Verb) for dir in $(OPTIONAL_DIRS); do \
751 ($(MAKE) -C$$dir $@ ) || exit 1; \
756 #---------------------------------------------------------
757 # Handle the CONFIG_FILES options
758 #---------------------------------------------------------
763 $(Echo) Install circumvented with NO_INSTALL
765 $(Echo) UnInstall circumvented with NO_INSTALL
767 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
768 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
769 $(Verb)for file in $(CONFIG_FILES); do \
770 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
771 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
772 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
773 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
775 $(ECHO) Error: cannot find config file $${file}. ; \
780 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
781 $(Verb)for file in $(CONFIG_FILES); do \
782 $(RM) -f $(PROJ_etcdir)/$${file} ; \
788 ###############################################################################
789 # Set up variables for building libararies
790 ###############################################################################
792 #---------------------------------------------------------
793 # Define various command line options pertaining to the
794 # libraries needed when linking. There are "Proj" libs
795 # (defined by the user's project) and "LLVM" libs (defined
796 # by the LLVM project).
797 #---------------------------------------------------------
800 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
801 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
802 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
803 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
807 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
808 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
809 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
810 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
813 ifndef IS_CLEANING_TARGET
814 ifdef LINK_COMPONENTS
816 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
817 # clean in tools, then do a make in tools (instead of at the top level).
819 @echo "*** llvm-config doesn't exist - rebuilding it."
820 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
822 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
824 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
825 LLVMLibsPaths += $(LLVM_CONFIG) \
826 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
830 ###############################################################################
831 # Library Build Rules: Four ways to build a library
832 ###############################################################################
834 #---------------------------------------------------------
835 # Bytecode Module Targets:
836 # If the user set MODULE_NAME then they want to build a
837 # bytecode module from the sources. We compile all the
838 # sources and link it together into a single bytecode
840 #---------------------------------------------------------
843 ifeq ($(strip $(LLVMGCC)),)
844 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
847 Module := $(LibDir)/$(MODULE_NAME).bc
848 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
851 ifdef EXPORTED_SYMBOL_FILE
852 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
855 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
856 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
857 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
859 all-local:: $(Module)
862 ifneq ($(strip $(Module)),)
863 -$(Verb) $(RM) -f $(Module)
866 ifdef BYTECODE_DESTINATION
867 ModuleDestDir := $(BYTECODE_DESTINATION)
869 ModuleDestDir := $(PROJ_libdir)
874 $(Echo) Install circumvented with NO_INSTALL
876 $(Echo) Uninstall circumvented with NO_INSTALL
878 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
880 install-module:: $(DestModule)
881 install-local:: $(DestModule)
883 $(DestModule): $(ModuleDestDir) $(Module)
884 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
885 $(Verb) $(DataInstall) $(Module) $(DestModule)
888 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
889 -$(Verb) $(RM) -f $(DestModule)
895 # if we're building a library ...
898 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
899 LIBRARYNAME := $(strip $(LIBRARYNAME))
900 ifdef LOADABLE_MODULE
901 LibName.A := $(LibDir)/$(LIBRARYNAME).a
902 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
904 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
905 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
907 LibName.O := $(LibDir)/$(LIBRARYNAME).o
908 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
910 #---------------------------------------------------------
911 # Shared Library Targets:
912 # If the user asked for a shared library to be built
913 # with the SHARED_LIBRARY variable, then we provide
914 # targets for building them.
915 #---------------------------------------------------------
918 all-local:: $(LibName.SO)
920 ifdef LINK_LIBS_IN_SHARED
921 ifdef LOADABLE_MODULE
922 SharedLibKindMessage := "Loadable Module"
924 SharedLibKindMessage := "Shared Library"
926 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
927 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
928 $(LIBRARYNAME)$(SHLIBEXT)
929 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
930 $(ProjLibsOptions) $(LLVMLibsOptions)
932 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
933 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
934 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
938 ifneq ($(strip $(LibName.SO)),)
939 -$(Verb) $(RM) -f $(LibName.SO)
944 $(Echo) Install circumvented with NO_INSTALL
946 $(Echo) Uninstall circumvented with NO_INSTALL
948 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
950 install-local:: $(DestSharedLib)
952 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
953 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
954 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
957 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
958 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
962 #---------------------------------------------------------
963 # Bytecode Library Targets:
964 # If the user asked for a bytecode library to be built
965 # with the BYTECODE_LIBRARY variable, then we provide
966 # targets for building them.
967 #---------------------------------------------------------
968 ifdef BYTECODE_LIBRARY
969 ifeq ($(strip $(LLVMGCC)),)
970 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
973 all-local:: $(LibName.BCA)
975 ifdef EXPORTED_SYMBOL_FILE
976 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
977 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
979 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
980 $(LLVMToolDir)/llvm-ar
981 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
983 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
985 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
987 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
988 $(LLVMToolDir)/llvm-ar
989 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
991 $(Verb) $(LArchive) $@ $(ObjectsBC)
996 ifneq ($(strip $(LibName.BCA)),)
997 -$(Verb) $(RM) -f $(LibName.BCA)
1000 ifdef BYTECODE_DESTINATION
1001 BytecodeDestDir := $(BYTECODE_DESTINATION)
1003 BytecodeDestDir := $(PROJ_libdir)
1006 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
1008 install-bytecode-local:: $(DestBytecodeLib)
1012 $(Echo) Install circumvented with NO_INSTALL
1014 $(Echo) Uninstall circumvented with NO_INSTALL
1016 install-local:: $(DestBytecodeLib)
1018 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1019 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1020 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1023 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1024 -$(Verb) $(RM) -f $(DestBytecodeLib)
1029 #---------------------------------------------------------
1030 # ReLinked Library Targets:
1031 # If the user explicitly requests a relinked library with
1032 # BUILD_RELINKED, provide it. Otherwise, if they specify
1033 # neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
1035 #---------------------------------------------------------
1036 ifndef BUILD_ARCHIVE
1037 ifndef DONT_BUILD_RELINKED
1042 ifdef BUILD_RELINKED
1044 all-local:: $(LibName.O)
1046 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
1047 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
1048 $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
1051 ifneq ($(strip $(LibName.O)),)
1052 -$(Verb) $(RM) -f $(LibName.O)
1057 $(Echo) Install circumvented with NO_INSTALL
1059 $(Echo) Uninstall circumvented with NO_INSTALL
1061 DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
1063 install-local:: $(DestRelinkedLib)
1065 $(DestRelinkedLib): $(LibName.O) $(PROJ_libdir)
1066 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
1067 $(Verb) $(INSTALL) $(LibName.O) $(DestRelinkedLib)
1070 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
1071 -$(Verb) $(RM) -f $(DestRelinkedLib)
1075 #---------------------------------------------------------
1076 # Archive Library Targets:
1077 # If the user wanted a regular archive library built,
1078 # then we provide targets for building them.
1079 #---------------------------------------------------------
1082 all-local:: $(LibName.A)
1084 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1085 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1086 -$(Verb) $(RM) -f $@
1087 $(Verb) $(Archive) $@ $(ObjectsO)
1088 $(Verb) $(Ranlib) $@
1091 ifneq ($(strip $(LibName.A)),)
1092 -$(Verb) $(RM) -f $(LibName.A)
1097 $(Echo) Install circumvented with NO_INSTALL
1099 $(Echo) Uninstall circumvented with NO_INSTALL
1101 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1103 install-local:: $(DestArchiveLib)
1105 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1106 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1107 $(Verb) $(MKDIR) $(PROJ_libdir)
1108 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1111 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1112 -$(Verb) $(RM) -f $(DestArchiveLib)
1119 ###############################################################################
1120 # Tool Build Rules: Build executable tool based on TOOLNAME option
1121 ###############################################################################
1125 #---------------------------------------------------------
1126 # Set up variables for building a tool.
1127 #---------------------------------------------------------
1129 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1131 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1134 #---------------------------------------------------------
1136 #---------------------------------------------------------
1138 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1139 # not exporting all of the weak symbols from the binary. This reduces dyld
1140 # startup time by 4x on darwin in some cases.
1141 ifdef TOOL_NO_EXPORTS
1144 # Tiger tools don't support this.
1145 ifneq ($(DARWIN_MAJVERS),4)
1146 LD.Flags += -Wl,-exported_symbol -Wl,_main
1150 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
1151 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1156 #---------------------------------------------------------
1157 # Provide targets for building the tools
1158 #---------------------------------------------------------
1159 all-local:: $(ToolBuildPath)
1162 ifneq ($(strip $(ToolBuildPath)),)
1163 -$(Verb) $(RM) -f $(ToolBuildPath)
1167 $(ToolBuildPath): $(ExmplDir)/.dir
1169 $(ToolBuildPath): $(ToolDir)/.dir
1172 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1173 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1174 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1175 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1176 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1181 $(Echo) Install circumvented with NO_INSTALL
1183 $(Echo) Uninstall circumvented with NO_INSTALL
1185 DestTool = $(PROJ_bindir)/$(TOOLNAME)
1187 install-local:: $(DestTool)
1189 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1190 $(Echo) Installing $(BuildMode) $(DestTool)
1191 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1194 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1195 -$(Verb) $(RM) -f $(DestTool)
1199 ###############################################################################
1200 # Object Build Rules: Build object files based on sources
1201 ###############################################################################
1203 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1205 DISABLE_AUTO_DEPENDENCIES=1
1208 # Provide rule sets for when dependency generation is enabled
1209 ifndef DISABLE_AUTO_DEPENDENCIES
1211 #---------------------------------------------------------
1212 # Create .o files in the ObjDir directory from the .cpp and .c files...
1213 #---------------------------------------------------------
1215 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1216 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1218 # If the build succeeded, move the dependency file over. If it failed, put an
1220 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1221 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1223 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1224 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1225 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1228 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1229 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1230 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1233 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1234 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1235 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1238 #---------------------------------------------------------
1239 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1240 #---------------------------------------------------------
1242 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1243 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1244 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1245 $< -o $@ -S -emit-llvm ; \
1246 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1247 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1248 $(call UPGRADE_MSG,$@)
1249 $(call UPGRADE_LL,$@)
1251 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1252 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1253 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1254 $< -o $@ -S -emit-llvm ; \
1255 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1256 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1257 $(call UPGRADE_MSG,$@)
1258 $(call UPGRADE_LL,$@)
1260 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1261 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1262 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1263 $< -o $@ -S -emit-llvm ; \
1264 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1265 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
1266 $(call UPGRADE_MSG,$@)
1267 $(call UPGRADE_LL,$@)
1269 # Provide alternate rule sets if dependencies are disabled
1272 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1273 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1274 $(Compile.CXX) $< -o $@
1276 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1277 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1278 $(Compile.CXX) $< -o $@
1280 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1281 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1282 $(Compile.C) $< -o $@
1284 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1285 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1286 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1287 $(call UPGRADE_MSG,$@)
1288 $(call UPGRADE_LL,$@)
1290 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1291 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1292 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1293 $(call UPGRADE_MSG,$@)
1294 $(call UPGRADE_LL,$@)
1296 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1297 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1298 $(BCCompile.C) $< -o $@ -S -emit-llvm
1299 $(call UPGRADE_MSG,@)
1300 $(call UPGRADE_LL,@)
1305 ## Rules for building preprocessed (.i/.ii) outputs.
1306 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1307 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1308 $(Verb) $(Preprocess.CXX) $< -o $@
1310 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1311 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1312 $(Verb) $(Preprocess.CXX) $< -o $@
1314 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1315 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1316 $(Verb) $(Preprocess.C) $< -o $@
1319 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1320 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1321 $(Compile.CXX) $< -o $@ -S
1323 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1324 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1325 $(Compile.CXX) $< -o $@ -S
1327 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1328 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1329 $(Compile.C) $< -o $@ -S
1332 # make the C and C++ compilers strip debug info out of bytecode libraries.
1334 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1335 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1336 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
1338 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
1339 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1340 $(Verb) $(LLVMAS) $< -o - | \
1341 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
1345 #---------------------------------------------------------
1346 # Provide rule to build .bc files from .ll sources,
1347 # regardless of dependencies
1348 #---------------------------------------------------------
1349 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1350 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1351 $(Verb) $(LLVMAS) $< -f -o $@
1353 ###############################################################################
1354 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1355 ###############################################################################
1358 TABLEGEN_INC_FILES_COMMON = 1
1361 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1362 TABLEGEN_INC_FILES_COMMON = 1
1365 ifdef TABLEGEN_INC_FILES_COMMON
1367 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1368 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1369 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1371 # INCFiles rule: All of the tblgen generated files are emitted to
1372 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1373 # us to only "touch" the real file if the contents of it change. IOW, if
1374 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1375 # dependencies of the .inc files are, unless the contents of the .inc file
1377 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1378 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1380 endif # TABLEGEN_INC_FILES_COMMON
1384 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1385 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1386 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1387 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1388 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1389 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1390 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1392 # All of these files depend on tblgen and the .td files.
1393 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1395 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1396 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1397 $(Echo) "Building $(<F) register names with tblgen"
1398 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1400 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1401 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1402 $(Echo) "Building $(<F) register information header with tblgen"
1403 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1405 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1406 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1407 $(Echo) "Building $(<F) register info implementation with tblgen"
1408 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1410 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1411 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1412 $(Echo) "Building $(<F) instruction names with tblgen"
1413 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1415 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1416 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1417 $(Echo) "Building $(<F) instruction information with tblgen"
1418 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1420 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1421 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1422 $(Echo) "Building $(<F) assembly writer with tblgen"
1423 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1425 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1426 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1427 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1428 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1430 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1431 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1432 $(Echo) "Building $(<F) code emitter with tblgen"
1433 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1435 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1436 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1437 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1438 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1440 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1441 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1442 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1443 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1445 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1446 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1447 $(Echo) "Building $(<F) subtarget information with tblgen"
1448 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1450 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1451 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1452 $(Echo) "Building $(<F) calling convention information with tblgen"
1453 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1455 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1456 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1457 $(Echo) "Building $(<F) calling convention information with tblgen"
1458 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1461 -$(Verb) $(RM) -f $(INCFiles)
1465 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1467 LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
1469 TDFiles := $(LLVMCPluginSrc) \
1470 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1472 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1473 $(TBLGEN) $(TD_COMMON)
1474 $(Echo) "Building LLVMC configuration library with tblgen"
1475 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1477 endif # LLVMC_BUILD_AUTOGENERATED_INC
1479 ###############################################################################
1480 # OTHER RULES: Other rules needed
1481 ###############################################################################
1483 # To create postscript files from dot files...
1484 ifneq ($(DOT),false)
1486 $(DOT) -Tps < $< > $@
1489 $(Echo) "Cannot build $@: The program dot is not installed"
1492 # This rules ensures that header files that are removed still have a rule for
1493 # which they can be "generated." This allows make to ignore them and
1494 # reproduce the dependency lists.
1498 # Define clean-local to clean the current directory. Note that this uses a
1499 # very conservative approach ensuring that empty variables do not cause
1500 # errors or disastrous removal.
1502 ifneq ($(strip $(ObjRootDir)),)
1503 -$(Verb) $(RM) -rf $(ObjRootDir)
1505 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1506 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1507 -$(Verb) $(RM) -f *$(SHLIBEXT)
1511 -$(Verb) $(RM) -rf Debug Release Profile
1514 ###############################################################################
1515 # DEPENDENCIES: Include the dependency files if we should
1516 ###############################################################################
1517 ifndef DISABLE_AUTO_DEPENDENCIES
1519 # If its not one of the cleaning targets
1520 ifndef IS_CLEANING_TARGET
1522 # Get the list of dependency files
1523 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1524 DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1526 -include $(DependFiles) ""
1532 ###############################################################################
1533 # CHECK: Running the test suite
1534 ###############################################################################
1537 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1538 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1539 $(EchoCmd) Running test suite ; \
1540 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1541 TESTSUITE=$(TESTSUITE) ; \
1543 $(EchoCmd) No Makefile in test directory ; \
1546 $(EchoCmd) No test directory ; \
1549 ###############################################################################
1550 # UNITTESTS: Running the unittests test suite
1551 ###############################################################################
1554 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1555 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1556 $(EchoCmd) Running unittests test suite ; \
1557 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1559 $(EchoCmd) No Makefile in unittests directory ; \
1562 $(EchoCmd) No unittests directory ; \
1565 ###############################################################################
1566 # DISTRIBUTION: Handle construction of a distribution tarball
1567 ###############################################################################
1569 #------------------------------------------------------------------------
1570 # Define distribution related variables
1571 #------------------------------------------------------------------------
1572 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1573 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1574 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1575 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1576 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1577 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1578 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1579 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1580 Makefile.config.in configure autoconf
1581 DistOther := $(notdir $(wildcard \
1582 $(PROJ_SRC_DIR)/*.h \
1583 $(PROJ_SRC_DIR)/*.td \
1584 $(PROJ_SRC_DIR)/*.def \
1585 $(PROJ_SRC_DIR)/*.ll \
1586 $(PROJ_SRC_DIR)/*.in))
1587 DistSubDirs := $(SubDirs)
1588 DistSources = $(Sources) $(EXTRA_DIST)
1589 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1591 #------------------------------------------------------------------------
1592 # We MUST build distribution with OBJ_DIR != SRC_DIR
1593 #------------------------------------------------------------------------
1594 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1595 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1596 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1600 #------------------------------------------------------------------------
1601 # Prevent attempt to run dist targets from anywhere but the top level
1602 #------------------------------------------------------------------------
1604 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1605 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1608 #------------------------------------------------------------------------
1609 # Provide the top level targets
1610 #------------------------------------------------------------------------
1612 dist-gzip:: $(DistTarGZip)
1614 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1615 $(Echo) Packing gzipped distribution tar file.
1616 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1617 $(GZIP) -c > "$(DistTarGZip)"
1619 dist-bzip2:: $(DistTarBZ2)
1621 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1622 $(Echo) Packing bzipped distribution tar file.
1623 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1624 $(BZIP2) -c >$(DistTarBZ2)
1626 dist-zip:: $(DistZip)
1628 $(DistZip) : $(TopDistDir)/.makedistdir
1629 $(Echo) Packing zipped distribution file.
1630 $(Verb) rm -f $(DistZip)
1631 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1633 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1634 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1636 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1638 dist-check:: $(DistTarGZip)
1639 $(Echo) Checking distribution tar file.
1640 $(Verb) if test -d $(DistCheckDir) ; then \
1641 $(RM) -rf $(DistCheckDir) ; \
1643 $(Verb) $(MKDIR) $(DistCheckDir)
1644 $(Verb) cd $(DistCheckDir) && \
1645 $(MKDIR) $(DistCheckDir)/build && \
1646 $(MKDIR) $(DistCheckDir)/install && \
1647 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1649 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1650 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1653 $(MAKE) unittests && \
1654 $(MAKE) install && \
1655 $(MAKE) uninstall && \
1656 $(MAKE) dist-clean && \
1657 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1660 $(Echo) Cleaning distribution files
1661 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1666 #------------------------------------------------------------------------
1667 # Provide the recursive distdir target for building the distribution directory
1668 #------------------------------------------------------------------------
1669 distdir: $(DistDir)/.makedistdir
1670 $(DistDir)/.makedistdir: $(DistSources)
1671 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1672 if test -d "$(DistDir)" ; then \
1673 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1676 $(EchoCmd) Removing old $(DistDir) ; \
1677 $(RM) -rf $(DistDir); \
1678 $(EchoCmd) Making 'all' to verify build ; \
1679 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1681 $(Echo) Building Distribution Directory $(DistDir)
1682 $(Verb) $(MKDIR) $(DistDir)
1683 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1684 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1685 for file in $(DistFiles) ; do \
1687 $(PROJ_SRC_DIR)/*) \
1688 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1690 $(PROJ_SRC_ROOT)/*) \
1691 file=`echo "$$file" | \
1692 sed "s#^$$srcrootstrip/##"` \
1695 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1696 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1697 from_dir="$(PROJ_SRC_DIR)" ; \
1698 elif test -f "$$file" || test -d "$$file" ; then \
1701 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1702 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1703 to_dir="$(DistDir)/$$dir"; \
1704 $(MKDIR) "$$to_dir" ; \
1706 to_dir="$(DistDir)"; \
1708 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1709 if test -n "$$mid_dir" ; then \
1710 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1712 if test -d "$$from_dir/$$file"; then \
1713 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1714 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1715 cd $(PROJ_SRC_DIR) ; \
1716 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1717 ( cd $$to_dir ; $(TAR) xf - ) ; \
1718 cd $(PROJ_OBJ_DIR) ; \
1721 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1722 ( cd $$to_dir ; $(TAR) xf - ) ; \
1723 cd $(PROJ_OBJ_DIR) ; \
1725 elif test -f "$$from_dir/$$file" ; then \
1726 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1727 elif test -L "$$from_dir/$$file" ; then \
1728 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1729 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1730 $(EchoCmd) "===== WARNING: Distribution Source " \
1731 "$$from_dir/$$file Not Found!" ; \
1732 elif test "$(Verb)" != '@' ; then \
1733 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1736 $(Verb) for subdir in $(DistSubDirs) ; do \
1737 if test "$$subdir" \!= "." ; then \
1738 new_distdir="$(DistDir)/$$subdir" ; \
1739 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1740 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1741 DistDir="$$new_distdir" distdir ) || exit 1; \
1744 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1745 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1746 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1747 -name .svn \) -print` ;\
1748 $(MAKE) dist-hook ; \
1749 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1750 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1751 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1752 -o ! -type d ! -perm -444 -exec \
1753 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1754 || chmod -R a+r $(DistDir) ; \
1757 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1763 ###############################################################################
1764 # TOP LEVEL - targets only to apply at the top level directory
1765 ###############################################################################
1769 #------------------------------------------------------------------------
1770 # Install support for the project's include files:
1771 #------------------------------------------------------------------------
1774 $(Echo) Install circumvented with NO_INSTALL
1776 $(Echo) Uninstall circumvented with NO_INSTALL
1779 $(Echo) Installing include files
1780 $(Verb) $(MKDIR) $(PROJ_includedir)
1781 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1782 cd $(PROJ_SRC_ROOT)/include && \
1783 for hdr in `find . -type f '!' '(' -name '*~' \
1784 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1785 grep -v .svn` ; do \
1786 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1787 if test \! -d "$$instdir" ; then \
1788 $(EchoCmd) Making install directory $$instdir ; \
1789 $(MKDIR) $$instdir ;\
1791 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1794 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1795 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1796 cd $(PROJ_OBJ_ROOT)/include && \
1797 for hdr in `find . -type f -print | grep -v CVS` ; do \
1798 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1804 $(Echo) Uninstalling include files
1805 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1806 cd $(PROJ_SRC_ROOT)/include && \
1807 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1808 '!' '(' -name '*~' -o -name '.#*' \
1809 -o -name '*.in' ')' -print ')' | \
1810 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1811 cd $(PROJ_SRC_ROOT)/include && \
1812 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1813 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1819 @echo searching for overlength lines in files: $(Sources)
1822 egrep -n '.{81}' $(Sources) /dev/null
1825 @echo searching for tabs in files: $(Sources)
1828 egrep -n ' ' $(Sources) /dev/null
1831 @ls -l $(LibDir) | awk '\
1832 BEGIN { sum = 0; } \
1834 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1835 @ls -l $(ToolDir) | awk '\
1836 BEGIN { sum = 0; } \
1838 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1839 #------------------------------------------------------------------------
1840 # Print out the directories used for building
1841 #------------------------------------------------------------------------
1843 $(Echo) "BuildMode : " '$(BuildMode)'
1844 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1845 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1846 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1847 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1848 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1849 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1850 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1851 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1852 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1853 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1854 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1855 $(Echo) "UserTargets : " '$(UserTargets)'
1856 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1857 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1858 $(Echo) "ObjDir : " '$(ObjDir)'
1859 $(Echo) "LibDir : " '$(LibDir)'
1860 $(Echo) "ToolDir : " '$(ToolDir)'
1861 $(Echo) "ExmplDir : " '$(ExmplDir)'
1862 $(Echo) "Sources : " '$(Sources)'
1863 $(Echo) "TDFiles : " '$(TDFiles)'
1864 $(Echo) "INCFiles : " '$(INCFiles)'
1865 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1866 $(Echo) "PreConditions: " '$(PreConditions)'
1867 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1868 $(Echo) "Compile.C : " '$(Compile.C)'
1869 $(Echo) "Archive : " '$(Archive)'
1870 $(Echo) "YaccFiles : " '$(YaccFiles)'
1871 $(Echo) "LexFiles : " '$(LexFiles)'
1872 $(Echo) "Module : " '$(Module)'
1873 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1874 $(Echo) "SubDirs : " '$(SubDirs)'
1875 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1876 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1881 # General debugging rule, use 'make dbg-print-XXX' to print the
1882 # definition, value and origin of XXX.
1884 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))