sim: Fix up various coding style violations
[platform/upstream/ofono.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(ofono, 1.5)
3
4 AM_INIT_AUTOMAKE([foreign subdir-objects color-tests])
5 AM_CONFIG_HEADER(config.h)
6
7 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
8
9 AM_MAINTAINER_MODE
10
11 AC_PREFIX_DEFAULT(/usr/local)
12
13 PKG_PROG_PKG_CONFIG
14
15 COMPILER_FLAGS
16
17 AC_LANG_C
18
19 AC_C_RESTRICT
20
21 AC_PROG_CC
22 AM_PROG_CC_C_O
23 AC_PROG_CC_PIE
24 AC_PROG_INSTALL
25 AM_PROG_MKDIR_P
26
27 m4_define([_LT_AC_TAGCONFIG], [])
28 m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
29
30 AC_DISABLE_STATIC
31 AC_PROG_LIBTOOL
32
33 AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
34                         [disable code optimization through compiler]), [
35         if (test "${enableval}" = "no"); then
36                 CFLAGS="$CFLAGS -O0"
37         fi
38 ])
39
40 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
41                         [enable compiling with debugging information]), [
42         if (test "${enableval}" = "yes" &&
43                                 test "${ac_cv_prog_cc_g}" = "yes"); then
44                 CFLAGS="$CFLAGS -g"
45         fi
46 ])
47
48 AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test],
49                 [enable test/example scripts]), [enable_test=${enableval}])
50 AM_CONDITIONAL(TEST, test "${enable_test}" = "yes")
51
52 AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
53                         [enable position independent executables flag]), [
54         if (test "${enableval}" = "yes" &&
55                                 test "${ac_cv_prog_cc_pie}" = "yes"); then
56                 CFLAGS="$CFLAGS -fPIE"
57                 LDFLAGS="$LDFLAGS -pie"
58         fi
59 ])
60
61 AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
62                 [enable threading support]), [enable_threads=${enableval}])
63
64 AC_CHECK_FUNC(signalfd, dummy=yes,
65                         AC_MSG_ERROR(signalfd support is required))
66
67 AC_CHECK_LIB(dl, dlopen, dummy=yes,
68                         AC_MSG_ERROR(dynamic linking loader is required))
69
70 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
71                                 AC_MSG_ERROR(GLib >= 2.28 is required))
72 AC_SUBST(GLIB_CFLAGS)
73 AC_SUBST(GLIB_LIBS)
74
75 if (test "${enable_threads}" = "yes"); then
76         AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
77         PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
78                                 AC_MSG_ERROR(GThread >= 2.16 is required))
79         GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
80         GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
81 fi
82
83 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
84                                 AC_MSG_ERROR(D-Bus >= 1.0 is required))
85 saved_CFLAGS="$CFLAGS"
86 saved_LIBS="$LIBS"
87 CFLAGS="$CFLAGS $DBUS_CFLAGS"
88 LIBS="$LIBS $DBUS_LIBS"
89 AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
90         AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
91                 [Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
92 AC_CHECK_LIB(dbus-1, dbus_connection_can_send_type, dummy=yes,
93         AC_DEFINE(NEED_DBUS_CONNECTION_CAN_SEND_TYPE, 1,
94                 [Define to 1 if you need the dbus_connection_can_send_type() function.]
95 ))
96 CFLAGS="$saved_CFLAGS"
97 LIBS="$saved_LIBS"
98 AC_SUBST(DBUS_CFLAGS)
99 AC_SUBST(DBUS_LIBS)
100
101 AC_ARG_WITH(dbusconfdir, AC_HELP_STRING([--with-dbusconfdir=PATH],
102         [path to D-Bus config directory]), [path_dbusconf=${withval}],
103                 [path_dbusconf="`$PKG_CONFIG --variable=sysconfdir dbus-1`"])
104 if (test -z "${path_dbusconf}"); then
105         DBUS_CONFDIR="${sysconfdir}/dbus-1/system.d"
106 else
107         DBUS_CONFDIR="${path_dbusconf}/dbus-1/system.d"
108 fi
109 AC_SUBST(DBUS_CONFDIR)
110
111 AC_ARG_WITH(dbusdatadir, AC_HELP_STRING([--with-dbusdatadir=PATH],
112         [path to D-Bus data directory]), [path_dbusdata=${withval}],
113                 [path_dbusdata="`$PKG_CONFIG --variable=datadir dbus-1`"])
114 if (test -z "${path_dbusdata}"); then
115         DBUS_DATADIR="${datadir}/dbus-1/system-services"
116 else
117         DBUS_DATADIR="${path_dbusdata}/dbus-1/system-services"
118 fi
119 AC_SUBST(DBUS_DATADIR)
120
121 AC_ARG_WITH([systemdunitdir], AC_HELP_STRING([--with-systemdunitdir=DIR],
122         [path to systemd service directory]), [path_systemdunit=${withval}],
123                 [path_systemdunit="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"])
124 if (test -n "${path_systemdunit}"); then
125         SYSTEMD_UNITDIR="${path_systemdunit}"
126         AC_SUBST(SYSTEMD_UNITDIR)
127 fi
128 AM_CONDITIONAL(SYSTEMD, test -n "${path_systemdunit}")
129
130 AC_ARG_ENABLE(capng, AC_HELP_STRING([--enable-capng],
131                 [enable capabilities support]), [enable_capng=${enableval}])
132 if (test "${enable_capng}" = "yes"); then
133         PKG_CHECK_MODULES(CAPNG, libcap-ng, dummy=yes,
134                                 AC_MSG_ERROR(Capabilities library is required))
135         AC_SUBST(CAPNG_CFLAGS)
136         AC_SUBST(CAPNG_LIBS)
137         AC_DEFINE(HAVE_CAPNG, 1, [Define to 1 if you have capabilities library.])
138 fi
139
140 AC_ARG_ENABLE(udev, AC_HELP_STRING([--disable-udev],
141                         [don't use udev support even if available]),
142                                                 [enable_udev=${enableval}])
143 if (test "${enable_udev}" != "no"); then
144         PKG_CHECK_MODULES(UDEV, libudev >= 143, [enable_udev="yes"],
145                                 AC_MSG_ERROR(libudev >= 143 is required))
146         UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
147         if (test -z "${UDEV_DATADIR}"); then
148                 UDEV_DATADIR="${sysconfdir}/udev/rules.d"
149         else
150                 UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
151         fi
152         AC_SUBST(UDEV_DATADIR)
153 fi
154 AC_SUBST(UDEV_CFLAGS)
155 AC_SUBST(UDEV_LIBS)
156 AM_CONDITIONAL(UDEV, test "${enable_udev}" = "yes")
157
158 AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools],
159                 [enable testing tools]), [enable_tools=${enableval}])
160 if (test "${enable_tools}" = "yes"); then
161         PKG_CHECK_MODULES(USB, libusb-1.0, dummy=yes,
162                                 AC_MSG_ERROR(USB library is required))
163         AC_SUBST(USB_CFLAGS)
164         AC_SUBST(USB_LIBS)
165 fi
166 AM_CONDITIONAL(TOOLS, test "${enable_tools}" = "yes")
167
168 AC_ARG_ENABLE(atmodem, AC_HELP_STRING([--disable-atmodem],
169                                 [disable ETSI AT modem support]),
170                                         [enable_atmodem=${enableval}])
171 AM_CONDITIONAL(ATMODEM, test "${enable_atmodem}" != "no")
172
173 AC_ARG_ENABLE(cdmamodem, AC_HELP_STRING([--disable-cdmamodem],
174                                 [disable CDMA AT modem support]),
175                                         [enable_cdmamodem=${enableval}])
176 AM_CONDITIONAL(CDMAMODEM, test "${enable_cdmamodem}" != "no")
177
178 AC_ARG_ENABLE(phonesim, AC_HELP_STRING([--disable-phonesim],
179                                 [disable Phone simulator support]),
180                                         [enable_phonesim=${enableval}])
181 AM_CONDITIONAL(PHONESIM, test "${enable_phonesim}" != "no" &&
182                                         test "${enable_atmodem}" != "no")
183
184 AC_ARG_ENABLE(isimodem, AC_HELP_STRING([--disable-isimodem],
185                                 [disable PhoNet/ISI modem support]),
186                                         [enable_isimodem=${enableval}])
187 AM_CONDITIONAL(ISIMODEM, test "${enable_isimodem}" != "no")
188
189 AC_ARG_ENABLE(bluetooth, AC_HELP_STRING([--disable-bluetooth],
190                                 [disable Bluetooth modem support]),
191                                         [enable_bluetooth=${enableval}])
192 if (test "${enable_bluetooth}" != "no"); then
193         PKG_CHECK_MODULES(BLUEZ, bluez >= 4.30, dummy=yes,
194                         AC_MSG_ERROR(Bluetooth library >= 4.30 is required))
195 fi
196 AC_SUBST(BLUEZ_CFLAGS)
197 AC_SUBST(BLUEZ_LIBS)
198 AM_CONDITIONAL(BLUETOOTH, test "${enable_bluetooth}" != "no")
199
200 AC_ARG_WITH([provisiondb], AC_HELP_STRING([--with-provisiondb=FILE],
201         [location of provision database]), [path_provisiondb=${withval}])
202
203 AC_ARG_ENABLE(provision, AC_HELP_STRING([--disable-provision],
204                                 [disable provisioning suport]),
205                                         [enable_provision=${enableval}])
206 if (test "${enable_provision}" != "no"); then
207         if (test -n "${path_provisiondb}"); then
208                 AC_DEFINE_UNQUOTED(PROVIDER_DATABASE, "${path_provisiondb}",
209                                                 [Mobile provider database])
210         else
211                 AC_MSG_CHECKING([for mobile-broadband-provider-info])
212                 PKG_CHECK_EXISTS(mobile-broadband-provider-info,
213                         _PKG_CONFIG(PROVIDER_DATABASE, [variable=database],
214                                         [mobile-broadband-provider-info])
215                         AC_DEFINE_UNQUOTED(PROVIDER_DATABASE,
216                                                 "$pkg_cv_PROVIDER_DATABASE",
217                                                 [Mobile provider database])
218                         AC_MSG_RESULT([yes]),
219                         AC_MSG_ERROR(Mobile broadband provider database is required))
220         fi
221 fi
222 AM_CONDITIONAL(PROVISION, test "${enable_provision}" != "no")
223
224 AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
225                         [don't install configuration and data files]),
226                                         [enable_datafiles=${enableval}])
227 AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
228
229 if (test "${prefix}" = "NONE"); then
230         dnl no prefix and no localstatedir, so default to /var
231         if (test "$localstatedir" = '${prefix}/var'); then
232                 AC_SUBST([localstatedir], ['/var'])
233         fi
234
235         prefix="${ac_default_prefix}"
236 fi
237
238 if (test "$localstatedir" = '${prefix}/var'); then
239         storagedir="${prefix}/var/lib/ofono"
240 else
241         storagedir="${localstatedir}/lib/ofono"
242 fi
243 AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
244                         [Directory for the storage files])
245
246 if (test "$sysconfdir" = '${prefix}/etc'); then
247         configdir="${prefix}/etc/ofono"
248 else
249         configdir="${sysconfdir}/ofono"
250 fi
251 AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
252                         [Directory for the configuration files])
253
254 AC_OUTPUT(Makefile include/version.h src/ofono.service ofono.pc)