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