OSDN Git Service

am 4e4c919: AI 148759: Add download page for NDK 1.5 r1.
[android-x86/build.git] / core / Makefile
1 # Put some miscellaneous rules here
2
3 # Pick a reasonable string to use to identify files.
4 ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
5   # BUILD_NUMBER has a timestamp in it, which means that
6   # it will change every time.  Pick a stable value.
7   FILE_NAME_TAG := eng.$(USER)
8 else
9   FILE_NAME_TAG := $(BUILD_NUMBER)
10 endif
11
12 # -----------------------------------------------------------------
13 # Define rules to copy PRODUCT_COPY_FILES defined by the product.
14 # PRODUCT_COPY_FILES contains words like <source file>:<dest file>.
15 # <dest file> is relative to $(PRODUCT_OUT), so it should look like,
16 # e.g., "system/etc/file.xml".
17 $(foreach cf,$(PRODUCT_COPY_FILES), \
18   $(eval _src := $(call word-colon,1,$(cf))) \
19   $(eval _dest := $(call \
20           append-path,$(PRODUCT_OUT),$(call word-colon,2,$(cf)))) \
21   $(eval $(call copy-one-file,$(_src),$(_dest))) \
22   $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_dest)) \
23  )
24
25 # -----------------------------------------------------------------
26 # docs/index.html
27 gen := $(OUT_DOCS)/index.html
28 ALL_DOCS += $(gen)
29 $(gen): frameworks/base/docs/docs-redirect-index.html
30         @mkdir -p $(dir $@)
31         @cp -f $< $@
32
33 # -----------------------------------------------------------------
34 # default.prop
35 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
36 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
37 ADDITIONAL_DEFAULT_PROPERTIES := \
38         $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
39
40 $(INSTALLED_DEFAULT_PROP_TARGET):
41         @echo Target buildinfo: $@
42         @mkdir -p $(dir $@)
43         $(hide) echo "#" > $@; \
44                 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
45                 echo "#" >> $@;
46         $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
47                 echo "$(line)" >> $@;)
48
49 # -----------------------------------------------------------------
50 # build.prop
51 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
52 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
53 ADDITIONAL_BUILD_PROPERTIES := \
54         $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
55
56 # A list of arbitrary tags describing the build configuration.
57 # Force ":=" so we can use +=
58 BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
59 ifeq ($(TARGET_BUILD_TYPE),debug)
60   BUILD_VERSION_TAGS += debug
61 endif
62 # Apps are always signed with test keys, and may be re-signed in a post-build
63 # step.  If that happens, the "test-keys" tag will be removed by that step.
64 BUILD_VERSION_TAGS += test-keys
65 BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
66
67 # A human-readable string that descibes this build in detail.
68 build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
69 $(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
70
71 # The string used to uniquely identify this build;  used by the OTA server.
72 ifeq (,$(strip $(BUILD_FINGERPRINT)))
73   BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE)/$(TARGET_BOOTLOADER_BOARD_NAME):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
74 endif
75 ifneq ($(words $(BUILD_FINGERPRINT)),1)
76   $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
77 endif
78
79 # Display parameters shown under Settings -> About Phone
80 ifeq ($(TARGET_BUILD_VARIANT),user)
81   # User builds should show:
82   # release build number or branch.buld_number non-release builds
83
84   # Dev. branches should have DISPLAY_BUILD_NUMBER set
85   ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
86     BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
87   else
88     BUILD_DISPLAY_ID := $(BUILD_ID)
89   endif
90 else
91   # Non-user builds should show detailed build information
92   BUILD_DISPLAY_ID := $(build_desc)
93 endif
94
95 # Selects the first locale in the list given as the argument,
96 # and splits it into language and region, which each may be
97 # empty.
98 define default-locale
99 $(subst _, , $(firstword $(1)))
100 endef
101
102 # Selects the first locale in the list given as the argument
103 # and returns the language (or the region)
104 define default-locale-language
105 $(word 2, 2, $(call default-locale, $(1)))
106 endef
107 define default-locale-region
108 $(word 3, 3, $(call default-locale, $(1)))
109 endef
110
111 BUILDINFO_SH := build/tools/buildinfo.sh
112 $(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE)
113         @echo Target buildinfo: $@
114         @mkdir -p $(dir $@)
115         $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
116                         TARGET_DEVICE="$(TARGET_DEVICE)" \
117                         PRODUCT_NAME="$(TARGET_PRODUCT)" \
118                         PRODUCT_BRAND="$(PRODUCT_BRAND)" \
119                         PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
120                         PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
121                         PRODUCT_MODEL="$(PRODUCT_MODEL)" \
122                         PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
123                         PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
124                         BUILD_ID="$(BUILD_ID)" \
125                         BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
126                         BUILD_NUMBER="$(BUILD_NUMBER)" \
127                         PLATFORM_VERSION="$(PLATFORM_VERSION)" \
128                         PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
129                         PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
130                         BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
131                         TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
132                         BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
133                         TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
134                 bash $(BUILDINFO_SH) > $@
135         $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
136                   cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
137                 fi
138         $(if $(ADDITIONAL_BUILD_PROPERTIES), \
139                 $(hide) echo >> $@; \
140                         echo "#" >> $@; \
141                         echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
142                         echo "#" >> $@; )
143         $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
144                 echo "$(line)" >> $@;)
145
146 build_desc :=
147
148 # -----------------------------------------------------------------
149 # sdk-build.prop
150 #
151 # There are certain things in build.prop that we don't want to
152 # ship with the sdk; remove them.
153
154 # This must be a list of entire property keys followed by
155 # "=" characters, without any internal spaces.
156 sdk_build_prop_remove := \
157         ro.build.user= \
158         ro.build.host= \
159         ro.product.brand= \
160         ro.product.manufacturer= \
161         ro.product.device=
162 # TODO: Remove this soon-to-be obsolete property
163 sdk_build_prop_remove += ro.build.product=
164 INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
165 $(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
166         @echo SDK buildinfo: $@
167         @mkdir -p $(dir $@)
168         $(hide) grep -v "$(subst $(space),\|,$(strip \
169                                 $(sdk_build_prop_remove)))" $< > $@.tmp
170         $(hide) for x in $(sdk_build_prop_remove); do \
171                                 echo "$$x"generic >> $@.tmp; done
172         $(hide) mv $@.tmp $@
173
174 # -----------------------------------------------------------------
175 # package stats
176 PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
177 PACKAGES_TO_STAT := \
178     $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
179         $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
180 $(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
181         @echo Package stats: $@
182         @mkdir -p $(dir $@)
183         $(hide) rm -f $@
184         $(hide) build/tools/dump-package-stats $^ > $@
185
186 .PHONY: package-stats
187 package-stats: $(PACKAGE_STATS_FILE)
188
189 # -----------------------------------------------------------------
190 # Cert-to-package mapping.  Used by the post-build signing tools.
191 name := $(TARGET_PRODUCT)
192 ifeq ($(TARGET_BUILD_TYPE),debug)
193   name := $(name)_debug
194 endif
195 name := $(name)-apkcerts-$(FILE_NAME_TAG)
196 intermediates := \
197         $(call intermediates-dir-for,PACKAGING,apkcerts)
198 APKCERTS_FILE := $(intermediates)/$(name).txt
199 # Depending on the built packages isn't exactly right,
200 # but it should guarantee that the apkcerts file is rebuilt
201 # if any packages change which certs they're signed with.
202 all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
203 $(APKCERTS_FILE): $(all_built_packages)
204         @echo APK certs list: $@
205         @mkdir -p $(dir $@)
206         @rm -f $@
207         $(hide) $(foreach p,$(PACKAGES),\
208           echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
209                private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;)
210
211 .PHONY: apkcerts-list
212 apkcerts-list: $(APKCERTS_FILE)
213
214 # -----------------------------------------------------------------
215 # module info file
216 ifdef CREATE_MODULE_INFO_FILE
217   MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
218   $(info Generating $(MODULE_INFO_FILE)...)
219   $(shell rm -f $(MODULE_INFO_FILE))
220   $(foreach m,$(ALL_MODULES), \
221     $(shell echo "NAME=\"$(m)\"" \
222         "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
223         "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
224         "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
225         "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
226 endif
227
228 # Rules that need to be present for the simulator, even
229 # if they don't do anything.
230 .PHONY: systemimage
231 systemimage:
232
233 ifneq ($(TARGET_SIMULATOR),true)
234
235 # #################################################################
236 # Targets for boot/OS images
237 # #################################################################
238
239 # -----------------------------------------------------------------
240 # the ramdisk
241 INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
242         $(ALL_PREBUILT) \
243         $(ALL_COPIED_HEADERS) \
244         $(ALL_GENERATED_SOURCES) \
245         $(ALL_DEFAULT_INSTALLED_MODULES))
246
247 BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
248
249 # We just build this directly to the install location.
250 INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
251 $(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES)
252         $(call pretty,"Target ram disk: $@")
253         $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | gzip > $@
254
255
256 ifneq ($(strip $(TARGET_NO_KERNEL)),true)
257
258 # -----------------------------------------------------------------
259 # the boot image, which is a collection of other images.
260 INTERNAL_BOOTIMAGE_ARGS := \
261         $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
262         --kernel $(INSTALLED_KERNEL_TARGET) \
263         --ramdisk $(INSTALLED_RAMDISK_TARGET)
264
265 INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
266
267 BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
268 ifdef BOARD_KERNEL_CMDLINE
269   INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
270 endif
271
272 BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
273 ifdef BOARD_KERNEL_BASE
274   INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
275 endif
276
277 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
278
279 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
280 tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
281 INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
282 INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
283 $(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
284         $(call pretty,"Target boot image: $@")
285         $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
286
287 else # TARGET_BOOTIMAGE_USE_EXT2 != true
288
289 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
290         $(call pretty,"Target boot image: $@")
291         $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
292         $(hide) $(call assert-max-file-size,$@,$(BOARD_BOOTIMAGE_MAX_SIZE))
293 endif # TARGET_BOOTIMAGE_USE_EXT2
294
295 else    # TARGET_NO_KERNEL
296 # HACK: The top-level targets depend on the bootimage.  Not all targets
297 # can produce a bootimage, though, and emulator targets need the ramdisk
298 # instead.  Fake it out by calling the ramdisk the bootimage.
299 # TODO: make the emulator use bootimages, and make mkbootimg accept
300 #       kernel-less inputs.
301 INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
302 endif
303
304 # -----------------------------------------------------------------
305 # NOTICE files
306 #
307 # This needs to be before the systemimage rules, because it adds to
308 # ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
309 # go into the systemimage.
310
311 .PHONY: notice_files
312
313 # Create the rule to combine the files into text and html forms
314 # $(1) - Plain text output file
315 # $(2) - HTML output file
316 # $(3) - File title
317 # $(4) - Directory to use.  Notice files are all $(4)/src.  Other
318 #                directories in there will be used for scratch
319 # $(5) - Dependencies for the output files
320 #
321 # The algorithm here is that we go collect a hash for each of the notice
322 # files and write the names of the files that match that hash.  Then
323 # to generate the real files, we go print out all of the files and their
324 # hashes.
325 #
326 # These rules are fairly complex, so they depend on this makefile so if
327 # it changes, they'll run again.
328 #
329 # TODO: We could clean this up so that we just record the locations of the
330 # original notice files instead of making rules to copy them somwehere.
331 # Then we could traverse that without quite as much bash drama.
332 define combine-notice-files
333 $(1) $(2): PRIVATE_MESSAGE := $(3)
334 $(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
335 $(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
336         @echo Finding NOTICE files: $$@
337         $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
338         $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
339         $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
340                         hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
341                         hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
342                         echo $$$$file >> $$$$hashfile; \
343                 done
344         $$(hide) touch $$@
345 $(1): $(4)/hash-timestamp
346         @echo Combining NOTICE files: $$@
347         $$(hide) mkdir -p $$(dir $$@)
348         $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
349         $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
350                 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt:  \1:" >> $$@
351         $$(hide) echo >> $$@
352         $$(hide) echo >> $$@
353         $$(hide) echo >> $$@
354         $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
355                         echo "============================================================"\
356                                 >> $$@; \
357                         echo "Notices for file(s):" >> $$@; \
358                         cat $$$$hashfile | sort | \
359                                 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt:  \1:" >> \
360                                 $$@; \
361                         echo "------------------------------------------------------------"\
362                                 >> $$@; \
363                         echo >> $$@; \
364                         orig=$$$$(head -n 1 $$$$hashfile); \
365                         cat $$$$orig >> $$@; \
366                         echo >> $$@; \
367                         echo >> $$@; \
368                         echo >> $$@; \
369                 done
370 $(2): $(4)/hash-timestamp
371         @echo Combining NOTICE files: $$@
372         $$(hide) mkdir -p $$(dir $$@)
373         $$(hide) echo "<html><head>" > $$@
374         $$(hide) echo "<style type=\"text/css\">" >> $$@
375         $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
376         $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
377         $$(hide) echo ".label { font-weight: bold; }" >> $$@
378         $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
379         $$(hide) echo "</style>" >> $$@
380         $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
381         $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
382                 >> $$@
383         $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
384                         cat $$$$hashfile | sort | \
385                                 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt:  <a name=\"\1\"></a>:" >> \
386                                 $$@; \
387                         echo "<tr><td class=\"same-license\">" >> $$@; \
388                         echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
389                         echo "<div class=\"file-list\">" >> $$@; \
390                         cat $$$$hashfile | sort | \
391                                 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt:  \1<br/>:" >> $$@; \
392                         echo "</div><!-- file-list -->" >> $$@; \
393                         echo >> $$@; \
394                         orig=$$$$(head -n 1 $$$$hashfile); \
395                         echo "<pre class=\"license-text\">" >> $$@; \
396                         cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
397                                         | sed -e "s/>/\&gt;/g" >> $$@; \
398                         echo "</pre><!-- license-text -->" >> $$@; \
399                         echo "</td></tr><!-- same-license -->" >> $$@; \
400                         echo >> $$@; \
401                         echo >> $$@; \
402                         echo >> $$@; \
403                 done
404         $$(hide) echo "</table>" >> $$@
405         $$(hide) echo "</body></html>" >> $$@
406 notice_files: $(1) $(2)
407 endef
408
409 # TODO These intermediate NOTICE.txt/NOTICE.html files should go into
410 # TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
411 # the src subdirectory.
412
413 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
414 target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
415 target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
416 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
417 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
418
419 kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
420
421 $(eval $(call combine-notice-files, \
422                         $(target_notice_file_txt), \
423                         $(target_notice_file_html), \
424                         "Notices for files contained in the filesystem images in this directory:", \
425                         $(TARGET_OUT_NOTICE_FILES), \
426                         $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
427
428 $(eval $(call combine-notice-files, \
429                         $(tools_notice_file_txt), \
430                         $(tools_notice_file_html), \
431                         "Notices for files contained in the tools directory:", \
432                         $(HOST_OUT_NOTICE_FILES), \
433                         $(ALL_DEFAULT_INSTALLED_MODULES)))
434
435 # Install the html file at /system/etc/NOTICE.html.gz.
436 # This is not ideal, but this is very late in the game, after a lot of
437 # the module processing has already been done -- in fact, we used the
438 # fact that all that has been done to get the list of modules that we
439 # need notice files for.
440 $(target_notice_file_html_gz): $(target_notice_file_html)
441         gzip -c $< > $@
442 installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
443 $(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
444         $(copy-file-to-target)
445
446 # if we've been run my mm, mmm, etc, don't reinstall this every time
447 ifeq ($(ONE_SHOT_MAKEFILE),)
448 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
449 endif
450
451 # The kernel isn't really a module, so to get its module file in there, we
452 # make the target NOTICE files depend on this particular file too, which will
453 # then be in the right directory for the find in combine-notice-files to work.
454 $(kernel_notice_file): \
455             prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
456             | $(ACP)
457         @echo Copying: $@
458         $(hide) mkdir -p $(dir $@)
459         $(hide) $(ACP) $< $@
460
461
462 # #################################################################
463 # Targets for user images
464 # #################################################################
465
466 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
467 include external/genext2fs/Config.mk
468 INTERNAL_MKUSERFS := $(MKEXT2IMG)
469 else
470 INTERNAL_MKUSERFS := $(MKYAFFS2)
471 endif
472
473 # -----------------------------------------------------------------
474 # system yaffs image
475 #
476 # First, the "unoptimized" image, which contains .apk/.jar files
477 # that contain regular, unoptimized/unverified .dex entries.
478 #
479 systemimage_unopt_intermediates := \
480         $(call intermediates-dir-for,PACKAGING,systemimage_unopt)
481 BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img
482
483 INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
484         $(ALL_PREBUILT) \
485         $(ALL_COPIED_HEADERS) \
486         $(ALL_GENERATED_SOURCES) \
487         $(ALL_DEFAULT_INSTALLED_MODULES))
488
489 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
490 ## generate an ext2 image
491 # $(1): output file
492 define build-systemimage-target
493     @echo "Target system fs image: $(1)"
494     $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,)
495 endef
496
497 else # TARGET_USERIMAGES_USE_EXT2 != true
498
499 ## generate a yaffs2 image
500 # $(1): output file
501 define build-systemimage-target
502     @echo "Target system fs image: $(1)"
503     @mkdir -p $(dir $(1))
504     $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1)
505 endef
506 endif # TARGET_USERIMAGES_USE_EXT2
507
508 $(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS)
509         $(call build-systemimage-target,$@)
510
511 # The installed image, which may be optimized or unoptimized.
512 #
513 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
514
515 ifdef WITH_DEXPREOPT
516   ifndef DISABLE_DEXPREOPT
517     with_dexpreopt := true
518   endif
519 endif
520 ifdef with_dexpreopt
521   # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR
522   include build/tools/dexpreopt/Config.mk
523 else
524   BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT)
525   SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
526 endif
527
528 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) | $(ACP)
529         @echo "Install system fs image: $@"
530         $(copy-file-to-target)
531         $(hide) $(call assert-max-file-size,$@,$(BOARD_SYSTEMIMAGE_MAX_SIZE))
532
533 systemimage: $(INSTALLED_SYSTEMIMAGE)
534
535 .PHONY: systemimage-nodeps snod
536 systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
537                     | $(INTERNAL_MKUSERFS)
538         @echo "make $@: ignoring dependencies"
539         $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
540         $(hide) $(call assert-max-file-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_MAX_SIZE))
541
542 #######
543 ## system tarball
544 define build-systemtarball-target
545     $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
546     $(MKTARBALL) $(FS_GET_STATS) \
547                 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
548                 $(INSTALLED_SYSTEMTARBALL_TARGET)
549 endef
550
551 system_tar := $(PRODUCT_OUT)/system.tar
552 INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2
553 $(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
554 $(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
555         $(build-systemtarball-target)
556
557 .PHONY: systemtarball-nodeps
558 systemtarball-nodeps: $(FS_GET_STATS) \
559                       $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
560         $(build-systemtarball-target)
561
562 .PHONY: stnod
563 stnod: systemtarball-nodeps
564
565
566 # -----------------------------------------------------------------
567 # data partition image
568 INTERNAL_USERDATAIMAGE_FILES := \
569         $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
570
571 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
572 ## Generate an ext2 image
573 define build-userdataimage-target
574     $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
575     @mkdir -p $(TARGET_OUT_DATA)
576     $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,)
577     $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
578 endef
579
580 else # TARGET_USERIMAGES_USE_EXT2 != true
581
582 ## Generate a yaffs2 image
583 define build-userdataimage-target
584     $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
585     @mkdir -p $(TARGET_OUT_DATA)
586     $(hide) $(MKYAFFS2) -f $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
587     $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
588 endef
589 endif # TARGET_USERIMAGES_USE_EXT2
590
591 BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
592
593 # We just build this directly to the install location.
594 INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
595 $(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \
596                                    $(INTERNAL_USERDATAIMAGE_FILES)
597         $(build-userdataimage-target)
598
599 .PHONY: userdataimage-nodeps
600 userdataimage-nodeps: $(INTERNAL_MKUSERFS)
601         $(build-userdataimage-target)
602
603 #######
604 ## data partition tarball
605 define build-userdatatarball-target
606     $(call pretty,"Target userdata fs tarball: " \
607                   "$(INSTALLED_USERDATATARBALL_TARGET)")
608     $(MKTARBALL) $(FS_GET_STATS) \
609                 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
610                 $(INSTALLED_USERDATATARBALL_TARGET)
611 endef
612
613 userdata_tar := $(PRODUCT_OUT)/userdata.tar
614 INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
615 $(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
616 $(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
617         $(build-userdatatarball-target)
618
619 .PHONY: userdatatarball-nodeps
620 userdatatarball-nodeps: $(FS_GET_STATS)
621         $(build-userdatatarball-target)
622
623
624 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
625 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
626
627 # -----------------------------------------------------------------
628 # Recovery image
629 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
630
631 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
632 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
633 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
634 recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
635 recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
636 recovery_resources_common := $(call include-path-for, recovery)/res
637 recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
638 recovery_resource_deps := $(shell find $(recovery_resources_common) \
639   $(recovery_resources_private) -type f)
640
641 ifeq ($(recovery_resources_private),)
642   $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
643 endif
644
645 INTERNAL_RECOVERYIMAGE_ARGS := \
646         $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
647         --kernel $(recovery_kernel) \
648         --ramdisk $(recovery_ramdisk)
649
650 # Assumes this has already been stripped
651 ifdef BOARD_KERNEL_CMDLINE
652   INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
653 endif
654 ifdef BOARD_KERNEL_BASE
655   INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
656 endif
657
658 # Keys authorized to sign OTA packages this build will accept.  The
659 # build always uses test-keys for this; release packaging tools will
660 # substitute other keys for this one.
661 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
662
663 # Generate a file containing the keys that will be read by the
664 # recovery binary.
665 RECOVERY_INSTALL_OTA_KEYS := \
666         $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
667 DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
668 $(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
669 $(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
670         @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
671         @rm -rf $@
672         @mkdir -p $(dir $@)
673         java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
674
675 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \
676                 $(INSTALLED_RAMDISK_TARGET) \
677                 $(INSTALLED_BOOTIMAGE_TARGET) \
678                 $(recovery_binary) \
679                 $(recovery_initrc) $(recovery_kernel) \
680                 $(INSTALLED_2NDBOOTLOADER_TARGET) \
681                 $(recovery_build_prop) $(recovery_resource_deps) \
682                 $(RECOVERY_INSTALL_OTA_KEYS)
683         @echo ----- Making recovery image ------
684         rm -rf $(TARGET_RECOVERY_OUT)
685         mkdir -p $(TARGET_RECOVERY_OUT)
686         mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
687         mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
688         mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
689         echo Copying baseline ramdisk...
690         cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
691         echo Modifying ramdisk contents...
692         cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
693         cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
694         cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
695         $(foreach item,$(recovery_resources_private), \
696           cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
697         cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
698         cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
699                 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
700         $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | gzip > $(recovery_ramdisk)
701         $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
702         @echo ----- Made recovery image -------- $@
703         $(hide) $(call assert-max-file-size,$@,$(BOARD_RECOVERYIMAGE_MAX_SIZE))
704
705 else
706 INSTALLED_RECOVERYIMAGE_TARGET :=
707 endif
708
709 .PHONY: recoveryimage
710 recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
711
712 # -----------------------------------------------------------------
713 # bring in the installer image generation defines if necessary
714 ifeq ($(TARGET_USE_DISKINSTALLER),true)
715 include bootable/diskinstaller/config.mk
716 endif
717
718 # -----------------------------------------------------------------
719 # OTA update package
720 name := $(TARGET_PRODUCT)
721 ifeq ($(TARGET_BUILD_TYPE),debug)
722   name := $(name)_debug
723 endif
724 name := $(name)-ota-$(FILE_NAME_TAG)
725
726 INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
727 INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota)
728
729 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
730 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
731 INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img
732 else
733 INTERNAL_OTA_RECOVERYIMAGE_TARGET :=
734 endif
735 INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script
736
737 # Sign OTA packages with the test key by default.
738 # Actual product deliverables will be re-signed by hand.
739 private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8
740 certificate := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
741 $(INTERNAL_OTA_PACKAGE_TARGET): $(private_key) $(certificate) $(SIGNAPK_JAR)
742 $(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_PRIVATE_KEY := $(private_key)
743 $(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_CERTIFICATE := $(certificate)
744
745 # Depending on INSTALLED_SYSTEMIMAGE guarantees that SYSTEMIMAGE_SOURCE_DIR
746 # is up-to-date.  We use jar instead of zip so that we can use the -C
747 # switch to avoid cd-ing all over the place.
748 # TODO: Make our own jar-creation tool to avoid all these shenanigans.
749 $(INTERNAL_OTA_PACKAGE_TARGET): \
750                 $(INTERNAL_OTA_SCRIPT_TARGET) \
751                 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET) \
752                 $(INSTALLED_BOOTIMAGE_TARGET) \
753                 $(INSTALLED_RADIOIMAGE_TARGET) \
754                 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
755                 $(INSTALLED_SYSTEMIMAGE)
756         @echo "Package OTA: $@"
757         $(hide) rm -rf $@
758         $(hide) jar cf $@ \
759                 $(foreach item, \
760                         $(INSTALLED_BOOTIMAGE_TARGET) \
761                         $(INSTALLED_RADIOIMAGE_TARGET) \
762                         $(INSTALLED_ANDROID_INFO_TXT_TARGET), \
763                     -C $(dir $(item)) $(notdir $(item))) \
764                     -C $(INTERNAL_OTA_INTERMEDIATES_DIR) .
765         $(hide) find $(SYSTEMIMAGE_SOURCE_DIR) -type f -print | \
766                 sed 's|^$(dir $(SYSTEMIMAGE_SOURCE_DIR))|-C & |' | \
767                 xargs jar uf $@
768         $(hide) if jar tf $@ | egrep '.{65}' >&2; then \
769                     echo "Path too long (>64 chars) for OTA update" >&2; \
770                     exit 1; \
771                 fi
772         $(sign-package)
773
774 $(INTERNAL_OTA_SCRIPT_TARGET): \
775                 $(HOST_OUT_EXECUTABLES)/make-update-script \
776                 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
777                 $(INSTALLED_SYSTEMIMAGE)
778         @mkdir -p $(dir $@)
779         @rm -rf $@
780         @echo "Update script: $@"
781         $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \
782                 $< $(SYSTEMIMAGE_SOURCE_DIR) \
783                    $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
784                 > $@
785
786 ifneq (,$(INTERNAL_OTA_RECOVERYIMAGE_TARGET))
787 # This copy is so recovery.img can be in /system within the OTA package.
788 # That way it gets installed into the system image, which in turn installs it.
789 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ACP)
790         @mkdir -p $(dir $@)
791         $(hide) $(ACP) $< $@
792 endif
793
794 .PHONY: otapackage
795 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
796
797 # Keys authorized to sign OTA packages this build will accept.  The
798 # build always uses test-keys for this; release packaging tools will
799 # substitute other keys for this one.
800 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
801
802 # Build a keystore with the authorized keys in it.
803 # java/android/android/server/checkin/UpdateVerifier.java uses this.
804 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
805 $(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS)
806         $(hide) rm -f $@
807         $(hide) mkdir -p $(dir $@)
808         zip -qj $@ $(OTA_PUBLIC_KEYS)
809
810 # The device does not support JKS.
811 # $(hide) for f in $(OTA_PUBLIC_KEYS); do \
812 #   echo "keytool: $@ <= $$f" && \
813 #   keytool -keystore $@ -storepass $(notdir $@) -noprompt \
814 #           -import -file $$f -alias $(notdir $$f) || exit 1; \
815 # done
816
817 # -----------------------------------------------------------------
818 # A zip of the directories that map to the target filesystem.
819 # This zip can be used to create an OTA package or filesystem image
820 # as a post-build step.
821 #
822 name := $(TARGET_PRODUCT)
823 ifeq ($(TARGET_BUILD_TYPE),debug)
824   name := $(name)_debug
825 endif
826 name := $(name)-target_files-$(FILE_NAME_TAG)
827
828 intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
829 BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
830 $(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
831 $(BUILT_TARGET_FILES_PACKAGE): \
832                 zip_root := $(intermediates)/$(name)
833
834 # $(1): Directory to copy
835 # $(2): Location to copy it to
836 # The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
837 define package_files-copy-root
838   if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
839     mkdir -p $(2) && \
840     $(ACP) -rd $(strip $(1))/* $(2); \
841   fi
842 endef
843
844 built_ota_tools := \
845         $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
846         $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq
847 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
848
849 # Depending on the various images guarantees that the underlying
850 # directories are up-to-date.
851 $(BUILT_TARGET_FILES_PACKAGE): \
852                 $(INTERNAL_OTA_SCRIPT_TARGET) \
853                 $(INSTALLED_BOOTIMAGE_TARGET) \
854                 $(INSTALLED_RADIOIMAGE_TARGET) \
855                 $(INSTALLED_RECOVERYIMAGE_TARGET) \
856                 $(BUILT_SYSTEMIMAGE) \
857                 $(INSTALLED_USERDATAIMAGE_TARGET) \
858                 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
859                 $(INTERNAL_OTA_SCRIPT_TARGET) \
860                 $(built_ota_tools) \
861                 $(APKCERTS_FILE) \
862                 | $(ACP)
863         @echo "Package target files: $@"
864         $(hide) rm -rf $@ $(zip_root)
865         $(hide) mkdir -p $(dir $@) $(zip_root)
866         @# Components of the recovery image
867         $(hide) mkdir -p $(zip_root)/RECOVERY
868         $(hide) $(call package_files-copy-root, \
869                 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
870 ifdef INSTALLED_KERNEL_TARGET
871         $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
872 endif
873 ifdef INSTALLED_2NDBOOTLOADER_TARGET
874         $(hide) $(ACP) \
875                 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
876 endif
877 ifdef BOARD_KERNEL_CMDLINE
878         $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
879 endif
880         @# Components of the boot image
881         $(hide) mkdir -p $(zip_root)/BOOT
882         $(hide) $(call package_files-copy-root, \
883                 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
884 ifdef INSTALLED_KERNEL_TARGET
885         $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
886 endif
887 ifdef INSTALLED_2NDBOOTLOADER_TARGET
888         $(hide) $(ACP) \
889                 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
890 endif
891 ifdef BOARD_KERNEL_CMDLINE
892         $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
893 endif
894 ifdef INSTALLED_RADIOIMAGE_TARGET
895         @# The radio image
896         $(hide) mkdir -p $(zip_root)/RADIO
897         $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image
898 endif
899         @# Contents of the system image
900         $(hide) $(call package_files-copy-root, \
901                 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
902         @# Contents of the data image
903         $(hide) $(call package_files-copy-root, \
904                 $(TARGET_OUT_DATA),$(zip_root)/DATA)
905         @# Extra contents of the OTA package
906         $(hide) mkdir -p $(zip_root)/OTA/bin
907         $(hide) $(call package_files-copy-root, \
908                 $(INTERNAL_OTA_INTERMEDIATES_DIR),$(zip_root)/OTA)
909         $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
910         $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
911         @# Files that don't end up in any images, but are necessary to
912         @# build them.
913         $(hide) mkdir -p $(zip_root)/META
914         $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
915         $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
916         @# Zip everything up, preserving symlinks
917         $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
918
919 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
920
921 # -----------------------------------------------------------------
922 # installed file list
923 # Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
924 # gets the DexOpt one if we're doing that.
925 INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
926 $(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
927         @echo Installed file list: $@
928         @mkdir -p $(dir $@)
929         @rm -f $@
930         $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
931
932 .PHONY: installed-file-list
933 installed-file-list: $(INSTALLED_FILES_FILE)
934 $(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
935 $(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
936
937 # -----------------------------------------------------------------
938 # A zip of the tests that are built when running "make tests".
939 # This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
940 # only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
941 #
942 name := $(TARGET_PRODUCT)
943 ifeq ($(TARGET_BUILD_TYPE),debug)
944   name := $(name)_debug
945 endif
946 name := $(name)-tests-$(FILE_NAME_TAG)
947
948 intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
949 BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
950 $(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
951 $(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
952
953 # Depending on the images guarantees that the underlying
954 # directories are up-to-date.
955 $(BUILT_TESTS_ZIP_PACKAGE): \
956                 $(BUILT_SYSTEMIMAGE) \
957                 $(INSTALLED_USERDATAIMAGE_TARGET) \
958                 | $(ACP)
959         @echo "Package test files: $@"
960         $(hide) rm -rf $@ $(zip_root)
961         $(hide) mkdir -p $(dir $@) $(zip_root)
962         @# Some parts of the system image
963         $(hide) $(call package_files-copy-root, \
964                 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
965         $(hide) $(call package_files-copy-root, \
966                 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
967         $(hide) $(call package_files-copy-root, \
968                 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
969                 $(zip_root)/SYSTEM/framework)
970         $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
971         @# Contents of the data image
972         $(hide) $(call package_files-copy-root, \
973                 $(TARGET_OUT_DATA),$(zip_root)/DATA)
974         $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
975
976 tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
977
978 # -----------------------------------------------------------------
979 # A zip of the symbols directory.  Keep the full paths to make it
980 # more obvious where these files came from.
981 #
982 name := $(TARGET_PRODUCT)
983 ifeq ($(TARGET_BUILD_TYPE),debug)
984   name := $(name)_debug
985 endif
986 name := $(name)-symbols-$(FILE_NAME_TAG)
987
988 SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
989 $(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
990         @echo "Package symbols: $@"
991         $(hide) rm -rf $@
992         $(hide) mkdir -p $(dir $@)
993         $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
994
995 # -----------------------------------------------------------------
996 # A zip of the Android Apps. Not keeping full path so that we don't
997 # include product names when distributing
998 #
999 name := $(TARGET_PRODUCT)
1000 ifeq ($(TARGET_BUILD_TYPE),debug)
1001   name := $(name)_debug
1002 endif
1003 name := $(name)-apps-$(FILE_NAME_TAG)
1004
1005 APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1006 $(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1007         @echo "Package apps: $@"
1008         $(hide) rm -rf $@
1009         $(hide) mkdir -p $(dir $@)
1010         $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1011
1012 endif   # TARGET_SIMULATOR != true
1013
1014 # -----------------------------------------------------------------
1015 # dalvik something
1016 .PHONY: dalvikfiles
1017 dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1018
1019 # -----------------------------------------------------------------
1020 # The update package
1021
1022 INTERNAL_UPDATE_PACKAGE_FILES += \
1023                 $(INSTALLED_BOOTIMAGE_TARGET) \
1024                 $(INSTALLED_RECOVERYIMAGE_TARGET) \
1025                 $(INSTALLED_SYSTEMIMAGE) \
1026                 $(INSTALLED_USERDATAIMAGE_TARGET) \
1027                 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
1028
1029 ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),)
1030
1031 name := $(TARGET_PRODUCT)
1032 ifeq ($(TARGET_BUILD_TYPE),debug)
1033   name := $(name)_debug
1034 endif
1035 name := $(name)-img-$(FILE_NAME_TAG)
1036
1037 INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1038
1039 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES)
1040         @echo "Package: $@"
1041         $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES)
1042
1043 else
1044 INTERNAL_UPDATE_PACKAGE_TARGET :=
1045 endif
1046
1047 # -----------------------------------------------------------------
1048 # The emulator package
1049
1050 ifneq ($(TARGET_SIMULATOR),true)
1051
1052 INTERNAL_EMULATOR_PACKAGE_FILES += \
1053         $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1054         prebuilt/android-arm/kernel/kernel-qemu \
1055         $(INSTALLED_RAMDISK_TARGET) \
1056                 $(INSTALLED_SYSTEMIMAGE) \
1057                 $(INSTALLED_USERDATAIMAGE_TARGET)
1058
1059 name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1060
1061 INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1062
1063 $(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1064         @echo "Package: $@"
1065         $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1066
1067 endif
1068
1069 # -----------------------------------------------------------------
1070 # The pdk package (Platform Development Kit)
1071
1072 ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1073   include development/pdk/Pdk.mk
1074 endif
1075
1076 # -----------------------------------------------------------------
1077 # The SDK
1078
1079 ifneq ($(TARGET_SIMULATOR),true)
1080
1081 # The SDK includes host-specific components, so it belongs under HOST_OUT.
1082 sdk_dir := $(HOST_OUT)/sdk
1083
1084 # Build a name that looks like:
1085 #
1086 #     linux-x86   --> android-sdk_12345_linux-x86
1087 #     darwin-x86  --> android-sdk_12345_mac-x86
1088 #     windows-x86 --> android-sdk_12345_windows
1089 #
1090 sdk_name := android-sdk_$(FILE_NAME_TAG)
1091 ifeq ($(HOST_OS),darwin)
1092   INTERNAL_SDK_HOST_OS_NAME := mac
1093 else
1094   INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
1095 endif
1096 ifneq ($(HOST_OS),windows)
1097   INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
1098 endif
1099 sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
1100
1101 sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1102
1103 ATREE_FILES :=
1104 -include $(sdk_dep_file)
1105
1106 # if we don't have a real list, then use "everything"
1107 ifeq ($(strip $(ATREE_FILES)),)
1108 ATREE_FILES := \
1109         $(ALL_PREBUILT) \
1110         $(ALL_COPIED_HEADERS) \
1111         $(ALL_GENERATED_SOURCES) \
1112         $(ALL_DEFAULT_INSTALLED_MODULES) \
1113         $(INSTALLED_RAMDISK_TARGET) \
1114         $(ALL_DOCS) \
1115         $(ALL_SDK_FILES)
1116 endif
1117
1118 atree_dir := development/build
1119
1120 sdk_atree_files := \
1121         $(atree_dir)/sdk.exclude.atree \
1122         $(atree_dir)/sdk.atree \
1123         $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree
1124
1125 deps := \
1126         $(target_notice_file_txt) \
1127         $(tools_notice_file_txt) \
1128         $(OUT_DOCS)/offline-sdk-timestamp \
1129         $(INTERNAL_UPDATE_PACKAGE_TARGET) \
1130         $(INSTALLED_SDK_BUILD_PROP_TARGET) \
1131         $(ATREE_FILES) \
1132         $(atree_dir)/sdk.atree \
1133         $(HOST_OUT_EXECUTABLES)/atree \
1134     $(HOST_OUT_EXECUTABLES)/line_endings
1135
1136 INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1137 $(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1138 $(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1139 $(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1140 $(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1141
1142 # Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1143 #
1144 #SDK_GNU_ERROR := true
1145
1146 $(INTERNAL_SDK_TARGET): $(deps)
1147         @echo "Package SDK: $@"
1148         $(hide) rm -rf $(PRIVATE_DIR) $@
1149         $(hide) for f in $(target_gnu_MODULES); do \
1150           if [ -f $$f ]; then \
1151             echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1152                 including GNU target $$f >&2; \
1153             FAIL=$(SDK_GNU_ERROR); \
1154           fi; \
1155         done; \
1156         if [ $$FAIL ]; then exit 1; fi
1157         $(hide) ( \
1158                 $(HOST_OUT_EXECUTABLES)/atree \
1159                 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1160                         -m $(PRIVATE_DEP_FILE) \
1161                         -I . \
1162                         -I $(PRODUCT_OUT) \
1163                         -I $(HOST_OUT) \
1164                         -I $(TARGET_COMMON_OUT_ROOT) \
1165                         -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1166                         -o $(PRIVATE_DIR) && \
1167                 cp -f $(target_notice_file_txt) \
1168                                 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1169                 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1170                 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
1171                 development/tools/scripts/sdk_clean.sh $(PRIVATE_DIR) && \
1172                 chmod -R ug+rwX $(PRIVATE_DIR) && \
1173                 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1174         ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1175
1176 endif # !simulator
1177
1178 # -----------------------------------------------------------------
1179 # Findbugs
1180 INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1181 INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1182 $(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1183         @echo UnionBugs: $@
1184         $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1185         > $@
1186 $(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1187         @echo ConvertXmlToText: $@
1188         $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1189         $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1190
1191 # -----------------------------------------------------------------
1192 # Findbugs
1193
1194 # -----------------------------------------------------------------
1195 # These are some additional build tasks that need to be run.
1196 include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))