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