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