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