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 \
24 LocalTargets := all-local clean-local clean-all-local check-local \
25 install-local printvars uninstall-local \
26 install-bytecode-local
27 TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
29 UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30 InternalTargets := preconditions distdir dist-hook
32 ################################################################################
33 # INITIALIZATION: Basic things the makefile needs
34 ################################################################################
36 #--------------------------------------------------------------------
37 # Set the VPATH so that we can find source files.
38 #--------------------------------------------------------------------
41 #--------------------------------------------------------------------
42 # Reset the list of suffixes we know how to build.
43 #--------------------------------------------------------------------
45 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll
46 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
48 #--------------------------------------------------------------------
49 # Mark all of these targets as phony to avoid implicit rule search
50 #--------------------------------------------------------------------
51 .PHONY: $(UserTargets) $(InternalTargets)
53 #--------------------------------------------------------------------
54 # Make sure all the user-target rules are double colon rules and
55 # they are defined first.
56 #--------------------------------------------------------------------
60 ################################################################################
61 # PRECONDITIONS: that which must be built/checked first
62 ################################################################################
64 SrcMakefiles := $(filter %Makefile %Makefile.tests,\
65 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
66 ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
67 ConfigureScript := $(PROJ_SRC_ROOT)/configure
68 ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
69 MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
70 MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
71 MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
72 MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
73 PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
74 ifneq ($(MakefileCommonIn),)
75 PreConditions += $(MakefileCommon)
78 ifneq ($(MakefileConfigIn),)
79 PreConditions += $(MakefileConfig)
82 preconditions: $(PreConditions)
84 #------------------------------------------------------------------------
85 # Make sure the BUILT_SOURCES are built first
86 #------------------------------------------------------------------------
87 $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
90 ifneq ($(strip $(BUILT_SOURCES)),)
91 -$(Verb) $(RM) -f $(BUILT_SOURCES)
94 ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
96 $(Verb) if test -x config.status ; then \
97 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
98 $(MKDIR) .spotless.save ; \
99 $(MV) config.status .spotless.save ; \
100 $(MV) mklib .spotless.save ; \
101 $(MV) projects .spotless.save ; \
103 $(MV) .spotless.save/config.status . ; \
104 $(MV) .spotless.save/mklib . ; \
105 $(MV) .spotless.save/projects . ; \
106 $(RM) -rf .spotless.save ; \
107 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript) ; \
111 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
115 $(EchoCmd) "spotless target not supported for objdir == srcdir"
118 $(BUILT_SOURCES) : $(ObjMakefiles)
120 #------------------------------------------------------------------------
121 # Make sure we're not using a stale configuration
122 #------------------------------------------------------------------------
124 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
125 $(Verb) cd $(PROJ_OBJ_ROOT) && \
126 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
127 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
129 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
130 $(ConfigStatusScript)
132 # FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
133 # up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
135 .PRECIOUS: $(ConfigStatusScript)
136 $(ConfigStatusScript): $(ConfigureScript) $(LLVM_SRC_ROOT)/lib/Target/PIC16/AsmPrinter/Makefile $(LLVM_SRC_ROOT)/lib/Target/MSP430/AsmPrinter/Makefile
137 $(Echo) Reconfiguring with $<
138 $(Verb) cd $(PROJ_OBJ_ROOT) && \
139 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
140 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
142 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
143 $(ConfigStatusScript)
145 #------------------------------------------------------------------------
146 # Make sure the configuration makefile is up to date
147 #------------------------------------------------------------------------
148 ifneq ($(MakefileConfigIn),)
149 $(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
150 $(Echo) Regenerating $@
151 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
154 ifneq ($(MakefileCommonIn),)
155 $(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
156 $(Echo) Regenerating $@
157 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
160 #------------------------------------------------------------------------
161 # If the Makefile in the source tree has been updated, copy it over into the
162 # build tree. But, only do this if the source and object makefiles differ
163 #------------------------------------------------------------------------
164 ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
166 Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
167 $(Echo) "Updating Makefile"
168 $(Verb) $(MKDIR) $(@D)
169 $(Verb) $(CP) -f $< $@
171 # Copy the Makefile.* files unless we're in the root directory which avoids
172 # the copying of Makefile.config.in or other things that should be explicitly
174 $(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
176 *Makefile.rules) ;; \
178 *) $(EchoCmd) "Updating $(@F)" ; \
185 #------------------------------------------------------------------------
186 # Set up the basic dependencies
187 #------------------------------------------------------------------------
188 $(UserTargets):: $(PreConditions)
192 clean-all:: clean-local clean-all-local
193 install:: install-local
194 uninstall:: uninstall-local
195 install-local:: all-local
196 install-bytecode:: install-bytecode-local
198 ###############################################################################
199 # LLVMC: Provide rules for compiling llvmc plugins
200 ###############################################################################
204 LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
205 CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
208 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
209 LD.Flags += -lCompilerDriver
212 # Build a dynamic library if the user runs `make` directly from the plugin
214 ifndef LLVMC_BUILTIN_PLUGIN
219 ifneq ($(BUILT_SOURCES),)
220 LLVMC_BUILD_AUTOGENERATED_INC=1
225 ifdef LLVMC_BASED_DRIVER
227 TOOLNAME = $(LLVMC_BASED_DRIVER)
231 ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
232 LD.Flags += -lCompilerDriver
234 LLVMLIBS = CompilerDriver.a
235 LINK_COMPONENTS = support system
238 # Preprocessor magic that generates references to static variables in built-in
240 ifneq ($(LLVMC_BUILTIN_PLUGINS),)
242 USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
244 LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS))
245 LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS))
246 LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS))
247 LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS))
248 LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS))
250 ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
251 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
254 ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
255 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
258 ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
259 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
262 ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
263 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
266 ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
267 CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
272 endif # LLVMC_BASED_DRIVER
274 ###############################################################################
275 # VARIABLES: Set up various variables based on configuration data
276 ###############################################################################
278 # Variable for if this make is for a "cleaning" target
279 ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
283 #--------------------------------------------------------------------
284 # Variables derived from configuration we are building
285 #--------------------------------------------------------------------
288 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
289 # this can be overridden on the make command line.
290 ifndef OPTIMIZE_OPTION
291 ifneq ($(HOST_OS),MingW)
292 OPTIMIZE_OPTION := -O3
294 OPTIMIZE_OPTION := -O2
298 ifeq ($(ENABLE_OPTIMIZED),1)
300 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
301 ifneq ($(HOST_OS),FreeBSD)
302 ifneq ($(HOST_OS),Darwin)
303 OmitFramePointer := -fomit-frame-pointer
307 # Darwin requires -fstrict-aliasing to be explicitly enabled.
308 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
309 # with -fstrict-aliasing and ipa-type-escape radr://6756684
310 #ifeq ($(HOST_OS),Darwin)
311 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
313 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
314 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
315 LD.Flags += $(OPTIMIZE_OPTION)
324 ifeq ($(ENABLE_PROFILING),1)
325 BuildMode := $(BuildMode)+Profile
326 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
327 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
328 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
332 #ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
333 # CXX.Flags += -fvisibility-inlines-hidden
336 # IF REQUIRES_EH=1 is specified then don't disable exceptions
338 CXX.Flags += -fno-exceptions
341 ifdef REQUIRES_FRAME_POINTER
342 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
343 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
344 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
347 # If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
348 ifeq ($(REQUIRES_RTTI), 1)
349 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
350 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
353 ifdef ENABLE_COVERAGE
354 BuildMode := $(BuildMode)+Coverage
355 CXX.Flags += -ftest-coverage -fprofile-arcs
356 C.Flags += -ftest-coverage -fprofile-arcs
359 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
360 # then disable assertions by defining the appropriate preprocessor symbols.
361 ifdef DISABLE_ASSERTIONS
362 # Indicate that assertions are turned off using a minus sign
363 BuildMode := $(BuildMode)-Asserts
364 CPP.Defines += -DNDEBUG
366 CPP.Defines += -D_DEBUG
369 # If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
370 # configured), then enable expensive checks by defining the
371 # appropriate preprocessor symbols.
372 ifdef ENABLE_EXPENSIVE_CHECKS
373 BuildMode := $(BuildMode)+Checks
374 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
377 # LOADABLE_MODULE implies several other things so we force them to be
379 ifdef LOADABLE_MODULE
381 LINK_LIBS_IN_SHARED := 1
389 ifeq ($(ENABLE_PIC),1)
390 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
391 # Nothing. Win32 defaults to PIC and warns when given -fPIC
393 ifeq ($(HOST_OS),Darwin)
394 # Common symbols not allowed in dylib files
395 CXX.Flags += -fno-common
396 C.Flags += -fno-common
398 # Linux and others; pass -fPIC
404 ifeq ($(HOST_OS),Darwin)
405 CXX.Flags += -mdynamic-no-pic
406 C.Flags += -mdynamic-no-pic
410 CXX.Flags += -Woverloaded-virtual
411 CPP.BaseFlags += $(CPP.Defines)
414 # Make Floating point IEEE compliant on Alpha.
417 CPP.BaseFlags += -mieee
418 ifeq ($(ENABLE_PIC),0)
420 CPP.BaseFlags += -fPIC
425 LD.Flags += -Wl,--no-relax
428 ifeq ($(HOST_OS),MingW)
429 ifeq ($(LLVM_CROSS_COMPILING),1)
430 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
432 LD.Flags += -Wl,--allow-multiple-definition
437 ifdef ENABLE_EXPENSIVE_CHECKS
438 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
439 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
440 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
441 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
444 #--------------------------------------------------------------------
445 # Directory locations
446 #--------------------------------------------------------------------
448 ifeq ($(LLVM_CROSS_COMPILING),1)
449 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
452 ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
453 ObjDir := $(ObjRootDir)
454 LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
455 ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
456 ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
457 LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
458 LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
459 LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
460 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
462 #--------------------------------------------------------------------
463 # Full Paths To Compiled Tools and Utilities
464 #--------------------------------------------------------------------
465 EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
468 LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
471 ifeq ($(LLVM_CROSS_COMPILING),1)
472 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
474 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
477 LLVM_CONFIG := $(LLVMToolDir)/llvm-config
479 LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
482 LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
485 LLI := $(LLVMToolDir)/lli$(EXEEXT)
488 LLC := $(LLVMToolDir)/llc$(EXEEXT)
491 LOPT := $(LLVMToolDir)/opt$(EXEEXT)
494 LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
497 LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
499 ifeq ($(LLVMGCC_MAJVERS),3)
500 LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
501 LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
503 LLVMGCCWITHPATH := $(LLVMGCC)
504 LLVMGXXWITHPATH := $(LLVMGXX)
507 #--------------------------------------------------------------------
508 # Adjust to user's request
509 #--------------------------------------------------------------------
511 ifeq ($(HOST_OS),Darwin)
512 DARWIN_VERSION := `sw_vers -productVersion`
513 # Strip a number like 10.4.7 to 10.4
514 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
515 # Get "4" out of 10.4 for later pieces in the makefile.
516 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
518 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
521 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
524 ifeq ($(HOST_OS),Cygwin)
525 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
526 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
528 SharedLinkOptions=-shared
532 ifeq ($(TARGET_OS),Darwin)
534 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
538 # Adjust LD.Flags depending on the kind of library that is to be built. Note
539 # that if LOADABLE_MODULE is specified then the resulting shared library can
540 # be opened with dlopen.
541 ifdef LOADABLE_MODULE
546 ifneq ($(DARWIN_MAJVERS),4)
547 LD.Flags += $(RPATH) -Wl,$(LibDir)
558 # Adjust settings for verbose mode
561 AR.Flags += >/dev/null 2>/dev/null
562 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
564 ConfigureScriptFLAGS :=
567 # By default, strip symbol information from executable
569 Strip := $(PLATFORMSTRIPOPTS)
570 StripWarnMsg := "(without symbols)"
571 Install.StripFlag += -s
574 # Adjust linker flags for building an executable
575 ifneq ($(HOST_OS),Darwin)
576 ifneq ($(DARWIN_MAJVERS),4)
579 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
581 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
587 #----------------------------------------------------------
588 # Options To Invoke Tools
589 #----------------------------------------------------------
592 CompileCommonOpts += -pedantic -Wno-long-long
594 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
597 ifeq ($(HOST_OS),HP-UX)
598 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
601 # If we are building a universal binary on Mac OS/X, pass extra options. This
602 # is useful to people that want to link the LLVM libraries into their universal
605 # The following can be optionally specified:
606 # UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
607 # For Mac OS/X 10.4 Intel machines, the traditional one is:
608 # UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
609 # UNIVERSAL_ARCH can be optionally specified to be a list of architectures
610 # to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
613 ifndef UNIVERSAL_ARCH
614 UNIVERSAL_ARCH := i386 ppc
616 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
617 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
618 ifdef UNIVERSAL_SDK_PATH
619 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
622 # Building universal cannot compute dependencies automatically.
623 DISABLE_AUTO_DEPENDENCIES=1
625 ifeq ($(TARGET_OS),Darwin)
626 ifeq ($(ARCH),x86_64)
627 TargetCommonOpts = -m64
630 TargetCommonOpts = -m32
636 ifeq ($(HOST_OS),SunOS)
637 CPP.BaseFlags += -include llvm/System/Solaris.h
640 LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
641 CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
642 # All -I flags should go here, so that they don't confuse llvm-config.
643 CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
644 $(patsubst %,-I%/include,\
645 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
646 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
649 ifeq ($(BUILD_COMPONENT), 1)
650 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
651 $(TargetCommonOpts) $(CompileCommonOpts) -c
652 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
654 $(TargetCommonOpts) $(CompileCommonOpts) -c
655 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
656 $(CompileCommonOpts) $(CXX.Flags) -E
657 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
659 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
661 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
662 $(TargetCommonOpts) $(CompileCommonOpts) -c
663 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
664 $(TargetCommonOpts) $(CompileCommonOpts) -c
665 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
666 $(CompileCommonOpts) $(CXX.Flags) -E
667 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
668 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
671 BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CFLAGS) \
673 $(TargetCommonOpts) $(CompileCommonOpts)
674 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
675 $(TargetCommonOpts) $(CompileCommonOpts) -E
677 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
679 $(TargetCommonOpts) $(CompileCommonOpts)
681 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
682 ScriptInstall = $(INSTALL) -m 0755
683 DataInstall = $(INSTALL) -m 0644
685 # When compiling under Mingw/Cygwin, the tblgen tool expects Windows
686 # paths. In this case, the SYSPATH function (defined in
687 # Makefile.config) transforms Unix paths into Windows paths.
688 TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
689 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
690 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
691 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
693 Archive = $(AR) $(AR.Flags)
694 LArchive = $(LLVMToolDir)/llvm-ar rcsf
701 #----------------------------------------------------------
702 # Get the list of source files and compute object file
704 #----------------------------------------------------------
707 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
708 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
710 Sources := $(SOURCES)
714 Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
717 BaseNameSources := $(sort $(basename $(Sources)))
719 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
720 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
722 ###############################################################################
723 # DIRECTORIES: Handle recursive descent of directory structure
724 ###############################################################################
726 #---------------------------------------------------------
727 # Provide rules to make install dirs. This must be early
728 # in the file so they get built before dependencies
729 #---------------------------------------------------------
731 $(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
734 # To create other directories, as needed, and timestamp their creation
736 $(Verb) $(MKDIR) $* > /dev/null
739 .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
740 .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
742 #---------------------------------------------------------
743 # Handle the DIRS options for sequential construction
744 #---------------------------------------------------------
750 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
751 $(RecursiveTargets)::
752 $(Verb) for dir in $(DIRS); do \
753 if [ ! -f $$dir/Makefile ]; then \
755 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
757 ($(MAKE) -C $$dir $@ ) || exit 1; \
760 $(RecursiveTargets)::
761 $(Verb) for dir in $(DIRS); do \
762 ($(MAKE) -C $$dir $@ ) || exit 1; \
768 #---------------------------------------------------------
769 # Handle the EXPERIMENTAL_DIRS options ensuring success
770 # after each directory is built.
771 #---------------------------------------------------------
772 ifdef EXPERIMENTAL_DIRS
773 $(RecursiveTargets)::
774 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
775 if [ ! -f $$dir/Makefile ]; then \
777 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
779 ($(MAKE) -C $$dir $@ ) || exit 0; \
783 #-----------------------------------------------------------
784 # Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
785 #-----------------------------------------------------------
786 ifdef OPTIONAL_PARALLEL_DIRS
787 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
790 #-----------------------------------------------------------
791 # Handle the PARALLEL_DIRS options for parallel construction
792 #-----------------------------------------------------------
795 SubDirs += $(PARALLEL_DIRS)
797 # Unfortunately, this list must be maintained if new recursive targets are added
798 all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
799 clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
800 clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
801 install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
802 uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
803 install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
804 unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
806 ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
809 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
811 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
813 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
816 #---------------------------------------------------------
817 # Handle the OPTIONAL_DIRS options for directores that may
819 #---------------------------------------------------------
822 SubDirs += $(OPTIONAL_DIRS)
824 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
825 $(RecursiveTargets)::
826 $(Verb) for dir in $(OPTIONAL_DIRS); do \
827 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
828 if [ ! -f $$dir/Makefile ]; then \
830 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
832 ($(MAKE) -C$$dir $@ ) || exit 1; \
836 $(RecursiveTargets)::
837 $(Verb) for dir in $(OPTIONAL_DIRS); do \
838 ($(MAKE) -C$$dir $@ ) || exit 1; \
843 #---------------------------------------------------------
844 # Handle the CONFIG_FILES options
845 #---------------------------------------------------------
850 $(Echo) Install circumvented with NO_INSTALL
852 $(Echo) UnInstall circumvented with NO_INSTALL
854 install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
855 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
856 $(Verb)for file in $(CONFIG_FILES); do \
857 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
858 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
859 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
860 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
862 $(ECHO) Error: cannot find config file $${file}. ; \
867 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
868 $(Verb)for file in $(CONFIG_FILES); do \
869 $(RM) -f $(PROJ_etcdir)/$${file} ; \
875 ###############################################################################
876 # Set up variables for building libararies
877 ###############################################################################
879 #---------------------------------------------------------
880 # Define various command line options pertaining to the
881 # libraries needed when linking. There are "Proj" libs
882 # (defined by the user's project) and "LLVM" libs (defined
883 # by the LLVM project).
884 #---------------------------------------------------------
887 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
888 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
889 ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
890 ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
894 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
895 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
896 LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
897 LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
900 ifndef IS_CLEANING_TARGET
901 ifdef LINK_COMPONENTS
903 # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
904 # clean in tools, then do a make in tools (instead of at the top level).
906 @echo "*** llvm-config doesn't exist - rebuilding it."
907 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
909 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
911 LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
912 LLVMLibsPaths += $(LLVM_CONFIG) \
913 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
917 ###############################################################################
918 # Library Build Rules: Four ways to build a library
919 ###############################################################################
921 #---------------------------------------------------------
922 # Bytecode Module Targets:
923 # If the user set MODULE_NAME then they want to build a
924 # bytecode module from the sources. We compile all the
925 # sources and link it together into a single bytecode
927 #---------------------------------------------------------
930 ifeq ($(strip $(LLVMGCC)),)
931 $(warning Modules require llvm-gcc but no llvm-gcc is available ****)
934 Module := $(LibDir)/$(MODULE_NAME).bc
935 LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
938 ifdef EXPORTED_SYMBOL_FILE
939 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
942 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
943 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
944 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
946 all-local:: $(Module)
949 ifneq ($(strip $(Module)),)
950 -$(Verb) $(RM) -f $(Module)
953 ifdef BYTECODE_DESTINATION
954 ModuleDestDir := $(BYTECODE_DESTINATION)
956 ModuleDestDir := $(PROJ_libdir)
961 $(Echo) Install circumvented with NO_INSTALL
963 $(Echo) Uninstall circumvented with NO_INSTALL
965 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
967 install-module:: $(DestModule)
968 install-local:: $(DestModule)
970 $(DestModule): $(ModuleDestDir) $(Module)
971 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
972 $(Verb) $(DataInstall) $(Module) $(DestModule)
975 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
976 -$(Verb) $(RM) -f $(DestModule)
982 # if we're building a library ...
985 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
986 LIBRARYNAME := $(strip $(LIBRARYNAME))
987 ifdef LOADABLE_MODULE
988 LibName.A := $(LibDir)/$(LIBRARYNAME).a
989 LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
991 LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
992 LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
994 LibName.O := $(LibDir)/$(LIBRARYNAME).o
995 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
997 #---------------------------------------------------------
998 # Shared Library Targets:
999 # If the user asked for a shared library to be built
1000 # with the SHARED_LIBRARY variable, then we provide
1001 # targets for building them.
1002 #---------------------------------------------------------
1003 ifdef SHARED_LIBRARY
1005 all-local:: $(LibName.SO)
1007 ifdef LINK_LIBS_IN_SHARED
1008 ifdef LOADABLE_MODULE
1009 SharedLibKindMessage := "Loadable Module"
1011 SharedLibKindMessage := "Shared Library"
1013 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
1014 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1015 $(LIBRARYNAME)$(SHLIBEXT)
1016 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1017 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1019 $(LibName.SO): $(ObjectsO) $(LibDir)/.dir
1020 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
1021 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1025 ifneq ($(strip $(LibName.SO)),)
1026 -$(Verb) $(RM) -f $(LibName.SO)
1031 $(Echo) Install circumvented with NO_INSTALL
1033 $(Echo) Uninstall circumvented with NO_INSTALL
1035 DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1037 install-local:: $(DestSharedLib)
1039 $(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
1040 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1041 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1044 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1045 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1049 #---------------------------------------------------------
1050 # Bytecode Library Targets:
1051 # If the user asked for a bytecode library to be built
1052 # with the BYTECODE_LIBRARY variable, then we provide
1053 # targets for building them.
1054 #---------------------------------------------------------
1055 ifdef BYTECODE_LIBRARY
1056 ifeq ($(strip $(LLVMGCC)),)
1057 $(warning Bytecode libraries require llvm-gcc which could not be found ****)
1060 all-local:: $(LibName.BCA)
1062 ifdef EXPORTED_SYMBOL_FILE
1063 BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
1064 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1066 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1067 $(LLVMToolDir)/llvm-ar
1068 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1070 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1072 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1074 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1075 $(LLVMToolDir)/llvm-ar
1076 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1078 $(Verb) $(LArchive) $@ $(ObjectsBC)
1083 ifneq ($(strip $(LibName.BCA)),)
1084 -$(Verb) $(RM) -f $(LibName.BCA)
1087 ifdef BYTECODE_DESTINATION
1088 BytecodeDestDir := $(BYTECODE_DESTINATION)
1090 BytecodeDestDir := $(PROJ_libdir)
1093 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1095 install-bytecode-local:: $(DestBytecodeLib)
1099 $(Echo) Install circumvented with NO_INSTALL
1101 $(Echo) Uninstall circumvented with NO_INSTALL
1103 install-local:: $(DestBytecodeLib)
1105 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1106 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1107 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1110 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1111 -$(Verb) $(RM) -f $(DestBytecodeLib)
1116 #---------------------------------------------------------
1118 # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1119 # building an archive.
1120 #---------------------------------------------------------
1121 ifndef BUILD_ARCHIVE
1122 ifndef LOADABLE_MODULE
1127 #---------------------------------------------------------
1128 # Archive Library Targets:
1129 # If the user wanted a regular archive library built,
1130 # then we provide targets for building them.
1131 #---------------------------------------------------------
1134 all-local:: $(LibName.A)
1136 $(LibName.A): $(ObjectsO) $(LibDir)/.dir
1137 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1138 -$(Verb) $(RM) -f $@
1139 $(Verb) $(Archive) $@ $(ObjectsO)
1140 $(Verb) $(Ranlib) $@
1143 ifneq ($(strip $(LibName.A)),)
1144 -$(Verb) $(RM) -f $(LibName.A)
1149 $(Echo) Install circumvented with NO_INSTALL
1151 $(Echo) Uninstall circumvented with NO_INSTALL
1153 DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1155 install-local:: $(DestArchiveLib)
1157 $(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
1158 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1159 $(Verb) $(MKDIR) $(PROJ_libdir)
1160 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1163 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1164 -$(Verb) $(RM) -f $(DestArchiveLib)
1171 ###############################################################################
1172 # Tool Build Rules: Build executable tool based on TOOLNAME option
1173 ###############################################################################
1177 #---------------------------------------------------------
1178 # Set up variables for building a tool.
1179 #---------------------------------------------------------
1181 ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1183 ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1186 #---------------------------------------------------------
1188 #---------------------------------------------------------
1190 # If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1191 # not exporting all of the weak symbols from the binary. This reduces dyld
1192 # startup time by 4x on darwin in some cases.
1193 ifdef TOOL_NO_EXPORTS
1194 ifeq ($(HOST_OS),Darwin)
1196 # Tiger tools don't support this.
1197 ifneq ($(DARWIN_MAJVERS),4)
1198 LD.Flags += -Wl,-exported_symbol -Wl,_main
1202 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
1203 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1208 #---------------------------------------------------------
1209 # Provide targets for building the tools
1210 #---------------------------------------------------------
1211 all-local:: $(ToolBuildPath)
1214 ifneq ($(strip $(ToolBuildPath)),)
1215 -$(Verb) $(RM) -f $(ToolBuildPath)
1219 $(ToolBuildPath): $(ExmplDir)/.dir
1221 $(ToolBuildPath): $(ToolDir)/.dir
1224 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1225 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1226 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1227 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1228 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1233 $(Echo) Install circumvented with NO_INSTALL
1235 $(Echo) Uninstall circumvented with NO_INSTALL
1237 DestTool = $(PROJ_bindir)/$(TOOLNAME)$(EXEEXT)
1239 install-local:: $(DestTool)
1241 $(DestTool): $(ToolBuildPath) $(PROJ_bindir)
1242 $(Echo) Installing $(BuildMode) $(DestTool)
1243 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1246 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1247 -$(Verb) $(RM) -f $(DestTool)
1251 ###############################################################################
1252 # Object Build Rules: Build object files based on sources
1253 ###############################################################################
1255 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1256 ifeq ($(HOST_OS),HP-UX)
1257 DISABLE_AUTO_DEPENDENCIES=1
1260 # Provide rule sets for when dependency generation is enabled
1261 ifndef DISABLE_AUTO_DEPENDENCIES
1263 #---------------------------------------------------------
1264 # Create .o files in the ObjDir directory from the .cpp and .c files...
1265 #---------------------------------------------------------
1267 DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1268 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1270 # If the build succeeded, move the dependency file over, otherwise
1272 DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1273 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1275 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1276 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1277 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1280 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1281 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1282 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1285 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1286 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1287 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1290 #---------------------------------------------------------
1291 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1292 #---------------------------------------------------------
1294 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1295 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1297 # If the build succeeded, move the dependency file over, otherwise
1299 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1300 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1302 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1303 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1304 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1305 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1306 $(BC_DEPEND_MOVEFILE)
1308 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1309 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1310 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1311 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1312 $(BC_DEPEND_MOVEFILE)
1314 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1315 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1316 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1317 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1318 $(BC_DEPEND_MOVEFILE)
1320 # Provide alternate rule sets if dependencies are disabled
1323 $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1324 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1325 $(Compile.CXX) $< -o $@
1327 $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1328 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1329 $(Compile.CXX) $< -o $@
1331 $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1332 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1333 $(Compile.C) $< -o $@
1335 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1336 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1337 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1339 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1340 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1341 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
1343 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1344 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1345 $(BCCompile.C) $< -o $@ -S -emit-llvm
1350 ## Rules for building preprocessed (.i/.ii) outputs.
1351 $(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1352 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1353 $(Verb) $(Preprocess.CXX) $< -o $@
1355 $(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1356 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1357 $(Verb) $(Preprocess.CXX) $< -o $@
1359 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1360 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1361 $(Verb) $(Preprocess.C) $< -o $@
1364 $(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1365 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1366 $(Compile.CXX) $< -o $@ -S
1368 $(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1369 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1370 $(Compile.CXX) $< -o $@ -S
1372 $(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1373 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1374 $(Compile.C) $< -o $@ -S
1377 # make the C and C++ compilers strip debug info out of bytecode libraries.
1379 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1380 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1381 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1383 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1384 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1385 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1389 #---------------------------------------------------------
1390 # Provide rule to build .bc files from .ll sources,
1391 # regardless of dependencies
1392 #---------------------------------------------------------
1393 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1394 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1395 $(Verb) $(LLVMAS) $< -f -o $@
1397 ###############################################################################
1398 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
1399 ###############################################################################
1402 TABLEGEN_INC_FILES_COMMON = 1
1405 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1406 TABLEGEN_INC_FILES_COMMON = 1
1409 ifdef TABLEGEN_INC_FILES_COMMON
1411 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1412 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1413 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
1415 # INCFiles rule: All of the tblgen generated files are emitted to
1416 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1417 # us to only "touch" the real file if the contents of it change. IOW, if
1418 # tblgen is modified, all of the .inc.tmp files are regenerated, but no
1419 # dependencies of the .inc files are, unless the contents of the .inc file
1421 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1422 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1424 endif # TABLEGEN_INC_FILES_COMMON
1428 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1429 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1430 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1431 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1432 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1433 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1434 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1436 # All of these files depend on tblgen and the .td files.
1437 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1439 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1440 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1441 $(Echo) "Building $(<F) register names with tblgen"
1442 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
1444 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1445 $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1446 $(Echo) "Building $(<F) register information header with tblgen"
1447 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
1449 $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1450 $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1451 $(Echo) "Building $(<F) register info implementation with tblgen"
1452 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
1454 $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1455 $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1456 $(Echo) "Building $(<F) instruction names with tblgen"
1457 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
1459 $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1460 $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1461 $(Echo) "Building $(<F) instruction information with tblgen"
1462 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
1464 $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1465 $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1466 $(Echo) "Building $(<F) assembly writer with tblgen"
1467 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1469 $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1470 $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1471 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1472 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1474 $(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1475 $(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1476 $(Echo) "Building $(<F) assembly matcher with tblgen"
1477 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1479 $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1480 $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1481 $(Echo) "Building $(<F) code emitter with tblgen"
1482 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1484 $(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1485 $(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1486 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1487 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1489 $(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1490 $(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1491 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1492 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1494 $(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1495 $(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1496 $(Echo) "Building $(<F) subtarget information with tblgen"
1497 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1499 $(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1500 $(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1501 $(Echo) "Building $(<F) calling convention information with tblgen"
1502 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1504 $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1505 $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1506 $(Echo) "Building $(<F) calling convention information with tblgen"
1507 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1510 -$(Verb) $(RM) -f $(INCFiles)
1514 ifdef LLVMC_BUILD_AUTOGENERATED_INC
1516 LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1517 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
1519 TDFiles := $(LLVMCPluginSrc) \
1520 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1522 $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1523 $(TBLGEN) $(TD_COMMON)
1524 $(Echo) "Building LLVMC configuration library with tblgen"
1525 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1527 endif # LLVMC_BUILD_AUTOGENERATED_INC
1529 ###############################################################################
1530 # OTHER RULES: Other rules needed
1531 ###############################################################################
1533 # To create postscript files from dot files...
1534 ifneq ($(DOT),false)
1536 $(DOT) -Tps < $< > $@
1539 $(Echo) "Cannot build $@: The program dot is not installed"
1542 # This rules ensures that header files that are removed still have a rule for
1543 # which they can be "generated." This allows make to ignore them and
1544 # reproduce the dependency lists.
1548 # Define clean-local to clean the current directory. Note that this uses a
1549 # very conservative approach ensuring that empty variables do not cause
1550 # errors or disastrous removal.
1552 ifneq ($(strip $(ObjRootDir)),)
1553 -$(Verb) $(RM) -rf $(ObjRootDir)
1555 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1556 ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1557 -$(Verb) $(RM) -f *$(SHLIBEXT)
1561 -$(Verb) $(RM) -rf Debug Release Profile
1564 ###############################################################################
1565 # DEPENDENCIES: Include the dependency files if we should
1566 ###############################################################################
1567 ifndef DISABLE_AUTO_DEPENDENCIES
1569 # If its not one of the cleaning targets
1570 ifndef IS_CLEANING_TARGET
1572 # Get the list of dependency files
1573 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1574 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1576 # Include bitcode dependency files if using bitcode libraries
1577 ifdef BYTECODE_LIBRARY
1578 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1581 -include $(DependFiles) ""
1587 ###############################################################################
1588 # CHECK: Running the test suite
1589 ###############################################################################
1592 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1593 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1594 $(EchoCmd) Running test suite ; \
1595 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1596 TESTSUITE=$(TESTSUITE) ; \
1598 $(EchoCmd) No Makefile in test directory ; \
1601 $(EchoCmd) No test directory ; \
1605 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1606 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1607 $(EchoCmd) Running test suite ; \
1608 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1610 $(EchoCmd) No Makefile in test directory ; \
1613 $(EchoCmd) No test directory ; \
1616 ###############################################################################
1617 # UNITTESTS: Running the unittests test suite
1618 ###############################################################################
1621 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1622 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1623 $(EchoCmd) Running unittests test suite ; \
1624 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1626 $(EchoCmd) No Makefile in unittests directory ; \
1629 $(EchoCmd) No unittests directory ; \
1632 ###############################################################################
1633 # DISTRIBUTION: Handle construction of a distribution tarball
1634 ###############################################################################
1636 #------------------------------------------------------------------------
1637 # Define distribution related variables
1638 #------------------------------------------------------------------------
1639 DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1640 DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1641 TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1642 DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1643 DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1644 DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1645 DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1646 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1647 Makefile.config.in configure autoconf
1648 DistOther := $(notdir $(wildcard \
1649 $(PROJ_SRC_DIR)/*.h \
1650 $(PROJ_SRC_DIR)/*.td \
1651 $(PROJ_SRC_DIR)/*.def \
1652 $(PROJ_SRC_DIR)/*.ll \
1653 $(PROJ_SRC_DIR)/*.in))
1654 DistSubDirs := $(SubDirs)
1655 DistSources = $(Sources) $(EXTRA_DIST)
1656 DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1658 #------------------------------------------------------------------------
1659 # We MUST build distribution with OBJ_DIR != SRC_DIR
1660 #------------------------------------------------------------------------
1661 ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1662 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1663 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1667 #------------------------------------------------------------------------
1668 # Prevent attempt to run dist targets from anywhere but the top level
1669 #------------------------------------------------------------------------
1671 dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1672 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1675 #------------------------------------------------------------------------
1676 # Provide the top level targets
1677 #------------------------------------------------------------------------
1679 dist-gzip:: $(DistTarGZip)
1681 $(DistTarGZip) : $(TopDistDir)/.makedistdir
1682 $(Echo) Packing gzipped distribution tar file.
1683 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1684 $(GZIP) -c > "$(DistTarGZip)"
1686 dist-bzip2:: $(DistTarBZ2)
1688 $(DistTarBZ2) : $(TopDistDir)/.makedistdir
1689 $(Echo) Packing bzipped distribution tar file.
1690 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1691 $(BZIP2) -c >$(DistTarBZ2)
1693 dist-zip:: $(DistZip)
1695 $(DistZip) : $(TopDistDir)/.makedistdir
1696 $(Echo) Packing zipped distribution file.
1697 $(Verb) rm -f $(DistZip)
1698 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1700 dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1701 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1703 DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1705 dist-check:: $(DistTarGZip)
1706 $(Echo) Checking distribution tar file.
1707 $(Verb) if test -d $(DistCheckDir) ; then \
1708 $(RM) -rf $(DistCheckDir) ; \
1710 $(Verb) $(MKDIR) $(DistCheckDir)
1711 $(Verb) cd $(DistCheckDir) && \
1712 $(MKDIR) $(DistCheckDir)/build && \
1713 $(MKDIR) $(DistCheckDir)/install && \
1714 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1716 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1717 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1720 $(MAKE) unittests && \
1721 $(MAKE) install && \
1722 $(MAKE) uninstall && \
1723 $(MAKE) dist-clean && \
1724 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1727 $(Echo) Cleaning distribution files
1728 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1733 #------------------------------------------------------------------------
1734 # Provide the recursive distdir target for building the distribution directory
1735 #------------------------------------------------------------------------
1736 distdir: $(DistDir)/.makedistdir
1737 $(DistDir)/.makedistdir: $(DistSources)
1738 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1739 if test -d "$(DistDir)" ; then \
1740 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1743 $(EchoCmd) Removing old $(DistDir) ; \
1744 $(RM) -rf $(DistDir); \
1745 $(EchoCmd) Making 'all' to verify build ; \
1746 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1748 $(Echo) Building Distribution Directory $(DistDir)
1749 $(Verb) $(MKDIR) $(DistDir)
1750 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1751 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1752 for file in $(DistFiles) ; do \
1754 $(PROJ_SRC_DIR)/*) \
1755 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1757 $(PROJ_SRC_ROOT)/*) \
1758 file=`echo "$$file" | \
1759 sed "s#^$$srcrootstrip/##"` \
1762 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1763 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1764 from_dir="$(PROJ_SRC_DIR)" ; \
1765 elif test -f "$$file" || test -d "$$file" ; then \
1768 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1769 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1770 to_dir="$(DistDir)/$$dir"; \
1771 $(MKDIR) "$$to_dir" ; \
1773 to_dir="$(DistDir)"; \
1775 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1776 if test -n "$$mid_dir" ; then \
1777 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1779 if test -d "$$from_dir/$$file"; then \
1780 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1781 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1782 cd $(PROJ_SRC_DIR) ; \
1783 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1784 ( cd $$to_dir ; $(TAR) xf - ) ; \
1785 cd $(PROJ_OBJ_DIR) ; \
1788 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1789 ( cd $$to_dir ; $(TAR) xf - ) ; \
1790 cd $(PROJ_OBJ_DIR) ; \
1792 elif test -f "$$from_dir/$$file" ; then \
1793 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1794 elif test -L "$$from_dir/$$file" ; then \
1795 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1796 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1797 $(EchoCmd) "===== WARNING: Distribution Source " \
1798 "$$from_dir/$$file Not Found!" ; \
1799 elif test "$(Verb)" != '@' ; then \
1800 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1803 $(Verb) for subdir in $(DistSubDirs) ; do \
1804 if test "$$subdir" \!= "." ; then \
1805 new_distdir="$(DistDir)/$$subdir" ; \
1806 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1807 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1808 DistDir="$$new_distdir" distdir ) || exit 1; \
1811 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1812 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1813 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1814 -name .svn \) -print` ;\
1815 $(MAKE) dist-hook ; \
1816 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1817 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1818 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1819 -o ! -type d ! -perm -444 -exec \
1820 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1821 || chmod -R a+r $(DistDir) ; \
1824 # This is invoked by distdir target, define it as a no-op to avoid errors if not
1830 ###############################################################################
1831 # TOP LEVEL - targets only to apply at the top level directory
1832 ###############################################################################
1836 #------------------------------------------------------------------------
1837 # Install support for the project's include files:
1838 #------------------------------------------------------------------------
1841 $(Echo) Install circumvented with NO_INSTALL
1843 $(Echo) Uninstall circumvented with NO_INSTALL
1846 $(Echo) Installing include files
1847 $(Verb) $(MKDIR) $(PROJ_includedir)
1848 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1849 cd $(PROJ_SRC_ROOT)/include && \
1850 for hdr in `find . -type f '!' '(' -name '*~' \
1851 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1852 grep -v .svn` ; do \
1853 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1854 if test \! -d "$$instdir" ; then \
1855 $(EchoCmd) Making install directory $$instdir ; \
1856 $(MKDIR) $$instdir ;\
1858 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1861 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1862 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1863 cd $(PROJ_OBJ_ROOT)/include && \
1864 for hdr in `find . -type f -print | grep -v CVS` ; do \
1865 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1871 $(Echo) Uninstalling include files
1872 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1873 cd $(PROJ_SRC_ROOT)/include && \
1874 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1875 '!' '(' -name '*~' -o -name '.#*' \
1876 -o -name '*.in' ')' -print ')' | \
1877 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1878 cd $(PROJ_SRC_ROOT)/include && \
1879 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1880 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1886 @echo searching for overlength lines in files: $(Sources)
1889 egrep -n '.{81}' $(Sources) /dev/null
1892 @echo searching for tabs in files: $(Sources)
1895 egrep -n ' ' $(Sources) /dev/null
1898 @ls -l $(LibDir) | awk '\
1899 BEGIN { sum = 0; } \
1901 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1902 @ls -l $(ToolDir) | awk '\
1903 BEGIN { sum = 0; } \
1905 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1906 #------------------------------------------------------------------------
1907 # Print out the directories used for building
1908 #------------------------------------------------------------------------
1910 $(Echo) "BuildMode : " '$(BuildMode)'
1911 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1912 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1913 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1914 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1915 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1916 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1917 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1918 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1919 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1920 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1921 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1922 $(Echo) "UserTargets : " '$(UserTargets)'
1923 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1924 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1925 $(Echo) "ObjDir : " '$(ObjDir)'
1926 $(Echo) "LibDir : " '$(LibDir)'
1927 $(Echo) "ToolDir : " '$(ToolDir)'
1928 $(Echo) "ExmplDir : " '$(ExmplDir)'
1929 $(Echo) "Sources : " '$(Sources)'
1930 $(Echo) "TDFiles : " '$(TDFiles)'
1931 $(Echo) "INCFiles : " '$(INCFiles)'
1932 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1933 $(Echo) "PreConditions: " '$(PreConditions)'
1934 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1935 $(Echo) "Compile.C : " '$(Compile.C)'
1936 $(Echo) "Archive : " '$(Archive)'
1937 $(Echo) "YaccFiles : " '$(YaccFiles)'
1938 $(Echo) "LexFiles : " '$(LexFiles)'
1939 $(Echo) "Module : " '$(Module)'
1940 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1941 $(Echo) "SubDirs : " '$(SubDirs)'
1942 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1943 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
1948 # General debugging rule, use 'make dbg-print-XXX' to print the
1949 # definition, value and origin of XXX.
1951 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))