The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2008 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | ## |
| 18 | ## Common build system definitions. Mostly standard |
| 19 | ## commands for building various types of targets, which |
| 20 | ## are used by others to construct the final targets. |
| 21 | ## |
| 22 | |
| 23 | # These are variables we use to collect overall lists |
| 24 | # of things being processed. |
| 25 | |
| 26 | # Full paths to all of the documentation |
| 27 | ALL_DOCS:= |
| 28 | |
| 29 | # The short names of all of the targets in the system. |
| 30 | # For each element of ALL_MODULES, two other variables |
| 31 | # are defined: |
| 32 | # $(ALL_MODULES.$(target)).BUILT |
| 33 | # $(ALL_MODULES.$(target)).INSTALLED |
| 34 | # The BUILT variable contains LOCAL_BUILT_MODULE for that |
| 35 | # target, and the INSTALLED variable contains the LOCAL_INSTALLED_MODULE. |
| 36 | # Some targets may have multiple files listed in the BUILT and INSTALLED |
| 37 | # sub-variables. |
| 38 | ALL_MODULES:= |
| 39 | |
| 40 | # Full paths to targets that should be added to the "make droid" |
| 41 | # set of installed targets. |
| 42 | ALL_DEFAULT_INSTALLED_MODULES:= |
| 43 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | # The list of tags that have been defined by |
| 45 | # LOCAL_MODULE_TAGS. Each word in this variable maps |
| 46 | # to a corresponding ALL_MODULE_TAGS.<tagname> variable |
| 47 | # that contains all of the INSTALLED_MODULEs with that tag. |
| 48 | ALL_MODULE_TAGS:= |
| 49 | |
| 50 | # Similar to ALL_MODULE_TAGS, but contains the short names |
| 51 | # of all targets for a particular tag. The top-level variable |
| 52 | # won't have the list of tags; ust ALL_MODULE_TAGS to get |
| 53 | # the list of all known tags. (This means that this variable |
| 54 | # will always be empty; it's just here as a placeholder for |
| 55 | # its sub-variables.) |
| 56 | ALL_MODULE_NAME_TAGS:= |
| 57 | |
| 58 | # Full paths to all prebuilt files that will be copied |
| 59 | # (used to make the dependency on acp) |
| 60 | ALL_PREBUILT:= |
| 61 | |
| 62 | # Full path to all files that are made by some tool |
| 63 | ALL_GENERATED_SOURCES:= |
| 64 | |
| 65 | # Full path to all asm, C, C++, lex and yacc generated C files. |
| 66 | # These all have an order-only dependency on the copied headers |
| 67 | ALL_C_CPP_ETC_OBJECTS:= |
| 68 | |
| 69 | # The list of dynamic binaries that haven't been stripped/compressed/prelinked. |
| 70 | ALL_ORIGINAL_DYNAMIC_BINARIES:= |
| 71 | |
| 72 | # These files go into the SDK |
| 73 | ALL_SDK_FILES:= |
| 74 | |
| 75 | # Files for dalvik. This is often build without building the rest of the OS. |
| 76 | INTERNAL_DALVIK_MODULES:= |
| 77 | |
| 78 | # All findbugs xml files |
| 79 | ALL_FINDBUGS_FILES:= |
| 80 | |
| 81 | ########################################################### |
| 82 | ## Debugging; prints a variable list to stdout |
| 83 | ########################################################### |
| 84 | |
| 85 | # $(1): variable name list, not variable values |
| 86 | define print-vars |
| 87 | $(foreach var,$(1), \ |
| 88 | $(info $(var):) \ |
| 89 | $(foreach word,$($(var)), \ |
| 90 | $(info $(space)$(space)$(word)) \ |
| 91 | ) \ |
| 92 | ) |
| 93 | endef |
| 94 | |
| 95 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 96 | ## Evaluates to true if the string contains the word true, |
| 97 | ## and empty otherwise |
| 98 | ## $(1): a var to test |
| 99 | ########################################################### |
| 100 | |
| 101 | define true-or-empty |
| 102 | $(filter true, $(1)) |
| 103 | endef |
| 104 | |
| 105 | |
| 106 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 107 | ## Retrieve the directory of the current makefile |
| 108 | ########################################################### |
| 109 | |
| 110 | # Figure out where we are. |
| 111 | define my-dir |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 112 | $(strip \ |
| 113 | $(eval md_file_ := $$(lastword $$(MAKEFILE_LIST))) \ |
| 114 | $(if $(filter $(CLEAR_VARS),$(md_file_)), \ |
| 115 | $(error LOCAL_PATH must be set before including $$(CLEAR_VARS)) \ |
| 116 | , \ |
| 117 | $(patsubst %/,%,$(dir $(md_file_))) \ |
| 118 | ) \ |
| 119 | ) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 120 | endef |
| 121 | |
| 122 | ########################################################### |
| 123 | ## Retrieve a list of all makefiles immediately below some directory |
| 124 | ########################################################### |
| 125 | |
| 126 | define all-makefiles-under |
| 127 | $(wildcard $(1)/*/Android.mk) |
| 128 | endef |
| 129 | |
| 130 | ########################################################### |
| 131 | ## Look under a directory for makefiles that don't have parent |
| 132 | ## makefiles. |
| 133 | ########################################################### |
| 134 | |
| 135 | # $(1): directory to search under |
| 136 | # Ignores $(1)/Android.mk |
| 137 | define first-makefiles-under |
Joe Onorato | dc1a728 | 2009-08-04 15:58:26 -0400 | [diff] [blame] | 138 | $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git \ |
| 139 | --mindepth=2 $(1) Android.mk) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 140 | endef |
| 141 | |
| 142 | ########################################################### |
| 143 | ## Retrieve a list of all makefiles immediately below your directory |
| 144 | ########################################################### |
| 145 | |
| 146 | define all-subdir-makefiles |
| 147 | $(call all-makefiles-under,$(call my-dir)) |
| 148 | endef |
| 149 | |
| 150 | ########################################################### |
| 151 | ## Look in the named list of directories for makefiles, |
| 152 | ## relative to the current directory. |
| 153 | ########################################################### |
| 154 | |
| 155 | # $(1): List of directories to look for under this directory |
| 156 | define all-named-subdir-makefiles |
| 157 | $(wildcard $(addsuffix /Android.mk, $(addprefix $(my-dir)/,$(1)))) |
| 158 | endef |
| 159 | |
| 160 | ########################################################### |
| 161 | ## Find all of the java files under the named directories. |
| 162 | ## Meant to be used like: |
| 163 | ## SRC_FILES := $(call all-java-files-under,src tests) |
| 164 | ########################################################### |
| 165 | |
| 166 | define all-java-files-under |
| 167 | $(patsubst ./%,%, \ |
| 168 | $(shell cd $(LOCAL_PATH) ; \ |
| 169 | find $(1) -name "*.java" -and -not -name ".*") \ |
| 170 | ) |
| 171 | endef |
| 172 | |
| 173 | ########################################################### |
| 174 | ## Find all of the java files from here. Meant to be used like: |
| 175 | ## SRC_FILES := $(call all-subdir-java-files) |
| 176 | ########################################################### |
| 177 | |
| 178 | define all-subdir-java-files |
| 179 | $(call all-java-files-under,.) |
| 180 | endef |
| 181 | |
| 182 | ########################################################### |
| 183 | ## Find all of the c files under the named directories. |
| 184 | ## Meant to be used like: |
| 185 | ## SRC_FILES := $(call all-c-files-under,src tests) |
| 186 | ########################################################### |
| 187 | |
| 188 | define all-c-files-under |
| 189 | $(patsubst ./%,%, \ |
| 190 | $(shell cd $(LOCAL_PATH) ; \ |
| 191 | find $(1) -name "*.c" -and -not -name ".*") \ |
| 192 | ) |
| 193 | endef |
| 194 | |
| 195 | ########################################################### |
| 196 | ## Find all of the c files from here. Meant to be used like: |
| 197 | ## SRC_FILES := $(call all-subdir-c-files) |
| 198 | ########################################################### |
| 199 | |
| 200 | define all-subdir-c-files |
| 201 | $(call all-c-files-under,.) |
| 202 | endef |
| 203 | |
| 204 | ########################################################### |
| 205 | ## Find all files named "I*.aidl" under the named directories, |
| 206 | ## which must be relative to $(LOCAL_PATH). The returned list |
| 207 | ## is relative to $(LOCAL_PATH). |
| 208 | ########################################################### |
| 209 | |
| 210 | define all-Iaidl-files-under |
| 211 | $(patsubst ./%,%, \ |
| 212 | $(shell cd $(LOCAL_PATH) ; \ |
| 213 | find $(1) -name "I*.aidl" -and -not -name ".*") \ |
| 214 | ) |
| 215 | endef |
| 216 | |
| 217 | ########################################################### |
| 218 | ## Find all of the "I*.aidl" files under $(LOCAL_PATH). |
| 219 | ########################################################### |
| 220 | |
| 221 | define all-subdir-Iaidl-files |
| 222 | $(call all-Iaidl-files-under,.) |
| 223 | endef |
| 224 | |
| 225 | ########################################################### |
Bjorn Bringert | a89c990 | 2010-02-02 17:36:20 +0000 | [diff] [blame] | 226 | ## Find all of the logtags files under the named directories. |
| 227 | ## Meant to be used like: |
| 228 | ## SRC_FILES := $(call all-logtags-files-under,src) |
| 229 | ########################################################### |
| 230 | |
| 231 | define all-logtags-files-under |
| 232 | $(patsubst ./%,%, \ |
| 233 | $(shell cd $(LOCAL_PATH) ; \ |
| 234 | find $(1) -name "*.logtags" -and -not -name ".*") \ |
| 235 | ) |
| 236 | endef |
| 237 | |
| 238 | ########################################################### |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 239 | ## Find all of the RenderScript files under the named directories. |
| 240 | ## Meant to be used like: |
| 241 | ## SRC_FILES := $(call all-renderscript-files-under,src) |
| 242 | ########################################################### |
| 243 | |
| 244 | define all-renderscript-files-under |
| 245 | $(patsubst ./%,%, \ |
| 246 | $(shell cd $(LOCAL_PATH) ; \ |
| 247 | find $(1) -name "*.rs" -and -not -name ".*") \ |
| 248 | ) |
| 249 | endef |
| 250 | |
| 251 | ########################################################### |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 252 | ## Find all of the html files under the named directories. |
| 253 | ## Meant to be used like: |
| 254 | ## SRC_FILES := $(call all-html-files-under,src tests) |
| 255 | ########################################################### |
| 256 | |
| 257 | define all-html-files-under |
| 258 | $(patsubst ./%,%, \ |
| 259 | $(shell cd $(LOCAL_PATH) ; \ |
| 260 | find $(1) -name "*.html" -and -not -name ".*") \ |
| 261 | ) |
| 262 | endef |
| 263 | |
| 264 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 265 | ## Find all of the html files from here. Meant to be used like: |
| 266 | ## SRC_FILES := $(call all-subdir-html-files) |
| 267 | ########################################################### |
| 268 | |
| 269 | define all-subdir-html-files |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 270 | $(call all-html-files-under,.) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 271 | endef |
| 272 | |
| 273 | ########################################################### |
| 274 | ## Find all of the files matching pattern |
| 275 | ## SRC_FILES := $(call find-subdir-files, <pattern>) |
| 276 | ########################################################### |
| 277 | |
| 278 | define find-subdir-files |
| 279 | $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find $(1))) |
| 280 | endef |
| 281 | |
| 282 | ########################################################### |
| 283 | # find the files in the subdirectory $1 of LOCAL_DIR |
| 284 | # matching pattern $2, filtering out files $3 |
| 285 | # e.g. |
| 286 | # SRC_FILES += $(call find-subdir-subdir-files, \ |
| 287 | # css, *.cpp, DontWantThis.cpp) |
| 288 | ########################################################### |
| 289 | |
| 290 | define find-subdir-subdir-files |
| 291 | $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \ |
| 292 | $(LOCAL_PATH) ; find $(1) -maxdepth 1 -name $(2)))) |
| 293 | endef |
| 294 | |
| 295 | ########################################################### |
| 296 | ## Find all of the files matching pattern |
| 297 | ## SRC_FILES := $(call all-subdir-java-files) |
| 298 | ########################################################### |
| 299 | |
| 300 | define find-subdir-assets |
| 301 | $(if $(1),$(patsubst ./%,%, \ |
| 302 | $(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -type f -and -not -type l ; fi)), \ |
| 303 | $(warning Empty argument supplied to find-subdir-assets) \ |
| 304 | ) |
| 305 | endef |
| 306 | |
| 307 | ########################################################### |
| 308 | ## Find various file types in a list of directories relative to $(LOCAL_PATH) |
| 309 | ########################################################### |
| 310 | |
| 311 | define find-other-java-files |
| 312 | $(call find-subdir-files,$(1) -name "*.java" -and -not -name ".*") |
| 313 | endef |
| 314 | |
| 315 | define find-other-html-files |
| 316 | $(call find-subdir-files,$(1) -name "*.html" -and -not -name ".*") |
| 317 | endef |
| 318 | |
| 319 | ########################################################### |
| 320 | ## Scan through each directory of $(1) looking for files |
| 321 | ## that match $(2) using $(wildcard). Useful for seeing if |
| 322 | ## a given directory or one of its parents contains |
| 323 | ## a particular file. Returns the first match found, |
| 324 | ## starting furthest from the root. |
| 325 | ########################################################### |
| 326 | |
| 327 | define find-parent-file |
| 328 | $(strip \ |
| 329 | $(eval _fpf := $(wildcard $(strip $(1))/$(strip $(2)))) \ |
| 330 | $(if $(_fpf),$(_fpf), \ |
| 331 | $(if $(filter-out ./ .,$(1)), \ |
| 332 | $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \ |
| 333 | ) \ |
| 334 | ) \ |
| 335 | ) |
| 336 | endef |
| 337 | |
| 338 | ########################################################### |
| 339 | ## Function we can evaluate to introduce a dynamic dependency |
| 340 | ########################################################### |
| 341 | |
| 342 | define add-dependency |
| 343 | $(1): $(2) |
| 344 | endef |
| 345 | |
| 346 | ########################################################### |
| 347 | ## Set up the dependencies for a prebuilt target |
| 348 | ## $(call add-prebuilt-file, srcfile, [targetclass]) |
| 349 | ########################################################### |
| 350 | |
| 351 | define add-prebuilt-file |
| 352 | $(eval $(include-prebuilt)) |
| 353 | endef |
| 354 | |
| 355 | define include-prebuilt |
| 356 | include $$(CLEAR_VARS) |
| 357 | LOCAL_SRC_FILES := $(1) |
| 358 | LOCAL_BUILT_MODULE_STEM := $(1) |
| 359 | LOCAL_MODULE_SUFFIX := $$(suffix $(1)) |
| 360 | LOCAL_MODULE := $$(basename $(1)) |
| 361 | LOCAL_MODULE_CLASS := $(2) |
| 362 | include $$(BUILD_PREBUILT) |
| 363 | endef |
| 364 | |
| 365 | ########################################################### |
| 366 | ## do multiple prebuilts |
| 367 | ## $(call target class, files ...) |
| 368 | ########################################################### |
| 369 | |
| 370 | define add-prebuilt-files |
| 371 | $(foreach f,$(2),$(call add-prebuilt-file,$f,$(1))) |
| 372 | endef |
| 373 | |
| 374 | |
| 375 | |
| 376 | ########################################################### |
| 377 | ## The intermediates directory. Where object files go for |
| 378 | ## a given target. We could technically get away without |
| 379 | ## the "_intermediates" suffix on the directory, but it's |
| 380 | ## nice to be able to grep for that string to find out if |
| 381 | ## anyone's abusing the system. |
| 382 | ########################################################### |
| 383 | |
| 384 | # $(1): target class, like "APPS" |
| 385 | # $(2): target name, like "NotePad" |
| 386 | # $(3): if non-empty, this is a HOST target. |
| 387 | # $(4): if non-empty, force the intermediates to be COMMON |
| 388 | define intermediates-dir-for |
| 389 | $(strip \ |
| 390 | $(eval _idfClass := $(strip $(1))) \ |
| 391 | $(if $(_idfClass),, \ |
| 392 | $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \ |
| 393 | $(eval _idfName := $(strip $(2))) \ |
| 394 | $(if $(_idfName),, \ |
| 395 | $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \ |
| 396 | $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 397 | $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 398 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \ |
| 399 | , \ |
| 400 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \ |
| 401 | ) \ |
| 402 | $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ |
| 403 | ) |
| 404 | endef |
| 405 | |
| 406 | # Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE |
| 407 | # to determine the intermediates directory. |
| 408 | # |
| 409 | # $(1): if non-empty, force the intermediates to be COMMON |
| 410 | define local-intermediates-dir |
| 411 | $(strip \ |
| 412 | $(if $(strip $(LOCAL_MODULE_CLASS)),, \ |
| 413 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \ |
| 414 | $(if $(strip $(LOCAL_MODULE)),, \ |
| 415 | $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \ |
| 416 | $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \ |
| 417 | ) |
| 418 | endef |
| 419 | |
| 420 | ########################################################### |
| 421 | ## Convert "path/to/libXXX.so" to "-lXXX". |
| 422 | ## Any "path/to/libXXX.a" elements pass through unchanged. |
| 423 | ########################################################### |
| 424 | |
| 425 | define normalize-libraries |
| 426 | $(foreach so,$(filter %.so,$(1)),-l$(patsubst lib%.so,%,$(notdir $(so))))\ |
| 427 | $(filter-out %.so,$(1)) |
| 428 | endef |
| 429 | |
| 430 | # TODO: change users to call the common version. |
| 431 | define normalize-host-libraries |
| 432 | $(call normalize-libraries,$(1)) |
| 433 | endef |
| 434 | |
| 435 | define normalize-target-libraries |
| 436 | $(call normalize-libraries,$(1)) |
| 437 | endef |
| 438 | |
| 439 | ########################################################### |
| 440 | ## Convert a list of short module names (e.g., "framework", "Browser") |
| 441 | ## into the list of files that are built for those modules. |
| 442 | ## NOTE: this won't return reliable results until after all |
| 443 | ## sub-makefiles have been included. |
| 444 | ## $(1): target list |
| 445 | ########################################################### |
| 446 | |
| 447 | define module-built-files |
| 448 | $(foreach module,$(1),$(ALL_MODULES.$(module).BUILT)) |
| 449 | endef |
| 450 | |
| 451 | ########################################################### |
| 452 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 453 | ## into the list of files that are installed for those modules. |
| 454 | ## NOTE: this won't return reliable results until after all |
| 455 | ## sub-makefiles have been included. |
| 456 | ## $(1): target list |
| 457 | ########################################################### |
| 458 | |
| 459 | define module-installed-files |
| 460 | $(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED)) |
| 461 | endef |
| 462 | |
| 463 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 464 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 465 | ## into the list of files that should be used when linking |
| 466 | ## against that module as a public API. |
| 467 | ## TODO: Allow this for more than JAVA_LIBRARIES modules |
| 468 | ## NOTE: this won't return reliable results until after all |
| 469 | ## sub-makefiles have been included. |
| 470 | ## $(1): target list |
| 471 | ########################################################### |
| 472 | |
| 473 | define module-stubs-files |
| 474 | $(foreach module,$(1),$(ALL_MODULES.$(module).STUBS)) |
| 475 | endef |
| 476 | |
| 477 | ########################################################### |
| 478 | ## Evaluates to the timestamp file for a doc module, which |
| 479 | ## is the dependency that should be used. |
| 480 | ## $(1): doc module |
| 481 | ########################################################### |
| 482 | |
| 483 | define doc-timestamp-for |
| 484 | $(OUT_DOCS)/$(strip $(1))-timestamp |
| 485 | endef |
| 486 | |
| 487 | |
| 488 | ########################################################### |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 489 | ## Convert "core ext framework" to "out/.../javalib.jar ..." |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 490 | ## $(1): library list |
| 491 | ## $(2): Non-empty if IS_HOST_MODULE |
| 492 | ########################################################### |
| 493 | |
| 494 | # $(1): library name |
| 495 | # $(2): Non-empty if IS_HOST_MODULE |
| 496 | define _java-lib-dir |
| 497 | $(call intermediates-dir-for, \ |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 498 | JAVA_LIBRARIES,$(1),$(2),COMMON) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 499 | endef |
| 500 | |
| 501 | # $(1): library name |
| 502 | # $(2): Non-empty if IS_HOST_MODULE |
| 503 | define _java-lib-full-classes.jar |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 504 | $(call _java-lib-dir,$(1),$(2))/classes$(COMMON_JAVA_PACKAGE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 505 | endef |
| 506 | |
| 507 | # $(1): library name list |
| 508 | # $(2): Non-empty if IS_HOST_MODULE |
| 509 | define java-lib-files |
| 510 | $(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2))) |
| 511 | endef |
| 512 | |
| 513 | # $(1): library name |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 514 | # $(2): Non-empty if IS_HOST_MODULE |
| 515 | define _java-lib-full-dep |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 516 | $(call _java-lib-dir,$(1),$(2))/javalib$(COMMON_JAVA_PACKAGE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 517 | endef |
| 518 | |
| 519 | # $(1): library name list |
| 520 | # $(2): Non-empty if IS_HOST_MODULE |
| 521 | define java-lib-deps |
| 522 | $(foreach lib,$(1),$(call _java-lib-full-dep,$(lib),$(2))) |
| 523 | endef |
| 524 | |
| 525 | ########################################################### |
Joe Onorato | 8dc8faa | 2010-09-14 13:09:48 -0400 | [diff] [blame] | 526 | ## Run rot13 on a string |
| 527 | ## $(1): the string. Must be one line. |
| 528 | ########################################################### |
| 529 | define rot13 |
| 530 | $(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M') |
| 531 | endef |
| 532 | |
| 533 | |
| 534 | ########################################################### |
| 535 | ## Returns true if $(1) and $(2) are equal. Returns |
| 536 | ## the empty string if they are not equal. |
| 537 | ########################################################### |
| 538 | define streq |
| 539 | $(strip $(if $(strip $(1)),\ |
| 540 | $(if $(strip $(2)),\ |
| 541 | $(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \ |
| 542 | ),\ |
| 543 | $(if $(strip $(2)),\ |
| 544 | ,\ |
| 545 | true)\ |
| 546 | )) |
| 547 | endef |
| 548 | |
| 549 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 550 | ## Convert "a b c" into "a:b:c" |
| 551 | ########################################################### |
| 552 | |
| 553 | empty := |
| 554 | space := $(empty) $(empty) |
| 555 | |
| 556 | define normalize-path-list |
| 557 | $(subst $(space),:,$(strip $(1))) |
| 558 | endef |
| 559 | |
| 560 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 561 | ## Read the word out of a colon-separated list of words. |
| 562 | ## This has the same behavior as the built-in function |
| 563 | ## $(word n,str). |
| 564 | ## |
| 565 | ## The individual words may not contain spaces. |
| 566 | ## |
| 567 | ## $(1): 1 based index |
| 568 | ## $(2): value of the form a:b:c... |
| 569 | ########################################################### |
| 570 | |
| 571 | define word-colon |
| 572 | $(word $(1),$(subst :,$(space),$(2))) |
| 573 | endef |
| 574 | |
| 575 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 576 | ## Convert "a=b c= d e = f" into "a=b c=d e=f" |
| 577 | ## |
| 578 | ## $(1): list to collapse |
| 579 | ## $(2): if set, separator word; usually "=", ":", or ":=" |
| 580 | ## Defaults to "=" if not set. |
| 581 | ########################################################### |
| 582 | |
| 583 | define collapse-pairs |
| 584 | $(eval _cpSEP := $(strip $(if $(2),$(2),=)))\ |
| 585 | $(subst $(space)$(_cpSEP)$(space),$(_cpSEP),$(strip \ |
| 586 | $(subst $(_cpSEP), $(_cpSEP) ,$(1)))) |
| 587 | endef |
| 588 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 589 | ########################################################### |
| 590 | ## MODULE_TAG set operations |
| 591 | ########################################################### |
| 592 | |
| 593 | # Given a list of tags, return the targets that specify |
| 594 | # any of those tags. |
| 595 | # $(1): tag list |
| 596 | define modules-for-tag-list |
| 597 | $(sort $(foreach tag,$(1),$(ALL_MODULE_TAGS.$(tag)))) |
| 598 | endef |
| 599 | |
| 600 | # Same as modules-for-tag-list, but operates on |
| 601 | # ALL_MODULE_NAME_TAGS. |
| 602 | # $(1): tag list |
| 603 | define module-names-for-tag-list |
| 604 | $(sort $(foreach tag,$(1),$(ALL_MODULE_NAME_TAGS.$(tag)))) |
| 605 | endef |
| 606 | |
| 607 | # Given an accept and reject list, find the matching |
| 608 | # set of targets. If a target has multiple tags and |
| 609 | # any of them are rejected, the target is rejected. |
| 610 | # Reject overrides accept. |
| 611 | # $(1): list of tags to accept |
| 612 | # $(2): list of tags to reject |
| 613 | #TODO(dbort): do $(if $(strip $(1)),$(1),$(ALL_MODULE_TAGS)) |
Jean-Baptiste Queru | 75127b7 | 2010-01-07 11:44:22 -0800 | [diff] [blame] | 614 | #TODO(jbq): as of 20100106 nobody uses the second parameter |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 615 | define get-tagged-modules |
| 616 | $(filter-out \ |
| 617 | $(call modules-for-tag-list,$(2)), \ |
| 618 | $(call modules-for-tag-list,$(1))) |
| 619 | endef |
| 620 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 621 | ########################################################### |
| 622 | ## Append a leaf to a base path. Properly deals with |
| 623 | ## base paths ending in /. |
| 624 | ## |
| 625 | ## $(1): base path |
| 626 | ## $(2): leaf path |
| 627 | ########################################################### |
| 628 | |
| 629 | define append-path |
| 630 | $(subst //,/,$(1)/$(2)) |
| 631 | endef |
| 632 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 633 | |
| 634 | ########################################################### |
| 635 | ## Package filtering |
| 636 | ########################################################### |
| 637 | |
| 638 | # Given a list of installed modules (short or long names) |
| 639 | # return a list of the packages (yes, .apk packages, not |
| 640 | # modules in general) that are overridden by this list and, |
| 641 | # therefore, should not be installed. |
| 642 | # $(1): mixed list of installed modules |
| 643 | # TODO: This is fragile; find a reliable way to get this information. |
| 644 | define _get-package-overrides |
| 645 | $(eval ### Discard any words containing slashes, unless they end in .apk, \ |
| 646 | ### in which case trim off the directory component and the suffix. \ |
| 647 | ### If there are no slashes, keep the entire word.) |
| 648 | $(eval _gpo_names := $(subst /,@@@ @@@,$(1))) |
| 649 | $(eval _gpo_names := \ |
| 650 | $(filter %.apk,$(_gpo_names)) \ |
| 651 | $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 652 | $(eval _gpo_names := $(patsubst %.apk,%,$(_gpo_names))) |
| 653 | $(eval _gpo_names := $(patsubst @@@%,%,$(_gpo_names))) |
| 654 | |
| 655 | $(eval ### Remove any remaining words that contain dots.) |
| 656 | $(eval _gpo_names := $(subst .,@@@ @@@,$(_gpo_names))) |
| 657 | $(eval _gpo_names := $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 658 | |
| 659 | $(eval ### Now we have a list of any words that could possibly refer to \ |
| 660 | ### packages, although there may be words that do not. Only \ |
| 661 | ### real packages will be present under PACKAGES.*, though.) |
| 662 | $(foreach _gpo_name,$(_gpo_names),$(PACKAGES.$(_gpo_name).OVERRIDES)) |
| 663 | endef |
| 664 | |
| 665 | define get-package-overrides |
| 666 | $(strip $(sort $(call _get-package-overrides,$(1)))) |
| 667 | endef |
| 668 | |
| 669 | ########################################################### |
| 670 | ## Output the command lines, or not |
| 671 | ########################################################### |
| 672 | |
| 673 | ifeq ($(strip $(SHOW_COMMANDS)),) |
| 674 | define pretty |
| 675 | @echo $1 |
| 676 | endef |
| 677 | hide := @ |
| 678 | else |
| 679 | define pretty |
| 680 | endef |
| 681 | hide := |
| 682 | endif |
| 683 | |
| 684 | ########################################################### |
| 685 | ## Dump the variables that are associated with targets |
| 686 | ########################################################### |
| 687 | |
| 688 | define dump-module-variables |
| 689 | @echo all_dependencies=$^ |
| 690 | @echo PRIVATE_YACCFLAGS=$(PRIVATE_YACCFLAGS); |
| 691 | @echo PRIVATE_CFLAGS=$(PRIVATE_CFLAGS); |
| 692 | @echo PRIVATE_CPPFLAGS=$(PRIVATE_CPPFLAGS); |
| 693 | @echo PRIVATE_DEBUG_CFLAGS=$(PRIVATE_DEBUG_CFLAGS); |
| 694 | @echo PRIVATE_C_INCLUDES=$(PRIVATE_C_INCLUDES); |
| 695 | @echo PRIVATE_LDFLAGS=$(PRIVATE_LDFLAGS); |
| 696 | @echo PRIVATE_LDLIBS=$(PRIVATE_LDLIBS); |
| 697 | @echo PRIVATE_ARFLAGS=$(PRIVATE_ARFLAGS); |
| 698 | @echo PRIVATE_AAPT_FLAGS=$(PRIVATE_AAPT_FLAGS); |
| 699 | @echo PRIVATE_DX_FLAGS=$(PRIVATE_DX_FLAGS); |
Brian Carlstrom | f184a0f | 2010-02-01 11:13:32 -0800 | [diff] [blame] | 700 | @echo PRIVATE_JAVACFLAGS=$(PRIVATE_JAVACFLAGS); |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 701 | @echo PRIVATE_JAVA_LIBRARIES=$(PRIVATE_JAVA_LIBRARIES); |
| 702 | @echo PRIVATE_ALL_SHARED_LIBRARIES=$(PRIVATE_ALL_SHARED_LIBRARIES); |
| 703 | @echo PRIVATE_ALL_STATIC_LIBRARIES=$(PRIVATE_ALL_STATIC_LIBRARIES); |
| 704 | @echo PRIVATE_ALL_WHOLE_STATIC_LIBRARIES=$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES); |
| 705 | @echo PRIVATE_ALL_OBJECTS=$(PRIVATE_ALL_OBJECTS); |
| 706 | endef |
| 707 | |
| 708 | ########################################################### |
| 709 | ## Commands for using sed to replace given variable values |
| 710 | ########################################################### |
| 711 | |
| 712 | define transform-variables |
| 713 | @mkdir -p $(dir $@) |
| 714 | @echo "Sed: $(if $(PRIVATE_MODULE),$(PRIVATE_MODULE),$@) <= $<" |
| 715 | $(hide) sed $(foreach var,$(REPLACE_VARS),-e "s/{{$(var)}}/$(subst /,\/,$(PWD)/$($(var)))/g") $< >$@ |
| 716 | $(hide) if [ "$(suffix $@)" = ".sh" ]; then chmod a+rx $@; fi |
| 717 | endef |
| 718 | |
| 719 | |
| 720 | ########################################################### |
| 721 | ## Commands for munging the dependency files GCC generates |
| 722 | ########################################################### |
| 723 | |
| 724 | define transform-d-to-p |
| 725 | @cp $(@:%.o=%.d) $(@:%.o=%.P); \ |
| 726 | sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 727 | -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ |
| 728 | rm -f $(@:%.o=%.d) |
| 729 | endef |
| 730 | |
| 731 | ########################################################### |
| 732 | ## Commands for running lex |
| 733 | ########################################################### |
| 734 | |
| 735 | define transform-l-to-cpp |
| 736 | @mkdir -p $(dir $@) |
| 737 | @echo "Lex: $(PRIVATE_MODULE) <= $<" |
| 738 | $(hide) $(LEX) -o$@ $< |
| 739 | endef |
| 740 | |
| 741 | ########################################################### |
| 742 | ## Commands for running yacc |
| 743 | ## |
| 744 | ## Because the extension of c++ files can change, the |
| 745 | ## extension must be specified in $1. |
| 746 | ## E.g, "$(call transform-y-to-cpp,.cpp)" |
| 747 | ########################################################### |
| 748 | |
| 749 | define transform-y-to-cpp |
| 750 | @mkdir -p $(dir $@) |
| 751 | @echo "Yacc: $(PRIVATE_MODULE) <= $<" |
| 752 | $(YACC) $(PRIVATE_YACCFLAGS) -o $@ $< |
| 753 | touch $(@:$1=$(YACC_HEADER_SUFFIX)) |
| 754 | echo '#ifndef '$(@F:$1=_h) > $(@:$1=.h) |
| 755 | echo '#define '$(@F:$1=_h) >> $(@:$1=.h) |
| 756 | cat $(@:$1=$(YACC_HEADER_SUFFIX)) >> $(@:$1=.h) |
| 757 | echo '#endif' >> $(@:$1=.h) |
| 758 | rm -f $(@:$1=$(YACC_HEADER_SUFFIX)) |
| 759 | endef |
| 760 | |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 761 | ########################################################### |
| 762 | ## Commands to compile RenderScript |
| 763 | ########################################################### |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 764 | |
| 765 | define transform-renderscripts-to-java-and-bc |
| 766 | @echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)" |
| 767 | $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR) |
| 768 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw |
| 769 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src |
Shih-wei Liao | d01fadb | 2010-10-08 16:57:46 -0700 | [diff] [blame] | 770 | $(hide) $(LLVM_RS_CC) \ |
Ying Wang | ebfddaa | 2010-07-30 18:37:29 -0700 | [diff] [blame] | 771 | -o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \ |
| 772 | -p $(PRIVATE_RS_OUTPUT_DIR)/src \ |
Ying Wang | 24e1c01 | 2010-10-07 18:57:57 -0700 | [diff] [blame] | 773 | -d $(PRIVATE_RS_OUTPUT_DIR) \ |
| 774 | -a $@ -MD \ |
Ying Wang | 5128027 | 2010-09-01 13:28:52 -0700 | [diff] [blame] | 775 | $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \ |
Ying Wang | ebfddaa | 2010-07-30 18:37:29 -0700 | [diff] [blame] | 776 | $(PRIVATE_RS_SOURCE_FILES) |
Shih-wei Liao | c656030 | 2010-10-23 03:07:13 -0700 | [diff] [blame^] | 777 | #$(hide) $(LLVM_RS_LINK) \ |
| 778 | # $(PRIVATE_RS_OUTPUT_DIR)/res/raw/*.bc |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 779 | $(hide) mkdir -p $(dir $@) |
| 780 | $(hide) touch $@ |
| 781 | endef |
| 782 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 783 | |
| 784 | ########################################################### |
| 785 | ## Commands for running aidl |
| 786 | ########################################################### |
| 787 | |
| 788 | define transform-aidl-to-java |
| 789 | @mkdir -p $(dir $@) |
| 790 | @echo "Aidl: $(PRIVATE_MODULE) <= $<" |
| 791 | $(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@ |
| 792 | endef |
| 793 | #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@ |
| 794 | |
| 795 | |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 796 | ########################################################### |
| 797 | ## Commands for running java-event-log-tags.py |
| 798 | ########################################################### |
| 799 | |
| 800 | define transform-logtags-to-java |
| 801 | @mkdir -p $(dir $@) |
| 802 | @echo "logtags: $@ <= $<" |
Doug Zongker | abfbbe2 | 2010-02-16 14:32:08 -0800 | [diff] [blame] | 803 | $(hide) $(JAVATAGS) -o $@ $^ |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 804 | endef |
| 805 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 806 | |
| 807 | ########################################################### |
| 808 | ## Commands for running gcc to compile a C++ file |
| 809 | ########################################################### |
| 810 | |
| 811 | define transform-cpp-to-o |
| 812 | @mkdir -p $(dir $@) |
| 813 | @echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<" |
| 814 | $(hide) $(PRIVATE_CXX) \ |
| 815 | $(foreach incdir, \ |
Patrick Scott | 9825256 | 2010-02-08 17:28:15 -0500 | [diff] [blame] | 816 | $(PRIVATE_C_INCLUDES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 817 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 818 | $(PRIVATE_TARGET_PROJECT_INCLUDES) \ |
| 819 | $(PRIVATE_TARGET_C_INCLUDES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 820 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 821 | , \ |
| 822 | -I $(incdir) \ |
| 823 | ) \ |
| 824 | -c \ |
| 825 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 826 | $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ |
| 827 | $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 828 | $(PRIVATE_ARM_CFLAGS) \ |
| 829 | ) \ |
| 830 | -fno-rtti \ |
| 831 | $(PRIVATE_CFLAGS) \ |
| 832 | $(PRIVATE_CPPFLAGS) \ |
| 833 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 834 | -MD -o $@ $< |
| 835 | $(hide) $(transform-d-to-p) |
| 836 | endef |
| 837 | |
| 838 | |
| 839 | ########################################################### |
| 840 | ## Commands for running gcc to compile a C file |
| 841 | ########################################################### |
| 842 | |
| 843 | # $(1): extra flags |
| 844 | define transform-c-or-s-to-o-no-deps |
| 845 | @mkdir -p $(dir $@) |
| 846 | $(hide) $(PRIVATE_CC) \ |
| 847 | $(foreach incdir, \ |
Patrick Scott | 9825256 | 2010-02-08 17:28:15 -0500 | [diff] [blame] | 848 | $(PRIVATE_C_INCLUDES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 849 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 850 | $(PRIVATE_TARGET_PROJECT_INCLUDES) \ |
| 851 | $(PRIVATE_TARGET_C_INCLUDES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 852 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 853 | , \ |
| 854 | -I $(incdir) \ |
| 855 | ) \ |
| 856 | -c \ |
| 857 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 858 | $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 859 | $(PRIVATE_ARM_CFLAGS) \ |
| 860 | ) \ |
| 861 | $(PRIVATE_CFLAGS) \ |
| 862 | $(1) \ |
| 863 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 864 | -MD -o $@ $< |
| 865 | endef |
| 866 | |
| 867 | define transform-c-to-o-no-deps |
| 868 | @echo "target $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<" |
| 869 | $(call transform-c-or-s-to-o-no-deps, ) |
| 870 | endef |
| 871 | |
| 872 | define transform-s-to-o-no-deps |
| 873 | @echo "target asm: $(PRIVATE_MODULE) <= $<" |
| 874 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 875 | endef |
| 876 | |
| 877 | define transform-c-to-o |
| 878 | $(transform-c-to-o-no-deps) |
| 879 | $(hide) $(transform-d-to-p) |
| 880 | endef |
| 881 | |
| 882 | define transform-s-to-o |
| 883 | $(transform-s-to-o-no-deps) |
| 884 | $(hide) $(transform-d-to-p) |
| 885 | endef |
| 886 | |
| 887 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 888 | ## Commands for running gcc to compile an Objective-C file |
| 889 | ## This should never happen for target builds but this |
| 890 | ## will error at build time. |
| 891 | ########################################################### |
| 892 | |
| 893 | define transform-m-to-o-no-deps |
| 894 | @echo "target ObjC: $(PRIVATE_MODULE) <= $<" |
| 895 | $(call transform-c-or-s-to-o-no-deps) |
| 896 | endef |
| 897 | |
| 898 | define transform-m-to-o |
| 899 | $(transform-m-to-o-no-deps) |
| 900 | $(hide) $(transform-d-to-p) |
| 901 | endef |
| 902 | |
| 903 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 904 | ## Commands for running gcc to compile a host C++ file |
| 905 | ########################################################### |
| 906 | |
| 907 | define transform-host-cpp-to-o |
| 908 | @mkdir -p $(dir $@) |
| 909 | @echo "host C++: $(PRIVATE_MODULE) <= $<" |
| 910 | $(hide) $(PRIVATE_CXX) \ |
| 911 | $(foreach incdir, \ |
Patrick Scott | 9825256 | 2010-02-08 17:28:15 -0500 | [diff] [blame] | 912 | $(PRIVATE_C_INCLUDES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 913 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 914 | $(HOST_PROJECT_INCLUDES) \ |
| 915 | $(HOST_C_INCLUDES) \ |
| 916 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 917 | , \ |
| 918 | -I $(incdir) \ |
| 919 | ) \ |
| 920 | -c \ |
| 921 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 922 | $(HOST_GLOBAL_CFLAGS) \ |
| 923 | $(HOST_GLOBAL_CPPFLAGS) \ |
| 924 | ) \ |
| 925 | $(PRIVATE_CFLAGS) \ |
| 926 | $(PRIVATE_CPPFLAGS) \ |
| 927 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 928 | -MD -o $@ $< |
| 929 | $(transform-d-to-p) |
| 930 | endef |
| 931 | |
| 932 | |
| 933 | ########################################################### |
| 934 | ## Commands for running gcc to compile a host C file |
| 935 | ########################################################### |
| 936 | |
| 937 | # $(1): extra flags |
| 938 | define transform-host-c-or-s-to-o-no-deps |
| 939 | @mkdir -p $(dir $@) |
| 940 | $(hide) $(PRIVATE_CC) \ |
| 941 | $(foreach incdir, \ |
Patrick Scott | 9825256 | 2010-02-08 17:28:15 -0500 | [diff] [blame] | 942 | $(PRIVATE_C_INCLUDES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 943 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 944 | $(HOST_PROJECT_INCLUDES) \ |
| 945 | $(HOST_C_INCLUDES) \ |
| 946 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 947 | , \ |
| 948 | -I $(incdir) \ |
| 949 | ) \ |
| 950 | -c \ |
| 951 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 952 | $(HOST_GLOBAL_CFLAGS) \ |
| 953 | ) \ |
| 954 | $(PRIVATE_CFLAGS) \ |
| 955 | $(1) \ |
| 956 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 957 | -MD -o $@ $< |
| 958 | endef |
| 959 | |
| 960 | define transform-host-c-to-o-no-deps |
| 961 | @echo "host C: $(PRIVATE_MODULE) <= $<" |
| 962 | $(call transform-host-c-or-s-to-o-no-deps, ) |
| 963 | endef |
| 964 | |
| 965 | define transform-host-s-to-o-no-deps |
| 966 | @echo "host asm: $(PRIVATE_MODULE) <= $<" |
| 967 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 968 | endef |
| 969 | |
| 970 | define transform-host-c-to-o |
| 971 | $(transform-host-c-to-o-no-deps) |
| 972 | $(transform-d-to-p) |
| 973 | endef |
| 974 | |
| 975 | define transform-host-s-to-o |
| 976 | $(transform-host-s-to-o-no-deps) |
| 977 | $(transform-d-to-p) |
| 978 | endef |
| 979 | |
| 980 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 981 | ## Commands for running gcc to compile a host Objective-C file |
| 982 | ########################################################### |
| 983 | |
| 984 | define transform-host-m-to-o-no-deps |
| 985 | @echo "host ObjC: $(PRIVATE_MODULE) <= $<" |
| 986 | $(call transform-host-c-or-s-to-o-no-deps) |
| 987 | endef |
| 988 | |
| 989 | define tranform-host-m-to-o |
| 990 | $(transform-host-m-to-o-no-deps) |
| 991 | $(transform-d-to-p) |
| 992 | endef |
| 993 | |
| 994 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 995 | ## Commands for running ar |
| 996 | ########################################################### |
| 997 | |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 998 | define _concat-if-arg2-not-empty |
| 999 | $(if $(2),$(hide) $(1) $(2)) |
| 1000 | endef |
| 1001 | |
| 1002 | # Split long argument list into smaller groups and call the command repeatedly |
| 1003 | # |
| 1004 | # $(1): the command without arguments |
| 1005 | # $(2): the arguments |
| 1006 | define split-long-arguments |
| 1007 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1,500,$(2))) |
| 1008 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2))) |
| 1009 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2))) |
| 1010 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2))) |
| 1011 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2))) |
| 1012 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2))) |
| 1013 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2))) |
| 1014 | endef |
| 1015 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1016 | define extract-and-include-target-whole-static-libs |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1017 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
Colin Cross | 9ca2164 | 2010-05-04 15:42:22 -0700 | [diff] [blame] | 1018 | $(hide) echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \ |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1019 | ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\ |
| 1020 | rm -rf $$ldir; \ |
| 1021 | mkdir -p $$ldir; \ |
| 1022 | filelist=; \ |
| 1023 | for f in `$(TARGET_AR) t $(lib)`; do \ |
| 1024 | $(TARGET_AR) p $(lib) $$f > $$ldir/$$f; \ |
| 1025 | filelist="$$filelist $$ldir/$$f"; \ |
| 1026 | done ; \ |
| 1027 | $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\ |
| 1028 | ) |
| 1029 | endef |
| 1030 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1031 | # Explicitly delete the archive first so that ar doesn't |
| 1032 | # try to add to an existing archive. |
| 1033 | define transform-o-to-static-lib |
| 1034 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1035 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1036 | $(extract-and-include-target-whole-static-libs) |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1037 | @echo "target StaticLib: $(PRIVATE_MODULE) ($@)" |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1038 | $(call split-long-arguments,$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1039 | endef |
| 1040 | |
| 1041 | ########################################################### |
| 1042 | ## Commands for running host ar |
| 1043 | ########################################################### |
| 1044 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1045 | define extract-and-include-host-whole-static-libs |
| 1046 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1047 | $(hide) echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1048 | ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\ |
| 1049 | rm -rf $$ldir; \ |
| 1050 | mkdir -p $$ldir; \ |
| 1051 | filelist=; \ |
Dan Bornstein | 6581fed | 2009-10-22 13:14:41 -0700 | [diff] [blame] | 1052 | for f in `$(HOST_AR) t $(lib) | grep '\.o$$'`; do \ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1053 | $(HOST_AR) p $(lib) $$f > $$ldir/$$f; \ |
| 1054 | filelist="$$filelist $$ldir/$$f"; \ |
| 1055 | done ; \ |
| 1056 | $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\ |
| 1057 | ) |
| 1058 | endef |
| 1059 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1060 | # Explicitly delete the archive first so that ar doesn't |
| 1061 | # try to add to an existing archive. |
| 1062 | define transform-host-o-to-static-lib |
| 1063 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1064 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1065 | $(extract-and-include-host-whole-static-libs) |
Dan Bornstein | 6bffc91 | 2009-10-15 13:01:36 -0700 | [diff] [blame] | 1066 | @echo "host StaticLib: $(PRIVATE_MODULE) ($@)" |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1067 | $(call split-long-arguments,$(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1068 | endef |
| 1069 | |
| 1070 | |
| 1071 | ########################################################### |
| 1072 | ## Commands for running gcc to link a shared library or package |
| 1073 | ########################################################### |
| 1074 | |
| 1075 | # ld just seems to be so finicky with command order that we allow |
| 1076 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1077 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1078 | define transform-host-o-to-shared-lib-inner |
| 1079 | $(HOST_CXX) \ |
| 1080 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1081 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1082 | -shared -Wl,-soname,$(notdir $@) \ |
| 1083 | $(PRIVATE_LDFLAGS) \ |
| 1084 | $(HOST_GLOBAL_LD_DIRS) \ |
| 1085 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1086 | $(HOST_GLOBAL_LDFLAGS) \ |
| 1087 | ) \ |
| 1088 | $(PRIVATE_ALL_OBJECTS) \ |
| 1089 | -Wl,--whole-archive \ |
| 1090 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1091 | -Wl,--no-whole-archive \ |
| 1092 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1093 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1094 | -o $@ \ |
| 1095 | $(PRIVATE_LDLIBS) |
| 1096 | endef |
| 1097 | endif |
| 1098 | |
| 1099 | define transform-host-o-to-shared-lib |
| 1100 | @mkdir -p $(dir $@) |
| 1101 | @echo "host SharedLib: $(PRIVATE_MODULE) ($@)" |
| 1102 | $(hide) $(transform-host-o-to-shared-lib-inner) |
| 1103 | endef |
| 1104 | |
| 1105 | define transform-host-o-to-package |
| 1106 | @mkdir -p $(dir $@) |
| 1107 | @echo "host Package: $(PRIVATE_MODULE) ($@)" |
| 1108 | $(hide) $(transform-host-o-to-shared-lib-inner) |
| 1109 | endef |
| 1110 | |
| 1111 | |
| 1112 | ########################################################### |
| 1113 | ## Commands for running gcc to link a shared library or package |
| 1114 | ########################################################### |
| 1115 | |
| 1116 | #echo >$@.vers "{"; \ |
| 1117 | #echo >>$@.vers " global:"; \ |
| 1118 | #$(BUILD_SYSTEM)/filter_symbols.sh $(TARGET_NM) " " ";" $(filter %.o,$^) | sort -u >>$@.vers; \ |
| 1119 | #echo >>$@.vers " local:"; \ |
| 1120 | #echo >>$@.vers " *;"; \ |
| 1121 | #echo >>$@.vers "};"; \ |
| 1122 | |
| 1123 | # -Wl,--version-script=$@.vers \ |
| 1124 | |
| 1125 | # ld just seems to be so finicky with command order that we allow |
| 1126 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1127 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1128 | define transform-o-to-shared-lib-inner |
| 1129 | $(TARGET_CXX) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1130 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1131 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1132 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1133 | -shared -Wl,-soname,$(notdir $@) \ |
| 1134 | $(PRIVATE_LDFLAGS) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1135 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1136 | $(PRIVATE_ALL_OBJECTS) \ |
| 1137 | -Wl,--whole-archive \ |
| 1138 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1139 | -Wl,--no-whole-archive \ |
| 1140 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1141 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1142 | -o $@ \ |
| 1143 | $(PRIVATE_LDLIBS) |
| 1144 | endef |
| 1145 | endif |
| 1146 | |
| 1147 | define transform-o-to-shared-lib |
| 1148 | @mkdir -p $(dir $@) |
| 1149 | @echo "target SharedLib: $(PRIVATE_MODULE) ($@)" |
| 1150 | $(hide) $(transform-o-to-shared-lib-inner) |
| 1151 | endef |
| 1152 | |
| 1153 | define transform-o-to-package |
| 1154 | @mkdir -p $(dir $@) |
| 1155 | @echo "target Package: $(PRIVATE_MODULE) ($@)" |
| 1156 | $(hide) $(transform-o-to-shared-lib-inner) |
| 1157 | endef |
| 1158 | |
| 1159 | |
| 1160 | ########################################################### |
| 1161 | ## Commands for filtering a target executable or library |
| 1162 | ########################################################### |
| 1163 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1164 | define transform-to-stripped |
| 1165 | @mkdir -p $(dir $@) |
| 1166 | @echo "target Strip: $(PRIVATE_MODULE) ($@)" |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 1167 | $(hide) $(TARGET_STRIP_COMMAND) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1168 | endef |
| 1169 | |
| 1170 | define transform-to-prelinked |
| 1171 | @mkdir -p $(dir $@) |
| 1172 | @echo "target Prelink: $(PRIVATE_MODULE) ($@)" |
| 1173 | $(hide) $(APRIORI) \ |
| 1174 | --prelinkmap $(TARGET_PRELINKER_MAP) \ |
| 1175 | --locals-only \ |
| 1176 | --quiet \ |
| 1177 | $< \ |
| 1178 | --output $@ |
| 1179 | endef |
| 1180 | |
| 1181 | |
| 1182 | ########################################################### |
| 1183 | ## Commands for running gcc to link an executable |
| 1184 | ########################################################### |
| 1185 | |
| 1186 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1187 | define transform-o-to-executable-inner |
| 1188 | $(TARGET_CXX) \ |
| 1189 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 1190 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1191 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 1192 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1193 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1194 | $(PRIVATE_LDFLAGS) \ |
| 1195 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 1196 | $(PRIVATE_ALL_OBJECTS) \ |
| 1197 | -Wl,--whole-archive \ |
| 1198 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1199 | -Wl,--no-whole-archive \ |
| 1200 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1201 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1202 | -o $@ \ |
| 1203 | $(PRIVATE_LDLIBS) |
| 1204 | endef |
| 1205 | endif |
| 1206 | |
| 1207 | define transform-o-to-executable |
| 1208 | @mkdir -p $(dir $@) |
| 1209 | @echo "target Executable: $(PRIVATE_MODULE) ($@)" |
| 1210 | $(hide) $(transform-o-to-executable-inner) |
| 1211 | endef |
| 1212 | |
| 1213 | |
| 1214 | ########################################################### |
| 1215 | ## Commands for running gcc to link a statically linked |
| 1216 | ## executable. In practice, we only use this on arm, so |
| 1217 | ## the other platforms don't have the |
| 1218 | ## transform-o-to-static-executable defined |
| 1219 | ########################################################### |
| 1220 | |
| 1221 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1222 | define transform-o-to-static-executable-inner |
| 1223 | endef |
| 1224 | endif |
| 1225 | |
| 1226 | define transform-o-to-static-executable |
| 1227 | @mkdir -p $(dir $@) |
| 1228 | @echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)" |
| 1229 | $(hide) $(transform-o-to-static-executable-inner) |
| 1230 | endef |
| 1231 | |
| 1232 | |
| 1233 | ########################################################### |
| 1234 | ## Commands for running gcc to link a host executable |
| 1235 | ########################################################### |
| 1236 | |
| 1237 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1238 | define transform-host-o-to-executable-inner |
| 1239 | $(HOST_CXX) \ |
| 1240 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1241 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1242 | $(HOST_GLOBAL_LD_DIRS) \ |
| 1243 | $(PRIVATE_LDFLAGS) \ |
| 1244 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1245 | $(HOST_GLOBAL_LDFLAGS) \ |
| 1246 | ) \ |
| 1247 | $(PRIVATE_ALL_OBJECTS) \ |
| 1248 | -Wl,--whole-archive \ |
| 1249 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1250 | -Wl,--no-whole-archive \ |
| 1251 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1252 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1253 | -o $@ \ |
| 1254 | $(PRIVATE_LDLIBS) |
| 1255 | endef |
| 1256 | endif |
| 1257 | |
| 1258 | define transform-host-o-to-executable |
| 1259 | @mkdir -p $(dir $@) |
| 1260 | @echo "host Executable: $(PRIVATE_MODULE) ($@)" |
| 1261 | $(hide) $(transform-host-o-to-executable-inner) |
| 1262 | endef |
| 1263 | |
| 1264 | |
| 1265 | ########################################################### |
| 1266 | ## Commands for running javac to make .class files |
| 1267 | ########################################################### |
| 1268 | |
| 1269 | #@echo "Source intermediates dir: $(PRIVATE_SOURCE_INTERMEDIATES_DIR)" |
| 1270 | #@echo "Source intermediates: $$(find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java')" |
| 1271 | |
| 1272 | # TODO: Right now we generate the asset resources twice, first as part |
| 1273 | # of generating the Java classes, then at the end when packaging the final |
| 1274 | # assets. This should be changed to do one of two things: (1) Don't generate |
| 1275 | # any resource files the first time, only create classes during that stage; |
| 1276 | # or (2) Don't use the -c flag with the second stage, instead taking the |
| 1277 | # resource files from the first stage as additional input. My original intent |
| 1278 | # was to use approach (2), but this requires a little more work in the tool. |
| 1279 | # Maybe we should just use approach (1). |
| 1280 | |
| 1281 | # This rule creates the R.java and Manifest.java files, both of which |
| 1282 | # are PRODUCT-neutral. Don't pass PRODUCT_AAPT_CONFIG to this invocation. |
| 1283 | define create-resource-java-files |
| 1284 | @mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR) |
| 1285 | @mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 1286 | $(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1287 | $(eval # PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \ |
| 1288 | $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ |
| 1289 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1290 | $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \ |
| 1291 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1292 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1293 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 1294 | $(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1295 | $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
| 1296 | $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
Ying Wang | 1ae607a | 2010-06-23 13:34:22 -0700 | [diff] [blame] | 1297 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \ |
Ying Wang | 8f5069b | 2010-06-29 11:08:13 -0700 | [diff] [blame] | 1298 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \ |
Ying Wang | 8c25482 | 2010-03-16 16:13:56 -0700 | [diff] [blame] | 1299 | $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1300 | $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1301 | endef |
| 1302 | |
| 1303 | ifeq ($(HOST_OS),windows) |
| 1304 | xlint_unchecked := |
| 1305 | else |
Jeffrey Chyan | 7adbf97 | 2010-07-07 13:42:19 -0500 | [diff] [blame] | 1306 | xlint_unchecked := -Xlint:unchecked |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1307 | endif |
| 1308 | |
| 1309 | # emit-line, <word list>, <output file> |
| 1310 | define emit-line |
| 1311 | $(if $(1),echo -n '$(strip $(1)) ' >> $(2)) |
| 1312 | endef |
| 1313 | |
| 1314 | # dump-words-to-file, <word list>, <output file> |
| 1315 | define dump-words-to-file |
| 1316 | @rm -f $(2) |
| 1317 | @$(call emit-line,$(wordlist 1,200,$(1)),$(2)) |
| 1318 | @$(call emit-line,$(wordlist 201,400,$(1)),$(2)) |
| 1319 | @$(call emit-line,$(wordlist 401,600,$(1)),$(2)) |
| 1320 | @$(call emit-line,$(wordlist 601,800,$(1)),$(2)) |
| 1321 | @$(call emit-line,$(wordlist 801,1000,$(1)),$(2)) |
| 1322 | @$(call emit-line,$(wordlist 1001,1200,$(1)),$(2)) |
| 1323 | @$(call emit-line,$(wordlist 1201,1400,$(1)),$(2)) |
| 1324 | @$(call emit-line,$(wordlist 1401,1600,$(1)),$(2)) |
| 1325 | @$(call emit-line,$(wordlist 1601,1800,$(1)),$(2)) |
| 1326 | @$(call emit-line,$(wordlist 1801,2000,$(1)),$(2)) |
| 1327 | @$(call emit-line,$(wordlist 2001,2200,$(1)),$(2)) |
| 1328 | @$(call emit-line,$(wordlist 2201,2400,$(1)),$(2)) |
| 1329 | @$(call emit-line,$(wordlist 2401,2600,$(1)),$(2)) |
| 1330 | @$(call emit-line,$(wordlist 2601,2800,$(1)),$(2)) |
| 1331 | @$(call emit-line,$(wordlist 2801,3000,$(1)),$(2)) |
| 1332 | @$(call emit-line,$(wordlist 3001,3200,$(1)),$(2)) |
| 1333 | @$(call emit-line,$(wordlist 3201,3400,$(1)),$(2)) |
| 1334 | @$(call emit-line,$(wordlist 3401,3600,$(1)),$(2)) |
| 1335 | @$(call emit-line,$(wordlist 3601,3800,$(1)),$(2)) |
| 1336 | @$(call emit-line,$(wordlist 3801,4000,$(1)),$(2)) |
Jesse Wilson | 72c941a | 2010-05-04 16:33:49 -0700 | [diff] [blame] | 1337 | @$(call emit-line,$(wordlist 4001,4200,$(1)),$(2)) |
| 1338 | @$(call emit-line,$(wordlist 4201,4400,$(1)),$(2)) |
| 1339 | @$(call emit-line,$(wordlist 4401,4600,$(1)),$(2)) |
| 1340 | @$(call emit-line,$(wordlist 4601,4800,$(1)),$(2)) |
| 1341 | @$(call emit-line,$(wordlist 4801,5000,$(1)),$(2)) |
| 1342 | @$(if $(wordlist 5001,5002,$(1)),$(error Too many words ($(words $(1))))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1343 | endef |
| 1344 | |
| 1345 | # For a list of jar files, unzip them to a specified directory, |
| 1346 | # but make sure that no META-INF files come along for the ride. |
| 1347 | # |
| 1348 | # $(1): files to unzip |
| 1349 | # $(2): destination directory |
| 1350 | define unzip-jar-files |
| 1351 | $(hide) for f in $(1); \ |
| 1352 | do \ |
| 1353 | if [ ! -f $$f ]; then \ |
| 1354 | echo Missing file $$f; \ |
| 1355 | exit 1; \ |
| 1356 | fi; \ |
Sriram Raman | f1a55f8 | 2009-06-09 15:08:29 -0700 | [diff] [blame] | 1357 | unzip -qo $$f -d $(2); \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1358 | (cd $(2) && rm -rf META-INF); \ |
| 1359 | done |
| 1360 | endef |
| 1361 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1362 | # below we write the list of java files to java-source-list to avoid argument |
| 1363 | # list length problems with Cygwin we filter out duplicate java file names |
| 1364 | # because eclipse's compiler doesn't like them. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1365 | define transform-java-to-classes.jar |
| 1366 | @echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1367 | $(hide) rm -f $@ |
| 1368 | $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1369 | $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1370 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \ |
| 1371 | $(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1372 | $(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1373 | $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1374 | find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1375 | fi |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1376 | $(hide) tr ' ' '\n' < $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list \ |
| 1377 | | sort -u > $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1378 | $(hide) $(TARGET_JAVAC) -encoding ascii $(PRIVATE_BOOTCLASSPATH) \ |
| 1379 | $(addprefix -classpath ,$(strip \ |
| 1380 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \ |
Jeffrey Chyan | 7adbf97 | 2010-07-07 13:42:19 -0500 | [diff] [blame] | 1381 | $(PRIVATE_JAVACFLAGS) $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \ |
| 1382 | $(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1383 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1384 | \@$(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1385 | || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1386 | $(hide) rm -f $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list |
| 1387 | $(hide) rm -f $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1388 | $(hide) mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1389 | $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \ |
| 1390 | $@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1391 | $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1392 | endef |
| 1393 | |
| 1394 | define transform-classes.jar-to-emma |
| 1395 | $(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \ |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 1396 | $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \ |
Guang Zhu | 9cd3d8c | 2010-06-15 13:31:25 -0700 | [diff] [blame] | 1397 | $(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1398 | endef |
| 1399 | |
| 1400 | #TODO: use a smaller -Xmx value for most libraries; |
| 1401 | # only core.jar and framework.jar need a heap this big. |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 1402 | # Avoid the memory arguments on Windows, dx fails to load for some reason with them. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1403 | define transform-classes.jar-to-dex |
| 1404 | @echo "target Dex: $(PRIVATE_MODULE)" |
| 1405 | @mkdir -p $(dir $@) |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 1406 | $(hide) $(DX) \ |
| 1407 | $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1536M) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1408 | --dex --output=$@ \ |
| 1409 | $(if $(NO_OPTIMIZE_DX), \ |
| 1410 | --no-optimize) \ |
| 1411 | $(if $(GENERATE_DEX_DEBUG), \ |
| 1412 | --debug --verbose \ |
| 1413 | --dump-to=$(@:.dex=.lst) \ |
| 1414 | --dump-width=1000) \ |
| 1415 | $(PRIVATE_DX_FLAGS) \ |
| 1416 | $< |
| 1417 | endef |
| 1418 | |
| 1419 | # Create a mostly-empty .jar file that we'll add to later. |
| 1420 | # The MacOS jar tool doesn't like creating empty jar files, |
| 1421 | # so we need to give it something. |
| 1422 | define create-empty-package |
| 1423 | @mkdir -p $(dir $@) |
| 1424 | $(hide) touch $(dir $@)/dummy |
| 1425 | $(hide) (cd $(dir $@) && jar cf $(notdir $@) dummy) |
| 1426 | $(hide) zip -qd $@ dummy |
| 1427 | $(hide) rm $(dir $@)/dummy |
| 1428 | endef |
| 1429 | |
| 1430 | #TODO: we kinda want to build different asset packages for |
| 1431 | # different configurations, then combine them later (or something). |
| 1432 | # Per-locale, etc. |
| 1433 | # A list of dynamic and static parameters; build layers for |
| 1434 | # dynamic params that lay over the static ones. |
| 1435 | #TODO: update the manifest to point to the package file |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1436 | #Note that the version numbers are given to aapt as simple default |
| 1437 | #values; applications can override these by explicitly stating |
| 1438 | #them in their manifest. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1439 | define add-assets-to-package |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 1440 | $(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1441 | $(addprefix -c , $(PRODUCT_AAPT_CONFIG)) \ |
| 1442 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1443 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1444 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
| 1445 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1446 | $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
| 1447 | $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
Joe Onorato | 700b88e | 2010-10-05 17:33:58 -0400 | [diff] [blame] | 1448 | $(addprefix --product , $(TARGET_AAPT_CHARACTERISTICS)) \ |
Ying Wang | 1ae607a | 2010-06-23 13:34:22 -0700 | [diff] [blame] | 1449 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \ |
Ying Wang | 8f5069b | 2010-06-29 11:08:13 -0700 | [diff] [blame] | 1450 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \ |
Jeff Hamilton | bb67d21 | 2010-02-05 22:36:42 -0600 | [diff] [blame] | 1451 | $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1452 | $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1453 | -F $@ |
| 1454 | endef |
| 1455 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1456 | define add-jni-shared-libs-to-package |
| 1457 | $(hide) rm -rf $(dir $@)lib |
Jack Palevich | a0ab29b | 2010-06-18 15:38:07 +0800 | [diff] [blame] | 1458 | $(hide) mkdir -p $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI) |
| 1459 | $(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1460 | $(hide) (cd $(dir $@) && zip -r $(notdir $@) lib) |
| 1461 | $(hide) rm -rf $(dir $@)lib |
| 1462 | endef |
| 1463 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1464 | #TODO: update the manifest to point to the dex file |
| 1465 | define add-dex-to-package |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 1466 | $(if $(filter classes.dex,$(notdir $(PRIVATE_DEX_FILE))),\ |
| 1467 | $(hide) $(AAPT) add -k $@ $(PRIVATE_DEX_FILE),\ |
| 1468 | $(eval _adtp_classes.dex := $(dir $(PRIVATE_DEX_FILE))/classes.dex)\ |
| 1469 | $(hide) cp $(PRIVATE_DEX_FILE) $(_adtp_classes.dex) && \ |
| 1470 | $(AAPT) add -k $@ $(_adtp_classes.dex) && \ |
| 1471 | rm -f $(_adtp_classes.dex)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1472 | endef |
| 1473 | |
| 1474 | define add-java-resources-to-package |
| 1475 | $(hide) jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS) |
| 1476 | endef |
| 1477 | |
| 1478 | # Sign a package using the specified key/cert. |
| 1479 | # |
| 1480 | define sign-package |
| 1481 | $(hide) mv $@ $@.unsigned |
| 1482 | $(hide) java -jar $(SIGNAPK_JAR) \ |
| 1483 | $(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) $@.unsigned $@.signed |
| 1484 | $(hide) mv $@.signed $@ |
| 1485 | endef |
| 1486 | |
| 1487 | # Align STORED entries of a package on 4-byte boundaries |
| 1488 | # to make them easier to mmap. |
| 1489 | # |
| 1490 | define align-package |
| 1491 | $(hide) mv $@ $@.unaligned |
| 1492 | $(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned |
| 1493 | $(hide) mv $@.aligned $@ |
| 1494 | endef |
| 1495 | |
| 1496 | define install-dex-debug |
| 1497 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \ |
| 1498 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 1499 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.dex \ |
| 1500 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).dex; \ |
| 1501 | fi |
| 1502 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.lst" ]; then \ |
| 1503 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 1504 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.lst \ |
| 1505 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).lst; \ |
| 1506 | fi |
| 1507 | endef |
| 1508 | |
| 1509 | # TODO(joeo): If we can ever upgrade to post 3.81 make and get the |
| 1510 | # new prebuilt rules to work, we should change this to copy the |
| 1511 | # resources to the out directory and then copy the resources. |
| 1512 | |
| 1513 | # Note: not using aapt tool for this because we aren't making |
| 1514 | # an android package for the host. |
| 1515 | define transform-host-java-to-package |
| 1516 | @echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
| 1517 | @rm -f $@ |
| 1518 | @rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1519 | @mkdir -p $(dir $@) |
| 1520 | @mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1521 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \ |
| 1522 | $(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
| 1523 | $(call dump-words-to-file,$(sort\ |
| 1524 | $(PRIVATE_JAVA_SOURCES)),\ |
Joe Onorato | 483d924 | 2009-06-18 13:11:58 -0700 | [diff] [blame] | 1525 | $(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1526 | $(hide) $(HOST_JAVAC) -encoding ascii -g \ |
Brian Carlstrom | f184a0f | 2010-02-01 11:13:32 -0800 | [diff] [blame] | 1527 | $(PRIVATE_JAVACFLAGS) $(xlint_unchecked) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1528 | $(addprefix -classpath ,$(strip \ |
| 1529 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \ |
| 1530 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR)\ |
Joe Onorato | 483d924 | 2009-06-18 13:11:58 -0700 | [diff] [blame] | 1531 | \@$(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq || \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1532 | ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) |
Joe Onorato | 483d924 | 2009-06-18 13:11:58 -0700 | [diff] [blame] | 1533 | $(hide) rm -f $(PRIVATE_INTERMEDIATES_DIR)/java-source-list |
| 1534 | $(hide) rm -f $(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1535 | $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \ |
| 1536 | $@ $(PRIVATE_JAR_MANIFEST) $(PRIVATE_EXTRA_JAR_ARGS) \ |
| 1537 | -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . |
| 1538 | endef |
| 1539 | |
| 1540 | ########################################################### |
| 1541 | ## Obfuscate a jar file |
| 1542 | ########################################################### |
| 1543 | |
| 1544 | # PRIVATE_KEEP_FILE is a file containing a list of classes |
| 1545 | # PRIVATE_INTERMEDIATES_DIR is a directory we can use for temporary files |
| 1546 | # The module using this must depend on |
| 1547 | # $(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar |
| 1548 | define obfuscate-jar |
| 1549 | @echo "Obfuscate jar: $(notdir $@) ($@)" |
| 1550 | @mkdir -p $(dir $@) |
| 1551 | @rm -f $@ |
| 1552 | @mkdir -p $(PRIVATE_INTERMEDIATES_DIR) |
| 1553 | $(hide) sed -e 's/^/-keep class /' < $(PRIVATE_KEEP_FILE) > \ |
| 1554 | $(PRIVATE_INTERMEDIATES_DIR)/keep.pro |
| 1555 | $(hide) java -Xmx512M -jar $(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar \ |
| 1556 | -injars $< \ |
| 1557 | -outjars $@ \ |
| 1558 | -target 1.5 \ |
| 1559 | -dontnote -dontwarn \ |
| 1560 | -printmapping $(PRIVATE_INTERMEDIATES_DIR)/out.map \ |
| 1561 | -forceprocessing \ |
| 1562 | -renamesourcefileattribute SourceFile \ |
| 1563 | -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod \ |
| 1564 | -repackageclasses \ |
| 1565 | -keepclassmembers "class * { public protected *; }" \ |
| 1566 | @$(PRIVATE_INTERMEDIATES_DIR)/keep.pro |
| 1567 | endef |
| 1568 | |
| 1569 | ########################################################### |
| 1570 | ## Commands for copying files |
| 1571 | ########################################################### |
| 1572 | |
| 1573 | # Define a rule to copy a header. Used via $(eval) by copy_headers.make. |
| 1574 | # $(1): source header |
| 1575 | # $(2): destination header |
| 1576 | define copy-one-header |
| 1577 | $(2): $(1) |
| 1578 | @echo "Header: $$@" |
| 1579 | $$(copy-file-to-new-target-with-cp) |
| 1580 | endef |
| 1581 | |
| 1582 | # Define a rule to copy a file. For use via $(eval). |
| 1583 | # $(1): source file |
| 1584 | # $(2): destination file |
| 1585 | define copy-one-file |
| 1586 | $(2): $(1) | $(ACP) |
| 1587 | @echo "Copy: $$@" |
| 1588 | $$(copy-file-to-target) |
| 1589 | endef |
| 1590 | |
| 1591 | # The -t option to acp and the -p option to cp is |
| 1592 | # required for OSX. OSX has a ridiculous restriction |
| 1593 | # where it's an error for a .a file's modification time |
| 1594 | # to disagree with an internal timestamp, and this |
| 1595 | # macro is used to install .a files (among other things). |
| 1596 | |
| 1597 | # Copy a single file from one place to another, |
| 1598 | # preserving permissions and overwriting any existing |
| 1599 | # file. |
| 1600 | define copy-file-to-target |
| 1601 | @mkdir -p $(dir $@) |
| 1602 | $(hide) $(ACP) -fpt $< $@ |
| 1603 | endef |
| 1604 | |
| 1605 | # The same as copy-file-to-target, but use the local |
| 1606 | # cp command instead of acp. |
| 1607 | define copy-file-to-target-with-cp |
| 1608 | @mkdir -p $(dir $@) |
| 1609 | $(hide) cp -fp $< $@ |
| 1610 | endef |
| 1611 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 1612 | # The same as copy-file-to-target, but use the zipalign tool to do so. |
| 1613 | define copy-file-to-target-with-zipalign |
| 1614 | @mkdir -p $(dir $@) |
| 1615 | $(hide) $(ZIPALIGN) -f 4 $< $@ |
| 1616 | endef |
| 1617 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 1618 | # The same as copy-file-to-target, but strip out "# comment"-style |
| 1619 | # comments (for config files and such). |
| 1620 | define copy-file-to-target-strip-comments |
| 1621 | @mkdir -p $(dir $@) |
| 1622 | $(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@ |
| 1623 | endef |
| 1624 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1625 | # The same as copy-file-to-target, but don't preserve |
| 1626 | # the old modification time. |
| 1627 | define copy-file-to-new-target |
| 1628 | @mkdir -p $(dir $@) |
| 1629 | $(hide) $(ACP) -fp $< $@ |
| 1630 | endef |
| 1631 | |
| 1632 | # The same as copy-file-to-new-target, but use the local |
| 1633 | # cp command instead of acp. |
| 1634 | define copy-file-to-new-target-with-cp |
| 1635 | @mkdir -p $(dir $@) |
| 1636 | $(hide) cp -f $< $@ |
| 1637 | endef |
| 1638 | |
| 1639 | # Copy a prebuilt file to a target location. |
| 1640 | define transform-prebuilt-to-target |
| 1641 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 1642 | $(copy-file-to-target) |
| 1643 | endef |
| 1644 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 1645 | # Copy a prebuilt file to a target location, using zipalign on it. |
| 1646 | define transform-prebuilt-to-target-with-zipalign |
| 1647 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)" |
| 1648 | $(copy-file-to-target-with-zipalign) |
| 1649 | endef |
| 1650 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 1651 | # Copy a prebuilt file to a target location, stripping "# comment" comments. |
| 1652 | define transform-prebuilt-to-target-strip-comments |
| 1653 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 1654 | $(copy-file-to-target-strip-comments) |
| 1655 | endef |
| 1656 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1657 | ########################################################### |
| 1658 | ## On some platforms (MacOS), after copying a static |
| 1659 | ## library, ranlib must be run to update an internal |
| 1660 | ## timestamp!?!?! |
| 1661 | ########################################################### |
| 1662 | |
| 1663 | ifeq ($(HOST_RUN_RANLIB_AFTER_COPYING),true) |
| 1664 | define transform-host-ranlib-copy-hack |
| 1665 | $(hide) ranlib $@ || true |
| 1666 | endef |
| 1667 | else |
| 1668 | define transform-host-ranlib-copy-hack |
Patrick Scott | 0e27dff | 2010-05-07 08:37:11 -0400 | [diff] [blame] | 1669 | @true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1670 | endef |
| 1671 | endif |
| 1672 | |
| 1673 | ifeq ($(TARGET_RUN_RANLIB_AFTER_COPYING),true) |
| 1674 | define transform-ranlib-copy-hack |
| 1675 | $(hide) ranlib $@ |
| 1676 | endef |
| 1677 | else |
| 1678 | define transform-ranlib-copy-hack |
Patrick Scott | 0e27dff | 2010-05-07 08:37:11 -0400 | [diff] [blame] | 1679 | @true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1680 | endef |
| 1681 | endif |
| 1682 | |
| 1683 | |
| 1684 | ########################################################### |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 1685 | ## Commands to call Proguard |
| 1686 | ########################################################### |
| 1687 | |
| 1688 | # Command to copy the file with acp, if proguard is disabled. |
| 1689 | define proguard-disabled-commands |
| 1690 | @echo Copying: $@ |
| 1691 | $(hide) $(ACP) $< $@ |
| 1692 | endef |
| 1693 | |
| 1694 | # Command to call Proguard |
| 1695 | # $(1): extra flags for instrumentation. |
| 1696 | define proguard-enabled-commands |
| 1697 | @echo Proguard: $@ |
| 1698 | $(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) $(1) |
| 1699 | endef |
| 1700 | |
| 1701 | # Figure out the proguard dictionary file of the module that is instrumentationed for. |
| 1702 | define get-instrumentation-proguard-flags |
| 1703 | $(if $(PRIVATE_INSTRUMENTATION_FOR),$(if $(ALL_MODULES.$(PRIVATE_INSTRUMENTATION_FOR).PROGUARD_ENABLED),-applymapping $(call intermediates-dir-for,APPS,$(PRIVATE_INSTRUMENTATION_FOR),,COMMON)/proguard_dictionary)) |
| 1704 | endef |
| 1705 | |
| 1706 | define transform-jar-to-proguard |
| 1707 | $(eval _instrumentation_proguard_flags:=$(call get-instrumentation-proguard-flags)) |
| 1708 | $(eval _enable_proguard:=$(PRIVATE_PROGUARD_ENABLED)$(_instrumentation_proguard_flags)) |
| 1709 | $(if $(_enable_proguard),$(call proguard-enabled-commands,$(_instrumentation_proguard_flags)),$(call proguard-disabled-commands)) |
| 1710 | $(eval _instrumentation_proguard_flags:=) |
| 1711 | $(eval _enable_proguard:=) |
| 1712 | endef |
| 1713 | |
| 1714 | |
| 1715 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1716 | ## Stuff source generated from one-off tools |
| 1717 | ########################################################### |
| 1718 | |
| 1719 | define transform-generated-source |
| 1720 | @echo "target Generated: $(PRIVATE_MODULE) <= $<" |
| 1721 | @mkdir -p $(dir $@) |
| 1722 | $(hide) $(PRIVATE_CUSTOM_TOOL) |
| 1723 | endef |
| 1724 | |
| 1725 | |
| 1726 | ########################################################### |
| 1727 | ## Assertions about attributes of the target |
| 1728 | ########################################################### |
| 1729 | |
| 1730 | # $(1): The file to check |
| 1731 | ifndef get-file-size |
| 1732 | $(error HOST_OS must define get-file-size) |
| 1733 | endif |
| 1734 | |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1735 | # Convert a partition data size (eg, as reported in /proc/mtd) to the |
| 1736 | # size of the image used to flash that partition (which includes a |
| 1737 | # 64-byte spare area for each 2048-byte page). |
| 1738 | # $(1): the partition data size |
| 1739 | define image-size-from-data-size |
| 1740 | $(shell echo $$(($(1) / 2048 * (2048+64)))) |
| 1741 | endef |
| 1742 | |
| 1743 | # $(1): The file(s) to check (often $@) |
| 1744 | # $(2): The maximum total image size, in decimal bytes |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1745 | # $(3): the type of filesystem "yaffs" or "raw" |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1746 | # |
| 1747 | # If $(2) is empty, evaluates to "true" |
| 1748 | # |
| 1749 | # Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks) |
| 1750 | # is left over after the image has been flashed. Round the 1% up to the |
| 1751 | # next whole flash block size. |
| 1752 | define assert-max-file-size |
| 1753 | $(if $(2), \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 1754 | size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \ |
| 1755 | total=$$(( $$( echo "$$size" ) )); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1756 | printname=$$(echo -n "$(1)" | tr " " +); \ |
| 1757 | echo "$$printname total size is $$total"; \ |
| 1758 | img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1759 | if [ "$(3)" == "yaffs" ]; then \ |
Doug Zongker | 93d9ff4 | 2009-09-14 17:46:41 -0700 | [diff] [blame] | 1760 | reservedblocks=8; \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1761 | else \ |
Doug Zongker | 4ac1ba6 | 2009-08-25 20:38:50 -0700 | [diff] [blame] | 1762 | reservedblocks=0; \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1763 | fi; \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1764 | twoblocks=$$((img_blocksize * 2)); \ |
| 1765 | onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1766 | reserve=$$(((twoblocks > onepct ? twoblocks : onepct) + \ |
| 1767 | reservedblocks * img_blocksize)); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1768 | maxsize=$$(($(2) - reserve)); \ |
| 1769 | if [ "$$total" -gt "$$maxsize" ]; then \ |
| 1770 | echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \ |
| 1771 | false; \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 1772 | elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1773 | echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1774 | fi \ |
| 1775 | , \ |
| 1776 | true \ |
| 1777 | ) |
| 1778 | endef |
| 1779 | |
Doug Zongker | 8510a1e | 2009-08-07 16:38:08 -0700 | [diff] [blame] | 1780 | # Like assert-max-file-size, but the second argument is a partition |
| 1781 | # size, which we'll convert to a max image size before checking it |
| 1782 | # against the files. |
| 1783 | # |
| 1784 | # $(1): The file(s) to check (often $@) |
| 1785 | # $(2): The partition size. |
| 1786 | define assert-max-image-size |
| 1787 | $(if $(2), \ |
| 1788 | $(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2))), \ |
| 1789 | true) |
| 1790 | endef |
| 1791 | |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 1792 | |
| 1793 | ########################################################### |
| 1794 | ## Define device-specific radio files |
| 1795 | ########################################################### |
| 1796 | |
| 1797 | # Copy a radio image file to the output location, and add it to |
| 1798 | # INSTALLED_RADIOIMAGE_TARGET. |
| 1799 | # $(1): filename |
| 1800 | define add-radio-file |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 1801 | $(eval $(call add-radio-file-internal,$(1),$(notdir $(1)))) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 1802 | endef |
| 1803 | define add-radio-file-internal |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 1804 | INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2) |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 1805 | $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 1806 | $$(transform-prebuilt-to-target) |
| 1807 | endef |
| 1808 | |
| 1809 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1810 | ########################################################### |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 1811 | # Override the package defined in $(1), setting the |
| 1812 | # variables listed below differently. |
| 1813 | # |
| 1814 | # $(1): The makefile to override (relative to the source |
| 1815 | # tree root) |
| 1816 | # $(2): Old LOCAL_PACKAGE_NAME value. |
| 1817 | # $(3): New LOCAL_PACKAGE_NAME value. |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1818 | # $(4): New LOCAL_MANIFEST_PACKAGE_NAME value. |
| 1819 | # $(5): New LOCAL_CERTIFICATE value. |
| 1820 | # $(6): New LOCAL_INSTRUMENTATION_FOR value. |
| 1821 | # $(7): New LOCAL_MANIFEST_INSTRUMENTATION_FOR value. |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 1822 | # |
| 1823 | # Note that LOCAL_PACKAGE_OVERRIDES is NOT cleared in |
| 1824 | # clear_vars.mk. |
| 1825 | ########################################################### |
| 1826 | define inherit-package |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1827 | $(eval $(call inherit-package-internal,$(1),$(2),$(3),$(4),$(5),$(6),$(7))) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 1828 | endef |
| 1829 | |
| 1830 | define inherit-package-internal |
| 1831 | LOCAL_PACKAGE_OVERRIDES \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1832 | := $(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||&&$(strip $(5))||&&$(strip $(6))||&&$(strip $(7)) $(LOCAL_PACKAGE_OVERRIDES) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 1833 | include $(1) |
| 1834 | LOCAL_PACKAGE_OVERRIDES \ |
| 1835 | := $(wordlist 1,$(words $(LOCAL_PACKAGE_OVERRIDES)), $(LOCAL_PACKAGE_OVERRIDES)) |
| 1836 | endef |
| 1837 | |
| 1838 | # To be used with inherit-package above |
| 1839 | # Evalutes to true if the package was overridden |
| 1840 | define set-inherited-package-variables |
| 1841 | $(strip $(call set-inherited-package-variables-internal)) |
| 1842 | endef |
| 1843 | |
| 1844 | define keep-or-override |
| 1845 | $(eval $(1) := $(if $(2),$(2),$($(1)))) |
| 1846 | endef |
| 1847 | |
| 1848 | define set-inherited-package-variables-internal |
| 1849 | $(eval _o := $(subst ||, ,$(lastword $(LOCAL_PACKAGE_OVERRIDES)))) |
| 1850 | $(eval _n := $(subst ||, ,$(firstword $(LOCAL_PACKAGE_OVERRIDES)))) |
| 1851 | $(if $(filter $(word 2,$(_n)),$(LOCAL_PACKAGE_NAME)), \ |
| 1852 | $(eval LOCAL_PACKAGE_NAME := $(word 3,$(_o))) \ |
| 1853 | $(eval LOCAL_MANIFEST_PACKAGE_NAME := $(word 4,$(_o))) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1854 | $(call keep-or-override,LOCAL_CERTIFICATE,$(patsubst &&%,%,$(word 5,$(_o)))) \ |
| 1855 | $(call keep-or-override,LOCAL_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 6,$(_o)))) \ |
| 1856 | $(call keep-or-override,LOCAL_MANIFEST_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 7,$(_o)))) \ |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 1857 | $(eval LOCAL_OVERRIDES_PACKAGES := $(sort $(LOCAL_OVERRIDES_PACKAGES) $(word 2,$(_o)))) \ |
| 1858 | true \ |
| 1859 | ,) |
| 1860 | endef |
| 1861 | |
| 1862 | |
| 1863 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1864 | ## Other includes |
| 1865 | ########################################################### |
| 1866 | |
| 1867 | # ----------------------------------------------------------------- |
| 1868 | # Rules and functions to help copy important files to DIST_DIR |
| 1869 | # when requested. |
| 1870 | include $(BUILD_SYSTEM)/distdir.mk |
| 1871 | |
Jean-Baptiste Queru | 4074f23 | 2010-09-03 16:32:58 -0700 | [diff] [blame] | 1872 | # ----------------------------------------------------------------- |
| 1873 | # The modules allowed to use a user tag |
| 1874 | include $(BUILD_SYSTEM)/user_tags.mk |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1875 | |
| 1876 | # broken: |
| 1877 | # $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file))) |
| 1878 | |
| 1879 | ########################################################### |
| 1880 | ## Misc notes |
| 1881 | ########################################################### |
| 1882 | |
| 1883 | #DEPDIR = .deps |
| 1884 | #df = $(DEPDIR)/$(*F) |
| 1885 | |
| 1886 | #SRCS = foo.c bar.c ... |
| 1887 | |
| 1888 | #%.o : %.c |
| 1889 | # @$(MAKEDEPEND); \ |
| 1890 | # cp $(df).d $(df).P; \ |
| 1891 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 1892 | # -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \ |
| 1893 | # rm -f $(df).d |
| 1894 | # $(COMPILE.c) -o $@ $< |
| 1895 | |
| 1896 | #-include $(SRCS:%.c=$(DEPDIR)/%.P) |
| 1897 | |
| 1898 | |
| 1899 | #%.o : %.c |
| 1900 | # $(COMPILE.c) -MD -o $@ $< |
| 1901 | # @cp $*.d $*.P; \ |
| 1902 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 1903 | # -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ |
| 1904 | # rm -f $*.d |