1# We use the GNU Make Standard Library 2include $(GDK_ROOT)/build/gmsl/gmsl 3 4# ----------------------------------------------------------------------------- 5# Macro : empty 6# Returns : an empty macro 7# Usage : $(empty) 8# ----------------------------------------------------------------------------- 9empty := 10 11# ----------------------------------------------------------------------------- 12# Macro : space 13# Returns : a single space 14# Usage : $(space) 15# ----------------------------------------------------------------------------- 16space := $(empty) $(empty) 17 18# ----------------------------------------------------------------------------- 19# Function : last2 20# Arguments: a list 21# Returns : the penultimate (next-to-last) element of a list 22# Usage : $(call last2, <LIST>) 23# ----------------------------------------------------------------------------- 24last2 = $(word $(words $1), x $1) 25 26# ----------------------------------------------------------------------------- 27# Function : last3 28# Arguments: a list 29# Returns : the antepenultimate (second-next-to-last) element of a list 30# Usage : $(call last3, <LIST>) 31# ----------------------------------------------------------------------------- 32last3 = $(word $(words $1), x x $1) 33 34# ----------------------------------------------------------------------------- 35# Function : remove-duplicates 36# Arguments: a list 37# Returns : the list with duplicate items removed, order is preserved. 38# Usage : $(call remove-duplicates, <LIST>) 39# Note : This is equivalent to the 'uniq' function provided by GMSL, 40# however this implementation is non-recursive and *much* 41# faster. It will also not explode the stack with a lot of 42# items like 'uniq' does. 43# ----------------------------------------------------------------------------- 44remove-duplicates = $(strip \ 45 $(eval __uniq_ret :=) \ 46 $(foreach __uniq_item,$1,\ 47 $(if $(findstring $(__uniq_item),$(__uniq_ret)),,\ 48 $(eval __uniq_ret += $(__uniq_item))\ 49 )\ 50 )\ 51 $(__uniq_ret)) 52 53# ----------------------------------------------------------------------------- 54# Macro : this-makefile 55# Returns : the name of the current Makefile in the inclusion stack 56# Usage : $(this-makefile) 57# ----------------------------------------------------------------------------- 58this-makefile = $(lastword $(MAKEFILE_LIST)) 59 60# ----------------------------------------------------------------------------- 61# Macro : local-makefile 62# Returns : the name of the last parsed Android-portable.mk file 63# Usage : $(local-makefile) 64# ----------------------------------------------------------------------------- 65local-makefile = $(lastword $(filter %Android-portable.mk,$(MAKEFILE_LIST))) 66 67# ----------------------------------------------------------------------------- 68# Function : assert-defined 69# Arguments: 1: list of variable names 70# Returns : None 71# Usage : $(call assert-defined, VAR1 VAR2 VAR3...) 72# Rationale: Checks that all variables listed in $1 are defined, or abort the 73# build 74# ----------------------------------------------------------------------------- 75assert-defined = $(foreach __varname,$(strip $1),\ 76 $(if $(strip $($(__varname))),,\ 77 $(call __gdk_error, Assertion failure: $(__varname) is not defined)\ 78 )\ 79) 80 81# ----------------------------------------------------------------------------- 82# Function : clear-vars 83# Arguments: 1: list of variable names 84# 2: file where the variable should be defined 85# Returns : None 86# Usage : $(call clear-vars, VAR1 VAR2 VAR3...) 87# Rationale: Clears/undefines all variables in argument list 88# ----------------------------------------------------------------------------- 89clear-vars = $(foreach __varname,$1,$(eval $(__varname) := $(empty))) 90 91# ----------------------------------------------------------------------------- 92# Function : check-required-vars 93# Arguments: 1: list of variable names 94# 2: file where the variable(s) should be defined 95# Returns : None 96# Usage : $(call check-required-vars, VAR1 VAR2 VAR3..., <file>) 97# Rationale: Checks that all required vars listed in $1 were defined by $2 98# or abort the build with an error 99# ----------------------------------------------------------------------------- 100check-required-vars = $(foreach __varname,$1,\ 101 $(if $(strip $($(__varname))),,\ 102 $(call __gdk_info, Required variable $(__varname) is not defined by $2)\ 103 $(call __gdk_error,Aborting)\ 104 )\ 105) 106 107# ----------------------------------------------------------------------------- 108# Function : host-path 109# Arguments: 1: file path 110# Returns : file path, as understood by the host file system 111# Usage : $(call host-path,<path>) 112# Rationale: This function is used to translate Cygwin paths into 113# Windows-specific ones. On other platforms, it will just 114# return its argument. 115# ----------------------------------------------------------------------------- 116ifeq ($(HOST_OS),windows) 117host-path = $(if $(strip $1),$(call cygwin-to-host-path,$1)) 118else 119host-path = $1 120endif 121 122# ----------------------------------------------------------------------------- 123# Function : host-c-includes 124# Arguments: 1: list of file paths (e.g. "foo bar") 125# Returns : list of include compiler options (e.g. "-Ifoo -Ibar") 126# Usage : $(call host-c-includes,<paths>) 127# Rationale: This function is used to translate Cygwin paths into 128# Windows-specific ones. On other platforms, it will just 129# return its argument. 130# ----------------------------------------------------------------------------- 131ifeq ($(HOST_OS),windows) 132host-c-includes = $(patsubst %,-I%,$(call host-path,$1)) 133else 134host-c-includes = $(1:%=-I%) 135endif 136 137 138# ----------------------------------------------------------------------------- 139# Function : link-whole-archives 140# Arguments: 1: list of whole static libraries 141# Returns : linker flags to use the whole static libraries 142# Usage : $(call link-whole-archives,<libraries>) 143# Rationale: This function is used to put the list of whole static libraries 144# inside a -Wl,--whole-archive ... -Wl,--no-whole-archive block. 145# If the list is empty, it returns an empty string. 146# This function also calls host-path to translate the library 147# paths. 148# ----------------------------------------------------------------------------- 149link-whole-archives = $(if $(strip $1),$(call link-whole-archive-flags,$1)) 150link-whole-archive-flags = -Wl,--whole-archive $(call host-path,$1) -Wl,--no-whole-archive 151 152# ============================================================================= 153# 154# Modules database 155# 156# The following declarations are used to manage the list of modules 157# defined in application's Android-portable.mk files. 158# 159# Technical note: 160# We use __gdk_modules to hold the list of all modules corresponding 161# to a given application. 162# 163# For each module 'foo', __gdk_modules.foo.<field> is used 164# to store module-specific information. 165# 166# type -> type of module (e.g. 'static', 'shared', ...) 167# depends -> list of other modules this module depends on 168# 169# Also, LOCAL_XXXX values defined for a module are recorded in XXXX, e.g.: 170# 171# PATH -> recorded LOCAL_PATH for the module 172# CFLAGS -> recorded LOCAL_CFLAGS for the module 173# ... 174# 175# Some of these are created by build scripts like BUILD_STATIC_LIBRARY: 176# 177# MAKEFILE -> The Android-portable.mk where the module is defined. 178# LDFLAGS -> Final linker flags 179# OBJECTS -> List of module objects 180# BUILT_MODULE -> location of module built file (e.g. obj/<app>/<abi>/libfoo.so) 181# 182# Note that some modules are never installed (e.g. static libraries). 183# 184# ============================================================================= 185 186# The list of LOCAL_XXXX variables that are recorded for each module definition 187# These are documented by docs/ANDROID-MK.TXT. Exception is LOCAL_MODULE 188# 189modules-LOCALS := \ 190 MODULE \ 191 MODULE_FILENAME \ 192 PATH \ 193 SRC_FILES \ 194 CPP_EXTENSION \ 195 C_INCLUDES \ 196 CFLAGS \ 197 CXXFLAGS \ 198 CPPFLAGS 199 200# The following are generated by the build scripts themselves 201 202# LOCAL_MAKEFILE will contain the path to the Android-portable.mk defining the module 203modules-LOCALS += MAKEFILE 204 205# LOCAL_OBJECTS will contain the list of object files generated from the 206# module's sources, if any. 207modules-LOCALS += OBJECTS 208 209# LOCAL_BUILT_MODULE will contain the location of the symbolic version of 210# the generated module (i.e. the one containing all symbols used during 211# native debugging). It is generally under $PROJECT/obj/local/ 212modules-LOCALS += BUILT_MODULE 213 214# LOCAL_OBJS_DIR will contain the location where the object files for 215# this module will be stored. Usually $PROJECT/obj/local/<module>/obj 216modules-LOCALS += OBJS_DIR 217 218# LOCAL_INSTALLED will contain the location of the installed version 219# of the module. Usually $PROJECT/libs/<abi>/<prefix><module><suffix> 220# where <prefix> and <suffix> depend on the module class. 221modules-LOCALS += INSTALLED 222 223# LOCAL_MODULE_CLASS will contain the type of the module 224# (e.g. STATIC_LIBRARY, SHARED_LIBRARY, etc...) 225modules-LOCALS += MODULE_CLASS 226 227# the list of managed fields per module 228modules-fields = depends \ 229 $(modules-LOCALS) 230 231# ----------------------------------------------------------------------------- 232# Function : modules-clear 233# Arguments: None 234# Returns : None 235# Usage : $(call modules-clear) 236# Rationale: clears the list of defined modules known by the build system 237# ----------------------------------------------------------------------------- 238modules-clear = \ 239 $(foreach __mod,$(__gdk_modules),\ 240 $(foreach __field,$(modules-fields),\ 241 $(eval __gdk_modules.$(__mod).$(__field) := $(empty))\ 242 )\ 243 )\ 244 $(eval __gdk_modules := $(empty_set)) \ 245 $(eval __gdk_top_modules := $(empty)) \ 246 $(eval __gdk_import_list := $(empty)) \ 247 $(eval __gdk_import_depth := $(empty)) 248 249# ----------------------------------------------------------------------------- 250# Function : modules-get-list 251# Arguments: None 252# Returns : The list of all recorded modules 253# Usage : $(call modules-get-list) 254# ----------------------------------------------------------------------------- 255modules-get-list = $(__gdk_modules) 256 257# ----------------------------------------------------------------------------- 258# Function : modules-get-top-list 259# Arguments: None 260# Returns : The list of all recorded non-imported modules 261# Usage : $(call modules-get-top-list) 262# ----------------------------------------------------------------------------- 263modules-get-top-list = $(__gdk_top_modules) 264 265# ----------------------------------------------------------------------------- 266# Function : module-add 267# Arguments: 1: module name 268# Returns : None 269# Usage : $(call module-add,<modulename>) 270# Rationale: add a new module. If it is already defined, print an error message 271# and abort. This will record all LOCAL_XXX variables for the module. 272# ----------------------------------------------------------------------------- 273module-add = \ 274 $(call assert-defined,LOCAL_MAKEFILE LOCAL_BUILT_MODULE LOCAL_OBJS_DIR LOCAL_MODULE_CLASS)\ 275 $(if $(call set_is_member,$(__gdk_modules),$1),\ 276 $(call __gdk_info,Trying to define local module '$1' in $(LOCAL_MAKEFILE).)\ 277 $(call __gdk_info,But this module was already defined by $(__gdk_modules.$1.MAKEFILE).)\ 278 $(call __gdk_error,Aborting.)\ 279 )\ 280 $(eval __gdk_modules := $(call set_insert,$(__gdk_modules),$1))\ 281 $(if $(strip $(__gdk_import_depth)),,\ 282 $(eval __gdk_top_modules := $(call set_insert,$(__gdk_top_modules),$1))\ 283 )\ 284 $(if $(call module-class-is-installable,$(LOCAL_MODULE_CLASS)),\ 285 $(eval LOCAL_INSTALLED := $(GDK_APP_DST_DIR)/$(notdir $(LOCAL_BUILT_MODULE)))\ 286 )\ 287 $(foreach __local,$(modules-LOCALS),\ 288 $(eval __gdk_modules.$1.$(__local) := $(LOCAL_$(__local)))\ 289 ) 290 291 292# Retrieve the class of module $1 293module-get-class = $(__gdk_modules.$1.MODULE_CLASS) 294 295# Retrieve built location of module $1 296module-get-built = $(__gdk_modules.$1.BUILT_MODULE) 297 298# Returns $(true) is module $1 is installable 299# An installable module is one that will be copied to $PROJECT/libs/<abi>/ 300# (e.g. shared libraries). 301# 302module-is-installable = $(call module-class-is-installable,$(call module-get-class,$1)) 303 304# Returns $(true) if module $1 is prebuilt 305# A prebuilt module is one declared with BUILD_PREBUILT_SHARED_LIBRARY or 306# BUILD_PREBUILT_STATIC_LIBRARY 307# 308module-is-prebuilt = $(call module-class-is-prebuilt,$(call module-get-class,$1)) 309 310# ----------------------------------------------------------------------------- 311# Function : module-get-export 312# Arguments: 1: module name 313# 2: export variable name without LOCAL_EXPORT_ prefix (e.g. 'CFLAGS') 314# Returns : Exported value 315# Usage : $(call module-get-export,<modulename>,<varname>) 316# Rationale: Return the recorded value of LOCAL_EXPORT_$2, if any, for module $1 317# ----------------------------------------------------------------------------- 318module-get-export = $(__gdk_modules.$1.EXPORT_$2) 319 320# ----------------------------------------------------------------------------- 321# Function : module-get-listed-export 322# Arguments: 1: list of module names 323# 2: export variable name without LOCAL_EXPORT_ prefix (e.g. 'CFLAGS') 324# Returns : Exported values 325# Usage : $(call module-get-listed-export,<module-list>,<varname>) 326# Rationale: Return the recorded value of LOCAL_EXPORT_$2, if any, for modules 327# listed in $1. 328# ----------------------------------------------------------------------------- 329module-get-listed-export = $(strip \ 330 $(foreach __listed_module,$1,\ 331 $(call module-get-export,$(__listed_module),$2)\ 332 )) 333 334# ----------------------------------------------------------------------------- 335# Function : modules-restore-locals 336# Arguments: 1: module name 337# Returns : None 338# Usage : $(call module-restore-locals,<modulename>) 339# Rationale: Restore the recorded LOCAL_XXX definitions for a given module. 340# ----------------------------------------------------------------------------- 341module-restore-locals = \ 342 $(foreach __local,$(modules-LOCALS),\ 343 $(eval LOCAL_$(__local) := $(__gdk_modules.$1.$(__local)))\ 344 ) 345 346# Dump all module information. Only use this for debugging 347modules-dump-database = \ 348 $(info Modules: $(__gdk_modules)) \ 349 $(foreach __mod,$(__gdk_modules),\ 350 $(info $(space)$(space)$(__mod):)\ 351 $(foreach __field,$(modules-fields),\ 352 $(info $(space)$(space)$(space)$(space)$(__field): $(__gdk_modules.$(__mod).$(__field)))\ 353 )\ 354 )\ 355 $(info --- end of modules list) 356 357 358# ----------------------------------------------------------------------------- 359# Function : module-add-static-depends 360# Arguments: 1: module name 361# 2: list/set of static library modules this module depends on. 362# Returns : None 363# Usage : $(call module-add-static-depends,<modulename>,<list of module names>) 364# Rationale: Record that a module depends on a set of static libraries. 365# Use module-get-static-dependencies to retrieve final list. 366# ----------------------------------------------------------------------------- 367module-add-static-depends = \ 368 $(call module-add-depends-any,$1,$2,depends) \ 369 370# ----------------------------------------------------------------------------- 371# Function : module-add-shared-depends 372# Arguments: 1: module name 373# 2: list/set of shared library modules this module depends on. 374# Returns : None 375# Usage : $(call module-add-shared-depends,<modulename>,<list of module names>) 376# Rationale: Record that a module depends on a set of shared libraries. 377# Use modulge-get-shared-dependencies to retrieve final list. 378# ----------------------------------------------------------------------------- 379module-add-shared-depends = \ 380 $(call module-add-depends-any,$1,$2,depends) \ 381 382# Used internally by module-add-static-depends and module-add-shared-depends 383# NOTE: this function must not modify the existing dependency order when new depends are added. 384# 385module-add-depends-any = \ 386 $(eval __gdk_modules.$1.$3 += $(filter-out $(__gdk_modules.$1.$3),$(call strip-lib-prefix,$2))) 387 388# Used to recompute all dependencies once all module information has been recorded. 389# 390modules-compute-dependencies = \ 391 $(foreach __module,$(__gdk_modules),\ 392 $(call module-compute-depends,$(__module))\ 393 ) 394 395module-compute-depends = \ 396 $(call module-add-static-depends,$1,$(__gdk_modules.$1.STATIC_LIBRARIES))\ 397 $(call module-add-static-depends,$1,$(__gdk_modules.$1.WHOLE_STATIC_LIBRARIES))\ 398 $(call module-add-shared-depends,$1,$(__gdk_modules.$1.SHARED_LIBRARIES))\ 399 400module-get-installed = $(__gdk_modules.$1.INSTALLED) 401 402# ----------------------------------------------------------------------------- 403# Function : modules-get-all-dependencies 404# Arguments: 1: list of module names 405# Returns : List of all the modules $1 depends on transitively. 406# Usage : $(call modules-all-get-dependencies,<list of module names>) 407# Rationale: This computes the closure of all module dependencies starting from $1 408# ----------------------------------------------------------------------------- 409module-get-all-dependencies = \ 410 $(strip $(call modules-get-closure,$1,depends)) 411 412modules-get-closure = \ 413 $(eval __closure_deps := $(strip $1)) \ 414 $(eval __closure_wq := $(__closure_deps)) \ 415 $(eval __closure_field := $(strip $2)) \ 416 $(call modules-closure)\ 417 $(__closure_deps) 418 419# Used internally by modules-get-dependencies 420# Note the tricky use of conditional recursion to work around the fact that 421# the GNU Make language does not have any conditional looping construct 422# like 'while'. 423# 424modules-closure = \ 425 $(eval __closure_mod := $(call first,$(__closure_wq))) \ 426 $(eval __closure_wq := $(call rest,$(__closure_wq))) \ 427 $(eval __closure_new := $(filter-out $(__closure_deps),$(__gdk_modules.$(__closure_mod).$(__closure_field))))\ 428 $(eval __closure_deps += $(__closure_new)) \ 429 $(eval __closure_wq := $(strip $(__closure_wq) $(__closure_new)))\ 430 $(if $(__closure_wq),$(call modules-closure)) \ 431 432# Return the C++ extension of a given module 433# 434module-get-cpp-extension = $(strip \ 435 $(if $(__gdk_modules.$1.CPP_EXTENSION),\ 436 $(__gdk_modules.$1.CPP_EXTENSION),\ 437 .cpp\ 438 )) 439 440# Return the list of C++ sources of a given module 441# 442module-get-c++-sources = \ 443 $(filter %$(call module-get-cpp-extension,$1),$(__gdk_modules.$1.SRC_FILES)) 444 445# Returns true if a module has C++ sources 446# 447module-has-c++ = $(strip $(call module-get-c++-sources,$1)) 448 449# Add C++ dependencies to any module that has C++ sources. 450# $1: list of C++ runtime static libraries (if any) 451# $2: list of C++ runtime shared libraries (if any) 452# 453modules-add-c++-dependencies = \ 454 $(foreach __module,$(__gdk_modules),\ 455 $(if $(call module-has-c++,$(__module)),\ 456 $(call gdk_log,Module '$(__module)' has C++ sources)\ 457 $(call module-add-c++-deps,$(__module),$1,$2),\ 458 )\ 459 ) 460 461# Add standard C++ dependencies to a given module 462# 463# $1: module name 464# $2: list of C++ runtime static libraries (if any) 465# $3: list of C++ runtime shared libraries (if any) 466# 467module-add-c++-deps = \ 468 $(eval __gdk_modules.$1.STATIC_LIBRARIES += $(2))\ 469 $(eval __gdk_modules.$1.SHARED_LIBRARIES += $(3)) 470 471 472# ============================================================================= 473# 474# Utility functions 475# 476# ============================================================================= 477 478# ----------------------------------------------------------------------------- 479# Function : parent-dir 480# Arguments: 1: path 481# Returns : Parent dir or path of $1, with final separator removed. 482# ----------------------------------------------------------------------------- 483parent-dir = $(patsubst %/,%,$(dir $1)) 484 485 486# ----------------------------------------------------------------------------- 487# Function : pretty-dir 488# Arguments: 1: path 489# Returns : Remove GDK_PROJECT_PATH prefix from a given path. This can be 490# used to perform pretty-printing for logs. 491# ----------------------------------------------------------------------------- 492pretty-dir = $(patsubst $(GDK_ROOT)/%,<GDK>/%,\ 493 $(patsubst $(GDK_PROJECT_PATH)/%,%,$1)) 494 495# ----------------------------------------------------------------------------- 496# Function : check-user-define 497# Arguments: 1: name of variable that must be defined by the user 498# 2: name of Makefile where the variable should be defined 499# 3: name/description of the Makefile where the check is done, which 500# must be included by $2 501# Returns : None 502# ----------------------------------------------------------------------------- 503check-user-define = $(if $(strip $($1)),,\ 504 $(call __gdk_error,Missing $1 before including $3 in $2)) 505 506# ----------------------------------------------------------------------------- 507# This is used to check that LOCAL_MODULE is properly defined by an Android-portable.mk 508# file before including one of the $(BUILD_SHARED_LIBRARY), etc... files. 509# 510# Function : check-user-LOCAL_MODULE 511# Arguments: 1: name/description of the included build Makefile where the 512# check is done 513# Returns : None 514# Usage : $(call check-user-LOCAL_MODULE, BUILD_SHARED_LIBRARY) 515# ----------------------------------------------------------------------------- 516check-defined-LOCAL_MODULE = \ 517 $(call check-user-define,LOCAL_MODULE,$(local-makefile),$(1)) \ 518 $(if $(call seq,$(words $(LOCAL_MODULE)),1),,\ 519 $(call __gdk_info,LOCAL_MODULE definition in $(local-makefile) must not contain space)\ 520 $(call __gdk_error,Please correct error. Aborting)\ 521 ) 522 523# ----------------------------------------------------------------------------- 524# This is used to check that LOCAL_MODULE_FILENAME, if defined, is correct. 525# 526# Function : check-user-LOCAL_MODULE_FILENAME 527# Returns : None 528# Usage : $(call check-user-LOCAL_MODULE_FILENAME) 529# ----------------------------------------------------------------------------- 530check-LOCAL_MODULE_FILENAME = \ 531 $(if $(strip $(LOCAL_MODULE_FILENAME)),\ 532 $(if $(call seq,$(words $(LOCAL_MODULE_FILENAME)),1),,\ 533 $(call __gdk_info,$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain spaces)\ 534 $(call __gdk_error,Plase correct error. Aborting)\ 535 )\ 536 $(if $(filter %.a %.so,$(LOCAL_MODULE_FILENAME)),\ 537 $(call __gdk_info,$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME should not include file extensions)\ 538 )\ 539 ) 540 541# ----------------------------------------------------------------------------- 542# Function : handle-module-filename 543# Arguments : 1: default file prefix 544# 2: file suffix 545# Returns : None 546# Usage : $(call handle-module-filename,<prefix>,<suffix>) 547# Rationale : To be used to check and or set the module's filename through 548# the LOCAL_MODULE_FILENAME variable. 549# ----------------------------------------------------------------------------- 550handle-module-filename = $(eval $(call ev-handle-module-filename,$1,$2)) 551 552# 553# Check that LOCAL_MODULE_FILENAME is properly defined 554# - with one single item 555# - without a library file extension 556# - with no directory separators 557# 558define ev-check-module-filename 559ifneq (1,$$(words $$(LOCAL_MODULE_FILENAME))) 560 $$(call __gdk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain any space) 561 $$(call __gdk_error,Aborting) 562endif 563ifneq (,$$(filter %.a %.so,$$(LOCAL_MODULE_FILENAME))) 564 $$(call __gdk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain a file extension) 565 $$(call __gdk_error,Aborting) 566endif 567ifneq (1,$$(words $$(subst /, ,$$(LOCAL_MODULE_FILENAME)))) 568 $$(call __gdk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain directory separators) 569 $$(call __gdk_error,Aborting) 570endif 571endef 572 573# 574# Check the definition of LOCAL_MODULE_FILENAME. If none exists, 575# infer it from the LOCAL_MODULE name. 576# 577# $1: default file prefix 578# $2: default file suffix 579# 580define ev-handle-module-filename 581LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME)) 582ifndef LOCAL_MODULE_FILENAME 583 LOCAL_MODULE_FILENAME := $1$$(LOCAL_MODULE) 584endif 585$$(eval $$(call ev-check-module-filename)) 586LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$2 587endef 588 589handle-prebuilt-module-filename = $(eval $(call ev-handle-prebuilt-module-filename,$1)) 590 591# 592# Check the definition of LOCAL_MODULE_FILENAME for a _prebuilt_ module. 593# If none exists, infer it from $(LOCAL_SRC_FILES) 594# 595# $1: default file suffix 596# 597define ev-handle-prebuilt-module-filename 598LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME)) 599ifndef LOCAL_MODULE_FILENAME 600 LOCAL_MODULE_FILENAME := $$(notdir $(LOCAL_SRC_FILES)) 601 LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%.a=%) 602 LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%.so=%) 603endif 604LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$1 605$$(eval $$(call ev-check-module-filename)) 606endef 607 608 609# ----------------------------------------------------------------------------- 610# Function : handle-module-built 611# Returns : None 612# Usage : $(call handle-module-built) 613# Rationale : To be used to automatically compute the location of the generated 614# binary file, and the directory where to place its object files. 615# ----------------------------------------------------------------------------- 616handle-module-built = \ 617 $(eval LOCAL_BUILT_MODULE := $(TARGET_OUT)/$(LOCAL_MODULE_FILENAME))\ 618 $(eval LOCAL_OBJS_DIR := $(TARGET_OBJS)/$(LOCAL_MODULE)) 619 620# ----------------------------------------------------------------------------- 621# Strip any 'lib' prefix in front of a given string. 622# 623# Function : strip-lib-prefix 624# Arguments: 1: module name 625# Returns : module name, without any 'lib' prefix if any 626# Usage : $(call strip-lib-prefix,$(LOCAL_MODULE)) 627# ----------------------------------------------------------------------------- 628strip-lib-prefix = $(1:lib%=%) 629 630# ----------------------------------------------------------------------------- 631# This is used to strip any lib prefix from LOCAL_MODULE, then check that 632# the corresponding module name is not already defined. 633# 634# Function : check-user-LOCAL_MODULE 635# Arguments: 1: path of Android-portable.mk where this LOCAL_MODULE is defined 636# Returns : None 637# Usage : $(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE)) 638# ----------------------------------------------------------------------------- 639check-LOCAL_MODULE = \ 640 $(eval LOCAL_MODULE := $$(call strip-lib-prefix,$$(LOCAL_MODULE))) 641 642# ----------------------------------------------------------------------------- 643# Macro : my-dir 644# Returns : the directory of the current Makefile 645# Usage : $(my-dir) 646# ----------------------------------------------------------------------------- 647my-dir = $(call parent-dir,$(lastword $(MAKEFILE_LIST))) 648 649# ----------------------------------------------------------------------------- 650# Function : all-makefiles-under 651# Arguments: 1: directory path 652# Returns : a list of all makefiles immediately below some directory 653# Usage : $(call all-makefiles-under, <some path>) 654# ----------------------------------------------------------------------------- 655all-makefiles-under = $(wildcard $1/*/Android-portable.mk) 656 657# ----------------------------------------------------------------------------- 658# Macro : all-subdir-makefiles 659# Returns : list of all makefiles in subdirectories of the current Makefile's 660# location 661# Usage : $(all-subdir-makefiles) 662# ----------------------------------------------------------------------------- 663all-subdir-makefiles = $(call all-makefiles-under,$(call my-dir)) 664 665# ============================================================================= 666# 667# Source file tagging support. 668# 669# Each source file listed in LOCAL_SRC_FILES can have any number of 670# 'tags' associated to it. A tag name must not contain space, and its 671# usage can vary. 672# 673# For example, the 'debug' tag is used to sources that must be built 674# in debug mode, the 'arm' tag is used for sources that must be built 675# using the 32-bit instruction set on ARM platforms, and 'neon' is used 676# for sources that must be built with ARM Advanced SIMD (a.k.a. NEON) 677# support. 678# 679# More tags might be introduced in the future. 680# 681# LOCAL_SRC_TAGS contains the list of all tags used (initially empty) 682# LOCAL_SRC_FILES contains the list of all source files. 683# LOCAL_SRC_TAG.<tagname> contains the set of source file names tagged 684# with <tagname> 685# LOCAL_SRC_FILES_TAGS.<filename> contains the set of tags for a given 686# source file name 687# 688# Tags are processed by a toolchain-specific function (e.g. TARGET-compute-cflags) 689# which will call various functions to compute source-file specific settings. 690# These are currently stored as: 691# 692# LOCAL_SRC_FILES_TARGET_CFLAGS.<filename> contains the list of 693# target-specific C compiler flags used to compile a given 694# source file. This is set by the function TARGET-set-cflags 695# defined in the toolchain's setup.mk script. 696# 697# LOCAL_SRC_FILES_TEXT.<filename> contains the 'text' that will be 698# displayed along the label of the build output line. For example 699# 'thumb' or 'arm ' with ARM-based toolchains. 700# 701# ============================================================================= 702 703# ----------------------------------------------------------------------------- 704# Macro : clear-all-src-tags 705# Returns : remove all source file tags and associated data. 706# Usage : $(clear-all-src-tags) 707# ----------------------------------------------------------------------------- 708clear-all-src-tags = \ 709$(foreach __tag,$(LOCAL_SRC_TAGS), \ 710 $(eval LOCAL_SRC_TAG.$(__tag) := $(empty)) \ 711) \ 712$(foreach __src,$(LOCAL_SRC_FILES), \ 713 $(eval LOCAL_SRC_FILES_TAGS.$(__src) := $(empty)) \ 714 $(eval LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) := $(empty)) \ 715 $(eval LOCAL_SRC_FILES_TEXT.$(__src) := $(empty)) \ 716) \ 717$(eval LOCAL_SRC_TAGS := $(empty_set)) 718 719# ----------------------------------------------------------------------------- 720# Macro : tag-src-files 721# Arguments: 1: list of source files to tag 722# 2: tag name (must not contain space) 723# Usage : $(call tag-src-files,<list-of-source-files>,<tagname>) 724# Rationale: Add a tag to a list of source files 725# ----------------------------------------------------------------------------- 726tag-src-files = \ 727$(eval LOCAL_SRC_TAGS := $(call set_insert,$2,$(LOCAL_SRC_TAGS))) \ 728$(eval LOCAL_SRC_TAG.$2 := $(call set_union,$1,$(LOCAL_SRC_TAG.$2))) \ 729$(foreach __src,$1, \ 730 $(eval LOCAL_SRC_FILES_TAGS.$(__src) += $2) \ 731) 732 733# ----------------------------------------------------------------------------- 734# Macro : get-src-files-with-tag 735# Arguments: 1: tag name 736# Usage : $(call get-src-files-with-tag,<tagname>) 737# Return : The list of source file names that have been tagged with <tagname> 738# ----------------------------------------------------------------------------- 739get-src-files-with-tag = $(LOCAL_SRC_TAG.$1) 740 741# ----------------------------------------------------------------------------- 742# Macro : get-src-files-without-tag 743# Arguments: 1: tag name 744# Usage : $(call get-src-files-without-tag,<tagname>) 745# Return : The list of source file names that have NOT been tagged with <tagname> 746# ----------------------------------------------------------------------------- 747get-src-files-without-tag = $(filter-out $(LOCAL_SRC_TAG.$1),$(LOCAL_SRC_FILES)) 748 749# ----------------------------------------------------------------------------- 750# Macro : set-src-files-target-cflags 751# Arguments: 1: list of source files 752# 2: list of compiler flags 753# Usage : $(call set-src-files-target-cflags,<sources>,<flags>) 754# Rationale: Set or replace the set of compiler flags that will be applied 755# when building a given set of source files. This function should 756# normally be called from the toolchain-specific function that 757# computes all compiler flags for all source files. 758# ----------------------------------------------------------------------------- 759set-src-files-target-cflags = $(foreach __src,$1,$(eval LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) := $2)) 760 761# ----------------------------------------------------------------------------- 762# Macro : add-src-files-target-cflags 763# Arguments: 1: list of source files 764# 2: list of compiler flags 765# Usage : $(call add-src-files-target-cflags,<sources>,<flags>) 766# Rationale: A variant of set-src-files-target-cflags that can be used 767# to append, instead of replace, compiler flags for specific 768# source files. 769# ----------------------------------------------------------------------------- 770add-src-files-target-cflags = $(foreach __src,$1,$(eval LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) += $2)) 771 772# ----------------------------------------------------------------------------- 773# Macro : get-src-file-target-cflags 774# Arguments: 1: single source file name 775# Usage : $(call get-src-file-target-cflags,<source>) 776# Rationale: Return the set of target-specific compiler flags that must be 777# applied to a given source file. These must be set prior to this 778# call using set-src-files-target-cflags or add-src-files-target-cflags 779# ----------------------------------------------------------------------------- 780get-src-file-target-cflags = $(LOCAL_SRC_FILES_TARGET_CFLAGS.$1) 781 782# ----------------------------------------------------------------------------- 783# Macro : set-src-files-text 784# Arguments: 1: list of source files 785# 2: text 786# Usage : $(call set-src-files-text,<sources>,<text>) 787# Rationale: Set or replace the 'text' associated to a set of source files. 788# The text is a very short string that complements the build 789# label. For example, it will be either 'thumb' or 'arm ' for 790# ARM-based toolchains. This function must be called by the 791# toolchain-specific functions that processes all source files. 792# ----------------------------------------------------------------------------- 793set-src-files-text = $(foreach __src,$1,$(eval LOCAL_SRC_FILES_TEXT.$(__src) := $2)) 794 795# ----------------------------------------------------------------------------- 796# Macro : get-src-file-text 797# Arguments: 1: single source file 798# Usage : $(call get-src-file-text,<source>) 799# Rationale: Return the 'text' associated to a given source file when 800# set-src-files-text was called. 801# ----------------------------------------------------------------------------- 802get-src-file-text = $(LOCAL_SRC_FILES_TEXT.$1) 803 804# This should only be called for debugging the source files tagging system 805dump-src-file-tags = \ 806$(info LOCAL_SRC_TAGS := $(LOCAL_SRC_TAGS)) \ 807$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES)) \ 808$(foreach __tag,$(LOCAL_SRC_TAGS),$(info LOCAL_SRC_TAG.$(__tag) = $(LOCAL_SRC_TAG.$(__tag)))) \ 809$(foreach __src,$(LOCAL_SRC_FILES),$(info LOCAL_SRC_FILES_TAGS.$(__src) = $(LOCAL_SRC_FILES_TAGS.$(__src)))) \ 810$(info WITH arm = $(call get-src-files-with-tag,arm)) \ 811$(info WITHOUT arm = $(call get-src-files-without-tag,arm)) \ 812$(foreach __src,$(LOCAL_SRC_FILES),$(info LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src) = $(LOCAL_SRC_FILES_TARGET_CFLAGS.$(__src)))) \ 813$(foreach __src,$(LOCAL_SRC_FILES),$(info LOCAL_SRC_FILES_TEXT.$(__src) = $(LOCAL_SRC_FILES_TEXT.$(__src)))) \ 814 815 816# ============================================================================= 817# 818# Application.mk support 819# 820# ============================================================================= 821 822# the list of variables that *must* be defined in Application.mk files 823GDK_APP_VARS_REQUIRED := 824 825# the list of variables that *may* be defined in Application.mk files 826GDK_APP_VARS_OPTIONAL := APP_OPTIM APP_CPPFLAGS APP_CFLAGS APP_CXXFLAGS \ 827 APP_PLATFORM APP_BUILD_SCRIPT APP_ABI APP_MODULES \ 828 APP_PROJECT_PATH APP_STL 829 830# the list of all variables that may appear in an Application.mk file 831# or defined by the build scripts. 832GDK_APP_VARS := $(GDK_APP_VARS_REQUIRED) \ 833 $(GDK_APP_VARS_OPTIONAL) \ 834 APP_DEBUG \ 835 APP_DEBUGGABLE \ 836 APP_MANIFEST 837 838# ============================================================================= 839# 840# Android.mk support 841# 842# ============================================================================= 843 844# ============================================================================= 845# 846# Build commands support 847# 848# ============================================================================= 849 850# ----------------------------------------------------------------------------- 851# Macro : hide 852# Returns : nothing 853# Usage : $(hide)<make commands> 854# Rationale: To be used as a prefix for Make build commands to hide them 855# by default during the build. To show them, set V=1 in your 856# environment or command-line. 857# 858# For example: 859# 860# foo.o: foo.c 861# -->|$(hide) <build-commands> 862# 863# Where '-->|' stands for a single tab character. 864# 865# ----------------------------------------------------------------------------- 866ifeq ($(V),1) 867hide = $(empty) 868else 869hide = @ 870endif 871 872# cmd-convert-deps 873# 874# Commands used to copy/convert the .d.org depency file generated by the 875# compiler into its final .d version. 876# 877# On windows, this myst convert the Windows paths to a format that our 878# Cygwin-based GNU Make can understand (i.e. C:/Foo => /cygdrive/c/Foo) 879# 880# On other platforms, this simply renames the file. 881# 882# NOTE: In certain cases, no dependency file will be generated by the 883# compiler (e.g. when compiling an assembly file as foo.s) 884# 885ifeq ($(HOST_OS),windows) 886cmd-convert-deps = \ 887 ( if [ -f "$1.org" ]; then \ 888 $(HOST_AWK) -f $(BUILD_AWK)/convert-deps-to-cygwin.awk $1.org > $1 && \ 889 rm -f $1.org; \ 890 fi ) 891else 892cmd-convert-deps = \ 893 ( if [ -f "$1.org" ]; then \ 894 rm -f $1 && \ 895 mv $1.org $1; \ 896 fi ) 897endif 898 899# This assumes that many variables have been pre-defined: 900# _SRC: source file 901# _OBJ: destination file 902# _CC: 'compiler' command 903# _FLAGS: 'compiler' flags 904# _TEXT: Display text (e.g. "Compile++ thumb", must be EXACTLY 17 chars long) 905# 906define ev-build-file 907$$(_OBJ): PRIVATE_SRC := $$(_SRC) 908$$(_OBJ): PRIVATE_OBJ := $$(_OBJ) 909$$(_OBJ): PRIVATE_DEPS := $$(call host-path,$$(_OBJ).d) 910$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) 911$$(_OBJ): PRIVATE_TEXT := "$$(_TEXT)" 912$$(_OBJ): PRIVATE_CC := $$(_CC) 913$$(_OBJ): PRIVATE_CFLAGS := $$(_FLAGS) 914$$(_OBJ): $$(_SRC) $$(LOCAL_MAKEFILE) $$(GDK_APP_APPLICATION_MK) 915 @mkdir -p $$(dir $$(PRIVATE_OBJ)) 916 @echo "$$(PRIVATE_TEXT): $$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" 917 $(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) $$(call host-path,$$(PRIVATE_SRC)) -o $$(call host-path,$$(PRIVATE_OBJ)) 918endef 919 920# This assumes the same things than ev-build-file, but will handle 921# the definition of LOCAL_FILTER_ASM as well. 922define ev-build-source-file 923LOCAL_DEPENDENCY_DIRS += $$(dir $$(_OBJ)) 924ifndef LOCAL_FILTER_ASM 925 # Trivial case: Directly generate an object file 926 $$(eval $$(call ev-build-file)) 927else 928 # This is where things get hairy, we first transform 929 # the source into an assembler file, send it to the 930 # filter, then generate a final object file from it. 931 # 932 933 # First, remember the original settings and compute 934 # the location of our temporary files. 935 # 936 _ORG_SRC := $$(_SRC) 937 _ORG_OBJ := $$(_OBJ) 938 _ORG_FLAGS := $$(_FLAGS) 939 _ORG_TEXT := $$(_TEXT) 940 941 _OBJ_ASM_ORIGINAL := $$(patsubst %.o,%.s,$$(_ORG_OBJ)) 942 _OBJ_ASM_FILTERED := $$(patsubst %.o,%.filtered.s,$$(_ORG_OBJ)) 943 944 # If the source file is a plain assembler file, we're going to 945 # use it directly in our filter. 946 ifneq (,$$(filter %.s,$$(_SRC))) 947 _OBJ_ASM_ORIGINAL := $$(_SRC) 948 endif 949 950 #$$(info SRC=$$(_SRC) OBJ=$$(_OBJ) OBJ_ORIGINAL=$$(_OBJ_ASM_ORIGINAL) OBJ_FILTERED=$$(_OBJ_ASM_FILTERED)) 951 952 # We need to transform the source into an assembly file, instead of 953 # an object. The proper way to do that depends on the file extension. 954 # 955 # For C and C++ source files, simply replace the -c by an -S in the 956 # compilation command (this forces the compiler to generate an 957 # assembly file). 958 # 959 # For assembler templates (which end in .S), replace the -c with -E 960 # to send it to the preprocessor instead. 961 # 962 # Don't do anything for plain assembly files (which end in .s) 963 # 964 ifeq (,$$(filter %.s,$$(_SRC))) 965 _OBJ := $$(_OBJ_ASM_ORIGINAL) 966 ifneq (,$$(filter %.S,$$(_SRC))) 967 _FLAGS := $$(patsubst -c,-E,$$(_ORG_FLAGS)) 968 else 969 _FLAGS := $$(patsubst -c,-S,$$(_ORG_FLAGS)) 970 endif 971 $$(eval $$(call ev-build-file)) 972 endif 973 974 # Next, process the assembly file with the filter 975 $$(_OBJ_ASM_FILTERED): PRIVATE_SRC := $$(_OBJ_ASM_ORIGINAL) 976 $$(_OBJ_ASM_FILTERED): PRIVATE_DST := $$(_OBJ_ASM_FILTERED) 977 $$(_OBJ_ASM_FILTERED): PRIVATE_FILTER := $$(LOCAL_FILTER_ASM) 978 $$(_OBJ_ASM_FILTERED): PRIVATE_MODULE := $$(LOCAL_MODULE) 979 $$(_OBJ_ASM_FILTERED): $$(_OBJ_ASM_ORIGINAL) 980 @echo "AsmFilter : $$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" 981 $(hide) $$(PRIVATE_FILTER) $$(PRIVATE_SRC) $$(PRIVATE_DST) 982 983 # Then, generate the final object, we need to keep assembler-specific 984 # flags which look like -Wa,<option>: 985 _SRC := $$(_OBJ_ASM_FILTERED) 986 _OBJ := $$(_ORG_OBJ) 987 _FLAGS := $$(filter -Wa%,$$(_ORG_FLAGS)) -c 988 _TEXT := "Assembly " 989 $$(eval $$(call ev-build-file)) 990endif 991endef 992 993# ----------------------------------------------------------------------------- 994# Template : ev-compile-c-source 995# Arguments : 1: single C source file name (relative to LOCAL_PATH) 996# 2: target object file (without path) 997# Returns : None 998# Usage : $(eval $(call ev-compile-c-source,<srcfile>,<objfile>) 999# Rationale : Internal template evaluated by compile-c-source and 1000# compile-s-source 1001# ----------------------------------------------------------------------------- 1002define ev-compile-c-source 1003_SRC:=$$(LOCAL_PATH)/$(1) 1004_OBJ:=$$(LOCAL_OBJS_DIR)/$(2) 1005 1006_FLAGS := $$($$(my)CFLAGS) \ 1007 $$(call get-src-file-target-cflags,$(1)) \ 1008 $$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \ 1009 $$(LOCAL_CFLAGS) \ 1010 $$(GDK_APP_CFLAGS) \ 1011 $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 1012 -c \ 1013 1014_TEXT := "Compile Bitcode " 1015_CC := $$(TARGET_CC) 1016 1017$$(eval $$(call ev-build-source-file)) 1018endef 1019 1020# ----------------------------------------------------------------------------- 1021# Function : compile-c-source 1022# Arguments : 1: single C source file name (relative to LOCAL_PATH) 1023# Returns : None 1024# Usage : $(call compile-c-source,<srcfile>) 1025# Rationale : Setup everything required to build a single C source file 1026# ----------------------------------------------------------------------------- 1027compile-c-source = $(eval $(call ev-compile-c-source,$1,$(1:%.c=%.bc))) 1028 1029# ----------------------------------------------------------------------------- 1030# Function : compile-s-source 1031# Arguments : 1: single Assembly source file name (relative to LOCAL_PATH) 1032# Returns : None 1033# Usage : $(call compile-s-source,<srcfile>) 1034# Rationale : Setup everything required to build a single Assembly source file 1035# ----------------------------------------------------------------------------- 1036compile-s-source = $(eval $(call ev-compile-c-source,$1,$(patsubst %.s,%.o,$(patsubst %.S,%.o,$1)))) 1037 1038 1039# ----------------------------------------------------------------------------- 1040# Template : ev-compile-cpp-source 1041# Arguments : 1: single C++ source file name (relative to LOCAL_PATH) 1042# 2: target object file (without path) 1043# Returns : None 1044# Usage : $(eval $(call ev-compile-cpp-source,<srcfile>,<objfile>) 1045# Rationale : Internal template evaluated by compile-cpp-source 1046# ----------------------------------------------------------------------------- 1047 1048define ev-compile-cpp-source 1049_SRC:=$$(LOCAL_PATH)/$(1) 1050_OBJ:=$$(LOCAL_OBJS_DIR)/$(2) 1051_FLAGS := $$($$(my)CXXFLAGS) \ 1052 $$(call get-src-file-target-cflags,$(1)) \ 1053 $$(call host-c-includes, $$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \ 1054 $$(LOCAL_CFLAGS) \ 1055 $$(LOCAL_CPPFLAGS) \ 1056 $$(LOCAL_CXXFLAGS) \ 1057 $$(GDK_APP_CFLAGS) \ 1058 $$(GDK_APP_CPPFLAGS) \ 1059 $$(GDK_APP_CXXFLAGS) \ 1060 $$(call host-c-includes,$$($(my)C_INCLUDES)) \ 1061 -c \ 1062 1063_CC := $$($$(my)CXX) 1064_TEXT := "Compile++ Bitcode" 1065 1066$$(eval $$(call ev-build-source-file)) 1067endef 1068 1069# ----------------------------------------------------------------------------- 1070# Function : compile-cpp-source 1071# Arguments : 1: single C++ source file name (relative to LOCAL_PATH) 1072# Returns : None 1073# Usage : $(call compile-c-source,<srcfile>) 1074# Rationale : Setup everything required to build a single C++ source file 1075# ----------------------------------------------------------------------------- 1076compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.bc))) 1077 1078# ----------------------------------------------------------------------------- 1079# Command : cmd-install-file 1080# Arguments : 1: source file 1081# 2: destination file 1082# Returns : None 1083# Usage : $(call cmd-install-file,<srcfile>,<dstfile>) 1084# Rationale : To be used as a Make build command to copy/install a file to 1085# a given location. 1086# ----------------------------------------------------------------------------- 1087define cmd-install-file 1088@mkdir -p $(dir $2) 1089$(hide) cp -fp $1 $2 1090endef 1091 1092 1093# 1094# Module Cannot import module with spaces in tag: '$(__import_tag)')\ 1095# )\ 1096# $(if $(call set_is_member,$(__gdk_import_list),$(__import_tag)),\ 1097# $(call gdk_log,Skipping duplicate import for module with tag '$(__import_tag)')\ 1098# ,\ 1099# $(call gdk_log,Looking for imported module with tag '$(__import_tag)')\ 1100# $(eval __imported_path := $(call import-find-module,$(__import_tag)))\ 1101# $(if $(__imported_path),\ 1102# $(call gdk_log, Found in $(__imported_path))\ 1103# $(eval __gdk_import_depth := $(__gdk_import_depth)x) \ 1104# $(eval __gdk_import_list := $(call set_insert,$(__gdk_import_list),$(__import_tag)))\ 1105# $(eval include $(__imported_path)/Android-portable.mk)\ 1106# $(eval __gdk_import_depth := $(__gdk_import_depth:%x=%))\ 1107# ,\ 1108# $(call __gdk_info,$(call local-makefile): Cannot find module with tag '$(__import_tag)' in import path)\ 1109# $(call __gdk_info,Are you sure your GDK_MODULE_PATH variable is properly defined ?)\ 1110# $(call __gdk_info,The following directories were searched:)\ 1111# $(for __import_dir,$(__gdk_import_dirs),\ 1112# $(call __gdk_info, $(__import_dir))\ 1113# )\ 1114# $(call __gdk_error,Aborting.)\ 1115# )\ 1116# ) 1117 1118# Only used for debugging 1119# 1120import-debug = \ 1121 $(info IMPORT DIRECTORIES:)\ 1122 $(foreach __dir,$(__gdk_import_dirs),\ 1123 $(info -- $(__dir))\ 1124 )\ 1125 1126# 1127# Module classes 1128# 1129GDK_MODULE_CLASSES := 1130 1131# Register a new module class 1132# $1: class name (e.g. STATIC_LIBRARY) 1133# $2: optional file prefix (e.g. 'lib') 1134# $3: optional file suffix (e.g. '.so') 1135# 1136module-class-register = \ 1137 $(eval GDK_MODULE_CLASSES += $1) \ 1138 $(eval GDK_MODULE_CLASS.$1.FILE_PREFIX := $2) \ 1139 $(eval GDK_MODULE_CLASS.$1.FILE_SUFFIX := $3) \ 1140 $(eval GDK_MODULE_CLASS.$1.INSTALLABLE := $(false)) \ 1141 1142# Same a module-class-register, for installable modules 1143# 1144# An installable module is one that will be copied to $PROJECT/libs/<abi>/ 1145# during the GDK build. 1146# 1147# $1: class name 1148# $2: optional file prefix 1149# $3: optional file suffix 1150# 1151module-class-register-installable = \ 1152 $(call module-class-register,$1,$2,$3) \ 1153 $(eval GDK_MODULE_CLASS.$1.INSTALLABLE := $(true)) 1154 1155module-class-set-prebuilt = \ 1156 $(eval GDK_MODULE_CLASS.$1.PREBUILT := $(true)) 1157 1158# Returns $(true) if $1 is a valid/registered LOCAL_MODULE_CLASS value 1159# 1160module-class-check = $(call set_is_member,$(GDK_MODULE_CLASSES),$1) 1161 1162# Returns $(true) if $1 corresponds to an installable module class 1163# 1164module-class-is-installable = $(if $(GDK_MODULE_CLASS.$1.INSTALLABLE),$(true),$(false)) 1165 1166# Returns $(true) if $1 corresponds to an installable module class 1167# 1168module-class-is-prebuilt = $(if $(GDK_MODULE_CLASS.$1.PREBUILT),$(true),$(false)) 1169 1170# 1171# Register valid module classes 1172# 1173 1174# static libraries: 1175# <foo> -> lib<foo>.a by default 1176#$(call module-class-register,STATIC_LIBRARY,lib,.a) 1177 1178# shared libraries: 1179# <foo> -> lib<foo>.so 1180# a shared library is installable. 1181#$(call module-class-register-installable,SHARED_LIBRARY,lib,.so) 1182 1183# bitcodes: 1184# <foo> -> lib<foo>.bc 1185$(call module-class-register-installable,BITCODE,lib,.bc) 1186 1187# executable 1188# <foo> -> <foo> 1189# an executable is installable. 1190#$(call module-class-register-installable,EXECUTABLE,,) 1191 1192# prebuilt shared library 1193# <foo> -> <foo> (we assume it is already well-named) 1194# it is installable 1195#$(call module-class-register-installable,PREBUILT_SHARED_LIBRARY,,) 1196#$(call module-class-set-prebuilt,PREBUILT_SHARED_LIBRARY) 1197 1198# prebuilt static library 1199# <foo> -> <foo> (we assume it is already well-named) 1200#$(call module-class-register,PREBUILT_STATIC_LIBRARY,,) 1201#$(call module-class-set-prebuilt,PREBUILT_STATIC_LIBRARY) 1202 1203# 1204# C++ STL support 1205# 1206 1207## The list of registered STL implementations we support 1208#GDK_STL_LIST := 1209# 1210## Used internally to register a given STL implementation, see below. 1211## 1212## $1: STL name as it appears in APP_STL (e.g. system) 1213## $2: STL module name (e.g. cxx-stl/system) 1214## $3: list of static libraries all modules will depend on 1215## $4: list of shared libraries all modules will depend on 1216## 1217#gdk-stl-register = \ 1218# $(eval __gdk_stl := $(strip $1)) \ 1219# $(eval GDK_STL_LIST += $(__gdk_stl)) \ 1220# $(eval GDK_STL.$(__gdk_stl).IMPORT_MODULE := $(strip $2)) \ 1221# $(eval GDK_STL.$(__gdk_stl).STATIC_LIBS := $(strip $3)) \ 1222# $(eval GDK_STL.$(__gdk_stl).SHARED_LIBS := $(strip $4)) 1223# 1224## Called to check that the value of APP_STL is a valid one. 1225## $1: STL name as it apperas in APP_STL (e.g. 'system') 1226## 1227#gdk-stl-check = \ 1228# $(if $(call set_is_member,$(GDK_STL_LIST),$1),,\ 1229# $(call __gdk_info,Invalid APP_STL value: $1)\ 1230# $(call __gdk_info,Please use one of the following instead: $(GDK_STL_LIST))\ 1231# $(call __gdk_error,Aborting)) 1232# 1233## Called before the top-level Android.mk is parsed to 1234## select the STL implementation. 1235## $1: STL name as it appears in APP_STL (e.g. system) 1236## 1237#gdk-stl-select = \ 1238# $(call import-module,$(GDK_STL.$1.IMPORT_MODULE)) 1239# 1240## Called after all Android.mk files are parsed to add 1241## proper STL dependencies to every C++ module. 1242## $1: STL name as it appears in APP_STL (e.g. system) 1243## 1244##gdk-stl-add-dependencies = \ 1245# $(call modules-add-c++-dependencies,\ 1246# $(GDK_STL.$1.STATIC_LIBS),\ 1247# $(GDK_STL.$1.SHARED_LIBS)) 1248# 1249## 1250## 1251# 1252## Register the 'system' STL implementation 1253## 1254#$(call gdk-stl-register,\ 1255# system,\ 1256# cxx-stl/system,\ 1257# libstdc++,\ 1258# ) 1259# 1260## Register the 'stlport_static' STL implementation 1261## 1262#$(call gdk-stl-register,\ 1263# stlport_static,\ 1264# cxx-stl/stlport,\ 1265# stlport_static,\ 1266# ) 1267# 1268## Register the 'stlport_shared' STL implementation 1269## 1270#$(call gdk-stl-register,\ 1271# stlport_shared,\ 1272# cxx-stl/stlport,\ 1273# ,\ 1274# stlport_shared\ 1275# ) 1276# 1277## Register the 'gnustl_static' STL implementation 1278## 1279#$(call gdk-stl-register,\ 1280# gnustl_static,\ 1281# cxx-stl/gnu-libstdc++,\ 1282# gnustl_static,\ 1283# \ 1284# ) 1285# 1286