1# Copyright (C) 2007 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH:= $(call my-dir)
16
17fastboot_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
18
19include $(CLEAR_VARS)
20
21LOCAL_C_INCLUDES := $(LOCAL_PATH)/../mkbootimg \
22  $(LOCAL_PATH)/../../extras/ext4_utils \
23  $(LOCAL_PATH)/../../extras/f2fs_utils
24LOCAL_SRC_FILES := protocol.c engine.c bootimg_utils.cpp fastboot.cpp util.c fs.c
25LOCAL_MODULE := fastboot
26LOCAL_MODULE_TAGS := debug
27LOCAL_CONLYFLAGS += -std=gnu99
28LOCAL_CFLAGS += -Wall -Wextra -Werror -Wunreachable-code
29
30LOCAL_CFLAGS += -DFASTBOOT_REVISION='"$(fastboot_version)"'
31
32ifeq ($(HOST_OS),linux)
33  LOCAL_SRC_FILES += usb_linux.c util_linux.c
34endif
35
36ifeq ($(HOST_OS),darwin)
37  LOCAL_SRC_FILES += usb_osx.c util_osx.c
38  LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
39  LOCAL_CFLAGS += -Wno-unused-parameter
40endif
41
42ifeq ($(HOST_OS),windows)
43  LOCAL_SRC_FILES += usb_windows.c util_windows.c
44  EXTRA_STATIC_LIBS := AdbWinApi
45  ifneq ($(strip $(USE_CYGWIN)),)
46    # Pure cygwin case
47    LOCAL_LDLIBS += -lpthread
48  endif
49  ifneq ($(strip $(USE_MINGW)),)
50    # MinGW under Linux case
51    LOCAL_LDLIBS += -lws2_32
52    USE_SYSDEPS_WIN32 := 1
53  endif
54  LOCAL_C_INCLUDES += development/host/windows/usb/api
55endif
56
57LOCAL_STATIC_LIBRARIES := \
58    $(EXTRA_STATIC_LIBS) \
59    libziparchive-host \
60    libext4_utils_host \
61    libsparse_host \
62    libutils \
63    liblog \
64    libz \
65    libbase
66
67ifneq ($(HOST_OS),windows)
68LOCAL_STATIC_LIBRARIES += libselinux
69endif # HOST_OS != windows
70
71ifeq ($(HOST_OS),linux)
72# libf2fs_dlutils_host will dlopen("libf2fs_fmt_host_dyn")
73LOCAL_CFLAGS += -DUSE_F2FS
74LOCAL_LDFLAGS += -ldl -rdynamic -Wl,-rpath,.
75LOCAL_REQUIRED_MODULES := libf2fs_fmt_host_dyn
76# The following libf2fs_* are from system/extras/f2fs_utils,
77# and do not use code in external/f2fs-tools.
78LOCAL_STATIC_LIBRARIES += libf2fs_utils_host libf2fs_ioutils_host libf2fs_dlutils_host
79endif
80
81# libc++ not available on windows yet
82ifneq ($(HOST_OS),windows)
83    LOCAL_CXX_STL := libc++_static
84endif
85
86# Don't add anything here, we don't want additional shared dependencies
87# on the host fastboot tool, and shared libraries that link against libc++
88# will violate ODR
89LOCAL_SHARED_LIBRARIES :=
90
91include $(BUILD_HOST_EXECUTABLE)
92
93my_dist_files := $(LOCAL_BUILT_MODULE)
94ifeq ($(HOST_OS),linux)
95my_dist_files += $(HOST_LIBRARY_PATH)/libf2fs_fmt_host_dyn$(HOST_SHLIB_SUFFIX)
96endif
97$(call dist-for-goals,dist_files sdk,$(my_dist_files))
98my_dist_files :=
99
100
101ifeq ($(HOST_OS),linux)
102include $(CLEAR_VARS)
103LOCAL_SRC_FILES := usbtest.c usb_linux.c util.c
104LOCAL_MODULE := usbtest
105LOCAL_CFLAGS := -Werror
106include $(BUILD_HOST_EXECUTABLE)
107endif
108
109ifeq ($(HOST_OS),windows)
110$(LOCAL_INSTALLED_MODULE): $(HOST_OUT_EXECUTABLES)/AdbWinApi.dll
111endif
112