build: install .pc files & non-existing docs, honour libdir for plugins.
[profile/ivi/murphy.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.59)
5
6 AC_INIT([murphy],
7         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
8         [krisztian.litkey at intel.com])
9
10 AC_CONFIG_MACRO_DIR([m4])
11 AC_CONFIG_SRCDIR([src])
12 AC_CONFIG_HEADER([src/config.h])
13 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
14
15 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
16
17 m4_define(version_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`)
18 m4_define(version_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`)
19 m4_define(version_patch, `echo $VERSION | cut -d. -f3 | cut -d- -f1`)
20
21 AC_SUBST(VERSION)
22 AC_SUBST(VERSION_MAJOR, version_major)
23 AC_SUBST(VERSION_MINOR, version_minor)
24 AC_SUBST(VERSION_PATCH, version_patch)
25 AC_SUBST(VERSION_FULL, version_major.version_minor.version_patch)
26
27 MURPHY_VERSION_INFO="0:0:0"
28 AC_SUBST(MURPHY_VERSION_INFO)
29
30 # Disable static libraries.
31 AC_DISABLE_STATIC
32
33 # Checks for programs.
34 AC_PROG_CC
35 AC_PROG_CC_C99
36 AC_PROG_AWK
37 AC_PROG_INSTALL
38 AM_PROG_CC_C_O
39 AM_PROG_LIBTOOL
40
41 # Checks for libraries.
42 AC_CHECK_LIB([dl], [dlopen dlclose dlsym dlerror])
43
44 # Checks for header files.
45 AC_PATH_X
46 AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/statvfs.h sys/vfs.h syslog.h unistd.h])
47
48 # Checks for typedefs, structures, and compiler characteristics.
49 AC_HEADER_STDBOOL
50 AC_C_INLINE
51 AC_TYPE_INT16_T
52 AC_TYPE_INT32_T
53 AC_TYPE_INT64_T
54 AC_TYPE_MODE_T
55 AC_TYPE_PID_T
56 AC_TYPE_SIZE_T
57 AC_TYPE_SSIZE_T
58 AC_CHECK_MEMBERS([struct stat.st_rdev])
59 AC_TYPE_UINT16_T
60 AC_TYPE_UINT32_T
61 AC_TYPE_UINT64_T
62 AC_TYPE_UINT8_T
63 AC_CHECK_TYPES([ptrdiff_t])
64
65 # Checks for library functions.
66 AC_FUNC_ERROR_AT_LINE
67 AC_HEADER_MAJOR
68 AC_FUNC_MALLOC
69 AC_FUNC_STRTOD
70 AC_CHECK_FUNCS([clock_gettime memmove memset regcomp strcasecmp strchr strdup strrchr strtol strtoul])
71
72 # Check for glib.
73 PKG_CHECK_MODULES(GLIB, glib-2.0)
74 AC_SUBST(GLIB_CFLAGS)
75 AC_SUBST(GLIB_LIBS)
76
77 # Check for low-level DBUS libs.
78 PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.70 dbus-1 >= 0.70)
79 AC_SUBST(DBUS_CFLAGS)
80 AC_SUBST(DBUS_LIBS)
81
82 DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
83 AC_SUBST(DBUS_SESSION_DIR)
84
85 # Check and enable extra compiler warnings if they are supported.
86 AC_ARG_ENABLE(extra-warnings,
87               [  --enable-extra-warnings         enable extra compiler warnings],
88               [extra_warnings=$enableval], [extra_warnings=auto])
89
90 WARNING_CFLAGS=""
91 warncflags="-Wall -Wextra"
92 if test "$extra_warnings" != "no"; then
93     save_CPPFLAGS="$CPPFLAGS"
94     for opt in $warncflags; do
95         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
96                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
97     done
98     CPPFLAGS="$save_CPPFLAGS"
99 fi
100
101 AC_SUBST(WARNING_CFLAGS)
102
103
104 # Set up murphy CFLAGS and LIBS.
105 MURPHY_CFLAGS="$GLIB_CFLAGS $DBUS_CFLAGS"
106 MURPHY_LIBS="$GLIB_LIBS $DBUS_LIBS"
107 AC_SUBST(MURPHY_CFLAGS)
108 AC_SUBST(MURPHY_LIBS)
109
110 # Add LIBDIR to config.h.
111 AC_MSG_CHECKING([libdir])
112 AC_MSG_RESULT([$libdir])
113 AC_SUBST(LIBDIR, [$libdir])
114
115 # Check which plugins should be built in.
116 AC_ARG_WITH(builtin-plugins,
117             [  --with-builtin-plugins=<plugin-list>  specify which plugins to link in],
118             [builtin_plugins=$withval],[builtin_plugins=all])
119
120 all_plugins=$(ls src/plugins/*.c 2>/dev/null | \
121               sed 's#src/plugins/plugin-##g;s#\.c$##g' | tr '\n' ' ')
122
123 case $builtin_plugins in
124     all)  builtin_plugins="$all_plugins";;
125     none) builtin_plugins="";;
126 esac
127
128 internal=""; it=""
129 external=""; et=""
130 for plugin in $all_plugins; do 
131     type=external
132
133     for p in ${builtin_plugins//,/ }; do
134         if test "$plugin" = "$p"; then
135             internal="$internal$it$plugin"
136             type=internal
137             it=" "
138         fi
139     done
140
141     if test "$type" = "external"; then
142         external="$external$et$plugin"
143         et=" "
144     fi
145 done
146
147 INTERNAL_PLUGINS="$internal"
148 EXTERNAL_PLUGINS="$external"
149
150 function check_if_internal() {
151     for p in $INTERNAL_PLUGINS; do
152         if test "$1" = "$p"; then
153             return 0
154         fi
155     done
156
157     return 1
158 }
159
160 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,    [check_if_internal test])
161 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,    [check_if_internal dbus])
162 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,    [check_if_internal glib])
163 #AM_CONDITIONAL(BUILTIN_PLUGIN_STORAGE, [check_if_internal storage])
164 #AM_CONDITIONAL(BUILTIN_PLUGIN_SYSFS,   [check_if_internal sysfs  ])
165 #AM_CONDITIONAL(BUILTIN_PLUGIN_DISPLAY, [check_if_internal display])
166 #AM_CONDITIONAL(BUILTIN_PLUGIN_NETWORK, [check_if_internal network])
167 #AM_CONDITIONAL(BUILTIN_PLUGIN_BATTERY, [check_if_internal battery])
168 #AM_CONDITIONAL(BUILTIN_PLUGIN_XFS,     [check_if_internal xfs])
169
170 # Check for Check (unit test framework).
171 PKG_CHECK_MODULES(CHECK, 
172                   check >= 0.9.4,
173                   [has_check="yes"], [has_check="no"])
174 AM_CONDITIONAL(HAVE_CHECK, test "x$has_check" = "xyes")
175
176 if test "x$has_check" = "xno"; then
177     AC_MSG_WARN([Check framework not found, unit tests are DISABLED.])
178 fi
179
180 # Shave by default.
181 SHAVE_INIT([build-aux], [enable])
182
183 # Create murphy symlink to src.
184 if test ! -L murphy; then
185     AC_MSG_NOTICE([Symlinking src to murphy...])
186     ln -s src murphy
187 fi
188
189 # Generate output.
190 AC_CONFIG_FILES([build-aux/shave
191                  build-aux/shave-libtool
192                  Makefile
193                  src/Makefile
194                  src/common/tests/Makefile
195                  src/core/tests/Makefile
196                  src/daemon/tests/Makefile
197                  src/common/murphy-common.pc
198                  src/core/murphy-core.pc
199                  doc/Makefile
200                  ])
201 AC_OUTPUT
202
203 # Display the configuration.
204 echo "----- configuration -----"
205 echo "Extra C warnings flags: $WARNING_CFLAGS"
206 echo "Plugins:"
207 echo "  - linked-in:"
208 for plugin in ${INTERNAL_PLUGINS:-none}; do
209     echo "      $plugin"
210 done
211
212 echo "  - dynamic:"
213 for plugin in ${EXTERNAL_PLUGINS:-none}; do
214     echo "      $plugin"
215 done