Valgrind integration, refactor build process
[platform/upstream/libsecret.git] / configure.ac
1 AC_PREREQ(2.65)
2 AC_CONFIG_MACRO_DIR([build/m4])
3
4 AC_INIT([gsecret],[0.1],[http://bugzilla.gnome.org/enter_bug.cgi?product=gsecret])
5
6 AC_CONFIG_SRCDIR([library/gsecret-value.c])
7 AC_CONFIG_HEADERS([config.h])
8
9 dnl Other initialization
10 AM_INIT_AUTOMAKE
11 AM_MAINTAINER_MODE([enable])
12 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
13 LT_INIT
14
15 dnl Checks for programs.
16 AC_PROG_CC
17 AC_PROG_CPP
18 AM_PROG_CC_C_O
19
20 AC_CHECK_FUNCS(mlock)
21
22 # --------------------------------------------------------------------
23 # intltool
24 #
25
26 IT_PROG_INTLTOOL([0.35.0])
27 GETTEXT_PACKAGE=gsecret
28
29 AC_SUBST([GETTEXT_PACKAGE])
30 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[The gettext domain name])
31 AM_GLIB_GNU_GETTEXT
32
33 # --------------------------------------------------------------------
34 # GLib
35 #
36
37 PKG_CHECK_MODULES(GLIB,
38         glib-2.0 >= 2.31.0
39         gio-2.0 >= 2.31.0
40         gio-unix-2.0)
41 LIBS="$LIBS $GLIB_LIBS"
42 CFLAGS="$CFLAGS $GLIB_CFLAGS"
43
44 # --------------------------------------------------------------------
45 # libgcrypt
46 #
47
48 GCRYPT_VERSION=1.2.2
49 GCRYPT_LIBVER=1
50
51 AC_ARG_ENABLE(gcrypt,
52               [AC_HELP_STRING([--disable-gcrypt],
53                               [without gcrypt and transport encryption])
54               ])
55
56 if test "$enable_gcrypt" != "no"; then
57         AM_PATH_LIBGCRYPT($GCRYPT_LIBVER:$GCRYPT_VERSION,,
58                           AC_MSG_ERROR([[
59 ***
60 *** libgcrypt was not found. You may want to get it from
61 *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
62 ***
63                           ]]))
64
65         AC_DEFINE(WITH_GCRYPT, 1, [Build with libgcypt and transport encryption])
66         AC_DEFINE_UNQUOTED(LIBGCRYPT_VERSION, "$GCRYPT_VERSION",
67                            [Version of GCRYPT we expect])
68
69         AC_SUBST([LIBGCRYPT_CFLAGS])
70         AC_SUBST([LIBGCRYPT_LIBS])
71
72         gcrypt_status=$GCRYPT_VERSION
73         enable_gcrypt="yes"
74 else
75         gcrypt_status="no"
76 fi
77
78 AM_CONDITIONAL(WITH_GCRYPT, test "$enable_gcrypt" = "yes")
79
80 # --------------------------------------------------------------------
81 # Compilation options
82 #
83
84 AC_ARG_ENABLE(more-warnings,
85               AS_HELP_STRING([--disable-more-warnings], [Inhibit compiler warnings]),
86               set_more_warnings=no)
87
88 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
89         CFLAGS="$CFLAGS \
90                 -Wall -Wstrict-prototypes -Wmissing-declarations \
91                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith \
92                 -Wdeclaration-after-statement -Wformat=2 -Winit-self \
93                 -Waggregate-return -Wmissing-format-attribute"
94
95         for option in -Wmissing-include-dirs -Wundef; do
96                 SAVE_CFLAGS="$CFLAGS"
97                 CFLAGS="$CFLAGS $option"
98                 AC_MSG_CHECKING([whether gcc understands $option])
99                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
100                                   [has_option=yes],
101                                   [has_option=no])
102                 AC_MSG_RESULT($has_option)
103                 if test $has_option = no; then
104                         CFLAGS="$SAVE_CFLAGS"
105                 fi
106         done
107 fi
108
109 AC_ARG_ENABLE(strict, [
110                AS_HELP_STRING([--enable-strict], [Strict code compilation])
111              ])
112
113 AC_MSG_CHECKING([build strict])
114
115 if test "$enable_strict" = "yes"; then
116         CFLAGS="$CFLAGS -Werror \
117                 -DGTK_DISABLE_DEPRECATED \
118                 -DGDK_DISABLE_DEPRECATED \
119                 -DG_DISABLE_DEPRECATED \
120                 -DGDK_PIXBUF_DISABLE_DEPRECATED"
121         TEST_MODE="thorough"
122 else 
123         TEST_MODE="quick"
124         $enable_strict="no"
125 fi
126
127 AC_MSG_RESULT($enable_strict)
128 AC_SUBST(TEST_MODE)
129
130 AC_MSG_CHECKING([for debug mode])
131 AC_ARG_ENABLE(debug,
132               AC_HELP_STRING([--enable-debug=no/default/yes],
133                              [Turn on or off debugging])
134              )
135
136 if test "$enable_debug" != "no"; then
137         AC_DEFINE_UNQUOTED(WITH_DEBUG, 1, [Print debug output])
138         AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode])
139         CFLAGS="$CFLAGS -g"
140 fi
141 if test "$enable_debug" = "yes"; then
142         debug_status="yes"
143         CFLAGS="$CFLAGS -O0"
144 elif test "$enable_debug" = "no"; then
145         debug_status="no"
146         AC_DEFINE_UNQUOTED(G_DISABLE_ASSERT, 1, [Disable glib assertions])
147 else
148         debug_status="default"
149 fi
150
151 AC_MSG_RESULT($debug_status)
152
153 AC_MSG_CHECKING([whether to build with gcov testing])
154 AC_ARG_ENABLE([coverage],
155               AS_HELP_STRING([--enable-coverage],
156                              [Whether to enable coverage testing ]),
157               [], [enable_coverage=no])
158 AC_MSG_RESULT([$enable_coverage])
159
160 if test "$enable_coverage" = "yes"; then
161         if test "$GCC" != "yes"; then
162                 AC_MSG_ERROR(Coverage testing requires GCC)
163         fi
164
165         AC_PATH_PROG(GCOV, gcov, no)
166         if test "$GCOV" = "no" ; then
167                 AC_MSG_ERROR(gcov tool is not available)
168         fi
169
170         AC_PATH_PROG(LCOV, lcov, no)
171         if test "$LCOV" = "no" ; then
172                 AC_MSG_ERROR(lcov tool is not installed)
173         fi
174
175         AC_PATH_PROG(GENHTML, genhtml, no)
176         if test "$GENHTML" = "no" ; then
177                 AC_MSG_ERROR(lcov's genhtml tool is not installed)
178         fi
179
180         CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
181         LDFLAGS="$LDFLAGS -lgcov"
182 fi
183
184 AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_coverage" = "yes"])
185 AC_SUBST(LCOV)
186 AC_SUBST(GCOV)
187 AC_SUBST(GENHTML)
188
189 # ------------------------------------------------------------------------------
190 # Results
191 #
192
193 AC_CONFIG_FILES([
194         Makefile
195         build/Makefile
196         egg/Makefile
197         egg/tests/Makefile
198         po/Makefile.in
199         po/Makefile
200         library/Makefile
201         library/tests/Makefile
202 ])
203 AC_OUTPUT
204
205 echo
206 echo "CFLAGS: $CFLAGS"
207 echo
208 echo "OPTIONS:"
209 echo "  libgcrypt:            $gcrypt_status"
210 echo "  Debug:                $debug_status"
211 echo "  Coverage:             $enable_coverage"
212 echo