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 | |
Iliyan Malchev | b375e71 | 2011-03-08 16:19:48 -0800 | [diff] [blame] | 69 | # The list of dynamic binaries that haven't been stripped/compressed/etc. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | |
Ying Wang | fd626f2 | 2011-12-12 12:57:38 -0800 | [diff] [blame] | 81 | # GPL module license files |
| 82 | ALL_GPL_MODULE_LICENSE_FILES:= |
| 83 | |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 84 | # Target and host installed module's dependencies on shared libraries. |
Ying Wang | d6b1d61 | 2013-04-15 17:32:21 -0700 | [diff] [blame] | 85 | # They are list of "<module_name>:<installed_file>:lib1,lib2...". |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 86 | TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Colin Cross | 5394bf1 | 2014-02-04 19:42:32 -0800 | [diff] [blame] | 87 | 2ND_TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 88 | HOST_DEPENDENCIES_ON_SHARED_LIBRARIES := |
| 89 | |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame] | 90 | # Generated class file names for Android resource. |
| 91 | # They are escaped and quoted so can be passed safely to a bash command. |
| 92 | ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class' |
| 93 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 94 | ########################################################### |
| 95 | ## Debugging; prints a variable list to stdout |
| 96 | ########################################################### |
| 97 | |
| 98 | # $(1): variable name list, not variable values |
| 99 | define print-vars |
| 100 | $(foreach var,$(1), \ |
| 101 | $(info $(var):) \ |
| 102 | $(foreach word,$($(var)), \ |
| 103 | $(info $(space)$(space)$(word)) \ |
| 104 | ) \ |
| 105 | ) |
| 106 | endef |
| 107 | |
| 108 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 109 | ## Evaluates to true if the string contains the word true, |
| 110 | ## and empty otherwise |
| 111 | ## $(1): a var to test |
| 112 | ########################################################### |
| 113 | |
| 114 | define true-or-empty |
| 115 | $(filter true, $(1)) |
| 116 | endef |
| 117 | |
| 118 | |
| 119 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 120 | ## Retrieve the directory of the current makefile |
| 121 | ########################################################### |
| 122 | |
| 123 | # Figure out where we are. |
| 124 | define my-dir |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 125 | $(strip \ |
Ying Wang | 68f1c77 | 2012-04-23 21:29:18 -0700 | [diff] [blame] | 126 | $(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \ |
| 127 | $(if $(filter $(CLEAR_VARS),$(LOCAL_MODULE_MAKEFILE)), \ |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 128 | $(error LOCAL_PATH must be set before including $$(CLEAR_VARS)) \ |
| 129 | , \ |
Ying Wang | 68f1c77 | 2012-04-23 21:29:18 -0700 | [diff] [blame] | 130 | $(patsubst %/,%,$(dir $(LOCAL_MODULE_MAKEFILE))) \ |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 131 | ) \ |
| 132 | ) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 133 | endef |
| 134 | |
| 135 | ########################################################### |
| 136 | ## Retrieve a list of all makefiles immediately below some directory |
| 137 | ########################################################### |
| 138 | |
| 139 | define all-makefiles-under |
| 140 | $(wildcard $(1)/*/Android.mk) |
| 141 | endef |
| 142 | |
| 143 | ########################################################### |
| 144 | ## Look under a directory for makefiles that don't have parent |
| 145 | ## makefiles. |
| 146 | ########################################################### |
| 147 | |
| 148 | # $(1): directory to search under |
| 149 | # Ignores $(1)/Android.mk |
| 150 | define first-makefiles-under |
JP Abgrall | 1390cac | 2013-07-11 19:08:06 -0700 | [diff] [blame] | 151 | $(shell build/tools/findleaves.py --prune=$(OUT_DIR) --prune=.repo --prune=.git \ |
Joe Onorato | dc1a728 | 2009-08-04 15:58:26 -0400 | [diff] [blame] | 152 | --mindepth=2 $(1) Android.mk) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 153 | endef |
| 154 | |
| 155 | ########################################################### |
| 156 | ## Retrieve a list of all makefiles immediately below your directory |
| 157 | ########################################################### |
| 158 | |
| 159 | define all-subdir-makefiles |
| 160 | $(call all-makefiles-under,$(call my-dir)) |
| 161 | endef |
| 162 | |
| 163 | ########################################################### |
| 164 | ## Look in the named list of directories for makefiles, |
| 165 | ## relative to the current directory. |
| 166 | ########################################################### |
| 167 | |
| 168 | # $(1): List of directories to look for under this directory |
| 169 | define all-named-subdir-makefiles |
Chih-Wei Huang | e73c4bb | 2011-01-16 18:31:29 +0800 | [diff] [blame] | 170 | $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 171 | endef |
| 172 | |
| 173 | ########################################################### |
| 174 | ## Find all of the java files under the named directories. |
| 175 | ## Meant to be used like: |
| 176 | ## SRC_FILES := $(call all-java-files-under,src tests) |
| 177 | ########################################################### |
| 178 | |
| 179 | define all-java-files-under |
| 180 | $(patsubst ./%,%, \ |
| 181 | $(shell cd $(LOCAL_PATH) ; \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 182 | find -L $(1) -name "*.java" -and -not -name ".*") \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 183 | ) |
| 184 | endef |
| 185 | |
| 186 | ########################################################### |
| 187 | ## Find all of the java files from here. Meant to be used like: |
| 188 | ## SRC_FILES := $(call all-subdir-java-files) |
| 189 | ########################################################### |
| 190 | |
| 191 | define all-subdir-java-files |
| 192 | $(call all-java-files-under,.) |
| 193 | endef |
| 194 | |
| 195 | ########################################################### |
| 196 | ## Find all of the c files under the named directories. |
| 197 | ## Meant to be used like: |
| 198 | ## SRC_FILES := $(call all-c-files-under,src tests) |
| 199 | ########################################################### |
| 200 | |
| 201 | define all-c-files-under |
| 202 | $(patsubst ./%,%, \ |
| 203 | $(shell cd $(LOCAL_PATH) ; \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 204 | find -L $(1) -name "*.c" -and -not -name ".*") \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 205 | ) |
| 206 | endef |
| 207 | |
| 208 | ########################################################### |
| 209 | ## Find all of the c files from here. Meant to be used like: |
| 210 | ## SRC_FILES := $(call all-subdir-c-files) |
| 211 | ########################################################### |
| 212 | |
| 213 | define all-subdir-c-files |
| 214 | $(call all-c-files-under,.) |
| 215 | endef |
| 216 | |
| 217 | ########################################################### |
| 218 | ## Find all files named "I*.aidl" under the named directories, |
| 219 | ## which must be relative to $(LOCAL_PATH). The returned list |
| 220 | ## is relative to $(LOCAL_PATH). |
| 221 | ########################################################### |
| 222 | |
| 223 | define all-Iaidl-files-under |
| 224 | $(patsubst ./%,%, \ |
| 225 | $(shell cd $(LOCAL_PATH) ; \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 226 | find -L $(1) -name "I*.aidl" -and -not -name ".*") \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 227 | ) |
| 228 | endef |
| 229 | |
| 230 | ########################################################### |
| 231 | ## Find all of the "I*.aidl" files under $(LOCAL_PATH). |
| 232 | ########################################################### |
| 233 | |
| 234 | define all-subdir-Iaidl-files |
| 235 | $(call all-Iaidl-files-under,.) |
| 236 | endef |
| 237 | |
| 238 | ########################################################### |
Bjorn Bringert | a89c990 | 2010-02-02 17:36:20 +0000 | [diff] [blame] | 239 | ## Find all of the logtags files under the named directories. |
| 240 | ## Meant to be used like: |
| 241 | ## SRC_FILES := $(call all-logtags-files-under,src) |
| 242 | ########################################################### |
| 243 | |
| 244 | define all-logtags-files-under |
| 245 | $(patsubst ./%,%, \ |
| 246 | $(shell cd $(LOCAL_PATH) ; \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 247 | find -L $(1) -name "*.logtags" -and -not -name ".*") \ |
Bjorn Bringert | a89c990 | 2010-02-02 17:36:20 +0000 | [diff] [blame] | 248 | ) |
| 249 | endef |
| 250 | |
| 251 | ########################################################### |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 252 | ## Find all of the .proto files under the named directories. |
| 253 | ## Meant to be used like: |
| 254 | ## SRC_FILES := $(call all-proto-files-under,src) |
| 255 | ########################################################### |
| 256 | |
| 257 | define all-proto-files-under |
| 258 | $(patsubst ./%,%, \ |
| 259 | $(shell cd $(LOCAL_PATH) ; \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 260 | find -L $(1) -name "*.proto" -and -not -name ".*") \ |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 261 | ) |
| 262 | endef |
| 263 | |
| 264 | ########################################################### |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 265 | ## Find all of the RenderScript files under the named directories. |
| 266 | ## Meant to be used like: |
| 267 | ## SRC_FILES := $(call all-renderscript-files-under,src) |
| 268 | ########################################################### |
| 269 | |
| 270 | define all-renderscript-files-under |
| 271 | $(patsubst ./%,%, \ |
| 272 | $(shell cd $(LOCAL_PATH) ; \ |
Stephen Hines | d263757 | 2012-10-11 22:08:57 -0700 | [diff] [blame] | 273 | find -L $(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") \ |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 274 | ) |
| 275 | endef |
| 276 | |
| 277 | ########################################################### |
Elliott Hughes | e3b044a | 2014-02-11 13:48:35 -0800 | [diff] [blame] | 278 | ## Find all of the S files under the named directories. |
| 279 | ## Meant to be used like: |
| 280 | ## SRC_FILES := $(call all-c-files-under,src tests) |
| 281 | ########################################################### |
| 282 | |
| 283 | define all-S-files-under |
| 284 | $(patsubst ./%,%, \ |
| 285 | $(shell cd $(LOCAL_PATH) ; \ |
| 286 | find -L $(1) -name "*.S" -and -not -name ".*") \ |
| 287 | ) |
| 288 | endef |
| 289 | |
| 290 | ########################################################### |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 291 | ## Find all of the html files under the named directories. |
| 292 | ## Meant to be used like: |
| 293 | ## SRC_FILES := $(call all-html-files-under,src tests) |
| 294 | ########################################################### |
| 295 | |
| 296 | define all-html-files-under |
| 297 | $(patsubst ./%,%, \ |
| 298 | $(shell cd $(LOCAL_PATH) ; \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 299 | find -L $(1) -name "*.html" -and -not -name ".*") \ |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 300 | ) |
| 301 | endef |
| 302 | |
| 303 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 304 | ## Find all of the html files from here. Meant to be used like: |
| 305 | ## SRC_FILES := $(call all-subdir-html-files) |
| 306 | ########################################################### |
| 307 | |
| 308 | define all-subdir-html-files |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 309 | $(call all-html-files-under,.) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 310 | endef |
| 311 | |
| 312 | ########################################################### |
| 313 | ## Find all of the files matching pattern |
| 314 | ## SRC_FILES := $(call find-subdir-files, <pattern>) |
| 315 | ########################################################### |
| 316 | |
| 317 | define find-subdir-files |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 318 | $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 319 | endef |
| 320 | |
| 321 | ########################################################### |
| 322 | # find the files in the subdirectory $1 of LOCAL_DIR |
| 323 | # matching pattern $2, filtering out files $3 |
| 324 | # e.g. |
| 325 | # SRC_FILES += $(call find-subdir-subdir-files, \ |
| 326 | # css, *.cpp, DontWantThis.cpp) |
| 327 | ########################################################### |
| 328 | |
| 329 | define find-subdir-subdir-files |
| 330 | $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \ |
Conley Owens | f435739 | 2012-10-02 10:32:00 -0700 | [diff] [blame] | 331 | $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 332 | endef |
| 333 | |
| 334 | ########################################################### |
| 335 | ## Find all of the files matching pattern |
| 336 | ## SRC_FILES := $(call all-subdir-java-files) |
| 337 | ########################################################### |
| 338 | |
| 339 | define find-subdir-assets |
| 340 | $(if $(1),$(patsubst ./%,%, \ |
Ying Wang | 6ab5d6a | 2011-08-10 16:05:51 -0700 | [diff] [blame] | 341 | $(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 342 | $(warning Empty argument supplied to find-subdir-assets) \ |
| 343 | ) |
| 344 | endef |
| 345 | |
| 346 | ########################################################### |
| 347 | ## Find various file types in a list of directories relative to $(LOCAL_PATH) |
| 348 | ########################################################### |
| 349 | |
| 350 | define find-other-java-files |
| 351 | $(call find-subdir-files,$(1) -name "*.java" -and -not -name ".*") |
| 352 | endef |
| 353 | |
| 354 | define find-other-html-files |
| 355 | $(call find-subdir-files,$(1) -name "*.html" -and -not -name ".*") |
| 356 | endef |
| 357 | |
| 358 | ########################################################### |
Ying Wang | 7c8c7bd | 2013-12-04 16:04:49 -0800 | [diff] [blame] | 359 | # Use utility find to find given files in the given subdirs. |
| 360 | # This function uses $(1), instead of LOCAL_PATH as the base. |
| 361 | # $(1): the base dir, relative to the root of the source tree. |
| 362 | # $(2): the file name pattern to be passed to find as "-name". |
| 363 | # $(3): a list of subdirs of the base dir. |
| 364 | # Returns: a list of paths relative to the base dir. |
| 365 | ########################################################### |
| 366 | |
| 367 | define find-files-in-subdirs |
| 368 | $(patsubst ./%,%, \ |
| 369 | $(shell cd $(1) ; \ |
| 370 | find -L $(3) -name $(2) -and -not -name ".*") \ |
| 371 | ) |
| 372 | endef |
| 373 | |
| 374 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 375 | ## Scan through each directory of $(1) looking for files |
| 376 | ## that match $(2) using $(wildcard). Useful for seeing if |
| 377 | ## a given directory or one of its parents contains |
| 378 | ## a particular file. Returns the first match found, |
| 379 | ## starting furthest from the root. |
| 380 | ########################################################### |
| 381 | |
| 382 | define find-parent-file |
| 383 | $(strip \ |
Ying Wang | a67ce69 | 2011-03-03 13:29:38 -0800 | [diff] [blame] | 384 | $(eval _fpf := $(wildcard $(foreach f, $(2), $(strip $(1))/$(f)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 385 | $(if $(_fpf),$(_fpf), \ |
| 386 | $(if $(filter-out ./ .,$(1)), \ |
| 387 | $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \ |
| 388 | ) \ |
| 389 | ) \ |
| 390 | ) |
| 391 | endef |
| 392 | |
| 393 | ########################################################### |
| 394 | ## Function we can evaluate to introduce a dynamic dependency |
| 395 | ########################################################### |
| 396 | |
| 397 | define add-dependency |
| 398 | $(1): $(2) |
| 399 | endef |
| 400 | |
| 401 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 402 | ## The intermediates directory. Where object files go for |
| 403 | ## a given target. We could technically get away without |
| 404 | ## the "_intermediates" suffix on the directory, but it's |
| 405 | ## nice to be able to grep for that string to find out if |
| 406 | ## anyone's abusing the system. |
| 407 | ########################################################### |
| 408 | |
| 409 | # $(1): target class, like "APPS" |
| 410 | # $(2): target name, like "NotePad" |
| 411 | # $(3): if non-empty, this is a HOST target. |
| 412 | # $(4): if non-empty, force the intermediates to be COMMON |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 413 | # $(5): if non-empty, force the intermedistes to be for the 2nd arch |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 414 | define intermediates-dir-for |
| 415 | $(strip \ |
| 416 | $(eval _idfClass := $(strip $(1))) \ |
| 417 | $(if $(_idfClass),, \ |
| 418 | $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \ |
| 419 | $(eval _idfName := $(strip $(2))) \ |
| 420 | $(if $(_idfName),, \ |
| 421 | $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \ |
| 422 | $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ |
Colin Cross | 02e31d2 | 2014-01-24 13:38:08 -0800 | [diff] [blame] | 423 | $(eval _idf2ndArchPrefix := $(if $(call directory_is_64_bit_blacklisted,$(LOCAL_PATH))$(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \ |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 424 | $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 425 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \ |
Colin Cross | 02e31d2 | 2014-01-24 13:38:08 -0800 | [diff] [blame] | 426 | ,$(if $(filter $(_idfPrefix)-$(_idfClass),TARGET-SHARED_LIBRARIES TARGET-STATIC_LIBRARIES TARGET-EXECUTABLES),\ |
| 427 | $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \ |
| 428 | ,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \ |
| 429 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 430 | ) \ |
| 431 | $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ |
| 432 | ) |
| 433 | endef |
| 434 | |
| 435 | # Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE |
| 436 | # to determine the intermediates directory. |
| 437 | # |
| 438 | # $(1): if non-empty, force the intermediates to be COMMON |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 439 | # $(2): if non-empty, force the intermediates to be for the 2nd arch |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 440 | define local-intermediates-dir |
| 441 | $(strip \ |
| 442 | $(if $(strip $(LOCAL_MODULE_CLASS)),, \ |
| 443 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \ |
| 444 | $(if $(strip $(LOCAL_MODULE)),, \ |
| 445 | $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 446 | $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1),$(2)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 447 | ) |
| 448 | endef |
| 449 | |
| 450 | ########################################################### |
Colin Cross | d826264 | 2014-01-24 23:17:21 -0800 | [diff] [blame] | 451 | ## The generated sources directory. Placing generated |
| 452 | ## source files directly in the intermediates directory |
| 453 | ## causes problems for multiarch builds, where there are |
| 454 | ## two intermediates directories for a single target. Put |
| 455 | ## them in a separate directory, and they will be copied to |
| 456 | ## each intermediates directory automatically. |
| 457 | ########################################################### |
| 458 | |
| 459 | # $(1): target class, like "APPS" |
| 460 | # $(2): target name, like "NotePad" |
| 461 | # $(3): if non-empty, this is a HOST target. |
| 462 | # $(4): if non-empty, force the generated sources to be COMMON |
| 463 | define generated-sources-dir-for |
| 464 | $(strip \ |
| 465 | $(eval _idfClass := $(strip $(1))) \ |
| 466 | $(if $(_idfClass),, \ |
| 467 | $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \ |
| 468 | $(eval _idfName := $(strip $(2))) \ |
| 469 | $(if $(_idfName),, \ |
| 470 | $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \ |
| 471 | $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ |
| 472 | $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ |
| 473 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN_COMMON)) \ |
| 474 | , \ |
| 475 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN)) \ |
| 476 | ) \ |
| 477 | $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ |
| 478 | ) |
| 479 | endef |
| 480 | |
| 481 | # Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE |
| 482 | # to determine the generated sources directory. |
| 483 | # |
| 484 | # $(1): if non-empty, force the intermediates to be COMMON |
| 485 | define local-generated-sources-dir |
| 486 | $(strip \ |
| 487 | $(if $(strip $(LOCAL_MODULE_CLASS)),, \ |
| 488 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \ |
| 489 | $(if $(strip $(LOCAL_MODULE)),, \ |
| 490 | $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \ |
| 491 | $(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \ |
| 492 | ) |
| 493 | endef |
| 494 | |
| 495 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 496 | ## Convert "path/to/libXXX.so" to "-lXXX". |
| 497 | ## Any "path/to/libXXX.a" elements pass through unchanged. |
| 498 | ########################################################### |
| 499 | |
| 500 | define normalize-libraries |
| 501 | $(foreach so,$(filter %.so,$(1)),-l$(patsubst lib%.so,%,$(notdir $(so))))\ |
| 502 | $(filter-out %.so,$(1)) |
| 503 | endef |
| 504 | |
| 505 | # TODO: change users to call the common version. |
| 506 | define normalize-host-libraries |
| 507 | $(call normalize-libraries,$(1)) |
| 508 | endef |
| 509 | |
| 510 | define normalize-target-libraries |
| 511 | $(call normalize-libraries,$(1)) |
| 512 | endef |
| 513 | |
| 514 | ########################################################### |
| 515 | ## Convert a list of short module names (e.g., "framework", "Browser") |
| 516 | ## into the list of files that are built for those modules. |
| 517 | ## NOTE: this won't return reliable results until after all |
| 518 | ## sub-makefiles have been included. |
| 519 | ## $(1): target list |
| 520 | ########################################################### |
| 521 | |
| 522 | define module-built-files |
| 523 | $(foreach module,$(1),$(ALL_MODULES.$(module).BUILT)) |
| 524 | endef |
| 525 | |
| 526 | ########################################################### |
| 527 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 528 | ## into the list of files that are installed for those modules. |
| 529 | ## NOTE: this won't return reliable results until after all |
| 530 | ## sub-makefiles have been included. |
| 531 | ## $(1): target list |
| 532 | ########################################################### |
| 533 | |
| 534 | define module-installed-files |
| 535 | $(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED)) |
| 536 | endef |
| 537 | |
| 538 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 539 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 540 | ## into the list of files that should be used when linking |
| 541 | ## against that module as a public API. |
| 542 | ## TODO: Allow this for more than JAVA_LIBRARIES modules |
| 543 | ## NOTE: this won't return reliable results until after all |
| 544 | ## sub-makefiles have been included. |
| 545 | ## $(1): target list |
| 546 | ########################################################### |
| 547 | |
| 548 | define module-stubs-files |
| 549 | $(foreach module,$(1),$(ALL_MODULES.$(module).STUBS)) |
| 550 | endef |
| 551 | |
| 552 | ########################################################### |
| 553 | ## Evaluates to the timestamp file for a doc module, which |
| 554 | ## is the dependency that should be used. |
| 555 | ## $(1): doc module |
| 556 | ########################################################### |
| 557 | |
| 558 | define doc-timestamp-for |
| 559 | $(OUT_DOCS)/$(strip $(1))-timestamp |
| 560 | endef |
| 561 | |
| 562 | |
| 563 | ########################################################### |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 564 | ## Convert "core ext framework" to "out/.../javalib.jar ..." |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 565 | ## $(1): library list |
| 566 | ## $(2): Non-empty if IS_HOST_MODULE |
| 567 | ########################################################### |
| 568 | |
| 569 | # $(1): library name |
| 570 | # $(2): Non-empty if IS_HOST_MODULE |
| 571 | define _java-lib-dir |
| 572 | $(call intermediates-dir-for, \ |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 573 | JAVA_LIBRARIES,$(1),$(2),COMMON) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 574 | endef |
| 575 | |
| 576 | # $(1): library name |
| 577 | # $(2): Non-empty if IS_HOST_MODULE |
| 578 | define _java-lib-full-classes.jar |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 579 | $(call _java-lib-dir,$(1),$(2))/classes$(COMMON_JAVA_PACKAGE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 580 | endef |
| 581 | |
| 582 | # $(1): library name list |
| 583 | # $(2): Non-empty if IS_HOST_MODULE |
| 584 | define java-lib-files |
| 585 | $(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2))) |
| 586 | endef |
| 587 | |
| 588 | # $(1): library name |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 589 | # $(2): Non-empty if IS_HOST_MODULE |
| 590 | define _java-lib-full-dep |
Ying Wang | 45150f8 | 2013-02-27 15:23:42 -0800 | [diff] [blame] | 591 | $(call _java-lib-dir,$(1),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 592 | endef |
| 593 | |
| 594 | # $(1): library name list |
| 595 | # $(2): Non-empty if IS_HOST_MODULE |
| 596 | define java-lib-deps |
| 597 | $(foreach lib,$(1),$(call _java-lib-full-dep,$(lib),$(2))) |
| 598 | endef |
| 599 | |
| 600 | ########################################################### |
Joe Onorato | 8dc8faa | 2010-09-14 13:09:48 -0400 | [diff] [blame] | 601 | ## Run rot13 on a string |
| 602 | ## $(1): the string. Must be one line. |
| 603 | ########################################################### |
| 604 | define rot13 |
| 605 | $(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M') |
| 606 | endef |
| 607 | |
| 608 | |
| 609 | ########################################################### |
| 610 | ## Returns true if $(1) and $(2) are equal. Returns |
| 611 | ## the empty string if they are not equal. |
| 612 | ########################################################### |
| 613 | define streq |
| 614 | $(strip $(if $(strip $(1)),\ |
| 615 | $(if $(strip $(2)),\ |
| 616 | $(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \ |
| 617 | ),\ |
| 618 | $(if $(strip $(2)),\ |
| 619 | ,\ |
| 620 | true)\ |
| 621 | )) |
| 622 | endef |
| 623 | |
| 624 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 625 | ## Convert "a b c" into "a:b:c" |
| 626 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 627 | define normalize-path-list |
| 628 | $(subst $(space),:,$(strip $(1))) |
| 629 | endef |
| 630 | |
| 631 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 632 | ## Read the word out of a colon-separated list of words. |
| 633 | ## This has the same behavior as the built-in function |
| 634 | ## $(word n,str). |
| 635 | ## |
| 636 | ## The individual words may not contain spaces. |
| 637 | ## |
| 638 | ## $(1): 1 based index |
| 639 | ## $(2): value of the form a:b:c... |
| 640 | ########################################################### |
| 641 | |
| 642 | define word-colon |
| 643 | $(word $(1),$(subst :,$(space),$(2))) |
| 644 | endef |
| 645 | |
| 646 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 647 | ## Convert "a=b c= d e = f" into "a=b c=d e=f" |
| 648 | ## |
| 649 | ## $(1): list to collapse |
| 650 | ## $(2): if set, separator word; usually "=", ":", or ":=" |
| 651 | ## Defaults to "=" if not set. |
| 652 | ########################################################### |
| 653 | |
| 654 | define collapse-pairs |
| 655 | $(eval _cpSEP := $(strip $(if $(2),$(2),=)))\ |
| 656 | $(subst $(space)$(_cpSEP)$(space),$(_cpSEP),$(strip \ |
| 657 | $(subst $(_cpSEP), $(_cpSEP) ,$(1)))) |
| 658 | endef |
| 659 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 660 | ########################################################### |
Ying Wang | 7e8d442 | 2011-06-17 17:05:35 -0700 | [diff] [blame] | 661 | ## Given a list of pairs, if multiple pairs have the same |
| 662 | ## first components, keep only the first pair. |
| 663 | ## |
| 664 | ## $(1): list of pairs |
| 665 | ## $(2): the separator word, such as ":", "=", etc. |
| 666 | define uniq-pairs-by-first-component |
| 667 | $(eval _upbfc_fc_set :=)\ |
| 668 | $(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\ |
| 669 | $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\ |
| 670 | $(eval _upbfc_fc_set += $(_first)))))\ |
| 671 | $(eval _upbfc_fc_set :=)\ |
| 672 | $(eval _first:=) |
| 673 | endef |
| 674 | |
| 675 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 676 | ## MODULE_TAG set operations |
| 677 | ########################################################### |
| 678 | |
| 679 | # Given a list of tags, return the targets that specify |
| 680 | # any of those tags. |
| 681 | # $(1): tag list |
| 682 | define modules-for-tag-list |
| 683 | $(sort $(foreach tag,$(1),$(ALL_MODULE_TAGS.$(tag)))) |
| 684 | endef |
| 685 | |
| 686 | # Same as modules-for-tag-list, but operates on |
| 687 | # ALL_MODULE_NAME_TAGS. |
| 688 | # $(1): tag list |
| 689 | define module-names-for-tag-list |
| 690 | $(sort $(foreach tag,$(1),$(ALL_MODULE_NAME_TAGS.$(tag)))) |
| 691 | endef |
| 692 | |
| 693 | # Given an accept and reject list, find the matching |
| 694 | # set of targets. If a target has multiple tags and |
| 695 | # any of them are rejected, the target is rejected. |
| 696 | # Reject overrides accept. |
| 697 | # $(1): list of tags to accept |
| 698 | # $(2): list of tags to reject |
| 699 | #TODO(dbort): do $(if $(strip $(1)),$(1),$(ALL_MODULE_TAGS)) |
Jean-Baptiste Queru | 75127b7 | 2010-01-07 11:44:22 -0800 | [diff] [blame] | 700 | #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] | 701 | define get-tagged-modules |
| 702 | $(filter-out \ |
| 703 | $(call modules-for-tag-list,$(2)), \ |
| 704 | $(call modules-for-tag-list,$(1))) |
| 705 | endef |
| 706 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 707 | ########################################################### |
| 708 | ## Append a leaf to a base path. Properly deals with |
| 709 | ## base paths ending in /. |
| 710 | ## |
| 711 | ## $(1): base path |
| 712 | ## $(2): leaf path |
| 713 | ########################################################### |
| 714 | |
| 715 | define append-path |
| 716 | $(subst //,/,$(1)/$(2)) |
| 717 | endef |
| 718 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 719 | |
| 720 | ########################################################### |
| 721 | ## Package filtering |
| 722 | ########################################################### |
| 723 | |
| 724 | # Given a list of installed modules (short or long names) |
| 725 | # return a list of the packages (yes, .apk packages, not |
| 726 | # modules in general) that are overridden by this list and, |
| 727 | # therefore, should not be installed. |
| 728 | # $(1): mixed list of installed modules |
| 729 | # TODO: This is fragile; find a reliable way to get this information. |
| 730 | define _get-package-overrides |
| 731 | $(eval ### Discard any words containing slashes, unless they end in .apk, \ |
| 732 | ### in which case trim off the directory component and the suffix. \ |
| 733 | ### If there are no slashes, keep the entire word.) |
| 734 | $(eval _gpo_names := $(subst /,@@@ @@@,$(1))) |
| 735 | $(eval _gpo_names := \ |
| 736 | $(filter %.apk,$(_gpo_names)) \ |
| 737 | $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 738 | $(eval _gpo_names := $(patsubst %.apk,%,$(_gpo_names))) |
| 739 | $(eval _gpo_names := $(patsubst @@@%,%,$(_gpo_names))) |
| 740 | |
| 741 | $(eval ### Remove any remaining words that contain dots.) |
| 742 | $(eval _gpo_names := $(subst .,@@@ @@@,$(_gpo_names))) |
| 743 | $(eval _gpo_names := $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 744 | |
| 745 | $(eval ### Now we have a list of any words that could possibly refer to \ |
| 746 | ### packages, although there may be words that do not. Only \ |
| 747 | ### real packages will be present under PACKAGES.*, though.) |
| 748 | $(foreach _gpo_name,$(_gpo_names),$(PACKAGES.$(_gpo_name).OVERRIDES)) |
| 749 | endef |
| 750 | |
| 751 | define get-package-overrides |
Conley Owens | d7a1a9b | 2011-12-22 09:46:19 -0800 | [diff] [blame] | 752 | $(sort $(strip $(call _get-package-overrides,$(1)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 753 | endef |
| 754 | |
| 755 | ########################################################### |
| 756 | ## Output the command lines, or not |
| 757 | ########################################################### |
| 758 | |
| 759 | ifeq ($(strip $(SHOW_COMMANDS)),) |
| 760 | define pretty |
| 761 | @echo $1 |
| 762 | endef |
| 763 | hide := @ |
| 764 | else |
| 765 | define pretty |
| 766 | endef |
| 767 | hide := |
| 768 | endif |
| 769 | |
| 770 | ########################################################### |
| 771 | ## Dump the variables that are associated with targets |
| 772 | ########################################################### |
| 773 | |
| 774 | define dump-module-variables |
| 775 | @echo all_dependencies=$^ |
| 776 | @echo PRIVATE_YACCFLAGS=$(PRIVATE_YACCFLAGS); |
| 777 | @echo PRIVATE_CFLAGS=$(PRIVATE_CFLAGS); |
| 778 | @echo PRIVATE_CPPFLAGS=$(PRIVATE_CPPFLAGS); |
| 779 | @echo PRIVATE_DEBUG_CFLAGS=$(PRIVATE_DEBUG_CFLAGS); |
| 780 | @echo PRIVATE_C_INCLUDES=$(PRIVATE_C_INCLUDES); |
| 781 | @echo PRIVATE_LDFLAGS=$(PRIVATE_LDFLAGS); |
| 782 | @echo PRIVATE_LDLIBS=$(PRIVATE_LDLIBS); |
| 783 | @echo PRIVATE_ARFLAGS=$(PRIVATE_ARFLAGS); |
| 784 | @echo PRIVATE_AAPT_FLAGS=$(PRIVATE_AAPT_FLAGS); |
| 785 | @echo PRIVATE_DX_FLAGS=$(PRIVATE_DX_FLAGS); |
Brian Carlstrom | f184a0f | 2010-02-01 11:13:32 -0800 | [diff] [blame] | 786 | @echo PRIVATE_JAVACFLAGS=$(PRIVATE_JAVACFLAGS); |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 787 | @echo PRIVATE_JAVA_LIBRARIES=$(PRIVATE_JAVA_LIBRARIES); |
| 788 | @echo PRIVATE_ALL_SHARED_LIBRARIES=$(PRIVATE_ALL_SHARED_LIBRARIES); |
| 789 | @echo PRIVATE_ALL_STATIC_LIBRARIES=$(PRIVATE_ALL_STATIC_LIBRARIES); |
| 790 | @echo PRIVATE_ALL_WHOLE_STATIC_LIBRARIES=$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES); |
| 791 | @echo PRIVATE_ALL_OBJECTS=$(PRIVATE_ALL_OBJECTS); |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 792 | @echo PRIVATE_NO_CRT=$(PRIVATE_NO_CRT); |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 793 | endef |
| 794 | |
| 795 | ########################################################### |
| 796 | ## Commands for using sed to replace given variable values |
| 797 | ########################################################### |
| 798 | |
| 799 | define transform-variables |
| 800 | @mkdir -p $(dir $@) |
| 801 | @echo "Sed: $(if $(PRIVATE_MODULE),$(PRIVATE_MODULE),$@) <= $<" |
| 802 | $(hide) sed $(foreach var,$(REPLACE_VARS),-e "s/{{$(var)}}/$(subst /,\/,$(PWD)/$($(var)))/g") $< >$@ |
| 803 | $(hide) if [ "$(suffix $@)" = ".sh" ]; then chmod a+rx $@; fi |
| 804 | endef |
| 805 | |
| 806 | |
| 807 | ########################################################### |
| 808 | ## Commands for munging the dependency files GCC generates |
| 809 | ########################################################### |
Ying Wang | c23f4ef | 2012-09-07 17:04:06 -0700 | [diff] [blame] | 810 | # $(1): the input .d file |
| 811 | # $(2): the output .P file |
| 812 | define transform-d-to-p-args |
| 813 | $(hide) cp $(1) $(2); \ |
| 814 | sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 815 | -e '/^$$/ d' -e 's/$$/ :/' < $(1) >> $(2); \ |
| 816 | rm -f $(1) |
| 817 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 818 | |
| 819 | define transform-d-to-p |
Ying Wang | c23f4ef | 2012-09-07 17:04:06 -0700 | [diff] [blame] | 820 | $(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 821 | endef |
| 822 | |
| 823 | ########################################################### |
| 824 | ## Commands for running lex |
| 825 | ########################################################### |
| 826 | |
| 827 | define transform-l-to-cpp |
| 828 | @mkdir -p $(dir $@) |
| 829 | @echo "Lex: $(PRIVATE_MODULE) <= $<" |
| 830 | $(hide) $(LEX) -o$@ $< |
| 831 | endef |
| 832 | |
| 833 | ########################################################### |
| 834 | ## Commands for running yacc |
| 835 | ## |
| 836 | ## Because the extension of c++ files can change, the |
| 837 | ## extension must be specified in $1. |
| 838 | ## E.g, "$(call transform-y-to-cpp,.cpp)" |
| 839 | ########################################################### |
| 840 | |
| 841 | define transform-y-to-cpp |
| 842 | @mkdir -p $(dir $@) |
| 843 | @echo "Yacc: $(PRIVATE_MODULE) <= $<" |
| 844 | $(YACC) $(PRIVATE_YACCFLAGS) -o $@ $< |
| 845 | touch $(@:$1=$(YACC_HEADER_SUFFIX)) |
| 846 | echo '#ifndef '$(@F:$1=_h) > $(@:$1=.h) |
| 847 | echo '#define '$(@F:$1=_h) >> $(@:$1=.h) |
| 848 | cat $(@:$1=$(YACC_HEADER_SUFFIX)) >> $(@:$1=.h) |
| 849 | echo '#endif' >> $(@:$1=.h) |
| 850 | rm -f $(@:$1=$(YACC_HEADER_SUFFIX)) |
| 851 | endef |
| 852 | |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 853 | ########################################################### |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 854 | ## Commands to compile RenderScript to Java |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 855 | ########################################################### |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 856 | |
| 857 | define transform-renderscripts-to-java-and-bc |
| 858 | @echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)" |
| 859 | $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR) |
| 860 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw |
| 861 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src |
Ying Wang | 7d83ef8 | 2011-05-25 17:16:22 -0700 | [diff] [blame] | 862 | $(hide) $(PRIVATE_RS_CC) \ |
Ying Wang | ebfddaa | 2010-07-30 18:37:29 -0700 | [diff] [blame] | 863 | -o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \ |
| 864 | -p $(PRIVATE_RS_OUTPUT_DIR)/src \ |
Ying Wang | 24e1c01 | 2010-10-07 18:57:57 -0700 | [diff] [blame] | 865 | -d $(PRIVATE_RS_OUTPUT_DIR) \ |
| 866 | -a $@ -MD \ |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 867 | $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \ |
Stephen Hines | 914f7a2 | 2011-12-06 18:43:24 -0800 | [diff] [blame] | 868 | $(PRIVATE_RS_FLAGS) \ |
Ying Wang | 5128027 | 2010-09-01 13:28:52 -0700 | [diff] [blame] | 869 | $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \ |
Ying Wang | ebfddaa | 2010-07-30 18:37:29 -0700 | [diff] [blame] | 870 | $(PRIVATE_RS_SOURCE_FILES) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 871 | $(hide) mkdir -p $(dir $@) |
| 872 | $(hide) touch $@ |
| 873 | endef |
| 874 | |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 875 | define transform-bc-to-so |
Stephen Hines | 9ac9b53 | 2013-02-27 00:51:08 -0800 | [diff] [blame] | 876 | @echo "Renderscript compatibility: $(notdir $@) <= $(notdir $<)" |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 877 | $(hide) mkdir -p $(dir $@) |
Stephen Hines | f692513 | 2012-12-17 14:23:14 -0800 | [diff] [blame] | 878 | $(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \ |
Tim Murray | 1a6f09a | 2013-03-05 11:07:15 -0800 | [diff] [blame] | 879 | -rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_TRIPLE) $< |
Stephen Hines | 7d6ec71 | 2012-12-13 19:24:50 -0800 | [diff] [blame] | 880 | $(hide) $(PRIVATE_CXX) -shared -Wl,-soname,$(notdir $@) -nostdlib \ |
Stephen Hines | f692513 | 2012-12-17 14:23:14 -0800 | [diff] [blame] | 881 | -Wl,-rpath,\$$ORIGIN/../lib \ |
Stephen Hines | 9541f58 | 2013-01-18 16:27:23 -0800 | [diff] [blame] | 882 | $(dir $@)/$(notdir $(<:.bc=.o)) \ |
Tim Murray | 1a6f09a | 2013-03-05 11:07:15 -0800 | [diff] [blame] | 883 | $(RS_PREBUILT_COMPILER_RT) \ |
Stephen Hines | 9541f58 | 2013-01-18 16:27:23 -0800 | [diff] [blame] | 884 | -o $@ -L prebuilts/gcc/ \ |
Tim Murray | 1a6f09a | 2013-03-05 11:07:15 -0800 | [diff] [blame] | 885 | -L $(TARGET_OUT_INTERMEDIATE_LIBRARIES) $(RS_PREBUILT_LIBPATH) \ |
Stephen Hines | 8db4cce | 2013-03-27 16:51:38 -0700 | [diff] [blame] | 886 | -lRSSupport -lm -lc |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 887 | endef |
| 888 | |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 889 | ########################################################### |
| 890 | ## Commands to compile RenderScript to C++ |
| 891 | ########################################################### |
| 892 | |
| 893 | define transform-renderscripts-to-cpp-and-bc |
| 894 | @echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)" |
| 895 | $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR) |
| 896 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/ |
| 897 | $(hide) $(PRIVATE_RS_CC) \ |
| 898 | -o $(PRIVATE_RS_OUTPUT_DIR)/ \ |
| 899 | -d $(PRIVATE_RS_OUTPUT_DIR) \ |
| 900 | -a $@ -MD \ |
| 901 | -reflect-c++ \ |
| 902 | $(PRIVATE_RS_FLAGS) \ |
| 903 | $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \ |
| 904 | $(PRIVATE_RS_SOURCE_FILES) |
| 905 | $(hide) mkdir -p $(dir $@) |
| 906 | $(hide) touch $@ |
| 907 | endef |
| 908 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 909 | |
| 910 | ########################################################### |
| 911 | ## Commands for running aidl |
| 912 | ########################################################### |
| 913 | |
| 914 | define transform-aidl-to-java |
| 915 | @mkdir -p $(dir $@) |
| 916 | @echo "Aidl: $(PRIVATE_MODULE) <= $<" |
| 917 | $(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@ |
| 918 | endef |
| 919 | #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@ |
| 920 | |
| 921 | |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 922 | ########################################################### |
| 923 | ## Commands for running java-event-log-tags.py |
| 924 | ########################################################### |
| 925 | |
| 926 | define transform-logtags-to-java |
| 927 | @mkdir -p $(dir $@) |
| 928 | @echo "logtags: $@ <= $<" |
Doug Zongker | abfbbe2 | 2010-02-16 14:32:08 -0800 | [diff] [blame] | 929 | $(hide) $(JAVATAGS) -o $@ $^ |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 930 | endef |
| 931 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 932 | |
| 933 | ########################################################### |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 934 | ## Commands for running protoc to compile .proto into .java |
| 935 | ########################################################### |
| 936 | |
| 937 | define transform-proto-to-java |
| 938 | @mkdir -p $(dir $@) |
| 939 | @echo "Protoc: $@ <= $(PRIVATE_PROTO_SRC_FILES)" |
| 940 | @rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) |
| 941 | @mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) |
Ben Murdoch | fc2bad5 | 2013-07-25 11:44:53 +0100 | [diff] [blame] | 942 | $(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \ |
| 943 | $(PROTOC) \ |
Ulas Kirazci | 28b46fc | 2013-07-24 14:32:14 -0700 | [diff] [blame] | 944 | $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \ |
Ulas Kirazci | 6e485b5 | 2013-07-25 12:28:19 -0700 | [diff] [blame] | 945 | $(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \ |
Ben Murdoch | fc2bad5 | 2013-07-25 11:44:53 +0100 | [diff] [blame] | 946 | $(PRIVATE_PROTOC_FLAGS) \ |
| 947 | $$f || exit 33; \ |
| 948 | done |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 949 | $(hide) touch $@ |
| 950 | endef |
| 951 | |
| 952 | ###################################################################### |
| 953 | ## Commands for running protoc to compile .proto into .pb.cc and .pb.h |
| 954 | ###################################################################### |
| 955 | define transform-proto-to-cc |
| 956 | @mkdir -p $(dir $@) |
| 957 | @echo "Protoc: $@ <= $<" |
| 958 | $(hide) $(PROTOC) \ |
| 959 | $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \ |
Ying Wang | 33c0d95 | 2010-11-05 11:30:58 -0700 | [diff] [blame] | 960 | $(PRIVATE_PROTOC_FLAGS) \ |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 961 | --cpp_out=$(PRIVATE_PROTO_CC_OUTPUT_DIR) $< |
| 962 | endef |
| 963 | |
| 964 | |
| 965 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 966 | ## Commands for running gcc to compile a C++ file |
| 967 | ########################################################### |
| 968 | |
| 969 | define transform-cpp-to-o |
| 970 | @mkdir -p $(dir $@) |
| 971 | @echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<" |
| 972 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 973 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 974 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 975 | $(addprefix -isystem ,\ |
| 976 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 977 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 978 | $(PRIVATE_TARGET_PROJECT_INCLUDES) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 979 | $(PRIVATE_TARGET_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 980 | -c \ |
| 981 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 982 | $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ |
| 983 | $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 984 | $(PRIVATE_ARM_CFLAGS) \ |
| 985 | ) \ |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 986 | $(PRIVATE_RTTI_FLAG) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 987 | $(PRIVATE_CFLAGS) \ |
| 988 | $(PRIVATE_CPPFLAGS) \ |
| 989 | $(PRIVATE_DEBUG_CFLAGS) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 990 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 991 | $(transform-d-to-p) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 992 | endef |
| 993 | |
| 994 | |
| 995 | ########################################################### |
| 996 | ## Commands for running gcc to compile a C file |
| 997 | ########################################################### |
| 998 | |
| 999 | # $(1): extra flags |
| 1000 | define transform-c-or-s-to-o-no-deps |
| 1001 | @mkdir -p $(dir $@) |
| 1002 | $(hide) $(PRIVATE_CC) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1003 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1004 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 1005 | $(addprefix -isystem ,\ |
| 1006 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1007 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1008 | $(PRIVATE_TARGET_PROJECT_INCLUDES) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 1009 | $(PRIVATE_TARGET_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1010 | -c \ |
| 1011 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1012 | $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1013 | $(PRIVATE_ARM_CFLAGS) \ |
| 1014 | ) \ |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 1015 | $(1) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1016 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1017 | endef |
| 1018 | |
| 1019 | define transform-c-to-o-no-deps |
| 1020 | @echo "target $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 7429e21 | 2012-08-15 10:59:10 -0700 | [diff] [blame] | 1021 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1022 | endef |
| 1023 | |
| 1024 | define transform-s-to-o-no-deps |
| 1025 | @echo "target asm: $(PRIVATE_MODULE) <= $<" |
| 1026 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 1027 | endef |
| 1028 | |
| 1029 | define transform-c-to-o |
| 1030 | $(transform-c-to-o-no-deps) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1031 | $(transform-d-to-p) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1032 | endef |
| 1033 | |
| 1034 | define transform-s-to-o |
| 1035 | $(transform-s-to-o-no-deps) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1036 | $(transform-d-to-p) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1037 | endef |
| 1038 | |
| 1039 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1040 | ## Commands for running gcc to compile an Objective-C file |
| 1041 | ## This should never happen for target builds but this |
| 1042 | ## will error at build time. |
| 1043 | ########################################################### |
| 1044 | |
| 1045 | define transform-m-to-o-no-deps |
| 1046 | @echo "target ObjC: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 1047 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1048 | endef |
| 1049 | |
| 1050 | define transform-m-to-o |
| 1051 | $(transform-m-to-o-no-deps) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1052 | $(transform-d-to-p) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1053 | endef |
| 1054 | |
| 1055 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1056 | ## Commands for running gcc to compile a host C++ file |
| 1057 | ########################################################### |
| 1058 | |
| 1059 | define transform-host-cpp-to-o |
| 1060 | @mkdir -p $(dir $@) |
| 1061 | @echo "host C++: $(PRIVATE_MODULE) <= $<" |
| 1062 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1063 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1064 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1065 | $(addprefix -isystem ,\ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1066 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1067 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
| 1068 | $(HOST_PROJECT_INCLUDES) \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1069 | $(PRIVATE_HOST_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1070 | -c \ |
| 1071 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1072 | $(PRIVATE_HOST_GLOBAL_CFLAGS) \ |
| 1073 | $(PRIVATE_HOST_GLOBAL_CPPFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1074 | ) \ |
| 1075 | $(PRIVATE_CFLAGS) \ |
| 1076 | $(PRIVATE_CPPFLAGS) \ |
| 1077 | $(PRIVATE_DEBUG_CFLAGS) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1078 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1079 | $(transform-d-to-p) |
| 1080 | endef |
| 1081 | |
| 1082 | |
| 1083 | ########################################################### |
| 1084 | ## Commands for running gcc to compile a host C file |
| 1085 | ########################################################### |
| 1086 | |
| 1087 | # $(1): extra flags |
| 1088 | define transform-host-c-or-s-to-o-no-deps |
| 1089 | @mkdir -p $(dir $@) |
| 1090 | $(hide) $(PRIVATE_CC) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1091 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1092 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1093 | $(addprefix -isystem ,\ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1094 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1095 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
| 1096 | $(HOST_PROJECT_INCLUDES) \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1097 | $(PRIVATE_HOST_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1098 | -c \ |
| 1099 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1100 | $(PRIVATE_HOST_GLOBAL_CFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1101 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1102 | $(1) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1103 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1104 | endef |
| 1105 | |
| 1106 | define transform-host-c-to-o-no-deps |
| 1107 | @echo "host C: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 7429e21 | 2012-08-15 10:59:10 -0700 | [diff] [blame] | 1108 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1109 | endef |
| 1110 | |
| 1111 | define transform-host-s-to-o-no-deps |
| 1112 | @echo "host asm: $(PRIVATE_MODULE) <= $<" |
| 1113 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 1114 | endef |
| 1115 | |
| 1116 | define transform-host-c-to-o |
| 1117 | $(transform-host-c-to-o-no-deps) |
| 1118 | $(transform-d-to-p) |
| 1119 | endef |
| 1120 | |
| 1121 | define transform-host-s-to-o |
| 1122 | $(transform-host-s-to-o-no-deps) |
| 1123 | $(transform-d-to-p) |
| 1124 | endef |
| 1125 | |
| 1126 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1127 | ## Commands for running gcc to compile a host Objective-C file |
| 1128 | ########################################################### |
| 1129 | |
| 1130 | define transform-host-m-to-o-no-deps |
| 1131 | @echo "host ObjC: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 1132 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1133 | endef |
| 1134 | |
David 'Digit' Turner | 5ca286d | 2011-02-11 16:19:31 +0100 | [diff] [blame] | 1135 | define transform-host-m-to-o |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1136 | $(transform-host-m-to-o-no-deps) |
| 1137 | $(transform-d-to-p) |
| 1138 | endef |
| 1139 | |
| 1140 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1141 | ## Commands for running ar |
| 1142 | ########################################################### |
| 1143 | |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1144 | define _concat-if-arg2-not-empty |
| 1145 | $(if $(2),$(hide) $(1) $(2)) |
| 1146 | endef |
| 1147 | |
| 1148 | # Split long argument list into smaller groups and call the command repeatedly |
Torne (Richard Coles) | bffaef2 | 2012-06-15 16:03:52 +0100 | [diff] [blame] | 1149 | # Call the command at least once even if there are no arguments, as otherwise |
| 1150 | # the output file won't be created. |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1151 | # |
| 1152 | # $(1): the command without arguments |
| 1153 | # $(2): the arguments |
| 1154 | define split-long-arguments |
Torne (Richard Coles) | bffaef2 | 2012-06-15 16:03:52 +0100 | [diff] [blame] | 1155 | $(hide) $(1) $(wordlist 1,500,$(2)) |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1156 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2))) |
| 1157 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2))) |
| 1158 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2))) |
| 1159 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2))) |
| 1160 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2))) |
| 1161 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2))) |
| 1162 | endef |
| 1163 | |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1164 | # $(1): the full path of the source static library. |
| 1165 | define _extract-and-include-single-target-whole-static-lib |
| 1166 | @echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]" |
| 1167 | $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ |
| 1168 | rm -rf $$ldir; \ |
| 1169 | mkdir -p $$ldir; \ |
| 1170 | filelist=; \ |
| 1171 | for f in `$(TARGET_AR) t $(1)`; do \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1172 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $(1) $$f > $$ldir/$$f; \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1173 | filelist="$$filelist $$ldir/$$f"; \ |
| 1174 | done ; \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1175 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \ |
| 1176 | $(PRIVATE_ARFLAGS) $@ $$filelist |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1177 | |
| 1178 | endef |
| 1179 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1180 | define extract-and-include-target-whole-static-libs |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1181 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1182 | $(call _extract-and-include-single-target-whole-static-lib, $(lib))) |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1183 | endef |
| 1184 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1185 | # Explicitly delete the archive first so that ar doesn't |
| 1186 | # try to add to an existing archive. |
| 1187 | define transform-o-to-static-lib |
| 1188 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1189 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1190 | $(extract-and-include-target-whole-static-libs) |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1191 | @echo "target StaticLib: $(PRIVATE_MODULE) ($@)" |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1192 | $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \ |
| 1193 | $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1194 | endef |
| 1195 | |
| 1196 | ########################################################### |
| 1197 | ## Commands for running host ar |
| 1198 | ########################################################### |
| 1199 | |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1200 | # $(1): the full path of the source static library. |
| 1201 | define _extract-and-include-single-host-whole-static-lib |
| 1202 | @echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]" |
| 1203 | $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ |
| 1204 | rm -rf $$ldir; \ |
| 1205 | mkdir -p $$ldir; \ |
| 1206 | filelist=; \ |
Jeff Hamilton | 293f939 | 2011-11-18 17:15:25 -0600 | [diff] [blame] | 1207 | for f in `$(HOST_AR) t $(1) | \grep '\.o$$'`; do \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1208 | $(HOST_AR) p $(1) $$f > $$ldir/$$f; \ |
| 1209 | filelist="$$filelist $$ldir/$$f"; \ |
| 1210 | done ; \ |
| 1211 | $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist |
| 1212 | |
| 1213 | endef |
| 1214 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1215 | define extract-and-include-host-whole-static-libs |
| 1216 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1217 | $(call _extract-and-include-single-host-whole-static-lib, $(lib))) |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1218 | endef |
| 1219 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1220 | # Explicitly delete the archive first so that ar doesn't |
| 1221 | # try to add to an existing archive. |
| 1222 | define transform-host-o-to-static-lib |
| 1223 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1224 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1225 | $(extract-and-include-host-whole-static-libs) |
Dan Bornstein | 6bffc91 | 2009-10-15 13:01:36 -0700 | [diff] [blame] | 1226 | @echo "host StaticLib: $(PRIVATE_MODULE) ($@)" |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1227 | $(call split-long-arguments,$(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1228 | endef |
| 1229 | |
| 1230 | |
| 1231 | ########################################################### |
| 1232 | ## Commands for running gcc to link a shared library or package |
| 1233 | ########################################################### |
| 1234 | |
| 1235 | # ld just seems to be so finicky with command order that we allow |
| 1236 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1237 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1238 | define transform-host-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1239 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 1240 | -Wl,-rpath-link=$(HOST_OUT_INTERMEDIATE_LIBRARIES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1241 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1242 | -shared -Wl,-soname,$(notdir $@) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1243 | $(HOST_GLOBAL_LD_DIRS) \ |
| 1244 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1245 | $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1246 | ) \ |
Torne (Richard Coles) | db7dcc2 | 2014-02-12 14:24:41 +0000 | [diff] [blame] | 1247 | $(PRIVATE_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1248 | $(PRIVATE_ALL_OBJECTS) \ |
| 1249 | -Wl,--whole-archive \ |
| 1250 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1251 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1252 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1253 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1254 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1255 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1256 | -o $@ \ |
| 1257 | $(PRIVATE_LDLIBS) |
| 1258 | endef |
| 1259 | endif |
| 1260 | |
| 1261 | define transform-host-o-to-shared-lib |
| 1262 | @mkdir -p $(dir $@) |
| 1263 | @echo "host SharedLib: $(PRIVATE_MODULE) ($@)" |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1264 | $(transform-host-o-to-shared-lib-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1265 | endef |
| 1266 | |
| 1267 | define transform-host-o-to-package |
| 1268 | @mkdir -p $(dir $@) |
| 1269 | @echo "host Package: $(PRIVATE_MODULE) ($@)" |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1270 | $(transform-host-o-to-shared-lib-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1271 | endef |
| 1272 | |
| 1273 | |
| 1274 | ########################################################### |
| 1275 | ## Commands for running gcc to link a shared library or package |
| 1276 | ########################################################### |
| 1277 | |
| 1278 | #echo >$@.vers "{"; \ |
| 1279 | #echo >>$@.vers " global:"; \ |
| 1280 | #$(BUILD_SYSTEM)/filter_symbols.sh $(TARGET_NM) " " ";" $(filter %.o,$^) | sort -u >>$@.vers; \ |
| 1281 | #echo >>$@.vers " local:"; \ |
| 1282 | #echo >>$@.vers " *;"; \ |
| 1283 | #echo >>$@.vers "};"; \ |
| 1284 | |
| 1285 | # -Wl,--version-script=$@.vers \ |
| 1286 | |
| 1287 | # ld just seems to be so finicky with command order that we allow |
| 1288 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1289 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1290 | define transform-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1291 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1292 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
Ying Wang | 9fb3526 | 2014-02-21 16:17:05 -0800 | [diff] [blame] | 1293 | -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1294 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1295 | -shared -Wl,-soname,$(notdir $@) \ |
| 1296 | $(PRIVATE_LDFLAGS) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1297 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1298 | $(PRIVATE_ALL_OBJECTS) \ |
| 1299 | -Wl,--whole-archive \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 1300 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1301 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1302 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1303 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1304 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1305 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1306 | -o $@ \ |
| 1307 | $(PRIVATE_LDLIBS) |
| 1308 | endef |
| 1309 | endif |
| 1310 | |
| 1311 | define transform-o-to-shared-lib |
| 1312 | @mkdir -p $(dir $@) |
| 1313 | @echo "target SharedLib: $(PRIVATE_MODULE) ($@)" |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 1314 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)transform-o-to-shared-lib-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1315 | endef |
| 1316 | |
| 1317 | |
| 1318 | ########################################################### |
| 1319 | ## Commands for filtering a target executable or library |
| 1320 | ########################################################### |
| 1321 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1322 | define transform-to-stripped |
| 1323 | @mkdir -p $(dir $@) |
| 1324 | @echo "target Strip: $(PRIVATE_MODULE) ($@)" |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 1325 | $(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_COMMAND) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1326 | endef |
| 1327 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1328 | |
| 1329 | ########################################################### |
| 1330 | ## Commands for running gcc to link an executable |
| 1331 | ########################################################### |
| 1332 | |
| 1333 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1334 | define transform-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1335 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | c6ffc00 | 2012-09-25 17:52:10 -0700 | [diff] [blame] | 1336 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
| 1337 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Ying Wang | 9fb3526 | 2014-02-21 16:17:05 -0800 | [diff] [blame] | 1338 | -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1339 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1340 | $(PRIVATE_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1341 | $(PRIVATE_ALL_OBJECTS) \ |
| 1342 | -Wl,--whole-archive \ |
| 1343 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1344 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1345 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1346 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1347 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1348 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1349 | -o $@ \ |
| 1350 | $(PRIVATE_LDLIBS) |
| 1351 | endef |
| 1352 | endif |
| 1353 | |
| 1354 | define transform-o-to-executable |
| 1355 | @mkdir -p $(dir $@) |
| 1356 | @echo "target Executable: $(PRIVATE_MODULE) ($@)" |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 1357 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)transform-o-to-executable-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1358 | endef |
| 1359 | |
| 1360 | |
| 1361 | ########################################################### |
| 1362 | ## Commands for running gcc to link a statically linked |
| 1363 | ## executable. In practice, we only use this on arm, so |
| 1364 | ## the other platforms don't have the |
| 1365 | ## transform-o-to-static-executable defined |
| 1366 | ########################################################### |
| 1367 | |
| 1368 | ifneq ($(TARGET_CUSTOM_LD_COMMAND),true) |
| 1369 | define transform-o-to-static-executable-inner |
| 1370 | endef |
| 1371 | endif |
| 1372 | |
| 1373 | define transform-o-to-static-executable |
| 1374 | @mkdir -p $(dir $@) |
| 1375 | @echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)" |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 1376 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)transform-o-to-static-executable-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1377 | endef |
| 1378 | |
| 1379 | |
| 1380 | ########################################################### |
| 1381 | ## Commands for running gcc to link a host executable |
| 1382 | ########################################################### |
| 1383 | |
| 1384 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1385 | define transform-host-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1386 | $(hide) $(PRIVATE_CXX) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1387 | $(PRIVATE_ALL_OBJECTS) \ |
| 1388 | -Wl,--whole-archive \ |
| 1389 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1390 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1391 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1392 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1393 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1394 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Conley Owens | d9e7d25 | 2011-11-10 09:57:40 -0800 | [diff] [blame] | 1395 | -Wl,-rpath-link=$(HOST_OUT_INTERMEDIATE_LIBRARIES) \ |
| 1396 | -Wl,-rpath,\$$ORIGIN/../lib \ |
| 1397 | $(HOST_GLOBAL_LD_DIRS) \ |
Conley Owens | d9e7d25 | 2011-11-10 09:57:40 -0800 | [diff] [blame] | 1398 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1399 | $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ |
Joshua J. Drake | b0eafa2 | 2013-12-12 00:34:29 -0600 | [diff] [blame] | 1400 | -fPIE -pie \ |
Conley Owens | d9e7d25 | 2011-11-10 09:57:40 -0800 | [diff] [blame] | 1401 | ) \ |
Torne (Richard Coles) | db7dcc2 | 2014-02-12 14:24:41 +0000 | [diff] [blame] | 1402 | $(PRIVATE_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1403 | -o $@ \ |
| 1404 | $(PRIVATE_LDLIBS) |
| 1405 | endef |
| 1406 | endif |
| 1407 | |
| 1408 | define transform-host-o-to-executable |
| 1409 | @mkdir -p $(dir $@) |
| 1410 | @echo "host Executable: $(PRIVATE_MODULE) ($@)" |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1411 | $(transform-host-o-to-executable-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1412 | endef |
| 1413 | |
| 1414 | |
| 1415 | ########################################################### |
| 1416 | ## Commands for running javac to make .class files |
| 1417 | ########################################################### |
| 1418 | |
| 1419 | #@echo "Source intermediates dir: $(PRIVATE_SOURCE_INTERMEDIATES_DIR)" |
| 1420 | #@echo "Source intermediates: $$(find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java')" |
| 1421 | |
| 1422 | # TODO: Right now we generate the asset resources twice, first as part |
| 1423 | # of generating the Java classes, then at the end when packaging the final |
| 1424 | # assets. This should be changed to do one of two things: (1) Don't generate |
| 1425 | # any resource files the first time, only create classes during that stage; |
| 1426 | # or (2) Don't use the -c flag with the second stage, instead taking the |
| 1427 | # resource files from the first stage as additional input. My original intent |
| 1428 | # was to use approach (2), but this requires a little more work in the tool. |
| 1429 | # Maybe we should just use approach (1). |
| 1430 | |
| 1431 | # This rule creates the R.java and Manifest.java files, both of which |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 1432 | # are PRODUCT-neutral. Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1433 | define create-resource-java-files |
| 1434 | @mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR) |
| 1435 | @mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 1436 | $(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \ |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 1437 | $(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1438 | $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ |
| 1439 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1440 | $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \ |
| 1441 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1442 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1443 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 1444 | $(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 1445 | $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
| 1446 | $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
Ying Wang | 1ae607a | 2010-06-23 13:34:22 -0700 | [diff] [blame] | 1447 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \ |
Ying Wang | 8f5069b | 2010-06-29 11:08:13 -0700 | [diff] [blame] | 1448 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \ |
Ying Wang | 8c25482 | 2010-03-16 16:13:56 -0700 | [diff] [blame] | 1449 | $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1450 | $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1451 | endef |
| 1452 | |
| 1453 | ifeq ($(HOST_OS),windows) |
| 1454 | xlint_unchecked := |
| 1455 | else |
Jeffrey Chyan | 7adbf97 | 2010-07-07 13:42:19 -0500 | [diff] [blame] | 1456 | xlint_unchecked := -Xlint:unchecked |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1457 | endif |
| 1458 | |
Brian Carlstrom | bb7c6d8 | 2011-04-01 15:45:58 -0700 | [diff] [blame] | 1459 | ifeq (true, $(ENABLE_INCREMENTALJAVAC)) |
| 1460 | incremental_dex := --incremental |
| 1461 | else |
| 1462 | incremental_dex := |
| 1463 | endif |
| 1464 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1465 | # emit-line, <word list>, <output file> |
| 1466 | define emit-line |
| 1467 | $(if $(1),echo -n '$(strip $(1)) ' >> $(2)) |
| 1468 | endef |
| 1469 | |
| 1470 | # dump-words-to-file, <word list>, <output file> |
| 1471 | define dump-words-to-file |
| 1472 | @rm -f $(2) |
| 1473 | @$(call emit-line,$(wordlist 1,200,$(1)),$(2)) |
| 1474 | @$(call emit-line,$(wordlist 201,400,$(1)),$(2)) |
| 1475 | @$(call emit-line,$(wordlist 401,600,$(1)),$(2)) |
| 1476 | @$(call emit-line,$(wordlist 601,800,$(1)),$(2)) |
| 1477 | @$(call emit-line,$(wordlist 801,1000,$(1)),$(2)) |
| 1478 | @$(call emit-line,$(wordlist 1001,1200,$(1)),$(2)) |
| 1479 | @$(call emit-line,$(wordlist 1201,1400,$(1)),$(2)) |
| 1480 | @$(call emit-line,$(wordlist 1401,1600,$(1)),$(2)) |
| 1481 | @$(call emit-line,$(wordlist 1601,1800,$(1)),$(2)) |
| 1482 | @$(call emit-line,$(wordlist 1801,2000,$(1)),$(2)) |
| 1483 | @$(call emit-line,$(wordlist 2001,2200,$(1)),$(2)) |
| 1484 | @$(call emit-line,$(wordlist 2201,2400,$(1)),$(2)) |
| 1485 | @$(call emit-line,$(wordlist 2401,2600,$(1)),$(2)) |
| 1486 | @$(call emit-line,$(wordlist 2601,2800,$(1)),$(2)) |
| 1487 | @$(call emit-line,$(wordlist 2801,3000,$(1)),$(2)) |
| 1488 | @$(call emit-line,$(wordlist 3001,3200,$(1)),$(2)) |
| 1489 | @$(call emit-line,$(wordlist 3201,3400,$(1)),$(2)) |
| 1490 | @$(call emit-line,$(wordlist 3401,3600,$(1)),$(2)) |
| 1491 | @$(call emit-line,$(wordlist 3601,3800,$(1)),$(2)) |
| 1492 | @$(call emit-line,$(wordlist 3801,4000,$(1)),$(2)) |
Jesse Wilson | 72c941a | 2010-05-04 16:33:49 -0700 | [diff] [blame] | 1493 | @$(call emit-line,$(wordlist 4001,4200,$(1)),$(2)) |
| 1494 | @$(call emit-line,$(wordlist 4201,4400,$(1)),$(2)) |
| 1495 | @$(call emit-line,$(wordlist 4401,4600,$(1)),$(2)) |
| 1496 | @$(call emit-line,$(wordlist 4601,4800,$(1)),$(2)) |
| 1497 | @$(call emit-line,$(wordlist 4801,5000,$(1)),$(2)) |
| 1498 | @$(if $(wordlist 5001,5002,$(1)),$(error Too many words ($(words $(1))))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1499 | endef |
| 1500 | |
| 1501 | # For a list of jar files, unzip them to a specified directory, |
| 1502 | # but make sure that no META-INF files come along for the ride. |
| 1503 | # |
| 1504 | # $(1): files to unzip |
| 1505 | # $(2): destination directory |
| 1506 | define unzip-jar-files |
| 1507 | $(hide) for f in $(1); \ |
| 1508 | do \ |
| 1509 | if [ ! -f $$f ]; then \ |
| 1510 | echo Missing file $$f; \ |
| 1511 | exit 1; \ |
| 1512 | fi; \ |
Sriram Raman | f1a55f8 | 2009-06-09 15:08:29 -0700 | [diff] [blame] | 1513 | unzip -qo $$f -d $(2); \ |
Ying Wang | 3a6f758 | 2012-08-30 12:59:42 -0700 | [diff] [blame] | 1514 | done \ |
| 1515 | $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,;rm -rf $(2)/META-INF) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1516 | endef |
| 1517 | |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1518 | # Common definition to invoke javac on the host and target. |
| 1519 | # |
| 1520 | # Some historical notes: |
| 1521 | # - below we write the list of java files to java-source-list to avoid argument |
| 1522 | # list length problems with Cygwin |
| 1523 | # - we filter out duplicate java file names because eclipse's compiler |
| 1524 | # doesn't like them. |
| 1525 | # |
| 1526 | # $(1): javac |
| 1527 | # $(2): bootclasspath |
| 1528 | define compile-java |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1529 | $(hide) rm -f $@ |
| 1530 | $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1531 | $(hide) mkdir -p $(dir $@) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1532 | $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1533 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1534 | $(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1535 | $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1536 | find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1537 | fi |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1538 | $(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \ |
| 1539 | | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
Ying Wang | e109a1d | 2011-12-12 17:52:03 -0800 | [diff] [blame] | 1540 | $(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \ |
| 1541 | $(1) -encoding UTF-8 \ |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1542 | $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \ |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 1543 | $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1544 | $(2) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1545 | $(addprefix -classpath ,$(strip \ |
| 1546 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \ |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 1547 | $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1548 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1549 | $(PRIVATE_JAVACFLAGS) \ |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1550 | \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \ |
Ying Wang | e109a1d | 2011-12-12 17:52:03 -0800 | [diff] [blame] | 1551 | || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \ |
| 1552 | fi |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 1553 | $(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/tools/java-layers.py \ |
| 1554 | $(PRIVATE_JAVA_LAYERS_FILE) \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq,) |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1555 | $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list |
| 1556 | $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 1557 | $(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
| 1558 | -name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \ |
| 1559 | $(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \ |
| 1560 | | xargs rm -rf) |
Jeff Brown | ae859f9 | 2013-07-17 20:29:51 -0700 | [diff] [blame] | 1561 | $(if $(PRIVATE_JAR_PACKAGES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -mindepth 1 -type d \ |
| 1562 | $(foreach pkg, $(PRIVATE_JAR_PACKAGES), \ |
| 1563 | -not -path $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))) \ |
| 1564 | | xargs rm -rf) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1565 | $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \ |
| 1566 | $@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1567 | endef |
| 1568 | |
| 1569 | define transform-java-to-classes.jar |
| 1570 | @echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
| 1571 | $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1572 | endef |
| 1573 | |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1574 | # Override the above definitions if we want to do incremetal javac |
| 1575 | ifeq (true, $(ENABLE_INCREMENTALJAVAC)) |
| 1576 | define compile-java |
| 1577 | $(hide) mkdir -p $(dir $@) |
| 1578 | $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
| 1579 | $(hide) touch $(PRIVATE_CLASS_INTERMEDIATES_DIR)/newstamp |
| 1580 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
| 1581 | $(hide) if [ -e $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp ] ; then \ |
| 1582 | newerFlag=$$(echo -n "-newer $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp") ; \ |
| 1583 | fi ; \ |
| 1584 | find $(PRIVATE_JAVA_SOURCES) $$newerFlag > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list ; \ |
| 1585 | if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
| 1586 | find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' $$newerFlag >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \ |
| 1587 | fi |
| 1588 | $(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \ |
| 1589 | | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
| 1590 | @echo "(Incremental) build source files:" |
| 1591 | @cat $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
| 1592 | $(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \ |
Joe Onorato | 149dd91 | 2011-05-31 18:21:07 -0700 | [diff] [blame] | 1593 | $(1) -encoding UTF-8 \ |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1594 | $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \ |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 1595 | $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1596 | $(2) \ |
| 1597 | $(addprefix -classpath ,$(strip \ |
| 1598 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES) $(PRIVATE_CLASS_INTERMEDIATES_DIR)))) \ |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 1599 | $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1600 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
| 1601 | $(PRIVATE_JAVACFLAGS) \ |
| 1602 | \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \ |
| 1603 | || ( exit 41 ) \ |
| 1604 | fi |
| 1605 | $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list |
| 1606 | $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
| 1607 | $(hide) rm -f $@ |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame] | 1608 | $(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
| 1609 | -name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \ |
| 1610 | $(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \ |
| 1611 | | xargs rm -rf) |
Jeff Brown | ae859f9 | 2013-07-17 20:29:51 -0700 | [diff] [blame] | 1612 | $(if $(PRIVATE_JAR_PACKAGES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -mindepth 1 -type d \ |
| 1613 | $(foreach pkg, $(PRIVATE_JAR_PACKAGES), \ |
| 1614 | -not -path $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))) \ |
| 1615 | | xargs rm -rf) |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1616 | $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \ |
| 1617 | $@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . |
| 1618 | $(hide) mv $(PRIVATE_CLASS_INTERMEDIATES_DIR)/newstamp $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp |
| 1619 | endef |
| 1620 | |
| 1621 | define transform-java-to-classes.jar |
| 1622 | @echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
| 1623 | $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH)) |
| 1624 | endef |
| 1625 | endif # ENABLE_INCREMENTALJAVAC |
| 1626 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1627 | define transform-classes.jar-to-emma |
| 1628 | $(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \ |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 1629 | $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \ |
Guang Zhu | 9cd3d8c | 2010-06-15 13:31:25 -0700 | [diff] [blame] | 1630 | $(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1631 | endef |
| 1632 | |
| 1633 | #TODO: use a smaller -Xmx value for most libraries; |
| 1634 | # only core.jar and framework.jar need a heap this big. |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 1635 | # 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] | 1636 | define transform-classes.jar-to-dex |
| 1637 | @echo "target Dex: $(PRIVATE_MODULE)" |
| 1638 | @mkdir -p $(dir $@) |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 1639 | $(hide) $(DX) \ |
Wink Saville | 29b3afa | 2012-01-30 15:30:10 -0800 | [diff] [blame] | 1640 | $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx2048M) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1641 | --dex --output=$@ \ |
Brian Carlstrom | bb7c6d8 | 2011-04-01 15:45:58 -0700 | [diff] [blame] | 1642 | $(incremental_dex) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1643 | $(if $(NO_OPTIMIZE_DX), \ |
| 1644 | --no-optimize) \ |
| 1645 | $(if $(GENERATE_DEX_DEBUG), \ |
| 1646 | --debug --verbose \ |
| 1647 | --dump-to=$(@:.dex=.lst) \ |
| 1648 | --dump-width=1000) \ |
| 1649 | $(PRIVATE_DX_FLAGS) \ |
| 1650 | $< |
| 1651 | endef |
| 1652 | |
| 1653 | # Create a mostly-empty .jar file that we'll add to later. |
| 1654 | # The MacOS jar tool doesn't like creating empty jar files, |
| 1655 | # so we need to give it something. |
| 1656 | define create-empty-package |
| 1657 | @mkdir -p $(dir $@) |
| 1658 | $(hide) touch $(dir $@)/dummy |
| 1659 | $(hide) (cd $(dir $@) && jar cf $(notdir $@) dummy) |
| 1660 | $(hide) zip -qd $@ dummy |
| 1661 | $(hide) rm $(dir $@)/dummy |
| 1662 | endef |
| 1663 | |
| 1664 | #TODO: we kinda want to build different asset packages for |
| 1665 | # different configurations, then combine them later (or something). |
| 1666 | # Per-locale, etc. |
| 1667 | # A list of dynamic and static parameters; build layers for |
| 1668 | # dynamic params that lay over the static ones. |
| 1669 | #TODO: update the manifest to point to the package file |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1670 | #Note that the version numbers are given to aapt as simple default |
| 1671 | #values; applications can override these by explicitly stating |
| 1672 | #them in their manifest. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1673 | define add-assets-to-package |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 1674 | $(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 1675 | $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \ |
Dianne Hackborn | a0f464a | 2011-10-14 19:37:57 -0700 | [diff] [blame] | 1676 | $(addprefix --preferred-configurations , $(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1677 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1678 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1679 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
| 1680 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 1681 | $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
| 1682 | $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
Joe Onorato | 700b88e | 2010-10-05 17:33:58 -0400 | [diff] [blame] | 1683 | $(addprefix --product , $(TARGET_AAPT_CHARACTERISTICS)) \ |
Ying Wang | 1ae607a | 2010-06-23 13:34:22 -0700 | [diff] [blame] | 1684 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \ |
Ying Wang | 8f5069b | 2010-06-29 11:08:13 -0700 | [diff] [blame] | 1685 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \ |
Jeff Hamilton | bb67d21 | 2010-02-05 22:36:42 -0600 | [diff] [blame] | 1686 | $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 1687 | $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1688 | -F $@ |
| 1689 | endef |
| 1690 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1691 | define add-jni-shared-libs-to-package |
| 1692 | $(hide) rm -rf $(dir $@)lib |
Jack Palevich | a0ab29b | 2010-06-18 15:38:07 +0800 | [diff] [blame] | 1693 | $(hide) mkdir -p $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI) |
| 1694 | $(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1695 | $(hide) (cd $(dir $@) && zip -r $(notdir $@) lib) |
| 1696 | $(hide) rm -rf $(dir $@)lib |
| 1697 | endef |
| 1698 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1699 | #TODO: update the manifest to point to the dex file |
| 1700 | define add-dex-to-package |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 1701 | $(if $(filter classes.dex,$(notdir $(PRIVATE_DEX_FILE))),\ |
-b master | c3ccfee | 2013-01-23 16:54:32 -0800 | [diff] [blame] | 1702 | $(hide) zip -qj $@ $(PRIVATE_DEX_FILE),\ |
Ying Wang | 6e7db38 | 2011-07-27 12:49:15 -0700 | [diff] [blame] | 1703 | $(hide) _adtp_classes_dex=$(dir $(PRIVATE_DEX_FILE))classes.dex; \ |
| 1704 | cp $(PRIVATE_DEX_FILE) $$_adtp_classes_dex && \ |
-b master | c3ccfee | 2013-01-23 16:54:32 -0800 | [diff] [blame] | 1705 | zip -qj $@ $$_adtp_classes_dex && rm -f $$_adtp_classes_dex) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1706 | endef |
| 1707 | |
Ying Wang | 8548062 | 2012-08-09 15:20:50 -0700 | [diff] [blame] | 1708 | # Add java resources added by the current module. |
| 1709 | # |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1710 | define add-java-resources-to-package |
Ying Wang | 194a8ec | 2011-06-06 14:34:52 -0700 | [diff] [blame] | 1711 | $(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(dir $@)jar-arg-list) |
| 1712 | $(hide) jar uf $@ @$(dir $@)jar-arg-list |
| 1713 | @rm -f $(dir $@)jar-arg-list |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1714 | endef |
| 1715 | |
Ying Wang | 8548062 | 2012-08-09 15:20:50 -0700 | [diff] [blame] | 1716 | # Add java resources carried by static Java libraries. |
| 1717 | # |
| 1718 | define add-carried-java-resources |
| 1719 | $(hide) if [ -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) ] ; then \ |
| 1720 | java_res_jar_flags=$$(find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -type f -a -not -name "*.class" \ |
| 1721 | | sed -e "s?^$(PRIVATE_CLASS_INTERMEDIATES_DIR)/? -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ?"); \ |
| 1722 | if [ -n "$$java_res_jar_flags" ] ; then \ |
| 1723 | echo $$java_res_jar_flags >$(dir $@)java_res_jar_flags; \ |
| 1724 | jar uf $@ $$java_res_jar_flags; \ |
| 1725 | fi; \ |
| 1726 | fi |
| 1727 | endef |
| 1728 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1729 | # Sign a package using the specified key/cert. |
| 1730 | # |
| 1731 | define sign-package |
| 1732 | $(hide) mv $@ $@.unsigned |
| 1733 | $(hide) java -jar $(SIGNAPK_JAR) \ |
Ying Wang | 31df068 | 2012-11-13 10:55:28 -0800 | [diff] [blame] | 1734 | $(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \ |
| 1735 | $(PRIVATE_ADDITIONAL_CERTIFICATES) $@.unsigned $@.signed |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1736 | $(hide) mv $@.signed $@ |
| 1737 | endef |
| 1738 | |
| 1739 | # Align STORED entries of a package on 4-byte boundaries |
| 1740 | # to make them easier to mmap. |
| 1741 | # |
| 1742 | define align-package |
| 1743 | $(hide) mv $@ $@.unaligned |
| 1744 | $(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned |
| 1745 | $(hide) mv $@.aligned $@ |
| 1746 | endef |
| 1747 | |
| 1748 | define install-dex-debug |
| 1749 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \ |
| 1750 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 1751 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.dex \ |
| 1752 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).dex; \ |
| 1753 | fi |
| 1754 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.lst" ]; then \ |
| 1755 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 1756 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.lst \ |
| 1757 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).lst; \ |
| 1758 | fi |
| 1759 | endef |
| 1760 | |
| 1761 | # TODO(joeo): If we can ever upgrade to post 3.81 make and get the |
| 1762 | # new prebuilt rules to work, we should change this to copy the |
| 1763 | # resources to the out directory and then copy the resources. |
| 1764 | |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1765 | # Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR |
| 1766 | # in transform-java-to-classes for the sake of vm-tests. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1767 | define transform-host-java-to-package |
| 1768 | @echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1769 | $(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH)) |
Ying Wang | 194a8ec | 2011-06-06 14:34:52 -0700 | [diff] [blame] | 1770 | $(if $(PRIVATE_EXTRA_JAR_ARGS), $(call add-java-resources-to-package)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1771 | endef |
| 1772 | |
| 1773 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1774 | ## Commands for copying files |
| 1775 | ########################################################### |
| 1776 | |
| 1777 | # Define a rule to copy a header. Used via $(eval) by copy_headers.make. |
| 1778 | # $(1): source header |
| 1779 | # $(2): destination header |
| 1780 | define copy-one-header |
| 1781 | $(2): $(1) |
| 1782 | @echo "Header: $$@" |
| 1783 | $$(copy-file-to-new-target-with-cp) |
| 1784 | endef |
| 1785 | |
| 1786 | # Define a rule to copy a file. For use via $(eval). |
| 1787 | # $(1): source file |
| 1788 | # $(2): destination file |
| 1789 | define copy-one-file |
| 1790 | $(2): $(1) | $(ACP) |
| 1791 | @echo "Copy: $$@" |
| 1792 | $$(copy-file-to-target) |
| 1793 | endef |
| 1794 | |
Joe Onorato | e44705a | 2012-05-17 17:12:04 -0700 | [diff] [blame] | 1795 | # Copies many files. |
| 1796 | # $(1): The files to copy. Each entry is a ':' separated src:dst pair |
| 1797 | # Evaluates to the list of the dst files (ie suitable for a dependency list) |
| 1798 | define copy-many-files |
| 1799 | $(foreach f, $(1), $(strip \ |
| 1800 | $(eval _cmf_tuple := $(subst :, ,$(f))) \ |
| 1801 | $(eval _cmf_src := $(word 1,$(_cmf_tuple))) \ |
| 1802 | $(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \ |
| 1803 | $(eval $(call copy-one-file,$(_cmf_src),$(_cmf_dest))) \ |
| 1804 | $(_cmf_dest))) |
| 1805 | endef |
| 1806 | |
Ying Wang | 3ceecfa | 2012-05-14 14:39:00 -0700 | [diff] [blame] | 1807 | # Copy the file only if it's a well-formed xml file. For use via $(eval). |
| 1808 | # $(1): source file |
| 1809 | # $(2): destination file, must end with .xml. |
| 1810 | define copy-xml-file-checked |
| 1811 | $(2): $(1) | $(ACP) |
| 1812 | @echo "Copy xml: $$@" |
| 1813 | $(hide) xmllint $$< >/dev/null # Don't print the xml file to stdout. |
| 1814 | $$(copy-file-to-target) |
| 1815 | endef |
| 1816 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1817 | # The -t option to acp and the -p option to cp is |
| 1818 | # required for OSX. OSX has a ridiculous restriction |
| 1819 | # where it's an error for a .a file's modification time |
| 1820 | # to disagree with an internal timestamp, and this |
| 1821 | # macro is used to install .a files (among other things). |
| 1822 | |
| 1823 | # Copy a single file from one place to another, |
| 1824 | # preserving permissions and overwriting any existing |
| 1825 | # file. |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 1826 | # We disable the "-t" option for acp cannot handle |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 1827 | # high resolution timestamp correctly on file systems like ext4. |
| 1828 | # Therefore copy-file-to-target is the same as copy-file-to-new-target. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1829 | define copy-file-to-target |
| 1830 | @mkdir -p $(dir $@) |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 1831 | $(hide) $(ACP) -fp $< $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1832 | endef |
| 1833 | |
| 1834 | # The same as copy-file-to-target, but use the local |
| 1835 | # cp command instead of acp. |
| 1836 | define copy-file-to-target-with-cp |
| 1837 | @mkdir -p $(dir $@) |
| 1838 | $(hide) cp -fp $< $@ |
| 1839 | endef |
| 1840 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 1841 | # The same as copy-file-to-target, but use the zipalign tool to do so. |
| 1842 | define copy-file-to-target-with-zipalign |
| 1843 | @mkdir -p $(dir $@) |
| 1844 | $(hide) $(ZIPALIGN) -f 4 $< $@ |
| 1845 | endef |
| 1846 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 1847 | # The same as copy-file-to-target, but strip out "# comment"-style |
| 1848 | # comments (for config files and such). |
| 1849 | define copy-file-to-target-strip-comments |
| 1850 | @mkdir -p $(dir $@) |
| 1851 | $(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@ |
| 1852 | endef |
| 1853 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1854 | # The same as copy-file-to-target, but don't preserve |
| 1855 | # the old modification time. |
| 1856 | define copy-file-to-new-target |
| 1857 | @mkdir -p $(dir $@) |
| 1858 | $(hide) $(ACP) -fp $< $@ |
| 1859 | endef |
| 1860 | |
| 1861 | # The same as copy-file-to-new-target, but use the local |
| 1862 | # cp command instead of acp. |
| 1863 | define copy-file-to-new-target-with-cp |
| 1864 | @mkdir -p $(dir $@) |
| 1865 | $(hide) cp -f $< $@ |
| 1866 | endef |
| 1867 | |
| 1868 | # Copy a prebuilt file to a target location. |
| 1869 | define transform-prebuilt-to-target |
| 1870 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 1871 | $(copy-file-to-target) |
| 1872 | endef |
| 1873 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 1874 | # Copy a prebuilt file to a target location, using zipalign on it. |
| 1875 | define transform-prebuilt-to-target-with-zipalign |
| 1876 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)" |
| 1877 | $(copy-file-to-target-with-zipalign) |
| 1878 | endef |
| 1879 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 1880 | # Copy a prebuilt file to a target location, stripping "# comment" comments. |
| 1881 | define transform-prebuilt-to-target-strip-comments |
| 1882 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 1883 | $(copy-file-to-target-strip-comments) |
| 1884 | endef |
| 1885 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1886 | ########################################################### |
| 1887 | ## On some platforms (MacOS), after copying a static |
| 1888 | ## library, ranlib must be run to update an internal |
| 1889 | ## timestamp!?!?! |
| 1890 | ########################################################### |
| 1891 | |
| 1892 | ifeq ($(HOST_RUN_RANLIB_AFTER_COPYING),true) |
| 1893 | define transform-host-ranlib-copy-hack |
| 1894 | $(hide) ranlib $@ || true |
| 1895 | endef |
| 1896 | else |
| 1897 | define transform-host-ranlib-copy-hack |
Patrick Scott | 0e27dff | 2010-05-07 08:37:11 -0400 | [diff] [blame] | 1898 | @true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1899 | endef |
| 1900 | endif |
| 1901 | |
| 1902 | ifeq ($(TARGET_RUN_RANLIB_AFTER_COPYING),true) |
| 1903 | define transform-ranlib-copy-hack |
| 1904 | $(hide) ranlib $@ |
| 1905 | endef |
| 1906 | else |
| 1907 | define transform-ranlib-copy-hack |
Patrick Scott | 0e27dff | 2010-05-07 08:37:11 -0400 | [diff] [blame] | 1908 | @true |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1909 | endef |
| 1910 | endif |
| 1911 | |
| 1912 | |
| 1913 | ########################################################### |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 1914 | ## Commands to call Proguard |
| 1915 | ########################################################### |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 1916 | define transform-jar-to-proguard |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 1917 | @echo Proguard: $@ |
| 1918 | $(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 1919 | endef |
| 1920 | |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 1921 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1922 | ## Stuff source generated from one-off tools |
| 1923 | ########################################################### |
| 1924 | |
| 1925 | define transform-generated-source |
| 1926 | @echo "target Generated: $(PRIVATE_MODULE) <= $<" |
| 1927 | @mkdir -p $(dir $@) |
| 1928 | $(hide) $(PRIVATE_CUSTOM_TOOL) |
| 1929 | endef |
| 1930 | |
| 1931 | |
| 1932 | ########################################################### |
| 1933 | ## Assertions about attributes of the target |
| 1934 | ########################################################### |
| 1935 | |
| 1936 | # $(1): The file to check |
| 1937 | ifndef get-file-size |
| 1938 | $(error HOST_OS must define get-file-size) |
| 1939 | endif |
| 1940 | |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1941 | # Convert a partition data size (eg, as reported in /proc/mtd) to the |
| 1942 | # size of the image used to flash that partition (which includes a |
Lars Svensson | 9cb8c28 | 2010-12-06 15:24:58 +0100 | [diff] [blame] | 1943 | # spare area for each page). |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1944 | # $(1): the partition data size |
| 1945 | define image-size-from-data-size |
Ying Wang | 4a2ecaf | 2011-02-09 17:24:27 -0800 | [diff] [blame] | 1946 | $(strip $(eval _isfds_value := $$(shell echo $$$$(($(1) / $(BOARD_NAND_PAGE_SIZE) * \ |
| 1947 | ($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE))))))\ |
| 1948 | $(if $(filter 0, $(_isfds_value)),$(shell echo $$(($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE)))),$(_isfds_value))\ |
| 1949 | $(eval _isfds_value :=)) |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1950 | endef |
| 1951 | |
| 1952 | # $(1): The file(s) to check (often $@) |
| 1953 | # $(2): The maximum total image size, in decimal bytes |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1954 | # $(3): the type of filesystem "yaffs" or "raw" |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1955 | # |
| 1956 | # If $(2) is empty, evaluates to "true" |
| 1957 | # |
| 1958 | # Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks) |
| 1959 | # is left over after the image has been flashed. Round the 1% up to the |
| 1960 | # next whole flash block size. |
| 1961 | define assert-max-file-size |
| 1962 | $(if $(2), \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 1963 | size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \ |
| 1964 | total=$$(( $$( echo "$$size" ) )); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1965 | printname=$$(echo -n "$(1)" | tr " " +); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1966 | img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1967 | if [ "$(3)" == "yaffs" ]; then \ |
Doug Zongker | 93d9ff4 | 2009-09-14 17:46:41 -0700 | [diff] [blame] | 1968 | reservedblocks=8; \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1969 | else \ |
Doug Zongker | 4ac1ba6 | 2009-08-25 20:38:50 -0700 | [diff] [blame] | 1970 | reservedblocks=0; \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1971 | fi; \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1972 | twoblocks=$$((img_blocksize * 2)); \ |
| 1973 | onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \ |
Doug Zongker | 6dd2ae0 | 2009-08-25 17:23:57 -0700 | [diff] [blame] | 1974 | reserve=$$(((twoblocks > onepct ? twoblocks : onepct) + \ |
| 1975 | reservedblocks * img_blocksize)); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1976 | maxsize=$$(($(2) - reserve)); \ |
Ying Wang | 99bcbeb | 2011-12-02 10:34:45 -0800 | [diff] [blame] | 1977 | echo "$$printname maxsize=$$maxsize blocksize=$$img_blocksize total=$$total reserve=$$reserve"; \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1978 | if [ "$$total" -gt "$$maxsize" ]; then \ |
| 1979 | echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \ |
| 1980 | false; \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 1981 | elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 1982 | 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] | 1983 | fi \ |
| 1984 | , \ |
| 1985 | true \ |
| 1986 | ) |
| 1987 | endef |
| 1988 | |
Doug Zongker | 8510a1e | 2009-08-07 16:38:08 -0700 | [diff] [blame] | 1989 | # Like assert-max-file-size, but the second argument is a partition |
| 1990 | # size, which we'll convert to a max image size before checking it |
| 1991 | # against the files. |
| 1992 | # |
| 1993 | # $(1): The file(s) to check (often $@) |
| 1994 | # $(2): The partition size. |
| 1995 | define assert-max-image-size |
| 1996 | $(if $(2), \ |
| 1997 | $(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2))), \ |
| 1998 | true) |
| 1999 | endef |
| 2000 | |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2001 | |
| 2002 | ########################################################### |
| 2003 | ## Define device-specific radio files |
| 2004 | ########################################################### |
Ying Wang | 94de1eb | 2013-07-26 12:19:20 -0700 | [diff] [blame] | 2005 | INSTALLED_RADIOIMAGE_TARGET := |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2006 | |
| 2007 | # Copy a radio image file to the output location, and add it to |
| 2008 | # INSTALLED_RADIOIMAGE_TARGET. |
| 2009 | # $(1): filename |
| 2010 | define add-radio-file |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 2011 | $(eval $(call add-radio-file-internal,$(1),$(notdir $(1)))) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2012 | endef |
| 2013 | define add-radio-file-internal |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 2014 | INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2) |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 2015 | $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2016 | $$(transform-prebuilt-to-target) |
| 2017 | endef |
| 2018 | |
Doug Zongker | 9296f09 | 2012-03-20 16:42:22 -0700 | [diff] [blame] | 2019 | # Version of add-radio-file that also arranges for the version of the |
| 2020 | # file to be checked against the contents of |
| 2021 | # $(TARGET_BOARD_INFO_FILE). |
| 2022 | # $(1): filename |
| 2023 | # $(2): name of version variable in board-info (eg, "version-baseband") |
| 2024 | define add-radio-file-checked |
| 2025 | $(eval $(call add-radio-file-checked-internal,$(1),$(notdir $(1)),$(2))) |
| 2026 | endef |
| 2027 | define add-radio-file-checked-internal |
| 2028 | INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2) |
| 2029 | BOARD_INFO_CHECK += $(3):$(LOCAL_PATH)/$(1) |
| 2030 | $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP) |
| 2031 | $$(transform-prebuilt-to-target) |
| 2032 | endef |
| 2033 | |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2034 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2035 | ########################################################### |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2036 | # Override the package defined in $(1), setting the |
| 2037 | # variables listed below differently. |
| 2038 | # |
| 2039 | # $(1): The makefile to override (relative to the source |
| 2040 | # tree root) |
| 2041 | # $(2): Old LOCAL_PACKAGE_NAME value. |
| 2042 | # $(3): New LOCAL_PACKAGE_NAME value. |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2043 | # $(4): New LOCAL_MANIFEST_PACKAGE_NAME value. |
| 2044 | # $(5): New LOCAL_CERTIFICATE value. |
| 2045 | # $(6): New LOCAL_INSTRUMENTATION_FOR value. |
| 2046 | # $(7): New LOCAL_MANIFEST_INSTRUMENTATION_FOR value. |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2047 | # |
| 2048 | # Note that LOCAL_PACKAGE_OVERRIDES is NOT cleared in |
| 2049 | # clear_vars.mk. |
| 2050 | ########################################################### |
| 2051 | define inherit-package |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2052 | $(eval $(call inherit-package-internal,$(1),$(2),$(3),$(4),$(5),$(6),$(7))) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2053 | endef |
| 2054 | |
| 2055 | define inherit-package-internal |
| 2056 | LOCAL_PACKAGE_OVERRIDES \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2057 | := $(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||&&$(strip $(5))||&&$(strip $(6))||&&$(strip $(7)) $(LOCAL_PACKAGE_OVERRIDES) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2058 | include $(1) |
| 2059 | LOCAL_PACKAGE_OVERRIDES \ |
| 2060 | := $(wordlist 1,$(words $(LOCAL_PACKAGE_OVERRIDES)), $(LOCAL_PACKAGE_OVERRIDES)) |
| 2061 | endef |
| 2062 | |
| 2063 | # To be used with inherit-package above |
| 2064 | # Evalutes to true if the package was overridden |
| 2065 | define set-inherited-package-variables |
| 2066 | $(strip $(call set-inherited-package-variables-internal)) |
| 2067 | endef |
| 2068 | |
| 2069 | define keep-or-override |
| 2070 | $(eval $(1) := $(if $(2),$(2),$($(1)))) |
| 2071 | endef |
| 2072 | |
| 2073 | define set-inherited-package-variables-internal |
| 2074 | $(eval _o := $(subst ||, ,$(lastword $(LOCAL_PACKAGE_OVERRIDES)))) |
| 2075 | $(eval _n := $(subst ||, ,$(firstword $(LOCAL_PACKAGE_OVERRIDES)))) |
| 2076 | $(if $(filter $(word 2,$(_n)),$(LOCAL_PACKAGE_NAME)), \ |
| 2077 | $(eval LOCAL_PACKAGE_NAME := $(word 3,$(_o))) \ |
| 2078 | $(eval LOCAL_MANIFEST_PACKAGE_NAME := $(word 4,$(_o))) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2079 | $(call keep-or-override,LOCAL_CERTIFICATE,$(patsubst &&%,%,$(word 5,$(_o)))) \ |
| 2080 | $(call keep-or-override,LOCAL_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 6,$(_o)))) \ |
| 2081 | $(call keep-or-override,LOCAL_MANIFEST_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 7,$(_o)))) \ |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2082 | $(eval LOCAL_OVERRIDES_PACKAGES := $(sort $(LOCAL_OVERRIDES_PACKAGES) $(word 2,$(_o)))) \ |
| 2083 | true \ |
| 2084 | ,) |
| 2085 | endef |
| 2086 | |
Ying Wang | 000e89a | 2012-04-30 15:48:27 -0700 | [diff] [blame] | 2087 | ########################################################### |
| 2088 | ## Expand a module name list with REQUIRED modules |
| 2089 | ########################################################### |
| 2090 | # $(1): The variable name that holds the initial module name list. |
| 2091 | # the variable will be modified to hold the expanded results. |
| 2092 | # $(2): The initial module name list. |
| 2093 | # Returns empty string (maybe with some whitespaces). |
| 2094 | define expand-required-modules |
| 2095 | $(eval _erm_new_modules := $(sort $(filter-out $($(1)),\ |
| 2096 | $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED)))))\ |
| 2097 | $(if $(_erm_new_modules),$(eval $(1) += $(_erm_new_modules))\ |
| 2098 | $(call expand-required-modules,$(1),$(_erm_new_modules))) |
| 2099 | endef |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2100 | |
| 2101 | ########################################################### |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2102 | ## API Check |
| 2103 | ########################################################### |
| 2104 | |
| 2105 | # eval this to define a rule that runs apicheck. |
| 2106 | # |
| 2107 | # Args: |
| 2108 | # $(1) target |
| 2109 | # $(2) stable api file |
| 2110 | # $(3) api file to be tested |
| 2111 | # $(4) arguments for apicheck |
| 2112 | # $(5) command to run if apicheck failed |
| 2113 | # $(6) target dependent on this api check |
| 2114 | # $(7) additional dependencies |
| 2115 | define check-api |
| 2116 | $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK) $(7) |
| 2117 | @echo "Checking API:" $(1) |
| 2118 | $(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) ) |
| 2119 | $(hide) mkdir -p $$(dir $$@) |
| 2120 | $(hide) touch $$@ |
| 2121 | $(6): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp |
| 2122 | endef |
| 2123 | |
Ying Wang | 63d94fa | 2012-12-13 18:23:01 -0800 | [diff] [blame] | 2124 | ## Whether to build from source if prebuilt alternative exists |
| 2125 | ########################################################### |
| 2126 | # $(1): module name |
| 2127 | # $(2): LOCAL_PATH |
| 2128 | # Expands to empty string if not from source. |
| 2129 | ifeq (true,$(ANDROID_BUILD_FROM_SOURCE)) |
| 2130 | define if-build-from-source |
| 2131 | true |
| 2132 | endef |
| 2133 | else |
| 2134 | define if-build-from-source |
| 2135 | $(if $(filter $(ANDROID_NO_PREBUILT_MODULES),$(1))$(filter \ |
| 2136 | $(addsuffix %,$(ANDROID_NO_PREBUILT_PATHS)),$(2)),true) |
| 2137 | endef |
| 2138 | endif |
| 2139 | |
| 2140 | # Include makefile $(1) if build from source for module $(2) |
| 2141 | # $(1): the makefile to include |
| 2142 | # $(2): module name |
| 2143 | # $(3): LOCAL_PATH |
| 2144 | define include-if-build-from-source |
| 2145 | $(if $(call if-build-from-source,$(2),$(3)),$(eval include $(1))) |
| 2146 | endef |
| 2147 | |
Ying Wang | 6c930fc | 2014-02-27 14:10:53 -0800 | [diff] [blame^] | 2148 | ## Return the arch for the source file of a prebuilt |
| 2149 | # $(1) the list of archs supported by the prebuilt |
| 2150 | define get-prebuilt-src-arch |
| 2151 | $(strip $(if $(filter $(TARGET_ARCH),$(1)),$(TARGET_ARCH),\ |
| 2152 | $(if $(filter $(TARGET_2ND_ARCH),$(1)),$(TARGET_2ND_ARCH)))) |
| 2153 | endef |
| 2154 | |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2155 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2156 | ## Other includes |
| 2157 | ########################################################### |
| 2158 | |
| 2159 | # ----------------------------------------------------------------- |
| 2160 | # Rules and functions to help copy important files to DIST_DIR |
| 2161 | # when requested. |
| 2162 | include $(BUILD_SYSTEM)/distdir.mk |
| 2163 | |
Marie Lennerhagen | 9e5efce | 2010-10-20 13:41:59 +0200 | [diff] [blame] | 2164 | # Include any vendor specific definitions.mk file |
| 2165 | -include $(TOPDIR)vendor/*/build/core/definitions.mk |
| 2166 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2167 | # broken: |
| 2168 | # $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file))) |
| 2169 | |
| 2170 | ########################################################### |
| 2171 | ## Misc notes |
| 2172 | ########################################################### |
| 2173 | |
| 2174 | #DEPDIR = .deps |
| 2175 | #df = $(DEPDIR)/$(*F) |
| 2176 | |
| 2177 | #SRCS = foo.c bar.c ... |
| 2178 | |
| 2179 | #%.o : %.c |
| 2180 | # @$(MAKEDEPEND); \ |
| 2181 | # cp $(df).d $(df).P; \ |
| 2182 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 2183 | # -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \ |
| 2184 | # rm -f $(df).d |
| 2185 | # $(COMPILE.c) -o $@ $< |
| 2186 | |
| 2187 | #-include $(SRCS:%.c=$(DEPDIR)/%.P) |
| 2188 | |
| 2189 | |
| 2190 | #%.o : %.c |
| 2191 | # $(COMPILE.c) -MD -o $@ $< |
| 2192 | # @cp $*.d $*.P; \ |
| 2193 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 2194 | # -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ |
| 2195 | # rm -f $*.d |