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 | ########################################################### |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 239 | ## Find all of the html files under the named directories. |
| 240 | ## Meant to be used like: |
| 241 | ## SRC_FILES := $(call all-html-files-under,src tests) |
| 242 | ########################################################### |
| 243 | |
| 244 | define all-html-files-under |
| 245 | $(patsubst ./%,%, \ |
| 246 | $(shell cd $(LOCAL_PATH) ; \ |
| 247 | find $(1) -name "*.html" -and -not -name ".*") \ |
| 248 | ) |
| 249 | endef |
| 250 | |
| 251 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 252 | ## Find all of the html files from here. Meant to be used like: |
| 253 | ## SRC_FILES := $(call all-subdir-html-files) |
| 254 | ########################################################### |
| 255 | |
| 256 | define all-subdir-html-files |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 257 | $(call all-html-files-under,.) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 258 | endef |
| 259 | |
| 260 | ########################################################### |
| 261 | ## Find all of the files matching pattern |
| 262 | ## SRC_FILES := $(call find-subdir-files, <pattern>) |
| 263 | ########################################################### |
| 264 | |
| 265 | define find-subdir-files |
| 266 | $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find $(1))) |
| 267 | endef |
| 268 | |
| 269 | ########################################################### |
| 270 | # find the files in the subdirectory $1 of LOCAL_DIR |
| 271 | # matching pattern $2, filtering out files $3 |
| 272 | # e.g. |
| 273 | # SRC_FILES += $(call find-subdir-subdir-files, \ |
| 274 | # css, *.cpp, DontWantThis.cpp) |
| 275 | ########################################################### |
| 276 | |
| 277 | define find-subdir-subdir-files |
| 278 | $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \ |
| 279 | $(LOCAL_PATH) ; find $(1) -maxdepth 1 -name $(2)))) |
| 280 | endef |
| 281 | |
| 282 | ########################################################### |
| 283 | ## Find all of the files matching pattern |
| 284 | ## SRC_FILES := $(call all-subdir-java-files) |
| 285 | ########################################################### |
| 286 | |
| 287 | define find-subdir-assets |
| 288 | $(if $(1),$(patsubst ./%,%, \ |
| 289 | $(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -type f -and -not -type l ; fi)), \ |
| 290 | $(warning Empty argument supplied to find-subdir-assets) \ |
| 291 | ) |
| 292 | endef |
| 293 | |
| 294 | ########################################################### |
| 295 | ## Find various file types in a list of directories relative to $(LOCAL_PATH) |
| 296 | ########################################################### |
| 297 | |
| 298 | define find-other-java-files |
| 299 | $(call find-subdir-files,$(1) -name "*.java" -and -not -name ".*") |
| 300 | endef |
| 301 | |
| 302 | define find-other-html-files |
| 303 | $(call find-subdir-files,$(1) -name "*.html" -and -not -name ".*") |
| 304 | endef |
| 305 | |
| 306 | ########################################################### |
| 307 | ## Scan through each directory of $(1) looking for files |
| 308 | ## that match $(2) using $(wildcard). Useful for seeing if |
| 309 | ## a given directory or one of its parents contains |
| 310 | ## a particular file. Returns the first match found, |
| 311 | ## starting furthest from the root. |
| 312 | ########################################################### |
| 313 | |
| 314 | define find-parent-file |
| 315 | $(strip \ |
| 316 | $(eval _fpf := $(wildcard $(strip $(1))/$(strip $(2)))) \ |
| 317 | $(if $(_fpf),$(_fpf), \ |
| 318 | $(if $(filter-out ./ .,$(1)), \ |
| 319 | $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \ |
| 320 | ) \ |
| 321 | ) \ |
| 322 | ) |
| 323 | endef |
| 324 | |
| 325 | ########################################################### |
| 326 | ## Function we can evaluate to introduce a dynamic dependency |
| 327 | ########################################################### |
| 328 | |
| 329 | define add-dependency |
| 330 | $(1): $(2) |
| 331 | endef |
| 332 | |
| 333 | ########################################################### |
| 334 | ## Set up the dependencies for a prebuilt target |
| 335 | ## $(call add-prebuilt-file, srcfile, [targetclass]) |
| 336 | ########################################################### |
| 337 | |
| 338 | define add-prebuilt-file |
| 339 | $(eval $(include-prebuilt)) |
| 340 | endef |
| 341 | |
| 342 | define include-prebuilt |
| 343 | include $$(CLEAR_VARS) |
| 344 | LOCAL_SRC_FILES := $(1) |
| 345 | LOCAL_BUILT_MODULE_STEM := $(1) |
| 346 | LOCAL_MODULE_SUFFIX := $$(suffix $(1)) |
| 347 | LOCAL_MODULE := $$(basename $(1)) |
| 348 | LOCAL_MODULE_CLASS := $(2) |
| 349 | include $$(BUILD_PREBUILT) |
| 350 | endef |
| 351 | |
| 352 | ########################################################### |
| 353 | ## do multiple prebuilts |
| 354 | ## $(call target class, files ...) |
| 355 | ########################################################### |
| 356 | |
| 357 | define add-prebuilt-files |
| 358 | $(foreach f,$(2),$(call add-prebuilt-file,$f,$(1))) |
| 359 | endef |
| 360 | |
| 361 | |
| 362 | |
| 363 | ########################################################### |
| 364 | ## The intermediates directory. Where object files go for |
| 365 | ## a given target. We could technically get away without |
| 366 | ## the "_intermediates" suffix on the directory, but it's |
| 367 | ## nice to be able to grep for that string to find out if |
| 368 | ## anyone's abusing the system. |
| 369 | ########################################################### |
| 370 | |
| 371 | # $(1): target class, like "APPS" |
| 372 | # $(2): target name, like "NotePad" |
| 373 | # $(3): if non-empty, this is a HOST target. |
| 374 | # $(4): if non-empty, force the intermediates to be COMMON |
| 375 | define intermediates-dir-for |
| 376 | $(strip \ |
| 377 | $(eval _idfClass := $(strip $(1))) \ |
| 378 | $(if $(_idfClass),, \ |
| 379 | $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \ |
| 380 | $(eval _idfName := $(strip $(2))) \ |
| 381 | $(if $(_idfName),, \ |
| 382 | $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \ |
| 383 | $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ |
| 384 | $(if $(filter $(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ |
| 385 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \ |
| 386 | , \ |
| 387 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \ |
| 388 | ) \ |
| 389 | $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ |
| 390 | ) |
| 391 | endef |
| 392 | |
| 393 | # Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE |
| 394 | # to determine the intermediates directory. |
| 395 | # |
| 396 | # $(1): if non-empty, force the intermediates to be COMMON |
| 397 | define local-intermediates-dir |
| 398 | $(strip \ |
| 399 | $(if $(strip $(LOCAL_MODULE_CLASS)),, \ |
| 400 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \ |
| 401 | $(if $(strip $(LOCAL_MODULE)),, \ |
| 402 | $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \ |
| 403 | $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \ |
| 404 | ) |
| 405 | endef |
| 406 | |
| 407 | ########################################################### |
| 408 | ## Convert "path/to/libXXX.so" to "-lXXX". |
| 409 | ## Any "path/to/libXXX.a" elements pass through unchanged. |
| 410 | ########################################################### |
| 411 | |
| 412 | define normalize-libraries |
| 413 | $(foreach so,$(filter %.so,$(1)),-l$(patsubst lib%.so,%,$(notdir $(so))))\ |
| 414 | $(filter-out %.so,$(1)) |
| 415 | endef |
| 416 | |
| 417 | # TODO: change users to call the common version. |
| 418 | define normalize-host-libraries |
| 419 | $(call normalize-libraries,$(1)) |
| 420 | endef |
| 421 | |
| 422 | define normalize-target-libraries |
| 423 | $(call normalize-libraries,$(1)) |
| 424 | endef |
| 425 | |
| 426 | ########################################################### |
| 427 | ## Convert a list of short module names (e.g., "framework", "Browser") |
| 428 | ## into the list of files that are built for those modules. |
| 429 | ## NOTE: this won't return reliable results until after all |
| 430 | ## sub-makefiles have been included. |
| 431 | ## $(1): target list |
| 432 | ########################################################### |
| 433 | |
| 434 | define module-built-files |
| 435 | $(foreach module,$(1),$(ALL_MODULES.$(module).BUILT)) |
| 436 | endef |
| 437 | |
| 438 | ########################################################### |
| 439 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 440 | ## into the list of files that are installed for those modules. |
| 441 | ## NOTE: this won't return reliable results until after all |
| 442 | ## sub-makefiles have been included. |
| 443 | ## $(1): target list |
| 444 | ########################################################### |
| 445 | |
| 446 | define module-installed-files |
| 447 | $(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED)) |
| 448 | endef |
| 449 | |
| 450 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 451 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 452 | ## into the list of files that should be used when linking |
| 453 | ## against that module as a public API. |
| 454 | ## TODO: Allow this for more than JAVA_LIBRARIES modules |
| 455 | ## NOTE: this won't return reliable results until after all |
| 456 | ## sub-makefiles have been included. |
| 457 | ## $(1): target list |
| 458 | ########################################################### |
| 459 | |
| 460 | define module-stubs-files |
| 461 | $(foreach module,$(1),$(ALL_MODULES.$(module).STUBS)) |
| 462 | endef |
| 463 | |
| 464 | ########################################################### |
| 465 | ## Evaluates to the timestamp file for a doc module, which |
| 466 | ## is the dependency that should be used. |
| 467 | ## $(1): doc module |
| 468 | ########################################################### |
| 469 | |
| 470 | define doc-timestamp-for |
| 471 | $(OUT_DOCS)/$(strip $(1))-timestamp |
| 472 | endef |
| 473 | |
| 474 | |
| 475 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 476 | ## Convert "framework framework-res ext" to "out/.../javalib.jar ..." |
| 477 | ## This lets us treat framework-res as a normal library. |
| 478 | ## $(1): library list |
| 479 | ## $(2): Non-empty if IS_HOST_MODULE |
| 480 | ########################################################### |
| 481 | |
| 482 | # $(1): library name |
| 483 | # $(2): Non-empty if IS_HOST_MODULE |
| 484 | define _java-lib-dir |
| 485 | $(call intermediates-dir-for, \ |
| 486 | $(if $(filter framework-res,$(1)),APPS,JAVA_LIBRARIES),$(1),$(2)) |
| 487 | endef |
| 488 | |
| 489 | # $(1): library name |
| 490 | define _java-lib-classes.jar |
| 491 | $(if $(filter framework-res,$(1)),package$(COMMON_ANDROID_PACKAGE_SUFFIX),classes$(COMMON_JAVA_PACKAGE_SUFFIX)) |
| 492 | endef |
| 493 | |
| 494 | # $(1): library name |
| 495 | # $(2): Non-empty if IS_HOST_MODULE |
| 496 | define _java-lib-full-classes.jar |
| 497 | $(call _java-lib-dir,$(1),$(2))/$(call _java-lib-classes.jar,$(1)) |
| 498 | endef |
| 499 | |
| 500 | # $(1): library name list |
| 501 | # $(2): Non-empty if IS_HOST_MODULE |
| 502 | define java-lib-files |
| 503 | $(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2))) |
| 504 | endef |
| 505 | |
| 506 | # $(1): library name |
| 507 | define _java-lib-dep |
| 508 | $(if $(filter framework-res,$(1)),package$(COMMON_ANDROID_PACKAGE_SUFFIX),javalib$(COMMON_JAVA_PACKAGE_SUFFIX)) |
| 509 | endef |
| 510 | |
| 511 | # $(1): library name |
| 512 | # $(2): Non-empty if IS_HOST_MODULE |
| 513 | define _java-lib-full-dep |
| 514 | $(call _java-lib-dir,$(1),$(2))/$(call _java-lib-dep,$(1)) |
| 515 | endef |
| 516 | |
| 517 | # $(1): library name list |
| 518 | # $(2): Non-empty if IS_HOST_MODULE |
| 519 | define java-lib-deps |
| 520 | $(foreach lib,$(1),$(call _java-lib-full-dep,$(lib),$(2))) |
| 521 | endef |
| 522 | |
| 523 | ########################################################### |
| 524 | ## Convert "a b c" into "a:b:c" |
| 525 | ########################################################### |
| 526 | |
| 527 | empty := |
| 528 | space := $(empty) $(empty) |
| 529 | |
| 530 | define normalize-path-list |
| 531 | $(subst $(space),:,$(strip $(1))) |
| 532 | endef |
| 533 | |
| 534 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 535 | ## Read the word out of a colon-separated list of words. |
| 536 | ## This has the same behavior as the built-in function |
| 537 | ## $(word n,str). |
| 538 | ## |
| 539 | ## The individual words may not contain spaces. |
| 540 | ## |
| 541 | ## $(1): 1 based index |
| 542 | ## $(2): value of the form a:b:c... |
| 543 | ########################################################### |
| 544 | |
| 545 | define word-colon |
| 546 | $(word $(1),$(subst :,$(space),$(2))) |
| 547 | endef |
| 548 | |
| 549 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 550 | ## Convert "a=b c= d e = f" into "a=b c=d e=f" |
| 551 | ## |
| 552 | ## $(1): list to collapse |
| 553 | ## $(2): if set, separator word; usually "=", ":", or ":=" |
| 554 | ## Defaults to "=" if not set. |
| 555 | ########################################################### |
| 556 | |
| 557 | define collapse-pairs |
| 558 | $(eval _cpSEP := $(strip $(if $(2),$(2),=)))\ |
| 559 | $(subst $(space)$(_cpSEP)$(space),$(_cpSEP),$(strip \ |
| 560 | $(subst $(_cpSEP), $(_cpSEP) ,$(1)))) |
| 561 | endef |
| 562 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 563 | ########################################################### |
| 564 | ## MODULE_TAG set operations |
| 565 | ########################################################### |
| 566 | |
| 567 | # Given a list of tags, return the targets that specify |
| 568 | # any of those tags. |
| 569 | # $(1): tag list |
| 570 | define modules-for-tag-list |
| 571 | $(sort $(foreach tag,$(1),$(ALL_MODULE_TAGS.$(tag)))) |
| 572 | endef |
| 573 | |
| 574 | # Same as modules-for-tag-list, but operates on |
| 575 | # ALL_MODULE_NAME_TAGS. |
| 576 | # $(1): tag list |
| 577 | define module-names-for-tag-list |
| 578 | $(sort $(foreach tag,$(1),$(ALL_MODULE_NAME_TAGS.$(tag)))) |
| 579 | endef |
| 580 | |
| 581 | # Given an accept and reject list, find the matching |
| 582 | # set of targets. If a target has multiple tags and |
| 583 | # any of them are rejected, the target is rejected. |
| 584 | # Reject overrides accept. |
| 585 | # $(1): list of tags to accept |
| 586 | # $(2): list of tags to reject |
| 587 | #TODO(dbort): do $(if $(strip $(1)),$(1),$(ALL_MODULE_TAGS)) |
Jean-Baptiste Queru | 75127b7 | 2010-01-07 11:44:22 -0800 | [diff] [blame] | 588 | #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] | 589 | define get-tagged-modules |
| 590 | $(filter-out \ |
| 591 | $(call modules-for-tag-list,$(2)), \ |
| 592 | $(call modules-for-tag-list,$(1))) |
| 593 | endef |
| 594 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 595 | ########################################################### |
| 596 | ## Append a leaf to a base path. Properly deals with |
| 597 | ## base paths ending in /. |
| 598 | ## |
| 599 | ## $(1): base path |
| 600 | ## $(2): leaf path |
| 601 | ########################################################### |
| 602 | |
| 603 | define append-path |
| 604 | $(subst //,/,$(1)/$(2)) |
| 605 | endef |
| 606 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 607 | |
| 608 | ########################################################### |
| 609 | ## Package filtering |
| 610 | ########################################################### |
| 611 | |
| 612 | # Given a list of installed modules (short or long names) |
| 613 | # return a list of the packages (yes, .apk packages, not |
| 614 | # modules in general) that are overridden by this list and, |
| 615 | # therefore, should not be installed. |
| 616 | # $(1): mixed list of installed modules |
| 617 | # TODO: This is fragile; find a reliable way to get this information. |
| 618 | define _get-package-overrides |
| 619 | $(eval ### Discard any words containing slashes, unless they end in .apk, \ |
| 620 | ### in which case trim off the directory component and the suffix. \ |
| 621 | ### If there are no slashes, keep the entire word.) |
| 622 | $(eval _gpo_names := $(subst /,@@@ @@@,$(1))) |
| 623 | $(eval _gpo_names := \ |
| 624 | $(filter %.apk,$(_gpo_names)) \ |
| 625 | $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 626 | $(eval _gpo_names := $(patsubst %.apk,%,$(_gpo_names))) |
| 627 | $(eval _gpo_names := $(patsubst @@@%,%,$(_gpo_names))) |
| 628 | |
| 629 | $(eval ### Remove any remaining words that contain dots.) |
| 630 | $(eval _gpo_names := $(subst .,@@@ @@@,$(_gpo_names))) |
| 631 | $(eval _gpo_names := $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 632 | |
| 633 | $(eval ### Now we have a list of any words that could possibly refer to \ |
| 634 | ### packages, although there may be words that do not. Only \ |
| 635 | ### real packages will be present under PACKAGES.*, though.) |
| 636 | $(foreach _gpo_name,$(_gpo_names),$(PACKAGES.$(_gpo_name).OVERRIDES)) |
| 637 | endef |
| 638 | |
| 639 | define get-package-overrides |
| 640 | $(strip $(sort $(call _get-package-overrides,$(1)))) |
| 641 | endef |
| 642 | |
| 643 | ########################################################### |
| 644 | ## Output the command lines, or not |
| 645 | ########################################################### |
| 646 | |
| 647 | ifeq ($(strip $(SHOW_COMMANDS)),) |
| 648 | define pretty |
| 649 | @echo $1 |
| 650 | endef |
| 651 | hide := @ |
| 652 | else |
| 653 | define pretty |
| 654 | endef |
| 655 | hide := |
| 656 | endif |
| 657 | |
| 658 | ########################################################### |
| 659 | ## Dump the variables that are associated with targets |
| 660 | ########################################################### |
| 661 | |
| 662 | define dump-module-variables |
| 663 | @echo all_dependencies=$^ |
| 664 | @echo PRIVATE_YACCFLAGS=$(PRIVATE_YACCFLAGS); |
| 665 | @echo PRIVATE_CFLAGS=$(PRIVATE_CFLAGS); |
| 666 | @echo PRIVATE_CPPFLAGS=$(PRIVATE_CPPFLAGS); |
| 667 | @echo PRIVATE_DEBUG_CFLAGS=$(PRIVATE_DEBUG_CFLAGS); |
| 668 | @echo PRIVATE_C_INCLUDES=$(PRIVATE_C_INCLUDES); |
| 669 | @echo PRIVATE_LDFLAGS=$(PRIVATE_LDFLAGS); |
| 670 | @echo PRIVATE_LDLIBS=$(PRIVATE_LDLIBS); |
| 671 | @echo PRIVATE_ARFLAGS=$(PRIVATE_ARFLAGS); |
| 672 | @echo PRIVATE_AAPT_FLAGS=$(PRIVATE_AAPT_FLAGS); |
| 673 | @echo PRIVATE_DX_FLAGS=$(PRIVATE_DX_FLAGS); |
| 674 | @echo PRIVATE_JAVA_LIBRARIES=$(PRIVATE_JAVA_LIBRARIES); |
| 675 | @echo PRIVATE_ALL_SHARED_LIBRARIES=$(PRIVATE_ALL_SHARED_LIBRARIES); |
| 676 | @echo PRIVATE_ALL_STATIC_LIBRARIES=$(PRIVATE_ALL_STATIC_LIBRARIES); |
| 677 | @echo PRIVATE_ALL_WHOLE_STATIC_LIBRARIES=$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES); |
| 678 | @echo PRIVATE_ALL_OBJECTS=$(PRIVATE_ALL_OBJECTS); |
| 679 | endef |
| 680 | |
| 681 | ########################################################### |
| 682 | ## Commands for using sed to replace given variable values |
| 683 | ########################################################### |
| 684 | |
| 685 | define transform-variables |
| 686 | @mkdir -p $(dir $@) |
| 687 | @echo "Sed: $(if $(PRIVATE_MODULE),$(PRIVATE_MODULE),$@) <= $<" |
| 688 | $(hide) sed $(foreach var,$(REPLACE_VARS),-e "s/{{$(var)}}/$(subst /,\/,$(PWD)/$($(var)))/g") $< >$@ |
| 689 | $(hide) if [ "$(suffix $@)" = ".sh" ]; then chmod a+rx $@; fi |
| 690 | endef |
| 691 | |
| 692 | |
| 693 | ########################################################### |
| 694 | ## Commands for munging the dependency files GCC generates |
| 695 | ########################################################### |
| 696 | |
| 697 | define transform-d-to-p |
| 698 | @cp $(@:%.o=%.d) $(@:%.o=%.P); \ |
| 699 | sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 700 | -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ |
| 701 | rm -f $(@:%.o=%.d) |
| 702 | endef |
| 703 | |
| 704 | ########################################################### |
| 705 | ## Commands for running lex |
| 706 | ########################################################### |
| 707 | |
| 708 | define transform-l-to-cpp |
| 709 | @mkdir -p $(dir $@) |
| 710 | @echo "Lex: $(PRIVATE_MODULE) <= $<" |
| 711 | $(hide) $(LEX) -o$@ $< |
| 712 | endef |
| 713 | |
| 714 | ########################################################### |
| 715 | ## Commands for running yacc |
| 716 | ## |
| 717 | ## Because the extension of c++ files can change, the |
| 718 | ## extension must be specified in $1. |
| 719 | ## E.g, "$(call transform-y-to-cpp,.cpp)" |
| 720 | ########################################################### |
| 721 | |
| 722 | define transform-y-to-cpp |
| 723 | @mkdir -p $(dir $@) |
| 724 | @echo "Yacc: $(PRIVATE_MODULE) <= $<" |
| 725 | $(YACC) $(PRIVATE_YACCFLAGS) -o $@ $< |
| 726 | touch $(@:$1=$(YACC_HEADER_SUFFIX)) |
| 727 | echo '#ifndef '$(@F:$1=_h) > $(@:$1=.h) |
| 728 | echo '#define '$(@F:$1=_h) >> $(@:$1=.h) |
| 729 | cat $(@:$1=$(YACC_HEADER_SUFFIX)) >> $(@:$1=.h) |
| 730 | echo '#endif' >> $(@:$1=.h) |
| 731 | rm -f $(@:$1=$(YACC_HEADER_SUFFIX)) |
| 732 | endef |
| 733 | |
| 734 | |
| 735 | ########################################################### |
| 736 | ## Commands for running aidl |
| 737 | ########################################################### |
| 738 | |
| 739 | define transform-aidl-to-java |
| 740 | @mkdir -p $(dir $@) |
| 741 | @echo "Aidl: $(PRIVATE_MODULE) <= $<" |
| 742 | $(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@ |
| 743 | endef |
| 744 | #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@ |
| 745 | |
| 746 | |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 747 | ########################################################### |
| 748 | ## Commands for running java-event-log-tags.py |
| 749 | ########################################################### |
| 750 | |
| 751 | define transform-logtags-to-java |
| 752 | @mkdir -p $(dir $@) |
| 753 | @echo "logtags: $@ <= $<" |
| 754 | $(hide) $(JAVATAGS) -o $@ $< |
| 755 | endef |
| 756 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 757 | |
| 758 | ########################################################### |
| 759 | ## Commands for running gcc to compile a C++ file |
| 760 | ########################################################### |
| 761 | |
| 762 | define transform-cpp-to-o |
| 763 | @mkdir -p $(dir $@) |
| 764 | @echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<" |
| 765 | $(hide) $(PRIVATE_CXX) \ |
| 766 | $(foreach incdir, \ |
| 767 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 768 | $(TARGET_PROJECT_INCLUDES) \ |
| 769 | $(TARGET_C_INCLUDES) \ |
| 770 | ) \ |
| 771 | $(PRIVATE_C_INCLUDES) \ |
| 772 | , \ |
| 773 | -I $(incdir) \ |
| 774 | ) \ |
| 775 | -c \ |
| 776 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 777 | $(TARGET_GLOBAL_CFLAGS) \ |
| 778 | $(TARGET_GLOBAL_CPPFLAGS) \ |
| 779 | $(PRIVATE_ARM_CFLAGS) \ |
| 780 | ) \ |
| 781 | -fno-rtti \ |
| 782 | $(PRIVATE_CFLAGS) \ |
| 783 | $(PRIVATE_CPPFLAGS) \ |
| 784 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 785 | -MD -o $@ $< |
| 786 | $(hide) $(transform-d-to-p) |
| 787 | endef |
| 788 | |
| 789 | |
| 790 | ########################################################### |
| 791 | ## Commands for running gcc to compile a C file |
| 792 | ########################################################### |
| 793 | |
| 794 | # $(1): extra flags |
| 795 | define transform-c-or-s-to-o-no-deps |
| 796 | @mkdir -p $(dir $@) |
| 797 | $(hide) $(PRIVATE_CC) \ |
| 798 | $(foreach incdir, \ |
| 799 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 800 | $(TARGET_PROJECT_INCLUDES) \ |
| 801 | $(TARGET_C_INCLUDES) \ |
| 802 | ) \ |
| 803 | $(PRIVATE_C_INCLUDES) \ |
| 804 | , \ |
| 805 | -I $(incdir) \ |
| 806 | ) \ |
| 807 | -c \ |
| 808 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 809 | $(TARGET_GLOBAL_CFLAGS) \ |
| 810 | $(PRIVATE_ARM_CFLAGS) \ |
| 811 | ) \ |
| 812 | $(PRIVATE_CFLAGS) \ |
| 813 | $(1) \ |
| 814 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 815 | -MD -o $@ $< |
| 816 | endef |
| 817 | |
| 818 | define transform-c-to-o-no-deps |
| 819 | @echo "target $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<" |
| 820 | $(call transform-c-or-s-to-o-no-deps, ) |
| 821 | endef |
| 822 | |
| 823 | define transform-s-to-o-no-deps |
| 824 | @echo "target asm: $(PRIVATE_MODULE) <= $<" |
| 825 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 826 | endef |
| 827 | |
| 828 | define transform-c-to-o |
| 829 | $(transform-c-to-o-no-deps) |
| 830 | $(hide) $(transform-d-to-p) |
| 831 | endef |
| 832 | |
| 833 | define transform-s-to-o |
| 834 | $(transform-s-to-o-no-deps) |
| 835 | $(hide) $(transform-d-to-p) |
| 836 | endef |
| 837 | |
| 838 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 839 | ## Commands for running gcc to compile an Objective-C file |
| 840 | ## This should never happen for target builds but this |
| 841 | ## will error at build time. |
| 842 | ########################################################### |
| 843 | |
| 844 | define transform-m-to-o-no-deps |
| 845 | @echo "target ObjC: $(PRIVATE_MODULE) <= $<" |
| 846 | $(call transform-c-or-s-to-o-no-deps) |
| 847 | endef |
| 848 | |
| 849 | define transform-m-to-o |
| 850 | $(transform-m-to-o-no-deps) |
| 851 | $(hide) $(transform-d-to-p) |
| 852 | endef |
| 853 | |
| 854 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 855 | ## Commands for running gcc to compile a host C++ file |
| 856 | ########################################################### |
| 857 | |
| 858 | define transform-host-cpp-to-o |
| 859 | @mkdir -p $(dir $@) |
| 860 | @echo "host C++: $(PRIVATE_MODULE) <= $<" |
| 861 | $(hide) $(PRIVATE_CXX) \ |
| 862 | $(foreach incdir, \ |
| 863 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 864 | $(HOST_PROJECT_INCLUDES) \ |
| 865 | $(HOST_C_INCLUDES) \ |
| 866 | ) \ |
| 867 | $(PRIVATE_C_INCLUDES) \ |
| 868 | , \ |
| 869 | -I $(incdir) \ |
| 870 | ) \ |
| 871 | -c \ |
| 872 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 873 | $(HOST_GLOBAL_CFLAGS) \ |
| 874 | $(HOST_GLOBAL_CPPFLAGS) \ |
| 875 | ) \ |
| 876 | $(PRIVATE_CFLAGS) \ |
| 877 | $(PRIVATE_CPPFLAGS) \ |
| 878 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 879 | -MD -o $@ $< |
| 880 | $(transform-d-to-p) |
| 881 | endef |
| 882 | |
| 883 | |
| 884 | ########################################################### |
| 885 | ## Commands for running gcc to compile a host C file |
| 886 | ########################################################### |
| 887 | |
| 888 | # $(1): extra flags |
| 889 | define transform-host-c-or-s-to-o-no-deps |
| 890 | @mkdir -p $(dir $@) |
| 891 | $(hide) $(PRIVATE_CC) \ |
| 892 | $(foreach incdir, \ |
| 893 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 894 | $(HOST_PROJECT_INCLUDES) \ |
| 895 | $(HOST_C_INCLUDES) \ |
| 896 | ) \ |
| 897 | $(PRIVATE_C_INCLUDES) \ |
| 898 | , \ |
| 899 | -I $(incdir) \ |
| 900 | ) \ |
| 901 | -c \ |
| 902 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 903 | $(HOST_GLOBAL_CFLAGS) \ |
| 904 | ) \ |
| 905 | $(PRIVATE_CFLAGS) \ |
| 906 | $(1) \ |
| 907 | $(PRIVATE_DEBUG_CFLAGS) \ |
| 908 | -MD -o $@ $< |
| 909 | endef |
| 910 | |
| 911 | define transform-host-c-to-o-no-deps |
| 912 | @echo "host C: $(PRIVATE_MODULE) <= $<" |
| 913 | $(call transform-host-c-or-s-to-o-no-deps, ) |
| 914 | endef |
| 915 | |
| 916 | define transform-host-s-to-o-no-deps |
| 917 | @echo "host asm: $(PRIVATE_MODULE) <= $<" |
| 918 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 919 | endef |
| 920 | |
| 921 | define transform-host-c-to-o |
| 922 | $(transform-host-c-to-o-no-deps) |
| 923 | $(transform-d-to-p) |
| 924 | endef |
| 925 | |
| 926 | define transform-host-s-to-o |
| 927 | $(transform-host-s-to-o-no-deps) |
| 928 | $(transform-d-to-p) |
| 929 | endef |
| 930 | |
| 931 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 932 | ## Commands for running gcc to compile a host Objective-C file |
| 933 | ########################################################### |
| 934 | |
| 935 | define transform-host-m-to-o-no-deps |
| 936 | @echo "host ObjC: $(PRIVATE_MODULE) <= $<" |
| 937 | $(call transform-host-c-or-s-to-o-no-deps) |
| 938 | endef |
| 939 | |
| 940 | define tranform-host-m-to-o |
| 941 | $(transform-host-m-to-o-no-deps) |
| 942 | $(transform-d-to-p) |
| 943 | endef |
| 944 | |
| 945 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 946 | ## Commands for running ar |
| 947 | ########################################################### |
| 948 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 949 | define extract-and-include-target-whole-static-libs |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 950 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
| 951 | @echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \ |
| 952 | ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\ |
| 953 | rm -rf $$ldir; \ |
| 954 | mkdir -p $$ldir; \ |
| 955 | filelist=; \ |
| 956 | for f in `$(TARGET_AR) t $(lib)`; do \ |
| 957 | $(TARGET_AR) p $(lib) $$f > $$ldir/$$f; \ |
| 958 | filelist="$$filelist $$ldir/$$f"; \ |
| 959 | done ; \ |
| 960 | $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\ |
| 961 | ) |
| 962 | endef |
| 963 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 964 | # Explicitly delete the archive first so that ar doesn't |
| 965 | # try to add to an existing archive. |
| 966 | define transform-o-to-static-lib |
| 967 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 968 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 969 | $(extract-and-include-target-whole-static-libs) |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 970 | @echo "target StaticLib: $(PRIVATE_MODULE) ($@)" |
Sriram Raman | 5bbd229 | 2009-10-07 16:27:38 -0700 | [diff] [blame] | 971 | $(hide) echo $^ | xargs $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 972 | endef |
| 973 | |
| 974 | ########################################################### |
| 975 | ## Commands for running host ar |
| 976 | ########################################################### |
| 977 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 978 | define extract-and-include-host-whole-static-libs |
| 979 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
| 980 | @echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \ |
| 981 | ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\ |
| 982 | rm -rf $$ldir; \ |
| 983 | mkdir -p $$ldir; \ |
| 984 | filelist=; \ |
Dan Bornstein | 6581fed | 2009-10-22 13:14:41 -0700 | [diff] [blame] | 985 | for f in `$(HOST_AR) t $(lib) | grep '\.o$$'`; do \ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 986 | $(HOST_AR) p $(lib) $$f > $$ldir/$$f; \ |
| 987 | filelist="$$filelist $$ldir/$$f"; \ |
| 988 | done ; \ |
| 989 | $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\ |
| 990 | ) |
| 991 | endef |
| 992 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 993 | # Explicitly delete the archive first so that ar doesn't |
| 994 | # try to add to an existing archive. |
| 995 | define transform-host-o-to-static-lib |
| 996 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 997 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 998 | $(extract-and-include-host-whole-static-libs) |
Dan Bornstein | 6bffc91 | 2009-10-15 13:01:36 -0700 | [diff] [blame] | 999 | @echo "host StaticLib: $(PRIVATE_MODULE) ($@)" |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1000 | echo $(filter %.o, $^) | \ |
| 1001 | xargs $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1002 | endef |
| 1003 | |
| 1004 | |
| 1005 | ########################################################### |
| 1006 | ## Commands for running gcc to link a shared library or package |
| 1007 | ########################################################### |
| 1008 | |
| 1009 | # ld just seems to be so finicky with command order that we allow |
| 1010 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1011 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1012 | define transform-host-o-to-shared-lib-inner |
| 1013 | $(HOST_CXX) \ |
| 1014 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1015 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1016 | -shared -Wl,-soname,$(notdir $@) \ |
| 1017 | $(PRIVATE_LDFLAGS) \ |
| 1018 | $(HOST_GLOBAL_LD_DIRS) \ |
| 1019 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1020 | $(HOST_GLOBAL_LDFLAGS) \ |
| 1021 | ) \ |
| 1022 | $(PRIVATE_ALL_OBJECTS) \ |
| 1023 | -Wl,--whole-archive \ |
| 1024 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1025 | -Wl,--no-whole-archive \ |
| 1026 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1027 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1028 | -o $@ \ |
| 1029 | $(PRIVATE_LDLIBS) |
| 1030 | endef |
| 1031 | endif |
| 1032 | |
| 1033 | define transform-host-o-to-shared-lib |
| 1034 | @mkdir -p $(dir $@) |
| 1035 | @echo "host SharedLib: $(PRIVATE_MODULE) ($@)" |
| 1036 | $(hide) $(transform-host-o-to-shared-lib-inner) |
| 1037 | endef |
| 1038 | |
| 1039 | define transform-host-o-to-package |
| 1040 | @mkdir -p $(dir $@) |
| 1041 | @echo "host Package: $(PRIVATE_MODULE) ($@)" |
| 1042 | $(hide) $(transform-host-o-to-shared-lib-inner) |
| 1043 | endef |
| 1044 | |
| 1045 | |
| 1046 | ########################################################### |
| 1047 | ## Commands for running gcc to link a shared library or package |
| 1048 | ########################################################### |
| 1049 | |
| 1050 | #echo >$@.vers "{"; \ |
| 1051 | #echo >>$@.vers " global:"; \ |
| 1052 | #$(BUILD_SYSTEM)/filter_symbols.sh $(TARGET_NM) " " ";" $(filter %.o,$^) | sort -u >>$@.vers; \ |
| 1053 | #echo >>$@.vers " local:"; \ |
| 1054 | #echo >>$@.vers " *;"; \ |
| 1055 | #echo >>$@.vers "};"; \ |
| 1056 | |
| 1057 | # -Wl,--version-script=$@.vers \ |
| 1058 | |
| 1059 | # ld just seems to be so finicky with command order that we allow |
| 1060 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1061 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1062 | define transform-o-to-shared-lib-inner |
| 1063 | $(TARGET_CXX) \ |
| 1064 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 1065 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1066 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1067 | -shared -Wl,-soname,$(notdir $@) \ |
| 1068 | $(PRIVATE_LDFLAGS) \ |
| 1069 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 1070 | $(PRIVATE_ALL_OBJECTS) \ |
| 1071 | -Wl,--whole-archive \ |
| 1072 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1073 | -Wl,--no-whole-archive \ |
| 1074 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1075 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1076 | -o $@ \ |
| 1077 | $(PRIVATE_LDLIBS) |
| 1078 | endef |
| 1079 | endif |
| 1080 | |
| 1081 | define transform-o-to-shared-lib |
| 1082 | @mkdir -p $(dir $@) |
| 1083 | @echo "target SharedLib: $(PRIVATE_MODULE) ($@)" |
| 1084 | $(hide) $(transform-o-to-shared-lib-inner) |
| 1085 | endef |
| 1086 | |
| 1087 | define transform-o-to-package |
| 1088 | @mkdir -p $(dir $@) |
| 1089 | @echo "target Package: $(PRIVATE_MODULE) ($@)" |
| 1090 | $(hide) $(transform-o-to-shared-lib-inner) |
| 1091 | endef |
| 1092 | |
| 1093 | |
| 1094 | ########################################################### |
| 1095 | ## Commands for filtering a target executable or library |
| 1096 | ########################################################### |
| 1097 | |
| 1098 | # Because of bug 743462 ("Prelinked image magic gets stripped |
| 1099 | # by arm-elf-objcopy"), we have to use soslim to strip target |
| 1100 | # binaries. |
| 1101 | define transform-to-stripped |
| 1102 | @mkdir -p $(dir $@) |
| 1103 | @echo "target Strip: $(PRIVATE_MODULE) ($@)" |
| 1104 | $(hide) $(SOSLIM) --strip --shady --quiet $< --outfile $@ |
| 1105 | endef |
| 1106 | |
| 1107 | define transform-to-prelinked |
| 1108 | @mkdir -p $(dir $@) |
| 1109 | @echo "target Prelink: $(PRIVATE_MODULE) ($@)" |
| 1110 | $(hide) $(APRIORI) \ |
| 1111 | --prelinkmap $(TARGET_PRELINKER_MAP) \ |
| 1112 | --locals-only \ |
| 1113 | --quiet \ |
| 1114 | $< \ |
| 1115 | --output $@ |
| 1116 | endef |
| 1117 | |
| 1118 | |
| 1119 | ########################################################### |
| 1120 | ## Commands for running gcc to link an executable |
| 1121 | ########################################################### |
| 1122 | |
| 1123 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1124 | define transform-o-to-executable-inner |
| 1125 | $(TARGET_CXX) \ |
| 1126 | $(TARGET_GLOBAL_LDFLAGS) \ |
| 1127 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1128 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 1129 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1130 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1131 | $(PRIVATE_LDFLAGS) \ |
| 1132 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 1133 | $(PRIVATE_ALL_OBJECTS) \ |
| 1134 | -Wl,--whole-archive \ |
| 1135 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1136 | -Wl,--no-whole-archive \ |
| 1137 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1138 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1139 | -o $@ \ |
| 1140 | $(PRIVATE_LDLIBS) |
| 1141 | endef |
| 1142 | endif |
| 1143 | |
| 1144 | define transform-o-to-executable |
| 1145 | @mkdir -p $(dir $@) |
| 1146 | @echo "target Executable: $(PRIVATE_MODULE) ($@)" |
| 1147 | $(hide) $(transform-o-to-executable-inner) |
| 1148 | endef |
| 1149 | |
| 1150 | |
| 1151 | ########################################################### |
| 1152 | ## Commands for running gcc to link a statically linked |
| 1153 | ## executable. In practice, we only use this on arm, so |
| 1154 | ## the other platforms don't have the |
| 1155 | ## transform-o-to-static-executable defined |
| 1156 | ########################################################### |
| 1157 | |
| 1158 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1159 | define transform-o-to-static-executable-inner |
| 1160 | endef |
| 1161 | endif |
| 1162 | |
| 1163 | define transform-o-to-static-executable |
| 1164 | @mkdir -p $(dir $@) |
| 1165 | @echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)" |
| 1166 | $(hide) $(transform-o-to-static-executable-inner) |
| 1167 | endef |
| 1168 | |
| 1169 | |
| 1170 | ########################################################### |
| 1171 | ## Commands for running gcc to link a host executable |
| 1172 | ########################################################### |
| 1173 | |
| 1174 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1175 | define transform-host-o-to-executable-inner |
| 1176 | $(HOST_CXX) \ |
| 1177 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1178 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1179 | $(HOST_GLOBAL_LD_DIRS) \ |
| 1180 | $(PRIVATE_LDFLAGS) \ |
| 1181 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1182 | $(HOST_GLOBAL_LDFLAGS) \ |
| 1183 | ) \ |
| 1184 | $(PRIVATE_ALL_OBJECTS) \ |
| 1185 | -Wl,--whole-archive \ |
| 1186 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1187 | -Wl,--no-whole-archive \ |
| 1188 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 1189 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1190 | -o $@ \ |
| 1191 | $(PRIVATE_LDLIBS) |
| 1192 | endef |
| 1193 | endif |
| 1194 | |
| 1195 | define transform-host-o-to-executable |
| 1196 | @mkdir -p $(dir $@) |
| 1197 | @echo "host Executable: $(PRIVATE_MODULE) ($@)" |
| 1198 | $(hide) $(transform-host-o-to-executable-inner) |
| 1199 | endef |
| 1200 | |
| 1201 | |
| 1202 | ########################################################### |
| 1203 | ## Commands for running javac to make .class files |
| 1204 | ########################################################### |
| 1205 | |
| 1206 | #@echo "Source intermediates dir: $(PRIVATE_SOURCE_INTERMEDIATES_DIR)" |
| 1207 | #@echo "Source intermediates: $$(find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java')" |
| 1208 | |
| 1209 | # TODO: Right now we generate the asset resources twice, first as part |
| 1210 | # of generating the Java classes, then at the end when packaging the final |
| 1211 | # assets. This should be changed to do one of two things: (1) Don't generate |
| 1212 | # any resource files the first time, only create classes during that stage; |
| 1213 | # or (2) Don't use the -c flag with the second stage, instead taking the |
| 1214 | # resource files from the first stage as additional input. My original intent |
| 1215 | # was to use approach (2), but this requires a little more work in the tool. |
| 1216 | # Maybe we should just use approach (1). |
| 1217 | |
| 1218 | # This rule creates the R.java and Manifest.java files, both of which |
| 1219 | # are PRODUCT-neutral. Don't pass PRODUCT_AAPT_CONFIG to this invocation. |
| 1220 | define create-resource-java-files |
| 1221 | @mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR) |
| 1222 | @mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) |
| 1223 | $(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m -z \ |
| 1224 | $(eval # PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \ |
| 1225 | $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ |
| 1226 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1227 | $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \ |
| 1228 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1229 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1230 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 1231 | $(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1232 | $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
| 1233 | $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
| 1234 | $(addprefix --version-code , $(PLATFORM_SDK_VERSION)) \ |
| 1235 | $(addprefix --version-name , $(PLATFORM_VERSION)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1236 | endef |
| 1237 | |
| 1238 | ifeq ($(HOST_OS),windows) |
| 1239 | xlint_unchecked := |
| 1240 | else |
| 1241 | #xlint_unchecked := -Xlint:unchecked |
| 1242 | endif |
| 1243 | |
| 1244 | # emit-line, <word list>, <output file> |
| 1245 | define emit-line |
| 1246 | $(if $(1),echo -n '$(strip $(1)) ' >> $(2)) |
| 1247 | endef |
| 1248 | |
| 1249 | # dump-words-to-file, <word list>, <output file> |
| 1250 | define dump-words-to-file |
| 1251 | @rm -f $(2) |
| 1252 | @$(call emit-line,$(wordlist 1,200,$(1)),$(2)) |
| 1253 | @$(call emit-line,$(wordlist 201,400,$(1)),$(2)) |
| 1254 | @$(call emit-line,$(wordlist 401,600,$(1)),$(2)) |
| 1255 | @$(call emit-line,$(wordlist 601,800,$(1)),$(2)) |
| 1256 | @$(call emit-line,$(wordlist 801,1000,$(1)),$(2)) |
| 1257 | @$(call emit-line,$(wordlist 1001,1200,$(1)),$(2)) |
| 1258 | @$(call emit-line,$(wordlist 1201,1400,$(1)),$(2)) |
| 1259 | @$(call emit-line,$(wordlist 1401,1600,$(1)),$(2)) |
| 1260 | @$(call emit-line,$(wordlist 1601,1800,$(1)),$(2)) |
| 1261 | @$(call emit-line,$(wordlist 1801,2000,$(1)),$(2)) |
| 1262 | @$(call emit-line,$(wordlist 2001,2200,$(1)),$(2)) |
| 1263 | @$(call emit-line,$(wordlist 2201,2400,$(1)),$(2)) |
| 1264 | @$(call emit-line,$(wordlist 2401,2600,$(1)),$(2)) |
| 1265 | @$(call emit-line,$(wordlist 2601,2800,$(1)),$(2)) |
| 1266 | @$(call emit-line,$(wordlist 2801,3000,$(1)),$(2)) |
| 1267 | @$(call emit-line,$(wordlist 3001,3200,$(1)),$(2)) |
| 1268 | @$(call emit-line,$(wordlist 3201,3400,$(1)),$(2)) |
| 1269 | @$(call emit-line,$(wordlist 3401,3600,$(1)),$(2)) |
| 1270 | @$(call emit-line,$(wordlist 3601,3800,$(1)),$(2)) |
| 1271 | @$(call emit-line,$(wordlist 3801,4000,$(1)),$(2)) |
| 1272 | @$(if $(wordlist 4001,4002,$(1)),$(error Too many words ($(words $(1))))) |
| 1273 | endef |
| 1274 | |
| 1275 | # For a list of jar files, unzip them to a specified directory, |
| 1276 | # but make sure that no META-INF files come along for the ride. |
| 1277 | # |
| 1278 | # $(1): files to unzip |
| 1279 | # $(2): destination directory |
| 1280 | define unzip-jar-files |
| 1281 | $(hide) for f in $(1); \ |
| 1282 | do \ |
| 1283 | if [ ! -f $$f ]; then \ |
| 1284 | echo Missing file $$f; \ |
| 1285 | exit 1; \ |
| 1286 | fi; \ |
Sriram Raman | f1a55f8 | 2009-06-09 15:08:29 -0700 | [diff] [blame] | 1287 | unzip -qo $$f -d $(2); \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1288 | (cd $(2) && rm -rf META-INF); \ |
| 1289 | done |
| 1290 | endef |
| 1291 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1292 | # below we write the list of java files to java-source-list to avoid argument |
| 1293 | # list length problems with Cygwin we filter out duplicate java file names |
| 1294 | # because eclipse's compiler doesn't like them. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1295 | define transform-java-to-classes.jar |
| 1296 | @echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1297 | $(hide) rm -f $@ |
| 1298 | $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1299 | $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1300 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \ |
| 1301 | $(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1302 | $(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] | 1303 | $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1304 | 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] | 1305 | fi |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1306 | $(hide) tr ' ' '\n' < $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list \ |
| 1307 | | 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] | 1308 | $(hide) $(TARGET_JAVAC) -encoding ascii $(PRIVATE_BOOTCLASSPATH) \ |
| 1309 | $(addprefix -classpath ,$(strip \ |
| 1310 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \ |
| 1311 | $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) $(xlint_unchecked) \ |
| 1312 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1313 | \@$(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1314 | || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 1315 | $(hide) rm -f $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list |
| 1316 | $(hide) rm -f $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1317 | $(hide) mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1318 | $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \ |
| 1319 | $@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1320 | $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1321 | endef |
| 1322 | |
| 1323 | define transform-classes.jar-to-emma |
| 1324 | $(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \ |
| 1325 | $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) |
| 1326 | endef |
| 1327 | |
| 1328 | #TODO: use a smaller -Xmx value for most libraries; |
| 1329 | # only core.jar and framework.jar need a heap this big. |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 1330 | # 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] | 1331 | define transform-classes.jar-to-dex |
| 1332 | @echo "target Dex: $(PRIVATE_MODULE)" |
| 1333 | @mkdir -p $(dir $@) |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 1334 | $(hide) $(DX) \ |
| 1335 | $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1536M) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1336 | --dex --output=$@ \ |
| 1337 | $(if $(NO_OPTIMIZE_DX), \ |
| 1338 | --no-optimize) \ |
| 1339 | $(if $(GENERATE_DEX_DEBUG), \ |
| 1340 | --debug --verbose \ |
| 1341 | --dump-to=$(@:.dex=.lst) \ |
| 1342 | --dump-width=1000) \ |
| 1343 | $(PRIVATE_DX_FLAGS) \ |
| 1344 | $< |
| 1345 | endef |
| 1346 | |
| 1347 | # Create a mostly-empty .jar file that we'll add to later. |
| 1348 | # The MacOS jar tool doesn't like creating empty jar files, |
| 1349 | # so we need to give it something. |
| 1350 | define create-empty-package |
| 1351 | @mkdir -p $(dir $@) |
| 1352 | $(hide) touch $(dir $@)/dummy |
| 1353 | $(hide) (cd $(dir $@) && jar cf $(notdir $@) dummy) |
| 1354 | $(hide) zip -qd $@ dummy |
| 1355 | $(hide) rm $(dir $@)/dummy |
| 1356 | endef |
| 1357 | |
| 1358 | #TODO: we kinda want to build different asset packages for |
| 1359 | # different configurations, then combine them later (or something). |
| 1360 | # Per-locale, etc. |
| 1361 | # A list of dynamic and static parameters; build layers for |
| 1362 | # dynamic params that lay over the static ones. |
| 1363 | #TODO: update the manifest to point to the package file |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1364 | #Note that the version numbers are given to aapt as simple default |
| 1365 | #values; applications can override these by explicitly stating |
| 1366 | #them in their manifest. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1367 | define add-assets-to-package |
| 1368 | $(hide) $(AAPT) package -z -u $(PRIVATE_AAPT_FLAGS) \ |
| 1369 | $(addprefix -c , $(PRODUCT_AAPT_CONFIG)) \ |
| 1370 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1371 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1372 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
| 1373 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1374 | $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
| 1375 | $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ |
| 1376 | $(addprefix --version-code , $(PLATFORM_SDK_VERSION)) \ |
| 1377 | $(addprefix --version-name , $(PLATFORM_VERSION)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1378 | -F $@ |
| 1379 | endef |
| 1380 | |
| 1381 | #TODO: Allow library directory to be specified based on the target |
| 1382 | # CPU and ABI instead of being hard coded as armeabi. |
| 1383 | define add-jni-shared-libs-to-package |
| 1384 | $(hide) rm -rf $(dir $@)lib |
| 1385 | $(hide) mkdir -p $(dir $@)lib/armeabi |
| 1386 | $(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/armeabi |
| 1387 | $(hide) (cd $(dir $@) && zip -r $(notdir $@) lib) |
| 1388 | $(hide) rm -rf $(dir $@)lib |
| 1389 | endef |
| 1390 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1391 | #TODO: update the manifest to point to the dex file |
| 1392 | define add-dex-to-package |
Doug Zongker | 9e4374b | 2009-10-09 12:11:30 -0700 | [diff] [blame] | 1393 | $(hide) $(AAPT) add -k $@ $(PRIVATE_DEX_FILE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1394 | endef |
| 1395 | |
| 1396 | define add-java-resources-to-package |
| 1397 | $(hide) jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS) |
| 1398 | endef |
| 1399 | |
| 1400 | # Sign a package using the specified key/cert. |
| 1401 | # |
| 1402 | define sign-package |
| 1403 | $(hide) mv $@ $@.unsigned |
| 1404 | $(hide) java -jar $(SIGNAPK_JAR) \ |
| 1405 | $(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) $@.unsigned $@.signed |
| 1406 | $(hide) mv $@.signed $@ |
| 1407 | endef |
| 1408 | |
| 1409 | # Align STORED entries of a package on 4-byte boundaries |
| 1410 | # to make them easier to mmap. |
| 1411 | # |
| 1412 | define align-package |
| 1413 | $(hide) mv $@ $@.unaligned |
| 1414 | $(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned |
| 1415 | $(hide) mv $@.aligned $@ |
| 1416 | endef |
| 1417 | |
| 1418 | define install-dex-debug |
| 1419 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \ |
| 1420 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 1421 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.dex \ |
| 1422 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).dex; \ |
| 1423 | fi |
| 1424 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.lst" ]; then \ |
| 1425 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 1426 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.lst \ |
| 1427 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).lst; \ |
| 1428 | fi |
| 1429 | endef |
| 1430 | |
| 1431 | # TODO(joeo): If we can ever upgrade to post 3.81 make and get the |
| 1432 | # new prebuilt rules to work, we should change this to copy the |
| 1433 | # resources to the out directory and then copy the resources. |
| 1434 | |
| 1435 | # Note: not using aapt tool for this because we aren't making |
| 1436 | # an android package for the host. |
| 1437 | define transform-host-java-to-package |
| 1438 | @echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
| 1439 | @rm -f $@ |
| 1440 | @rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1441 | @mkdir -p $(dir $@) |
| 1442 | @mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1443 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \ |
| 1444 | $(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
| 1445 | $(call dump-words-to-file,$(sort\ |
| 1446 | $(PRIVATE_JAVA_SOURCES)),\ |
Joe Onorato | 483d924 | 2009-06-18 13:11:58 -0700 | [diff] [blame] | 1447 | $(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1448 | $(hide) $(HOST_JAVAC) -encoding ascii -g \ |
| 1449 | $(xlint_unchecked) \ |
| 1450 | $(addprefix -classpath ,$(strip \ |
| 1451 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \ |
| 1452 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR)\ |
Joe Onorato | 483d924 | 2009-06-18 13:11:58 -0700 | [diff] [blame] | 1453 | \@$(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq || \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1454 | ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) |
Joe Onorato | 483d924 | 2009-06-18 13:11:58 -0700 | [diff] [blame] | 1455 | $(hide) rm -f $(PRIVATE_INTERMEDIATES_DIR)/java-source-list |
| 1456 | $(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] | 1457 | $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \ |
| 1458 | $@ $(PRIVATE_JAR_MANIFEST) $(PRIVATE_EXTRA_JAR_ARGS) \ |
| 1459 | -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . |
| 1460 | endef |
| 1461 | |
| 1462 | ########################################################### |
| 1463 | ## Obfuscate a jar file |
| 1464 | ########################################################### |
| 1465 | |
| 1466 | # PRIVATE_KEEP_FILE is a file containing a list of classes |
| 1467 | # PRIVATE_INTERMEDIATES_DIR is a directory we can use for temporary files |
| 1468 | # The module using this must depend on |
| 1469 | # $(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar |
| 1470 | define obfuscate-jar |
| 1471 | @echo "Obfuscate jar: $(notdir $@) ($@)" |
| 1472 | @mkdir -p $(dir $@) |
| 1473 | @rm -f $@ |
| 1474 | @mkdir -p $(PRIVATE_INTERMEDIATES_DIR) |
| 1475 | $(hide) sed -e 's/^/-keep class /' < $(PRIVATE_KEEP_FILE) > \ |
| 1476 | $(PRIVATE_INTERMEDIATES_DIR)/keep.pro |
| 1477 | $(hide) java -Xmx512M -jar $(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar \ |
| 1478 | -injars $< \ |
| 1479 | -outjars $@ \ |
| 1480 | -target 1.5 \ |
| 1481 | -dontnote -dontwarn \ |
| 1482 | -printmapping $(PRIVATE_INTERMEDIATES_DIR)/out.map \ |
| 1483 | -forceprocessing \ |
| 1484 | -renamesourcefileattribute SourceFile \ |
| 1485 | -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod \ |
| 1486 | -repackageclasses \ |
| 1487 | -keepclassmembers "class * { public protected *; }" \ |
| 1488 | @$(PRIVATE_INTERMEDIATES_DIR)/keep.pro |
| 1489 | endef |
| 1490 | |
| 1491 | ########################################################### |
| 1492 | ## Commands for copying files |
| 1493 | ########################################################### |
| 1494 | |
| 1495 | # Define a rule to copy a header. Used via $(eval) by copy_headers.make. |
| 1496 | # $(1): source header |
| 1497 | # $(2): destination header |
| 1498 | define copy-one-header |
| 1499 | $(2): $(1) |
| 1500 | @echo "Header: $$@" |
| 1501 | $$(copy-file-to-new-target-with-cp) |
| 1502 | endef |
| 1503 | |
| 1504 | # Define a rule to copy a file. For use via $(eval). |
| 1505 | # $(1): source file |
| 1506 | # $(2): destination file |
| 1507 | define copy-one-file |
| 1508 | $(2): $(1) | $(ACP) |
| 1509 | @echo "Copy: $$@" |
| 1510 | $$(copy-file-to-target) |
| 1511 | endef |
| 1512 | |
| 1513 | # The -t option to acp and the -p option to cp is |
| 1514 | # required for OSX. OSX has a ridiculous restriction |
| 1515 | # where it's an error for a .a file's modification time |
| 1516 | # to disagree with an internal timestamp, and this |
| 1517 | # macro is used to install .a files (among other things). |
| 1518 | |
| 1519 | # Copy a single file from one place to another, |
| 1520 | # preserving permissions and overwriting any existing |
| 1521 | # file. |
| 1522 | define copy-file-to-target |
| 1523 | @mkdir -p $(dir $@) |
| 1524 | $(hide) $(ACP) -fpt $< $@ |
| 1525 | endef |
| 1526 | |
| 1527 | # The same as copy-file-to-target, but use the local |
| 1528 | # cp command instead of acp. |
| 1529 | define copy-file-to-target-with-cp |
| 1530 | @mkdir -p $(dir $@) |
| 1531 | $(hide) cp -fp $< $@ |
| 1532 | endef |
| 1533 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 1534 | # The same as copy-file-to-target, but use the zipalign tool to do so. |
| 1535 | define copy-file-to-target-with-zipalign |
| 1536 | @mkdir -p $(dir $@) |
| 1537 | $(hide) $(ZIPALIGN) -f 4 $< $@ |
| 1538 | endef |
| 1539 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 1540 | # The same as copy-file-to-target, but strip out "# comment"-style |
| 1541 | # comments (for config files and such). |
| 1542 | define copy-file-to-target-strip-comments |
| 1543 | @mkdir -p $(dir $@) |
| 1544 | $(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@ |
| 1545 | endef |
| 1546 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1547 | # The same as copy-file-to-target, but don't preserve |
| 1548 | # the old modification time. |
| 1549 | define copy-file-to-new-target |
| 1550 | @mkdir -p $(dir $@) |
| 1551 | $(hide) $(ACP) -fp $< $@ |
| 1552 | endef |
| 1553 | |
| 1554 | # The same as copy-file-to-new-target, but use the local |
| 1555 | # cp command instead of acp. |
| 1556 | define copy-file-to-new-target-with-cp |
| 1557 | @mkdir -p $(dir $@) |
| 1558 | $(hide) cp -f $< $@ |
| 1559 | endef |
| 1560 | |
| 1561 | # Copy a prebuilt file to a target location. |
| 1562 | define transform-prebuilt-to-target |
| 1563 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 1564 | $(copy-file-to-target) |
| 1565 | endef |
| 1566 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 1567 | # Copy a prebuilt file to a target location, using zipalign on it. |
| 1568 | define transform-prebuilt-to-target-with-zipalign |
| 1569 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)" |
| 1570 | $(copy-file-to-target-with-zipalign) |
| 1571 | endef |
| 1572 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 1573 | # Copy a prebuilt file to a target location, stripping "# comment" comments. |
| 1574 | define transform-prebuilt-to-target-strip-comments |
| 1575 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 1576 | $(copy-file-to-target-strip-comments) |
| 1577 | endef |
| 1578 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1579 | |
| 1580 | ########################################################### |
| 1581 | ## On some platforms (MacOS), after copying a static |
| 1582 | ## library, ranlib must be run to update an internal |
| 1583 | ## timestamp!?!?! |
| 1584 | ########################################################### |
| 1585 | |
| 1586 | ifeq ($(HOST_RUN_RANLIB_AFTER_COPYING),true) |
| 1587 | define transform-host-ranlib-copy-hack |
| 1588 | $(hide) ranlib $@ || true |
| 1589 | endef |
| 1590 | else |
| 1591 | define transform-host-ranlib-copy-hack |
| 1592 | true |
| 1593 | endef |
| 1594 | endif |
| 1595 | |
| 1596 | ifeq ($(TARGET_RUN_RANLIB_AFTER_COPYING),true) |
| 1597 | define transform-ranlib-copy-hack |
| 1598 | $(hide) ranlib $@ |
| 1599 | endef |
| 1600 | else |
| 1601 | define transform-ranlib-copy-hack |
| 1602 | true |
| 1603 | endef |
| 1604 | endif |
| 1605 | |
| 1606 | |
| 1607 | ########################################################### |
| 1608 | ## Stuff source generated from one-off tools |
| 1609 | ########################################################### |
| 1610 | |
| 1611 | define transform-generated-source |
| 1612 | @echo "target Generated: $(PRIVATE_MODULE) <= $<" |
| 1613 | @mkdir -p $(dir $@) |
| 1614 | $(hide) $(PRIVATE_CUSTOM_TOOL) |
| 1615 | endef |
| 1616 | |
| 1617 | |
| 1618 | ########################################################### |
| 1619 | ## Assertions about attributes of the target |
| 1620 | ########################################################### |
| 1621 | |
| 1622 | # $(1): The file to check |
| 1623 | ifndef get-file-size |
| 1624 | $(error HOST_OS must define get-file-size) |
| 1625 | endif |
| 1626 | |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1627 | # Convert a partition data size (eg, as reported in /proc/mtd) to the |
| 1628 | # size of the image used to flash that partition (which includes a |
| 1629 | # 64-byte spare area for each 2048-byte page). |
| 1630 | # $(1): the partition data size |
| 1631 | define image-size-from-data-size |
| 1632 | $(shell echo $$(($(1) / 2048 * (2048+64)))) |
| 1633 | endef |
| 1634 | |
| 1635 | # $(1): The file(s) to check (often $@) |
| 1636 | # $(2): The maximum total image size, in decimal bytes |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1637 | # $(3): the type of filesystem "yaffs" or "raw" |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1638 | # |
| 1639 | # If $(2) is empty, evaluates to "true" |
| 1640 | # |
| 1641 | # Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks) |
| 1642 | # is left over after the image has been flashed. Round the 1% up to the |
| 1643 | # next whole flash block size. |
| 1644 | define assert-max-file-size |
| 1645 | $(if $(2), \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 1646 | size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \ |
| 1647 | total=$$(( $$( echo "$$size" ) )); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1648 | printname=$$(echo -n "$(1)" | tr " " +); \ |
| 1649 | echo "$$printname total size is $$total"; \ |
| 1650 | img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1651 | if [ "$(3)" == "yaffs" ]; then \ |
Doug Zongker | 93d9ff4 | 2009-09-14 17:46:41 -0700 | [diff] [blame] | 1652 | reservedblocks=8; \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1653 | else \ |
Doug Zongker | 4ac1ba6 | 2009-08-25 20:38:50 -0700 | [diff] [blame] | 1654 | reservedblocks=0; \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1655 | fi; \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1656 | twoblocks=$$((img_blocksize * 2)); \ |
| 1657 | onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1658 | reserve=$$(((twoblocks > onepct ? twoblocks : onepct) + \ |
| 1659 | reservedblocks * img_blocksize)); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1660 | maxsize=$$(($(2) - reserve)); \ |
| 1661 | if [ "$$total" -gt "$$maxsize" ]; then \ |
| 1662 | echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \ |
| 1663 | false; \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 1664 | elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1665 | 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] | 1666 | fi \ |
| 1667 | , \ |
| 1668 | true \ |
| 1669 | ) |
| 1670 | endef |
| 1671 | |
Doug Zongker | 8510a1e | 2009-08-07 16:38:08 -0700 | [diff] [blame] | 1672 | # Like assert-max-file-size, but the second argument is a partition |
| 1673 | # size, which we'll convert to a max image size before checking it |
| 1674 | # against the files. |
| 1675 | # |
| 1676 | # $(1): The file(s) to check (often $@) |
| 1677 | # $(2): The partition size. |
| 1678 | define assert-max-image-size |
| 1679 | $(if $(2), \ |
| 1680 | $(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2))), \ |
| 1681 | true) |
| 1682 | endef |
| 1683 | |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 1684 | |
| 1685 | ########################################################### |
| 1686 | ## Define device-specific radio files |
| 1687 | ########################################################### |
| 1688 | |
| 1689 | # Copy a radio image file to the output location, and add it to |
| 1690 | # INSTALLED_RADIOIMAGE_TARGET. |
| 1691 | # $(1): filename |
| 1692 | define add-radio-file |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame^] | 1693 | $(eval $(call add-radio-file-internal,$(1),$(notdir $(1)))) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 1694 | endef |
| 1695 | define add-radio-file-internal |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame^] | 1696 | INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2) |
| 1697 | ALL_PREBUILT += $$(PRODUCT_OUT)/$(2) |
| 1698 | $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 1699 | $$(transform-prebuilt-to-target) |
| 1700 | endef |
| 1701 | |
| 1702 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1703 | ########################################################### |
| 1704 | ## Other includes |
| 1705 | ########################################################### |
| 1706 | |
| 1707 | # ----------------------------------------------------------------- |
| 1708 | # Rules and functions to help copy important files to DIST_DIR |
| 1709 | # when requested. |
| 1710 | include $(BUILD_SYSTEM)/distdir.mk |
| 1711 | |
| 1712 | |
| 1713 | # broken: |
| 1714 | # $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file))) |
| 1715 | |
| 1716 | ########################################################### |
| 1717 | ## Misc notes |
| 1718 | ########################################################### |
| 1719 | |
| 1720 | #DEPDIR = .deps |
| 1721 | #df = $(DEPDIR)/$(*F) |
| 1722 | |
| 1723 | #SRCS = foo.c bar.c ... |
| 1724 | |
| 1725 | #%.o : %.c |
| 1726 | # @$(MAKEDEPEND); \ |
| 1727 | # cp $(df).d $(df).P; \ |
| 1728 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 1729 | # -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \ |
| 1730 | # rm -f $(df).d |
| 1731 | # $(COMPILE.c) -o $@ $< |
| 1732 | |
| 1733 | #-include $(SRCS:%.c=$(DEPDIR)/%.P) |
| 1734 | |
| 1735 | |
| 1736 | #%.o : %.c |
| 1737 | # $(COMPILE.c) -MD -o $@ $< |
| 1738 | # @cp $*.d $*.P; \ |
| 1739 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 1740 | # -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ |
| 1741 | # rm -f $*.d |