3 # Copyright (c) 2018, The OpenThread Authors.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # 3. Neither the name of the copyright holder nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
33 #######################################
34 # Prepare dbus source code
41 #######################################
44 DBUS_SOURCE=dbus-1.4.26
45 wget -nv "https://dbus.freedesktop.org/releases/dbus/${DBUS_SOURCE}.tar.gz"
46 tar xvf "${DBUS_SOURCE}.tar.gz"
47 (cd "${DBUS_SOURCE}" && ./configure --prefix= --exec-prefix=/usr \
48 && sed -i '/HAVE_BACKTRACE/d' config.h \
49 && sed -i 's/long/long long/' dbus/dbus-arch-deps.h)
50 cat >"${DBUS_SOURCE}/dbus/Android.mk" <<EOF
51 LOCAL_PATH:= \$(call my-dir)
52 include \$(CLEAR_VARS)
62 dbus-credentials-util.c \
72 dbus-marshal-basic.c \
73 dbus-marshal-byteswap.c \
74 dbus-marshal-byteswap-util.c \
75 dbus-marshal-header.c \
76 dbus-marshal-recursive.c \
77 dbus-marshal-recursive-util.c \
78 dbus-marshal-validate.c \
79 dbus-marshal-validate-util.c \
83 dbus-message-factory.c \
93 dbus-server-debug-pipe.c \
94 dbus-server-launchd.c \
95 dbus-server-socket.c \
104 dbus-sysdeps-pthread.c \
105 dbus-sysdeps-unix.c \
106 dbus-sysdeps-util.c \
107 dbus-sysdeps-util-unix.c \
113 dbus-transport-socket.c \
114 dbus-transport-unix.c \
121 \$(DBUS_SOURCES:\$(LOCAL_PATH)/%=%)
123 LOCAL_C_INCLUDES+= \$(LOCAL_PATH)/..
125 LOCAL_MODULE:=libdbus
127 DBUS_HEADERS := \$(wildcard \$(LOCAL_PATH)/*.h)
128 LOCAL_COPY_HEADERS := \$(DBUS_HEADERS:\$(LOCAL_PATH)/%=%)
130 LOCAL_COPY_HEADERS_TO := dbus
134 -DHAVE_MONOTONIC_CLOCK \
135 -DDBUS_MACHINE_UUID_FILE=\"/etc/machine-id\" \
136 -DDBUS_SYSTEM_CONFIG_FILE=\"/etc/dbus-1/system.conf\" \
137 -DDBUS_SESSION_CONFIG_FILE=\"/etc/dbus-1/session.conf\" \
139 -Wno-missing-field-initializers \
142 -Wno-tautological-compare \
144 -Wno-unused-parameter
146 include \$(BUILD_SHARED_LIBRARY)
150 #######################################
151 # Prepare libmdns source code
158 #######################################
161 readonly MDNSRESPONDER_SOURCE=mDNSResponder-878.30.4
163 [[ ${OTBR_MDNS} == mDNSResponder ]] || return 0
165 wget -nv "https://opensource.apple.com/tarballs/mDNSResponder/${MDNSRESPONDER_SOURCE}.tar.gz"
166 tar xvf "${MDNSRESPONDER_SOURCE}.tar.gz"
167 cat >"${MDNSRESPONDER_SOURCE}/Android.mk" <<EOF
168 LOCAL_PATH:= \$(call my-dir)
170 include \$(CLEAR_VARS)
173 mDNSShared/dnssd_clientlib.c \
174 mDNSShared/dnssd_clientstub.c \
175 mDNSShared/dnssd_ipc.c \
177 LOCAL_MODULE := libmdnssd
178 LOCAL_MODULE_TAGS := eng
180 DBUS_HEADERS := \$(wildcard \$(LOCAL_PATH)/mDNSShared/*.h)
181 LOCAL_COPY_HEADERS := \$(DBUS_HEADERS:\$(LOCAL_PATH)/%=%)
183 LOCAL_CFLAGS := -O2 -g -W -Wall -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DTARGET_OS_LINUX -fno-strict-aliasing -DHAVE_LINUX -DMDNS_DEBUGMSGS=0
185 include \$(BUILD_SHARED_LIBRARY)
196 mv "${SRC_DIR}"/../../third_party/openthread/repo external/openthread
197 cat >>buildspec.mk <<EOF
200 OTBR_ENABLE_ANDROID_MK := 1
201 OPENTHREAD_ENABLE_ANDROID_MK := 1
203 OPENTHREAD_PROJECT_CFLAGS := \
204 -DOPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE=1 \
205 -DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
206 -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\"
210 #######################################
211 # Check build with android build system
218 #######################################
225 make showcommands otbr-agent otbr-agent.conf
227 test -f out/target/product/generic/system/bin/otbr-agent
228 test -f out/target/product/generic/system/etc/dbus-1/system.d/otbr-agent.conf