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