1#
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# This tool is prebuilt if we're doing an app-only build.
18ifeq ($(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)),)
19
20# ==========================================================
21# Setup some common variables for the different build
22# targets here.
23# ==========================================================
24LOCAL_PATH:= $(call my-dir)
25
26main := Main.cpp
27sources := \
28    Abi.cpp \
29    Grouper.cpp \
30    Rule.cpp \
31    RuleGenerator.cpp \
32    SplitDescription.cpp \
33    SplitSelector.cpp
34
35testSources := \
36    Grouper_test.cpp \
37    Rule_test.cpp \
38    RuleGenerator_test.cpp \
39    SplitSelector_test.cpp \
40    TestRules.cpp
41
42cIncludes := \
43    external/zlib \
44    frameworks/base/tools
45
46hostLdLibs :=
47hostStaticLibs := \
48    libaapt \
49    libandroidfw \
50    libpng \
51    liblog \
52    libutils \
53    libcutils \
54    libexpat \
55    libziparchive-host \
56    libbase
57
58cFlags := -Wall -Werror
59
60ifeq ($(HOST_OS),linux)
61    hostLdLibs += -lrt -ldl -lpthread
62endif
63
64# Statically link libz for MinGW (Win SDK under Linux),
65# and dynamically link for all others.
66ifneq ($(strip $(USE_MINGW)),)
67    hostStaticLibs += libz
68else
69    hostLdLibs += -lz
70endif
71
72
73# ==========================================================
74# Build the host static library: libsplit-select
75# ==========================================================
76include $(CLEAR_VARS)
77LOCAL_MODULE := libsplit-select
78
79LOCAL_SRC_FILES := $(sources)
80
81LOCAL_C_INCLUDES += $(cIncludes)
82LOCAL_CFLAGS += $(cFlags) -D_DARWIN_UNLIMITED_STREAMS
83
84include $(BUILD_HOST_STATIC_LIBRARY)
85
86
87# ==========================================================
88# Build the host tests: libsplit-select_tests
89# ==========================================================
90include $(CLEAR_VARS)
91LOCAL_MODULE := libsplit-select_tests
92LOCAL_MODULE_TAGS := tests
93
94LOCAL_SRC_FILES := $(testSources)
95
96LOCAL_C_INCLUDES += $(cIncludes)
97LOCAL_STATIC_LIBRARIES += libsplit-select $(hostStaticLibs)
98LOCAL_LDLIBS += $(hostLdLibs)
99LOCAL_CFLAGS += $(cFlags)
100
101include $(BUILD_HOST_NATIVE_TEST)
102
103# ==========================================================
104# Build the host executable: split-select
105# ==========================================================
106include $(CLEAR_VARS)
107LOCAL_MODULE := split-select
108
109LOCAL_SRC_FILES := $(main)
110
111LOCAL_C_INCLUDES += $(cIncludes)
112LOCAL_STATIC_LIBRARIES += libsplit-select $(hostStaticLibs)
113LOCAL_LDLIBS += $(hostLdLibs)
114LOCAL_CFLAGS += $(cFlags)
115
116include $(BUILD_HOST_EXECUTABLE)
117
118endif # No TARGET_BUILD_APPS or TARGET_BUILD_PDK
119