blob: 8bd5351a6f9075b36b6303172219b55264ad7f72 [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".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080017# The filter part means "only eval the copy-one-file rule if this
18# src:dest pair is the first one to match %:dest"
The Android Open Source Project88b60792009-03-03 19:28:42 -080019$(foreach cf,$(PRODUCT_COPY_FILES), \
Joe Onorato64d85d02009-04-09 19:31:12 -070020 $(eval _src := $(call word-colon,1,$(cf))) \
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080021 $(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)) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080026 )
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 "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070049 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
50 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -080051
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
The Android Open Source Project88b60792009-03-03 19:28:42 -080068BUILD_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)))
Doug Zongker135a1202010-09-15 13:02:12 -070076 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -080077endif
78ifneq ($(words $(BUILD_FINGERPRINT)),1)
79 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
80endif
81
Sriram Raman7b641242009-03-24 22:40:59 -070082# 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
The Android Open Source Project88b60792009-03-03 19:28:42 -080098# 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))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700124 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800125 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)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700133 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134 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)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700138 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800139 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140 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 "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700149 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
150 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800151
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))
Ying Wangefb21682010-07-23 16:42:13 -0700209ifneq ($(TARGET_BUILD_APPS),)
210# We don't need to really build all the modules for apps_only build.
211$(APKCERTS_FILE):
212else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800213$(APKCERTS_FILE): $(all_built_packages)
Ying Wangefb21682010-07-23 16:42:13 -0700214endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800215 @echo APK certs list: $@
216 @mkdir -p $(dir $@)
217 @rm -f $@
218 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800219 $(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)"' >> $@;))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800224
225.PHONY: apkcerts-list
226apkcerts-list: $(APKCERTS_FILE)
227
Ying Wangefb21682010-07-23 16:42:13 -0700228$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
229
The Android Open Source Project88b60792009-03-03 19:28:42 -0800230# -----------------------------------------------------------------
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
Doug Zongker8678df42009-06-15 14:30:14 -0700244# -----------------------------------------------------------------
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
The Android Open Source Project88b60792009-03-03 19:28:42 -0800253# Rules that need to be present for the simulator, even
254# if they don't do anything.
255.PHONY: systemimage
256systemimage:
257
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800258# -----------------------------------------------------------------
259
260.PHONY: event-log-tags
261
Joe Onoratob7510532010-07-14 10:22:54 -0700262# 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
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800278event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800279
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)
Joe Onoratob7510532010-07-14 10:22:54 -0700288$(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)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800290 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700291 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800292
293event-log-tags: $(event_log_tags_file)
294
295ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
296
Joe Onoratob7510532010-07-14 10:22:54 -0700297
The Android Open Source Project88b60792009-03-03 19:28:42 -0800298ifneq ($(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
Joe Onorato64d85d02009-04-09 19:31:12 -0700312BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
313
314# We just build this directly to the install location.
315INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700316$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800317 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700318 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800319
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
Dima Zavin1e0847c2009-05-07 19:43:08 -0700337BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
338ifdef BOARD_KERNEL_BASE
339 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
340endif
341
Ying Wangffff0022010-08-23 12:56:25 -0700342BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
343ifdef BOARD_KERNEL_PAGESIZE
344 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
345endif
346
The Android Open Source Project88b60792009-03-03 19:28:42 -0800347INSTALLED_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 $@
Doug Zongkered96e882009-08-26 09:37:07 -0700362 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800363endif # 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.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700510$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700511 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800512installed_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)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700515
516# if we've been run my mm, mmm, etc, don't reinstall this every time
517ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800518ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700519endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800520
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
Doug Zongker8678df42009-06-15 14:30:14 -0700532# -----------------------------------------------------------------
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)
Doug Zongker37c0e272009-06-15 15:36:16 -0700540$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700541 $(hide) rm -f $@
542 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700543 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700544
545.PHONY: otacerts
546otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
547
548
The Android Open Source Project88b60792009-03-03 19:28:42 -0800549# #################################################################
550# Targets for user images
551# #################################################################
552
Ying Wang065521b2010-08-23 11:34:40 -0700553INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800554ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Ying Wang065521b2010-08-23 11:34:40 -0700555INTERNAL_USERIMAGES_USE_EXT := true
556INTERNAL_USERIMAGES_EXT_VARIANT := ext2
The Android Open Source Project88b60792009-03-03 19:28:42 -0800557else
Ying Wang065521b2010-08-23 11:34:40 -0700558ifeq ($(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)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800585endif
586
587# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700588# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700589
590# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700591ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700592
Doug Zongker4647f122009-07-02 09:00:54 -0700593INSTALLED_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)
Doug Zongker258bf462010-09-20 18:04:41 -0700604recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700605
606ifeq ($(recovery_resources_private),)
607 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
608endif
609
Doug Zongker258bf462010-09-20 18:04:41 -0700610ifeq ($(recovery_fstab),)
611 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
612endif
613
Doug Zongker4647f122009-07-02 09:00:54 -0700614INTERNAL_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
Ying Wang4de6b5b2010-08-25 14:29:34 -0700626BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
627ifdef BOARD_KERNEL_PAGESIZE
628 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
629endif
Doug Zongker4647f122009-07-02 09:00:54 -0700630
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) \
Doug Zongkerc0434ac2010-09-21 14:25:51 -0700655 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700656 $(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)
Doug Zongkerc19a8d52010-07-01 15:30:11 -0700665 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700666 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)/)
Doug Zongker258bf462010-09-20 18:04:41 -0700672 $(foreach item,$(recovery_fstab), \
673 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700674 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 -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700680 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700681
682else
683INSTALLED_RECOVERYIMAGE_TARGET :=
684endif
685
686.PHONY: recoveryimage
687recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
688
Dima Zavin11818982010-02-05 13:34:34 -0800689ifneq ($(BOARD_NAND_PAGE_SIZE),)
690mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
691else
692mkyaffs2_extra_flags :=
693endif
694
695
Doug Zongker4647f122009-07-02 09:00:54 -0700696# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700697# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800698#
Ying Wang02352372010-09-27 10:37:25 -0700699systemimage_intermediates := \
700 $(call intermediates-dir-for,PACKAGING,systemimage)
701BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
The Android Open Source Project88b60792009-03-03 19:28:42 -0800702
703INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
704 $(ALL_PREBUILT) \
705 $(ALL_COPIED_HEADERS) \
706 $(ALL_GENERATED_SOURCES) \
707 $(ALL_DEFAULT_INSTALLED_MODULES))
708
Ying Wang065521b2010-08-23 11:34:40 -0700709ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800710## generate an ext2 image
711# $(1): output file
712define build-systemimage-target
713 @echo "Target system fs image: $(1)"
Ying Wang065521b2010-08-23 11:34:40 -0700714 $(call build-userimage-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800715endef
716
Ying Wang065521b2010-08-23 11:34:40 -0700717else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800718
719## generate a yaffs2 image
720# $(1): output file
721define build-systemimage-target
722 @echo "Target system fs image: $(1)"
723 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800724 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800725endef
Ying Wang065521b2010-08-23 11:34:40 -0700726endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727
Ying Wang02352372010-09-27 10:37:25 -0700728$(BUILT_SYSTEMIMAGE): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800729 $(call build-systemimage-target,$@)
730
The Android Open Source Project88b60792009-03-03 19:28:42 -0800731INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700732SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733
Doug Zongker73ef8252009-07-23 15:12:53 -0700734# The system partition needs room for the recovery image as well. We
735# now store the recovery image as a binary patch using the boot image
736# as the source (since they are very similar). Generate the patch so
737# we can see how big it's going to be, and include that in the system
738# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700739ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700740intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
741RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
742$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
743 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700744 $(HOST_OUT_EXECUTABLES)/imgdiff \
745 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700746 @echo "Construct recovery from boot"
747 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700748 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700749endif
750
Doug Zongker73ef8252009-07-23 15:12:53 -0700751
752$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800753 @echo "Install system fs image: $@"
754 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700755 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800756
757systemimage: $(INSTALLED_SYSTEMIMAGE)
758
759.PHONY: systemimage-nodeps snod
760systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Ying Wang065521b2010-08-23 11:34:40 -0700761 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800762 @echo "make $@: ignoring dependencies"
763 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700764 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800765
766#######
767## system tarball
768define build-systemtarball-target
769 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
770 $(MKTARBALL) $(FS_GET_STATS) \
771 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
772 $(INSTALLED_SYSTEMTARBALL_TARGET)
773endef
774
775system_tar := $(PRODUCT_OUT)/system.tar
776INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2
777$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
778$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
779 $(build-systemtarball-target)
780
781.PHONY: systemtarball-nodeps
782systemtarball-nodeps: $(FS_GET_STATS) \
783 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
784 $(build-systemtarball-target)
785
786.PHONY: stnod
787stnod: systemtarball-nodeps
788
789
790# -----------------------------------------------------------------
791# data partition image
792INTERNAL_USERDATAIMAGE_FILES := \
793 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
794
Ying Wang065521b2010-08-23 11:34:40 -0700795ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
796## Generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800797define build-userdataimage-target
798 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
799 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang065521b2010-08-23 11:34:40 -0700800 $(call build-userimage-ext-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Doug Zongkered96e882009-08-26 09:37:07 -0700801 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800802endef
803
Ying Wang065521b2010-08-23 11:34:40 -0700804else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800805
806## Generate a yaffs2 image
807define build-userdataimage-target
808 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
809 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800810 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700811 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812endef
Ying Wang065521b2010-08-23 11:34:40 -0700813endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800814
Joe Onorato64d85d02009-04-09 19:31:12 -0700815BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
816
817# We just build this directly to the install location.
818INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Ying Wang065521b2010-08-23 11:34:40 -0700819$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800820 $(INTERNAL_USERDATAIMAGE_FILES)
821 $(build-userdataimage-target)
822
823.PHONY: userdataimage-nodeps
Ying Wang065521b2010-08-23 11:34:40 -0700824userdataimage-nodeps: $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800825 $(build-userdataimage-target)
826
827#######
828## data partition tarball
829define build-userdatatarball-target
830 $(call pretty,"Target userdata fs tarball: " \
831 "$(INSTALLED_USERDATATARBALL_TARGET)")
832 $(MKTARBALL) $(FS_GET_STATS) \
833 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
834 $(INSTALLED_USERDATATARBALL_TARGET)
835endef
836
837userdata_tar := $(PRODUCT_OUT)/userdata.tar
838INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
839$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
840$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
841 $(build-userdatatarball-target)
842
843.PHONY: userdatatarball-nodeps
844userdatatarball-nodeps: $(FS_GET_STATS)
845 $(build-userdatatarball-target)
846
847
The Android Open Source Project88b60792009-03-03 19:28:42 -0800848# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849# bring in the installer image generation defines if necessary
850ifeq ($(TARGET_USE_DISKINSTALLER),true)
851include bootable/diskinstaller/config.mk
852endif
853
854# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700855# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800856
Ying Wang06898662010-06-17 17:52:18 -0700857OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700858 $(HOST_OUT_EXECUTABLES)/mkbootfs \
859 $(HOST_OUT_EXECUTABLES)/mkbootimg \
860 $(HOST_OUT_EXECUTABLES)/fs_config \
861 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
862 $(HOST_OUT_EXECUTABLES)/zipalign \
863 $(HOST_OUT_EXECUTABLES)/aapt \
864 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700865 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700866 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
867 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar
The Android Open Source Project88b60792009-03-03 19:28:42 -0800868
Ying Wang06898662010-06-17 17:52:18 -0700869.PHONY: otatools
870otatools: $(OTATOOLS)
871
The Android Open Source Project88b60792009-03-03 19:28:42 -0800872# -----------------------------------------------------------------
873# A zip of the directories that map to the target filesystem.
874# This zip can be used to create an OTA package or filesystem image
875# as a post-build step.
876#
877name := $(TARGET_PRODUCT)
878ifeq ($(TARGET_BUILD_TYPE),debug)
879 name := $(name)_debug
880endif
881name := $(name)-target_files-$(FILE_NAME_TAG)
882
883intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
884BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
885$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
886$(BUILT_TARGET_FILES_PACKAGE): \
887 zip_root := $(intermediates)/$(name)
888
889# $(1): Directory to copy
890# $(2): Location to copy it to
891# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
892define package_files-copy-root
893 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
894 mkdir -p $(2) && \
895 $(ACP) -rd $(strip $(1))/* $(2); \
896 fi
897endef
898
899built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700900 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700901 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700902 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
903 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800904$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
905
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700906$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
907
Doug Zongkerc18736b2009-09-30 09:20:32 -0700908ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
909# default to common dir for device vendor
910$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
911else
912$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
913endif
914
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915# Depending on the various images guarantees that the underlying
916# directories are up-to-date.
917$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800918 $(INSTALLED_BOOTIMAGE_TARGET) \
919 $(INSTALLED_RADIOIMAGE_TARGET) \
920 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700921 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800922 $(INSTALLED_USERDATAIMAGE_TARGET) \
923 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800924 $(built_ota_tools) \
925 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700926 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800927 | $(ACP)
928 @echo "Package target files: $@"
929 $(hide) rm -rf $@ $(zip_root)
930 $(hide) mkdir -p $(dir $@) $(zip_root)
931 @# Components of the recovery image
932 $(hide) mkdir -p $(zip_root)/RECOVERY
933 $(hide) $(call package_files-copy-root, \
934 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
935ifdef INSTALLED_KERNEL_TARGET
936 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
937endif
938ifdef INSTALLED_2NDBOOTLOADER_TARGET
939 $(hide) $(ACP) \
940 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
941endif
942ifdef BOARD_KERNEL_CMDLINE
943 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
944endif
Doug Zongker38a649f2009-06-17 09:07:09 -0700945ifdef BOARD_KERNEL_BASE
946 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
947endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700948ifdef BOARD_KERNEL_PAGESIZE
949 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
950endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800951 @# Components of the boot image
952 $(hide) mkdir -p $(zip_root)/BOOT
953 $(hide) $(call package_files-copy-root, \
954 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
955ifdef INSTALLED_KERNEL_TARGET
956 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
957endif
958ifdef INSTALLED_2NDBOOTLOADER_TARGET
959 $(hide) $(ACP) \
960 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
961endif
962ifdef BOARD_KERNEL_CMDLINE
963 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
964endif
Doug Zongker38a649f2009-06-17 09:07:09 -0700965ifdef BOARD_KERNEL_BASE
966 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
967endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700968ifdef BOARD_KERNEL_PAGESIZE
969 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
970endif
Doug Zongkere01100c2009-06-19 17:12:18 -0700971 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
972 mkdir -p $(zip_root)/RADIO; \
973 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974 @# Contents of the system image
975 $(hide) $(call package_files-copy-root, \
976 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
977 @# Contents of the data image
978 $(hide) $(call package_files-copy-root, \
979 $(TARGET_OUT_DATA),$(zip_root)/DATA)
980 @# Extra contents of the OTA package
981 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -0800982 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
983 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -0700984 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -0800985 @# build them.
986 $(hide) mkdir -p $(zip_root)/META
987 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -0700988 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -0700989 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerc19a8d52010-07-01 15:30:11 -0700990ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -0700991 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerc19a8d52010-07-01 15:30:11 -0700992endif
993ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
994 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
995endif
996ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
997 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
998endif
999ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1000 $(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
1001endif
1002ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1003 $(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
1004endif
Doug Zongker37974732010-09-16 17:44:38 -07001005 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001006ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001007 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001008endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001009 @# Zip everything up, preserving symlinks
1010 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001011 @# Run fs_config on all the system files in the zip, and save the output
1012 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1013 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1014
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015
1016target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1017
1018# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -07001019# OTA update package
Doug Zongker367910f2009-06-15 18:56:51 -07001020
1021ifneq ($(TARGET_SIMULATOR),true)
1022ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001023ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001024ifneq ($(TARGET_NO_KERNEL),true)
Doug Zongker367910f2009-06-15 18:56:51 -07001025
Doug Zongker8678df42009-06-15 14:30:14 -07001026name := $(TARGET_PRODUCT)
1027ifeq ($(TARGET_BUILD_TYPE),debug)
1028 name := $(name)_debug
1029endif
1030name := $(name)-ota-$(FILE_NAME_TAG)
1031
1032INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1033
1034$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1035
Ying Wang06898662010-06-17 17:52:18 -07001036$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001037 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001038 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001039 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001040 -k $(KEY_CERT_PAIR) \
1041 $(BUILT_TARGET_FILES_PACKAGE) $@
1042
1043.PHONY: otapackage
1044otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1045
Ying Wangfb0a3472010-08-25 16:06:06 -07001046endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001047endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001048endif # TARGET_PRODUCT != sdk
1049endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001050
1051# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001052# installed file list
1053# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1054# gets the DexOpt one if we're doing that.
1055INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1056$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1057 @echo Installed file list: $@
1058 @mkdir -p $(dir $@)
1059 @rm -f $@
1060 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1061
1062.PHONY: installed-file-list
1063installed-file-list: $(INSTALLED_FILES_FILE)
1064$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
Joe Onorato03fbe402009-04-13 08:31:16 -07001065$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001066
1067# -----------------------------------------------------------------
1068# A zip of the tests that are built when running "make tests".
1069# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1070# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1071#
1072name := $(TARGET_PRODUCT)
1073ifeq ($(TARGET_BUILD_TYPE),debug)
1074 name := $(name)_debug
1075endif
1076name := $(name)-tests-$(FILE_NAME_TAG)
1077
1078intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1079BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1080$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1081$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1082
1083# Depending on the images guarantees that the underlying
1084# directories are up-to-date.
1085$(BUILT_TESTS_ZIP_PACKAGE): \
1086 $(BUILT_SYSTEMIMAGE) \
1087 $(INSTALLED_USERDATAIMAGE_TARGET) \
1088 | $(ACP)
1089 @echo "Package test files: $@"
1090 $(hide) rm -rf $@ $(zip_root)
1091 $(hide) mkdir -p $(dir $@) $(zip_root)
1092 @# Some parts of the system image
1093 $(hide) $(call package_files-copy-root, \
1094 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1095 $(hide) $(call package_files-copy-root, \
1096 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1097 $(hide) $(call package_files-copy-root, \
1098 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1099 $(zip_root)/SYSTEM/framework)
1100 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1101 @# Contents of the data image
1102 $(hide) $(call package_files-copy-root, \
1103 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1104 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1105
Ying Wang570a0ee2010-09-10 14:39:33 -07001106.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001107tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1108
Ying Wangdb2cb632010-09-14 16:07:56 -07001109# Target needed by tests build
1110.PHONY: tests-build-target
1111tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1112 $(BUILT_USERDATAIMAGE_TARGET)
1113
1114ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1115 $(call dist-for-goals, tests-build-target, \
1116 $(BUILT_TESTS_ZIP_PACKAGE) \
1117 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang570a0ee2010-09-10 14:39:33 -07001118endif
1119
The Android Open Source Project88b60792009-03-03 19:28:42 -08001120# -----------------------------------------------------------------
1121# A zip of the symbols directory. Keep the full paths to make it
1122# more obvious where these files came from.
1123#
1124name := $(TARGET_PRODUCT)
1125ifeq ($(TARGET_BUILD_TYPE),debug)
1126 name := $(name)_debug
1127endif
1128name := $(name)-symbols-$(FILE_NAME_TAG)
1129
1130SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1131$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1132 @echo "Package symbols: $@"
1133 $(hide) rm -rf $@
1134 $(hide) mkdir -p $(dir $@)
1135 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1136
1137# -----------------------------------------------------------------
1138# A zip of the Android Apps. Not keeping full path so that we don't
1139# include product names when distributing
1140#
1141name := $(TARGET_PRODUCT)
1142ifeq ($(TARGET_BUILD_TYPE),debug)
1143 name := $(name)_debug
1144endif
1145name := $(name)-apps-$(FILE_NAME_TAG)
1146
1147APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1148$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1149 @echo "Package apps: $@"
1150 $(hide) rm -rf $@
1151 $(hide) mkdir -p $(dir $@)
1152 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1153
Guang Zhu18b75562010-05-13 16:46:21 -07001154
1155#------------------------------------------------------------------
1156# A zip of emma code coverage meta files. Generated for fully emma
1157# instrumented build.
1158#
1159EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1160$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1161 @echo "Collecting Emma coverage meta files."
1162 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1163 zip -@ -q $@
1164
The Android Open Source Project88b60792009-03-03 19:28:42 -08001165endif # TARGET_SIMULATOR != true
1166
1167# -----------------------------------------------------------------
1168# dalvik something
1169.PHONY: dalvikfiles
1170dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1171
1172# -----------------------------------------------------------------
1173# The update package
1174
Doug Zongker367910f2009-06-15 18:56:51 -07001175ifneq ($(TARGET_SIMULATOR),true)
1176ifneq ($(TARGET_PRODUCT),sdk)
1177
The Android Open Source Project88b60792009-03-03 19:28:42 -08001178name := $(TARGET_PRODUCT)
1179ifeq ($(TARGET_BUILD_TYPE),debug)
1180 name := $(name)_debug
1181endif
1182name := $(name)-img-$(FILE_NAME_TAG)
1183
1184INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1185
Doug Zongker659fc552009-06-23 09:46:33 -07001186ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1187# default to common dir for device vendor
1188$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1189else
1190$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1191endif
1192
Ying Wang06898662010-06-17 17:52:18 -07001193$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001194 @echo "Package: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001195 $(hide) ./build/tools/releasetools/img_from_target_files -v \
Doug Zongker659fc552009-06-23 09:46:33 -07001196 -s $(extensions) \
Doug Zongker602a84e2009-06-18 08:35:12 -07001197 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001198 $(BUILT_TARGET_FILES_PACKAGE) $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001199
Doug Zongker8678df42009-06-15 14:30:14 -07001200.PHONY: updatepackage
1201updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001202
Doug Zongker367910f2009-06-15 18:56:51 -07001203endif # TARGET_PRODUCT != sdk
1204endif # TARGET_SIMULATOR != true
1205
The Android Open Source Project88b60792009-03-03 19:28:42 -08001206# -----------------------------------------------------------------
1207# The emulator package
1208
1209ifneq ($(TARGET_SIMULATOR),true)
1210
1211INTERNAL_EMULATOR_PACKAGE_FILES += \
1212 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1213 prebuilt/android-arm/kernel/kernel-qemu \
1214 $(INSTALLED_RAMDISK_TARGET) \
1215 $(INSTALLED_SYSTEMIMAGE) \
1216 $(INSTALLED_USERDATAIMAGE_TARGET)
1217
1218name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1219
1220INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1221
1222$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1223 @echo "Package: $@"
1224 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1225
1226endif
1227
1228# -----------------------------------------------------------------
1229# The pdk package (Platform Development Kit)
1230
1231ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1232 include development/pdk/Pdk.mk
1233endif
1234
1235# -----------------------------------------------------------------
1236# The SDK
1237
1238ifneq ($(TARGET_SIMULATOR),true)
1239
1240# The SDK includes host-specific components, so it belongs under HOST_OUT.
1241sdk_dir := $(HOST_OUT)/sdk
1242
1243# Build a name that looks like:
1244#
1245# linux-x86 --> android-sdk_12345_linux-x86
1246# darwin-x86 --> android-sdk_12345_mac-x86
1247# windows-x86 --> android-sdk_12345_windows
1248#
1249sdk_name := android-sdk_$(FILE_NAME_TAG)
1250ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001251 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001252else
Joe Onorato03fbe402009-04-13 08:31:16 -07001253 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001254endif
1255ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001256 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001257endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001258sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001259
1260sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1261
1262ATREE_FILES :=
1263-include $(sdk_dep_file)
1264
1265# if we don't have a real list, then use "everything"
1266ifeq ($(strip $(ATREE_FILES)),)
1267ATREE_FILES := \
1268 $(ALL_PREBUILT) \
1269 $(ALL_COPIED_HEADERS) \
1270 $(ALL_GENERATED_SOURCES) \
1271 $(ALL_DEFAULT_INSTALLED_MODULES) \
1272 $(INSTALLED_RAMDISK_TARGET) \
1273 $(ALL_DOCS) \
1274 $(ALL_SDK_FILES)
1275endif
1276
1277atree_dir := development/build
1278
1279sdk_atree_files := \
1280 $(atree_dir)/sdk.exclude.atree \
1281 $(atree_dir)/sdk.atree \
1282 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree
1283
1284deps := \
1285 $(target_notice_file_txt) \
1286 $(tools_notice_file_txt) \
1287 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001288 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001289 $(INSTALLED_SYSTEMIMAGE) \
1290 $(INSTALLED_USERDATAIMAGE_TARGET) \
1291 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001292 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001293 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001294 $(ATREE_FILES) \
1295 $(atree_dir)/sdk.atree \
1296 $(HOST_OUT_EXECUTABLES)/atree \
1297 $(HOST_OUT_EXECUTABLES)/line_endings
1298
1299INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1300$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1301$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1302$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1303$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1304
1305# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1306#
1307#SDK_GNU_ERROR := true
1308
1309$(INTERNAL_SDK_TARGET): $(deps)
1310 @echo "Package SDK: $@"
1311 $(hide) rm -rf $(PRIVATE_DIR) $@
1312 $(hide) for f in $(target_gnu_MODULES); do \
1313 if [ -f $$f ]; then \
1314 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1315 including GNU target $$f >&2; \
1316 FAIL=$(SDK_GNU_ERROR); \
1317 fi; \
1318 done; \
1319 if [ $$FAIL ]; then exit 1; fi
1320 $(hide) ( \
1321 $(HOST_OUT_EXECUTABLES)/atree \
1322 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1323 -m $(PRIVATE_DEP_FILE) \
1324 -I . \
1325 -I $(PRODUCT_OUT) \
1326 -I $(HOST_OUT) \
1327 -I $(TARGET_COMMON_OUT_ROOT) \
1328 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1329 -o $(PRIVATE_DIR) && \
1330 cp -f $(target_notice_file_txt) \
1331 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1332 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1333 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001334 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001335 chmod -R ug+rwX $(PRIVATE_DIR) && \
1336 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1337 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1338
Raphael9ca16282010-04-16 17:50:09 -07001339
1340# Is a Windows SDK requested? If so, we need some definitions from here
1341# in order to find the Linux SDK used to create the Windows one.
1342ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
1343LINUX_SDK_NAME := $(sdk_name)
1344LINUX_SDK_DIR := $(sdk_dir)
1345include $(TOPDIR)development/build/tools/windows_sdk.mk
1346endif
1347
The Android Open Source Project88b60792009-03-03 19:28:42 -08001348endif # !simulator
1349
1350# -----------------------------------------------------------------
1351# Findbugs
1352INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1353INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1354$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1355 @echo UnionBugs: $@
1356 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1357 > $@
1358$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1359 @echo ConvertXmlToText: $@
1360 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1361 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1362
1363# -----------------------------------------------------------------
1364# Findbugs
1365
1366# -----------------------------------------------------------------
1367# These are some additional build tasks that need to be run.
1368include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))