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