xref: /OK3568_Linux_fs/buildroot/package/android-tools/android-tools.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun################################################################################
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# android-tools
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun################################################################################
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunANDROID_TOOLS_SITE = https://launchpad.net/ubuntu/+archive/primary/+files
8*4882a593SmuzhiyunANDROID_TOOLS_VERSION = 4.2.2+git20130218
9*4882a593SmuzhiyunANDROID_TOOLS_SOURCE = android-tools_$(ANDROID_TOOLS_VERSION).orig.tar.xz
10*4882a593SmuzhiyunANDROID_TOOLS_EXTRA_DOWNLOADS = android-tools_$(ANDROID_TOOLS_VERSION)-3ubuntu41.debian.tar.gz
11*4882a593SmuzhiyunHOST_ANDROID_TOOLS_EXTRA_DOWNLOADS = $(ANDROID_TOOLS_EXTRA_DOWNLOADS)
12*4882a593SmuzhiyunANDROID_TOOLS_LICENSE = Apache-2.0
13*4882a593SmuzhiyunANDROID_TOOLS_LICENSE_FILES = debian/copyright
14*4882a593SmuzhiyunANDROID_TOOLS_DEPENDENCIES = host-pkgconf
15*4882a593SmuzhiyunHOST_ANDROID_TOOLS_DEPENDENCIES = host-pkgconf
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_ANDROID_TOOLS_STATIC),y)
18*4882a593SmuzhiyunANDROID_TOOLS_LDFLAGS = -static -ldl
19*4882a593Smuzhiyunendif
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun# Extract the Debian tarball inside the sources
22*4882a593Smuzhiyundefine ANDROID_TOOLS_DEBIAN_EXTRACT
23*4882a593Smuzhiyun	$(call suitable-extractor,$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS))) \
24*4882a593Smuzhiyun		$(ANDROID_TOOLS_DL_DIR)/$(notdir $(ANDROID_TOOLS_EXTRA_DOWNLOADS)) | \
25*4882a593Smuzhiyun		$(TAR) -C $(@D) $(TAR_OPTIONS) -
26*4882a593Smuzhiyunendef
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunHOST_ANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
29*4882a593SmuzhiyunANDROID_TOOLS_POST_EXTRACT_HOOKS += ANDROID_TOOLS_DEBIAN_EXTRACT
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun# Apply the Debian patches before applying the Buildroot patches
32*4882a593Smuzhiyundefine ANDROID_TOOLS_DEBIAN_PATCH
33*4882a593Smuzhiyun	$(APPLY_PATCHES) $(@D) $(@D)/debian/patches \*
34*4882a593Smuzhiyunendef
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunHOST_ANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
37*4882a593SmuzhiyunANDROID_TOOLS_PRE_PATCH_HOOKS += ANDROID_TOOLS_DEBIAN_PATCH
38*4882a593Smuzhiyun
39*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_FASTBOOT),y)
40*4882a593SmuzhiyunHOST_ANDROID_TOOLS_BUILD_TARGETS += fastboot
41*4882a593SmuzhiyunHOST_ANDROID_TOOLS_INSTALL_TARGETS += build-fastboot/fastboot
42*4882a593SmuzhiyunHOST_ANDROID_TOOLS_DEPENDENCIES += host-zlib host-libselinux
43*4882a593Smuzhiyunendif
44*4882a593Smuzhiyun
45*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_ADB),y)
46*4882a593SmuzhiyunHOST_ANDROID_TOOLS_BUILD_TARGETS += adb
47*4882a593SmuzhiyunHOST_ANDROID_TOOLS_INSTALL_TARGETS += build-adb/adb
48*4882a593SmuzhiyunHOST_ANDROID_TOOLS_DEPENDENCIES += host-zlib host-openssl
49*4882a593Smuzhiyunendif
50*4882a593Smuzhiyun
51*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_HOST_ANDROID_TOOLS_EXT4_UTILS),y)
52*4882a593SmuzhiyunHOST_ANDROID_TOOLS_BUILD_TARGETS += ext4_utils
53*4882a593SmuzhiyunHOST_ANDROID_TOOLS_INSTALL_TARGETS += \
54*4882a593Smuzhiyun	$(addprefix build-ext4_utils/,make_ext4fs ext4fixup ext2simg img2simg simg2img simg2simg)
55*4882a593SmuzhiyunHOST_ANDROID_TOOLS_DEPENDENCIES += host-libselinux
56*4882a593Smuzhiyunendif
57*4882a593Smuzhiyun
58*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_ANDROID_TOOLS_FASTBOOT),y)
59*4882a593SmuzhiyunANDROID_TOOLS_TARGETS += fastboot
60*4882a593SmuzhiyunANDROID_TOOLS_DEPENDENCIES += zlib libselinux
61*4882a593Smuzhiyunendif
62*4882a593Smuzhiyun
63*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADB),y)
64*4882a593SmuzhiyunANDROID_TOOLS_TARGETS += adb
65*4882a593SmuzhiyunANDROID_TOOLS_DEPENDENCIES += zlib openssl
66*4882a593Smuzhiyunendif
67*4882a593Smuzhiyun
68*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADBD),y)
69*4882a593SmuzhiyunANDROID_TOOLS_TARGETS += adbd
70*4882a593SmuzhiyunANDROID_TOOLS_DEPENDENCIES += zlib openssl
71*4882a593Smuzhiyunendif
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun# Build each tool in its own directory not to share object files
74*4882a593Smuzhiyun
75*4882a593Smuzhiyundefine HOST_ANDROID_TOOLS_BUILD_CMDS
76*4882a593Smuzhiyun	$(foreach t,$(HOST_ANDROID_TOOLS_BUILD_TARGETS),\
77*4882a593Smuzhiyun		mkdir -p $(@D)/build-$(t) && \
78*4882a593Smuzhiyun		$(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) SRCDIR=$(@D) \
79*4882a593Smuzhiyun			-C $(@D)/build-$(t) -f $(@D)/debian/makefiles/$(t).mk$(sep))
80*4882a593Smuzhiyunendef
81*4882a593Smuzhiyun
82*4882a593Smuzhiyundefine ANDROID_TOOLS_BUILD_CMDS
83*4882a593Smuzhiyun	$(foreach t,$(ANDROID_TOOLS_TARGETS),\
84*4882a593Smuzhiyun		mkdir -p $(@D)/build-$(t) && \
85*4882a593Smuzhiyun		$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) \
86*4882a593Smuzhiyun			LDFLAGS="$(ANDROID_TOOLS_LDFLAGS)" $(MAKE) SRCDIR=$(@D) \
87*4882a593Smuzhiyun			-C $(@D)/build-$(t) -f $(@D)/debian/makefiles/$(t).mk$(sep))
88*4882a593Smuzhiyunendef
89*4882a593Smuzhiyun
90*4882a593Smuzhiyundefine HOST_ANDROID_TOOLS_INSTALL_CMDS
91*4882a593Smuzhiyun	$(foreach t,$(HOST_ANDROID_TOOLS_INSTALL_TARGETS),\
92*4882a593Smuzhiyun		$(INSTALL) -D -m 0755 $(@D)/$(t) $(HOST_DIR)/bin/$(notdir $(t))$(sep))
93*4882a593Smuzhiyunendef
94*4882a593Smuzhiyun
95*4882a593Smuzhiyundefine ANDROID_TOOLS_INSTALL_TARGET_CMDS
96*4882a593Smuzhiyun	$(foreach t,$(ANDROID_TOOLS_TARGETS),\
97*4882a593Smuzhiyun		$(INSTALL) -D -m 0755 $(@D)/build-$(t)/$(t) $(TARGET_DIR)/usr/bin/$(t)$(sep))
98*4882a593Smuzhiyunendef
99*4882a593Smuzhiyun
100*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_ANDROID_TOOLS_ADBD),y)
101*4882a593Smuzhiyundefine ANDROID_TOOLS_INSTALL_TARGET_SHELL
102*4882a593Smuzhiyun	mkdir -p $(TARGET_DIR)/etc/profile.d
103*4882a593Smuzhiyun	echo "[ -x /bin/bash ] && export ADBD_SHELL=/bin/bash" > \
104*4882a593Smuzhiyun		$(TARGET_DIR)/etc/profile.d/adbd.sh
105*4882a593Smuzhiyunendef
106*4882a593SmuzhiyunANDROID_TOOLS_PRE_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_SHELL
107*4882a593Smuzhiyun
108*4882a593Smuzhiyunifneq ($(BR2_PACKAGE_ANDROID_TOOLS_TCP_PORT),0)
109*4882a593Smuzhiyundefine ANDROID_TOOLS_INSTALL_TARGET_TCP_PORT
110*4882a593Smuzhiyun	echo "export ADB_TCP_PORT=$(BR2_PACKAGE_ANDROID_TOOLS_TCP_PORT)" >> \
111*4882a593Smuzhiyun		$(TARGET_DIR)/etc/profile.d/adbd.sh
112*4882a593Smuzhiyunendef
113*4882a593SmuzhiyunANDROID_TOOLS_POST_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_TCP_PORT
114*4882a593Smuzhiyunendif
115*4882a593Smuzhiyun
116*4882a593SmuzhiyunADBD_AUTH_PASSWORD = $(call qstrip,$(BR2_PACKAGE_ANDROID_TOOLS_AUTH_PASSWORD))
117*4882a593Smuzhiyunifneq ($(ADBD_AUTH_PASSWORD),)
118*4882a593SmuzhiyunADBD_AUTH_PASSWORD_MD5=$(shell echo $(ADBD_AUTH_PASSWORD) | md5sum)
119*4882a593Smuzhiyun
120*4882a593Smuzhiyundefine ANDROID_TOOLS_INSTALL_TARGET_PASSWORD
121*4882a593Smuzhiyun	$(INSTALL) -D -m 0755 $(ANDROID_TOOLS_PKGDIR)/adbd-auth \
122*4882a593Smuzhiyun		$(TARGET_DIR)/usr/bin/adbd-auth
123*4882a593Smuzhiyun	sed -i "s/AUTH_PASSWORD/${ADBD_AUTH_PASSWORD_MD5}/g" \
124*4882a593Smuzhiyun		$(TARGET_DIR)/usr/bin/adbd-auth
125*4882a593Smuzhiyunendef
126*4882a593SmuzhiyunANDROID_TOOLS_POST_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_PASSWORD
127*4882a593Smuzhiyunendif
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunADBD_RSA_KEY = $(call qstrip,$(BR2_PACKAGE_ANDROID_TOOLS_AUTH_RSA_KEY))
130*4882a593Smuzhiyunifneq ($(ADBD_RSA_KEY),)
131*4882a593Smuzhiyundefine ANDROID_TOOLS_INSTALL_TARGET_RSA_KEY
132*4882a593Smuzhiyun	echo "export ADBD_RSA_KEY_FILE=/etc/adbkey.pub" >> \
133*4882a593Smuzhiyun		$(TARGET_DIR)/etc/profile.d/adbd.sh
134*4882a593Smuzhiyun	$(INSTALL) -D -m 0644 $(ADBD_RSA_KEY) $(TARGET_DIR)/etc/adbkey.pub
135*4882a593Smuzhiyunendef
136*4882a593SmuzhiyunANDROID_TOOLS_POST_INSTALL_TARGET_HOOKS += ANDROID_TOOLS_INSTALL_TARGET_RSA_KEY
137*4882a593Smuzhiyunendif
138*4882a593Smuzhiyun
139*4882a593Smuzhiyunendif
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun$(eval $(generic-package))
142*4882a593Smuzhiyun$(eval $(host-generic-package))
143