blob: 6d68beceffa2da95840e406cc4fa348f636469df [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001# Copyright 2005 The Android Open Source Project
2#
3# Android.mk for adb
4#
5
6LOCAL_PATH:= $(call my-dir)
7
Dan Albert9113b472015-07-30 10:25:32 -07008adb_host_sanitize :=
9adb_target_sanitize :=
10
Dan Albert1ba1d7c2015-05-05 17:46:50 -070011adb_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
12
13ADB_COMMON_CFLAGS := \
Dan Albert23fee8f2015-05-20 18:56:10 -070014 -Wall -Wextra -Werror \
Dan Albert459df8f2015-07-08 13:50:42 -070015 -Wno-unused-parameter \
Dan Albert286bb6d2015-07-09 20:35:09 +000016 -Wno-missing-field-initializers \
Dan Albert1ba1d7c2015-05-05 17:46:50 -070017 -DADB_REVISION='"$(adb_version)"' \
18
Spencer Lowe347c1d2015-08-02 18:13:54 -070019# Define windows.h and tchar.h Unicode preprocessor symbols so that
20# CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
21# build if you accidentally pass char*. Fix by calling like:
22# CreateFileW(widen(utf8).c_str()).
23ADB_COMMON_windows_CFLAGS := \
24 -DUNICODE=1 -D_UNICODE=1 \
25
Dan Albert630b9af2014-11-24 23:34:35 -080026# libadb
27# =========================================================
28
29# Much of adb is duplicated in bootable/recovery/minadb and fastboot. Changes
30# made to adb rarely get ported to the other two, so the trees have diverged a
31# bit. We'd like to stop this because it is a maintenance nightmare, but the
32# divergence makes this difficult to do all at once. For now, we will start
33# small by moving common files into a static library. Hopefully some day we can
34# get enough of adb in here that we no longer need minadb. https://b/17626262
Dan Albertba3a2512015-02-18 17:47:33 -080035LIBADB_SRC_FILES := \
Dan Albertbac34742015-02-25 17:51:28 -080036 adb.cpp \
37 adb_auth.cpp \
Dan Albertcc731cc2015-02-24 21:26:58 -080038 adb_io.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080039 adb_listeners.cpp \
Elliott Hughes58305772015-04-17 13:57:15 -070040 adb_utils.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080041 sockets.cpp \
42 transport.cpp \
43 transport_local.cpp \
44 transport_usb.cpp \
Dan Albertba3a2512015-02-18 17:47:33 -080045
Elliott Hughes53daee62015-04-19 13:17:01 -070046LIBADB_TEST_SRCS := \
47 adb_io_test.cpp \
48 adb_utils_test.cpp \
49 transport_test.cpp \
50
Dan Albertbf106472015-02-20 17:20:09 -080051LIBADB_CFLAGS := \
Dan Albert1ba1d7c2015-05-05 17:46:50 -070052 $(ADB_COMMON_CFLAGS) \
Dan Albertba3a2512015-02-18 17:47:33 -080053 -fvisibility=hidden \
Elliott Hughes4f1d7b52015-07-24 14:32:46 -070054
55LIBADB_linux_CFLAGS := \
Elliott Hughes812f0302015-07-23 15:20:09 -070056 -std=c++14 \
Dan Albert630b9af2014-11-24 23:34:35 -080057
Dan Willemsen87a419c2015-08-13 14:43:34 -070058LIBADB_windows_CFLAGS := \
59 $(ADB_COMMON_windows_CFLAGS) \
Elliott Hughes4f1d7b52015-07-24 14:32:46 -070060
Dan Albertbac34742015-02-25 17:51:28 -080061LIBADB_darwin_SRC_FILES := \
62 fdevent.cpp \
Elliott Hughes1a4d85a2015-04-16 13:24:58 -070063 get_my_path_darwin.cpp \
Dan Albert7447dd02015-04-16 19:20:40 -070064 usb_osx.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080065
66LIBADB_linux_SRC_FILES := \
67 fdevent.cpp \
68 get_my_path_linux.cpp \
69 usb_linux.cpp \
70
71LIBADB_windows_SRC_FILES := \
Elliott Hughesa2f2e562015-04-16 16:47:02 -070072 sysdeps_win32.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080073 usb_windows.cpp \
Dan Albert94493762014-11-25 11:00:56 -080074
Yabin Cuibec02fc2015-08-28 15:44:27 -070075LIBADB_TEST_linux_SRCS := \
76 fdevent_test.cpp \
77
78LIBADB_TEST_darwin_SRCS := \
79 fdevent_test.cpp \
80
Spencer Lowe6ae5732015-09-08 17:13:04 -070081LIBADB_TEST_windows_SRCS := \
82 sysdeps_win32_test.cpp \
83
Dan Albert94493762014-11-25 11:00:56 -080084include $(CLEAR_VARS)
Elliott Hughes2acec912015-04-16 14:12:50 -070085LOCAL_CLANG := true
Dan Albert94493762014-11-25 11:00:56 -080086LOCAL_MODULE := libadbd
87LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=0
Dan Albert21c3eaf2015-02-18 17:20:44 -080088LOCAL_SRC_FILES := \
89 $(LIBADB_SRC_FILES) \
Dan Albertbac34742015-02-25 17:51:28 -080090 adb_auth_client.cpp \
Dan Albert3c438582015-02-20 17:24:30 -080091 fdevent.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080092 jdwp_service.cpp \
Elliott Hughes2acec912015-04-16 14:12:50 -070093 usb_linux_client.cpp \
Dan Albert21c3eaf2015-02-18 17:20:44 -080094
Dan Albert9113b472015-07-30 10:25:32 -070095LOCAL_SANITIZE := $(adb_target_sanitize)
Elliott Hughes7b506092015-04-20 08:09:20 -070096
Dan Alberte2462192015-03-19 13:25:27 -070097# Even though we're building a static library (and thus there's no link step for
98# this to take effect), this adds the includes to our path.
99LOCAL_STATIC_LIBRARIES := libbase
100
Dan Albert94493762014-11-25 11:00:56 -0800101include $(BUILD_STATIC_LIBRARY)
102
Dan Albert630b9af2014-11-24 23:34:35 -0800103include $(CLEAR_VARS)
104LOCAL_MODULE := libadb
Dan Willemsen87a419c2015-08-13 14:43:34 -0700105LOCAL_MODULE_HOST_OS := darwin linux windows
Dan Albert94493762014-11-25 11:00:56 -0800106LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=1
Dan Willemsen87a419c2015-08-13 14:43:34 -0700107LOCAL_CFLAGS_windows := $(LIBADB_windows_CFLAGS)
108LOCAL_CFLAGS_linux := $(LIBADB_linux_CFLAGS)
Dan Alberte1ca6232015-02-19 13:19:42 -0800109LOCAL_SRC_FILES := \
110 $(LIBADB_SRC_FILES) \
Dan Albertbac34742015-02-25 17:51:28 -0800111 adb_auth_host.cpp \
Dan Albert630b9af2014-11-24 23:34:35 -0800112
Dan Willemsen87a419c2015-08-13 14:43:34 -0700113LOCAL_SRC_FILES_darwin := $(LIBADB_darwin_SRC_FILES)
114LOCAL_SRC_FILES_linux := $(LIBADB_linux_SRC_FILES)
115LOCAL_SRC_FILES_windows := $(LIBADB_windows_SRC_FILES)
116
Dan Albert9113b472015-07-30 10:25:32 -0700117LOCAL_SANITIZE := $(adb_host_sanitize)
Elliott Hughes7b506092015-04-20 08:09:20 -0700118
Dan Alberte1ca6232015-02-19 13:19:42 -0800119# Even though we're building a static library (and thus there's no link step for
Dan Alberte2462192015-03-19 13:25:27 -0700120# this to take effect), this adds the includes to our path.
121LOCAL_STATIC_LIBRARIES := libcrypto_static libbase
Dan Alberte1ca6232015-02-19 13:19:42 -0800122
Dan Willemsen87a419c2015-08-13 14:43:34 -0700123LOCAL_C_INCLUDES_windows := development/host/windows/usb/api/
Dan Willemsen66680c52015-09-03 20:29:56 -0700124LOCAL_MULTILIB := first
Dan Albert88cf1c82015-02-24 14:08:03 -0800125
Dan Albert630b9af2014-11-24 23:34:35 -0800126include $(BUILD_HOST_STATIC_LIBRARY)
127
Dan Albert055f1aa2015-02-20 17:24:58 -0800128include $(CLEAR_VARS)
Elliott Hughes53daee62015-04-19 13:17:01 -0700129LOCAL_CLANG := true
Dan Albert055f1aa2015-02-20 17:24:58 -0800130LOCAL_MODULE := adbd_test
131LOCAL_CFLAGS := -DADB_HOST=0 $(LIBADB_CFLAGS)
Yabin Cuibec02fc2015-08-28 15:44:27 -0700132LOCAL_SRC_FILES := \
133 $(LIBADB_TEST_SRCS) \
134 $(LIBADB_TEST_linux_SRCS) \
David Pursell0955c662015-08-31 10:42:13 -0700135 shell_service.cpp \
David Pursellb9e2e842015-08-31 15:36:18 -0700136 shell_service_protocol.cpp \
137 shell_service_protocol_test.cpp \
David Pursell0955c662015-08-31 10:42:13 -0700138 shell_service_test.cpp \
Yabin Cuibec02fc2015-08-28 15:44:27 -0700139
Dan Albert9113b472015-07-30 10:25:32 -0700140LOCAL_SANITIZE := $(adb_target_sanitize)
Dan Albert055f1aa2015-02-20 17:24:58 -0800141LOCAL_STATIC_LIBRARIES := libadbd
Yabin Cuicb992d92015-09-08 18:27:10 -0700142LOCAL_SHARED_LIBRARIES := libbase libcutils
Dan Albert055f1aa2015-02-20 17:24:58 -0800143include $(BUILD_NATIVE_TEST)
144
Spencer Lowcf168a82015-05-24 15:36:28 -0700145# adb_test
146# =========================================================
147
Dan Albert055f1aa2015-02-20 17:24:58 -0800148include $(CLEAR_VARS)
Dan Albert055f1aa2015-02-20 17:24:58 -0800149LOCAL_MODULE := adb_test
Spencer Lowebf770f2015-09-07 23:39:02 -0700150LOCAL_MODULE_HOST_OS := darwin linux windows
Dan Albert055f1aa2015-02-20 17:24:58 -0800151LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
Dan Willemsen87a419c2015-08-13 14:43:34 -0700152LOCAL_CFLAGS_windows := $(LIBADB_windows_CFLAGS)
153LOCAL_CFLAGS_linux := $(LIBADB_linux_CFLAGS)
David Pursellb9e2e842015-08-31 15:36:18 -0700154LOCAL_SRC_FILES := \
155 $(LIBADB_TEST_SRCS) \
156 services.cpp \
157 shell_service_protocol.cpp \
158 shell_service_protocol_test.cpp \
159
David Pursellb404dec2015-09-11 16:06:59 -0700160LOCAL_SRC_FILES_linux := $(LIBADB_TEST_linux_SRCS)
Dan Willemsen87a419c2015-08-13 14:43:34 -0700161LOCAL_SRC_FILES_darwin := $(LIBADB_TEST_darwin_SRCS)
Spencer Lowe6ae5732015-09-08 17:13:04 -0700162LOCAL_SRC_FILES_windows := $(LIBADB_TEST_windows_SRCS)
Dan Albert9113b472015-07-30 10:25:32 -0700163LOCAL_SANITIZE := $(adb_host_sanitize)
Yabin Cuicb992d92015-09-08 18:27:10 -0700164LOCAL_SHARED_LIBRARIES := libbase
Dan Albert055f1aa2015-02-20 17:24:58 -0800165LOCAL_STATIC_LIBRARIES := \
166 libadb \
167 libcrypto_static \
168 libcutils \
169
Spencer Lowe6ae5732015-09-08 17:13:04 -0700170# Set entrypoint to wmain from sysdeps_win32.cpp instead of main
171LOCAL_LDFLAGS_windows := -municode
Dan Willemsen87a419c2015-08-13 14:43:34 -0700172LOCAL_LDLIBS_linux := -lrt -ldl -lpthread
173LOCAL_LDLIBS_darwin := -framework CoreFoundation -framework IOKit
174LOCAL_LDLIBS_windows := -lws2_32 -luserenv
175LOCAL_STATIC_LIBRARIES_windows := AdbWinApi
Dan Albert055f1aa2015-02-20 17:24:58 -0800176
Spencer Lowcf168a82015-05-24 15:36:28 -0700177include $(BUILD_HOST_NATIVE_TEST)
178
Elliott Hughese67f1f82015-04-30 17:32:03 -0700179# adb device tracker (used by ddms) test tool
180# =========================================================
181
182ifeq ($(HOST_OS),linux)
183include $(CLEAR_VARS)
Elliott Hughese67f1f82015-04-30 17:32:03 -0700184LOCAL_MODULE := adb_device_tracker_test
185LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
Dan Willemsen87a419c2015-08-13 14:43:34 -0700186LOCAL_CFLAGS_windows := $(LIBADB_windows_CFLAGS)
187LOCAL_CFLAGS_linux := $(LIBADB_linux_CFLAGS)
Elliott Hughese67f1f82015-04-30 17:32:03 -0700188LOCAL_SRC_FILES := test_track_devices.cpp
Dan Albert9113b472015-07-30 10:25:32 -0700189LOCAL_SANITIZE := $(adb_host_sanitize)
Yabin Cuicb992d92015-09-08 18:27:10 -0700190LOCAL_SHARED_LIBRARIES := libbase
Elliott Hughese67f1f82015-04-30 17:32:03 -0700191LOCAL_STATIC_LIBRARIES := libadb libcrypto_static libcutils
192LOCAL_LDLIBS += -lrt -ldl -lpthread
193include $(BUILD_HOST_EXECUTABLE)
194endif
195
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800196# adb host tool
197# =========================================================
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800198include $(CLEAR_VARS)
199
Dan Willemsen87a419c2015-08-13 14:43:34 -0700200LOCAL_LDLIBS_linux := -lrt -ldl -lpthread
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800201
Dan Willemsen87a419c2015-08-13 14:43:34 -0700202LOCAL_LDLIBS_darwin := -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
203LOCAL_CFLAGS_darwin := -Wno-sizeof-pointer-memaccess -Wno-unused-parameter
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800204
Dan Willemsen87a419c2015-08-13 14:43:34 -0700205# Use wmain instead of main
206LOCAL_LDFLAGS_windows := -municode
207LOCAL_LDLIBS_windows := -lws2_32 -lgdi32
208LOCAL_STATIC_LIBRARIES_windows := AdbWinApi
209LOCAL_REQUIRED_MODULES_windows := AdbWinApi AdbWinUsbApi
Dan Albert9697ce52015-02-20 17:28:44 -0800210
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800211LOCAL_SRC_FILES := \
Dan Albertc89e0cc2015-05-08 16:13:53 -0700212 client/main.cpp \
Dan Albertbac34742015-02-25 17:51:28 -0800213 console.cpp \
214 commandline.cpp \
215 adb_client.cpp \
216 services.cpp \
217 file_sync_client.cpp \
David Pursellb9e2e842015-08-31 15:36:18 -0700218 shell_service_protocol.cpp \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800219
Dan Albert7fd821e2015-02-24 22:38:21 -0800220LOCAL_CFLAGS += \
Dan Albert1ba1d7c2015-05-05 17:46:50 -0700221 $(ADB_COMMON_CFLAGS) \
Dan Albert7fd821e2015-02-24 22:38:21 -0800222 -D_GNU_SOURCE \
223 -DADB_HOST=1 \
224
Dan Willemsen87a419c2015-08-13 14:43:34 -0700225LOCAL_CFLAGS_windows := \
226 $(ADB_COMMON_windows_CFLAGS)
227
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800228LOCAL_MODULE := adb
Kenny Rootd5d6d972012-09-26 09:58:07 -0700229LOCAL_MODULE_TAGS := debug
Dan Willemsen87a419c2015-08-13 14:43:34 -0700230LOCAL_MODULE_HOST_OS := darwin linux windows
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800231
Dan Albert9113b472015-07-30 10:25:32 -0700232LOCAL_SANITIZE := $(adb_host_sanitize)
Dan Albert630b9af2014-11-24 23:34:35 -0800233LOCAL_STATIC_LIBRARIES := \
234 libadb \
Elliott Hughes2baae3a2015-04-17 10:59:34 -0700235 libbase \
Dan Albert630b9af2014-11-24 23:34:35 -0800236 libcrypto_static \
Elliott Hughes53daee62015-04-19 13:17:01 -0700237 libcutils \
Elliott Hughes9309ecb2015-04-27 14:20:17 -0700238 liblog \
Dan Albert630b9af2014-11-24 23:34:35 -0800239
Dan Willemsen87a419c2015-08-13 14:43:34 -0700240LOCAL_CXX_STL := libc++_static
Colin Cross55bf5f02015-04-16 16:21:44 -0700241
242# Don't add anything here, we don't want additional shared dependencies
243# on the host adb tool, and shared libraries that link against libc++
244# will violate ODR
245LOCAL_SHARED_LIBRARIES :=
246
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800247include $(BUILD_HOST_EXECUTABLE)
248
Ying Wang96535ba2012-09-05 10:26:43 -0700249$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800250
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800251
252# adbd device daemon
253# =========================================================
254
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800255include $(CLEAR_VARS)
256
Elliott Hughes53daee62015-04-19 13:17:01 -0700257LOCAL_CLANG := true
Dan Albert9697ce52015-02-20 17:28:44 -0800258
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800259LOCAL_SRC_FILES := \
Dan Albertc89e0cc2015-05-08 16:13:53 -0700260 daemon/main.cpp \
Dan Albertbac34742015-02-25 17:51:28 -0800261 services.cpp \
262 file_sync_service.cpp \
263 framebuffer_service.cpp \
264 remount_service.cpp \
265 set_verity_enable_state_service.cpp \
David Pursell80f67022015-08-28 15:08:49 -0700266 shell_service.cpp \
David Pursellb9e2e842015-08-31 15:36:18 -0700267 shell_service_protocol.cpp \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800268
Christopher Ferris51448eb2014-09-03 19:48:48 -0700269LOCAL_CFLAGS := \
Dan Albert1ba1d7c2015-05-05 17:46:50 -0700270 $(ADB_COMMON_CFLAGS) \
Dan Albertbac34742015-02-25 17:51:28 -0800271 -DADB_HOST=0 \
272 -D_GNU_SOURCE \
Dan Albertbac34742015-02-25 17:51:28 -0800273 -Wno-deprecated-declarations \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800274
Elliott Hughes5cba5042015-06-17 15:23:42 -0700275LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0)
Nick Kralevich5890fe32012-01-19 13:11:35 -0800276
Elliott Hughesec7a6672015-03-16 21:58:32 +0000277ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
Paul Lawrenceec900bb2014-10-09 14:22:49 +0000278LOCAL_CFLAGS += -DALLOW_ADBD_DISABLE_VERITY=1
Elliott Hughes5cba5042015-06-17 15:23:42 -0700279LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
Paul Lawrenceec900bb2014-10-09 14:22:49 +0000280endif
281
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800282LOCAL_MODULE := adbd
283
284LOCAL_FORCE_STATIC_EXECUTABLE := true
285LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
286LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
Tao Bao175b7bb2015-03-29 11:22:34 -0700287LOCAL_C_INCLUDES += system/extras/ext4_utils
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800288
Dan Albert9113b472015-07-30 10:25:32 -0700289LOCAL_SANITIZE := $(adb_target_sanitize)
Dan Albert630b9af2014-11-24 23:34:35 -0800290LOCAL_STATIC_LIBRARIES := \
Dan Albert94493762014-11-25 11:00:56 -0800291 libadbd \
Tao Bao175b7bb2015-03-29 11:22:34 -0700292 libbase \
Dan Albert030b76f2015-01-26 17:13:54 -0800293 libfs_mgr \
Dan Albert630b9af2014-11-24 23:34:35 -0800294 liblog \
Dan Albert630b9af2014-11-24 23:34:35 -0800295 libmincrypt \
296 libselinux \
Dan Albert030b76f2015-01-26 17:13:54 -0800297 libext4_utils_static \
Dan Alberte2462192015-03-19 13:25:27 -0700298 libcutils \
299 libbase \
Paul Lawrenceec900bb2014-10-09 14:22:49 +0000300
Jeff Brown29e1e732011-07-11 22:12:32 -0700301include $(BUILD_EXECUTABLE)