forked from facebookarchive/fb-adb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
299 lines (260 loc) · 8.96 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
dnl Copyright (c) 2014, Facebook, Inc.
dnl All rights reserved.
dnl
dnl This source code is licensed under the BSD-style license found in
dnl the LICENSE file in the root directory of this source tree. An
dnl additional grant of patent rights can be found in the PATENTS file
dnl in the same directory.
dnl
AC_INIT([fb-adb], [1.99.99-4], [[email protected]])
if test "$srcdir" = "."; then
dnl We configure this directory multiple times, once for each stub
dnl architecture, but we can only do that if we're out of tree for
dnl _all_ builds, unfortunately, including the one for the normal
dnl host system.
AC_MSG_ERROR([Only out-of-tree builds supported. Try mkdir build && cd build && ../configure.])
fi
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
platform=
AC_ARG_WITH([android-ndk],
AS_HELP_STRING([--with-android-ndk=NDK],
[Android NDK location (defaults to $ANDROID_NDK)
"system" means to try finding cross-compilers
in PATH instead of in an NDK.]))
if test -z "$with_android_ndk" && test -n "$ANDROID_NDK"; then
with_android_ndk=$ANDROID_NDK
fi
if test -z "$with_android_ndk"; then
AC_MSG_ERROR([Android NDK location not given])
fi
andk=$with_android_ndk
if test "$andk" = "system"; then
echo "Using system Android cross-compilers"
platform=system
else
if ! test -f "$andk/build/tools/make-standalone-toolchain.sh"; then
AC_MSG_ERROR([Android NDK not in "$andk"])
fi
echo "Using Android NDK at $andk"
fi
dnl We default to android-19 because it's broadly compatible
AC_ARG_WITH([android-platform],
AS_HELP_STRING([--with-android-platform=API-VERSION],
[Android NDK API version (default android-19).
"latest" means to use latest from the NDK.]))
if test "$platform" = "system"; then
if test -n "$with_android_platform"; then
AC_MSG_ERROR([Cannot specify platform when using system cross-compilers])
fi
else
if test -z "$with_android_platform"; then
platform=android-19
elif test "$with_android_platform" = "latest"; then
platform=$(ls -1 "$andk"/platforms | sort -rk2 -t- -n | head -1)
else
platform=$with_android_platform
fi
fi
if test "$platform" = "system"; then
true
else
if test -n "$BUILD_STUB" && test -z "$STUB_LOCAL"; then
rm -rf toolchain
mkdir -p toolchain
if test $host_cpu = i686; then
toolchain_cpu=x86
else
toolchain_cpu=arm
fi
echo "Configuring native NDK toolchain for $platform/$toolchain_cpu"
"$andk"/build/tools/make-standalone-toolchain.sh \
--install-dir=toolchain --platform=$platform \
--arch=$toolchain_cpu
export PATH="$PWD/toolchain/bin:$PATH"
fi
fi
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_SUBST([PATH])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_SYS_LARGEFILE
AC_CHECK_SIZEOF([off_t])
AC_CHECK_HEADERS([machine/endian.h endian.h features.h])
AC_PROG_SED
AC_CHECK_TOOLS(RANLIB, [gcc-ranlib ranlib])
AC_CHECK_TOOLS(AR, [gcc-ar ar])
AC_CHECK_TOOLS(STRIP, [strip])
AM_PROG_AR
AC_CHECK_PROGS(PYTHON3, [python3], [
AC_MSG_ERROR([python3 required for building])
])
AC_CHECK_PROGS(POD2MAN, [pod2man], [
AC_MSG_ERROR([pod2man required for man page generation])
])
if test -z "$BUILD_STUB"; then
AC_PATH_PROG([XXD], [xxd])
if test -z "$XXD"; then
AC_MSG_ERROR([xxd is required to build])
fi
if test -n "$HOST_CFLAGS"; then
CFLAGS="$CFLAGS $HOST_CFLAGS"
fi
if test -n "$HOST_LDFLAGS"; then
CFLAGS="$CFLAGS $HOST_LDFLAGS"
fi
fi
if test -n "$BUILD_STUB"; then
if test -n "$STUB_CFLAGS"; then
CFLAGS="$CFLAGS $STUB_CFLAGS"
fi
if test -n "$STUB_LDFLAGS"; then
CFLAGS="$CFLAGS $STUB_LDFLAGS"
fi
fi
AC_CHECK_FUNCS([ppoll signalfd4 dup3 mkostemp kqueue pipe2 ptsname])
AC_CHECK_FUNCS([accept4 fopencookie funopen clock_gettime execvpe])
AC_CHECK_FUNCS([fallocate futimes posix_fallocate ftruncate64])
AC_CHECK_FUNCS([posix_fadvise realpath])
is_android=$(echo "$CC" | grep android)
if test -n "$BUILD_STUB" && test -z "$STUB_LOCAL" && test -z "$is_android"; then
AC_MSG_ERROR([could not find Android cross-compiler for $host])
fi
CPPFLAGS="$CPPFLAGS -Wall"
dnl _FORTIFY_SOURCE produces too many false positives: read(fd, buf,
dnl min(sizeof(buf), x)), unsigned x, tricks _FORTIFY_SOURCE into
dnl thinking we might overflow the buffer, but we clearly can't.
CPPFLAGS="$CPPFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"
AC_ARG_ENABLE([checking],
AS_HELP_STRING([--enable-checking],
[Enable assertions (default no)]),
[true],
[enable_checking=no])
if test "$enable_checking" = "yes"; then
CPPFLAGS="$CPPFLAGS -Werror"
elif test "$enable_checking" = "no"; then
CPPFLAGS="$CPPFLAGS -DNDEBUG=1"
else
AC_MSG_ERROR([invalid value for --enable-checking: need yes or no])
fi
dnl Each of these stub variants has a corresponding source
dnl subdirectory; each subdirectory contains a dummy configure script
dnl that re-invokes this script with BUILD_STUB on the command line.
dnl To add a new stub variant, add a new entry to this list, new
dnl subdirectories, and new entries in stubs.s.
m4_define([xxstubs], [stub-x86, stub-arm, stub-x86-pic, stub-arm-pic])
have_local_stub=no
if test -z "$BUILD_STUB"; then
STUB_BINARIES=
STUB_SUBDIRS=
if test "$enable_checking" = "yes"; then
have_local_stub=yes
AC_DEFINE([HAVE_LOCAL_STUB], [1])
AC_CONFIG_SUBDIRS([stub-local])
STUB_BINARIES="stub-local/stub $STUB_BINARIES"
STUB_SUBDIRS="stub-local $STUB_SUBDIRS"
fi
m4_foreach([xxstub], [xxstubs], [
AC_CONFIG_SUBDIRS(xxstub)
STUB_BINARIES="$STUB_BINARIES xxstub/stub"
STUB_SUBDIRS="$STUB_SUBDIRS xxstub"
])
AC_SUBST([STUB_BINARIES])
fi
AC_ARG_ENABLE([input-output-termios],
AS_HELP_STRING([--enable-input-output-termios],
[Enable separate input and output terminal configuration]),
[true],
[enable_input_output_termios=no])
if test "$enable_input_output_termios" = "yes"; then
AC_DEFINE([INPUT_OUTPUT_TERMIOS], [1])
elif test "$enable_input_output_termios" = "no"; then
true
else
AC_MSG_ERROR([invalid value for --enable-input-output-termios: need yes or no])
fi
dnl GCC can't prove to itself that stack reslist allocations are
dnl always tagged with RES_RESLIST_ONSTACK, not RES_RESLIST_ONHEAP,
dnl and so warns that the call to free(3) below might be trying to
dnl free stack memory.
warning_sup=
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-free-nonheap-object -Werror"
AC_MSG_CHECKING([compiler accepts -Wno-free-nonheap-object])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([],[])],
[AC_MSG_RESULT([yes])
warning_sup="$warning_sup -Wno-free-nonheap-object"],
[AC_MSG_RESULT([no])])
CFLAGS=$old_CFLAGS
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-initializer-overrides -Werror"
AC_MSG_CHECKING([compiler accepts -Wno-initializer-overrides])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([],[])],
[AC_MSG_RESULT([yes])
warning_sup="$warning_sup -Wno-initializer-overrides"],
[AC_MSG_RESULT([no])])
CFLAGS=$old_CFLAGS
AC_SUBST([WARNING_SUPPRESSION], [$warning_sup])
AC_MSG_CHECKING([ncurses])
old_LIBS=$LIBS
LIBS="$LIBS -lncurses"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([
#include <curses.h>
#include <term.h>
], [setupterm((char*)0,0,NULL);])],
[AC_MSG_RESULT([yes])
AC_DEFINE([USE_NCURSES])
ncurses=yes
],
[AC_MSG_RESULT([no])
LIBS=$old_LIBS
ncurses=no])
AC_ARG_ENABLE([git-stamp],
AS_HELP_STRING(
[--enable-git-stamp],
[include the git revision in the version output]),
[true],
[enable_git_stamp=no])
if test "$enable_git_stamp" = "yes"; then
AC_DEFINE([HAVE_GIT_STAMP], [1])
fi
AC_ARG_ENABLE([debuggable-stubs],
AS_HELP_STRING(
[--enable-debuggable-stubs],
[allow stubs to be debuggable; causes build to be]
[non-deterministic]),
[true],
[enable_debuggable_stubs=no])
AM_CONDITIONAL([STRIP_STUBS], [test "$enable_debuggable_stubs" = "no"])
AC_CHECK_MEMBERS([struct stat.st_mtim])
AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_atim])
AC_CHECK_MEMBERS([struct stat.st_blocks])
AC_CHECK_MEMBERS([struct stat.st_blksize])
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [
#include <dirent.h>
])
AM_CONDITIONAL([GIT_STAMP], [test "$enable_git_stamp" = "yes"])
AM_CONDITIONAL([BUILD_STUB], [test -n "$BUILD_STUB"])
AM_CONDITIONAL([STUB_LOCAL], [test -n "$STUB_LOCAL"])
AM_CONDITIONAL([HAVE_LOCAL_STUB], [test "$have_local_stub" = "yes"])
AM_CONDITIONAL([BUILD_PIC], [test -n "$BUILD_PIC"])
AC_SUBST([STUB_SUBDIRS])
AC_CONFIG_FILES([Makefile])
echo "Debuggable stubs? ${enable_debuggable_stubs}"
echo "Checking enabled? ${enable_checking}"
echo "Git stamp included? ${enable_git_stamp}"
echo "Input-output termios? ${enable_input_output_termios}"
echo "Using ncurses? ${ncurses}"
if test -z "$BUILD_STUB"; then
echo "Local transport? ${have_local_stub}"
fi
if test "$enable_debuggable_stubs" != "no"; then
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65015
AC_MSG_WARN([allowing debug information stubs; build non-deterministic])
fi
AC_OUTPUT