Add option to disable compiler optimization
[platform/upstream/ofono.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT()
3
4 AM_INIT_AUTOMAKE(ofono, 0.1)
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 AC_LANG_C
14
15 AC_PROG_CC
16 AC_PROG_CC_PIE
17 AC_PROG_INSTALL
18 AC_C_RESTRICT
19
20 m4_define([_LT_AC_TAGCONFIG], [])
21 m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
22
23 AC_DISABLE_STATIC
24 AC_PROG_LIBTOOL
25
26 AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
27                         [disable code optimization through compiler]), [
28         if (test "${enableval}" = "no"); then
29                 CFLAGS="$CFLAGS -O0"
30         fi
31 ])
32
33 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
34                         [enable compiling with debugging information]), [
35         if (test "${enableval}" = "yes" &&
36                                 test "${ac_cv_prog_cc_g}" = "yes"); then
37                 CFLAGS="$CFLAGS -g"
38         fi
39 ])
40
41 AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
42                         [enable position independent executables flag]), [
43         if (test "${enableval}" = "yes" &&
44                                 test "${ac_cv_prog_cc_pie}" = "yes"); then
45                 CFLAGS="$CFLAGS -fPIE"
46                 LDFLAGS="$LDFLAGS -pie"
47         fi
48 ])
49
50 AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
51                 [enable threading support]), [enable_threads=${enableval}])
52
53 AC_CHECK_LIB(dl, dlopen, dummy=yes,
54                         AC_MSG_ERROR(dynamic linking loader is required))
55
56 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
57                                 AC_MSG_ERROR(GLib >= 2.16 is required))
58 AC_SUBST(GLIB_CFLAGS)
59 AC_SUBST(GLIB_LIBS)
60
61 if (test "${enable_threads}" = "yes"); then
62         AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
63         PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
64                                 AC_MSG_ERROR(GThread >= 2.16 is required))
65         GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
66         GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
67 fi
68
69 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
70                                 AC_MSG_ERROR(D-Bus >= 1.0 is required))
71 AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
72         AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
73                 [Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
74 AC_SUBST(DBUS_CFLAGS)
75 AC_SUBST(DBUS_LIBS)
76 DBUS_DATADIR="`$PKG_CONFIG --variable=sysconfdir dbus-1`"
77 if (test -z "{DBUS_DATADIR}"); then
78         DBUS_DATADIR="${sysconfdir}/dbus-1/system.d"
79 else
80         DBUS_DATADIR="$DBUS_DATADIR/dbus-1/system.d"
81 fi
82 AC_SUBST(DBUS_DATADIR)
83
84 AC_SUBST([GDBUS_CFLAGS], ['$(DBUS_CFLAGS) -I$(top_srcdir)/gdbus'])
85 AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la $(DBUS_LIBS)'])
86
87 AC_SUBST([GATCHAT_CFLAGS], ['-I$(top_srcdir)/gatchat'])
88 AC_SUBST([GATCHAT_LIBS], ['$(top_builddir)/gatchat/libgatchat.la'])
89
90 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
91 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
92
93 AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
94                         [don't install configuration and data files]),
95                                         [enable_datafiles=${enableval}])
96
97 AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
98
99 COMPILER_FLAGS
100
101 AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile gisi/Makefile
102                         include/Makefile include/version.h src/Makefile
103                         plugins/Makefile drivers/Makefile unit/Makefile
104                                                                 doc/Makefile)