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