xref: /OK3568_Linux_fs/buildroot/package/android-tools/android-tools.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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
17ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_STATIC),y)
18ANDROID_TOOLS_LDFLAGS = -static -ldl
19endif
20
21# Extract the Debian tarball inside the sources
22define ANDROID_TOOLS_DEBIAN_EXTRACT
23	$(call suitable-extractor,$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS))) \
24		$(ANDROID_TOOLS_DL_DIR)/$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS)) | \
25		$(TAR) -C $(@D) $(TAR_OPTIONS) -
26endef
27
28HOST_ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
29ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
30
31# Apply the Debian patches before applying the Buildroot patches
32define ANDROID_TOOLS_DEBIAN_PATCH
33	$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*
34endef
35
36HOST_ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
37ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
38
39ifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_FASTBOOT),y)
40HOST_ANDROID_TOOLS_BUILD_TARGETS += fastboot
41HOST_ANDROID_TOOLS_INSTALL_TARGETS += build-fastboot/fastboot
42HOST_ANDROID_TOOLS_DEPENDENCIES += host-zlib host-libselinux
43endif
44
45ifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_ADB),y)
46HOST_ANDROID_TOOLS_BUILD_TARGETS += adb
47HOST_ANDROID_TOOLS_INSTALL_TARGETS += build-adb/adb
48HOST_ANDROID_TOOLS_DEPENDENCIES += host-zlib host-openssl
49endif
50
51ifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_EXT4_UTILS),y)
52HOST_ANDROID_TOOLS_BUILD_TARGETS += ext4_utils
53HOST_ANDROID_TOOLS_INSTALL_TARGETS += \
54	$(addprefix build-ext4_utils/,make_ext4fs ext4fixup ext2simg img2simg simg2img simg2simg)
55HOST_ANDROID_TOOLS_DEPENDENCIES += host-libselinux
56endif
57
58ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT),y)
59ANDROID_TOOLS_TARGETS += fastboot
60ANDROID_TOOLS_DEPENDENCIES += zlib libselinux
61endif
62
63ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADB),y)
64ANDROID_TOOLS_TARGETS += adb
65ANDROID_TOOLS_DEPENDENCIES += zlib openssl
66endif
67
68ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADBD),y)
69ANDROID_TOOLS_TARGETS += adbd
70ANDROID_TOOLS_DEPENDENCIES += zlib openssl
71endif
72
73# Build each tool in its own directory not to share object files
74
75define HOST_ANDROID_TOOLS_BUILD_CMDS
76	$(foreach t,$(HOST_ANDROID_TOOLS_BUILD_TARGETS),\
77		mkdir -p $(@D)/build-$(t) && \
78		$(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) SRCDIR=$(@D) \
79			-C $(@D)/build-$(t) -f $(@D)/debian/makefiles/$(t).mk$(sep))
80endef
81
82define ANDROID_TOOLS_BUILD_CMDS
83	$(foreach t,$(ANDROID_TOOLS_TARGETS),\
84		mkdir -p $(@D)/build-$(t) && \
85		$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) \
86			LDFLAGS="$(ANDROID_TOOLS_LDFLAGS)" $(MAKE) SRCDIR=$(@D) \
87			-C $(@D)/build-$(t) -f $(@D)/debian/makefiles/$(t).mk$(sep))
88endef
89
90define HOST_ANDROID_TOOLS_INSTALL_CMDS
91	$(foreach t,$(HOST_ANDROID_TOOLS_INSTALL_TARGETS),\
92		$(INSTALL) -D -m 0755 $(@D)/$(t) $(HOST_DIR)/bin/$(notdir $(t))$(sep))
93endef
94
95define ANDROID_TOOLS_INSTALL_TARGET_CMDS
96	$(foreach t,$(ANDROID_TOOLS_TARGETS),\
97		$(INSTALL) -D -m 0755 $(@D)/build-$(t)/$(t) $(TARGET_DIR)/usr/bin/$(t)$(sep))
98endef
99
100ifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADBD),y)
101define ANDROID_TOOLS_INSTALL_TARGET_SHELL
102	mkdir -p $(TARGET_DIR)/etc/profile.d
103	echo "[ -x /bin/bash ] && export ADBD_SHELL=/bin/bash" > \
104		$(TARGET_DIR)/etc/profile.d/adbd.sh
105endef
106ANDROID_TOOLS_PRE_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_SHELL
107
108ifneq ($(BR2_PACKAGE_ANDROID_TOOLS_TCP_PORT),0)
109define ANDROID_TOOLS_INSTALL_TARGET_TCP_PORT
110	echo "export ADB_TCP_PORT=$(BR2_PACKAGE_ANDROID_TOOLS_TCP_PORT)" >> \
111		$(TARGET_DIR)/etc/profile.d/adbd.sh
112endef
113ANDROID_TOOLS_POST_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_TCP_PORT
114endif
115
116ADBD_AUTH_PASSWORD = $(call qstrip,$(BR2_PACKAGE_ANDROID_TOOLS_AUTH_PASSWORD))
117ifneq ($(ADBD_AUTH_PASSWORD),)
118ADBD_AUTH_PASSWORD_MD5=$(shell echo $(ADBD_AUTH_PASSWORD) | md5sum)
119
120define ANDROID_TOOLS_INSTALL_TARGET_PASSWORD
121	$(INSTALL) -D -m 0755 $(ANDROID_TOOLS_PKGDIR)/adbd-auth \
122		$(TARGET_DIR)/usr/bin/adbd-auth
123	sed -i "s/AUTH_PASSWORD/${ADBD_AUTH_PASSWORD_MD5}/g" \
124		$(TARGET_DIR)/usr/bin/adbd-auth
125endef
126ANDROID_TOOLS_POST_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_PASSWORD
127endif
128
129ADBD_RSA_KEY = $(call qstrip,$(BR2_PACKAGE_ANDROID_TOOLS_AUTH_RSA_KEY))
130ifneq ($(ADBD_RSA_KEY),)
131define ANDROID_TOOLS_INSTALL_TARGET_RSA_KEY
132	echo "export ADBD_RSA_KEY_FILE=/etc/adbkey.pub" >> \
133		$(TARGET_DIR)/etc/profile.d/adbd.sh
134	$(INSTALL) -D -m 0644 $(ADBD_RSA_KEY) $(TARGET_DIR)/etc/adbkey.pub
135endef
136ANDROID_TOOLS_POST_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_RSA_KEY
137endif
138
139endif
140
141$(eval $(generic-package))
142$(eval $(host-generic-package))
143