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