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