1# Copyright (C) 2009 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15# Common definitions for the Android NDK build system 16# 17 18# We use the GNU Make Standard Library 19include $(NDK_ROOT)/build/gmsl/gmsl 20 21include $(BUILD_SYSTEM)/definitions-tests.mk 22include $(BUILD_SYSTEM)/definitions-utils.mk 23include $(BUILD_SYSTEM)/definitions-host.mk 24include $(BUILD_SYSTEM)/definitions-graph.mk 25 26# ----------------------------------------------------------------------------- 27# Macro : this-makefile 28# Returns : the name of the current Makefile in the inclusion stack 29# Usage : $(this-makefile) 30# ----------------------------------------------------------------------------- 31this-makefile = $(lastword $(MAKEFILE_LIST)) 32 33# ----------------------------------------------------------------------------- 34# Macro : local-makefile 35# Returns : the name of the last parsed Android.mk file 36# Usage : $(local-makefile) 37# ----------------------------------------------------------------------------- 38local-makefile = $(lastword $(filter %Android.mk,$(MAKEFILE_LIST))) 39 40# ----------------------------------------------------------------------------- 41# Function : assert-defined 42# Arguments: 1: list of variable names 43# Returns : None 44# Usage : $(call assert-defined, VAR1 VAR2 VAR3...) 45# Rationale: Checks that all variables listed in $1 are defined, or abort the 46# build 47# ----------------------------------------------------------------------------- 48assert-defined = $(foreach __varname,$(strip $1),\ 49 $(if $(strip $($(__varname))),,\ 50 $(call __ndk_error, Assertion failure: $(__varname) is not defined)\ 51 )\ 52) 53 54# ----------------------------------------------------------------------------- 55# Function : check-required-vars 56# Arguments: 1: list of variable names 57# 2: file where the variable(s) should be defined 58# Returns : None 59# Usage : $(call check-required-vars, VAR1 VAR2 VAR3..., <file>) 60# Rationale: Checks that all required vars listed in $1 were defined by $2 61# or abort the build with an error 62# ----------------------------------------------------------------------------- 63check-required-vars = $(foreach __varname,$1,\ 64 $(if $(strip $($(__varname))),,\ 65 $(call __ndk_info, Required variable $(__varname) is not defined by $2)\ 66 $(call __ndk_error,Aborting)\ 67 )\ 68) 69 70# The list of default C++ extensions supported by GCC. 71default-c++-extensions := .cc .cp .cxx .cpp .CPP .c++ .C 72 73# The list of default RS extensions supported by llvm-rs-cc 74default-rs-extensions := .rs .fs 75 76# ----------------------------------------------------------------------------- 77# Function : generate-dir 78# Arguments: 1: directory path 79# Returns : Generate a rule, but not dependency, to create a directory with 80# host-mkdir. 81# Usage : $(call generate-dir,<path>) 82# ----------------------------------------------------------------------------- 83define ev-generate-dir 84__ndk_dir := $1 85ifeq (,$$(__ndk_dir_flag__$$(__ndk_dir))) 86# Note that the following doesn't work because path in windows may contain 87# ':' if ndk-build is called inside jni/ directory when path is expanded 88# to full-path, eg. C:/path/to/project/jni/ 89# 90# __ndk_dir_flag__$1 := true 91# 92__ndk_dir_flag__$$(__ndk_dir) := true 93$1: 94 @$$(call host-mkdir,$$@) 95endif 96endef 97 98generate-dir = $(eval $(call ev-generate-dir,$1)) 99 100# ----------------------------------------------------------------------------- 101# Function : generate-file-dir 102# Arguments: 1: file path 103# Returns : Generate a dependency and a rule to ensure that the parent 104# directory of the input file path will be created before it. 105# This is used to enforce a call to host-mkdir. 106# Usage : $(call generate-file-dir,<file>) 107# Rationale: Many object files will be stored in the same output directory. 108# Introducing a dependency on the latter avoids calling mkdir -p 109# for every one of them. 110# 111# ----------------------------------------------------------------------------- 112 113define ev-generate-file-dir 114__ndk_file_dir := $(call parent-dir,$1) 115$$(call generate-dir,$$(__ndk_file_dir)) 116$1:| $$(__ndk_file_dir) 117endef 118 119generate-file-dir = $(eval $(call ev-generate-file-dir,$1)) 120 121# ----------------------------------------------------------------------------- 122# Function : generate-list-file 123# Arguments: 1: list of strings (possibly very long) 124# 2: file name 125# Returns : write the content of a possibly very long string list to a file. 126# this shall be used in commands and will work around limitations 127# of host command-line lengths. 128# Usage : $(call host-echo-to-file,<string-list>,<file>) 129# Rationale: When there is a very large number of objects and/or libraries at 130# link time, the size of the command becomes too large for the 131# host system's maximum. Various tools however support the 132# @<listfile> syntax, where <listfile> is the path of a file 133# which content will be parsed as if they were options. 134# 135# This function is used to generate such a list file from a long 136# list of strings in input. 137# 138# ----------------------------------------------------------------------------- 139 140# Helper functions because the GNU Make $(word ...) function does 141# not accept a 0 index, so we need to bump any of these to 1 when 142# we find them. 143# 144index-is-zero = $(filter 0 00 000 0000 00000 000000 0000000,$1) 145bump-0-to-1 = $(if $(call index-is-zero,$1),1,$1) 146 147-test-bump-0-to-1 = \ 148 $(call test-expect,$(call bump-0-to-1))\ 149 $(call test-expect,1,$(call bump-0-to-1,0))\ 150 $(call test-expect,1,$(call bump-0-to-1,1))\ 151 $(call test-expect,2,$(call bump-0-to-1,2))\ 152 $(call test-expect,1,$(call bump-0-to-1,00))\ 153 $(call test-expect,1,$(call bump-0-to-1,000))\ 154 $(call test-expect,1,$(call bump-0-to-1,0000))\ 155 $(call test-expect,1,$(call bump-0-to-1,00000))\ 156 $(call test-expect,1,$(call bump-0-to-1,000000))\ 157 $(call test-expect,10,$(call bump-0-to-1,10))\ 158 $(call test-expect,100,$(call bump-0-to-1,100)) 159 160# Same as $(wordlist ...) except the start index, if 0, is bumped to 1 161index-word-list = $(wordlist $(call bump-0-to-1,$1),$2,$3) 162 163-test-index-word-list = \ 164 $(call test-expect,,$(call index-word-list,1,1))\ 165 $(call test-expect,a b,$(call index-word-list,0,2,a b c d))\ 166 $(call test-expect,b c,$(call index-word-list,2,3,a b c d))\ 167 168# NOTE: With GNU Make $1 and $(1) are equivalent, which means 169# that $10 is equivalent to $(1)0, and *not* $(10). 170 171# Used to generate a slice of up to 10 items starting from index $1, 172# If $1 is 0, it will be bumped to 1 (and only 9 items will be printed) 173# $1: start (tenth) index. Can be 0 174# $2: word list 175# 176define list-file-start-gen-10 177 $$(hide) $$(HOST_ECHO_N) "$(call index-word-list,$10,$19,$2) " >> $$@ 178endef 179 180# Used to generate a slice of always 10 items starting from index $1 181# $1: start (tenth) index. CANNOT BE 0 182# $2: word list 183define list-file-always-gen-10 184 $$(hide) $$(HOST_ECHO_N) "$(wordlist $10,$19,$2) " >> $$@ 185endef 186 187# Same as list-file-always-gen-10, except that the word list might be 188# empty at position $10 (i.e. $(1)0) 189define list-file-maybe-gen-10 190ifneq ($(word $10,$2),) 191 $$(hide) $$(HOST_ECHO_N) "$(wordlist $10,$19,$2) " >> $$@ 192endif 193endef 194 195define list-file-start-gen-100 196$(call list-file-start-gen-10,$10,$2) 197$(call list-file-always-gen-10,$11,$2) 198$(call list-file-always-gen-10,$12,$2) 199$(call list-file-always-gen-10,$13,$2) 200$(call list-file-always-gen-10,$14,$2) 201$(call list-file-always-gen-10,$15,$2) 202$(call list-file-always-gen-10,$16,$2) 203$(call list-file-always-gen-10,$17,$2) 204$(call list-file-always-gen-10,$18,$2) 205$(call list-file-always-gen-10,$19,$2) 206endef 207 208define list-file-always-gen-100 209$(call list-file-always-gen-10,$10,$2) 210$(call list-file-always-gen-10,$11,$2) 211$(call list-file-always-gen-10,$12,$2) 212$(call list-file-always-gen-10,$13,$2) 213$(call list-file-always-gen-10,$14,$2) 214$(call list-file-always-gen-10,$15,$2) 215$(call list-file-always-gen-10,$16,$2) 216$(call list-file-always-gen-10,$17,$2) 217$(call list-file-always-gen-10,$18,$2) 218$(call list-file-always-gen-10,$19,$2) 219endef 220 221define list-file-maybe-gen-100 222ifneq ($(word $(call bump-0-to-1,$100),$2),) 223ifneq ($(word $199,$2),) 224$(call list-file-start-gen-10,$10,$2) 225$(call list-file-always-gen-10,$11,$2) 226$(call list-file-always-gen-10,$12,$2) 227$(call list-file-always-gen-10,$13,$2) 228$(call list-file-always-gen-10,$14,$2) 229$(call list-file-always-gen-10,$15,$2) 230$(call list-file-always-gen-10,$16,$2) 231$(call list-file-always-gen-10,$17,$2) 232$(call list-file-always-gen-10,$18,$2) 233$(call list-file-always-gen-10,$19,$2) 234else 235ifneq ($(word $150,$2),) 236$(call list-file-start-gen-10,$10,$2) 237$(call list-file-always-gen-10,$11,$2) 238$(call list-file-always-gen-10,$12,$2) 239$(call list-file-always-gen-10,$13,$2) 240$(call list-file-always-gen-10,$14,$2) 241$(call list-file-maybe-gen-10,$15,$2) 242$(call list-file-maybe-gen-10,$16,$2) 243$(call list-file-maybe-gen-10,$17,$2) 244$(call list-file-maybe-gen-10,$18,$2) 245$(call list-file-maybe-gen-10,$19,$2) 246else 247$(call list-file-start-gen-10,$10,$2) 248$(call list-file-maybe-gen-10,$11,$2) 249$(call list-file-maybe-gen-10,$12,$2) 250$(call list-file-maybe-gen-10,$13,$2) 251$(call list-file-maybe-gen-10,$14,$2) 252endif 253endif 254endif 255endef 256 257define list-file-maybe-gen-1000 258ifneq ($(word $(call bump-0-to-1,$1000),$2),) 259ifneq ($(word $1999,$2),) 260$(call list-file-start-gen-100,$10,$2) 261$(call list-file-always-gen-100,$11,$2) 262$(call list-file-always-gen-100,$12,$2) 263$(call list-file-always-gen-100,$13,$2) 264$(call list-file-always-gen-100,$14,$2) 265$(call list-file-always-gen-100,$15,$2) 266$(call list-file-always-gen-100,$16,$2) 267$(call list-file-always-gen-100,$17,$2) 268$(call list-file-always-gen-100,$18,$2) 269$(call list-file-always-gen-100,$19,$2) 270else 271ifneq ($(word $1500,$2),) 272$(call list-file-start-gen-100,$10,$2) 273$(call list-file-always-gen-100,$11,$2) 274$(call list-file-always-gen-100,$12,$2) 275$(call list-file-always-gen-100,$13,$2) 276$(call list-file-always-gen-100,$14,$2) 277$(call list-file-maybe-gen-100,$15,$2) 278$(call list-file-maybe-gen-100,$16,$2) 279$(call list-file-maybe-gen-100,$17,$2) 280$(call list-file-maybe-gen-100,$18,$2) 281$(call list-file-maybe-gen-100,$19,$2) 282else 283$(call list-file-start-gen-100,$10,$2) 284$(call list-file-maybe-gen-100,$11,$2) 285$(call list-file-maybe-gen-100,$12,$2) 286$(call list-file-maybe-gen-100,$13,$2) 287$(call list-file-maybe-gen-100,$14,$2) 288endif 289endif 290endif 291endef 292 293 294define generate-list-file-ev 295__list_file := $2 296 297.PHONY: $$(__list_file).tmp 298 299$$(call generate-file-dir,$$(__list_file).tmp) 300 301$$(__list_file).tmp: 302 $$(hide) $$(HOST_ECHO_N) "" > $$@ 303$(call list-file-maybe-gen-1000,0,$1) 304$(call list-file-maybe-gen-1000,1,$1) 305$(call list-file-maybe-gen-1000,2,$1) 306$(call list-file-maybe-gen-1000,3,$1) 307$(call list-file-maybe-gen-1000,4,$1) 308$(call list-file-maybe-gen-1000,5,$1) 309 310$$(__list_file): $$(__list_file).tmp 311 $$(hide) $$(call host-copy-if-differ,$$@.tmp,$$@) 312 $$(hide) $$(call host-rm,$$@.tmp) 313 314endef 315 316generate-list-file = $(eval $(call generate-list-file-ev,$1,$2)) 317 318# ----------------------------------------------------------------------------- 319# Function : link-whole-archives 320# Arguments: 1: list of whole static libraries 321# Returns : linker flags to use the whole static libraries 322# Usage : $(call link-whole-archives,<libraries>) 323# Rationale: This function is used to put the list of whole static libraries 324# inside a -Wl,--whole-archive ... -Wl,--no-whole-archive block. 325# If the list is empty, it returns an empty string. 326# This function also calls host-path to translate the library 327# paths. 328# ----------------------------------------------------------------------------- 329link-whole-archives = $(if $(strip $1),$(call link-whole-archive-flags,$1)) 330link-whole-archive-flags = -Wl,--whole-archive $(call host-path,$1) -Wl,--no-whole-archive 331 332-test-link-whole-archive = \ 333 $(call test-expect,,$(call link-whole-archives))\ 334 $(eval _start := -Wl,--whole-archive)\ 335 $(eval _end := -Wl,--no-whole-archive)\ 336 $(call test-expect,$(_start) foo $(_end),$(call link-whole-archives,foo))\ 337 $(call test-expect,$(_start) foo bar $(_end),$(call link-whole-archives,foo bar)) 338 339# ============================================================================= 340# 341# Modules database 342# 343# The following declarations are used to manage the list of modules 344# defined in application's Android.mk files. 345# 346# Technical note: 347# We use __ndk_modules to hold the list of all modules corresponding 348# to a given application. 349# 350# For each module 'foo', __ndk_modules.foo.<field> is used 351# to store module-specific information. 352# 353# type -> type of module (e.g. 'static', 'shared', ...) 354# depends -> list of other modules this module depends on 355# 356# Also, LOCAL_XXXX values defined for a module are recorded in XXXX, e.g.: 357# 358# PATH -> recorded LOCAL_PATH for the module 359# CFLAGS -> recorded LOCAL_CFLAGS for the module 360# ... 361# 362# Some of these are created by build scripts like BUILD_STATIC_LIBRARY: 363# 364# MAKEFILE -> The Android.mk where the module is defined. 365# LDFLAGS -> Final linker flags 366# OBJECTS -> List of module objects 367# BUILT_MODULE -> location of module built file (e.g. obj/<app>/<abi>/libfoo.so) 368# 369# Note that some modules are never installed (e.g. static libraries). 370# 371# ============================================================================= 372 373# The list of LOCAL_XXXX variables that are recorded for each module definition 374# These are documented by docs/ANDROID-MK.TXT. Exception is LOCAL_MODULE 375# 376modules-LOCALS := \ 377 MODULE \ 378 MODULE_FILENAME \ 379 PATH \ 380 SRC_FILES \ 381 CPP_EXTENSION \ 382 C_INCLUDES \ 383 CFLAGS \ 384 CONLYFLAGS \ 385 CXXFLAGS \ 386 CPPFLAGS \ 387 ASMFLAGS \ 388 STATIC_LIBRARIES \ 389 WHOLE_STATIC_LIBRARIES \ 390 SHARED_LIBRARIES \ 391 LDLIBS \ 392 ALLOW_UNDEFINED_SYMBOLS \ 393 ARM_MODE \ 394 ARM_NEON \ 395 DISABLE_NO_EXECUTE \ 396 DISABLE_RELRO \ 397 DISABLE_FORMAT_STRING_CHECKS \ 398 EXPORT_CFLAGS \ 399 EXPORT_CONLYFLAGS \ 400 EXPORT_CPPFLAGS \ 401 EXPORT_ASMFLAGS \ 402 EXPORT_LDFLAGS \ 403 EXPORT_LDLIBS \ 404 EXPORT_C_INCLUDES \ 405 FILTER_ASM \ 406 CPP_FEATURES \ 407 SHORT_COMMANDS \ 408 BUILT_MODULE_NOT_COPIED \ 409 THIN_ARCHIVE \ 410 PCH \ 411 RENDERSCRIPT_INCLUDES \ 412 RENDERSCRIPT_INCLUDES_OVERRIDE \ 413 RENDERSCRIPT_FLAGS \ 414 RENDERSCRIPT_TARGET_API 415 416# The following are generated by the build scripts themselves 417 418# LOCAL_MAKEFILE will contain the path to the Android.mk defining the module 419modules-LOCALS += MAKEFILE 420 421# LOCAL_LDFLAGS will contain the set of final linker flags for the module 422modules-LOCALS += LDFLAGS 423 424# LOCAL_OBJECTS will contain the list of object files generated from the 425# module's sources, if any. 426modules-LOCALS += OBJECTS 427 428# LOCAL_BUILT_MODULE will contain the location of the symbolic version of 429# the generated module (i.e. the one containing all symbols used during 430# native debugging). It is generally under $PROJECT/obj/local/ 431modules-LOCALS += BUILT_MODULE 432 433# LOCAL_OBJS_DIR will contain the location where the object files for 434# this module will be stored. Usually $PROJECT/obj/local/<module>/obj 435modules-LOCALS += OBJS_DIR 436 437# LOCAL_INSTALLED will contain the location of the installed version 438# of the module. Usually $PROJECT/libs/<abi>/<prefix><module><suffix> 439# where <prefix> and <suffix> depend on the module class. 440modules-LOCALS += INSTALLED 441 442# LOCAL_MODULE_CLASS will contain the type of the module 443# (e.g. STATIC_LIBRARY, SHARED_LIBRARY, etc...) 444modules-LOCALS += MODULE_CLASS 445 446# the list of managed fields per module 447modules-fields = depends \ 448 $(modules-LOCALS) 449 450# ----------------------------------------------------------------------------- 451# Function : modules-clear 452# Arguments: None 453# Returns : None 454# Usage : $(call modules-clear) 455# Rationale: clears the list of defined modules known by the build system 456# ----------------------------------------------------------------------------- 457modules-clear = \ 458 $(foreach __mod,$(__ndk_modules),\ 459 $(foreach __field,$(modules-fields),\ 460 $(eval __ndk_modules.$(__mod).$(__field) := $(empty))\ 461 )\ 462 )\ 463 $(eval __ndk_modules := $(empty_set)) \ 464 $(eval __ndk_top_modules := $(empty)) \ 465 $(eval __ndk_import_list := $(empty)) \ 466 $(eval __ndk_import_depth := $(empty)) 467 468# ----------------------------------------------------------------------------- 469# Function : modules-get-list 470# Arguments: None 471# Returns : The list of all recorded modules 472# Usage : $(call modules-get-list) 473# ----------------------------------------------------------------------------- 474modules-get-list = $(__ndk_modules) 475 476# ----------------------------------------------------------------------------- 477# Function : modules-get-top-list 478# Arguments: None 479# Returns : The list of all recorded non-imported modules 480# Usage : $(call modules-get-top-list) 481# ----------------------------------------------------------------------------- 482modules-get-top-list = $(__ndk_top_modules) 483 484# ----------------------------------------------------------------------------- 485# Function : module-add 486# Arguments: 1: module name 487# Returns : None 488# Usage : $(call module-add,<modulename>) 489# Rationale: add a new module. If it is already defined, print an error message 490# and abort. This will record all LOCAL_XXX variables for the module. 491# ----------------------------------------------------------------------------- 492module-add = \ 493 $(call assert-defined,LOCAL_MAKEFILE LOCAL_BUILT_MODULE LOCAL_OBJS_DIR LOCAL_MODULE_CLASS)\ 494 $(if $(call set_is_member,$(__ndk_modules),$1),\ 495 $(call __ndk_info,Trying to define local module '$1' in $(LOCAL_MAKEFILE).)\ 496 $(call __ndk_info,But this module was already defined by $(__ndk_modules.$1.MAKEFILE).)\ 497 $(call __ndk_error,Aborting.)\ 498 )\ 499 $(eval __ndk_modules := $(call set_insert,$(__ndk_modules),$1))\ 500 $(if $(strip $(__ndk_import_depth)),,\ 501 $(eval __ndk_top_modules := $(call set_insert,$(__ndk_top_modules),$1))\ 502 )\ 503 $(if $(call module-class-is-installable,$(LOCAL_MODULE_CLASS)),\ 504 $(eval LOCAL_INSTALLED := $(NDK_APP_DST_DIR)/$(notdir $(LOCAL_BUILT_MODULE))),\ 505 $(eval LOCAL_INSTALLED := $(LOCAL_BUILT_MODULE))\ 506 )\ 507 $(foreach __field,STATIC_LIBRARIES WHOLE_STATIC_LIBRARIES SHARED_LIBRARIES,\ 508 $(eval LOCAL_$(__field) := $(call strip-lib-prefix,$(LOCAL_$(__field)))))\ 509 $(foreach __local,$(modules-LOCALS),\ 510 $(eval __ndk_modules.$1.$(__local) := $(LOCAL_$(__local)))\ 511 )\ 512 $(call module-handle-c++-features,$1) 513 514 515# Retrieve the class of module $1 516module-get-class = $(__ndk_modules.$1.MODULE_CLASS) 517 518# Retrieve built location of module $1 519module-get-built = $(__ndk_modules.$1.BUILT_MODULE) 520 521# Returns $(true) is module $1 is installable 522# An installable module is one that will be copied to $PROJECT/libs/<abi>/ 523# (e.g. shared libraries). 524# 525module-is-installable = $(call module-class-is-installable,$(call module-get-class,$1)) 526 527# Returns $(true) if module $1 is a copyable prebuilt 528# A copyable prebuilt module is one that will be copied to $NDK_OUT/<abi>/ 529# at build time. At the moment, this is only used for prebuilt shared 530# libraries, since it helps ndk-gdb. 531# 532module-is-copyable = $(call module-class-is-copyable,$(call module-get-class,$1)) 533 534# ----------------------------------------------------------------------------- 535# Function : module-get-export 536# Arguments: 1: module name 537# 2: export variable name without LOCAL_EXPORT_ prefix (e.g. 'CFLAGS') 538# Returns : Exported value 539# Usage : $(call module-get-export,<modulename>,<varname>) 540# Rationale: Return the recorded value of LOCAL_EXPORT_$2, if any, for module $1 541# ----------------------------------------------------------------------------- 542module-get-export = $(__ndk_modules.$1.EXPORT_$2) 543 544# ----------------------------------------------------------------------------- 545# Function : module-get-listed-export 546# Arguments: 1: list of module names 547# 2: export variable name without LOCAL_EXPORT_ prefix (e.g. 'CFLAGS') 548# Returns : Exported values 549# Usage : $(call module-get-listed-export,<module-list>,<varname>) 550# Rationale: Return the recorded value of LOCAL_EXPORT_$2, if any, for modules 551# listed in $1. 552# ----------------------------------------------------------------------------- 553module-get-listed-export = $(strip \ 554 $(foreach __listed_module,$1,\ 555 $(call module-get-export,$(__listed_module),$2)\ 556 )) 557 558# ----------------------------------------------------------------------------- 559# Function : modules-restore-locals 560# Arguments: 1: module name 561# Returns : None 562# Usage : $(call module-restore-locals,<modulename>) 563# Rationale: Restore the recorded LOCAL_XXX definitions for a given module. 564# ----------------------------------------------------------------------------- 565module-restore-locals = \ 566 $(foreach __local,$(modules-LOCALS),\ 567 $(eval LOCAL_$(__local) := $(__ndk_modules.$1.$(__local)))\ 568 ) 569 570# Dump all module information. Only use this for debugging 571modules-dump-database = \ 572 $(info Modules [$(TARGET_ARCH_ABI)]: $(__ndk_modules)) \ 573 $(foreach __mod,$(__ndk_modules),\ 574 $(info $(space4)$(__mod):)\ 575 $(foreach __field,$(modules-fields),\ 576 $(eval __fieldval := $(strip $(__ndk_modules.$(__mod).$(__field))))\ 577 $(if $(__fieldval),\ 578 $(if $(filter 1,$(words $(__fieldval))),\ 579 $(info $(space4)$(space4)$(__field): $(__fieldval)),\ 580 $(info $(space4)$(space4)$(__field): )\ 581 $(foreach __fielditem,$(__fieldval),\ 582 $(info $(space4)$(space4)$(space4)$(__fielditem))\ 583 )\ 584 )\ 585 )\ 586 )\ 587 )\ 588 $(info Top modules: $(__ndk_top_modules))\ 589 $(info --- end of modules list) 590 591 592# ----------------------------------------------------------------------------- 593# Function : module-add-static-depends 594# Arguments: 1: module name 595# 2: list/set of static library modules this module depends on. 596# Returns : None 597# Usage : $(call module-add-static-depends,<modulename>,<list of module names>) 598# Rationale: Record that a module depends on a set of static libraries. 599# Use module-get-static-dependencies to retrieve final list. 600# ----------------------------------------------------------------------------- 601module-add-static-depends = \ 602 $(call module-add-depends-any,$1,$2,depends) \ 603 604# ----------------------------------------------------------------------------- 605# Function : module-add-shared-depends 606# Arguments: 1: module name 607# 2: list/set of shared library modules this module depends on. 608# Returns : None 609# Usage : $(call module-add-shared-depends,<modulename>,<list of module names>) 610# Rationale: Record that a module depends on a set of shared libraries. 611# Use modulge-get-shared-dependencies to retrieve final list. 612# ----------------------------------------------------------------------------- 613module-add-shared-depends = \ 614 $(call module-add-depends-any,$1,$2,depends) \ 615 616# Used internally by module-add-static-depends and module-add-shared-depends 617# NOTE: this function must not modify the existing dependency order when new depends are added. 618# 619module-add-depends-any = \ 620 $(eval __ndk_modules.$1.$3 += $(filter-out $(__ndk_modules.$1.$3),$2)) 621 622 623# ----------------------------------------------------------------------------- 624# Returns non-empty if a module is a static library 625# Arguments: 1: module name 626# Returns : non-empty iff the module is a static library. 627# Usage : $(if $(call module-is-static-library,<name>),...) 628# ----------------------------------------------------------------------------- 629module-is-static-library = $(strip \ 630 $(filter STATIC_LIBRARY PREBUILT_STATIC_LIBRARY,\ 631 $(call module-get-class,$1))) 632 633# ----------------------------------------------------------------------------- 634# Returns non-empty if a module is a shared library 635# Arguments: 1: module name 636# Returns : non-empty iff the module is a shared library. 637# Usage : $(if $(call module-is-shared-library,<name>),...) 638# ----------------------------------------------------------------------------- 639module-is-shared-library = $(strip \ 640 $(filter SHARED_LIBRARY PREBUILT_SHARED_LIBRARY,\ 641 $(call module-get-class,$1))) 642 643# ----------------------------------------------------------------------------- 644# Filter a list of module names to retain only the static libraries. 645# Arguments: 1: module name list 646# Returns : input list modules which are static libraries. 647# ----------------------------------------------------------------------------- 648module-filter-static-libraries = $(call filter-by,$1,module-is-static-library) 649 650# ----------------------------------------------------------------------------- 651# Filter a list of module names to retain only the shared libraries. 652# Arguments: 1: module name list 653# Returns : input list modules which are shared libraries. 654# ----------------------------------------------------------------------------- 655module-filter-shared-libraries = $(call filter-by,$1,module-is-shared-library) 656 657# ----------------------------------------------------------------------------- 658# Return the LOCAL_STATIC_LIBRARIES for a given module. 659# Arguments: 1: module name 660# Returns : List of static library modules. 661# ----------------------------------------------------------------------------- 662module-get-static-libs = $(__ndk_modules.$1.STATIC_LIBRARIES) 663 664# ----------------------------------------------------------------------------- 665# Return the LOCAL_WHOLE_STATIC_LIBRARIES for a given module. 666# Arguments: 1: module name 667# Returns : List of whole static library modules. 668# ----------------------------------------------------------------------------- 669module-get-whole-static-libs = $(__ndk_modules.$1.WHOLE_STATIC_LIBRARIES) 670 671# ----------------------------------------------------------------------------- 672# Return all static libraries for a given module. 673# Arguments: 1: module name 674# Returns : List of static library modules (whole or not). 675# ----------------------------------------------------------------------------- 676module-get-all-static-libs = $(strip \ 677 $(__ndk_modules.$1.STATIC_LIBRARIES) \ 678 $(__ndk_modules.$1.WHOLE_STATIC_LIBRARIES)) 679 680# ----------------------------------------------------------------------------- 681# Return the list of LOCAL_SHARED_LIBRARIES for a given module. 682# Arguments: 1: module name 683# Returns : List of shared library modules. 684# ----------------------------------------------------------------------------- 685module-get-shared-libs = $(__ndk_modules.$1.SHARED_LIBRARIES) 686 687# ----------------------------------------------------------------------------- 688# Return the list of all libraries a modules depends directly on. 689# This is the concatenation of its LOCAL_STATIC_LIBRARIES, 690# LOCAL_WHOLE_STATIC_LIBRARIES, and LOCAL_SHARED_LIBRARIES variables. 691# Arguments: 1: module name 692# Returns : List of library modules (static or shared). 693# ----------------------------------------------------------------------------- 694module-get-direct-libs = $(strip \ 695 $(__ndk_modules.$1.STATIC_LIBRARIES) \ 696 $(__ndk_modules.$1.WHOLE_STATIC_LIBRARIES) \ 697 $(__ndk_modules.$1.SHARED_LIBRARIES)) 698 699 700# ----------------------------------------------------------------------------- 701# Computes the full closure of a module and its dependencies. Order is 702# defined by a breadth-first walk of the graph. 703# $1 will be the first item in the result. 704# 705# Arguments: 1: module name 706# Returns : List of all modules $1 depends on. 707# 708# Note: Do not use this to determine build dependencies. The returned list 709# is much too large for this. For example consider the following 710# dependency graph: 711# 712# main.exe -> libA.a -> libfoo.so -> libB.a 713# 714# This function will return all four modules in the result, while 715# at link time building main.exe only requires the first three. 716# 717# ----------------------------------------------------------------------------- 718module-get-all-dependencies = $(call -ndk-mod-get-closure,$1,module-get-depends) 719 720# ----------------------------------------------------------------------------- 721# Compute the list of all static and shared libraries required to link a 722# given module. 723# 724# Note that the result is topologically ordered, i.e. if library A depends 725# on library B, then A will always appear after B in the result. 726# 727# Arguments: 1: module name 728# Returns : List of all library $1 depends at link time. 729# 730# Note: This doesn't differentiate between regular and whole static 731# libraries. Use module-extract-whole-static-libs to filter the 732# result returned by this function. 733# ----------------------------------------------------------------------------- 734module-get-link-libs = $(strip \ 735 $(eval _ndk_mod_link_module := $1) \ 736 $(call -ndk-mod-get-topological-depends,$1,-ndk-mod-link-deps)) 737 738# Special dependency function used by module-get-link-libs. 739# The rules to follow are the following: 740# - if $1 is the link module, or if it is a static library, then all 741# direct dependencies. 742# - otherwise, the module is a shared library, don't add build deps. 743-ndk-mod-link-deps = \ 744 $(if $(call seq,$1,$(_ndk_mod_link_module))$(call module-is-static-library,$1),\ 745 $(call module-get-direct-libs,$1)) 746 747# ----------------------------------------------------------------------------- 748# This function is used to extract the list of static libraries that need 749# to be linked as whole, i.e. placed in a special section on the final 750# link command. 751# Arguments: $1: module name. 752# $2: list of all static link-time libraries (regular or whole). 753# Returns : list of static libraries from '$2' that need to be linked 754# as whole. 755# ----------------------------------------------------------------------------- 756module-extract-whole-static-libs = $(strip \ 757 $(eval _ndk_mod_whole_all := $(call map,module-get-whole-static-libs,$1 $2))\ 758 $(eval _ndk_mod_whole_result := $(filter $(_ndk_mod_whole_all),$2))\ 759 $(_ndk_mod_whole_result)) 760 761# Used to recompute all dependencies once all module information has been recorded. 762# 763modules-compute-dependencies = \ 764 $(foreach __module,$(__ndk_modules),\ 765 $(call module-compute-depends,$(__module))\ 766 ) 767 768module-compute-depends = \ 769 $(call module-add-static-depends,$1,$(__ndk_modules.$1.STATIC_LIBRARIES))\ 770 $(call module-add-static-depends,$1,$(__ndk_modules.$1.WHOLE_STATIC_LIBRARIES))\ 771 $(call module-add-shared-depends,$1,$(__ndk_modules.$1.SHARED_LIBRARIES))\ 772 773module-get-installed = $(__ndk_modules.$1.INSTALLED) 774 775module-get-depends = $(__ndk_modules.$1.depends) 776 777# ----------------------------------------------------------------------------- 778# Function : modules-get-all-installable 779# Arguments: 1: list of module names 780# Returns : List of all the installable modules $1 depends on transitively. 781# Usage : $(call modules-all-get-installable,<list of module names>) 782# Rationale: This computes the closure of all installable module dependencies starting from $1 783# ----------------------------------------------------------------------------- 784# For now, only the closure of LOCAL_SHARED_LIBRARIES is enough 785modules-get-all-installable = $(strip \ 786 $(foreach __alldep,$(call module-get-all-dependencies,$1),\ 787 $(if $(call module-is-installable,$(__alldep)),$(__alldep))\ 788 )) 789 790# Return the C++ extension(s) of a given module 791# $1: module name 792module-get-c++-extensions = $(strip \ 793 $(if $(__ndk_modules.$1.CPP_EXTENSION),\ 794 $(__ndk_modules.$1.CPP_EXTENSION),\ 795 $(default-c++-extensions)\ 796 )) 797 798# Return the list of C++ sources of a given module 799# 800module-get-c++-sources = \ 801 $(eval __files := $(__ndk_modules.$1.SRC_FILES:%.neon=%)) \ 802 $(eval __files := $(__files:%.arm=%)) \ 803 $(eval __extensions := $(call module-get-c++-extensions,$1))\ 804 $(filter $(foreach __extension,$(__extensions),%$(__extension)),$(__files)) 805 806# Returns true if a module has C++ sources 807# 808module-has-c++-sources = $(strip $(call module-get-c++-sources,$1)) 809 810 811# Add C++ dependencies to any module that has C++ sources. 812# $1: list of C++ runtime static libraries (if any) 813# $2: list of C++ runtime shared libraries (if any) 814# 815modules-add-c++-dependencies = \ 816 $(foreach __module,$(__ndk_modules),\ 817 $(if $(call module-has-c++-sources,$(__module)),\ 818 $(call ndk_log,Module '$(__module)' has C++ sources)\ 819 $(call module-add-c++-deps,$(__module),$1,$2),\ 820 )\ 821 ) 822 823 824# Return the compiler flags used to compile a C++ module 825# Order matters and should match the one used by the build command 826module-get-c++-flags = $(strip \ 827 $(__ndk_modules.$1.CFLAGS) \ 828 $(__ndk_modules.$1.CPPFLAGS) \ 829 $(__ndk_modules.$1.CXXFLAGS)) 830 831# This function is used to remove certain flags from a module compiler flags 832# $1: Module name 833# $2: List of flags to remove 834# 835module-filter-out-compiler-flags = \ 836 $(eval __ndk_modules.$1.CFLAGS := $(filter-out $2,$(__ndk_modules.$1.CFLAGS)))\ 837 $(eval __ndk_modules.$1.CONLYFLAGS := $(filter-out $2,$(__ndk_modules.$1.CONLYFLAGS)))\ 838 $(eval __ndk_modules.$1.CPPFLAGS := $(filter-out $2,$(__ndk_modules.$1.CPPFLAGS)))\ 839 $(eval __ndk_modules.$1.CXXFLAGS := $(filter-out $2,$(__ndk_modules.$1.CXXFLAGS)))\ 840 $(eval __ndk_modules.$1.ASMFLAGS := $(filter-out $2,$(__ndk_modules.$1.ASMFLAGS))) 841 842# Return true if a module's compiler flags enable rtti 843# We just look at -frtti and -fno-rtti on the command-line 844# and keep the last one of these flags. 845module-flags-have-rtti = $(strip \ 846 $(filter -frtti,\ 847 $(lastword $(filter -frtti -fno-rtti,$(call module-get-c++-flags,$1)))\ 848 )\ 849 ) 850 851# Same with C++ exception support (i.e. -fexceptions and -fno-exceptions) 852# 853module-flags-have-exceptions = $(strip \ 854 $(filter -fexceptions,\ 855 $(lastword $(filter -fexceptions -fno-execeptions,$(call module-get-c++-flags,$1)))\ 856 )\ 857 ) 858 859# Handle the definition of LOCAL_CPP_FEATURES, i.e.: 860# 861# - If it is defined, check that it only contains valid values 862# - If it is undefined, try to compute its value automatically by 863# looking at the C++ compiler flags used to build the module 864# 865# After this, we remove all features flags from the module's command-line 866# And add only the correct ones back in LOCAL_CPP_FLAGS 867# 868module-handle-c++-features = \ 869 $(if $(strip $(__ndk_modules.$1.CPP_FEATURES)),\ 870 $(eval __cxxbad := $(filter-out rtti exceptions,$(__ndk_modules.$1.CPP_FEATURES)))\ 871 $(if $(__cxxbad),\ 872 $(call __ndk_info,WARNING: Ignoring invalid values in LOCAL_CPP_FEATURES definition in $(__ndk_modules.$1.MAKEFILE): $(__cxxbad))\ 873 $(eval __ndk_modules.$1.CPP_FEATURES := $(strip $(filter-out $(__cxxbad),$(__ndk_modules.$1.CPP_FEATURES))))\ 874 )\ 875 ,\ 876 $(eval __ndk_modules.$1.CPP_FEATURES := $(strip \ 877 $(if $(call module-flags-have-rtti,$1),rtti) \ 878 $(if $(call module-flags-have-exceptions,$1),exceptions) \ 879 )) \ 880 )\ 881 $(call module-filter-out-compiler-flags,$1,-frtti -fno-rtti -fexceptions -fno-exceptions)\ 882 883# Returns true if a module or its dependencies have specific C++ features 884# (i.e. RTTI or Exceptions) 885# 886# $1: module name 887# $2: list of features (e.g. 'rtti' or 'exceptions') 888# 889module-has-c++-features = $(strip \ 890 $(eval __cxxdeps := $(call module-get-all-dependencies,$1))\ 891 $(eval __cxxflags := $(foreach __cxxdep,$(__cxxdeps),$(__ndk_modules.$(__cxxdep).CPP_FEATURES)))\ 892 $(if $(filter $2,$(__cxxflags)),true,)\ 893 ) 894 895# Add standard C++ dependencies to a given module 896# 897# $1: module name 898# $2: list of C++ runtime static libraries (if any) 899# $3: list of C++ runtime shared libraries (if any) 900# 901module-add-c++-deps = \ 902 $(if $(call strip,$2),$(call ndk_log,Add dependency '$(call strip,$2)' to module '$1'))\ 903 $(eval __ndk_modules.$1.STATIC_LIBRARIES += $(2))\ 904 $(if $(call strip,$3),$(call ndk_log,Add dependency '$(call strip,$3)' to module '$1'))\ 905 $(eval __ndk_modules.$1.SHARED_LIBRARIES += $(3)) 906 907 908# ============================================================================= 909# 910# Utility functions 911# 912# ============================================================================= 913 914# ----------------------------------------------------------------------------- 915# Function : pretty-dir 916# Arguments: 1: path 917# Returns : Remove NDK_PROJECT_PATH prefix from a given path. This can be 918# used to perform pretty-printing for logs. 919# ----------------------------------------------------------------------------- 920pretty-dir = $(patsubst $(NDK_ROOT)/%,<NDK>/%,\ 921 $(patsubst $(NDK_PROJECT_PATH)/%,%,$1)) 922 923# Note: NDK_PROJECT_PATH is typically defined after this test is run. 924-test-pretty-dir = \ 925 $(eval NDK_PROJECT_PATH ?= .)\ 926 $(call test-expect,foo,$(call pretty-dir,foo))\ 927 $(call test-expect,foo,$(call pretty-dir,$(NDK_PROJECT_PATH)/foo))\ 928 $(call test-expect,foo/bar,$(call pretty-dir,$(NDK_PROJECT_PATH)/foo/bar))\ 929 $(call test-expect,<NDK>/foo,$(call pretty-dir,$(NDK_ROOT)/foo))\ 930 $(call test-expect,<NDK>/foo/bar,$(call pretty-dir,$(NDK_ROOT)/foo/bar)) 931 932# ----------------------------------------------------------------------------- 933# Function : check-user-define 934# Arguments: 1: name of variable that must be defined by the user 935# 2: name of Makefile where the variable should be defined 936# 3: name/description of the Makefile where the check is done, which 937# must be included by $2 938# Returns : None 939# ----------------------------------------------------------------------------- 940check-user-define = $(if $(strip $($1)),,\ 941 $(call __ndk_error,Missing $1 before including $3 in $2)) 942 943# ----------------------------------------------------------------------------- 944# This is used to check that LOCAL_MODULE is properly defined by an Android.mk 945# file before including one of the $(BUILD_SHARED_LIBRARY), etc... files. 946# 947# Function : check-user-LOCAL_MODULE 948# Arguments: 1: name/description of the included build Makefile where the 949# check is done 950# Returns : None 951# Usage : $(call check-user-LOCAL_MODULE, BUILD_SHARED_LIBRARY) 952# ----------------------------------------------------------------------------- 953check-defined-LOCAL_MODULE = \ 954 $(call check-user-define,LOCAL_MODULE,$(local-makefile),$(1)) \ 955 $(if $(call seq,$(words $(LOCAL_MODULE)),1),,\ 956 $(call __ndk_info,LOCAL_MODULE definition in $(local-makefile) must not contain space)\ 957 $(call __ndk_error,Please correct error. Aborting)\ 958 ) 959 960# ----------------------------------------------------------------------------- 961# This is used to check that LOCAL_MODULE_FILENAME, if defined, is correct. 962# 963# Function : check-user-LOCAL_MODULE_FILENAME 964# Returns : None 965# Usage : $(call check-user-LOCAL_MODULE_FILENAME) 966# ----------------------------------------------------------------------------- 967check-LOCAL_MODULE_FILENAME = \ 968 $(if $(strip $(LOCAL_MODULE_FILENAME)),\ 969 $(if $(call seq,$(words $(LOCAL_MODULE_FILENAME)),1),,\ 970 $(call __ndk_info,$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain spaces)\ 971 $(call __ndk_error,Plase correct error. Aborting)\ 972 )\ 973 $(if $(filter %$(TARGET_LIB_EXTENSION) %$(TARGET_SONAME_EXTENSION),$(LOCAL_MODULE_FILENAME)),\ 974 $(call __ndk_info,$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME should not include file extensions)\ 975 )\ 976 ) 977 978# ----------------------------------------------------------------------------- 979# Function : handle-module-filename 980# Arguments : 1: default file prefix 981# 2: file suffix 982# Returns : None 983# Usage : $(call handle-module-filename,<prefix>,<suffix>) 984# Rationale : To be used to check and or set the module's filename through 985# the LOCAL_MODULE_FILENAME variable. 986# ----------------------------------------------------------------------------- 987handle-module-filename = $(eval $(call ev-handle-module-filename,$1,$2)) 988 989# 990# Check that LOCAL_MODULE_FILENAME is properly defined 991# - with one single item 992# - without a library file extension 993# - with no directory separators 994# 995define ev-check-module-filename 996ifneq (1,$$(words $$(LOCAL_MODULE_FILENAME))) 997 $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain any space) 998 $$(call __ndk_error,Aborting) 999endif 1000ifneq (,$$(filter %$$(TARGET_LIB_EXTENSION) %$$(TARGET_SONAME_EXTENSION),$$(LOCAL_MODULE_FILENAME))) 1001 $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain a file extension) 1002 $$(call __ndk_error,Aborting) 1003endif 1004ifneq (1,$$(words $$(subst /, ,$$(LOCAL_MODULE_FILENAME)))) 1005 $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain directory separators) 1006 $$(call __ndk_error,Aborting) 1007endif 1008endef 1009 1010# 1011# Check the definition of LOCAL_MODULE_FILENAME. If none exists, 1012# infer it from the LOCAL_MODULE name. 1013# 1014# $1: default file prefix 1015# $2: default file suffix 1016# 1017define ev-handle-module-filename 1018LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME)) 1019ifndef LOCAL_MODULE_FILENAME 1020 LOCAL_MODULE_FILENAME := $1$$(LOCAL_MODULE) 1021endif 1022$$(eval $$(call ev-check-module-filename)) 1023LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$2 1024endef 1025 1026handle-prebuilt-module-filename = $(eval $(call ev-handle-prebuilt-module-filename,$1)) 1027 1028# 1029# Check the definition of LOCAL_MODULE_FILENAME for a _prebuilt_ module. 1030# If none exists, infer it from $(LOCAL_SRC_FILES) 1031# 1032# $1: default file suffix 1033# 1034define ev-handle-prebuilt-module-filename 1035LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME)) 1036ifndef LOCAL_MODULE_FILENAME 1037 LOCAL_MODULE_FILENAME := $$(notdir $(LOCAL_SRC_FILES)) 1038 LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%$$(TARGET_LIB_EXTENSION)=%) 1039 LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%$$(TARGET_SONAME_EXTENSION)=%) 1040endif 1041LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$1 1042$$(eval $$(call ev-check-module-filename)) 1043endef 1044 1045 1046# ----------------------------------------------------------------------------- 1047# Function : handle-module-built 1048# Returns : None 1049# Usage : $(call handle-module-built) 1050# Rationale : To be used to automatically compute the location of the generated 1051# binary file, and the directory where to place its object files. 1052# ----------------------------------------------------------------------------- 1053handle-module-built = \ 1054 $(eval LOCAL_BUILT_MODULE := $(TARGET_OUT)/$(LOCAL_MODULE_FILENAME))\ 1055 $(eval LOCAL_OBJS_DIR := $(TARGET_OBJS)/$(LOCAL_MODULE)) 1056 1057# ----------------------------------------------------------------------------- 1058# Compute the real path of a prebuilt file. 1059# 1060# Function : local-prebuilt-path 1061# Arguments: 1: prebuilt path (as listed in $(LOCAL_SRC_FILES)) 1062# Returns : full path. If $1 begins with a /, the path is considered 1063# absolute and returned as-is. Otherwise, $(LOCAL_PATH)/$1 is 1064# returned instead. 1065# Usage : $(call local-prebuilt-path,$(LOCAL_SRC_FILES)) 1066# ----------------------------------------------------------------------------- 1067local-prebuilt-path = $(call local-source-file-path,$1) 1068 1069# ----------------------------------------------------------------------------- 1070# This is used to strip any lib prefix from LOCAL_MODULE, then check that 1071# the corresponding module name is not already defined. 1072# 1073# Function : check-user-LOCAL_MODULE 1074# Arguments: 1: path of Android.mk where this LOCAL_MODULE is defined 1075# Returns : None 1076# Usage : $(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE)) 1077# ----------------------------------------------------------------------------- 1078check-LOCAL_MODULE = \ 1079 $(eval LOCAL_MODULE := $$(call strip-lib-prefix,$$(LOCAL_MODULE))) 1080 1081# ----------------------------------------------------------------------------- 1082# Macro : my-dir 1083# Returns : the directory of the current Makefile 1084# Usage : $(my-dir) 1085# ----------------------------------------------------------------------------- 1086my-dir = $(call parent-dir,$(lastword $(MAKEFILE_LIST))) 1087 1088# ----------------------------------------------------------------------------- 1089# Function : all-makefiles-under 1090# Arguments: 1: directory path 1091# Returns : a list of all makefiles immediately below some directory 1092# Usage : $(call all-makefiles-under, <some path>) 1093# ----------------------------------------------------------------------------- 1094all-makefiles-under = $(wildcard $1/*/Android.mk) 1095 1096# ----------------------------------------------------------------------------- 1097# Macro : all-subdir-makefiles 1098# Returns : list of all makefiles in subdirectories of the current Makefile's 1099# location 1100# Usage : $(all-subdir-makefiles) 1101# ----------------------------------------------------------------------------- 1102all-subdir-makefiles = $(call all-makefiles-under,$(call my-dir)) 1103 1104# ============================================================================= 1105# 1106# Source file tagging support. 1107# 1108# Each source file listed in LOCAL_SRC_FILES can have any number of 1109# 'tags' associated to it. A tag name must not contain space, and its 1110# usage can vary. 1111# 1112# For example, the 'debug' tag is used to sources that must be built 1113# in debug mode, the 'arm' tag is used for sources that must be built 1114# using the 32-bit instruction set on ARM platforms, and 'neon' is used 1115# for sources that must be built with ARM Advanced SIMD (a.k.a. NEON) 1116# support. 1117# 1118# More tags might be introduced in the future. 1119# 1120# LOCAL_SRC_TAGS contains the list of all tags used (initially empty) 1121# LOCAL_SRC_FILES contains the list of all source files. 1122# LOCAL_SRC_TAG.<tagname> contains the set of source file names tagged 1123# with <tagname> 1124# LOCAL_SRC_FILES_TAGS.<filename> contains the set of tags for a given 1125# source file name 1126# 1127# Tags are processed by a toolchain-specific function (e.g. TARGET-compute-cflags) 1128# which will call various functions to compute source-file specific settings. 1129# These are currently stored as: 1130# 1131# LOCAL_SRC_FILES_TARGET_CFLAGS.<filename> contains the list of 1132# target-specific C compiler flags used to compile a given 1133# source file. This is set by the function TARGET-set-cflags 1134# defined in the toolchain's setup.mk script. 1135# 1136# LOCAL_SRC_FILES_TEXT.<filename> contains the 'text' that will be 1137# displayed along the label of the build output line. For example 1138# 'thumb' or 'arm ' with ARM-based toolchains. 1139# 1140# ============================================================================= 1141 1142# ----------------------------------------------------------------------------- 1143# Macro : clear-all-src-tags 1144# Returns : remove all source file tags and associated data. 1145# Usage : $(clear-all-src-tags) 1146# ----------------------------------------------------------------------------- 1147clear-all-src-tags = \ 1148$(foreach __tag,$(LOCAL_SRC_TAGS), \ 1149 $(eval LOCAL_SRC_TAG.$(__tag) := $(empty)) \ 1150) \ 1151$(foreach __src,$(LOCAL_SRC_FILES), \ 1152 $(eval LOCAL_SRC_FILES_TAGS.$(__src) := $(empty)) \ 1153 $(eval LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) := $(empty)) \ 1154 $(eval LOCAL_SRC_FILES_TEXT.$(__src) := $(empty)) \ 1155) \ 1156$(eval LOCAL_SRC_TAGS := $(empty_set)) 1157 1158# ----------------------------------------------------------------------------- 1159# Macro : tag-src-files 1160# Arguments: 1: list of source files to tag 1161# 2: tag name (must not contain space) 1162# Usage : $(call tag-src-files,<list-of-source-files>,<tagname>) 1163# Rationale: Add a tag to a list of source files 1164# ----------------------------------------------------------------------------- 1165tag-src-files = \ 1166$(eval LOCAL_SRC_TAGS := $(call set_insert,$2,$(LOCAL_SRC_TAGS))) \ 1167$(eval LOCAL_SRC_TAG.$2 := $(call set_union,$1,$(LOCAL_SRC_TAG.$2))) \ 1168$(foreach __src,$1, \ 1169 $(eval LOCAL_SRC_FILES_TAGS.$(__src) += $2) \ 1170) 1171 1172# ----------------------------------------------------------------------------- 1173# Macro : get-src-files-with-tag 1174# Arguments: 1: tag name 1175# Usage : $(call get-src-files-with-tag,<tagname>) 1176# Return : The list of source file names that have been tagged with <tagname> 1177# ----------------------------------------------------------------------------- 1178get-src-files-with-tag = $(LOCAL_SRC_TAG.$1) 1179 1180# ----------------------------------------------------------------------------- 1181# Macro : get-src-files-without-tag 1182# Arguments: 1: tag name 1183# Usage : $(call get-src-files-without-tag,<tagname>) 1184# Return : The list of source file names that have NOT been tagged with <tagname> 1185# ----------------------------------------------------------------------------- 1186get-src-files-without-tag = $(filter-out $(LOCAL_SRC_TAG.$1),$(LOCAL_SRC_FILES)) 1187 1188# ----------------------------------------------------------------------------- 1189# Macro : set-src-files-target-cflags 1190# Arguments: 1: list of source files 1191# 2: list of compiler flags 1192# Usage : $(call set-src-files-target-cflags,<sources>,<flags>) 1193# Rationale: Set or replace the set of compiler flags that will be applied 1194# when building a given set of source files. This function should 1195# normally be called from the toolchain-specific function that 1196# computes all compiler flags for all source files. 1197# ----------------------------------------------------------------------------- 1198set-src-files-target-cflags = $(foreach __src,$1,$(eval LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) := $2)) 1199 1200# ----------------------------------------------------------------------------- 1201# Macro : add-src-files-target-cflags 1202# Arguments: 1: list of source files 1203# 2: list of compiler flags 1204# Usage : $(call add-src-files-target-cflags,<sources>,<flags>) 1205# Rationale: A variant of set-src-files-target-cflags that can be used 1206# to append, instead of replace, compiler flags for specific 1207# source files. 1208# ----------------------------------------------------------------------------- 1209add-src-files-target-cflags = $(foreach __src,$1,$(eval LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) += $2)) 1210 1211# ----------------------------------------------------------------------------- 1212# Macro : get-src-file-target-cflags 1213# Arguments: 1: single source file name 1214# Usage : $(call get-src-file-target-cflags,<source>) 1215# Rationale: Return the set of target-specific compiler flags that must be 1216# applied to a given source file. These must be set prior to this 1217# call using set-src-files-target-cflags or add-src-files-target-cflags 1218# ----------------------------------------------------------------------------- 1219get-src-file-target-cflags = $(LOCAL_SRC_FILES_TARGET_CFLAGS.$1) 1220 1221# ----------------------------------------------------------------------------- 1222# Macro : set-src-files-text 1223# Arguments: 1: list of source files 1224# 2: text 1225# Usage : $(call set-src-files-text,<sources>,<text>) 1226# Rationale: Set or replace the 'text' associated to a set of source files. 1227# The text is a very short string that complements the build 1228# label. For example, it will be either 'thumb' or 'arm ' for 1229# ARM-based toolchains. This function must be called by the 1230# toolchain-specific functions that processes all source files. 1231# ----------------------------------------------------------------------------- 1232set-src-files-text = $(foreach __src,$1,$(eval LOCAL_SRC_FILES_TEXT.$(__src) := $2)) 1233 1234# ----------------------------------------------------------------------------- 1235# Macro : get-src-file-text 1236# Arguments: 1: single source file 1237# Usage : $(call get-src-file-text,<source>) 1238# Rationale: Return the 'text' associated to a given source file when 1239# set-src-files-text was called. 1240# ----------------------------------------------------------------------------- 1241get-src-file-text = $(LOCAL_SRC_FILES_TEXT.$1) 1242 1243# This should only be called for debugging the source files tagging system 1244dump-src-file-tags = \ 1245$(info LOCAL_SRC_TAGS := $(LOCAL_SRC_TAGS)) \ 1246$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES)) \ 1247$(foreach __tag,$(LOCAL_SRC_TAGS),$(info LOCAL_SRC_TAG.$(__tag) = $(LOCAL_SRC_TAG.$(__tag)))) \ 1248$(foreach __src,$(LOCAL_SRC_FILES),$(info LOCAL_SRC_FILES_TAGS.$(__src) = $(LOCAL_SRC_FILES_TAGS.$(__src)))) \ 1249$(info WITH arm = $(call get-src-files-with-tag,arm)) \ 1250$(info WITHOUT arm = $(call get-src-files-without-tag,arm)) \ 1251$(foreach __src,$(LOCAL_SRC_FILES),$(info LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) = $(LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src)))) \ 1252$(foreach __src,$(LOCAL_SRC_FILES),$(info LOCAL_SRC_FILES_TEXT.$(__src) = $(LOCAL_SRC_FILES_TEXT.$(__src)))) \ 1253 1254 1255# ============================================================================= 1256# 1257# Application.mk support 1258# 1259# ============================================================================= 1260 1261# the list of variables that *must* be defined in Application.mk files 1262NDK_APP_VARS_REQUIRED := 1263 1264# the list of variables that *may* be defined in Application.mk files 1265NDK_APP_VARS_OPTIONAL := APP_OPTIM APP_CPPFLAGS APP_CFLAGS APP_CONLY_FLAGS APP_CXXFLAGS \ 1266 APP_LDFLAGS APP_PLATFORM APP_BUILD_SCRIPT APP_ABI APP_MODULES \ 1267 APP_PROJECT_PATH APP_STL APP_SHORT_COMMANDS \ 1268 APP_PIE APP_THIN_ARCHIVE 1269 1270# the list of all variables that may appear in an Application.mk file 1271# or defined by the build scripts. 1272NDK_APP_VARS := $(NDK_APP_VARS_REQUIRED) \ 1273 $(NDK_APP_VARS_OPTIONAL) \ 1274 APP_DEBUG \ 1275 APP_DEBUGGABLE \ 1276 APP_MANIFEST 1277 1278# ============================================================================= 1279# 1280# Android.mk support 1281# 1282# ============================================================================= 1283 1284# ============================================================================= 1285# 1286# Build commands support 1287# 1288# ============================================================================= 1289 1290get-object-name = $(strip \ 1291 $(subst ../,__/,\ 1292 $(subst :,_,\ 1293 $(eval __obj := $1)\ 1294 $(foreach __ext,.c .s .S .asm $(LOCAL_CPP_EXTENSION) $(LOCAL_RS_EXTENSION),\ 1295 $(eval __obj := $(__obj:%$(__ext)=%$(TARGET_OBJ_EXTENSION)))\ 1296 )\ 1297 $(__obj)\ 1298 ))) 1299 1300-test-get-object-name = \ 1301 $(eval TARGET_OBJ_EXTENSION=.o)\ 1302 $(eval LOCAL_CPP_EXTENSION ?= .cpp)\ 1303 $(eval LOCAL_RS_EXTENSION ?= .rs)\ 1304 $(call test-expect,foo.o,$(call get-object-name,foo.c))\ 1305 $(call test-expect,bar.o,$(call get-object-name,bar.s))\ 1306 $(call test-expect,zoo.o,$(call get-object-name,zoo.S))\ 1307 $(call test-expect,tot.o,$(call get-object-name,tot.cpp))\ 1308 $(call test-expect,RS.o,$(call get-object-name,RS.rs))\ 1309 $(call test-expect,goo.o,$(call get-object-name,goo.asm)) 1310 1311get-rs-scriptc-name = $(strip \ 1312 $(subst ../,__/,\ 1313 $(subst :,_,\ 1314 $(eval __obj := $1)\ 1315 $(foreach __ext,$(LOCAL_RS_EXTENSION),\ 1316 $(eval __obj := $(__obj:%$(__ext)=%.cpp))\ 1317 )\ 1318 $(dir $(__obj))ScriptC_$(notdir $(__obj))\ 1319 ))) 1320 1321get-rs-bc-name = $(strip \ 1322 $(subst ../,__/,\ 1323 $(subst :,_,\ 1324 $(eval __obj := $1)\ 1325 $(foreach __ext,$(LOCAL_RS_EXTENSION),\ 1326 $(eval __obj := $(__obj:%$(__ext)=%.bc))\ 1327 )\ 1328 $(__obj)\ 1329 ))) 1330 1331get-rs-so-name = $(strip \ 1332 $(subst ../,__/,\ 1333 $(subst :,_,\ 1334 $(eval __obj := $1)\ 1335 $(foreach __ext,$(LOCAL_RS_EXTENSION),\ 1336 $(eval __obj := $(__obj:%$(__ext)=%$(TARGET_SONAME_EXTENSION)))\ 1337 )\ 1338 $(notdir $(__obj))\ 1339 ))) 1340 1341# ----------------------------------------------------------------------------- 1342# Macro : hide 1343# Returns : nothing 1344# Usage : $(hide)<make commands> 1345# Rationale: To be used as a prefix for Make build commands to hide them 1346# by default during the build. To show them, set V=1 in your 1347# environment or command-line. 1348# 1349# For example: 1350# 1351# foo.o: foo.c 1352# -->|$(hide) <build-commands> 1353# 1354# Where '-->|' stands for a single tab character. 1355# 1356# ----------------------------------------------------------------------------- 1357ifeq ($(V),1) 1358hide = $(empty) 1359else 1360hide = @ 1361endif 1362 1363 1364# ----------------------------------------------------------------------------- 1365# Function : local-source-file-path 1366# Parameters: $1: source file (as listed in LOCAL_SRC_FILES) 1367# Returns : full source file path of $1 1368# Usage : $(call local-source-file-path,$1) 1369# Rationale : Used to compute the full path of a source listed in 1370# LOCAL_SRC_FILES. If it is an absolute path, then this 1371# returns the input, otherwise, prepends $(LOCAL_PATH)/ 1372# to the result. 1373# ----------------------------------------------------------------------------- 1374local-source-file-path = $(if $(call host-path-is-absolute,$1),$1,$(LOCAL_PATH)/$1) 1375 1376# cmd-convert-deps 1377# 1378# On Cygwin, we need to convert the .d dependency file generated by 1379# the gcc toolchain by transforming any Windows paths inside it into 1380# Cygwin paths that GNU Make can understand (i.e. C:/Foo => /cygdrive/c/Foo) 1381# 1382# To do that, we will force the compiler to write the dependency file to 1383# <foo>.d.org, which will will later convert through a clever sed script 1384# that is auto-generated by our build system. 1385# 1386# The script is invoked with: 1387# 1388# $(NDK_DEPENDENCIES_CONVERTER) foo.d 1389# 1390# It will look if foo.d.org exists, and if so, process it 1391# to generate foo.d, then remove the original foo.d.org. 1392# 1393# On other systems, we simply tell the compiler to write to the .d file directly. 1394# 1395# NOTE: In certain cases, no dependency file will be generated by the 1396# compiler (e.g. when compiling an assembly file as foo.s) 1397# 1398# convert-deps is used to compute the name of the compiler-generated dependency file 1399# cmd-convert-deps is a command used to convert it to a Cygwin-specific path 1400# 1401ifeq ($(HOST_OS),cygwin) 1402convert-deps = $1.org 1403cmd-convert-deps = && $(NDK_DEPENDENCIES_CONVERTER) $1 1404else 1405convert-deps = $1 1406cmd-convert-deps = 1407endif 1408 1409# This assumes that many variables have been pre-defined: 1410# _SRC: source file 1411# _OBJ: destination file 1412# _CC: 'compiler' command 1413# _FLAGS: 'compiler' flags 1414# _TEXT: Display text (e.g. "Compile++ thumb", must be EXACTLY 15 chars long) 1415# 1416define ev-build-file 1417$$(_OBJ): PRIVATE_ABI := $$(TARGET_ARCH_ABI) 1418$$(_OBJ): PRIVATE_SRC := $$(_SRC) 1419$$(_OBJ): PRIVATE_OBJ := $$(_OBJ) 1420$$(_OBJ): PRIVATE_DEPS := $$(call host-path,$$(_OBJ).d) 1421$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) 1422$$(_OBJ): PRIVATE_TEXT := $$(_TEXT) 1423$$(_OBJ): PRIVATE_CC := $$(_CC) 1424$$(_OBJ): PRIVATE_CFLAGS := $$(_FLAGS) 1425 1426ifeq ($$(LOCAL_SHORT_COMMANDS),true) 1427_OPTIONS_LISTFILE := $$(_OBJ).cflags 1428$$(_OBJ): $$(call generate-list-file,$$(_FLAGS),$$(_OPTIONS_LISTFILE)) 1429$$(_OBJ): PRIVATE_CFLAGS := @$$(call host-path,$$(_OPTIONS_LISTFILE)) 1430$$(_OBJ): $$(_OPTIONS_LISTFILE) 1431endif 1432 1433$$(call generate-file-dir,$$(_OBJ)) 1434$$(_OBJ): $$(_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK) $$(NDK_DEPENDENCIES_CONVERTER) $(LOCAL_RS_OBJECTS) 1435 $$(call host-echo-build-step,$$(PRIVATE_ABI),$$(PRIVATE_TEXT)) "$$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" 1436 $$(hide) $$(PRIVATE_CC) -MMD -MP -MF $$(call convert-deps,$$(PRIVATE_DEPS)) $$(PRIVATE_CFLAGS) $$(call host-path,$$(PRIVATE_SRC)) -o $$(call host-path,$$(PRIVATE_OBJ)) \ 1437 $$(call cmd-convert-deps,$$(PRIVATE_DEPS)) 1438endef 1439 1440 1441# For renderscript: slightly different from the above ev-build-file 1442# _RS_SRC: RS source file 1443# _CPP_SRC: ScriptC_RS.cpp source file 1444# _BC_SRC: Bitcode source file 1445# _BC_SO: Bitcode SO name, no path 1446# _OBJ: destination file 1447# _RS_CC: 'compiler' command for _RS_SRC 1448# _RS_BCC: 'compiler' command for _BC_SRC 1449# _CXX: 'compiler' command for _CPP_SRC 1450# _RS_FLAGS: 'compiler' flags for _RS_SRC 1451# _CPP_FLAGS: 'compiler' flags for _CPP_SRC 1452# _TEXT: Display text (e.g. "Compile RS") 1453# _OUT: output dir 1454# _COMPAT: 'true' if bcc_compat is required 1455# 1456define ev-build-rs-file 1457$$(_OBJ): PRIVATE_ABI := $$(TARGET_ARCH_ABI) 1458$$(_OBJ): PRIVATE_RS_SRC := $$(_RS_SRC) 1459$$(_OBJ): PRIVATE_CPP_SRC := $$(_CPP_SRC) 1460$$(_OBJ): PRIVATE_BC_SRC := $$(_BC_SRC) 1461$$(_OBJ): PRIVATE_OBJ := $$(_OBJ) 1462$$(_OBJ): PRIVATE_BC_OBJ := $$(_BC_SRC)$(TARGET_OBJ_EXTENSION) 1463$$(_OBJ): PRIVATE_BC_SO := $$(_BC_SO) 1464$$(_OBJ): PRIVATE_DEPS := $$(call host-path,$$(_OBJ).d) 1465$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) 1466$$(_OBJ): PRIVATE_TEXT := $$(_TEXT) 1467$$(_OBJ): PRIVATE_RS_CC := $$(_RS_CC) 1468$$(_OBJ): PRIVATE_RS_BCC := $$(_RS_BCC) 1469$$(_OBJ): PRIVATE_CXX := $$(_CXX) 1470$$(_OBJ): PRIVATE_RS_FLAGS := $$(_RS_FLAGS) 1471$$(_OBJ): PRIVATE_CPPFLAGS := $$(_CPP_FLAGS) 1472$$(_OBJ): PRIVATE_OUT := $$(NDK_APP_DST_DIR) 1473$$(_OBJ): PRIVATE_RS_TRIPLE := $$(RS_TRIPLE) 1474$$(_OBJ): PRIVATE_COMPAT := $$(_COMPAT) 1475 1476ifeq ($$(LOCAL_SHORT_COMMANDS),true) 1477_OPTIONS_LISTFILE := $$(_OBJ).cflags 1478$$(_OBJ): $$(call generate-list-file,$$(_CPP_FLAGS),$$(_OPTIONS_LISTFILE)) 1479$$(_OBJ): PRIVATE_CPPFLAGS := @$$(call host-path,$$(_OPTIONS_LISTFILE)) 1480$$(_OBJ): $$(_OPTIONS_LISTFILE) 1481endif 1482 1483# llvm-rc-cc.exe has problem accepting input *.rs with path. To workaround: 1484# cd ($dir $(_SRC)) ; llvm-rs-cc $(notdir $(_SRC)) -o ...full-path... 1485# 1486ifeq ($$(_COMPAT),true) 1487$$(_OBJ): $$(_RS_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK) $$(NDK_DEPENDENCIES_CONVERTER) 1488 $$(call host-echo-build-step,$$(PRIVATE_ABI),$$(PRIVATE_TEXT)) "$$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_RS_SRC))" 1489 $$(hide) \ 1490 cd $$(call host-path,$$(dir $$(PRIVATE_RS_SRC))) && $$(PRIVATE_RS_CC) -o $$(call host-path,$$(abspath $$(dir $$(PRIVATE_OBJ))))/ -d $$(abspath $$(call host-path,$$(dir $$(PRIVATE_OBJ)))) -MD -reflect-c++ $$(PRIVATE_RS_FLAGS) $$(notdir $$(PRIVATE_RS_SRC)) 1491 $$(hide) \ 1492 $$(PRIVATE_RS_BCC) -O3 -o $$(call host-path,$$(PRIVATE_BC_OBJ)) -fPIC -shared -rt-path $$(call host-path,$(SYSROOT_LINK)/usr/lib/rs/libclcore.bc) -mtriple $$(PRIVATE_RS_TRIPLE) $$(call host-path,$$(PRIVATE_BC_SRC)) && \ 1493 $$(PRIVATE_CXX) -shared -Wl,-soname,librs.$$(PRIVATE_BC_SO) -nostdlib $$(call host-path,$$(PRIVATE_BC_OBJ)) $$(call host-path,$(SYSROOT_LINK)/usr/lib/rs/libcompiler_rt.a) -o $$(call host-path,$$(PRIVATE_OUT)/librs.$$(PRIVATE_BC_SO)) -L $$(call host-path,$(SYSROOT_LINK)/usr/lib) -L $$(call host-path,$(SYSROOT_LINK)/usr/lib/rs) -lRSSupport -lm -lc && \ 1494 $$(PRIVATE_CXX) -MMD -MP -MF $$(call convert-deps,$$(PRIVATE_DEPS)) $$(PRIVATE_CPPFLAGS) $$(call host-path,$$(PRIVATE_CPP_SRC)) -o $$(call host-path,$$(PRIVATE_OBJ)) \ 1495 $$(call cmd-convert-deps,$$(PRIVATE_DEPS)) 1496else 1497$$(_OBJ): $$(_RS_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK) $$(NDK_DEPENDENCIES_CONVERTER) 1498 $$(call host-echo-build-step,$$(PRIVATE_ABI),$$(PRIVATE_TEXT)) "$$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_RS_SRC))" 1499 $$(hide) \ 1500 cd $$(call host-path,$$(dir $$(PRIVATE_RS_SRC))) && $$(PRIVATE_RS_CC) -o $$(call host-path,$$(abspath $$(dir $$(PRIVATE_OBJ))))/ -d $$(abspath $$(call host-path,$$(dir $$(PRIVATE_OBJ)))) -MD -reflect-c++ $$(PRIVATE_RS_FLAGS) $$(notdir $$(PRIVATE_RS_SRC)) 1501 $$(hide) \ 1502 $$(PRIVATE_CXX) -MMD -MP -MF $$(call convert-deps,$$(PRIVATE_DEPS)) $$(PRIVATE_CPPFLAGS) $$(call host-path,$$(PRIVATE_CPP_SRC)) -o $$(call host-path,$$(PRIVATE_OBJ)) \ 1503 $$(call cmd-convert-deps,$$(PRIVATE_DEPS)) 1504endif 1505endef 1506 1507# This assumes the same things than ev-build-file, but will handle 1508# the definition of LOCAL_FILTER_ASM as well. 1509define ev-build-source-file 1510LOCAL_DEPENDENCY_DIRS += $$(dir $$(_OBJ)) 1511ifndef LOCAL_FILTER_ASM 1512 # Trivial case: Directly generate an object file 1513 $$(eval $$(call ev-build-file)) 1514else 1515 # This is where things get hairy, we first transform 1516 # the source into an assembler file, send it to the 1517 # filter, then generate a final object file from it. 1518 # 1519 1520 # First, remember the original settings and compute 1521 # the location of our temporary files. 1522 # 1523 _ORG_SRC := $$(_SRC) 1524 _ORG_OBJ := $$(_OBJ) 1525 _ORG_FLAGS := $$(_FLAGS) 1526 _ORG_TEXT := $$(_TEXT) 1527 1528 _OBJ_ASM_ORIGINAL := $$(patsubst %$$(TARGET_OBJ_EXTENSION),%.s,$$(_ORG_OBJ)) 1529 _OBJ_ASM_FILTERED := $$(patsubst %$$(TARGET_OBJ_EXTENSION),%.filtered.s,$$(_ORG_OBJ)) 1530 1531 # If the source file is a plain assembler file, we're going to 1532 # use it directly in our filter. 1533 ifneq (,$$(filter %.s,$$(_SRC))) 1534 _OBJ_ASM_ORIGINAL := $$(_SRC) 1535 endif 1536 1537 #$$(info SRC=$$(_SRC) OBJ=$$(_OBJ) OBJ_ORIGINAL=$$(_OBJ_ASM_ORIGINAL) OBJ_FILTERED=$$(_OBJ_ASM_FILTERED)) 1538 1539 # We need to transform the source into an assembly file, instead of 1540 # an object. The proper way to do that depends on the file extension. 1541 # 1542 # For C and C++ source files, simply replace the -c by an -S in the 1543 # compilation command (this forces the compiler to generate an 1544 # assembly file). 1545 # 1546 # For assembler templates (which end in .S), replace the -c with -E 1547 # to send it to the preprocessor instead. 1548 # 1549 # Don't do anything for plain assembly files (which end in .s) 1550 # 1551 ifeq (,$$(filter %.s,$$(_SRC))) 1552 _OBJ := $$(_OBJ_ASM_ORIGINAL) 1553 ifneq (,$$(filter %.S,$$(_SRC))) 1554 _FLAGS := $$(patsubst -c,-E,$$(_ORG_FLAGS)) 1555 else 1556 _FLAGS := $$(patsubst -c,-S,$$(_ORG_FLAGS)) 1557 endif 1558 $$(eval $$(call ev-build-file)) 1559 endif 1560 1561 # Next, process the assembly file with the filter 1562 $$(_OBJ_ASM_FILTERED): PRIVATE_ABI := $$(TARGET_ARCH_ABI) 1563 $$(_OBJ_ASM_FILTERED): PRIVATE_SRC := $$(_OBJ_ASM_ORIGINAL) 1564 $$(_OBJ_ASM_FILTERED): PRIVATE_DST := $$(_OBJ_ASM_FILTERED) 1565 $$(_OBJ_ASM_FILTERED): PRIVATE_FILTER := $$(LOCAL_FILTER_ASM) 1566 $$(_OBJ_ASM_FILTERED): PRIVATE_MODULE := $$(LOCAL_MODULE) 1567 $$(_OBJ_ASM_FILTERED): $$(_OBJ_ASM_ORIGINAL) 1568 $$(call host-echo-build-step,$$(PRIVATE_ABI),AsmFilter) "$$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" 1569 $$(hide) $$(PRIVATE_FILTER) $$(PRIVATE_SRC) $$(PRIVATE_DST) 1570 1571 # Then, generate the final object, we need to keep assembler-specific 1572 # flags which look like -Wa,<option>: 1573 _SRC := $$(_OBJ_ASM_FILTERED) 1574 _OBJ := $$(_ORG_OBJ) 1575 _FLAGS := $$(filter -Wa%,$$(_ORG_FLAGS)) -c 1576 _TEXT := Assembly 1577 $$(eval $$(call ev-build-file)) 1578endif 1579endef 1580 1581# ----------------------------------------------------------------------------- 1582# Template : ev-compile-c-source 1583# Arguments : 1: single C source file name (relative to LOCAL_PATH) 1584# 2: target object file (without path) 1585# Returns : None 1586# Usage : $(eval $(call ev-compile-c-source,<srcfile>,<objfile>) 1587# Rationale : Internal template evaluated by compile-c-source and 1588# compile-s-source 1589# ----------------------------------------------------------------------------- 1590define ev-compile-c-source 1591_SRC:=$$(call local-source-file-path,$(1)) 1592_OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(2) 1593 1594_FLAGS := $$($$(my)CFLAGS) \ 1595 $$(call get-src-file-target-cflags,$(1)) \ 1596 $$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \ 1597 $$(LOCAL_CFLAGS) \ 1598 $$(LOCAL_CONLYFLAGS) \ 1599 $$(NDK_APP_CFLAGS) \ 1600 $$(NDK_APP_CONLYFLAGS) \ 1601 $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 1602 -c \ 1603 1604_TEXT := Compile $$(call get-src-file-text,$1) 1605_CC := $$(NDK_CCACHE) $$(TARGET_CC) 1606 1607$$(eval $$(call ev-build-source-file)) 1608endef 1609 1610# ----------------------------------------------------------------------------- 1611# Template : ev-compile-asm-source 1612# Arguments : 1: single ASM source file name (relative to LOCAL_PATH) 1613# 2: target object file (without path) 1614# Returns : None 1615# Usage : $(eval $(call ev-compile-asm-source,<srcfile>,<objfile>) 1616# Rationale : Internal template evaluated by compile-asm-source 1617# ----------------------------------------------------------------------------- 1618define ev-compile-asm-source 1619_SRC:=$$(call local-source-file-path,$(1)) 1620_OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(2) 1621 1622_FLAGS := $$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \ 1623 $$(LOCAL_ASMFLAGS) \ 1624 $$(NDK_APP_ASMFLAGS) \ 1625 $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 1626 -f elf32 -m x86 1627 1628_TEXT := Assemble $$(call get-src-file-text,$1) 1629_CC := $$(NDK_CCACHE) $$(TARGET_ASM) 1630 1631$$(_OBJ): PRIVATE_ABI := $$(TARGET_ARCH_ABI) 1632$$(_OBJ): PRIVATE_SRC := $$(_SRC) 1633$$(_OBJ): PRIVATE_OBJ := $$(_OBJ) 1634$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) 1635$$(_OBJ): PRIVATE_TEXT := $$(_TEXT) 1636$$(_OBJ): PRIVATE_CC := $$(_CC) 1637$$(_OBJ): PRIVATE_CFLAGS := $$(_FLAGS) 1638 1639ifeq ($$(LOCAL_SHORT_COMMANDS),true) 1640_OPTIONS_LISTFILE := $$(_OBJ).cflags 1641$$(_OBJ): $$(call generate-list-file,$$(_FLAGS),$$(_OPTIONS_LISTFILE)) 1642$$(_OBJ): PRIVATE_CFLAGS := @$$(call host-path,$$(_OPTIONS_LISTFILE)) 1643$$(_OBJ): $$(_OPTIONS_LISTFILE) 1644endif 1645 1646$$(call generate-file-dir,$$(_OBJ)) 1647$$(_OBJ): $$(_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK) $$(NDK_DEPENDENCIES_CONVERTER) $(LOCAL_RS_OBJECTS) 1648 $$(call host-echo-build-step,$$(PRIVATE_ABI),$$(PRIVATE_TEXT)) "$$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" 1649 $$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) $$(call host-path,$$(PRIVATE_SRC)) -o $$(call host-path,$$(PRIVATE_OBJ)) 1650endef 1651 1652# ----------------------------------------------------------------------------- 1653# Function : compile-c-source 1654# Arguments : 1: single C source file name (relative to LOCAL_PATH) 1655# 2: object file 1656# Returns : None 1657# Usage : $(call compile-c-source,<srcfile>,<objfile>) 1658# Rationale : Setup everything required to build a single C source file 1659# ----------------------------------------------------------------------------- 1660compile-c-source = $(eval $(call ev-compile-c-source,$1,$2)) 1661 1662# ----------------------------------------------------------------------------- 1663# Function : compile-s-source 1664# Arguments : 1: single Assembly source file name (relative to LOCAL_PATH) 1665# 2: object file 1666# Returns : None 1667# Usage : $(call compile-s-source,<srcfile>,<objfile>) 1668# Rationale : Setup everything required to build a single Assembly source file 1669# ----------------------------------------------------------------------------- 1670compile-s-source = $(eval $(call ev-compile-c-source,$1,$2)) 1671 1672# ----------------------------------------------------------------------------- 1673# Function : compile-asm-source 1674# Arguments : 1: single Assembly source file name (relative to LOCAL_PATH) 1675# 2: object file 1676# Returns : None 1677# Usage : $(call compile-asm-source,<srcfile>,<objfile>) 1678# Rationale : Setup everything required to build a single Assembly source file 1679# ----------------------------------------------------------------------------- 1680compile-asm-source = $(eval $(call ev-compile-asm-source,$1,$2)) 1681 1682# ----------------------------------------------------------------------------- 1683# Template : ev-compile-cpp-source 1684# Arguments : 1: single C++ source file name (relative to LOCAL_PATH) 1685# 2: target object file (without path) 1686# Returns : None 1687# Usage : $(eval $(call ev-compile-cpp-source,<srcfile>,<objfile>) 1688# Rationale : Internal template evaluated by compile-cpp-source 1689# ----------------------------------------------------------------------------- 1690 1691define ev-compile-cpp-source 1692_SRC:=$$(call local-source-file-path,$(1)) 1693_OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(2) 1694_FLAGS := $$($$(my)CXXFLAGS) \ 1695 $$(call get-src-file-target-cflags,$(1)) \ 1696 $$(call host-c-includes, $$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \ 1697 $$(LOCAL_CFLAGS) \ 1698 $$(LOCAL_CPPFLAGS) \ 1699 $$(LOCAL_CXXFLAGS) \ 1700 $$(NDK_APP_CFLAGS) \ 1701 $$(NDK_APP_CPPFLAGS) \ 1702 $$(NDK_APP_CXXFLAGS) \ 1703 $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 1704 -c \ 1705 1706_CC := $$(NDK_CCACHE) $$($$(my)CXX) 1707_TEXT := Compile++ $$(call get-src-file-text,$1) 1708 1709$$(eval $$(call ev-build-source-file)) 1710endef 1711 1712# ----------------------------------------------------------------------------- 1713# Function : compile-cpp-source 1714# Arguments : 1: single C++ source file name (relative to LOCAL_PATH) 1715# : 2: object file name 1716# Returns : None 1717# Usage : $(call compile-cpp-source,<srcfile>) 1718# Rationale : Setup everything required to build a single C++ source file 1719# ----------------------------------------------------------------------------- 1720compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$2)) 1721 1722# ----------------------------------------------------------------------------- 1723# Template : ev-compile-rs-source 1724# Arguments : 1: single RS source file name (relative to LOCAL_PATH) 1725# 2: intermediate cpp file (without path) 1726# 3: intermediate bc file (without path) 1727# 4: so file from bc (without path) 1728# 5: target object file (without path) 1729# 6: 'true' if bcc_compat is required 1730# Returns : None 1731# Usage : $(eval $(call ev-compile-rs-source,<srcfile>,<cppfile>,<objfile>) 1732# Rationale : Internal template evaluated by compile-rs-source 1733# ----------------------------------------------------------------------------- 1734 1735define ev-compile-rs-source 1736_RS_SRC:=$$(call local-source-file-path,$(1)) 1737_CPP_SRC:=$$(LOCAL_OBJS_DIR:%/=%)/$(2) 1738_BC_SRC:=$$(LOCAL_OBJS_DIR:%/=%)/$(3) 1739_BC_SO:=$(4) 1740_OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(5) 1741_COMPAT := $(6) 1742_CPP_FLAGS := $$($$(my)CXXFLAGS) \ 1743 $$(call get-src-file-target-cflags,$(1)) \ 1744 $$(call host-c-includes, $$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \ 1745 $$(LOCAL_CFLAGS) \ 1746 $$(LOCAL_CPPFLAGS) \ 1747 $$(LOCAL_CXXFLAGS) \ 1748 $$(NDK_APP_CFLAGS) \ 1749 $$(NDK_APP_CPPFLAGS) \ 1750 $$(NDK_APP_CXXFLAGS) \ 1751 $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 1752 -fno-rtti \ 1753 -c \ 1754 1755_RS_FLAGS := $$(call host-c-includes, $$(LOCAL_RENDERSCRIPT_INCLUDES) $$(LOCAL_PATH)) \ 1756 $$($$(my)RS_FLAGS) \ 1757 $$(LOCAL_RENDERSCRIPT_FLAGS) \ 1758 $$(call host-c-includes,$$($(my)RENDERSCRIPT_INCLUDES)) \ 1759 1760_RS_CC := $$(NDK_CCACHE) $$($$(my)RS_CC) 1761_RS_BCC := $$(NDK_CCACHE) $$($$(my)RS_BCC) 1762_CXX := $$(NDK_CCACHE) $$($$(my)CXX) 1763_TEXT := Compile RS 1764_OUT := $$($$(my)OUT) 1765 1766$$(eval $$(call ev-build-rs-file)) 1767endef 1768 1769# ----------------------------------------------------------------------------- 1770# Function : compile-rs-source 1771# Arguments : 1: single RS source file name (relative to LOCAL_PATH) 1772# 2: intermediate cpp file name 1773# 3: intermediate bc file 1774# 4: so file from bc (without path) 1775# 5: object file name 1776# 6: 'true' if bcc_compat is required 1777# Returns : None 1778# Usage : $(call compile-rs-source,<srcfile>) 1779# Rationale : Setup everything required to build a single RS source file 1780# ----------------------------------------------------------------------------- 1781compile-rs-source = $(eval $(call ev-compile-rs-source,$1,$2,$3,$4,$5,$6)) 1782 1783# 1784# Module imports 1785# 1786 1787# Initialize import list 1788import-init = $(eval __ndk_import_dirs :=) 1789 1790# Add an optional single directory to the list of import paths 1791# 1792import-add-path-optional = \ 1793 $(if $(strip $(wildcard $1)),\ 1794 $(call ndk_log,Adding import directory: $1)\ 1795 $(eval __ndk_import_dirs += $1)\ 1796 )\ 1797 1798# Add a directory to the list of import paths 1799# This will warn if the directory does not exist 1800# 1801import-add-path = \ 1802 $(if $(strip $(wildcard $1)),\ 1803 $(call ndk_log,Adding import directory: $1)\ 1804 $(eval __ndk_import_dirs += $1)\ 1805 ,\ 1806 $(call __ndk_info,WARNING: Ignoring unknown import directory: $1)\ 1807 )\ 1808 1809import-find-module = $(strip \ 1810 $(eval __imported_module :=)\ 1811 $(foreach __import_dir,$(__ndk_import_dirs),\ 1812 $(if $(__imported_module),,\ 1813 $(call ndk_log, Probing $(__import_dir)/$1/Android.mk)\ 1814 $(if $(strip $(wildcard $(__import_dir)/$1/Android.mk)),\ 1815 $(eval __imported_module := $(__import_dir)/$1)\ 1816 )\ 1817 )\ 1818 )\ 1819 $(__imported_module)\ 1820 ) 1821 1822# described in docs/IMPORT-MODULE.TXT 1823# $1: tag name for the lookup 1824# 1825# Small technical note on __ndk_import_depth: we use this variable to 1826# record the depth of recursive import-module calls. The variable is 1827# initially empty, and we append a "x" to it each time import-module is 1828# called. I.e. for three recursive calls to import-module, we would get 1829# the values: 1830# 1831# first call: x 1832# second call: xx 1833# third call: xxx 1834# 1835# This is used in module-add to add the top-level modules (i.e. those 1836# that are not added with import-module) to __ndk_top_modules, corresponding 1837# to the default list of wanted modules (see setup-toolchain.mk). 1838# 1839import-module = \ 1840 $(eval __import_tag := $(strip $1))\ 1841 $(if $(call seq,$(words $(__import_tag)),1),,\ 1842 $(call __ndk_info,$(call local-makefile): Cannot import module with spaces in tag: '$(__import_tag)')\ 1843 )\ 1844 $(if $(call set_is_member,$(__ndk_import_list),$(__import_tag)),\ 1845 $(call ndk_log,Skipping duplicate import for module with tag '$(__import_tag)')\ 1846 ,\ 1847 $(call ndk_log,Looking for imported module with tag '$(__import_tag)')\ 1848 $(eval __imported_path := $(call import-find-module,$(__import_tag)))\ 1849 $(if $(__imported_path),\ 1850 $(call ndk_log, Found in $(__imported_path))\ 1851 $(eval __ndk_import_depth := $(__ndk_import_depth)x) \ 1852 $(eval __ndk_import_list := $(call set_insert,$(__ndk_import_list),$(__import_tag)))\ 1853 $(eval include $(__imported_path)/Android.mk)\ 1854 $(eval __ndk_import_depth := $(__ndk_import_depth:%x=%))\ 1855 ,\ 1856 $(call __ndk_info,$(call local-makefile): Cannot find module with tag '$(__import_tag)' in import path)\ 1857 $(call __ndk_info,Are you sure your NDK_MODULE_PATH variable is properly defined ?)\ 1858 $(call __ndk_info,The following directories were searched:)\ 1859 $(for __import_dir,$(__ndk_import_dirs),\ 1860 $(call __ndk_info, $(__import_dir))\ 1861 )\ 1862 $(call __ndk_error,Aborting.)\ 1863 )\ 1864 ) 1865 1866# Only used for debugging 1867# 1868import-debug = \ 1869 $(info IMPORT DIRECTORIES:)\ 1870 $(foreach __dir,$(__ndk_import_dirs),\ 1871 $(info -- $(__dir))\ 1872 )\ 1873 1874# 1875# Module classes 1876# 1877NDK_MODULE_CLASSES := 1878 1879# Register a new module class 1880# $1: class name (e.g. STATIC_LIBRARY) 1881# $2: optional file prefix (e.g. 'lib') 1882# $3: optional file suffix (e.g. '.so') 1883# 1884module-class-register = \ 1885 $(eval NDK_MODULE_CLASSES += $1) \ 1886 $(eval NDK_MODULE_CLASS.$1.FILE_PREFIX := $2) \ 1887 $(eval NDK_MODULE_CLASS.$1.FILE_SUFFIX := $3) \ 1888 $(eval NDK_MODULE_CLASS.$1.INSTALLABLE := $(false)) \ 1889 1890# Same a module-class-register, for installable modules 1891# 1892# An installable module is one that will be copied to $PROJECT/libs/<abi>/ 1893# during the NDK build. 1894# 1895# $1: class name 1896# $2: optional file prefix 1897# $3: optional file suffix 1898# 1899module-class-register-installable = \ 1900 $(call module-class-register,$1,$2,$3) \ 1901 $(eval NDK_MODULE_CLASS.$1.INSTALLABLE := $(true)) 1902 1903# Returns $(true) if $1 is a valid/registered LOCAL_MODULE_CLASS value 1904# 1905module-class-check = $(call set_is_member,$(NDK_MODULE_CLASSES),$1) 1906 1907# Returns $(true) if $1 corresponds to an installable module class 1908# 1909module-class-is-installable = $(if $(NDK_MODULE_CLASS.$1.INSTALLABLE),$(true),$(false)) 1910 1911# Returns $(true) if $1 corresponds to a copyable prebuilt module class 1912# 1913module-class-is-copyable = $(if $(call seq,$1,PREBUILT_SHARED_LIBRARY),$(true),$(false)) 1914 1915# 1916# Register valid module classes 1917# 1918 1919# static libraries: 1920# <foo> -> lib<foo>.a by default 1921$(call module-class-register,STATIC_LIBRARY,lib,$(TARGET_LIB_EXTENSION)) 1922 1923# shared libraries: 1924# <foo> -> lib<foo>.so 1925# a shared library is installable. 1926$(call module-class-register-installable,SHARED_LIBRARY,lib,$(TARGET_SONAME_EXTENSION)) 1927 1928# executable 1929# <foo> -> <foo> 1930# an executable is installable. 1931$(call module-class-register-installable,EXECUTABLE,,) 1932 1933# prebuilt shared library 1934# <foo> -> <foo> (we assume it is already well-named) 1935# it is installable 1936$(call module-class-register-installable,PREBUILT_SHARED_LIBRARY,,) 1937 1938# prebuilt static library 1939# <foo> -> <foo> (we assume it is already well-named) 1940$(call module-class-register,PREBUILT_STATIC_LIBRARY,,) 1941 1942# 1943# C++ STL support 1944# 1945 1946# The list of registered STL implementations we support 1947NDK_STL_LIST := 1948 1949# Used internally to register a given STL implementation, see below. 1950# 1951# $1: STL name as it appears in APP_STL (e.g. system) 1952# $2: STL module name (e.g. cxx-stl/system) 1953# $3: list of static libraries all modules will depend on 1954# $4: list of shared libraries all modules will depend on 1955# 1956ndk-stl-register = \ 1957 $(eval __ndk_stl := $(strip $1)) \ 1958 $(eval NDK_STL_LIST += $(__ndk_stl)) \ 1959 $(eval NDK_STL.$(__ndk_stl).IMPORT_MODULE := $(strip $2)) \ 1960 $(eval NDK_STL.$(__ndk_stl).STATIC_LIBS := $(strip $(call strip-lib-prefix,$3))) \ 1961 $(eval NDK_STL.$(__ndk_stl).SHARED_LIBS := $(strip $(call strip-lib-prefix,$4))) 1962 1963# Called to check that the value of APP_STL is a valid one. 1964# $1: STL name as it apperas in APP_STL (e.g. 'system') 1965# 1966ndk-stl-check = \ 1967 $(if $(call set_is_member,$(NDK_STL_LIST),$1),,\ 1968 $(call __ndk_info,Invalid APP_STL value: $1)\ 1969 $(call __ndk_info,Please use one of the following instead: $(NDK_STL_LIST))\ 1970 $(call __ndk_error,Aborting)) 1971 1972# Called before the top-level Android.mk is parsed to 1973# select the STL implementation. 1974# $1: STL name as it appears in APP_STL (e.g. system) 1975# 1976ndk-stl-select = \ 1977 $(call import-module,$(NDK_STL.$1.IMPORT_MODULE)) 1978 1979# Called after all Android.mk files are parsed to add 1980# proper STL dependencies to every C++ module. 1981# $1: STL name as it appears in APP_STL (e.g. system) 1982# 1983ndk-stl-add-dependencies = \ 1984 $(call modules-add-c++-dependencies,\ 1985 $(NDK_STL.$1.STATIC_LIBS),\ 1986 $(NDK_STL.$1.SHARED_LIBS)) 1987 1988# 1989# 1990 1991# Register the 'system' STL implementation 1992# 1993$(call ndk-stl-register,\ 1994 system,\ 1995 cxx-stl/system,\ 1996 libstdc++,\ 1997 ) 1998 1999# Register the 'stlport_static' STL implementation 2000# 2001$(call ndk-stl-register,\ 2002 stlport_static,\ 2003 cxx-stl/stlport,\ 2004 stlport_static,\ 2005 ) 2006 2007# Register the 'stlport_shared' STL implementation 2008# 2009$(call ndk-stl-register,\ 2010 stlport_shared,\ 2011 cxx-stl/stlport,\ 2012 ,\ 2013 stlport_shared\ 2014 ) 2015 2016# Register the 'gnustl_static' STL implementation 2017# 2018$(call ndk-stl-register,\ 2019 gnustl_static,\ 2020 cxx-stl/gnu-libstdc++,\ 2021 gnustl_static,\ 2022 \ 2023 ) 2024 2025# Register the 'gnustl_shared' STL implementation 2026# 2027$(call ndk-stl-register,\ 2028 gnustl_shared,\ 2029 cxx-stl/gnu-libstdc++,\ 2030 ,\ 2031 gnustl_shared\ 2032 ) 2033 2034# Register the 'gabi++_static' STL implementation 2035# 2036$(call ndk-stl-register,\ 2037 gabi++_static,\ 2038 cxx-stl/gabi++,\ 2039 gabi++_static,\ 2040 \ 2041 ) 2042 2043# Register the 'gabi++_shared' STL implementation 2044# 2045$(call ndk-stl-register,\ 2046 gabi++_shared,\ 2047 cxx-stl/gabi++,\ 2048 ,\ 2049 gabi++_shared\ 2050 ) 2051 2052# Register the 'c++_static' STL implementation 2053# 2054$(call ndk-stl-register,\ 2055 c++_static,\ 2056 cxx-stl/llvm-libc++,\ 2057 c++_static,\ 2058 \ 2059 ) 2060 2061# Register the 'c++_shared' STL implementation 2062# 2063$(call ndk-stl-register,\ 2064 c++_shared,\ 2065 cxx-stl/llvm-libc++,\ 2066 ,\ 2067 c++_shared\ 2068 ) 2069 2070# The 'none' APP_STL value corresponds to no C++ support at 2071# all. Used by some of the STLport and GAbi++ test projects. 2072# 2073$(call ndk-stl-register,\ 2074 none,\ 2075 cxx-stl/system,\ 2076 ) 2077 2078ifneq (,$(NDK_UNIT_TESTS)) 2079$(call ndk-run-all-tests) 2080endif 2081