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