blob: f9d44415b58dc0273ad3609964835db429eb0b6e [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
Elliott Hughes53daee62015-04-19 13:17:01 -07008ifeq ($(HOST_OS),windows)
Dan Alberta7a67c32015-05-05 14:50:09 -07009 adb_host_clang := false # libc++ for mingw not ready yet.
Elliott Hughes53daee62015-04-19 13:17:01 -070010else
Dan Alberta7a67c32015-05-05 14:50:09 -070011 adb_host_clang := true
Elliott Hughes53daee62015-04-19 13:17:01 -070012endif
Dan Albert9697ce52015-02-20 17:28:44 -080013
Dan Albert9113b472015-07-30 10:25:32 -070014adb_host_sanitize :=
15adb_target_sanitize :=
16
Dan Albert1ba1d7c2015-05-05 17:46:50 -070017adb_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
18
19ADB_COMMON_CFLAGS := \
Dan Albert23fee8f2015-05-20 18:56:10 -070020 -Wall -Wextra -Werror \
Dan Albert459df8f2015-07-08 13:50:42 -070021 -Wno-unused-parameter \
Dan Albert286bb6d2015-07-09 20:35:09 +000022 -Wno-missing-field-initializers \
Dan Albert1ba1d7c2015-05-05 17:46:50 -070023 -DADB_REVISION='"$(adb_version)"' \
24
Spencer Lowe347c1d2015-08-02 18:13:54 -070025# Define windows.h and tchar.h Unicode preprocessor symbols so that
26# CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
27# build if you accidentally pass char*. Fix by calling like:
28# CreateFileW(widen(utf8).c_str()).
29ADB_COMMON_windows_CFLAGS := \
30 -DUNICODE=1 -D_UNICODE=1 \
31
32ADB_COMMON_CFLAGS += $(ADB_COMMON_$(HOST_OS)_CFLAGS)
33
Dan Albert630b9af2014-11-24 23:34:35 -080034# libadb
35# =========================================================
36
37# Much of adb is duplicated in bootable/recovery/minadb and fastboot. Changes
38# made to adb rarely get ported to the other two, so the trees have diverged a
39# bit. We'd like to stop this because it is a maintenance nightmare, but the
40# divergence makes this difficult to do all at once. For now, we will start
41# small by moving common files into a static library. Hopefully some day we can
42# get enough of adb in here that we no longer need minadb. https://b/17626262
Dan Albertba3a2512015-02-18 17:47:33 -080043LIBADB_SRC_FILES := \
Dan Albertbac34742015-02-25 17:51:28 -080044 adb.cpp \
45 adb_auth.cpp \
Dan Albertcc731cc2015-02-24 21:26:58 -080046 adb_io.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080047 adb_listeners.cpp \
Elliott Hughes58305772015-04-17 13:57:15 -070048 adb_utils.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080049 sockets.cpp \
50 transport.cpp \
51 transport_local.cpp \
52 transport_usb.cpp \
Dan Albertba3a2512015-02-18 17:47:33 -080053
Elliott Hughes53daee62015-04-19 13:17:01 -070054LIBADB_TEST_SRCS := \
55 adb_io_test.cpp \
56 adb_utils_test.cpp \
57 transport_test.cpp \
58
Dan Albertbf106472015-02-20 17:20:09 -080059LIBADB_CFLAGS := \
Dan Albert1ba1d7c2015-05-05 17:46:50 -070060 $(ADB_COMMON_CFLAGS) \
Dan Albertba3a2512015-02-18 17:47:33 -080061 -fvisibility=hidden \
Elliott Hughes4f1d7b52015-07-24 14:32:46 -070062
63LIBADB_linux_CFLAGS := \
Elliott Hughes812f0302015-07-23 15:20:09 -070064 -std=c++14 \
Dan Albert630b9af2014-11-24 23:34:35 -080065
Elliott Hughes4f1d7b52015-07-24 14:32:46 -070066LIBADB_CFLAGS += $(LIBADB_$(HOST_OS)_CFLAGS)
67
Dan Albertbac34742015-02-25 17:51:28 -080068LIBADB_darwin_SRC_FILES := \
69 fdevent.cpp \
Elliott Hughes1a4d85a2015-04-16 13:24:58 -070070 get_my_path_darwin.cpp \
Dan Albert7447dd02015-04-16 19:20:40 -070071 usb_osx.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080072
73LIBADB_linux_SRC_FILES := \
74 fdevent.cpp \
75 get_my_path_linux.cpp \
76 usb_linux.cpp \
77
78LIBADB_windows_SRC_FILES := \
Elliott Hughesa2f2e562015-04-16 16:47:02 -070079 sysdeps_win32.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080080 usb_windows.cpp \
Dan Albert94493762014-11-25 11:00:56 -080081
82include $(CLEAR_VARS)
Elliott Hughes2acec912015-04-16 14:12:50 -070083LOCAL_CLANG := true
Dan Albert94493762014-11-25 11:00:56 -080084LOCAL_MODULE := libadbd
85LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=0
Dan Albert21c3eaf2015-02-18 17:20:44 -080086LOCAL_SRC_FILES := \
87 $(LIBADB_SRC_FILES) \
Dan Albertbac34742015-02-25 17:51:28 -080088 adb_auth_client.cpp \
Dan Albert3c438582015-02-20 17:24:30 -080089 fdevent.cpp \
Dan Albertbac34742015-02-25 17:51:28 -080090 jdwp_service.cpp \
Elliott Hughes2acec912015-04-16 14:12:50 -070091 usb_linux_client.cpp \
Dan Albert21c3eaf2015-02-18 17:20:44 -080092
Dan Albert9113b472015-07-30 10:25:32 -070093LOCAL_SANITIZE := $(adb_target_sanitize)
Elliott Hughes7b506092015-04-20 08:09:20 -070094LOCAL_SHARED_LIBRARIES := libbase
95
Dan Alberte2462192015-03-19 13:25:27 -070096# Even though we're building a static library (and thus there's no link step for
97# this to take effect), this adds the includes to our path.
98LOCAL_STATIC_LIBRARIES := libbase
99
Dan Albert94493762014-11-25 11:00:56 -0800100include $(BUILD_STATIC_LIBRARY)
101
Dan Albert630b9af2014-11-24 23:34:35 -0800102include $(CLEAR_VARS)
Elliott Hughes53daee62015-04-19 13:17:01 -0700103LOCAL_CLANG := $(adb_host_clang)
Dan Albert630b9af2014-11-24 23:34:35 -0800104LOCAL_MODULE := libadb
Dan Albert94493762014-11-25 11:00:56 -0800105LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=1
Dan Alberte1ca6232015-02-19 13:19:42 -0800106LOCAL_SRC_FILES := \
107 $(LIBADB_SRC_FILES) \
Dan Albert3c438582015-02-20 17:24:30 -0800108 $(LIBADB_$(HOST_OS)_SRC_FILES) \
Dan Albertbac34742015-02-25 17:51:28 -0800109 adb_auth_host.cpp \
Dan Albert630b9af2014-11-24 23:34:35 -0800110
Dan Albert9113b472015-07-30 10:25:32 -0700111LOCAL_SANITIZE := $(adb_host_sanitize)
Elliott Hughes7b506092015-04-20 08:09:20 -0700112LOCAL_SHARED_LIBRARIES := libbase
113
Dan Alberte1ca6232015-02-19 13:19:42 -0800114# Even though we're building a static library (and thus there's no link step for
Dan Alberte2462192015-03-19 13:25:27 -0700115# this to take effect), this adds the includes to our path.
116LOCAL_STATIC_LIBRARIES := libcrypto_static libbase
Dan Alberte1ca6232015-02-19 13:19:42 -0800117
Dan Albert88cf1c82015-02-24 14:08:03 -0800118ifeq ($(HOST_OS),windows)
119 LOCAL_C_INCLUDES += development/host/windows/usb/api/
Elliott Hughesdaa6c462015-08-25 19:38:14 -0700120else
121 LOCAL_MULTILIB := 64
Dan Albert88cf1c82015-02-24 14:08:03 -0800122endif
123
Dan Albert630b9af2014-11-24 23:34:35 -0800124include $(BUILD_HOST_STATIC_LIBRARY)
125
Dan Albert055f1aa2015-02-20 17:24:58 -0800126include $(CLEAR_VARS)
Elliott Hughes53daee62015-04-19 13:17:01 -0700127LOCAL_CLANG := true
Dan Albert055f1aa2015-02-20 17:24:58 -0800128LOCAL_MODULE := adbd_test
129LOCAL_CFLAGS := -DADB_HOST=0 $(LIBADB_CFLAGS)
130LOCAL_SRC_FILES := $(LIBADB_TEST_SRCS)
Dan Albert9113b472015-07-30 10:25:32 -0700131LOCAL_SANITIZE := $(adb_target_sanitize)
Dan Albert055f1aa2015-02-20 17:24:58 -0800132LOCAL_STATIC_LIBRARIES := libadbd
Dan Albertc007bc32015-03-16 10:08:46 -0700133LOCAL_SHARED_LIBRARIES := liblog libbase libcutils
Dan Albert055f1aa2015-02-20 17:24:58 -0800134include $(BUILD_NATIVE_TEST)
135
Spencer Lowcf168a82015-05-24 15:36:28 -0700136# adb_test
137# =========================================================
138
Dan Albert055f1aa2015-02-20 17:24:58 -0800139include $(CLEAR_VARS)
Elliott Hughes53daee62015-04-19 13:17:01 -0700140LOCAL_CLANG := $(adb_host_clang)
Dan Albert055f1aa2015-02-20 17:24:58 -0800141LOCAL_MODULE := adb_test
142LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
Dan Albertbac34742015-02-25 17:51:28 -0800143LOCAL_SRC_FILES := $(LIBADB_TEST_SRCS) services.cpp
Dan Albert9113b472015-07-30 10:25:32 -0700144LOCAL_SANITIZE := $(adb_host_sanitize)
Dan Albertc007bc32015-03-16 10:08:46 -0700145LOCAL_SHARED_LIBRARIES := liblog libbase
Dan Albert055f1aa2015-02-20 17:24:58 -0800146LOCAL_STATIC_LIBRARIES := \
147 libadb \
148 libcrypto_static \
149 libcutils \
150
151ifeq ($(HOST_OS),linux)
Dan Alberta7a67c32015-05-05 14:50:09 -0700152 LOCAL_LDLIBS += -lrt -ldl -lpthread
Dan Albert055f1aa2015-02-20 17:24:58 -0800153endif
154
Dan Albertf8d6b9b2015-04-16 19:13:58 -0700155ifeq ($(HOST_OS),darwin)
Dan Alberta7a67c32015-05-05 14:50:09 -0700156 LOCAL_LDLIBS += -framework CoreFoundation -framework IOKit
Dan Albertf8d6b9b2015-04-16 19:13:58 -0700157endif
158
Spencer Lowcf168a82015-05-24 15:36:28 -0700159ifeq ($(HOST_OS),windows)
160 LOCAL_LDLIBS += -lws2_32 -luserenv
161 LOCAL_STATIC_LIBRARIES += AdbWinApi
Dan Alberta7a67c32015-05-05 14:50:09 -0700162endif
Dan Albert055f1aa2015-02-20 17:24:58 -0800163
Spencer Lowcf168a82015-05-24 15:36:28 -0700164include $(BUILD_HOST_NATIVE_TEST)
165
Elliott Hughese67f1f82015-04-30 17:32:03 -0700166# adb device tracker (used by ddms) test tool
167# =========================================================
168
169ifeq ($(HOST_OS),linux)
170include $(CLEAR_VARS)
171LOCAL_CLANG := $(adb_host_clang)
172LOCAL_MODULE := adb_device_tracker_test
173LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
174LOCAL_SRC_FILES := test_track_devices.cpp
Dan Albert9113b472015-07-30 10:25:32 -0700175LOCAL_SANITIZE := $(adb_host_sanitize)
Elliott Hughese67f1f82015-04-30 17:32:03 -0700176LOCAL_SHARED_LIBRARIES := liblog libbase
177LOCAL_STATIC_LIBRARIES := libadb libcrypto_static libcutils
178LOCAL_LDLIBS += -lrt -ldl -lpthread
179include $(BUILD_HOST_EXECUTABLE)
180endif
181
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800182# adb host tool
183# =========================================================
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800184include $(CLEAR_VARS)
185
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800186ifeq ($(HOST_OS),linux)
Spencer Low142ec752015-05-06 16:13:42 -0700187 LOCAL_LDLIBS += -lrt -ldl -lpthread
188 LOCAL_CFLAGS += -DWORKAROUND_BUG6558362
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800189endif
190
191ifeq ($(HOST_OS),darwin)
Spencer Low142ec752015-05-06 16:13:42 -0700192 LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
193 LOCAL_CFLAGS += -Wno-sizeof-pointer-memaccess -Wno-unused-parameter
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800194endif
195
196ifeq ($(HOST_OS),windows)
Spencer Lowcf4ff642015-05-11 01:08:48 -0700197 # Use wmain instead of main
198 LOCAL_LDFLAGS += -municode
Spencer Low142ec752015-05-06 16:13:42 -0700199 LOCAL_LDLIBS += -lws2_32 -lgdi32
200 EXTRA_STATIC_LIBS := AdbWinApi
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800201endif
202
Elliott Hughes53daee62015-04-19 13:17:01 -0700203LOCAL_CLANG := $(adb_host_clang)
Dan Albert9697ce52015-02-20 17:28:44 -0800204
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800205LOCAL_SRC_FILES := \
Dan Albertc89e0cc2015-05-08 16:13:53 -0700206 client/main.cpp \
Dan Albertbac34742015-02-25 17:51:28 -0800207 console.cpp \
208 commandline.cpp \
209 adb_client.cpp \
210 services.cpp \
211 file_sync_client.cpp \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800212
Dan Albert7fd821e2015-02-24 22:38:21 -0800213LOCAL_CFLAGS += \
Dan Albert1ba1d7c2015-05-05 17:46:50 -0700214 $(ADB_COMMON_CFLAGS) \
Dan Albert7fd821e2015-02-24 22:38:21 -0800215 -D_GNU_SOURCE \
216 -DADB_HOST=1 \
217
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800218LOCAL_MODULE := adb
Kenny Rootd5d6d972012-09-26 09:58:07 -0700219LOCAL_MODULE_TAGS := debug
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800220
Dan Albert9113b472015-07-30 10:25:32 -0700221LOCAL_SANITIZE := $(adb_host_sanitize)
Dan Albert630b9af2014-11-24 23:34:35 -0800222LOCAL_STATIC_LIBRARIES := \
223 libadb \
Elliott Hughes2baae3a2015-04-17 10:59:34 -0700224 libbase \
Dan Albert630b9af2014-11-24 23:34:35 -0800225 libcrypto_static \
Elliott Hughes53daee62015-04-19 13:17:01 -0700226 libcutils \
Elliott Hughes9309ecb2015-04-27 14:20:17 -0700227 liblog \
Dan Albert630b9af2014-11-24 23:34:35 -0800228 $(EXTRA_STATIC_LIBS) \
229
Colin Crossdc1e4822015-04-20 12:36:50 -0700230# libc++ not available on windows yet
231ifneq ($(HOST_OS),windows)
232 LOCAL_CXX_STL := libc++_static
233endif
Colin Cross55bf5f02015-04-16 16:21:44 -0700234
235# Don't add anything here, we don't want additional shared dependencies
236# on the host adb tool, and shared libraries that link against libc++
237# will violate ODR
238LOCAL_SHARED_LIBRARIES :=
239
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800240include $(BUILD_HOST_EXECUTABLE)
241
Ying Wang96535ba2012-09-05 10:26:43 -0700242$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800243
244ifeq ($(HOST_OS),windows)
Raphael26f3de62009-08-11 11:08:45 -0700245$(LOCAL_INSTALLED_MODULE): \
246 $(HOST_OUT_EXECUTABLES)/AdbWinApi.dll \
247 $(HOST_OUT_EXECUTABLES)/AdbWinUsbApi.dll
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800248endif
249
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800250
251# adbd device daemon
252# =========================================================
253
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800254include $(CLEAR_VARS)
255
Elliott Hughes53daee62015-04-19 13:17:01 -0700256LOCAL_CLANG := true
Dan Albert9697ce52015-02-20 17:28:44 -0800257
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800258LOCAL_SRC_FILES := \
Dan Albertc89e0cc2015-05-08 16:13:53 -0700259 daemon/main.cpp \
Dan Albertbac34742015-02-25 17:51:28 -0800260 services.cpp \
261 file_sync_service.cpp \
262 framebuffer_service.cpp \
263 remount_service.cpp \
264 set_verity_enable_state_service.cpp \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800265
Christopher Ferris51448eb2014-09-03 19:48:48 -0700266LOCAL_CFLAGS := \
Dan Albert1ba1d7c2015-05-05 17:46:50 -0700267 $(ADB_COMMON_CFLAGS) \
Dan Albertbac34742015-02-25 17:51:28 -0800268 -DADB_HOST=0 \
269 -D_GNU_SOURCE \
Dan Albertbac34742015-02-25 17:51:28 -0800270 -Wno-deprecated-declarations \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800271
Elliott Hughes5cba5042015-06-17 15:23:42 -0700272LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0)
Nick Kralevich5890fe32012-01-19 13:11:35 -0800273
Elliott Hughesec7a6672015-03-16 21:58:32 +0000274ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
Paul Lawrenceec900bb2014-10-09 14:22:49 +0000275LOCAL_CFLAGS += -DALLOW_ADBD_DISABLE_VERITY=1
Elliott Hughes5cba5042015-06-17 15:23:42 -0700276LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
Paul Lawrenceec900bb2014-10-09 14:22:49 +0000277endif
278
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800279LOCAL_MODULE := adbd
280
Tom Cherry20391b12015-08-14 13:02:51 -0700281LOCAL_INIT_RC := adbd.rc
282
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800283LOCAL_FORCE_STATIC_EXECUTABLE := true
284LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
285LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
Tao Bao175b7bb2015-03-29 11:22:34 -0700286LOCAL_C_INCLUDES += system/extras/ext4_utils
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800287
Dan Albert9113b472015-07-30 10:25:32 -0700288LOCAL_SANITIZE := $(adb_target_sanitize)
Dan Albert630b9af2014-11-24 23:34:35 -0800289LOCAL_STATIC_LIBRARIES := \
Dan Albert94493762014-11-25 11:00:56 -0800290 libadbd \
Tao Bao175b7bb2015-03-29 11:22:34 -0700291 libbase \
Dan Albert030b76f2015-01-26 17:13:54 -0800292 libfs_mgr \
Dan Albert630b9af2014-11-24 23:34:35 -0800293 liblog \
Dan Albert630b9af2014-11-24 23:34:35 -0800294 libmincrypt \
295 libselinux \
Dan Albert030b76f2015-01-26 17:13:54 -0800296 libext4_utils_static \
Dan Alberte2462192015-03-19 13:25:27 -0700297 libcutils \
298 libbase \
Paul Lawrenceec900bb2014-10-09 14:22:49 +0000299
Jeff Brown29e1e732011-07-11 22:12:32 -0700300include $(BUILD_EXECUTABLE)