forked from corellium/usbfluxd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
258 lines (239 loc) · 9.57 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
dnl# -*- Autoconf -*-
dnl# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.64])
AC_INIT([usbfluxd],[1.2.0],[https://corellium.com],[],[https://corellium.com])
AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])
AC_CONFIG_SRCDIR([usbfluxd/])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])dnl
AC_USE_SYSTEM_EXTENSIONS
# Checks for programs.
if test "x${CXX}" = "x" && test "x${ac_cv_prog_CXXCPP}" = "x" && \
test "x${CXXCPP}" = "x" && test "x${ac_cv_prog_cxx_g}" = "x" && \
test "x${ac_cv_cxx_compiler_gnu}" = "x" && \
test "x${ac_cv_prog_ac_ct_CXX}" = "x" && \
test "x${am_cv_CXX_dependencies_compiler_type}" = "x"; then
if test -x "`which autoscan`" && test "x${BE_NOISY}" = "xVERY"; then
test -z "${CXX}" && echo "CXX is unset"
test -z "${ac_cv_prog_CXXCPP}" && echo "ac_cv_prog_CXXCPP is unset"
test -z "${CXXCPP}" && echo "CXXCPP is unset"
test -z "${ac_cv_prog_cxx_g}" && echo "ac_cv_prog_cxx_g is unset"
test -z "${ac_cv_cxx_compiler_gnu}" && echo "ac_cv_cxx_compiler_gnu is unset"
test -z "${ac_cv_prog_ac_ct_CXX}" && echo "ac_cv_prog_ac_ct_CXX is unset"
test -z "${am_cv_CXX_dependencies_compiler_type}" && echo "am_cv_CXX_dependencies_compiler_type is unset"
fi
AC_PROG_CXX
fi
LT_INIT([win32-dll])
LT_LANG([C])
AC_DEFUN([AC_REQUIRE_PROGS],[
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_CPP])dnl
AC_REQUIRE([AM_PROG_CC_C_O])dnl
AC_REQUIRE([AC_PROG_OBJC])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
AC_REQUIRE([AC_PROG_LN_S])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_PROG_SED])dnl
AC_REQUIRE([AC_PROG_EGREP])dnl
])dnl
AC_REQUIRE_PROGS
AC_PATH_PROG([SHELLCHECK],[shellcheck],[shellcheck])dnl
# Checks for libraries.
PKG_CHECK_MODULES([libplist],[libplist >= 2.2.0],
[
AC_DEFINE([HAVE_LIBPLIST],[1],[Use libplist])
LIBPLIST=libplist
],[
PKG_CHECK_MODULES([libplist],[libplist-2.0 >= 2.2.0],[
LIBPLIST=libplist-2.0
AC_DEFINE([HAVE_LIBPLIST_2_0],[1],[Use libplist-2.0])
])],
[])dnl
if test "x${LIBPLIST}" != "x"; then
CFLAGS_save="${CFLAGS}"
CFLAGS="${CFLAGS} ${libplist_CFLAGS}"
AC_CHECK_DECLS([plist_format_typedef],[],[],[
#include <plist/plist.h>
plist_format_t plist_format_typedef;
])
CFLAGS="${CFLAGS_save}"
fi
AC_CHECK_LIB([pthread],[pthread_create, pthread_mutex_lock],
[AC_SUBST([libpthread_LIBS],[-lpthread])],
[AC_MSG_ERROR([libpthread is required to build usbfluxd])])dnl
AC_SEARCH_LIBS([fmin],[m crlibm mvec])dnl
# Checks for header files.
AC_DEFUN([AC_REQUIRE_HEADER_STDC],[
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl
])dnl
AC_REQUIRE_HEADER_STDC
AC_HEADER_STDBOOL dnl# also "_CHECK"s it
AC_HEADER_TIME
AC_CHECK_HEADERS([CFNetwork/CFNetServices.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h features.h mach/mach_time.h netdb.h \
netinet/in.h sys/statvfs.h sys/time.h syslog.h])dnl
if test "x${ac_cv_header_stdint_h}" = "x"; then
test -z "${ac_cv_header_stdint_h}"
AC_CHECK_HEADERS([stdint.h])
fi
if test "x${ac_cv_header_unistd_h}" = "x"; then
test -z "${ac_cv_header_unistd_h}"
AC_CHECK_HEADERS([unistd.h])
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_STRUCT_TM
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
# Checks for library functions.
AC_DEFUN([AC_REQUIRE_FUNCS],[
AC_REQUIRE([AC_FUNC_FORK])dnl
AC_REQUIRE([AC_FUNC_MEMCMP])dnl
AC_REQUIRE([AC_FUNC_MALLOC])dnl
AC_REQUIRE([AC_FUNC_REALLOC])dnl
AC_REQUIRE([AC_FUNC_SELECT_ARGTYPES])dnl
AC_REQUIRE([AC_FUNC_STAT])dnl
AC_REQUIRE([AC_FUNC_STRFTIME])dnl
m4_ifdef([AC_FUNC_VFPRINTF],[
AC_REQUIRE([AC_FUNC_VFPRINTF])dnl
])dnl
])dnl
AC_REQUIRE_FUNCS
AC_CHECK_FUNCS([strcasecmp strdup strerror strndup stpcpy localtime_r])
AC_CHECK_FUNCS([bzero client_clear_remote gethostbyname gettimeofday memmove \
memset select socket strchr strrchr strtol strtoul])
AC_CHECK_FUNCS([ppoll clock_gettime])dnl
# Check for operating system
AC_MSG_CHECKING([whether to enable WIN32 build settings])
AC_LDADD=""
case ${host_os} in
*mingw32*|*cygwin*)
win32=true
AC_MSG_RESULT([yes])
AC_CHECK_TOOL([WINDRES],[windres],[AC_MSG_ERROR([windres not found])])
AC_SUBST([WINDRES])
;;
darwin*)
win32=false
AC_MSG_RESULT([no])
# No support for launchd yet, TODO
AC_DEFINE([HAVE_CFNETWORK],[1],[Define to enable CFNetwork support])
AC_LDADD="-framework CoreFoundation -framework CFNetwork"
;;
*)
win32=false
AC_MSG_RESULT([no])
PKG_CHECK_MODULES([avahi_client],[avahi-client >= 0.6.32],
[have_avahi=yes],[have_avahi=no])
if test "x${have_avahi}" = "xyes"; then
AC_HEADER_ASSERT
AC_DEFINE([HAVE_AVAHI_CLIENT],[1],
[Define to 1 to enable avahi-client support])
fi
;;
esac
AC_SUBST([AC_LDADD])dnl
AM_CONDITIONAL([WIN32],[test "x${win32}" = "xtrue"])dnl
AC_ARG_WITH([static-libplist],
[AS_HELP_STRING([--with-static-libplist[=/path/to/static/libplist]],
[link against a static libplist])],[
if test "x${withval}" != "x"; then
test -n "${withval}" && echo "using ${withval} as withval"
with_static_libplist=${withval}
else
test -z "${withval}" && echo "uh oh... empty withval!"
with_static_libplist=no
fi
],[with_static_libplist=yes])
echo "with_static_libplist is ${with_static_libplist}"
if test "x${with_static_libplist}" != "xno"; then
if test "x${with_static_libplist}" = "xyes"; then
if test "x${LIBPLIST}" != "x"; then
test -n "${LIBPLIST}" && echo "seeing if ${LIBPLIST} is available statically"
LIBPLIST_PKG_CONFIG_LIBDIR="`pkg-config --libs-only-L ${LIBPLIST}`"
if test "x${LIBPLIST_PKG_CONFIG_LIBDIR}" != "x"; then
test -n "${LIBPLIST_PKG_CONFIG_LIBDIR}" && echo "pkg-config says: ${LIBPLIST_PKG_CONFIG_LIBDIR}"
else
echo "outputting some attempts at debugging the relevant pkg-config file"
echo "'pkg-config --debug --libs-only-L ${LIBPLIST}' says:" && pkg-config --debug --libs-only-L ${LIBPLIST}
echo "'pkg-config --print-variables ${LIBPLIST}' says:" && pkg-config --print-variables ${LIBPLIST}
m4_pattern_allow([PKG_CONFIG_LIBPLIST_ERRORS])
PKG_CONFIG_LIBPLIST_ERRORS="`pkg-config --print-errors ${LIBPLIST}`"
if test "x${PKG_CONFIG_LIBPLIST_ERRORS}" != "x"; then
test -n "${PKG_CONFIG_LIBPLIST_ERRORS}" && echo "'pkg-config --print-errors ${LIBPLIST}' says: ${PKG_CONFIG_LIBPLIST_ERRORS}"
else
test -z "${PKG_CONFIG_LIBPLIST_ERRORS}" && echo "pkg-config has no errors to report for ${LIBPLIST}."
fi
echo "'pkg-config --debug --validate ${LIBPLIST}' says:" && pkg-config --debug --validate ${LIBPLIST}
m4_pattern_allow([PKG_CONFIG_LIBDIR_LIBPLIST])
PKG_CONFIG_LIBDIR_LIBPLIST="`pkg-config --variable=libdir ${LIBPLIST}`"
if test "x${PKG_CONFIG_LIBDIR_LIBPLIST}" != "x"; then
test -n "${PKG_CONFIG_LIBDIR_LIBPLIST}" && echo "trying to use ${PKG_CONFIG_LIBDIR_LIBPLIST} as the relevant libdir here..."
test -z "${LIBPLIST_PKG_CONFIG_LIBDIR}" && export LIBPLIST_PKG_CONFIG_LIBDIR="${PKG_CONFIG_LIBDIR_LIBPLIST}"
else
test -z "${PKG_CONFIG_LIBDIR_LIBPLIST}" && echo "bad news: PKG_CONFIG_LIBDIR_LIBPLIST is empty!"
fi
fi
STATIC_LIBPLIST="`echo ${LIBPLIST_PKG_CONFIG_LIBDIR} | sed "s/^..//; s/[ ]*$/\/${LIBPLIST}.a/"`"
if test ! -e "${STATIC_LIBPLIST}"; then
STATIC_LIBPLIST="${LIBPLIST_PKG_CONFIG_LIBDIR}/${LIBPLIST}.a"
fi
test -n "${STATIC_LIBPLIST}" && echo "STATIC_LIBPLIST is now ${STATIC_LIBPLIST}"
else
STATIC_LIBPLIST="`pkg-config --libs-only-L libplist | sed "s/^..//; s/[ ]*$/\/libplist.a/"`"
fi
else
if test "x${with_static_libplist}" != "x"; then
test -n "${with_static_libplist}" && STATIC_LIBPLIST="${with_static_libplist}"
elif test -x "`which locate`"; then
echo "attempting to locate libplist.a; this may take awhile..."
STATIC_LIBPLIST="`locate libplist.a | head -n 1`"
elif test -x "`which find`"; then
echo "attempting to find libplist.a; this may take awhile..."
STATIC_LIBPLIST="`find / -name libplist.a 2>/dev/null | head -n 1`"
else
STATIC_LIBPLIST=libplist.a
fi
if test "x${STATIC_LIBPLIST}" = "x"; then
test -z "${STATIC_LIBPLIST}" && export STATIC_LIBPLIST=libplist.a
fi
fi
if ! test -f "${STATIC_LIBPLIST}"; then
AC_MSG_ERROR([The file ${STATIC_LIBPLIST} passed to --with-static-libplist does not exist])
fi
echo "*** Note: Will link with static libplist found at ${STATIC_LIBPLIST} ***"
AC_SUBST([libplist_LIBS],[${STATIC_LIBPLIST}])
else
echo "*** Note: Skipping checks about linking with static libplist ***"
fi
if test "x${ac_cv_header_sys_socket_h}" = "x"; then
test -z "${ac_cv_header_sys_socket_h}"
AC_CHECK_HEADERS([sys/socket.h])
fi
AS_COMPILER_FLAGS([GLOBAL_CFLAGS],["-g -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wformat=2 -Werror=format-security -Wpedantic -Wno-unused-parameter"])
AC_SUBST([GLOBAL_CFLAGS])dnl
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])dnl
# Output.
AC_CONFIG_FILES([
Makefile
usbfluxd/Makefile
tools/Makefile
])
AC_OUTPUT
echo "
Configuration for ${PACKAGE} ${VERSION}:
-------------------------------------------
install prefix ............: ${prefix}
Now type 'make' to build ${PACKAGE} ${VERSION},
and then 'make install' for installation.
"