source: icGREP/icgrep-devel/llvm-3.6.1.src/Makefile.rules @ 4721

Last change on this file since 4721 was 4574, checked in by cameron, 4 years ago

Updating to LLVM 3.6

File size: 71.3 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
380  LD.Flags   += -ftest-coverage -fprofile-arcs
381endif
382
383# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
384# then disable assertions by defining the appropriate preprocessor symbols.
385ifeq ($(DISABLE_ASSERTIONS),1)
386  CPP.Defines += -DNDEBUG
387else
388  BuildMode := $(BuildMode)+Asserts
389  CPP.Defines += -D_DEBUG
390endif
391
392# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
393# configured), then enable expensive checks by defining the
394# appropriate preprocessor symbols.
395ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
396  BuildMode := $(BuildMode)+Checks
397  CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
398endif
399
400# LOADABLE_MODULE implies several other things so we force them to be
401# defined/on.
402ifdef LOADABLE_MODULE
403  SHARED_LIBRARY := 1
404  LINK_LIBS_IN_SHARED := 1
405endif
406
407ifdef SHARED_LIBRARY
408  ENABLE_PIC := 1
409  PIC_FLAG = "(PIC)"
410endif
411
412ifeq ($(ENABLE_PIC),1)
413  ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
414    # Nothing. Win32 defaults to PIC and warns when given -fPIC
415  else
416    ifeq ($(HOST_OS),Darwin)
417      # Common symbols not allowed in dylib files
418      CXX.Flags += -fno-common
419      C.Flags   += -fno-common
420    else
421      # Linux and others; pass -fPIC
422      CXX.Flags += -fPIC
423      C.Flags   += -fPIC
424    endif
425  endif
426else
427  ifeq ($(HOST_OS),Darwin)
428      CXX.Flags += -mdynamic-no-pic
429      C.Flags   += -mdynamic-no-pic
430  endif
431endif
432
433# Support makefile variable to disable any kind of timestamp/non-deterministic
434# info from being used in the build.
435ifeq ($(ENABLE_TIMESTAMPS),1)
436  DOTDIR_TIMESTAMP_COMMAND := $(DATE)
437else
438  DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
439endif
440
441ifeq ($(HOST_OS),MingW)
442  # Work around PR4957
443  CPP.Defines += -D__NO_CTYPE_INLINE
444  ifeq ($(LLVM_CROSS_COMPILING),1)
445    # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
446    ifdef TOOLNAME
447      LD.Flags += -Wl,--allow-multiple-definition
448    endif
449  endif
450endif
451
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) $(NO_COMMENT)
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
729# On Windows, SharedLibDir != LibDir. The order is important.
730ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
731  LD.Flags    += -L$(SharedLibDir) -L$(LibDir) -L$(LLVMToolDir) -L$(LLVMLibDir)
732else
733  LD.Flags    += -L$(LibDir) -L$(LLVMLibDir)
734endif
735
736CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
737# All -I flags should go here, so that they don't confuse llvm-config.
738CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
739                 $(patsubst %,-I%/include,\
740                 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
741                 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
742                 $(CPP.BaseFlags)
743
744ifeq ($(INCLUDE_BUILD_DIR),1)
745  CPP.Flags   += -I$(ObjDir)
746endif
747
748# SHOW_DIAGNOSTICS support.
749ifeq ($(SHOW_DIAGNOSTICS),1)
750  Compile.Wrapper := env CC_LOG_DIAGNOSTICS=1 \
751                          CC_LOG_DIAGNOSTICS_FILE="$(LLVM_OBJ_ROOT)/$(BuildMode)/diags"
752else
753  Compile.Wrapper :=
754endif
755
756Compile.C     = $(Compile.Wrapper) \
757                  $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
758                $(TargetCommonOpts) $(CompileCommonOpts) -c
759Compile.CXX   = $(Compile.Wrapper) \
760                  $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
761                $(TargetCommonOpts) $(CompileCommonOpts) -c
762Preprocess.CXX= $(Compile.Wrapper) \
763                  $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
764                $(CompileCommonOpts) $(CXX.Flags) -E
765Link          = $(Compile.Wrapper) \
766                  $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
767                $(TargetCommonOpts) $(Strip)
768
769Preprocess.C  = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
770                $(TargetCommonOpts) $(CompileCommonOpts) -E
771
772ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755
773ScriptInstall = $(INSTALL) -m 0755
774DataInstall   = $(INSTALL) -m 0644
775
776# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
777# paths. In this case, the SYSPATH function (defined in
778# Makefile.config) transforms Unix paths into Windows paths.
779TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
780                -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
781                -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
782                -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
783LLVMTableGen  = $(LLVM_TBLGEN) $(TableGen.Flags)
784
785Archive       = $(AR) $(AR.Flags)
786ifdef RANLIB
787Ranlib        = $(RANLIB)
788else
789Ranlib        = ranlib
790endif
791
792AliasTool     = ln -sf
793
794#----------------------------------------------------------
795# Get the list of source files and compute object file
796# names from them.
797#----------------------------------------------------------
798
799ifndef SOURCES
800  Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
801             $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
802else
803  Sources := $(SOURCES)
804endif
805
806ifdef BUILT_SOURCES
807Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
808endif
809
810BaseNameSources := $(sort $(basename $(Sources)))
811SourceDirs := $(sort $(dir $(Sources)))
812
813ObjectsO  := $(BaseNameSources:%=$(ObjDir)/%.o)
814ObjectDirs := $(SourceDirs:%=$(ObjDir)/%)
815
816#----------------------------------------------------------
817# For Mingw MSYS bash and Python/w32:
818#
819# $(ECHOPATH) prints DOSish pathstring.
820#   ex) $(ECHOPATH) /include/sys/types.h
821#   --> C:/mingw/include/sys/types.h
822# built-in "echo" does not transform path to DOSish path.
823#
824# FIXME: It would not be needed when MSYS's python
825# were provided.
826#----------------------------------------------------------
827
828ifeq (-mingw32,$(findstring -mingw32,$(BUILD_TRIPLE)))
829  ECHOPATH := $(Verb)$(PYTHON) -u -c "import sys;print ' '.join(sys.argv[1:])"
830else
831  ECHOPATH := $(Verb)$(ECHO)
832endif
833
834###############################################################################
835# DIRECTORIES: Handle recursive descent of directory structure
836###############################################################################
837
838#---------------------------------------------------------
839# Provide rules to make install dirs. This must be early
840# in the file so they get built before dependencies
841#---------------------------------------------------------
842
843$(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
844        $(Verb) $(MKDIR) $@
845
846# To create other directories, as needed, and timestamp their creation
847%/.dir:
848        $(Verb) $(MKDIR) $* > /dev/null
849        $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
850
851.PRECIOUS: $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
852.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
853
854#---------------------------------------------------------
855# Collect the object directories (as there may be more
856# than one if the source code is spread across
857# subdirectories).
858#---------------------------------------------------------
859
860OBJECT_DIRS := $(ObjDir)/.dir $(ObjectDirs:%=%/.dir)
861.PRECIOUS: $(OBJECT_DIRS)
862
863#---------------------------------------------------------
864# Handle the DIRS options for sequential construction
865#---------------------------------------------------------
866
867SubDirs :=
868ifdef DIRS
869SubDirs += $(DIRS)
870
871ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
872$(RecursiveTargets)::
873        $(Verb) for dir in $(DIRS); do \
874          if ([ ! -f $$dir/Makefile ] || \
875              command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
876            $(MKDIR) $$dir; \
877            $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
878          fi; \
879          ($(MAKE) -C $$dir $@ ) || exit 1; \
880        done
881else
882$(RecursiveTargets)::
883        $(Verb) for dir in $(DIRS); do \
884          ($(MAKE) -C $$dir $@ ) || exit 1; \
885        done
886endif
887
888endif
889
890#---------------------------------------------------------
891# Handle the EXPERIMENTAL_DIRS options ensuring success
892# after each directory is built.
893#---------------------------------------------------------
894ifdef EXPERIMENTAL_DIRS
895$(RecursiveTargets)::
896        $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
897          if ([ ! -f $$dir/Makefile ] || \
898              command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
899            $(MKDIR) $$dir; \
900            $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
901          fi; \
902          ($(MAKE) -C $$dir $@ ) || exit 0; \
903        done
904endif
905
906#-----------------------------------------------------------
907# Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
908#-----------------------------------------------------------
909ifdef OPTIONAL_PARALLEL_DIRS
910  PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) -o -f $(T)/Makefile && echo "$(T)"))
911endif
912
913#-----------------------------------------------------------
914# Handle the PARALLEL_DIRS options for parallel construction
915#-----------------------------------------------------------
916ifdef PARALLEL_DIRS
917
918SubDirs += $(PARALLEL_DIRS)
919
920# Unfortunately, this list must be maintained if new recursive targets are added
921all      :: $(addsuffix /.makeall      ,$(PARALLEL_DIRS))
922clean    :: $(addsuffix /.makeclean    ,$(PARALLEL_DIRS))
923clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
924install  :: $(addsuffix /.makeinstall  ,$(PARALLEL_DIRS))
925uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
926install-bytecode  :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
927unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
928
929ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
930
931$(ParallelTargets) :
932        $(Verb) \
933          SD=$(PROJ_SRC_DIR)/$(@D); \
934          DD=$(@D); \
935          if [ ! -f $$SD/Makefile ]; then \
936            SD=$(@D); \
937            DD=$(notdir $(@D)); \
938          fi; \
939          if ([ ! -f $$DD/Makefile ] || \
940                    command test $$DD/Makefile -ot \
941                      $$SD/Makefile ); then \
942          $(MKDIR) $$DD; \
943          $(CP) $$SD/Makefile $$DD/Makefile; \
944        fi; \
945        $(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
946endif
947
948#---------------------------------------------------------
949# Handle the OPTIONAL_DIRS options for directores that may
950# or may not exist.
951#---------------------------------------------------------
952ifdef OPTIONAL_DIRS
953
954SubDirs += $(OPTIONAL_DIRS)
955
956ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
957$(RecursiveTargets)::
958        $(Verb) for dir in $(OPTIONAL_DIRS); do \
959          if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
960            if ([ ! -f $$dir/Makefile ] || \
961                command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
962              $(MKDIR) $$dir; \
963              $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
964            fi; \
965            ($(MAKE) -C$$dir $@ ) || exit 1; \
966          fi \
967        done
968else
969$(RecursiveTargets)::
970        $(Verb) for dir in $(OPTIONAL_DIRS); do \
971          if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
972            ($(MAKE) -C$$dir $@ ) || exit 1; \
973          fi \
974        done
975endif
976endif
977
978#---------------------------------------------------------
979# Handle the CONFIG_FILES options
980#---------------------------------------------------------
981ifdef CONFIG_FILES
982
983ifdef NO_INSTALL
984install-local::
985        $(Echo) Install circumvented with NO_INSTALL
986uninstall-local::
987        $(Echo) UnInstall circumvented with NO_INSTALL
988else
989install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
990        $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
991        $(Verb)for file in $(CONFIG_FILES); do \
992          if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
993            $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
994          elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
995            $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
996          else \
997            $(ECHO) Error: cannot find config file $${file}. ; \
998          fi \
999        done
1000
1001uninstall-local::
1002        $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
1003        $(Verb)for file in $(CONFIG_FILES); do \
1004          $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
1005        done
1006endif
1007
1008endif
1009
1010###############################################################################
1011# Set up variables for building libraries
1012###############################################################################
1013
1014#---------------------------------------------------------
1015# Define various command line options pertaining to the
1016# libraries needed when linking. There are "Proj" libs
1017# (defined by the user's project) and "LLVM" libs (defined
1018# by the LLVM project).
1019#---------------------------------------------------------
1020
1021ifdef USEDLIBS
1022ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
1023ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
1024ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
1025ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
1026endif
1027
1028ifdef LLVMLIBS
1029LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
1030LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
1031LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
1032LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
1033endif
1034
1035# Loadable module for Win32 requires all symbols resolved for linking.
1036# Then all symbols in LLVM.dll will be available.
1037ifeq ($(ENABLE_SHARED),1)
1038  ifdef LOADABLE_MODULE
1039    ifneq (,$(filter $(HOST_OS),Cygwin MingW))
1040      LINK_COMPONENTS += all
1041    endif
1042  endif
1043endif
1044
1045ifndef IS_CLEANING_TARGET
1046ifdef LINK_COMPONENTS
1047
1048# If LLVM_CONFIG doesn't exist, build it.  This can happen if you do a make
1049# clean in tools, then do a make in tools (instead of at the top level).
1050$(LLVM_CONFIG):
1051        @echo "*** llvm-config doesn't exist - rebuilding it."
1052        @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
1053
1054$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
1055
1056ifeq ($(ENABLE_SHARED), 1)
1057# We can take the "auto-import" feature to get rid of using dllimport.
1058ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1059LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
1060                   -L $(SharedLibDir)
1061endif
1062LLVM_SO_NAME = LLVM-$(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)$(LLVM_VERSION_SUFFIX)
1063LLVMLibsOptions += -l$(LLVM_SO_NAME)
1064LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)$(LLVM_SO_NAME)$(SHLIBEXT)
1065else
1066
1067ifndef NO_LLVM_CONFIG
1068LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
1069ifeq ($(LLVMConfigLibs),Error)
1070$(error llvm-config --libs failed)
1071endif
1072LLVMLibsOptions += $(LLVMConfigLibs)
1073LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
1074ifeq ($(LLVMConfigLibfiles),Error)
1075$(error llvm-config --libfiles failed)
1076endif
1077LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
1078endif
1079
1080endif
1081endif
1082endif
1083
1084# Set up the library exports file.
1085ifdef EXPORTED_SYMBOL_FILE
1086
1087# First, set up the native export file, which may differ from the source
1088# export file.
1089
1090ifeq ($(HOST_OS),Darwin)
1091# Darwin convention prefixes symbols with underscores.
1092NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
1093$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1094        $(Verb) sed -e 's/^/_/' < $< > $@
1095clean-local::
1096        -$(Verb) $(RM) -f $(NativeExportsFile)
1097else
1098ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1099# Gold and BFD ld require a version script rather than a plain list.
1100NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
1101$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1102        $(Verb) echo "{" > $@
1103        $(Verb) grep -q '[[:alnum:]_]' $< && echo "  global:" >> $@ || :
1104        $(Verb) sed -e 's/$$/;/' -e 's/^/    /' < $< >> $@
1105ifneq ($(HOST_OS),OpenBSD)
1106        $(Verb) echo "  local: *;" >> $@
1107endif
1108        $(Verb) echo "};" >> $@
1109clean-local::
1110        -$(Verb) $(RM) -f $(NativeExportsFile)
1111else
1112ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1113# GNU ld Win32 accepts .DEF files that contain "DATA" entries.
1114NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
1115$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
1116        $(Echo) Generating $(notdir $@)
1117        $(Verb) $(ECHO) "EXPORTS" > $@
1118        $(Verb) $(CAT) $< >> $@
1119clean-local::
1120        -$(Verb) $(RM) -f $(NativeExportsFile)
1121else
1122# Default behavior: just use the exports file verbatim.
1123NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
1124endif
1125endif
1126endif
1127
1128# Now add the linker command-line options to use the native export file.
1129
1130# Darwin
1131ifeq ($(HOST_OS),Darwin)
1132LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1133endif
1134
1135# gold, bfd ld, etc.
1136ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1137LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
1138endif
1139
1140# Windows
1141ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1142# LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1143SharedLinkOptions += $(NativeExportsFile)
1144endif
1145
1146endif
1147
1148###############################################################################
1149# Library Build Rules: Four ways to build a library
1150###############################################################################
1151
1152# if we're building a library ...
1153ifdef LIBRARYNAME
1154
1155# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1156LIBRARYNAME := $(strip $(LIBRARYNAME))
1157LIBRARYALIASNAME := $(strip $(LIBRARYALIASNAME))
1158ifdef LOADABLE_MODULE
1159BaseLibName.A  := $(LIBRARYNAME).a
1160BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1161BaseAliasName.SO := $(LIBRARYALIASNAME)$(SHLIBEXT)
1162else
1163BaseLibName.A  := lib$(LIBRARYNAME).a
1164BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1165BaseAliasName.SO := $(SharedPrefix)$(LIBRARYALIASNAME)$(SHLIBEXT)
1166endif
1167LibName.A  := $(LibDir)/$(BaseLibName.A)
1168LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1169AliasName.SO := $(SharedLibDir)/$(BaseAliasName.SO)
1170LibName.O  := $(LibDir)/$(LIBRARYNAME).o
1171
1172#---------------------------------------------------------
1173# Shared Library Targets:
1174#   If the user asked for a shared library to be built
1175#   with the SHARED_LIBRARY variable, then we provide
1176#   targets for building them.
1177#---------------------------------------------------------
1178ifdef SHARED_LIBRARY
1179
1180all-local:: $(AliasName.SO)
1181
1182$(AliasName.SO): $(LibName.SO)
1183ifdef SHARED_ALIAS
1184        $(Verb) $(AliasTool) $(BaseLibName.SO) $(AliasName.SO)
1185endif
1186
1187ifdef EXPORTED_SYMBOL_FILE
1188$(LibName.SO): $(NativeExportsFile)
1189endif
1190
1191ifdef LINK_LIBS_IN_SHARED
1192ifdef LOADABLE_MODULE
1193SharedLibKindMessage := "Loadable Module"
1194SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1195else
1196SharedLibKindMessage := "Shared Library"
1197endif
1198$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1199        $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1200          $(notdir $@)
1201        $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1202          $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1203else
1204$(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1205        $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1206        $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1207endif
1208
1209clean-local::
1210ifneq ($(strip $(LibName.SO)),)
1211        -$(Verb) $(RM) -f $(LibName.SO)
1212endif
1213
1214ifdef NO_INSTALL
1215install-local::
1216        $(Echo) Install circumvented with NO_INSTALL
1217uninstall-local::
1218        $(Echo) Uninstall circumvented with NO_INSTALL
1219else
1220
1221# Win32.DLL prefers to be located on the "PATH" of binaries.
1222ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1223DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
1224else
1225DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
1226endif
1227DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
1228DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO)
1229
1230install-local:: $(DestSharedLib)
1231
1232$(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
1233        $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
1234        $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
1235ifdef SHARED_ALIAS
1236        $(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias)
1237        $(Verb) $(AliasTool) $(BaseLibName.SO) $(DestSharedAlias)
1238endif
1239
1240uninstall-local::
1241        $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1242        -$(Verb) $(RM) -f $(DestSharedLib)
1243ifdef SHARED_ALIAS
1244        -$(Verb) $(RM) -f $(DestSharedAlias)
1245endif
1246endif
1247endif
1248
1249#---------------------------------------------------------
1250# Library Targets:
1251#   If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1252#   building an archive.
1253#---------------------------------------------------------
1254ifndef NO_BUILD_ARCHIVE
1255ifndef BUILD_ARCHIVE
1256ifndef LOADABLE_MODULE
1257BUILD_ARCHIVE = 1
1258endif
1259endif
1260endif
1261
1262#---------------------------------------------------------
1263# Archive Library Targets:
1264#   If the user wanted a regular archive library built,
1265#   then we provide targets for building them.
1266#---------------------------------------------------------
1267ifdef BUILD_ARCHIVE
1268
1269all-local:: $(LibName.A)
1270
1271$(LibName.A): $(ObjectsO) $(LibDir)/.dir
1272        $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1273        -$(Verb) $(RM) -f $@
1274        $(Verb) $(Archive) $@ $(ObjectsO)
1275        $(Verb) $(Ranlib) $@
1276
1277clean-local::
1278ifneq ($(strip $(LibName.A)),)
1279        -$(Verb) $(RM) -f $(LibName.A)
1280endif
1281
1282ifdef NO_INSTALL
1283install-local::
1284        $(Echo) Install circumvented with NO_INSTALL
1285uninstall-local::
1286        $(Echo) Uninstall circumvented with NO_INSTALL
1287else
1288ifdef NO_INSTALL_ARCHIVES
1289install-local::
1290        $(Echo) Install circumvented with NO_INSTALL
1291uninstall-local::
1292        $(Echo) Uninstall circumvented with NO_INSTALL
1293else
1294DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
1295
1296install-local:: $(DestArchiveLib)
1297
1298$(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
1299        $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1300        $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
1301        $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
1302
1303uninstall-local::
1304        $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1305        -$(Verb) $(RM) -f $(DestArchiveLib)
1306endif
1307endif
1308endif
1309
1310# endif LIBRARYNAME
1311endif
1312
1313###############################################################################
1314# Tool Build Rules: Build executable tool based on TOOLNAME option
1315###############################################################################
1316
1317ifdef TOOLNAME
1318
1319#---------------------------------------------------------
1320# Set up variables for building a tool.
1321#---------------------------------------------------------
1322TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
1323ifdef EXAMPLE_TOOL
1324ToolBuildPath   := $(ExmplDir)/$(TOOLEXENAME)
1325else
1326ToolBuildPath   := $(ToolDir)/$(TOOLEXENAME)
1327endif
1328
1329# TOOLALIAS is a name to symlink (or copy) the tool to.
1330ifdef TOOLALIAS
1331ifdef EXAMPLE_TOOL
1332ToolAliasBuildPath   := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1333else
1334ToolAliasBuildPath   := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1335endif
1336endif
1337
1338#---------------------------------------------------------
1339# Prune Exports
1340#---------------------------------------------------------
1341
1342# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1343# not exporting all of the weak symbols from the binary.  This reduces dyld
1344# startup time by 4x on darwin in some cases.
1345ifdef TOOL_NO_EXPORTS
1346ifeq ($(HOST_OS),Darwin)
1347
1348# Tiger tools don't support this.
1349ifneq ($(DARWIN_MAJVERS),4)
1350LD.Flags += -Wl,-exported_symbol,_main
1351endif
1352endif
1353
1354ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux NetBSD FreeBSD GNU/kFreeBSD GNU))
1355ifneq ($(ARCH), Mips)
1356  LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
1357endif
1358endif
1359endif
1360
1361#---------------------------------------------------------
1362# Tool Order File Support
1363#---------------------------------------------------------
1364
1365ifeq ($(HOST_OS),Darwin)
1366ifdef TOOL_ORDER_FILE
1367
1368LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1369
1370endif
1371endif
1372
1373#---------------------------------------------------------
1374# Tool Version Info Support
1375#---------------------------------------------------------
1376
1377ifeq ($(HOST_OS),Darwin)
1378ifdef TOOL_INFO_PLIST
1379
1380LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1381
1382$(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1383
1384$(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
1385        $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1386        $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1387                   -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1388                   -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1389                 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1390                   $< > $@
1391
1392endif
1393endif
1394
1395#---------------------------------------------------------
1396# Provide targets for building the tools
1397#---------------------------------------------------------
1398all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
1399
1400clean-local::
1401ifneq ($(strip $(ToolBuildPath)),)
1402        -$(Verb) $(RM) -f $(ToolBuildPath)
1403endif
1404ifneq ($(strip $(ToolAliasBuildPath)),)
1405        -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1406endif
1407
1408ifdef EXAMPLE_TOOL
1409$(ToolBuildPath): $(ExmplDir)/.dir
1410else
1411$(ToolBuildPath): $(ToolDir)/.dir
1412endif
1413
1414ifdef CODESIGN_TOOLS
1415TOOL_CODESIGN_IDENTITY ?= -
1416
1417$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1418        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1419        $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1420        $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1421        $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1422          $(StripWarnMsg)
1423        $(Echo) ======= Code-Signing $(BuildMode) Executable $(TOOLNAME)
1424        $(Verb) codesign -s $(TOOL_CODESIGN_IDENTITY) $@
1425else
1426$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1427        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
1428        $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
1429        $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1430        $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1431          $(StripWarnMsg)
1432endif
1433
1434ifneq ($(strip $(ToolAliasBuildPath)),)
1435$(ToolAliasBuildPath): $(ToolBuildPath)
1436        $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1437        $(Verb) $(RM) -f $(ToolAliasBuildPath)
1438        $(Verb) $(AliasTool) $(notdir $(ToolBuildPath)) $(ToolAliasBuildPath)
1439        $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
1440          $(StripWarnMsg)
1441endif
1442
1443ifdef NO_INSTALL
1444install-local::
1445        $(Echo) Install circumvented with NO_INSTALL
1446uninstall-local::
1447        $(Echo) Uninstall circumvented with NO_INSTALL
1448else
1449
1450ifdef INTERNAL_TOOL
1451ToolBinDir = $(DESTDIR)$(PROJ_internal_prefix)/bin
1452else
1453ToolBinDir = $(DESTDIR)$(PROJ_bindir)
1454endif
1455DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
1456
1457install-local:: $(DestTool)
1458
1459$(DestTool): $(ToolBuildPath)
1460        $(Echo) Installing $(BuildMode) $(DestTool)
1461        $(Verb) $(MKDIR) $(ToolBinDir)
1462        $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1463
1464uninstall-local::
1465        $(Echo) Uninstalling $(BuildMode) $(DestTool)
1466        -$(Verb) $(RM) -f $(DestTool)
1467
1468# TOOLALIAS install.
1469ifdef TOOLALIAS
1470DestToolAlias = $(ToolBinDir)/$(program_prefix)$(TOOLALIAS)$(EXEEXT)
1471
1472install-local:: $(DestToolAlias)
1473
1474$(DestToolAlias): $(DestTool)
1475        $(Echo) Installing $(BuildMode) $(DestToolAlias)
1476        $(Verb) $(RM) -f $(DestToolAlias)
1477        $(Verb) $(AliasTool) $(notdir $(DestTool)) $(DestToolAlias)
1478
1479uninstall-local::
1480        $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1481        -$(Verb) $(RM) -f $(DestToolAlias)
1482endif
1483
1484endif
1485endif
1486
1487###############################################################################
1488# Object Build Rules: Build object files based on sources
1489###############################################################################
1490
1491# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1492ifeq ($(HOST_OS),HP-UX)
1493  DISABLE_AUTO_DEPENDENCIES=1
1494endif
1495
1496COMPILE_DEPS = $(OBJECT_DIRS) $(BUILT_SOURCES) $(PROJ_MAKEFILE)
1497
1498# Provide rule sets for when dependency generation is enabled
1499ifndef DISABLE_AUTO_DEPENDENCIES
1500
1501#---------------------------------------------------------
1502# Create .o files in the ObjDir directory from the .cpp and .c files...
1503#---------------------------------------------------------
1504
1505DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1506         -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
1507
1508# If the build succeeded, move the dependency file over, otherwise
1509# remove it.
1510DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1511                  else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1512
1513$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1514        $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1515        $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1516                $(DEPEND_MOVEFILE)
1517
1518$(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1519        $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1520        $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1521                $(DEPEND_MOVEFILE)
1522
1523$(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1524        $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1525        $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1526                $(DEPEND_MOVEFILE)
1527
1528$(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1529        $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1530        $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1531                $(DEPEND_MOVEFILE)
1532
1533$(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1534        $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1535        $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1536                $(DEPEND_MOVEFILE)
1537
1538# Provide alternate rule sets if dependencies are disabled
1539else
1540
1541$(ObjDir)/%.o: %.cpp $(COMPILE_DEPS)
1542        $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1543        $(Compile.CXX) $< -o $@
1544
1545$(ObjDir)/%.o: %.mm $(COMPILE_DEPS)
1546        $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1547        $(Compile.CXX) $< -o $@
1548
1549$(ObjDir)/%.o: %.cc $(COMPILE_DEPS)
1550        $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1551        $(Compile.CXX) $< -o $@
1552
1553$(ObjDir)/%.o: %.c $(COMPILE_DEPS)
1554        $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1555        $(Compile.C) $< -o $@
1556
1557$(ObjDir)/%.o: %.m $(COMPILE_DEPS)
1558        $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1559        $(Compile.C) $< -o $@
1560endif
1561
1562
1563## Rules for building preprocessed (.i/.ii) outputs.
1564$(BuildMode)/%.ii: %.cpp $(COMPILE_DEPS)
1565        $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1566        $(Verb) $(Preprocess.CXX) $< -o $@
1567
1568$(BuildMode)/%.ii: %.mm $(COMPILE_DEPS)
1569        $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1570        $(Verb) $(Preprocess.CXX) $< -o $@
1571
1572$(BuildMode)/%.ii: %.cc $(COMPILE_DEPS)
1573        $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1574        $(Verb) $(Preprocess.CXX) $< -o $@
1575
1576$(BuildMode)/%.i: %.c $(COMPILE_DEPS)
1577        $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1578        $(Verb) $(Preprocess.C) $< -o $@
1579
1580$(BuildMode)/%.i: %.m $(COMPILE_DEPS)
1581        $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1582        $(Verb) $(Preprocess.C) $< -o $@
1583
1584
1585$(ObjDir)/%.s: %.cpp $(COMPILE_DEPS)
1586        $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1587        $(Compile.CXX) $< -o $@ -S
1588
1589$(ObjDir)/%.s: %.mm $(COMPILE_DEPS)
1590        $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1591        $(Compile.CXX) $< -o $@ -S
1592
1593$(ObjDir)/%.s: %.cc $(COMPILE_DEPS)
1594        $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1595        $(Compile.CXX) $< -o $@ -S
1596
1597$(ObjDir)/%.s: %.c $(COMPILE_DEPS)
1598        $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1599        $(Compile.C) $< -o $@ -S
1600
1601$(ObjDir)/%.s: %.m $(COMPILE_DEPS)
1602        $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1603        $(Compile.C) $< -o $@ -S
1604
1605###############################################################################
1606# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1607###############################################################################
1608
1609ifdef TARGET
1610TABLEGEN_INC_FILES_COMMON = 1
1611endif
1612
1613ifdef TABLEGEN_INC_FILES_COMMON
1614
1615INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1616INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1617.PRECIOUS: $(INCTMPFiles) $(INCFiles)
1618
1619# INCFiles rule: All of the tblgen generated files are emitted to
1620# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
1621# us to only "touch" the real file if the contents of it change.  IOW, if
1622# tblgen is modified, all of the .inc.tmp files are regenerated, but no
1623# dependencies of the .inc files are, unless the contents of the .inc file
1624# changes.
1625$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1626        $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1627
1628endif # TABLEGEN_INC_FILES_COMMON
1629
1630ifdef TARGET
1631
1632TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1633           $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1634           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1635           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1636           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1637           $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1638           $(wildcard $(LLVM_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
1639
1640# All .inc.tmp files depend on the .td files.
1641$(INCTMPFiles) : $(TDFiles)
1642
1643$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1644$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1645        $(Echo) "Building $(<F) register info implementation with tblgen"
1646        $(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
1647
1648$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1649$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1650        $(Echo) "Building $(<F) instruction information with tblgen"
1651        $(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
1652
1653$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1654$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1655        $(Echo) "Building $(<F) assembly writer with tblgen"
1656        $(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
1657
1658$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1659$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1660        $(Echo) "Building $(<F) assembly writer #1 with tblgen"
1661        $(Verb) $(LLVMTableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
1662
1663$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1664$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1665        $(Echo) "Building $(<F) assembly matcher with tblgen"
1666        $(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1667
1668$(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1669$(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1670        $(Echo) "Building $(<F) MC code emitter with tblgen"
1671        $(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
1672
1673$(TARGET:%=$(ObjDir)/%GenMCPseudoLowering.inc.tmp): \
1674$(ObjDir)/%GenMCPseudoLowering.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1675        $(Echo) "Building $(<F) MC Pseudo instruction expander with tblgen"
1676        $(Verb) $(LLVMTableGen) -gen-pseudo-lowering -o $(call SYSPATH, $@) $<
1677
1678$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1679$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1680        $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
1681        $(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
1682
1683$(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1684$(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1685        $(Echo) "Building $(<F) disassembly tables with tblgen"
1686        $(Verb) $(LLVMTableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1687
1688$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1689$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1690        $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1691        $(Verb) $(LLVMTableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1692
1693$(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
1694$(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1695        $(Echo) "Building $(<F) subtarget information with tblgen"
1696        $(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
1697
1698$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1699$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1700        $(Echo) "Building $(<F) calling convention information with tblgen"
1701        $(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
1702
1703$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1704$(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1705        $(Echo) "Building $(<F) intrinsics information with tblgen"
1706        $(Verb) $(LLVMTableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1707
1708$(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1709        $(Echo) "Building $(<F) decoder tables with tblgen"
1710        $(Verb) $(LLVMTableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1711
1712$(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
1713        $(Echo) "Building $(<F) DFA packetizer tables with tblgen"
1714        $(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
1715
1716# Dump all the records to <target>.td.expanded.  This is useful for debugging.
1717$(TARGET:%=%.td.expanded): \
1718%.td.expanded : %.td $(LLVM_TBLGEN) $(TDFiles)
1719        $(Echo) "Building a fully expanded version of $(<F)"
1720        $(Verb) $(LLVMTableGen) -o $(call SYSPATH, $@) $<
1721
1722clean-local::
1723        -$(Verb) $(RM) -f $(INCFiles) $(TARGET).td.expanded
1724
1725endif # TARGET
1726
1727###############################################################################
1728# OTHER RULES: Other rules needed
1729###############################################################################
1730
1731# To create postscript files from dot files...
1732ifneq ($(DOT),false)
1733%.ps: %.dot
1734        $(DOT) -Tps < $< > $@
1735else
1736%.ps: %.dot
1737        $(Echo) "Cannot build $@: The program dot is not installed"
1738endif
1739
1740# This rules ensures that header files that are removed still have a rule for
1741# which they can be "generated."  This allows make to ignore them and
1742# reproduce the dependency lists.
1743%.h:: ;
1744%.hpp:: ;
1745
1746# Define clean-local to clean the current directory. Note that this uses a
1747# very conservative approach ensuring that empty variables do not cause
1748# errors or disastrous removal.
1749clean-local::
1750ifneq ($(strip $(ObjRootDir)),)
1751        -$(Verb) $(RM) -rf $(ObjRootDir)
1752endif
1753ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1754        -$(Verb) $(RM) -f *$(SHLIBEXT)
1755endif
1756
1757clean-all-local::
1758        -$(Verb) $(RM) -rf Debug Release Profile
1759
1760
1761###############################################################################
1762# DEPENDENCIES: Include the dependency files if we should
1763###############################################################################
1764ifndef DISABLE_AUTO_DEPENDENCIES
1765
1766# If its not one of the cleaning targets
1767ifndef IS_CLEANING_TARGET
1768
1769# Get the list of dependency files
1770DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
1771DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1772
1773-include $(DependFiles) ""
1774
1775endif
1776
1777endif
1778
1779###############################################################################
1780# CHECK: Running the test suite
1781###############################################################################
1782
1783check::
1784        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1785          if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1786            $(EchoCmd) Running test suite ; \
1787            $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1788              TESTSUITE=$(TESTSUITE) ; \
1789          else \
1790            $(EchoCmd) No Makefile in test directory ; \
1791          fi ; \
1792        else \
1793          $(EchoCmd) No test directory ; \
1794        fi
1795
1796# An alias dating from when both lit and DejaGNU test runners were used.
1797check-lit:: check
1798
1799check-all::
1800        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1801          if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1802            $(EchoCmd) Running test suite ; \
1803            $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1804          else \
1805            $(EchoCmd) No Makefile in test directory ; \
1806          fi ; \
1807        else \
1808          $(EchoCmd) No test directory ; \
1809        fi
1810
1811###############################################################################
1812# UNITTESTS: Running the unittests test suite
1813###############################################################################
1814
1815unittests::
1816        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1817          if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1818            $(EchoCmd) Running unittests test suite ; \
1819            $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
1820          else \
1821            $(EchoCmd) No Makefile in unittests directory ; \
1822          fi ; \
1823        else \
1824          $(EchoCmd) No unittests directory ; \
1825        fi
1826
1827###############################################################################
1828# DISTRIBUTION: Handle construction of a distribution tarball
1829###############################################################################
1830
1831#------------------------------------------------------------------------
1832# Define distribution related variables
1833#------------------------------------------------------------------------
1834DistName    := $(PROJECT_NAME)-$(PROJ_VERSION)
1835DistDir     := $(PROJ_OBJ_ROOT)/$(DistName)
1836TopDistDir  := $(PROJ_OBJ_ROOT)/$(DistName)
1837DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1838DistZip     := $(PROJ_OBJ_ROOT)/$(DistName).zip
1839DistTarBZ2  := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1840DistAlways  := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1841               ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1842               Makefile.config.in configure autoconf
1843DistOther   := $(notdir $(wildcard \
1844               $(PROJ_SRC_DIR)/*.h \
1845               $(PROJ_SRC_DIR)/*.td \
1846               $(PROJ_SRC_DIR)/*.def \
1847               $(PROJ_SRC_DIR)/*.ll \
1848               $(PROJ_SRC_DIR)/*.in))
1849DistSubDirs := $(SubDirs)
1850DistSources  = $(Sources) $(EXTRA_DIST)
1851DistFiles    = $(DistAlways) $(DistSources) $(DistOther)
1852
1853#------------------------------------------------------------------------
1854# We MUST build distribution with OBJ_DIR != SRC_DIR
1855#------------------------------------------------------------------------
1856ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1857dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1858        $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1859
1860else
1861
1862#------------------------------------------------------------------------
1863# Prevent attempt to run dist targets from anywhere but the top level
1864#------------------------------------------------------------------------
1865ifneq ($(LEVEL),.)
1866dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1867        $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1868else
1869
1870#------------------------------------------------------------------------
1871# Provide the top level targets
1872#------------------------------------------------------------------------
1873
1874dist-gzip:: $(DistTarGZip)
1875
1876$(DistTarGZip) : $(TopDistDir)/.makedistdir
1877        $(Echo) Packing gzipped distribution tar file.
1878        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1879          $(GZIP) -c > "$(DistTarGZip)"
1880
1881dist-bzip2:: $(DistTarBZ2)
1882
1883$(DistTarBZ2) : $(TopDistDir)/.makedistdir
1884        $(Echo) Packing bzipped distribution tar file.
1885        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1886          $(BZIP2) -c >$(DistTarBZ2)
1887
1888dist-zip:: $(DistZip)
1889
1890$(DistZip) : $(TopDistDir)/.makedistdir
1891        $(Echo) Packing zipped distribution file.
1892        $(Verb) rm -f $(DistZip)
1893        $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1894
1895dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
1896        $(Echo) ===== DISTRIBUTION PACKAGING SUCCESSFUL =====
1897
1898DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1899
1900dist-check:: $(DistTarGZip)
1901        $(Echo) Checking distribution tar file.
1902        $(Verb) if test -d $(DistCheckDir) ; then \
1903          $(RM) -rf $(DistCheckDir) ; \
1904        fi
1905        $(Verb) $(MKDIR) $(DistCheckDir)
1906        $(Verb) cd $(DistCheckDir) && \
1907          $(MKDIR) $(DistCheckDir)/build && \
1908          $(MKDIR) $(DistCheckDir)/install && \
1909          gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1910          cd build && \
1911          ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1912            --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1913          $(MAKE) all && \
1914          $(MAKE) check && \
1915          $(MAKE) unittests && \
1916          $(MAKE) install && \
1917          $(MAKE) uninstall && \
1918          $(MAKE) dist-clean && \
1919          $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1920
1921dist-clean::
1922        $(Echo) Cleaning distribution files
1923        -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1924          $(DistCheckDir)
1925
1926endif
1927
1928#------------------------------------------------------------------------
1929# Provide the recursive distdir target for building the distribution directory
1930#------------------------------------------------------------------------
1931distdir: $(DistDir)/.makedistdir
1932$(DistDir)/.makedistdir: $(DistSources)
1933        $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1934          if test -d "$(DistDir)" ; then \
1935            find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';'  || \
1936              exit 1 ; \
1937          fi ; \
1938          $(EchoCmd) Removing old $(DistDir) ; \
1939          $(RM) -rf $(DistDir); \
1940          $(EchoCmd) Making 'all' to verify build ; \
1941          $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1942        fi
1943        $(Echo) Building Distribution Directory $(DistDir)
1944        $(Verb) $(MKDIR) $(DistDir)
1945        $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1946        srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1947        for file in $(DistFiles) ; do \
1948          case "$$file" in \
1949            $(PROJ_SRC_DIR)/*) \
1950              file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1951              ;; \
1952            $(PROJ_SRC_ROOT)/*) \
1953              file=`echo "$$file" | \
1954                sed "s#^$$srcrootstrip/##"` \
1955              ;; \
1956          esac; \
1957          if test -f "$(PROJ_SRC_DIR)/$$file" || \
1958             test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1959            from_dir="$(PROJ_SRC_DIR)" ; \
1960          elif test -f "$$file" || test -d "$$file" ; then \
1961            from_dir=. ; \
1962          fi ; \
1963          to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1964          if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1965            to_dir="$(DistDir)/$$dir"; \
1966            $(MKDIR) "$$to_dir" ; \
1967          else \
1968            to_dir="$(DistDir)"; \
1969          fi; \
1970          mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1971          if test -n "$$mid_dir" ; then \
1972            $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1973          fi ; \
1974          if test -d "$$from_dir/$$file"; then \
1975            if test -d "$(PROJ_SRC_DIR)/$$file" && \
1976               test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1977               cd $(PROJ_SRC_DIR) ; \
1978               $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1979                 ( cd $$to_dir ; $(TAR) xf - ) ; \
1980               cd $(PROJ_OBJ_DIR) ; \
1981            else \
1982               cd $$from_dir ; \
1983               $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1984                 ( cd $$to_dir ; $(TAR) xf - ) ; \
1985               cd $(PROJ_OBJ_DIR) ; \
1986            fi; \
1987          elif test -f "$$from_dir/$$file" ; then \
1988            $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1989          elif test -L "$$from_dir/$$file" ; then \
1990            $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1991          elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1992            $(EchoCmd) "===== WARNING: Distribution Source " \
1993              "$$from_dir/$$file Not Found!" ; \
1994          elif test "$(Verb)" != '@' ; then \
1995            $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1996          fi; \
1997        done
1998        $(Verb) for subdir in $(DistSubDirs) ; do \
1999          if test "$$subdir" \!= "." ; then \
2000            new_distdir="$(DistDir)/$$subdir" ; \
2001            test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
2002            ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
2003              DistDir="$$new_distdir" distdir ) || exit 1; \
2004          fi; \
2005        done
2006        $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
2007          $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
2008          $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2009                                  -name .svn \) -print` ;\
2010          $(MAKE) dist-hook ; \
2011          $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2012            -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2013            -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2014            -o ! -type d ! -perm -444 -exec \
2015              $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2016            || chmod -R a+r $(DistDir) ; \
2017        fi
2018
2019# This is invoked by distdir target, define it as a no-op to avoid errors if not
2020# defined by user.
2021dist-hook::
2022
2023endif
2024
2025###############################################################################
2026# TOP LEVEL - targets only to apply at the top level directory
2027###############################################################################
2028
2029ifeq ($(LEVEL),.)
2030
2031#------------------------------------------------------------------------
2032# Install support for the project's include files:
2033#------------------------------------------------------------------------
2034ifdef NO_INSTALL
2035install-local::
2036        $(Echo) Install circumvented with NO_INSTALL
2037uninstall-local::
2038        $(Echo) Uninstall circumvented with NO_INSTALL
2039else
2040install-local::
2041        $(Echo) Installing include files
2042        $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
2043        $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
2044          cd $(PROJ_SRC_ROOT)/include && \
2045          for hdr in `find . -type f \
2046              '(' -name LICENSE.TXT \
2047               -o -name '*.def' \
2048               -o -name '*.h' \
2049               -o -name '*.inc' \
2050               -o -name '*.td' \
2051              ')' -print | grep -v CVS | \
2052              grep -v .svn` ; do \
2053            instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2054            if test \! -d "$$instdir" ; then \
2055              $(EchoCmd) Making install directory $$instdir ; \
2056              $(MKDIR) $$instdir ;\
2057            fi ; \
2058            $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2059          done ; \
2060        fi
2061ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
2062        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
2063          cd $(PROJ_OBJ_ROOT)/include && \
2064          for hdr in `find . -type f \
2065              '(' -name LICENSE.TXT \
2066               -o -name '*.def' \
2067               -o -name '*.h' \
2068               -o -name '*.inc' \
2069               -o -name '*.td' \
2070              ')' -print | grep -v CVS | \
2071              grep -v .svn` ; do \
2072            instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
2073            if test \! -d "$$instdir" ; then \
2074              $(EchoCmd) Making install directory $$instdir ; \
2075              $(MKDIR) $$instdir ;\
2076            fi ; \
2077            $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
2078          done ; \
2079        fi
2080endif
2081
2082uninstall-local::
2083        $(Echo) Uninstalling include files
2084        $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2085          cd $(PROJ_SRC_ROOT)/include && \
2086            $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
2087              '!' '(' -name '*~' -o -name '.#*' \
2088        -o -name '*.in' ')' -print ')' | \
2089        grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2090          cd $(PROJ_SRC_ROOT)/include && \
2091            $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
2092      -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
2093        fi
2094endif
2095endif
2096
2097check-line-length:
2098        @echo searching for overlength lines in files: $(Sources)
2099        @echo
2100        @echo
2101        egrep -n '.{81}' $(Sources) /dev/null
2102
2103check-for-tabs:
2104        @echo searching for tabs in files: $(Sources)
2105        @echo
2106        @echo
2107        egrep -n '      ' $(Sources) /dev/null
2108
2109check-footprint:
2110        @ls -l $(LibDir) | awk '\
2111          BEGIN { sum = 0; } \
2112                { sum += $$5; } \
2113          END   { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2114        @ls -l $(ToolDir) | awk '\
2115          BEGIN { sum = 0; } \
2116                { sum += $$5; } \
2117          END   { printf("Programs:  %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2118#------------------------------------------------------------------------
2119# Print out the directories used for building
2120#------------------------------------------------------------------------
2121printvars::
2122        $(Echo) "BuildMode    : " '$(BuildMode)'
2123        $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2124        $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2125        $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2126        $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2127        $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2128        $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2129        $(Echo) "PROJ_prefix  : " '$(PROJ_prefix)'
2130        $(Echo) "PROJ_internal_prefix  : " '$(PROJ_internal_prefix)'
2131        $(Echo) "PROJ_bindir  : " '$(PROJ_bindir)'
2132        $(Echo) "PROJ_libdir  : " '$(PROJ_libdir)'
2133        $(Echo) "PROJ_etcdir  : " '$(PROJ_etcdir)'
2134        $(Echo) "PROJ_includedir  : " '$(PROJ_includedir)'
2135        $(Echo) "UserTargets  : " '$(UserTargets)'
2136        $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2137        $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2138        $(Echo) "ObjDir       : " '$(ObjDir)'
2139        $(Echo) "LibDir       : " '$(LibDir)'
2140        $(Echo) "ToolDir      : " '$(ToolDir)'
2141        $(Echo) "ExmplDir     : " '$(ExmplDir)'
2142        $(Echo) "Sources      : " '$(Sources)'
2143        $(Echo) "TDFiles      : " '$(TDFiles)'
2144        $(Echo) "INCFiles     : " '$(INCFiles)'
2145        $(Echo) "INCTMPFiles  : " '$(INCTMPFiles)'
2146        $(Echo) "PreConditions: " '$(PreConditions)'
2147        $(Echo) "Compile.CXX  : " '$(Compile.CXX)'
2148        $(Echo) "Compile.C    : " '$(Compile.C)'
2149        $(Echo) "Archive      : " '$(Archive)'
2150        $(Echo) "YaccFiles    : " '$(YaccFiles)'
2151        $(Echo) "LexFiles     : " '$(LexFiles)'
2152        $(Echo) "Module       : " '$(Module)'
2153        $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
2154        $(Echo) "SubDirs      : " '$(SubDirs)'
2155        $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2156        $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
2157
2158###
2159# Debugging
2160
2161# General debugging rule, use 'make dbg-print-XXX' to print the
2162# definition, value and origin of XXX.
2163make-print-%:
2164        $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))
Note: See TracBrowser for help on using the repository browser.