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