source: parabix-LLVM/llvm_git/Makefile.rules @ 5672

Last change on this file since 5672 was 4078, checked in by linmengl, 5 years ago

checkin llvm-meng source

File size: 71.6 KB
Line 
1#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
3#                     The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8#===------------------------------------------------------------------------===#
9#
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.
12#
13#===-----------------------------------------------------------------------====#
14
15################################################################################
16# TARGETS: Define standard targets that can be invoked
17################################################################################
18
19#--------------------------------------------------------------------
20# Define the various target sets
21#--------------------------------------------------------------------
22RecursiveTargets := all clean clean-all install uninstall install-bytecode \
23                    unitcheck
24LocalTargets     := all-local clean-local clean-all-local check-local \
25                    install-local printvars uninstall-local \
26                    install-bytecode-local
27TopLevelTargets  := check dist dist-check dist-clean dist-gzip dist-bzip2 \
28                    dist-zip unittests
29UserTargets      := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30InternalTargets  := preconditions distdir dist-hook
31
32################################################################################
33# INITIALIZATION: Basic things the makefile needs
34################################################################################
35
36#--------------------------------------------------------------------
37# Set the VPATH so that we can find source files.
38#--------------------------------------------------------------------
39VPATH=$(PROJ_SRC_DIR)
40
41#--------------------------------------------------------------------
42# Reset the list of suffixes we know how to build.
43#--------------------------------------------------------------------
44.SUFFIXES:
45.SUFFIXES: .c .cpp .cc .h .hpp .o .a .td .ps .dot .m .mm
46.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47
48#--------------------------------------------------------------------
49# Mark all of these targets as phony to avoid implicit rule search
50#--------------------------------------------------------------------
51.PHONY: $(UserTargets) $(InternalTargets)
52
53#--------------------------------------------------------------------
54# Make sure all the user-target rules are double colon rules and
55# they are defined first.
56#--------------------------------------------------------------------
57
58$(UserTargets)::
59
60#------------------------------------------------------------------------
61# LLVMBuild Integration
62#------------------------------------------------------------------------
63#
64# We use llvm-build to generate all the data required by the Makefile based
65# build system in one swoop:
66#
67#  - We generate a file (a Makefile fragment) in the object root which contains
68#    all the definitions that are required by Makefiles across the entire
69#    project.
70#
71#  - We generate the library table used by llvm-config.
72#
73#  - We generate the dependencies for the Makefile fragment, so that we will
74#    automatically reconfigure outselves.
75
76# The path to the llvm-build tool itself.
77LLVMBuildTool   := $(PROJ_SRC_ROOT)/utils/llvm-build/llvm-build
78
79# The files we are going to generate using llvm-build.
80LLVMBuildMakeFrag := $(PROJ_OBJ_ROOT)/Makefile.llvmbuild
81LLVMBuildCMakeFrag := $(PROJ_OBJ_ROOT)/LLVMBuild.cmake
82LLVMBuildCMakeExportsFrag := $(PROJ_OBJ_ROOT)/cmake/modules/LLVMBuildExports.cmake
83LLVMBuildMakeFrags := \
84        $(LLVMBuildMakeFrag) \
85        $(LLVMBuildCMakeFrag) \
86        $(LLVMBuildCMakeExportsFrag)
87LLVMConfigLibraryDependenciesInc := \
88        $(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc
89
90# This is for temporary backwards compatibility.
91ifndef TARGET_NATIVE_ARCH
92TARGET_NATIVE_ARCH := $(ARCH)
93endif
94
95# The rule to create the LLVMBuild Makefile fragment as well as the llvm-config
96# library table.
97#
98# Note that this target gets its real dependencies generated for us by
99# llvm-build.
100#
101# We include a dependency on this Makefile to ensure that changes to the
102# generation command get picked up.
103$(LLVMBuildMakeFrags): $(PROJ_SRC_ROOT)/Makefile.rules \
104                       $(PROJ_OBJ_ROOT)/Makefile.config
105        $(Echo) Constructing LLVMBuild project information.
106        $(Verb)$(PYTHON) $(LLVMBuildTool) \
107          --native-target "$(TARGET_NATIVE_ARCH)" \
108          --enable-targets "$(TARGETS_TO_BUILD)" \
109          --enable-optional-components "$(OPTIONAL_COMPONENTS)" \
110          --write-library-table $(LLVMConfigLibraryDependenciesInc) \
111          --write-make-fragment $(LLVMBuildMakeFrag) \
112          --write-cmake-fragment $(LLVMBuildCMakeFrag) \
113          --write-cmake-exports-fragment $(LLVMBuildCMakeExportsFrag)
114
115# For completeness, let Make know how the extra files are generated.
116$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrags)
117
118# Include the generated Makefile fragment.
119#
120# We currently only include the dependencies for the fragment itself if we are
121# at the top-level. Otherwise, recursive invocations would ends up doing
122# substantially more redundant stat'ing.
123#
124# This means that we won't properly regenerate things for developers used to
125# building from a subdirectory, but that is always somewhat unreliable.
126ifeq ($(LEVEL),.)
127LLVMBUILD_INCLUDE_DEPENDENCIES := 1
128
129# Clean the generated makefile fragment at the top-level.
130clean-local::
131        -$(Verb) $(RM) -f $(LLVMBuildMakeFrags)
132endif
133-include $(LLVMBuildMakeFrag)
134
135################################################################################
136# PRECONDITIONS: that which must be built/checked first
137################################################################################
138
139SrcMakefiles       := $(filter %Makefile %Makefile.tests,\
140                      $(wildcard $(PROJ_SRC_DIR)/Makefile*))
141ObjMakefiles       := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
142ConfigureScript    := $(PROJ_SRC_ROOT)/configure
143ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
144MakefileConfigIn   := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
145MakefileCommonIn   := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
146MakefileConfig     := $(PROJ_OBJ_ROOT)/Makefile.config
147MakefileCommon     := $(PROJ_OBJ_ROOT)/Makefile.common
148PreConditions      := $(ConfigStatusScript) $(ObjMakefiles)
149ifneq ($(MakefileCommonIn),)
150PreConditions      += $(MakefileCommon)
151endif
152
153ifneq ($(MakefileConfigIn),)
154PreConditions      += $(MakefileConfig)
155endif
156
157preconditions: $(PreConditions)
158
159#------------------------------------------------------------------------
160# Make sure the BUILT_SOURCES are built first
161#------------------------------------------------------------------------
162$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
163
164clean-all-local::
165ifneq ($(strip $(BUILT_SOURCES)),)
166        -$(Verb) $(RM) -f $(BUILT_SOURCES)
167endif
168
169ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
170spotless:
171        $(Verb) if test -x config.status ; then \
172          $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
173          $(MKDIR) .spotless.save ; \
174          $(MV) config.status .spotless.save ; \
175          $(MV) mklib  .spotless.save ; \
176          $(MV) projects  .spotless.save ; \
177          $(RM) -rf * ; \
178          $(MV) .spotless.save/config.status . ; \
179          $(MV) .spotless.save/mklib . ; \
180          $(MV) .spotless.save/projects . ; \
181          $(RM) -rf .spotless.save ; \
182          $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
183          $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
184          $(ConfigStatusScript) ; \
185        else \
186          $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
187        fi
188else
189spotless:
190        $(EchoCmd) "spotless target not supported for objdir == srcdir"
191endif
192
193$(BUILT_SOURCES) : $(ObjMakefiles)
194
195#------------------------------------------------------------------------
196# Make sure we're not using a stale configuration
197#------------------------------------------------------------------------
198reconfigure:
199        $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
200        $(Verb) cd $(PROJ_OBJ_ROOT) && \
201          $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
202          $(ConfigStatusScript)
203
204.PRECIOUS: $(ConfigStatusScript)
205$(ConfigStatusScript): $(ConfigureScript)
206        $(Echo) Reconfiguring with $<
207        $(Verb) cd $(PROJ_OBJ_ROOT) && \
208          $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
209          $(ConfigStatusScript)
210
211#------------------------------------------------------------------------
212# Make sure the configuration makefile is up to date
213#------------------------------------------------------------------------
214ifneq ($(MakefileConfigIn),)
215$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
216        $(Echo) Regenerating $@
217        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
218endif
219
220ifneq ($(MakefileCommonIn),)
221$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
222        $(Echo) Regenerating $@
223        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
224endif
225
226#------------------------------------------------------------------------
227# If the Makefile in the source tree has been updated, copy it over into the
228# build tree. But, only do this if the source and object makefiles differ
229#------------------------------------------------------------------------
230ifndef PROJ_MAKEFILE
231PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
232endif
233
234ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
235
236Makefile: $(PROJ_MAKEFILE) $(ExtraMakefiles)
237        $(Echo) "Updating Makefile"
238        $(Verb) $(MKDIR) $(@D)
239        $(Verb) $(CP) -f $< $@
240
241# Copy the Makefile.* files unless we're in the root directory which avoids
242# the copying of Makefile.config.in or other things that should be explicitly
243# taken care of.
244$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
245        @case '$?' in \
246          *Makefile.rules) ;; \
247          *.in) ;; \
248          *) $(EchoCmd) "Updating $(@F)" ; \
249             $(MKDIR) $(@D) ; \
250             $(CP) -f $< $@ ;; \
251        esac
252
253endif
254
255#------------------------------------------------------------------------
256# Set up the basic dependencies
257#------------------------------------------------------------------------
258$(UserTargets):: $(PreConditions)
259
260all:: all-local
261clean:: clean-local
262clean-all:: clean-local clean-all-local
263install:: install-local
264uninstall:: uninstall-local
265install-local:: all-local
266install-bytecode:: install-bytecode-local
267
268###############################################################################
269# VARIABLES: Set up various variables based on configuration data
270###############################################################################
271
272# Variable for if this make is for a "cleaning" target
273ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
274  IS_CLEANING_TARGET=1
275endif
276
277#--------------------------------------------------------------------
278# Variables derived from configuration we are building
279#--------------------------------------------------------------------
280
281CPP.Defines :=
282ifeq ($(ENABLE_OPTIMIZED),1)
283  BuildMode := Release
284  # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
285  ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
286    OmitFramePointer := -fomit-frame-pointer
287  endif
288
289  CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
290  C.Flags   += $(OPTIMIZE_OPTION) $(OmitFramePointer)
291  LD.Flags  += $(OPTIMIZE_OPTION)
292  ifdef DEBUG_SYMBOLS
293    BuildMode := $(BuildMode)+Debug
294    CXX.Flags += -g
295    C.Flags   += -g
296    KEEP_SYMBOLS := 1
297  endif
298else
299  ifdef NO_DEBUG_SYMBOLS
300    BuildMode := Unoptimized
301    CXX.Flags +=
302    C.Flags   +=
303    KEEP_SYMBOLS := 1
304  else
305    BuildMode := Debug
306    ifeq ($(ENABLE_SPLIT_DWARF), 1)
307    CXX.Flags += -gsplit-dwarf
308    C.Flags   += -gsplit-dwarf
309    else
310    CXX.Flags += -g
311    C.Flags   += -g
312    endif
313    KEEP_SYMBOLS := 1
314  endif
315endif
316
317ifeq ($(ENABLE_LIBCPP),1)
318  CXX.Flags +=  -stdlib=libc++
319  LD.Flags +=  -stdlib=libc++
320endif
321
322ifeq ($(ENABLE_CXX1Y),1)
323  CXX.Flags += -std=c++1y
324else
325  ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
326    # MinGW and Cygwin are a bit stricter and lack things like
327    # 'strdup', 'stricmp', etc in c++11 mode.
328    CXX.Flags += -std=gnu++11
329 else
330    CXX.Flags += -std=c++11
331 endif
332endif
333
334ifeq ($(ENABLE_WERROR),1)
335  CXX.Flags += -Werror
336  C.Flags += -Werror
337endif
338
339ifeq ($(ENABLE_PROFILING),1)
340  BuildMode := $(BuildMode)+Profile
341  CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
342  C.Flags   := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
343  LD.Flags  := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg
344  KEEP_SYMBOLS := 1
345endif
346
347ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
348    CXX.Flags += -fvisibility-inlines-hidden
349endif
350
351ifdef ENABLE_EXPENSIVE_CHECKS
352  # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
353  # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
354  REQUIRES_RTTI := 1
355endif
356
357# IF REQUIRES_EH=1 is specified then don't disable exceptions
358ifndef REQUIRES_EH
359  CXX.Flags += -fno-exceptions
360else
361  # If the library requires EH, it also requires RTTI.
362  REQUIRES_RTTI := 1
363endif
364
365ifdef REQUIRES_FRAME_POINTER
366  CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
367  C.Flags   := $(filter-out -fomit-frame-pointer,$(C.Flags))
368  LD.Flags  := $(filter-out -fomit-frame-pointer,$(LD.Flags))
369endif
370
371# If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
372ifneq ($(REQUIRES_RTTI), 1)
373  CXX.Flags += -fno-rtti
374endif
375
376ifeq ($(ENABLE_COVERAGE),1)
377  BuildMode := $(BuildMode)+Coverage
378  CXX.Flags += -ftest-coverage -fprofile-arcs
379  C.Flags   += -ftest-coverage -fprofile-arcs
380endif
381
382# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
383# then disable assertions by defining the appropriate preprocessor symbols.
384ifeq ($(DISABLE_ASSERTIONS),1)
385  CPP.Defines += -DNDEBUG
386else
387  BuildMode := $(BuildMode)+Asserts
388  CPP.Defines += -D_DEBUG
389endif
390
391# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
392# configured), then enable expensive checks by defining the
393# appropriate preprocessor symbols.
394ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
395  BuildMode := $(BuildMode)+Checks
396  CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
397endif
398
399# LOADABLE_MODULE implies several other things so we force them to be
400# defined/on.
401ifdef LOADABLE_MODULE
402  SHARED_LIBRARY := 1
403  LINK_LIBS_IN_SHARED := 1
404endif
405
406ifdef SHARED_LIBRARY
407  ENABLE_PIC := 1
408  PIC_FLAG = "(PIC)"
409endif
410
411ifeq ($(ENABLE_PIC),1)
412  ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
413    # Nothing. Win32 defaults to PIC and warns when given -fPIC
414  else
415    ifeq ($(HOST_OS),Darwin)
416      # Common symbols not allowed in dylib files
417      CXX.Flags += -fno-common
418      C.Flags   += -fno-common
419    else
420      # Linux and others; pass -fPIC
421      CXX.Flags += -fPIC
422      C.Flags   += -fPIC
423    endif
424  endif
425else
426  ifeq ($(HOST_OS),Darwin)
427      CXX.Flags += -mdynamic-no-pic
428      C.Flags   += -mdynamic-no-pic
429  endif
430endif
431
432# Support makefile variable to disable any kind of timestamp/non-deterministic
433# info from being used in the build.
434ifeq ($(ENABLE_TIMESTAMPS),1)
435  DOTDIR_TIMESTAMP_COMMAND := $(DATE)
436else
437  DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
438endif
439
440ifeq ($(HOST_OS),MingW)
441  # Work around PR4957
442  CPP.Defines += -D__NO_CTYPE_INLINE
443  ifeq ($(LLVM_CROSS_COMPILING),1)
444    # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
445    ifdef TOOLNAME
446      LD.Flags += -Wl,--allow-multiple-definition
447    endif
448  endif
449endif
450
451CXX.Flags     += -Woverloaded-virtual
452CPP.BaseFlags += $(CPP.Defines)
453AR.Flags      := cru
454
455# Make Floating point IEEE compliant on Alpha.
456ifeq ($(ARCH),Alpha)
457  CXX.Flags     += -mieee
458  CPP.BaseFlags += -mieee
459ifeq ($(ENABLE_PIC),0)
460  CXX.Flags     += -fPIC
461  CPP.BaseFlags += -fPIC
462endif
463
464  LD.Flags += -Wl,--no-relax
465endif
466
467# GNU ld/PECOFF accepts but ignores them below;
468#   --version-script
469#   --export-dynamic
470#   --rpath
471# FIXME: autoconf should be aware of them.
472ifneq (,$(filter $(HOST_OS),Cygwin MingW))
473  HAVE_LINK_VERSION_SCRIPT := 0
474  RPATH :=
475  RDYNAMIC := -Wl,--export-all-symbols
476endif
477
478#--------------------------------------------------------------------
479# Directory locations
480#--------------------------------------------------------------------
481TargetMode :=
482ifeq ($(LLVM_CROSS_COMPILING),1)
483  BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
484endif
485
486ObjRootDir  := $(PROJ_OBJ_DIR)/$(BuildMode)
487ObjDir      := $(ObjRootDir)
488LibDir      := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
489ToolDir     := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
490ExmplDir    := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
491LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
492LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
493LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
494
495#--------------------------------------------------------------------
496# Locations of shared libraries
497#--------------------------------------------------------------------
498
499SharedPrefix     := lib
500SharedLibDir     := $(LibDir)
501LLVMSharedLibDir := $(LLVMLibDir)
502
503# Win32.DLL prefers to be located on the "PATH" of binaries.
504ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
505  SharedLibDir     := $(ToolDir)
506  LLVMSharedLibDir := $(LLVMToolDir)
507
508  ifeq ($(HOST_OS),Cygwin)
509    SharedPrefix  := cyg
510  else
511    SharedPrefix  :=
512  endif
513endif
514
515#--------------------------------------------------------------------
516# Full Paths To Compiled Tools and Utilities
517#--------------------------------------------------------------------
518EchoCmd  := $(ECHO) llvm[$(MAKELEVEL)]:
519ifdef BUILD_DIRS_ONLY
520EchoCmd  := $(EchoCmd) "(build tools)":
521endif
522
523Echo     := @$(EchoCmd)
524ifndef LLVMAS
525LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
526endif
527ifndef LLVM_TBLGEN
528  ifeq ($(LLVM_CROSS_COMPILING),1)
529    LLVM_TBLGEN   := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT)
530  else
531    LLVM_TBLGEN   := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
532  endif
533endif
534ifeq ($(LLVM_CROSS_COMPILING),1)
535  LLVM_CONFIG := $(BuildLLVMToolDir)/llvm-config$(BUILD_EXEEXT)
536else
537  LLVM_CONFIG := $(LLVMToolDir)/llvm-config$(EXEEXT)
538endif
539ifndef LLVMDIS
540LLVMDIS  := $(LLVMToolDir)/llvm-dis$(EXEEXT)
541endif
542ifndef LLI
543LLI      := $(LLVMToolDir)/lli$(EXEEXT)
544endif
545ifndef LLC
546LLC      := $(LLVMToolDir)/llc$(EXEEXT)
547endif
548ifndef LOPT
549LOPT     := $(LLVMToolDir)/opt$(EXEEXT)
550endif
551ifndef LBUGPOINT
552LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
553endif
554ifndef LLVMLINK
555LLVMLINK      := $(LLVMToolDir)/llvm-link$(EXEEXT)
556endif
557
558#--------------------------------------------------------------------
559# Adjust to user's request
560#--------------------------------------------------------------------
561
562ifeq ($(HOST_OS),Darwin)
563 ifdef MACOSX_DEPLOYMENT_TARGET
564  DARWIN_VERSION := $(MACOSX_DEPLOYMENT_TARGET)
565 else
566  DARWIN_VERSION := `sw_vers -productVersion`
567 endif
568  # Strip a number like 10.4.7 to 10.4
569  DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/')
570  # Get "4" out of 10.4 for later pieces in the makefile.
571  DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/')
572
573  LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
574  SharedLinkOptions := -dynamiclib
575  ifdef DEPLOYMENT_TARGET
576    SharedLinkOptions += $(DEPLOYMENT_TARGET)
577  else
578    ifneq ($(ARCH),ARM)
579      SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
580    endif
581  endif
582else
583  SharedLinkOptions=-shared
584endif
585
586ifeq ($(TARGET_OS),Darwin)
587  ifdef DEPLOYMENT_TARGET
588    TargetCommonOpts += $(DEPLOYMENT_TARGET)
589  else
590    ifneq ($(ARCH),ARM)
591      TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
592    endif
593  endif
594endif
595
596ifdef SHARED_LIBRARY
597ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
598ifneq ($(HOST_OS),Darwin)
599  LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
600else
601  LD.Flags += -Wl,-install_name  -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
602endif
603endif
604endif
605
606ifdef TOOL_VERBOSE
607  C.Flags += -v
608  CXX.Flags += -v
609  LD.Flags += -v
610  VERBOSE := 1
611endif
612
613# Adjust settings for verbose mode
614ifndef VERBOSE
615  Verb := @
616  AR.Flags += >/dev/null 2>/dev/null
617  ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
618else
619  ConfigureScriptFLAGS :=
620endif
621
622# By default, strip symbol information from executable
623ifndef KEEP_SYMBOLS
624  Strip := $(PLATFORMSTRIPOPTS)
625  StripWarnMsg := "(without symbols)"
626  Install.StripFlag += -s
627endif
628
629# By default, strip dead symbols at link time
630ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
631ifneq ($(HOST_OS),Darwin)
632ifneq ($(HOST_ARCH),Mips)
633  CXX.Flags += -ffunction-sections -fdata-sections
634endif
635endif
636endif
637ifndef NO_DEAD_STRIP
638  ifeq ($(HOST_OS),Darwin)
639    LD.Flags += -Wl,-dead_strip
640  else
641    ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
642      LD.Flags += -Wl,--gc-sections
643    endif
644  endif
645endif
646
647# Adjust linker flags for building an executable
648ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
649  ifndef TOOL_NO_EXPORTS
650    LD.Flags += $(RDYNAMIC)
651  endif
652  ifneq ($(HOST_OS), Darwin)
653    ifdef TOOLNAME
654      LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
655    endif
656  else
657    ifneq ($(DARWIN_MAJVERS),4)
658      LD.Flags += $(RPATH) -Wl,@executable_path/../lib
659    endif
660    ifeq ($(RC_XBS),YES)
661      TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
662      LD.Flags += -Wl,-object_path_lto -Wl,$(TempFile)
663    endif
664  endif
665endif
666
667
668#----------------------------------------------------------
669# Options To Invoke Tools
670#----------------------------------------------------------
671
672ifdef EXTRA_LD_OPTIONS
673LD.Flags += $(EXTRA_LD_OPTIONS)
674endif
675
676ifndef NO_PEDANTIC
677CompileCommonOpts += -pedantic -Wno-long-long
678endif
679CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
680                     $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
681                     $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
682                     $(NO_MISSING_FIELD_INITIALIZERS)
683# Enable cast-qual for C++; the workaround is to use const_cast.
684CXX.Flags += -Wcast-qual
685
686ifeq ($(HOST_OS),HP-UX)
687  CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
688endif
689
690# If we are building a universal binary on Mac OS X, pass extra options.  This
691# is useful to people that want to link the LLVM libraries into their universal
692# apps.
693#
694# The following can be optionally specified:
695#   UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
696#      For Mac OS X 10.4 Intel machines, the traditional one is:
697#      UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
698#   UNIVERSAL_ARCH can be optionally specified to be a list of architectures
699#      to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64".  This defaults to
700#      i386/ppc only.
701ifdef UNIVERSAL
702  ifndef UNIVERSAL_ARCH
703    UNIVERSAL_ARCH := i386 ppc
704  endif
705  UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
706  TargetCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
707  ifdef UNIVERSAL_SDK_PATH
708    TargetCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
709  endif
710
711  # Building universal cannot compute dependencies automatically.
712  DISABLE_AUTO_DEPENDENCIES=1
713else
714  ifeq ($(TARGET_OS),Darwin)
715    ifeq ($(ARCH),x86_64)
716      TargetCommonOpts = -m64
717    else
718      ifeq ($(ARCH),x86)
719        TargetCommonOpts = -m32
720      endif
721    endif
722  endif
723endif
724
725ifeq ($(HOST_OS),SunOS)
726CPP.BaseFlags += -include llvm/Support/Solaris.h
727endif
728
729ifeq ($(HOST_OS),AuroraUX)
730CPP.BaseFlags += -include llvm/Support/Solaris.h
731endif # !HOST_OS - AuroraUX.
732
733# On Windows, SharedLibDir != LibDir. The order is important.
734ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
735  LD.Flags    += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
736else
737  LD.Flags    += -L$(LibDir) -L$(LLVMLibDir)
738endif
739
740CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
741# All -I flags should go here, so that they don't confuse llvm-config.
742CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
743                 $(patsubst %,-I%/include,\
744                 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
745                 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
746                 $(CPP.BaseFlags)
747
748ifeq ($(INCLUDE_BUILD_DIR),1)
749  CPP.Flags   += -I$(ObjDir)
750endif
751
752# SHOW_DIAGNOSTICS support.
753ifeq ($(SHOW_DIAGNOSTICS),1)
754  Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
755                          CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
756else
757  Compile.Wrapper :=
758endif
759
760Compile.C     = $(Compile.Wrapper) \
761                  $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
762                $(TargetCommonOpts) $(CompileCommonOpts) -c
763Compile.CXX   = $(Compile.Wrapper) \
764                  $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
765                $(TargetCommonOpts) $(CompileCommonOpts) -c
766Preprocess.CXX= $(Compile.Wrapper) \
767                  $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
768                $(CompileCommonOpts) $(CXX.Flags) -E
769Link          = $(Compile.Wrapper) \
770                  $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
771                $(TargetCommonOpts) $(Strip)
772
773Preprocess.C  = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
774                $(TargetCommonOpts) $(CompileCommonOpts) -E
775
776ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755
777ScriptInstall = $(INSTALL) -m 0755
778DataInstall   = $(INSTALL) -m 0644
779
780# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
781# paths. In this case, the SYSPATH function (defined in
782# Makefile.config) transforms Unix paths into Windows paths.
783TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
784                -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
785                -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
786                -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
787LLVMTableGen  = $(LLVM_TBLGEN) $(TableGen.Flags)
788
789Archive       = $(AR) $(AR.Flags)
790ifdef RANLIB
791Ranlib        = $(RANLIB)
792else
793Ranlib        = ranlib
794endif
795
796AliasTool     = ln -sf
797
798#----------------------------------------------------------
799# Get the list of source files and compute object file
800# names from them.
801#----------------------------------------------------------
802
803ifndef SOURCES
804  Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
805             $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
806else
807  Sources := $(SOURCES)
808endif
809
810ifdef BUILT_SOURCES
811Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
812endif
813
814BaseNameSources := $(sort $(basename $(Sources)))
815SourceDirs := $(sort $(dir $(Sources)))
816
817ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
818ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
819
820#----------------------------------------------------------
821# For Mingw MSYS bash and Python/w32:
822#
823# $(ECHOPATH) prints DOSish pathstring.
824#   ex) $(ECHOPATH) /include/sys/types.h
825#   --> C:/mingw/include/sys/types.h
826# built-in "echo" does not transform path to DOSish path.
827#
828# FIXME: It would not be needed when MSYS's python
829# were provided.
830#----------------------------------------------------------
831
832ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
833  ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
834else
835  ECHOPATH := $(Verb)$(ECHO)
836endif
837
838###############################################################################
839# DIRECTORIES: Handle recursive descent of directory structure
840###############################################################################
841
842#---------------------------------------------------------
843# Provide rules to make install dirs. This must be early
844# in the file so they get built before dependencies
845#---------------------------------------------------------
846
847$(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
848        $(Verb) $(MKDIR) $@
849
850# To create other directories, as needed, and timestamp their creation
851%/.dir:
852        $(Verb) $(MKDIR) $* > /dev/null
853        $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
854
855.PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
856.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
857
858#---------------------------------------------------------
859# Collect the object directories (as there may be more
860# than one if the source code is spread across
861# subdirectories).
862#---------------------------------------------------------
863
864OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
865.PRECIOUS: $(OBJECT_DIRS)
866
867#---------------------------------------------------------
868# Handle the DIRS options for sequential construction
869#---------------------------------------------------------
870
871SubDirs :=
872ifdef DIRS
873SubDirs += $(DIRS)
874
875ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
876$(RecursiveTargets)::
877        $(Verb) for dir in $(DIRS); do \
878          if ([ ! -f $$dir/Makefile ] || \
879              command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
880            $(MKDIR) $$dir; \
881            $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
882          fi; \
883          ($(MAKE) -C $$dir $@ ) || exit 1; \
884        done
885else
886$(RecursiveTargets)::
887        $(Verb) for dir in $(DIRS); do \
888          ($(MAKE) -C $$dir $@ ) || exit 1; \
889        done
890endif
891
892endif
893
894#---------------------------------------------------------
895# Handle the EXPERIMENTAL_DIRS options ensuring success
896# after each directory is built.
897#---------------------------------------------------------
898ifdef EXPERIMENTAL_DIRS
899$(RecursiveTargets)::
900        $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
901          if ([ ! -f $$dir/Makefile ] || \
902              command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
903            $(MKDIR) $$dir; \
904            $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
905          fi; \
906          ($(MAKE) -C $$dir $@ ) || exit 0; \
907        done
908endif
909
910#-----------------------------------------------------------
911# Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
912#-----------------------------------------------------------
913ifdef OPTIONAL_PARALLEL_DIRS
914  PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
915endif
916
917#-----------------------------------------------------------
918# Handle the PARALLEL_DIRS options for parallel construction
919#-----------------------------------------------------------
920ifdef PARALLEL_DIRS
921
922SubDirs += $(PARALLEL_DIRS)
923
924# Unfortunately, this list must be maintained if new recursive targets are added
925all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
926clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
927clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
928install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
929uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
930install-bytecode  :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
931unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
932
933ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
934
935$(ParallelTargets) :
936        $(Verb) \
937          SD=$(PROJ_SRC_DIR)/$(@D); \
938          DD=$(@D); \
939          if [ ! -f $$SD/Makefile ]; then \
940            SD=$(@D); \
941            DD=$(notdir $(@D)); \
942          fi; \
943          if ([ ! -f $$DD/Makefile ] || \
944                    command test $$DD/Makefile -ot \
945                      $$SD/Makefile ); then \
946          $(MKDIR) $$DD; \
947          $(CP) $$SD/Makefile $$DD/Makefile; \
948        fi; \
949        $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
950endif
951
952#---------------------------------------------------------
953# Handle the OPTIONAL_DIRS options for directores that may
954# or may not exist.
955#---------------------------------------------------------
956ifdef OPTIONAL_DIRS
957
958SubDirs += $(OPTIONAL_DIRS)
959
960ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
961$(RecursiveTargets)::
962        $(Verb) for dir in $(OPTIONAL_DIRS); do \
963          if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
964            if ([ ! -f $$dir/Makefile ] || \
965                command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
966              $(MKDIR) $$dir; \
967              $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
968            fi; \
969            ($(MAKE) -C$$dir $@ ) || exit 1; \
970          fi \
971        done
972else
973$(RecursiveTargets)::
974        $(Verb) for dir in $(OPTIONAL_DIRS); do \
975          if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
976            ($(MAKE) -C$$dir $@ ) || exit 1; \
977          fi \
978        done
979endif
980endif
981
982#---------------------------------------------------------
983# Handle the CONFIG_FILES options
984#---------------------------------------------------------
985ifdef CONFIG_FILES
986
987ifdef NO_INSTALL
988install-local::
989        $(Echo) Install circumvented with NO_INSTALL
990uninstall-local::
991        $(Echo) UnInstall circumvented with NO_INSTALL
992else
993install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
994        $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
995        $(Verb)for file in $(CONFIG_FILES); do \
996          if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
997            $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
998          elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
999            $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
1000          else \
1001            $(ECHO) Error: cannot find config file $${file}. ; \
1002          fi \
1003        done
1004
1005uninstall-local::
1006        $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
1007        $(Verb)for file in $(CONFIG_FILES); do \
1008          $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
1009        done
1010endif
1011
1012endif
1013
1014###############################################################################
1015# Set up variables for building libraries
1016###############################################################################
1017
1018#---------------------------------------------------------
1019# Define various command line options pertaining to the
1020# libraries needed when linking. There are "Proj" libs
1021# (defined by the user's project) and "LLVM" libs (defined
1022# by the LLVM project).
1023#---------------------------------------------------------
1024
1025ifdef USEDLIBS
1026ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1027ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
1028ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1029ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1030endif
1031
1032ifdef LLVMLIBS
1033LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1034LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1035LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1036LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1037endif
1038
1039# Loadable module for Win32 requires all symbols resolved for linking.
1040# Then all symbols in LLVM.dll will be available.
1041ifeq ($(ENABLE_SHARED),1)
1042  ifdef LOADABLE_MODULE
1043    ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1044      LINK_COMPONENTS += all
1045    endif
1046  endif
1047endif
1048
1049ifndef IS_CLEANING_TARGET
1050ifdef LINK_COMPONENTS
1051
1052# If LLVM_CONFIG doesn't exist, build it.  This can happen if you do a make
1053# clean in tools, then do a make in tools (instead of at the top level).
1054$(LLVM_CONFIG):
1055        @echo "*** llvm-config doesn't exist - rebuilding it."
1056        @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1057
1058$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1059
1060ifeq ($(ENABLE_SHARED), 1)
1061# We can take the "auto-import" feature to get rid of using dllimport.
1062ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1063LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1064                   -L $(SharedLibDir)
1065endif
1066LLVM_SO_NAME = LLVM-$(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)$(LLVM_VERSION_SUFFIX)
1067LLVMLibsOptions += -l$(LLVM_SO_NAME)
1068LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)$(LLVM_SO_NAME)$(SHLIBEXT)
1069else
1070
1071ifndef NO_LLVM_CONFIG
1072LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1073ifeq ($(LLVMConfigLibs),Error)
1074$(error llvm-config --libs failed)
1075endif
1076LLVMLibsOptions += $(LLVMConfigLibs)
1077LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1078ifeq ($(LLVMConfigLibfiles),Error)
1079$(error llvm-config --libfiles failed)
1080endif
1081LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1082endif
1083
1084endif
1085endif
1086endif
1087
1088# Set up the library exports file.
1089ifdef EXPORTED_SYMBOL_FILE
1090
1091# First, set up the native export file, which may differ from the source
1092# export file.
1093
1094ifeq ($(HOST_OS),Darwin)
1095# Darwin convention prefixes symbols with underscores.
1096NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1097$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1098        $(Verb) sed -e 's/^/_/' < $< > $@
1099clean-local::
1100        -$(Verb) $(RM) -f $(NativeExportsFile)
1101else
1102ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1103# Gold and BFD ld require a version script rather than a plain list.
1104NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1105$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1106        $(Verb) echo "{" > $@
1107        $(Verb) grep -q '[[:alnum:]_]' $< && echo "  global:" >> $@ || :
1108        $(Verb) sed -e 's/$$/;/' -e 's/^/    /' < $< >> $@
1109ifneq ($(HOST_OS),OpenBSD)
1110        $(Verb) echo "  local: *;" >> $@
1111endif
1112        $(Verb) echo "};" >> $@
1113clean-local::
1114        -$(Verb) $(RM) -f $(NativeExportsFile)
1115else
1116ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1117# GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1118NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1119$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1120        $(Echo) Generating $(notdir $@)
1121        $(Verb) $(ECHO) "EXPORTS" > $@
1122        $(Verb) $(CAT) $< >> $@
1123clean-local::
1124        -$(Verb) $(RM) -f $(NativeExportsFile)
1125else
1126# Default behavior: just use the exports file verbatim.
1127NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1128endif
1129endif
1130endif
1131
1132# Now add the linker command-line options to use the native export file.
1133
1134# Darwin
1135ifeq ($(HOST_OS),Darwin)
1136LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1137endif
1138
1139# gold, bfd ld, etc.
1140ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1141LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1142endif
1143
1144# Windows
1145ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1146# LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1147SharedLinkOptions += $(NativeExportsFile)
1148endif
1149
1150endif
1151
1152###############################################################################
1153# Library Build Rules: Four ways to build a library
1154###############################################################################
1155
1156# if we're building a library ...
1157ifdef LIBRARYNAME
1158
1159# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1160LIBRARYNAME := $(strip $(LIBRARYNAME))
1161LIBRARYALIASNAME := $(strip $(LIBRARYALIASNAME))
1162ifdef LOADABLE_MODULE
1163BaseLibName.A  := $(LIBRARYNAME).a
1164BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1165BaseAliasName.SO := $(LIBRARYALIASNAME)$(SHLIBEXT)
1166else
1167BaseLibName.A  := lib$(LIBRARYNAME).a
1168BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1169BaseAliasName.SO := $(SharedPrefix)$(LIBRARYALIASNAME)$(SHLIBEXT)
1170endif
1171LibName.A  := $(LibDir)/$(BaseLibName.A)
1172LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1173AliasName.SO := $(SharedLibDir)/$(BaseAliasName.SO)
1174LibName.O  := $(LibDir)/$(LIBRARYNAME).o
1175
1176#---------------------------------------------------------
1177# Shared Library Targets:
1178#   If the user asked for a shared library to be built
1179#   with the SHARED_LIBRARY variable, then we provide
1180#   targets for building them.
1181#---------------------------------------------------------
1182ifdef SHARED_LIBRARY
1183
1184all-local:: $(AliasName.SO)
1185
1186$(AliasName.SO): $(LibName.SO)
1187ifdef SHARED_ALIAS
1188        $(Verb) $(AliasTool) $(BaseLibName.SO) $(AliasName.SO)
1189endif
1190
1191ifdef EXPORTED_SYMBOL_FILE
1192$(LibName.SO): $(NativeExportsFile)
1193endif
1194
1195ifdef LINK_LIBS_IN_SHARED
1196ifdef LOADABLE_MODULE
1197SharedLibKindMessage := "Loadable Module"
1198SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1199else
1200SharedLibKindMessage := "Shared Library"
1201endif
1202$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1203        $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1204          $(notdir $@)
1205        $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1206          $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1207else
1208$(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1209        $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1210        $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1211endif
1212
1213clean-local::
1214ifneq ($(strip $(LibName.SO)),)
1215        -$(Verb) $(RM) -f $(LibName.SO)
1216endif
1217
1218ifdef NO_INSTALL
1219install-local::
1220        $(Echo) Install circumvented with NO_INSTALL
1221uninstall-local::
1222        $(Echo) Uninstall circumvented with NO_INSTALL
1223else
1224
1225# Win32.DLL prefers to be located on the "PATH" of binaries.
1226ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1227DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1228else
1229DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1230endif
1231DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1232DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO)
1233
1234install-local:: $(DestSharedLib)
1235
1236$(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1237        $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1238        $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1239ifdef SHARED_ALIAS
1240        $(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias)
1241        $(Verb) $(AliasTool) $(BaseLibName.SO) $(DestSharedAlias)
1242endif
1243
1244uninstall-local::
1245        $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1246        -$(Verb) $(RM) -f $(DestSharedLib)
1247ifdef SHARED_ALIAS
1248        -$(Verb) $(RM) -f $(DestSharedAlias)
1249endif
1250endif
1251endif
1252
1253#---------------------------------------------------------
1254# Library Targets:
1255#   If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1256#   building an archive.
1257#---------------------------------------------------------
1258ifndef NO_BUILD_ARCHIVE
1259ifndef BUILD_ARCHIVE
1260ifndef LOADABLE_MODULE
1261BUILD_ARCHIVE = 1
1262endif
1263endif
1264endif
1265
1266#---------------------------------------------------------
1267# Archive Library Targets:
1268#   If the user wanted a regular archive library built,
1269#   then we provide targets for building them.
1270#---------------------------------------------------------
1271ifdef BUILD_ARCHIVE
1272
1273all-local:: $(LibName.A)
1274
1275$(LibName.A): $(ObjectsO) $(LibDir)/.dir
1276        $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1277        -$(Verb) $(RM) -f $@
1278        $(Verb) $(Archive) $@ $(ObjectsO)
1279        $(Verb) $(Ranlib) $@
1280
1281clean-local::
1282ifneq ($(strip $(LibName.A)),)
1283        -$(Verb) $(RM) -f $(LibName.A)
1284endif
1285
1286ifdef NO_INSTALL
1287install-local::
1288        $(Echo) Install circumvented with NO_INSTALL
1289uninstall-local::
1290        $(Echo) Uninstall circumvented with NO_INSTALL
1291else
1292ifdef NO_INSTALL_ARCHIVES
1293install-local::
1294        $(Echo) Install circumvented with NO_INSTALL
1295uninstall-local::
1296        $(Echo) Uninstall circumvented with NO_INSTALL
1297else
1298DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1299
1300install-local:: $(DestArchiveLib)
1301
1302$(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1303        $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1304        $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1305        $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1306
1307uninstall-local::
1308        $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1309        -$(Verb) $(RM) -f $(DestArchiveLib)
1310endif
1311endif
1312endif
1313
1314# endif LIBRARYNAME
1315endif
1316
1317###############################################################################
1318# Tool Build Rules: Build executable tool based on TOOLNAME option
1319###############################################################################
1320
1321ifdef TOOLNAME
1322
1323#---------------------------------------------------------
1324# Set up variables for building a tool.
1325#---------------------------------------------------------
1326TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1327ifdef EXAMPLE_TOOL
1328ToolBuildPath   := $(ExmplDir)/$(TOOLEXENAME)
1329else
1330ToolBuildPath   := $(ToolDir)/$(TOOLEXENAME)
1331endif
1332
1333# TOOLALIAS is a name to symlink (or copy) the tool to.
1334ifdef TOOLALIAS
1335ifdef EXAMPLE_TOOL
1336ToolAliasBuildPath   := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1337else
1338ToolAliasBuildPath   := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1339endif
1340endif
1341
1342#---------------------------------------------------------
1343# Prune Exports
1344#---------------------------------------------------------
1345
1346# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1347# not exporting all of the weak symbols from the binary.  This reduces dyld
1348# startup time by 4x on darwin in some cases.
1349ifdef TOOL_NO_EXPORTS
1350ifeq ($(HOST_OS),Darwin)
1351
1352# Tiger tools don't support this.
1353ifneq ($(DARWIN_MAJVERS),4)
1354LD.Flags += -Wl,-exported_symbol,_main
1355endif
1356endif
1357
1358ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1359ifneq ($(ARCH), Mips)
1360  LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1361endif
1362endif
1363endif
1364
1365#---------------------------------------------------------
1366# Tool Order File Support
1367#---------------------------------------------------------
1368
1369ifeq ($(HOST_OS),Darwin)
1370ifdef TOOL_ORDER_FILE
1371
1372LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1373
1374endif
1375endif
1376
1377#---------------------------------------------------------
1378# Tool Version Info Support
1379#---------------------------------------------------------
1380
1381ifeq ($(HOST_OS),Darwin)
1382ifdef TOOL_INFO_PLIST
1383
1384LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1385
1386$(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1387
1388$(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1389        $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1390        $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1391                   -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1392                   -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1393                 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1394                   $< > $@
1395
1396endif
1397endif
1398
1399#---------------------------------------------------------
1400# Provide targets for building the tools
1401#---------------------------------------------------------
1402all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1403
1404clean-local::
1405ifneq ($(strip $(ToolBuildPath)),)
1406        -$(Verb) $(RM) -f $(ToolBuildPath)
1407endif
1408ifneq ($(strip $(ToolAliasBuildPath)),)
1409        -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1410endif
1411
1412ifdef EXAMPLE_TOOL
1413$(ToolBuildPath): $(ExmplDir)/.dir
1414else
1415$(ToolBuildPath): $(ToolDir)/.dir
1416endif
1417
1418ifdef CODESIGN_TOOLS
1419TOOL_CODESIGN_IDENTITY ?= -
1420
1421$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1422        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1423        $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1424        $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1425        $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1426          $(StripWarnMsg)
1427        $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1428        $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1429else
1430$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1431        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1432        $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1433        $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1434        $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1435          $(StripWarnMsg)
1436endif
1437
1438ifneq ($(strip $(ToolAliasBuildPath)),)
1439$(ToolAliasBuildPath): $(ToolBuildPath)
1440        $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1441        $(Verb) $(RM) -f $(ToolAliasBuildPath)
1442        $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1443        $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1444          $(StripWarnMsg)
1445endif
1446
1447ifdef NO_INSTALL
1448install-local::
1449        $(Echo) Install circumvented with NO_INSTALL
1450uninstall-local::
1451        $(Echo) Uninstall circumvented with NO_INSTALL
1452else
1453
1454ifdef INTERNAL_TOOL
1455ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1456else
1457ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1458endif
1459DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1460
1461install-local:: $(DestTool)
1462
1463$(DestTool): $(ToolBuildPath)
1464        $(Echo) Installing $(BuildMode) $(DestTool)
1465        $(Verb) $(MKDIR) $(ToolBinDir)
1466        $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1467
1468uninstall-local::
1469        $(Echo) Uninstalling $(BuildMode) $(DestTool)
1470        -$(Verb) $(RM) -f $(DestTool)
1471
1472# TOOLALIAS install.
1473ifdef TOOLALIAS
1474DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1475
1476install-local:: $(DestToolAlias)
1477
1478$(DestToolAlias): $(DestTool)
1479        $(Echo) Installing $(BuildMode) $(DestToolAlias)
1480        $(Verb) $(RM) -f $(DestToolAlias)
1481        $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1482
1483uninstall-local::
1484        $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1485        -$(Verb) $(RM) -f $(DestToolAlias)
1486endif
1487
1488endif
1489endif
1490
1491###############################################################################
1492# Object Build Rules: Build object files based on sources
1493###############################################################################
1494
1495# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1496ifeq ($(HOST_OS),HP-UX)
1497  DISABLE_AUTO_DEPENDENCIES=1
1498endif
1499
1500COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1501
1502# Provide rule sets for when dependency generation is enabled
1503ifndef DISABLE_AUTO_DEPENDENCIES
1504
1505#---------------------------------------------------------
1506# Create .o files in the ObjDir directory from the .cpp and .c files...
1507#---------------------------------------------------------
1508
1509DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1510         -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1511
1512# If the build succeeded, move the dependency file over, otherwise
1513# remove it.
1514DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1515                  else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1516
1517$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1518        $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1519        $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1520                $(DEPEND_MOVEFILE)
1521
1522$(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1523        $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1524        $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1525                $(DEPEND_MOVEFILE)
1526
1527$(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1528        $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1529        $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1530                $(DEPEND_MOVEFILE)
1531
1532$(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1533        $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1534        $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1535                $(DEPEND_MOVEFILE)
1536
1537$(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1538        $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1539        $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1540                $(DEPEND_MOVEFILE)
1541
1542# Provide alternate rule sets if dependencies are disabled
1543else
1544
1545$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1546        $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1547        $(Compile.CXX) $< -o $@
1548
1549$(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1550        $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1551        $(Compile.CXX) $< -o $@
1552
1553$(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1554        $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1555        $(Compile.CXX) $< -o $@
1556
1557$(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1558        $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1559        $(Compile.C) $< -o $@
1560
1561$(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1562        $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1563        $(Compile.C) $< -o $@
1564endif
1565
1566
1567## Rules for building preprocessed (.i/.ii) outputs.
1568$(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1569        $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1570        $(Verb) $(Preprocess.CXX) $< -o $@
1571
1572$(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1573        $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1574        $(Verb) $(Preprocess.CXX) $< -o $@
1575
1576$(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1577        $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1578        $(Verb) $(Preprocess.CXX) $< -o $@
1579
1580$(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1581        $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1582        $(Verb) $(Preprocess.C) $< -o $@
1583
1584$(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1585        $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1586        $(Verb) $(Preprocess.C) $< -o $@
1587
1588
1589$(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1590        $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1591        $(Compile.CXX) $< -o $@ -S
1592
1593$(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1594        $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1595        $(Compile.CXX) $< -o $@ -S
1596
1597$(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1598        $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1599        $(Compile.CXX) $< -o $@ -S
1600
1601$(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1602        $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1603        $(Compile.C) $< -o $@ -S
1604
1605$(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1606        $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1607        $(Compile.C) $< -o $@ -S
1608
1609###############################################################################
1610# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1611###############################################################################
1612
1613ifdef TARGET
1614TABLEGEN_INC_FILES_COMMON = 1
1615endif
1616
1617ifdef TABLEGEN_INC_FILES_COMMON
1618
1619INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1620INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1621.PRECIOUS: $(INCTMPFiles) $(INCFiles)
1622
1623# INCFiles rule: All of the tblgen generated files are emitted to
1624# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
1625# us to only "touch" the real file if the contents of it change.  IOW, if
1626# tblgen is modified, all of the .inc.tmp files are regenerated, but no
1627# dependencies of the .inc files are, unless the contents of the .inc file
1628# changes.
1629$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1630        $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1631
1632endif # TABLEGEN_INC_FILES_COMMON
1633
1634ifdef TARGET
1635
1636TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1637           $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1638           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1639           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1640           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1641           $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1642           $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1643
1644# All .inc.tmp files depend on the .td files.
1645$(INCTMPFiles) : $(TDFiles)
1646
1647$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1648$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1649        $(Echo) "Building $(<F) register info implementation with tblgen"
1650        $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1651
1652$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1653$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1654        $(Echo) "Building $(<F) instruction information with tblgen"
1655        $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1656
1657$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1658$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1659        $(Echo) "Building $(<F) assembly writer with tblgen"
1660        $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1661
1662$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1663$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1664        $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1665        $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1666
1667$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1668$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1669        $(Echo) "Building $(<F) assembly matcher with tblgen"
1670        $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1671
1672$(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1673$(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1674        $(Echo) "Building $(<F) MC code emitter with tblgen"
1675        $(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1676
1677$(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1678$(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1679        $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1680        $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1681
1682$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1683$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1684        $(Echo) "Building $(<F) code emitter with tblgen"
1685        $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1686
1687$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1688$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1689        $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1690        $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1691
1692$(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1693$(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1694        $(Echo) "Building $(<F) disassembly tables with tblgen"
1695        $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1696
1697$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1698$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1699        $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1700        $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1701
1702$(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1703$(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1704        $(Echo) "Building $(<F) subtarget information with tblgen"
1705        $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1706
1707$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1708$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1709        $(Echo) "Building $(<F) calling convention information with tblgen"
1710        $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1711
1712$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1713$(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1714        $(Echo) "Building $(<F) intrinsics information with tblgen"
1715        $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1716
1717$(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1718        $(Echo) "Building $(<F) decoder tables with tblgen"
1719        $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1720
1721$(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1722        $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1723        $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1724
1725# Dump all the records to <target>.td.expanded.  This is useful for debugging.
1726$(TARGET:%=%.td.expanded): \
1727%.td.expanded : %.td $(LLVM_TBLGEN)
1728        $(Echo) "Building a fully expanded version of $(<F)"
1729        $(Verb) $(LLVMTableGen) -o $(call SYSPATH, $@) $<
1730
1731clean-local::
1732        -$(Verb) $(RM) -f $(INCFiles) $(TARGET).td.expanded
1733
1734endif # TARGET
1735
1736###############################################################################
1737# OTHER RULES: Other rules needed
1738###############################################################################
1739
1740# To create postscript files from dot files...
1741ifneq ($(DOT),false)
1742%.ps: %.dot
1743        $(DOT) -Tps < $< > $@
1744else
1745%.ps: %.dot
1746        $(Echo) "Cannot build $@: The program dot is not installed"
1747endif
1748
1749# This rules ensures that header files that are removed still have a rule for
1750# which they can be "generated."  This allows make to ignore them and
1751# reproduce the dependency lists.
1752%.h:: ;
1753%.hpp:: ;
1754
1755# Define clean-local to clean the current directory. Note that this uses a
1756# very conservative approach ensuring that empty variables do not cause
1757# errors or disastrous removal.
1758clean-local::
1759ifneq ($(strip $(ObjRootDir)),)
1760        -$(Verb) $(RM) -rf $(ObjRootDir)
1761endif
1762ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1763        -$(Verb) $(RM) -f *$(SHLIBEXT)
1764endif
1765
1766clean-all-local::
1767        -$(Verb) $(RM) -rf Debug Release Profile
1768
1769
1770###############################################################################
1771# DEPENDENCIES: Include the dependency files if we should
1772###############################################################################
1773ifndef DISABLE_AUTO_DEPENDENCIES
1774
1775# If its not one of the cleaning targets
1776ifndef IS_CLEANING_TARGET
1777
1778# Get the list of dependency files
1779DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1780DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1781
1782-include $(DependFiles) ""
1783
1784endif
1785
1786endif
1787
1788###############################################################################
1789# CHECK: Running the test suite
1790###############################################################################
1791
1792check:: all
1793        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1794          if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1795            $(EchoCmd) Running test suite ; \
1796            $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1797              TESTSUITE=$(TESTSUITE) ; \
1798          else \
1799            $(EchoCmd) No Makefile in test directory ; \
1800          fi ; \
1801        else \
1802          $(EchoCmd) No test directory ; \
1803        fi
1804
1805# An alias dating from when both lit and DejaGNU test runners were used.
1806check-lit:: check
1807
1808check-all::
1809        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1810          if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1811            $(EchoCmd) Running test suite ; \
1812            $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1813          else \
1814            $(EchoCmd) No Makefile in test directory ; \
1815          fi ; \
1816        else \
1817          $(EchoCmd) No test directory ; \
1818        fi
1819
1820###############################################################################
1821# UNITTESTS: Running the unittests test suite
1822###############################################################################
1823
1824unittests::
1825        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1826          if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1827            $(EchoCmd) Running unittests test suite ; \
1828            $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1829          else \
1830            $(EchoCmd) No Makefile in unittests directory ; \
1831          fi ; \
1832        else \
1833          $(EchoCmd) No unittests directory ; \
1834        fi
1835
1836###############################################################################
1837# DISTRIBUTION: Handle construction of a distribution tarball
1838###############################################################################
1839
1840#------------------------------------------------------------------------
1841# Define distribution related variables
1842#------------------------------------------------------------------------
1843DistName    := $(PROJECT_NAME)-$(PROJ_VERSION)
1844DistDir     := $(PROJ_OBJ_ROOT)/$(DistName)
1845TopDistDir  := $(PROJ_OBJ_ROOT)/$(DistName)
1846DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1847DistZip     := $(PROJ_OBJ_ROOT)/$(DistName).zip
1848DistTarBZ2  := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1849DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1850               ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1851               Makefile.config.in configure autoconf
1852DistOther   := $(notdir $(wildcard \
1853               $(PROJ_SRC_DIR)/*.h \
1854               $(PROJ_SRC_DIR)/*.td \
1855               $(PROJ_SRC_DIR)/*.def \
1856               $(PROJ_SRC_DIR)/*.ll \
1857               $(PROJ_SRC_DIR)/*.in))
1858DistSubDirs := $(SubDirs)
1859DistSources  = $(Sources) $(EXTRA_DIST)
1860DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
1861
1862#------------------------------------------------------------------------
1863# We MUST build distribution with OBJ_DIR != SRC_DIR
1864#------------------------------------------------------------------------
1865ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1866dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1867        $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1868
1869else
1870
1871#------------------------------------------------------------------------
1872# Prevent attempt to run dist targets from anywhere but the top level
1873#------------------------------------------------------------------------
1874ifneq ($(LEVEL),.)
1875dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1876        $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1877else
1878
1879#------------------------------------------------------------------------
1880# Provide the top level targets
1881#------------------------------------------------------------------------
1882
1883dist-gzip:: $(DistTarGZip)
1884
1885$(DistTarGZip) : $(TopDistDir)/.makedistdir
1886        $(Echo) Packing gzipped distribution tar file.
1887        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1888          $(GZIP) -c > "$(DistTarGZip)"
1889
1890dist-bzip2:: $(DistTarBZ2)
1891
1892$(DistTarBZ2) : $(TopDistDir)/.makedistdir
1893        $(Echo) Packing bzipped distribution tar file.
1894        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1895          $(BZIP2) -c >$(DistTarBZ2)
1896
1897dist-zip:: $(DistZip)
1898
1899$(DistZip) : $(TopDistDir)/.makedistdir
1900        $(Echo) Packing zipped distribution file.
1901        $(Verb) rm -f $(DistZip)
1902        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1903
1904dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1905        $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1906
1907DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1908
1909dist-check:: $(DistTarGZip)
1910        $(Echo) Checking distribution tar file.
1911        $(Verb) if test -d $(DistCheckDir) ; then \
1912          $(RM) -rf $(DistCheckDir) ; \
1913        fi
1914        $(Verb) $(MKDIR) $(DistCheckDir)
1915        $(Verb) cd $(DistCheckDir) && \
1916          $(MKDIR) $(DistCheckDir)/build && \
1917          $(MKDIR) $(DistCheckDir)/install && \
1918          gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1919          cd build && \
1920          ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1921            --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1922          $(MAKE) all && \
1923          $(MAKE) check && \
1924          $(MAKE) unittests && \
1925          $(MAKE) install && \
1926          $(MAKE) uninstall && \
1927          $(MAKE) dist-clean && \
1928          $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1929
1930dist-clean::
1931        $(Echo) Cleaning distribution files
1932        -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1933          $(DistCheckDir)
1934
1935endif
1936
1937#------------------------------------------------------------------------
1938# Provide the recursive distdir target for building the distribution directory
1939#------------------------------------------------------------------------
1940distdir: $(DistDir)/.makedistdir
1941$(DistDir)/.makedistdir: $(DistSources)
1942        $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1943          if test -d "$(DistDir)" ; then \
1944            find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1945              exit 1 ; \
1946          fi ; \
1947          $(EchoCmd) Removing old $(DistDir) ; \
1948          $(RM) -rf $(DistDir); \
1949          $(EchoCmd) Making 'all' to verify build ; \
1950          $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1951        fi
1952        $(Echo) Building Distribution Directory $(DistDir)
1953        $(Verb) $(MKDIR) $(DistDir)
1954        $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1955        srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1956        for file in $(DistFiles) ; do \
1957          case "$$file" in \
1958            $(PROJ_SRC_DIR)/*) \
1959              file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1960              ;; \
1961            $(PROJ_SRC_ROOT)/*) \
1962              file=`echo "$$file" | \
1963                sed "s#^$$srcrootstrip/##"` \
1964              ;; \
1965          esac; \
1966          if test -f "$(PROJ_SRC_DIR)/$$file" || \
1967             test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1968            from_dir="$(PROJ_SRC_DIR)" ; \
1969          elif test -f "$$file" || test -d "$$file" ; then \
1970            from_dir=. ; \
1971          fi ; \
1972          to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1973          if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1974            to_dir="$(DistDir)/$$dir"; \
1975            $(MKDIR) "$$to_dir" ; \
1976          else \
1977            to_dir="$(DistDir)"; \
1978          fi; \
1979          mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1980          if test -n "$$mid_dir" ; then \
1981            $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1982          fi ; \
1983          if test -d "$$from_dir/$$file"; then \
1984            if test -d "$(PROJ_SRC_DIR)/$$file" && \
1985               test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1986               cd $(PROJ_SRC_DIR) ; \
1987               $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1988                 ( cd $$to_dir ; $(TAR) xf - ) ; \
1989               cd $(PROJ_OBJ_DIR) ; \
1990            else \
1991               cd $$from_dir ; \
1992               $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1993                 ( cd $$to_dir ; $(TAR) xf - ) ; \
1994               cd $(PROJ_OBJ_DIR) ; \
1995            fi; \
1996          elif test -f "$$from_dir/$$file" ; then \
1997            $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1998          elif test -L "$$from_dir/$$file" ; then \
1999            $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
2000          elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
2001            $(EchoCmd) "===== WARNING: Distribution Source " \
2002              "$$from_dir/$$file Not Found!" ; \
2003          elif test "$(Verb)" != '@' ; then \
2004            $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
2005          fi; \
2006        done
2007        $(Verb) for subdir in $(DistSubDirs) ; do \
2008          if test "$$subdir" \!= "." ; then \
2009            new_distdir="$(DistDir)/$$subdir" ; \
2010            test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
2011            ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
2012              DistDir="$$new_distdir" distdir ) || exit 1; \
2013          fi; \
2014        done
2015        $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2016          $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2017          $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2018                                  -name .svn \) -print` ;\
2019          $(MAKE) dist-hook ; \
2020          $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2021            -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2022            -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2023            -o ! -type d ! -perm -444 -exec \
2024              $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2025            || chmod -R a+r $(DistDir) ; \
2026        fi
2027
2028# This is invoked by distdir target, define it as a no-op to avoid errors if not
2029# defined by user.
2030dist-hook::
2031
2032endif
2033
2034###############################################################################
2035# TOP LEVEL - targets only to apply at the top level directory
2036###############################################################################
2037
2038ifeq ($(LEVEL),.)
2039
2040#------------------------------------------------------------------------
2041# Install support for the project's include files:
2042#------------------------------------------------------------------------
2043ifdef NO_INSTALL
2044install-local::
2045        $(Echo) Install circumvented with NO_INSTALL
2046uninstall-local::
2047        $(Echo) Uninstall circumvented with NO_INSTALL
2048else
2049install-local::
2050        $(Echo) Installing include files
2051        $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2052        $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2053          cd $(PROJ_SRC_ROOT)/include && \
2054          for hdr in `find . -type f \
2055              '(' -name LICENSE.TXT \
2056               -o -name '*.def' \
2057               -o -name '*.h' \
2058               -o -name '*.inc' \
2059               -o -name '*.td' \
2060              ')' -print | grep -v CVS | \
2061              grep -v .svn` ; do \
2062            instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2063            if test \! -d "$$instdir" ; then \
2064              $(EchoCmd) Making install directory $$instdir ; \
2065              $(MKDIR) $$instdir ;\
2066            fi ; \
2067            $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2068          done ; \
2069        fi
2070ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2071        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2072          cd $(PROJ_OBJ_ROOT)/include && \
2073          for hdr in `find . -type f \
2074              '(' -name LICENSE.TXT \
2075               -o -name '*.def' \
2076               -o -name '*.h' \
2077               -o -name '*.inc' \
2078               -o -name '*.td' \
2079              ')' -print | grep -v CVS | \
2080              grep -v .svn` ; do \
2081            instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2082            if test \! -d "$$instdir" ; then \
2083              $(EchoCmd) Making install directory $$instdir ; \
2084              $(MKDIR) $$instdir ;\
2085            fi ; \
2086            $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2087          done ; \
2088        fi
2089endif
2090
2091uninstall-local::
2092        $(Echo) Uninstalling include files
2093        $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2094          cd $(PROJ_SRC_ROOT)/include && \
2095            $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2096              '!' '(' -name '*~' -o -name '.#*' \
2097        -o -name '*.in' ')' -print ')' | \
2098        grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2099          cd $(PROJ_SRC_ROOT)/include && \
2100            $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2101      -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2102        fi
2103endif
2104endif
2105
2106check-line-length:
2107        @echo searching for overlength lines in files: $(Sources)
2108        @echo
2109        @echo
2110        egrep -n '.{81}' $(Sources) /dev/null
2111
2112check-for-tabs:
2113        @echo searching for tabs in files: $(Sources)
2114        @echo
2115        @echo
2116        egrep -n '      ' $(Sources) /dev/null
2117
2118check-footprint:
2119        @ls -l $(LibDir) | awk '\
2120          BEGIN { sum = 0; } \
2121                { sum += $$5; } \
2122          END   { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2123        @ls -l $(ToolDir) | awk '\
2124          BEGIN { sum = 0; } \
2125                { sum += $$5; } \
2126          END   { printf("Programs:  %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2127#------------------------------------------------------------------------
2128# Print out the directories used for building
2129#------------------------------------------------------------------------
2130printvars::
2131        $(Echo) "BuildMode    : " '$(BuildMode)'
2132        $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2133        $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2134        $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2135        $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2136        $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2137        $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2138        $(Echo) "PROJ_prefix  : " '$(PROJ_prefix)'
2139        $(Echo) "PROJ_internal_prefix  : " '$(PROJ_internal_prefix)'
2140        $(Echo) "PROJ_bindir  : " '$(PROJ_bindir)'
2141        $(Echo) "PROJ_libdir  : " '$(PROJ_libdir)'
2142        $(Echo) "PROJ_etcdir  : " '$(PROJ_etcdir)'
2143        $(Echo) "PROJ_includedir  : " '$(PROJ_includedir)'
2144        $(Echo) "UserTargets  : " '$(UserTargets)'
2145        $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2146        $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2147        $(Echo) "ObjDir       : " '$(ObjDir)'
2148        $(Echo) "LibDir       : " '$(LibDir)'
2149        $(Echo) "ToolDir      : " '$(ToolDir)'
2150        $(Echo) "ExmplDir     : " '$(ExmplDir)'
2151        $(Echo) "Sources      : " '$(Sources)'
2152        $(Echo) "TDFiles      : " '$(TDFiles)'
2153        $(Echo) "INCFiles     : " '$(INCFiles)'
2154        $(Echo) "INCTMPFiles  : " '$(INCTMPFiles)'
2155        $(Echo) "PreConditions: " '$(PreConditions)'
2156        $(Echo) "Compile.CXX  : " '$(Compile.CXX)'
2157        $(Echo) "Compile.C    : " '$(Compile.C)'
2158        $(Echo) "Archive      : " '$(Archive)'
2159        $(Echo) "YaccFiles    : " '$(YaccFiles)'
2160        $(Echo) "LexFiles     : " '$(LexFiles)'
2161        $(Echo) "Module       : " '$(Module)'
2162        $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2163        $(Echo) "SubDirs      : " '$(SubDirs)'
2164        $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2165        $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2166
2167###
2168# Debugging
2169
2170# General debugging rule, use 'make dbg-print-XXX' to print the
2171# definition, value and origin of XXX.
2172make-print-%:
2173        $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))
Note: See TracBrowser for help on using the repository browser.