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