ee49a22c4ec8d8a784adfe3d6dc031b8a506724f
[platform/upstream/connman.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(connman, 1.37)
3
4 AC_CONFIG_MACRO_DIR([m4])
5
6 AM_INIT_AUTOMAKE([foreign subdir-objects color-tests])
7 AC_CONFIG_HEADERS([config.h])
8
9 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
10
11 AM_MAINTAINER_MODE
12
13 AC_PREFIX_DEFAULT(/usr/local)
14
15 PKG_PROG_PKG_CONFIG
16
17 COMPILER_FLAGS
18
19 AC_SUBST(abs_top_srcdir)
20 AC_SUBST(abs_top_builddir)
21
22 AC_LANG_C
23 AC_USE_SYSTEM_EXTENSIONS
24
25 AC_PROG_CC
26 AM_PROG_CC_C_O
27 AC_PROG_CC_PIE
28 AC_PROG_INSTALL
29 AC_PROG_MKDIR_P
30
31 m4_define([_LT_AC_TAGCONFIG], [])
32 m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
33
34 AC_DISABLE_STATIC
35 AC_PROG_LIBTOOL
36
37 gl_CONFIGMAKE_PREP
38
39 AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
40                         [disable code optimization through compiler]), [
41         if (test "${enableval}" = "no"); then
42                 CFLAGS="$CFLAGS -O0 -U_FORTIFY_SOURCE"
43         fi
44 ])
45
46 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
47                         [enable compiling with debugging information]), [
48         if (test "${enableval}" = "yes" &&
49                                 test "${ac_cv_prog_cc_g}" = "yes"); then
50                 CFLAGS="$CFLAGS -g"
51         fi
52 ])
53
54 AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
55                         [enable position independent executables flag]), [
56         if (test "${enableval}" = "yes" &&
57                                 test "${ac_cv_prog_cc_pie}" = "yes"); then
58                 CFLAGS="$CFLAGS -fPIE"
59                 LDFLAGS="$LDFLAGS -pie"
60         fi
61 ])
62
63 AC_ARG_ENABLE(hh2serial-gps,
64         AC_HELP_STRING([--enable-hh2serial-gps], [enable hh2serial GPS support]),
65                         [enable_hh2serial_gps=${enableval}], [enable_hh2serial_gps="no"])
66 AM_CONDITIONAL(HH2SERIAL_GPS, test "${enable_hh2serial_gps}" != "no")
67 AM_CONDITIONAL(HH2SERIAL_GPS_BUILTIN, test "${enable_hh2serial_gps}" = "builtin")
68
69 AC_ARG_WITH(openconnect, AC_HELP_STRING([--with-openconnect=PROGRAM],
70         [specify location of openconnect binary]), [path_openconnect=${withval}])
71
72 AC_ARG_ENABLE(openconnect,
73         AC_HELP_STRING([--enable-openconnect], [enable openconnect support]),
74                         [enable_openconnect=${enableval}], [enable_openconnect="no"])
75 if (test "${enable_openconnect}" != "no"); then
76         if (test -z "${path_openconnect}"); then
77                 AC_PATH_PROG(OPENCONNECT, [openconnect], [], $PATH:/sbin:/usr/sbin)
78                 if (test -z "${OPENCONNECT}"); then
79                         AC_MSG_ERROR(openconnect binary not found)
80                 fi
81         else
82                 OPENCONNECT="${path_openconnect}"
83                 AC_SUBST(OPENCONNECT)
84         fi
85 fi
86 AM_CONDITIONAL(OPENCONNECT, test "${enable_openconnect}" != "no")
87 AM_CONDITIONAL(OPENCONNECT_BUILTIN, test "${enable_openconnect}" = "builtin")
88
89 AC_ARG_WITH(openvpn, AC_HELP_STRING([--with-openvpn=PROGRAM],
90         [specify location of openvpn binary]), [path_openvpn=${withval}])
91
92 AC_ARG_ENABLE(openvpn,
93         AC_HELP_STRING([--enable-openvpn], [enable openvpn support]),
94                         [enable_openvpn=${enableval}], [enable_openvpn="no"])
95 if (test "${enable_openvpn}" != "no"); then
96         if (test -z "${path_openvpn}"); then
97                 AC_PATH_PROG(OPENVPN, [openvpn], [], $PATH:/sbin:/usr/sbin)
98                 if (test -z "${OPENVPN}"); then
99                         AC_MSG_ERROR(openvpn binary not found)
100                 fi
101         else
102                 OPENVPN="${path_openvpn}"
103                 AC_SUBST(OPENVPN)
104         fi
105 fi
106 AM_CONDITIONAL(OPENVPN, test "${enable_openvpn}" != "no")
107 AM_CONDITIONAL(OPENVPN_BUILTIN, test "${enable_openvpn}" = "builtin")
108
109 AC_ARG_WITH(vpnc, AC_HELP_STRING([--with-vpnc=PROGRAM],
110         [specify location of vpnc binary]), [path_vpnc=${withval}])
111
112 AC_ARG_ENABLE(vpnc,
113         AC_HELP_STRING([--enable-vpnc], [enable vpnc support]),
114                 [enable_vpnc=${enableval}], [enable_vpnc="no"])
115 if (test "${enable_vpnc}" != "no"); then
116         if (test -z "${path_vpnc}"); then
117                 AC_PATH_PROG(VPNC, [vpnc], [], $PATH:/sbin:/usr/sbin)
118                 if (test -z "${VPNC}"); then
119                         AC_MSG_ERROR(vpnc binary not found)
120                 fi
121         else
122                 VPNC="${path_vpnc}"
123                 AC_SUBST(VPNC)
124         fi
125 fi
126 AM_CONDITIONAL(VPNC, test "${enable_vpnc}" != "no")
127 AM_CONDITIONAL(VPNC_BUILTIN, test "${enable_vpnc}" = "builtin")
128
129 AC_ARG_WITH(l2tp, AC_HELP_STRING([--with-l2tp=PROGRAM],
130         [specify location of l2tp binary]), [path_l2tp=${withval}])
131
132 AC_ARG_ENABLE(l2tp,
133         AC_HELP_STRING([--enable-l2tp], [enable l2tp support]),
134                         [enable_l2tp=${enableval}], [enable_l2tp="no"])
135 if (test "${enable_l2tp}" != "no"); then
136         if (test -z "${path_pppd}"); then
137                 AC_PATH_PROG(PPPD, [pppd], [/usr/sbin/pppd], $PATH:/sbin:/usr/sbin)
138         else
139                 PPPD="${path_pppd}"
140                 AC_SUBST(PPPD)
141         fi
142         AC_CHECK_HEADERS(pppd/pppd.h, dummy=yes,
143                         AC_MSG_ERROR(ppp header files are required))
144         if (test -z "${path_l2tp}"); then
145                 AC_PATH_PROG(L2TP, [xl2tpd], [/usr/sbin/xl2tpd], $PATH:/sbin:/usr/sbin)
146         else
147                 L2TP="${path_l2tp}"
148                 AC_SUBST(L2TP)
149         fi
150 fi
151 AM_CONDITIONAL(L2TP, test "${enable_l2tp}" != "no")
152 AM_CONDITIONAL(L2TP_BUILTIN, test "${enable_l2tp}" = "builtin")
153
154 AC_ARG_WITH(pptp, AC_HELP_STRING([--with-pptp=PROGRAM],
155         [specify location of pptp binary]), [path_pptp=${withval}])
156
157 AC_ARG_ENABLE(pptp,
158         AC_HELP_STRING([--enable-pptp], [enable pptp support]),
159                         [enable_pptp=${enableval}], [enable_pptp="no"])
160 if (test "${enable_pptp}" != "no"); then
161         if (test -z "${path_pppd}"); then
162                 AC_PATH_PROG(PPPD, [pppd], [/usr/sbin/pppd], $PATH:/sbin:/usr/sbin)
163         else
164                 PPPD="${path_pppd}"
165                 AC_SUBST(PPPD)
166         fi
167         AC_CHECK_HEADERS(pppd/pppd.h, dummy=yes,
168                         AC_MSG_ERROR(ppp header files are required))
169         if (test -z "${path_pptp}"); then
170                 AC_PATH_PROG(PPTP, [pptp], [/usr/sbin/pptp], $PATH:/sbin:/usr/sbin)
171         else
172                 PPTP="${path_pptp}"
173                 AC_SUBST(PPTP)
174         fi
175 fi
176 AM_CONDITIONAL(PPTP, test "${enable_pptp}" != "no")
177 AM_CONDITIONAL(PPTP_BUILTIN, test "${enable_pptp}" = "builtin")
178
179 AC_CHECK_HEADERS(resolv.h, dummy=yes,
180         AC_MSG_ERROR(resolver header files are required))
181 AC_CHECK_LIB(resolv, ns_initparse, dummy=yes, [
182         AC_CHECK_LIB(resolv, __ns_initparse, dummy=yes,
183                 AC_MSG_ERROR(resolver library support is required))
184 ])
185
186 AC_CHECK_HEADERS([execinfo.h])
187 AM_CONDITIONAL([BACKTRACE], [test "${ac_cv_header_execinfo_h}" = "yes"])
188
189 AC_CHECK_MEMBERS([struct in6_pktinfo.ipi6_addr], [], [], [[#include <netinet/in.h>]])
190
191 AC_CHECK_FUNC(signalfd, dummy=yes,
192                         AC_MSG_ERROR(signalfd support is required))
193
194 AC_CHECK_LIB(dl, dlopen, dummy=yes,
195                         AC_MSG_ERROR(dynamic linking loader is required))
196
197 AC_ARG_ENABLE(iospm, AC_HELP_STRING([--enable-iospm],
198                 [enable Intel OSPM support]), [enable_iospm=${enableval}])
199 AM_CONDITIONAL(IOSPM, test "${enable_iospm}" = "yes")
200
201 AC_ARG_ENABLE(tist,
202         AC_HELP_STRING([--enable-tist], [enable TI Shared Transport support]),
203                         [enable_tist=${enableval}], [enable_tist="no"])
204 AM_CONDITIONAL(TIST, test "${enable_tist}" != "no")
205 AM_CONDITIONAL(TIST_BUILTIN, test "${enable_tist}" = "builtin")
206
207 AC_ARG_ENABLE(session-policy-local,
208         AC_HELP_STRING([--enable-session-policy-local], [enable local file Session policy configuration support]),
209                         [enable_session_policy_local=${enableval}], [enable_session_policy_local="no"])
210 AM_CONDITIONAL(SESSION_POLICY_LOCAL, test "${enable_session_policy_local}" != "no")
211 AM_CONDITIONAL(SESSION_POLICY_LOCAL_BUILTIN, test "${enable_session_policy_local}" = "builtin")
212
213 AC_ARG_WITH(stats-max-file-size, AC_HELP_STRING([--with-stats-max-file-size=SIZE],
214                         [Maximal size of a statistics round robin file]),
215                         [stats_max_file_size=${withval}])
216
217 if (test -z "${stats_max_file_size}"); then
218    # default size is 16 kByte
219    stats_max_file_size="16 * 8 * 128"
220 fi
221
222 AC_DEFINE_UNQUOTED([STATS_MAX_FILE_SIZE], (${stats_max_file_size}), [Maximal size of a statistics round robin file])
223
224 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.40, dummy=yes,
225                                 AC_MSG_ERROR(GLib >= 2.40 is required))
226 AC_SUBST(GLIB_CFLAGS)
227 AC_SUBST(GLIB_LIBS)
228
229 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4, dummy=yes,
230                                 AC_MSG_ERROR(D-Bus >= 1.4 is required))
231 AC_SUBST(DBUS_CFLAGS)
232 AC_SUBST(DBUS_LIBS)
233
234 AC_ARG_WITH(dbusconfdir, AC_HELP_STRING([--with-dbusconfdir=PATH],
235         [path to D-Bus config directory]), [path_dbusconf=${withval}],
236                 [path_dbusconf="`$PKG_CONFIG --variable=datadir dbus-1`"])
237 if (test -z "${path_dbusconf}"); then
238         DBUS_CONFDIR="${datadir}/dbus-1/system.d"
239 else
240         DBUS_CONFDIR="${path_dbusconf}/dbus-1/system.d"
241 fi
242 AC_SUBST(DBUS_CONFDIR)
243
244 AC_ARG_WITH(dbusdatadir, AC_HELP_STRING([--with-dbusdatadir=PATH],
245         [path to D-Bus data directory]), [path_dbusdata=${withval}],
246                 [path_dbusdata="`$PKG_CONFIG --variable=datadir dbus-1`"])
247 if (test -z "${path_dbusdata}"); then
248         DBUS_DATADIR="${datadir}/dbus-1/system-services"
249 else
250         DBUS_DATADIR="${path_dbusdata}/dbus-1/system-services"
251 fi
252 AC_SUBST(DBUS_DATADIR)
253
254 AC_ARG_WITH([systemdunitdir], AC_HELP_STRING([--with-systemdunitdir=DIR],
255         [path to systemd service directory]), [path_systemdunit=${withval}],
256                 [path_systemdunit="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"])
257 if (test -n "${path_systemdunit}"); then
258         SYSTEMD_UNITDIR="${path_systemdunit}"
259         AC_SUBST(SYSTEMD_UNITDIR)
260 fi
261 AM_CONDITIONAL(SYSTEMD, test -n "${path_systemdunit}")
262
263 AC_ARG_WITH([tmpfilesdir], AC_HELP_STRING([--with-tmpfilesdir=DIR],
264         [path to systemd tmpfiles.d directory]), [path_tmpfiles=${withval}],
265                 [path_tmpfiles="`$PKG_CONFIG --variable=tmpfilesdir systemd`"])
266 if (test -n "${path_tmpfiles}"); then
267         SYSTEMD_TMPFILESDIR="${path_tmpfiles}"
268         AC_SUBST(SYSTEMD_TMPFILESDIR)
269 fi
270
271 AC_ARG_WITH(firewall, AC_HELP_STRING([--with-firewall=TYPE],
272                         [specify which firewall type is used iptables or nftables [default=iptables]]),
273                 [firewall_type=${withval}],
274                 [firewall_type="iptables"])
275
276 if (test "${firewall_type}" != "iptables" -a \
277                 "${firewall_type}" != "nftables"); then
278         AC_MSG_ERROR(neither nftables nor iptables support enabled)
279 fi
280
281 found_iptables="no"
282 if (test "${firewall_type}" = "iptables"); then
283         PKG_CHECK_MODULES(XTABLES, xtables >= 1.4.11, [found_iptables="yes"],
284                         AC_MSG_ERROR(Xtables library is required))
285         AC_SUBST(XTABLES_CFLAGS)
286         AC_SUBST(XTABLES_LIBS)
287 fi
288 AM_CONDITIONAL(XTABLES, test "${found_iptables}" != "no")
289
290 found_nftables="no"
291 if (test "${firewall_type}" = "nftables"); then
292         PKG_CHECK_MODULES(NFTABLES, [libnftnl >= 1.0.4 libmnl >= 1.0.0], [found_nftables="yes"],
293                 AC_MSG_ERROR([libnftnl >= 1.0.4 or libmnl >= 1.0.0 not found]))
294         AC_SUBST(NFTABLES_CFLAGS)
295         AC_SUBST(NFTABLES_LIBS)
296 fi
297 AM_CONDITIONAL(NFTABLES, test "${found_nftables}" != "no")
298
299 AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test],
300                 [enable test/example scripts]), [enable_test=${enableval}])
301 AM_CONDITIONAL(TEST, test "${enable_test}" = "yes")
302
303 AC_ARG_ENABLE(nmcompat, AC_HELP_STRING([--enable-nmcompat],
304                                 [enable Network Manager support]),
305                         [enable_nmcompat=${enableval}], [enable_nmcompat="no"])
306 AM_CONDITIONAL(NMCOMPAT, test "${enable_nmcompat}" != "no")
307
308 AC_ARG_ENABLE(polkit, AC_HELP_STRING([--enable-polkit],
309                                 [enable PolicyKit support]),
310                         [enable_polkit=${enableval}], [enable_polkit="no"])
311 if (test "${enable_polkit}" != "no"); then
312         POLKIT_DATADIR="`$PKG_CONFIG --variable=actiondir polkit`"
313         POLKIT_DATADIR=""
314         if (test -z "${POLKIT_DATADIR}"); then
315                 POLKIT_DATADIR="${datadir}/polkit-1/actions"
316         fi
317         AC_SUBST(POLKIT_DATADIR)
318 fi
319 AM_CONDITIONAL(POLKIT, test "${enable_polkit}" != "no")
320
321 AC_ARG_ENABLE(selinux, AC_HELP_STRING([--enable-selinux],
322                                 [enable selinux support]),
323                         [enable_selinux=${enableval}], [enable_selinux="no"])
324 AM_CONDITIONAL(SELINUX, test "${enable_selinux}" != "no")
325
326 AC_ARG_ENABLE(loopback, AC_HELP_STRING([--disable-loopback],
327                                 [disable loopback support]),
328                                         [enable_loopback=${enableval}])
329 AM_CONDITIONAL(LOOPBACK, test "${enable_loopback}" != "no")
330
331 AC_ARG_ENABLE(ethernet, AC_HELP_STRING([--disable-ethernet],
332                                 [disable Ethernet support]),
333                                         [enable_ethernet=${enableval}])
334 AM_CONDITIONAL(ETHERNET, test "${enable_ethernet}" != "no")
335
336 AC_ARG_ENABLE(gadget, AC_HELP_STRING([--disable-gadget],
337                                 [disable USB Gadget support]),
338                                         [enable_gadget=${enableval}])
339 AM_CONDITIONAL(GADGET, test "${enable_gadget}" != "no")
340
341 AC_ARG_ENABLE(wifi, AC_HELP_STRING([--disable-wifi],
342                                 [disable WiFi support]),
343                                         [enable_wifi=${enableval}])
344 AM_CONDITIONAL(WIFI, test "${enable_wifi}" != "no")
345
346 AC_ARG_ENABLE(iwd, AC_HELP_STRING([--enable-iwd],
347                                 [enable iwd support]),
348                                         [enable_iwd=${enableval}])
349 AM_CONDITIONAL(IWD, test "${enable_iwd}" = "yes")
350
351 AC_ARG_ENABLE(bluetooth, AC_HELP_STRING([--disable-bluetooth],
352                                 [disable Bluetooth support]),
353                                         [enable_bluetooth=${enableval}])
354 AM_CONDITIONAL(BLUETOOTH, test "${enable_bluetooth}" != "no")
355
356 AC_ARG_ENABLE(ofono, AC_HELP_STRING([--disable-ofono],
357                                 [disable oFono support]),
358                                         [enable_ofono=${enableval}])
359 AM_CONDITIONAL(OFONO, test "${enable_ofono}" != "no")
360
361 AC_ARG_ENABLE(dundee, AC_HELP_STRING([--disable-dundee],
362                                 [disable dundee support (Bluetooth DUN)]),
363                                         [enable_dundee=${enableval}])
364 AM_CONDITIONAL(DUNDEE, test "${enable_dundee}" != "no")
365
366 AC_ARG_ENABLE(pacrunner, AC_HELP_STRING([--disable-pacrunner],
367                                 [disable PACrunner support]),
368                                         [enable_pacrunner=${enableval}])
369 AM_CONDITIONAL(PACRUNNER, test "${enable_pacrunner}" != "no")
370
371 AC_ARG_ENABLE(neard, AC_HELP_STRING([--disable-neard],
372                                 [disable Neard support]),
373                                         [enable_neard=${enableval}])
374 AM_CONDITIONAL(NEARD, test "${enable_neard}" != "no")
375
376 AC_ARG_ENABLE(wispr, AC_HELP_STRING([--disable-wispr],
377                                 [disable WISPr support]),
378                                         [enable_wispr=${enableval}])
379 AM_CONDITIONAL(WISPR, test "${enable_wispr}" != "no")
380
381 AC_ARG_ENABLE(tools, AC_HELP_STRING([--disable-tools],
382                                 [disable testing tools]),
383                                         [enable_tools=${enableval}])
384 AM_CONDITIONAL(TOOLS, test "${enable_tools}" != "no")
385
386 AC_ARG_ENABLE(stats, AC_HELP_STRING([--disable-stats],
387                                 [disable statistics round robin file generation]),
388                                         [enable_stats=${enableval}])
389 AM_CONDITIONAL(STATS, test "${enable_stats}" != "no")
390
391 if (test "${enable_tools}" != "no"); then
392         AC_PATH_PROGS(IPTABLES_SAVE, [iptables-save], [],
393                                                 $PATH:/sbin:/usr/sbin)
394         AC_PATH_PROGS(IP6TABLES_SAVE, [ip6tables-save], [],
395                                                 $PATH:/sbin:/usr/sbin)
396         IPTABLES_SAVE=$ac_cv_path_IPTABLES_SAVE
397         IP6TABLES_SAVE=$ac_cv_path_IP6TABLES_SAVE
398 else
399         IPTABLES_SAVE=""
400         IP6TABLES_SAVE=""
401 fi
402 AC_SUBST(IPTABLES_SAVE)
403 AC_SUBST(IP6TABLES_SAVE)
404
405 AC_ARG_ENABLE(client, AC_HELP_STRING([--disable-client],
406                                 [disable command line client]),
407                                         [enable_client=${enableval}])
408 AM_CONDITIONAL(CLIENT, test "${enable_client}" != "no")
409
410 if (test "${enable_wispr}" != "no"); then
411         PKG_CHECK_MODULES(GNUTLS, gnutls, dummy=yes,
412                                 AC_MSG_ERROR(GnuTLS library is required))
413 else
414         GNUTLS_CFLAGS=""
415         GNUTLS_LIBS=""
416 fi
417 AC_SUBST(GNUTLS_CFLAGS)
418 AC_SUBST(GNUTLS_LIBS)
419
420 if (test "${enable_loopback}" != "no"); then
421         AC_CHECK_HEADERS(sys/inotify.h, dummy=yes,
422                         AC_MSG_ERROR(inotify header files are required))
423
424         AC_CHECK_LIB(c, inotify_init, dummy=yes,
425                         AC_MSG_ERROR(inotify library support is required))
426 fi
427
428 if (test "${enable_wifi}" != "no"); then
429         AC_PATH_PROG(WPASUPPLICANT, [wpa_supplicant], [],
430                                                 $PATH:/sbin:/usr/sbin)
431 fi
432
433 AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
434                         [don't install configuration and data files]),
435                                         [enable_datafiles=${enableval}])
436 AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
437
438 if (test "${enable_client}" != "no"); then
439         AC_CHECK_HEADERS(readline/readline.h, dummy=yes,
440                 AC_MSG_ERROR(readline header files are required))
441 fi
442
443 AM_CONDITIONAL(VPN, test "${enable_openconnect}" != "no" -o \
444                         "${enable_openvpn}" != "no" -o \
445                         "${enable_vpnc}" != "no" -o \
446                         "${enable_l2tp}" != "no" -o \
447                         "${enable_pptp}" != "no")
448
449 AC_MSG_CHECKING(which DNS backend to use)
450 AC_ARG_WITH(dns-backend, AC_HELP_STRING([--with-dns-backend=TYPE],
451             [specify which DNS backend to use: internal or systemd-resolved [default=internal]]),
452                 [dns_backend=${withval}],
453                 [dns_backend="internal"])
454
455 if (test "${dns_backend}" != "internal" -a \
456                 "${dns_backend}" != "systemd-resolved"); then
457         AC_MSG_ERROR(no suitable DNS backend defined)
458 fi
459 AM_CONDITIONAL(INTERNAL_DNS_BACKEND, test "${dns_backend}" = "internal")
460 AM_CONDITIONAL(SYSTEMD_RESOLVED_DNS_BACKEND, test "${dns_backend}" = "systemd-resolved")
461 AC_MSG_RESULT(${dns_backend})
462
463 AC_OUTPUT(Makefile include/version.h connman.pc)