1################################################################################
2#
3# android-tools
4#
5################################################################################
6
7ANDROID_TOOLS_SITE = https://launchpad.net/ubuntu/+archive/primary/+files
8ANDROID_TOOLS_VERSION = 4.2.2+git20130218
9ANDROID_TOOLS_SOURCE = android-tools_$(ANDROID_TOOLS_VERSION).orig.tar.xz
10ANDROID_TOOLS_EXTRA_DOWNLOADS = android-tools_$(ANDROID_TOOLS_VERSION)-3ubuntu41.debian.tar.gz
11HOST_ANDROID_TOOLS_EXTRA_DOWNLOADS = $(ANDROID_TOOLS_EXTRA_DOWNLOADS)
12ANDROID_TOOLS_LICENSE = Apache-2.0
13ANDROID_TOOLS_LICENSE_FILES = debian/copyright
14ANDROID_TOOLS_DEPENDENCIES = host-pkgconf
15HOST_ANDROID_TOOLS_DEPENDENCIES = host-pkgconf
16
17# Extract the Debian tarball inside the sources
18define ANDROID_TOOLS_DEBIAN_EXTRACT
19	$(call suitable-extractor,$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS))) \
20		$(ANDROID_TOOLS_DL_DIR)/$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS)) | \
21		$(TAR) -C $(@D) $(TAR_OPTIONS) -
22endef
23
24HOST_ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
25ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
26
27# Apply the Debian patches before applying the Buildroot patches
28define ANDROID_TOOLS_DEBIAN_PATCH
29	$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*
30endef
31
32HOST_ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
33ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
34
35ifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_FASTBOOT),y)
36HOST_ANDROID_TOOLS_BUILD_TARGETS += fastboot
37HOST_ANDROID_TOOLS_INSTALL_TARGETS += build-fastboot/fastboot
38HOST_ANDROID_TOOLS_DEPENDENCIES += host-zlib host-libselinux
39endif
40
41ifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_ADB),y)
42HOST_ANDROID_TOOLS_BUILD_TARGETS += adb
43HOST_ANDROID_TOOLS_INSTALL_TARGETS += build-adb/adb
44HOST_ANDROID_TOOLS_DEPENDENCIES += host-zlib host-openssl
45endif
46
47ifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_EXT4_UTILS),y)
48HOST_ANDROID_TOOLS_BUILD_TARGETS += ext4_utils
49HOST_ANDROID_TOOLS_INSTALL_TARGETS += \
50	$(addprefix build-ext4_utils/,make_ext4fs ext4fixup ext2simg img2simg simg2img simg2simg)
51HOST_ANDROID_TOOLS_DEPENDENCIES += host-libselinux
52endif
53
54ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT),y)
55ANDROID_TOOLS_TARGETS += fastboot
56ANDROID_TOOLS_DEPENDENCIES += zlib libselinux
57endif
58
59ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADB),y)
60ANDROID_TOOLS_TARGETS += adb
61ANDROID_TOOLS_DEPENDENCIES += zlib openssl
62endif
63
64ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADBD),y)
65ANDROID_TOOLS_TARGETS += adbd
66ANDROID_TOOLS_DEPENDENCIES += \
67	openssl \
68	zlib \
69	$(if $(BR2_PACKAGE_LIBXCRYPT),libxcrypt)
70endif
71
72# Build each tool in its own directory not to share object files
73
74define HOST_ANDROID_TOOLS_BUILD_CMDS
75	$(foreach t,$(HOST_ANDROID_TOOLS_BUILD_TARGETS),\
76		mkdir -p $(@D)/build-$(t) && \
77		$(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) SRCDIR=$(@D) \
78			-C $(@D)/build-$(t) -f $(@D)/debian/makefiles/$(t).mk$(sep))
79endef
80
81define ANDROID_TOOLS_BUILD_CMDS
82	$(foreach t,$(ANDROID_TOOLS_TARGETS),\
83		mkdir -p $(@D)/build-$(t) && \
84		$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) SRCDIR=$(@D) \
85			-C $(@D)/build-$(t) -f $(@D)/debian/makefiles/$(t).mk$(sep))
86endef
87
88define HOST_ANDROID_TOOLS_INSTALL_CMDS
89	$(foreach t,$(HOST_ANDROID_TOOLS_INSTALL_TARGETS),\
90		$(INSTALL) -D -m 0755 $(@D)/$(t) $(HOST_DIR)/bin/$(notdir $(t))$(sep))
91endef
92
93define ANDROID_TOOLS_INSTALL_TARGET_CMDS
94	$(foreach t,$(ANDROID_TOOLS_TARGETS),\
95		$(INSTALL) -D -m 0755 $(@D)/build-$(t)/$(t) $(TARGET_DIR)/usr/bin/$(t)$(sep))
96endef
97
98$(eval $(generic-package))
99$(eval $(host-generic-package))
100