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