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