blob: ba243ffb08476d3566073f20e5f30ea30bae98e0 [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
Ying Wang462d26b2010-11-02 21:31:47 -070018# src:dest pair is the first one to match the same dest"
Ying Wang7e8d4422011-06-17 17:05:35 -070019unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080020$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang462d26b2010-11-02 21:31:47 -070021 $(eval _src := $(call word-colon,1,$(cf))) \
22 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070023 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)),, \
Ying Wang462d26b2010-11-02 21:31:47 -070024 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
25 $(eval $(call copy-one-file,$(_src),$(_fulldest))) \
26 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070027 $(eval unique_product_copy_files_destinations += $(_dest))))
28unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080029
30# -----------------------------------------------------------------
31# docs/index.html
32gen := $(OUT_DOCS)/index.html
33ALL_DOCS += $(gen)
34$(gen): frameworks/base/docs/docs-redirect-index.html
35 @mkdir -p $(dir $@)
36 @cp -f $< $@
37
38# -----------------------------------------------------------------
39# default.prop
40INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
41ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
42ADDITIONAL_DEFAULT_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070043 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
Mike Lockwood0d23fec2011-06-09 14:54:40 -070044ADDITIONAL_DEFAULT_PROPERTIES += \
Ying Wang7e8d4422011-06-17 17:05:35 -070045 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
46ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
47 $(ADDITIONAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080048
49$(INSTALLED_DEFAULT_PROP_TARGET):
50 @echo Target buildinfo: $@
51 @mkdir -p $(dir $@)
52 $(hide) echo "#" > $@; \
53 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
54 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070055 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
56 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -070057 build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080058
59# -----------------------------------------------------------------
60# build.prop
61INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
62ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
63ADDITIONAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070064 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
65ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
66 $(ADDITIONAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080067
68# A list of arbitrary tags describing the build configuration.
69# Force ":=" so we can use +=
70BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
71ifeq ($(TARGET_BUILD_TYPE),debug)
72 BUILD_VERSION_TAGS += debug
73endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -070074# The "test-keys" tag marks builds signed with the old test keys,
75# which are available in the SDK. "dev-keys" marks builds signed with
76# non-default dev keys (usually private keys from a vendor directory).
77# Both of these tags will be removed and replaced with "release-keys"
78# when the target-files is signed in a post-build step.
79ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
80BUILD_VERSION_TAGS += test-keys
81else
Ying Wang3c21fe52011-10-04 10:50:08 -070082BUILD_VERSION_TAGS += dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -070083endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080084BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
85
86# A human-readable string that descibes this build in detail.
87build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
88$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
89
90# The string used to uniquely identify this build; used by the OTA server.
91ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -070092 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 -080093endif
94ifneq ($(words $(BUILD_FINGERPRINT)),1)
95 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
96endif
97
Sriram Raman7b641242009-03-24 22:40:59 -070098# Display parameters shown under Settings -> About Phone
99ifeq ($(TARGET_BUILD_VARIANT),user)
100 # User builds should show:
101 # release build number or branch.buld_number non-release builds
102
103 # Dev. branches should have DISPLAY_BUILD_NUMBER set
104 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
105 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
106 else
107 BUILD_DISPLAY_ID := $(BUILD_ID)
108 endif
109else
110 # Non-user builds should show detailed build information
111 BUILD_DISPLAY_ID := $(build_desc)
112endif
113
Ying Wang77c882f2010-04-27 15:45:35 -0700114# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700115product_property_override_locale_language := $(strip \
116 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700117 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700118product_property_overrides_locale_region := $(strip \
119 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700120 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
121
The Android Open Source Project88b60792009-03-03 19:28:42 -0800122# Selects the first locale in the list given as the argument,
123# and splits it into language and region, which each may be
124# empty.
125define default-locale
126$(subst _, , $(firstword $(1)))
127endef
128
129# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700130# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
131# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700133$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134endef
135define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700136$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800137endef
138
139BUILDINFO_SH := build/tools/buildinfo.sh
Chih-Wei Huang75947ef2010-11-03 18:33:46 +0800140$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800141 @echo Target buildinfo: $@
142 @mkdir -p $(dir $@)
143 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
144 TARGET_DEVICE="$(TARGET_DEVICE)" \
145 PRODUCT_NAME="$(TARGET_PRODUCT)" \
146 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
147 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
148 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700149 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800150 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
151 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
152 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
153 BUILD_ID="$(BUILD_ID)" \
154 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
155 BUILD_NUMBER="$(BUILD_NUMBER)" \
156 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
157 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700158 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800159 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
160 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
161 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
162 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700163 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800164 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800165 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800166 bash $(BUILDINFO_SH) > $@
167 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
168 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
169 fi
170 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
171 $(hide) echo >> $@; \
172 echo "#" >> $@; \
173 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
174 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700175 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
176 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -0700177 $(hide) build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800178
179build_desc :=
180
181# -----------------------------------------------------------------
182# sdk-build.prop
183#
184# There are certain things in build.prop that we don't want to
185# ship with the sdk; remove them.
186
187# This must be a list of entire property keys followed by
188# "=" characters, without any internal spaces.
189sdk_build_prop_remove := \
190 ro.build.user= \
191 ro.build.host= \
192 ro.product.brand= \
193 ro.product.manufacturer= \
194 ro.product.device=
195# TODO: Remove this soon-to-be obsolete property
196sdk_build_prop_remove += ro.build.product=
197INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
198$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
199 @echo SDK buildinfo: $@
200 @mkdir -p $(dir $@)
201 $(hide) grep -v "$(subst $(space),\|,$(strip \
202 $(sdk_build_prop_remove)))" $< > $@.tmp
203 $(hide) for x in $(sdk_build_prop_remove); do \
204 echo "$$x"generic >> $@.tmp; done
205 $(hide) mv $@.tmp $@
206
207# -----------------------------------------------------------------
208# package stats
209PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
210PACKAGES_TO_STAT := \
211 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
212 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
213$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
214 @echo Package stats: $@
215 @mkdir -p $(dir $@)
216 $(hide) rm -f $@
217 $(hide) build/tools/dump-package-stats $^ > $@
218
219.PHONY: package-stats
220package-stats: $(PACKAGE_STATS_FILE)
221
222# -----------------------------------------------------------------
223# Cert-to-package mapping. Used by the post-build signing tools.
224name := $(TARGET_PRODUCT)
225ifeq ($(TARGET_BUILD_TYPE),debug)
226 name := $(name)_debug
227endif
228name := $(name)-apkcerts-$(FILE_NAME_TAG)
229intermediates := \
230 $(call intermediates-dir-for,PACKAGING,apkcerts)
231APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800232# We don't need to really build all the modules.
233# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700234$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800235 @echo APK certs list: $@
236 @mkdir -p $(dir $@)
237 @rm -f $@
238 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800239 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
240 echo 'name="$(p).apk" certificate="EXTERNAL" \
241 private_key=""' >> $@;,\
242 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
243 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800244
245.PHONY: apkcerts-list
246apkcerts-list: $(APKCERTS_FILE)
247
Ying Wang15e487a2011-02-15 10:56:18 -0800248ifneq (,$(TARGET_BUILD_APPS))
249 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
250endif
Ying Wangefb21682010-07-23 16:42:13 -0700251
The Android Open Source Project88b60792009-03-03 19:28:42 -0800252# -----------------------------------------------------------------
253# module info file
254ifdef CREATE_MODULE_INFO_FILE
255 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
256 $(info Generating $(MODULE_INFO_FILE)...)
257 $(shell rm -f $(MODULE_INFO_FILE))
258 $(foreach m,$(ALL_MODULES), \
259 $(shell echo "NAME=\"$(m)\"" \
260 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
261 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
262 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
263 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
264endif
265
Doug Zongker8678df42009-06-15 14:30:14 -0700266# -----------------------------------------------------------------
267
Ying Wang3c21fe52011-10-04 10:50:08 -0700268# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700269# for future OTA packages installed by this system. Actual product
270# deliverables will be re-signed by hand. We expect this file to
271# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700272DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700273
274
Jeff Browne33ba4c2011-07-11 22:11:46 -0700275# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800276# if they don't do anything.
277.PHONY: systemimage
278systemimage:
279
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800280# -----------------------------------------------------------------
281
282.PHONY: event-log-tags
283
Joe Onoratob7510532010-07-14 10:22:54 -0700284# Produce an event logs tag file for everything we know about, in order
285# to properly allocate numbers. Then produce a file that's filtered
286# for what's going to be installed.
287
288all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
289
290# Include tags from all packages that we know about
291all_event_log_tags_src := \
292 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
293
294$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
295$(all_event_log_tags_file): $(all_event_log_tags_src)
296 $(hide) mkdir -p $(dir $@)
297 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
298
299
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800300event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800301
Doug Zongkera34fa952011-02-23 12:17:29 -0800302# Include tags from all packages included in this product, plus all
303# tags that are part of the system (ie, not in a vendor/ or device/
304# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800305event_log_tags_src := \
306 $(sort $(foreach m,\
307 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
308 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800309 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
310 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800311
312$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700313$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
314$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800315 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700316 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800317
318event-log-tags: $(event_log_tags_file)
319
320ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
321
Joe Onoratob7510532010-07-14 10:22:54 -0700322
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323# #################################################################
324# Targets for boot/OS images
325# #################################################################
326
327# -----------------------------------------------------------------
328# the ramdisk
329INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
330 $(ALL_PREBUILT) \
331 $(ALL_COPIED_HEADERS) \
332 $(ALL_GENERATED_SOURCES) \
333 $(ALL_DEFAULT_INSTALLED_MODULES))
334
Joe Onorato64d85d02009-04-09 19:31:12 -0700335BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
336
337# We just build this directly to the install location.
338INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700339$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800340 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700341 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800342
343
344ifneq ($(strip $(TARGET_NO_KERNEL)),true)
345
346# -----------------------------------------------------------------
347# the boot image, which is a collection of other images.
348INTERNAL_BOOTIMAGE_ARGS := \
349 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
350 --kernel $(INSTALLED_KERNEL_TARGET) \
351 --ramdisk $(INSTALLED_RAMDISK_TARGET)
352
353INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
354
355BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
356ifdef BOARD_KERNEL_CMDLINE
357 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
358endif
359
Dima Zavin1e0847c2009-05-07 19:43:08 -0700360BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
361ifdef BOARD_KERNEL_BASE
362 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
363endif
364
Ying Wangffff0022010-08-23 12:56:25 -0700365BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
366ifdef BOARD_KERNEL_PAGESIZE
367 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
368endif
369
The Android Open Source Project88b60792009-03-03 19:28:42 -0800370INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
371
372ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
373tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
374INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
375INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
376$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
377 $(call pretty,"Target boot image: $@")
378 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
379
380else # TARGET_BOOTIMAGE_USE_EXT2 != true
381
382$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
383 $(call pretty,"Target boot image: $@")
384 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700385 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800386endif # TARGET_BOOTIMAGE_USE_EXT2
387
388else # TARGET_NO_KERNEL
389# HACK: The top-level targets depend on the bootimage. Not all targets
390# can produce a bootimage, though, and emulator targets need the ramdisk
391# instead. Fake it out by calling the ramdisk the bootimage.
392# TODO: make the emulator use bootimages, and make mkbootimg accept
393# kernel-less inputs.
394INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
395endif
396
397# -----------------------------------------------------------------
398# NOTICE files
399#
400# This needs to be before the systemimage rules, because it adds to
401# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
402# go into the systemimage.
403
404.PHONY: notice_files
405
406# Create the rule to combine the files into text and html forms
407# $(1) - Plain text output file
408# $(2) - HTML output file
409# $(3) - File title
410# $(4) - Directory to use. Notice files are all $(4)/src. Other
411# directories in there will be used for scratch
412# $(5) - Dependencies for the output files
413#
414# The algorithm here is that we go collect a hash for each of the notice
415# files and write the names of the files that match that hash. Then
416# to generate the real files, we go print out all of the files and their
417# hashes.
418#
419# These rules are fairly complex, so they depend on this makefile so if
420# it changes, they'll run again.
421#
422# TODO: We could clean this up so that we just record the locations of the
423# original notice files instead of making rules to copy them somwehere.
424# Then we could traverse that without quite as much bash drama.
425define combine-notice-files
426$(1) $(2): PRIVATE_MESSAGE := $(3)
427$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
428$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
429 @echo Finding NOTICE files: $$@
430 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
431 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
432 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
433 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
434 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
435 echo $$$$file >> $$$$hashfile; \
436 done
437 $$(hide) touch $$@
438$(1): $(4)/hash-timestamp
439 @echo Combining NOTICE files: $$@
440 $$(hide) mkdir -p $$(dir $$@)
441 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
442 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
443 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
444 $$(hide) echo >> $$@
445 $$(hide) echo >> $$@
446 $$(hide) echo >> $$@
447 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
448 echo "============================================================"\
449 >> $$@; \
450 echo "Notices for file(s):" >> $$@; \
451 cat $$$$hashfile | sort | \
452 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
453 $$@; \
454 echo "------------------------------------------------------------"\
455 >> $$@; \
456 echo >> $$@; \
457 orig=$$$$(head -n 1 $$$$hashfile); \
458 cat $$$$orig >> $$@; \
459 echo >> $$@; \
460 echo >> $$@; \
461 echo >> $$@; \
462 done
463$(2): $(4)/hash-timestamp
464 @echo Combining NOTICE files: $$@
465 $$(hide) mkdir -p $$(dir $$@)
466 $$(hide) echo "<html><head>" > $$@
467 $$(hide) echo "<style type=\"text/css\">" >> $$@
468 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
469 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
470 $$(hide) echo ".label { font-weight: bold; }" >> $$@
471 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
472 $$(hide) echo "</style>" >> $$@
473 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
474 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
475 >> $$@
476 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
477 cat $$$$hashfile | sort | \
478 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
479 $$@; \
480 echo "<tr><td class=\"same-license\">" >> $$@; \
481 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
482 echo "<div class=\"file-list\">" >> $$@; \
483 cat $$$$hashfile | sort | \
484 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
485 echo "</div><!-- file-list -->" >> $$@; \
486 echo >> $$@; \
487 orig=$$$$(head -n 1 $$$$hashfile); \
488 echo "<pre class=\"license-text\">" >> $$@; \
489 cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
490 | sed -e "s/>/\&gt;/g" >> $$@; \
491 echo "</pre><!-- license-text -->" >> $$@; \
492 echo "</td></tr><!-- same-license -->" >> $$@; \
493 echo >> $$@; \
494 echo >> $$@; \
495 echo >> $$@; \
496 done
497 $$(hide) echo "</table>" >> $$@
498 $$(hide) echo "</body></html>" >> $$@
499notice_files: $(1) $(2)
500endef
501
502# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
503# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
504# the src subdirectory.
505
506target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
507target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
508target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
509tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
510tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
511
512kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
513
514$(eval $(call combine-notice-files, \
515 $(target_notice_file_txt), \
516 $(target_notice_file_html), \
517 "Notices for files contained in the filesystem images in this directory:", \
518 $(TARGET_OUT_NOTICE_FILES), \
519 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
520
521$(eval $(call combine-notice-files, \
522 $(tools_notice_file_txt), \
523 $(tools_notice_file_html), \
524 "Notices for files contained in the tools directory:", \
525 $(HOST_OUT_NOTICE_FILES), \
526 $(ALL_DEFAULT_INSTALLED_MODULES)))
527
528# Install the html file at /system/etc/NOTICE.html.gz.
529# This is not ideal, but this is very late in the game, after a lot of
530# the module processing has already been done -- in fact, we used the
531# fact that all that has been done to get the list of modules that we
532# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700533$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700534 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800535installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
536$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
537 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700538
539# if we've been run my mm, mmm, etc, don't reinstall this every time
540ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800541ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700542endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800543
544# The kernel isn't really a module, so to get its module file in there, we
545# make the target NOTICE files depend on this particular file too, which will
546# then be in the right directory for the find in combine-notice-files to work.
547$(kernel_notice_file): \
548 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
549 | $(ACP)
550 @echo Copying: $@
551 $(hide) mkdir -p $(dir $@)
552 $(hide) $(ACP) $< $@
553
554
Doug Zongker8678df42009-06-15 14:30:14 -0700555# -----------------------------------------------------------------
556# Build a keystore with the authorized keys in it, used to verify the
557# authenticity of downloaded OTA packages.
558#
559# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
560# before the rules that use that variable to build the image.
561ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
562$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700563$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700564 $(hide) rm -f $@
565 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700566 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700567
568.PHONY: otacerts
569otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
570
571
The Android Open Source Project88b60792009-03-03 19:28:42 -0800572# #################################################################
573# Targets for user images
574# #################################################################
575
Ying Wang933abf12010-06-16 14:31:34 -0700576INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800577ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700578INTERNAL_USERIMAGES_USE_EXT := true
579INTERNAL_USERIMAGES_EXT_VARIANT := ext2
580else
581ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
582INTERNAL_USERIMAGES_USE_EXT := true
583INTERNAL_USERIMAGES_EXT_VARIANT := ext3
584else
585ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
586INTERNAL_USERIMAGES_USE_EXT := true
587INTERNAL_USERIMAGES_EXT_VARIANT := ext4
588endif
589endif
590endif
591
Ying Wang542903a2010-11-17 15:40:38 -0800592ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
593 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
594endif
595
Colin Cross0a7b2c52010-05-07 02:23:59 -0700596ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Ying Wang542903a2010-11-17 15:40:38 -0800597INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS)
Ying Wang933abf12010-06-16 14:31:34 -0700598INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
599
Ying Wangc79f4da2010-06-16 14:58:50 -0700600# $(1): src directory
601# $(2): output file
Ying Wang026f1452010-09-27 17:49:03 -0700602# $(3): mount point
Ying Wangc79f4da2010-06-16 14:58:50 -0700603# $(4): ext variant (ext2, ext3, ext4)
Colin Crosse0a40212010-08-03 14:43:34 -0700604# $(5): size of the partition
Ying Wangc79f4da2010-06-16 14:58:50 -0700605define build-userimage-ext-target
606 @mkdir -p $(dir $(2))
Ying Wang1b5f1dc2011-02-17 15:44:45 -0800607 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Ying Wang542903a2010-11-17 15:40:38 -0800608 $(MKEXTUSERIMG) $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG) $(1) $(2) $(4) $(3) $(5)
Ying Wangc79f4da2010-06-16 14:58:50 -0700609endef
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610else
Colin Cross144b0282010-05-10 13:04:47 -0700611INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800612endif
613
614# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700615# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700616
617# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700618ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700619
Doug Zongker4647f122009-07-02 09:00:54 -0700620INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
621
622recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
623recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
624recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
625recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
626recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
627recovery_resources_common := $(call include-path-for, recovery)/res
628recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
629recovery_resource_deps := $(shell find $(recovery_resources_common) \
630 $(recovery_resources_private) -type f)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700631recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700632
633ifeq ($(recovery_resources_private),)
634 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
635endif
636
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700637ifeq ($(recovery_fstab),)
638 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
639endif
640
Doug Zongker4647f122009-07-02 09:00:54 -0700641INTERNAL_RECOVERYIMAGE_ARGS := \
642 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
643 --kernel $(recovery_kernel) \
644 --ramdisk $(recovery_ramdisk)
645
646# Assumes this has already been stripped
647ifdef BOARD_KERNEL_CMDLINE
648 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
649endif
650ifdef BOARD_KERNEL_BASE
651 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
652endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700653BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
654ifdef BOARD_KERNEL_PAGESIZE
655 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
656endif
Doug Zongker4647f122009-07-02 09:00:54 -0700657
658# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -0700659# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -0700660# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -0700661OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -0700662
663# Generate a file containing the keys that will be read by the
664# recovery binary.
665RECOVERY_INSTALL_OTA_KEYS := \
666 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
667DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
668$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700669$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800670$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
671 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700672 @rm -rf $@
673 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800674 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700675
676$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
677 $(INSTALLED_RAMDISK_TARGET) \
678 $(INSTALLED_BOOTIMAGE_TARGET) \
679 $(recovery_binary) \
680 $(recovery_initrc) $(recovery_kernel) \
681 $(INSTALLED_2NDBOOTLOADER_TARGET) \
682 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700683 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700684 $(RECOVERY_INSTALL_OTA_KEYS)
685 @echo ----- Making recovery image ------
686 rm -rf $(TARGET_RECOVERY_OUT)
687 mkdir -p $(TARGET_RECOVERY_OUT)
688 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
689 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
690 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
691 echo Copying baseline ramdisk...
692 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerb4c7d322010-07-01 15:30:11 -0700693 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700694 echo Modifying ramdisk contents...
695 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
696 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
697 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
698 $(foreach item,$(recovery_resources_private), \
699 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700700 $(foreach item,$(recovery_fstab), \
701 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700702 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
703 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
704 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
705 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
706 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
707 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700708 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700709
710else
711INSTALLED_RECOVERYIMAGE_TARGET :=
712endif
713
714.PHONY: recoveryimage
715recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
716
Dima Zavin11818982010-02-05 13:34:34 -0800717ifneq ($(BOARD_NAND_PAGE_SIZE),)
718mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
719else
720mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100721BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800722endif
723
Naseer Ahmed53871882010-08-06 12:19:29 -0700724ifneq ($(BOARD_NAND_SPARE_SIZE),)
725mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100726else
727BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700728endif
729
Doug Zongker4647f122009-07-02 09:00:54 -0700730# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700731# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800732#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733
734INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
735 $(ALL_PREBUILT) \
736 $(ALL_COPIED_HEADERS) \
737 $(ALL_GENERATED_SOURCES) \
738 $(ALL_DEFAULT_INSTALLED_MODULES))
739
Ying Wange5e8c5f2011-09-09 16:35:53 -0700740FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
741# -----------------------------------------------------------------
742# installed file list
743# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
744# We put installed-files.txt ahead of image itself in the dependency graph
745# so that we can get the size stat even if the build fails due to too large
746# system image.
747INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
748$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
749 @echo Installed file list: $@
750 @mkdir -p $(dir $@)
751 @rm -f $@
752 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
753
754.PHONY: installed-file-list
755installed-file-list: $(INSTALLED_FILES_FILE)
756ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
757$(call dist-for-goals, sdk win_sdk, $(INSTALLED_FILES_FILE))
758endif
759ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
760$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
761endif
762
763systemimage_intermediates := \
764 $(call intermediates-dir-for,PACKAGING,systemimage)
765BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
766
Colin Cross0a7b2c52010-05-07 02:23:59 -0700767ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
768## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800769# $(1): output file
770define build-systemimage-target
771 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700772 $(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 -0800773endef
774
Colin Cross0a7b2c52010-05-07 02:23:59 -0700775else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776
777## generate a yaffs2 image
778# $(1): output file
779define build-systemimage-target
780 @echo "Target system fs image: $(1)"
781 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800782 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800783endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700784endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800785
Ying Wange5e8c5f2011-09-09 16:35:53 -0700786$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800787 $(call build-systemimage-target,$@)
788
The Android Open Source Project88b60792009-03-03 19:28:42 -0800789INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700790SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800791
Doug Zongker73ef8252009-07-23 15:12:53 -0700792# The system partition needs room for the recovery image as well. We
793# now store the recovery image as a binary patch using the boot image
794# as the source (since they are very similar). Generate the patch so
795# we can see how big it's going to be, and include that in the system
796# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700797ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700798intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
799RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
800$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
801 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700802 $(HOST_OUT_EXECUTABLES)/imgdiff \
803 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700804 @echo "Construct recovery from boot"
805 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700806 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700807endif
808
Doug Zongker73ef8252009-07-23 15:12:53 -0700809
810$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800811 @echo "Install system fs image: $@"
812 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700813 $(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 -0800814
815systemimage: $(INSTALLED_SYSTEMIMAGE)
816
817.PHONY: systemimage-nodeps snod
818systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700819 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800820 @echo "make $@: ignoring dependencies"
821 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700822 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800823
824#######
825## system tarball
826define build-systemtarball-target
827 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
828 $(MKTARBALL) $(FS_GET_STATS) \
829 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
830 $(INSTALLED_SYSTEMTARBALL_TARGET)
831endef
832
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700833ifndef SYSTEM_TARBALL_FORMAT
834 SYSTEM_TARBALL_FORMAT := bz2
835endif
836
The Android Open Source Project88b60792009-03-03 19:28:42 -0800837system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700838INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800839$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
840$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
841 $(build-systemtarball-target)
842
843.PHONY: systemtarball-nodeps
844systemtarball-nodeps: $(FS_GET_STATS) \
845 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
846 $(build-systemtarball-target)
847
848.PHONY: stnod
849stnod: systemtarball-nodeps
850
851
Bruce Beare52aac202010-06-04 15:24:49 -0700852#######
853## boot tarball
854define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700855 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700856 $(hide) mkdir -p $(PRODUCT_OUT)/boot
857 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
858 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
859 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
860 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
861 $(INSTALLED_BOOTTARBALL_TARGET)
862endef
863
864ifndef BOOT_TARBALL_FORMAT
865 BOOT_TARBALL_FORMAT := bz2
866endif
867
868boot_tar := $(PRODUCT_OUT)/boot.tar
869INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
870$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
871$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
872 $(build-boottarball-target)
873
874.PHONY: boottarball-nodeps btnod
875boottarball-nodeps btnod: $(FS_GET_STATS) \
876 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
877 $(build-boottarball-target)
878
879
The Android Open Source Project88b60792009-03-03 19:28:42 -0800880# -----------------------------------------------------------------
881# data partition image
882INTERNAL_USERDATAIMAGE_FILES := \
883 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
884
Colin Cross0a7b2c52010-05-07 02:23:59 -0700885ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800886## Generate an ext2 image
887define build-userdataimage-target
888 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
889 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang026f1452010-09-27 17:49:03 -0700890 $(call build-userimage-ext-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),data,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Doug Zongkered96e882009-08-26 09:37:07 -0700891 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800892endef
893
Colin Cross0a7b2c52010-05-07 02:23:59 -0700894else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800895
896## Generate a yaffs2 image
897define build-userdataimage-target
898 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
899 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800900 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700901 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700903endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800904
Joe Onorato64d85d02009-04-09 19:31:12 -0700905BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
906
907# We just build this directly to the install location.
908INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700909$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800910 $(INTERNAL_USERDATAIMAGE_FILES)
911 $(build-userdataimage-target)
912
913.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700914userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915 $(build-userdataimage-target)
916
917#######
918## data partition tarball
919define build-userdatatarball-target
920 $(call pretty,"Target userdata fs tarball: " \
921 "$(INSTALLED_USERDATATARBALL_TARGET)")
922 $(MKTARBALL) $(FS_GET_STATS) \
923 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
924 $(INSTALLED_USERDATATARBALL_TARGET)
925endef
926
927userdata_tar := $(PRODUCT_OUT)/userdata.tar
928INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
929$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
930$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
931 $(build-userdatatarball-target)
932
933.PHONY: userdatatarball-nodeps
934userdatatarball-nodeps: $(FS_GET_STATS)
935 $(build-userdatatarball-target)
936
937
The Android Open Source Project88b60792009-03-03 19:28:42 -0800938# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800939# bring in the installer image generation defines if necessary
940ifeq ($(TARGET_USE_DISKINSTALLER),true)
941include bootable/diskinstaller/config.mk
942endif
943
944# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700945# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800946
Ying Wang06898662010-06-17 17:52:18 -0700947OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700948 $(HOST_OUT_EXECUTABLES)/mkbootfs \
949 $(HOST_OUT_EXECUTABLES)/mkbootimg \
950 $(HOST_OUT_EXECUTABLES)/fs_config \
951 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
952 $(HOST_OUT_EXECUTABLES)/zipalign \
953 $(HOST_OUT_EXECUTABLES)/aapt \
954 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700955 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700956 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700957 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
958 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
959 $(HOST_OUT_EXECUTABLES)/genext2fs \
960 $(HOST_OUT_EXECUTABLES)/tune2fs \
Sriram Ramanff83c852010-11-30 15:09:19 -0500961 $(HOST_OUT_EXECUTABLES)/e2fsck \
Sriram Ramanc647aec2010-11-29 18:51:20 -0500962 $(HOST_OUT_EXECUTABLES)/make_ext4fs
The Android Open Source Project88b60792009-03-03 19:28:42 -0800963
Ying Wang06898662010-06-17 17:52:18 -0700964.PHONY: otatools
965otatools: $(OTATOOLS)
966
The Android Open Source Project88b60792009-03-03 19:28:42 -0800967# -----------------------------------------------------------------
968# A zip of the directories that map to the target filesystem.
969# This zip can be used to create an OTA package or filesystem image
970# as a post-build step.
971#
972name := $(TARGET_PRODUCT)
973ifeq ($(TARGET_BUILD_TYPE),debug)
974 name := $(name)_debug
975endif
976name := $(name)-target_files-$(FILE_NAME_TAG)
977
978intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
979BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
980$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
981$(BUILT_TARGET_FILES_PACKAGE): \
982 zip_root := $(intermediates)/$(name)
983
984# $(1): Directory to copy
985# $(2): Location to copy it to
986# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
987define package_files-copy-root
988 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
989 mkdir -p $(2) && \
990 $(ACP) -rd $(strip $(1))/* $(2); \
991 fi
992endef
993
994built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700995 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700996 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700997 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
998 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800999$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1000
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001001$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
1002
Doug Zongkerc18736b2009-09-30 09:20:32 -07001003ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1004# default to common dir for device vendor
1005$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1006else
1007$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1008endif
1009
The Android Open Source Project88b60792009-03-03 19:28:42 -08001010# Depending on the various images guarantees that the underlying
1011# directories are up-to-date.
1012$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001013 $(INSTALLED_BOOTIMAGE_TARGET) \
1014 $(INSTALLED_RADIOIMAGE_TARGET) \
1015 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001016 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001017 $(INSTALLED_USERDATAIMAGE_TARGET) \
1018 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001019 $(built_ota_tools) \
1020 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001021 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001022 | $(ACP)
1023 @echo "Package target files: $@"
1024 $(hide) rm -rf $@ $(zip_root)
1025 $(hide) mkdir -p $(dir $@) $(zip_root)
1026 @# Components of the recovery image
1027 $(hide) mkdir -p $(zip_root)/RECOVERY
1028 $(hide) $(call package_files-copy-root, \
1029 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1030ifdef INSTALLED_KERNEL_TARGET
1031 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1032endif
1033ifdef INSTALLED_2NDBOOTLOADER_TARGET
1034 $(hide) $(ACP) \
1035 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1036endif
1037ifdef BOARD_KERNEL_CMDLINE
1038 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1039endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001040ifdef BOARD_KERNEL_BASE
1041 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1042endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001043ifdef BOARD_KERNEL_PAGESIZE
1044 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1045endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001046 @# Components of the boot image
1047 $(hide) mkdir -p $(zip_root)/BOOT
1048 $(hide) $(call package_files-copy-root, \
1049 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1050ifdef INSTALLED_KERNEL_TARGET
1051 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1052endif
1053ifdef INSTALLED_2NDBOOTLOADER_TARGET
1054 $(hide) $(ACP) \
1055 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1056endif
1057ifdef BOARD_KERNEL_CMDLINE
1058 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1059endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001060ifdef BOARD_KERNEL_BASE
1061 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1062endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001063ifdef BOARD_KERNEL_PAGESIZE
1064 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1065endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001066 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1067 mkdir -p $(zip_root)/RADIO; \
1068 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001069 @# Contents of the system image
1070 $(hide) $(call package_files-copy-root, \
1071 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1072 @# Contents of the data image
1073 $(hide) $(call package_files-copy-root, \
1074 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1075 @# Extra contents of the OTA package
1076 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001077 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1078 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001079 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001080 @# build them.
1081 $(hide) mkdir -p $(zip_root)/META
1082 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001083 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001084 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001085ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001086 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001087endif
1088ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001089 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001090endif
1091ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001092 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001093endif
1094ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001095 $(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001096endif
1097ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001098 $(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001099endif
Doug Zongker37974732010-09-16 17:44:38 -07001100 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001101ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001102 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001103endif
Ying Wangc5a07ce2010-11-17 17:45:36 -08001104ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
1105 $(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(zip_root)/META/misc_info.txt
1106endif
Ying Wang3c21fe52011-10-04 10:50:08 -07001107 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001108ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1109 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001110endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001111 @# Zip everything up, preserving symlinks
1112 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker23f8bde2011-09-07 14:11:51 -07001113 @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
1114 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1115 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/boot_filesystem_config.txt
1116 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/recovery_filesystem_config.txt
1117 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001118
The Android Open Source Project88b60792009-03-03 19:28:42 -08001119
1120target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1121
Doug Zongker367910f2009-06-15 18:56:51 -07001122
Doug Zongker367910f2009-06-15 18:56:51 -07001123ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001124ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001125ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001126ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001127
Ying Wang09a00a62010-10-20 14:01:09 -07001128# -----------------------------------------------------------------
1129# OTA update package
1130
Doug Zongker8678df42009-06-15 14:30:14 -07001131name := $(TARGET_PRODUCT)
1132ifeq ($(TARGET_BUILD_TYPE),debug)
1133 name := $(name)_debug
1134endif
1135name := $(name)-ota-$(FILE_NAME_TAG)
1136
1137INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1138
1139$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1140
Ying Wang06898662010-06-17 17:52:18 -07001141$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001142 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001143 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001144 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001145 -k $(KEY_CERT_PAIR) \
1146 $(BUILT_TARGET_FILES_PACKAGE) $@
1147
1148.PHONY: otapackage
1149otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1150
Ying Wang09a00a62010-10-20 14:01:09 -07001151# -----------------------------------------------------------------
1152# The update package
1153
1154name := $(TARGET_PRODUCT)
1155ifeq ($(TARGET_BUILD_TYPE),debug)
1156 name := $(name)_debug
1157endif
1158name := $(name)-img-$(FILE_NAME_TAG)
1159
1160INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1161
1162ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1163# default to common dir for device vendor
1164$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1165else
1166$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1167endif
1168
1169$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
1170 @echo "Package: $@"
1171 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1172 -s $(extensions) \
1173 -p $(HOST_OUT) \
1174 $(BUILT_TARGET_FILES_PACKAGE) $@
1175
1176.PHONY: updatepackage
1177updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1178
Ying Wanga73b6562011-03-03 21:52:08 -08001179endif # recovery_fstab is defined
Ying Wangfb0a3472010-08-25 16:06:06 -07001180endif # TARGET_NO_KERNEL != true
Ying Wang279f3082011-02-09 12:26:42 -08001181endif # TARGET_DEVICE != generic*
Doug Zongker367910f2009-06-15 18:56:51 -07001182endif # TARGET_PRODUCT != sdk
Doug Zongker8678df42009-06-15 14:30:14 -07001183
1184# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001185# A zip of the tests that are built when running "make tests".
1186# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1187# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1188#
1189name := $(TARGET_PRODUCT)
1190ifeq ($(TARGET_BUILD_TYPE),debug)
1191 name := $(name)_debug
1192endif
1193name := $(name)-tests-$(FILE_NAME_TAG)
1194
1195intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1196BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1197$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1198$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1199
1200# Depending on the images guarantees that the underlying
1201# directories are up-to-date.
1202$(BUILT_TESTS_ZIP_PACKAGE): \
1203 $(BUILT_SYSTEMIMAGE) \
1204 $(INSTALLED_USERDATAIMAGE_TARGET) \
1205 | $(ACP)
1206 @echo "Package test files: $@"
1207 $(hide) rm -rf $@ $(zip_root)
1208 $(hide) mkdir -p $(dir $@) $(zip_root)
1209 @# Some parts of the system image
1210 $(hide) $(call package_files-copy-root, \
1211 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1212 $(hide) $(call package_files-copy-root, \
1213 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1214 $(hide) $(call package_files-copy-root, \
1215 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1216 $(zip_root)/SYSTEM/framework)
1217 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1218 @# Contents of the data image
1219 $(hide) $(call package_files-copy-root, \
1220 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1221 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1222
Ying Wang9c762552010-09-10 14:39:33 -07001223.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001224tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1225
Ying Wangdb2cb632010-09-14 16:07:56 -07001226# Target needed by tests build
1227.PHONY: tests-build-target
1228tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1229 $(BUILT_USERDATAIMAGE_TARGET)
1230
1231ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1232 $(call dist-for-goals, tests-build-target, \
1233 $(BUILT_TESTS_ZIP_PACKAGE) \
1234 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang9c762552010-09-10 14:39:33 -07001235endif
1236
The Android Open Source Project88b60792009-03-03 19:28:42 -08001237# -----------------------------------------------------------------
1238# A zip of the symbols directory. Keep the full paths to make it
1239# more obvious where these files came from.
1240#
1241name := $(TARGET_PRODUCT)
1242ifeq ($(TARGET_BUILD_TYPE),debug)
1243 name := $(name)_debug
1244endif
1245name := $(name)-symbols-$(FILE_NAME_TAG)
1246
1247SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1248$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1249 @echo "Package symbols: $@"
1250 $(hide) rm -rf $@
1251 $(hide) mkdir -p $(dir $@)
1252 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1253
1254# -----------------------------------------------------------------
1255# A zip of the Android Apps. Not keeping full path so that we don't
1256# include product names when distributing
1257#
1258name := $(TARGET_PRODUCT)
1259ifeq ($(TARGET_BUILD_TYPE),debug)
1260 name := $(name)_debug
1261endif
1262name := $(name)-apps-$(FILE_NAME_TAG)
1263
1264APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1265$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1266 @echo "Package apps: $@"
1267 $(hide) rm -rf $@
1268 $(hide) mkdir -p $(dir $@)
1269 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1270
Guang Zhu0198d6e2010-04-23 11:54:37 -07001271
1272#------------------------------------------------------------------
1273# A zip of emma code coverage meta files. Generated for fully emma
1274# instrumented build.
1275#
1276EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1277$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1278 @echo "Collecting Emma coverage meta files."
1279 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1280 zip -@ -q $@
1281
The Android Open Source Project88b60792009-03-03 19:28:42 -08001282# -----------------------------------------------------------------
1283# dalvik something
1284.PHONY: dalvikfiles
1285dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1286
1287# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001288# The emulator package
1289
The Android Open Source Project88b60792009-03-03 19:28:42 -08001290INTERNAL_EMULATOR_PACKAGE_FILES += \
1291 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Bruce Beare18a130e2011-02-18 15:06:20 -08001292 prebuilt/android-$(TARGET_ARCH)/kernel/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001293 $(INSTALLED_RAMDISK_TARGET) \
1294 $(INSTALLED_SYSTEMIMAGE) \
1295 $(INSTALLED_USERDATAIMAGE_TARGET)
1296
1297name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1298
1299INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1300
1301$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1302 @echo "Package: $@"
1303 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1304
The Android Open Source Project88b60792009-03-03 19:28:42 -08001305# -----------------------------------------------------------------
1306# The pdk package (Platform Development Kit)
1307
1308ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1309 include development/pdk/Pdk.mk
1310endif
1311
1312# -----------------------------------------------------------------
1313# The SDK
1314
The Android Open Source Project88b60792009-03-03 19:28:42 -08001315# The SDK includes host-specific components, so it belongs under HOST_OUT.
1316sdk_dir := $(HOST_OUT)/sdk
1317
1318# Build a name that looks like:
1319#
1320# linux-x86 --> android-sdk_12345_linux-x86
1321# darwin-x86 --> android-sdk_12345_mac-x86
1322# windows-x86 --> android-sdk_12345_windows
1323#
1324sdk_name := android-sdk_$(FILE_NAME_TAG)
1325ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001326 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001327else
Joe Onorato03fbe402009-04-13 08:31:16 -07001328 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001329endif
1330ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001331 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001332endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001333sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001334
1335sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1336
1337ATREE_FILES :=
1338-include $(sdk_dep_file)
1339
1340# if we don't have a real list, then use "everything"
1341ifeq ($(strip $(ATREE_FILES)),)
1342ATREE_FILES := \
1343 $(ALL_PREBUILT) \
1344 $(ALL_COPIED_HEADERS) \
1345 $(ALL_GENERATED_SOURCES) \
1346 $(ALL_DEFAULT_INSTALLED_MODULES) \
1347 $(INSTALLED_RAMDISK_TARGET) \
1348 $(ALL_DOCS) \
1349 $(ALL_SDK_FILES)
1350endif
1351
1352atree_dir := development/build
1353
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001354# sdk/build/tools.atree contains the generic rules, while
1355#
1356# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
1357# the latter is optional.
1358#
1359sdk_tools_atree_files := sdk/build/tools.atree
1360ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
1361 sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
1362endif
1363
The Android Open Source Project88b60792009-03-03 19:28:42 -08001364sdk_atree_files := \
1365 $(atree_dir)/sdk.exclude.atree \
1366 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001367 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001368 $(sdk_tools_atree_files)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001369
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001370# development/build/sdk-android-<abi>.atree is used to differentiate
1371# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1372# files like the kernel image. We use TARGET_CPU_ABI because we don't
1373# have a better way to distinguish between CPU models.
1374ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1375 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1376endif
1377
The Android Open Source Project88b60792009-03-03 19:28:42 -08001378deps := \
1379 $(target_notice_file_txt) \
1380 $(tools_notice_file_txt) \
1381 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001382 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001383 $(INSTALLED_SYSTEMIMAGE) \
1384 $(INSTALLED_USERDATAIMAGE_TARGET) \
1385 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001386 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001387 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001388 $(ATREE_FILES) \
1389 $(atree_dir)/sdk.atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001390 $(sdk_tools_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001391 $(HOST_OUT_EXECUTABLES)/atree \
1392 $(HOST_OUT_EXECUTABLES)/line_endings
1393
1394INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1395$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1396$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1397$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1398$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1399
1400# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1401#
1402#SDK_GNU_ERROR := true
1403
1404$(INTERNAL_SDK_TARGET): $(deps)
1405 @echo "Package SDK: $@"
1406 $(hide) rm -rf $(PRIVATE_DIR) $@
1407 $(hide) for f in $(target_gnu_MODULES); do \
1408 if [ -f $$f ]; then \
1409 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1410 including GNU target $$f >&2; \
1411 FAIL=$(SDK_GNU_ERROR); \
1412 fi; \
1413 done; \
1414 if [ $$FAIL ]; then exit 1; fi
1415 $(hide) ( \
1416 $(HOST_OUT_EXECUTABLES)/atree \
1417 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1418 -m $(PRIVATE_DEP_FILE) \
1419 -I . \
1420 -I $(PRODUCT_OUT) \
1421 -I $(HOST_OUT) \
1422 -I $(TARGET_COMMON_OUT_ROOT) \
1423 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001424 -v "OUT_DIR=$(OUT_DIR)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001425 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1426 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001427 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001428 -o $(PRIVATE_DIR) && \
1429 cp -f $(target_notice_file_txt) \
Xavier Ducrohet4d2b9bf2011-09-21 10:22:19 -07001430 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001431 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001432 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001433 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001434 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001435 chmod -R ug+rwX $(PRIVATE_DIR) && \
1436 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1437 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1438
Raphael3d224a02010-04-16 17:50:09 -07001439
1440# Is a Windows SDK requested? If so, we need some definitions from here
1441# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001442MAIN_SDK_NAME := $(sdk_name)
1443MAIN_SDK_DIR := $(sdk_dir)
1444MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001445ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001446include $(TOPDIR)development/build/tools/windows_sdk.mk
1447endif
1448
The Android Open Source Project88b60792009-03-03 19:28:42 -08001449# -----------------------------------------------------------------
1450# Findbugs
1451INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1452INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1453$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1454 @echo UnionBugs: $@
1455 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1456 > $@
1457$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1458 @echo ConvertXmlToText: $@
1459 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1460 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1461
1462# -----------------------------------------------------------------
1463# Findbugs
1464
1465# -----------------------------------------------------------------
1466# These are some additional build tasks that need to be run.
1467include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001468-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Raphaelc4d47312011-02-15 16:09:36 -08001469
1470# -----------------------------------------------------------------
1471# Create SDK repository packages. Must be done after tasks/* since
1472# we need the addon rules defined.
1473ifneq ($(sdk_repo_goal),)
1474include $(TOPDIR)development/build/tools/sdk_repo.mk
1475endif