Add --enable-debug and --enable-coverage, egg tests etc
[platform/upstream/libsecret.git] / configure.ac
1 AC_PREREQ(2.65)
2 AC_CONFIG_MACRO_DIR([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, glib-2.0 >= 2.28.0 gio-2.0 >= 2.28.0 gthread-2.0 >= 2.16.0)
38 LIBS="$LIBS $GLIB_LIBS"
39 CFLAGS="$CFLAGS $GLIB_CFLAGS"
40
41 # --------------------------------------------------------------------
42 # libgcrypt
43 #
44
45 GCRYPT_VERSION=1.2.2
46 GCRYPT_LIBVER=1
47
48 AC_ARG_ENABLE(gcrypt,
49               [AC_HELP_STRING([--disable-gcrypt],
50                               [without gcrypt and transport encryption])
51               ])
52
53 if test "$enable_gcrypt" != "no"; then
54         AM_PATH_LIBGCRYPT($GCRYPT_LIBVER:$GCRYPT_VERSION,,
55                           AC_MSG_ERROR([[
56 ***
57 *** libgcrypt was not found. You may want to get it from
58 *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
59 ***
60                           ]]))
61
62         AC_DEFINE(WITH_GCRYPT, 1, [Build with libgcypt and transport encryption])
63         AC_DEFINE_UNQUOTED(LIBGCRYPT_VERSION, "$GCRYPT_VERSION",
64                            [Version of GCRYPT we expect])
65
66         AC_SUBST([LIBGCRYPT_CFLAGS])
67         AC_SUBST([LIBGCRYPT_LIBS])
68
69         gcrypt_status=$GCRYPT_VERSION
70         enable_gcrypt="yes"
71 else
72         gcrypt_status="no"
73 fi
74
75 AM_CONDITIONAL(WITH_GCRYPT, test "$enable_gcrypt" = "yes")
76
77 # --------------------------------------------------------------------
78 # Compilation options
79 #
80
81 AC_ARG_ENABLE(more-warnings,
82               AS_HELP_STRING([--disable-more-warnings], [Inhibit compiler warnings]),
83               set_more_warnings=no)
84
85 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
86         CFLAGS="$CFLAGS \
87                 -Wall -Wstrict-prototypes -Wmissing-declarations \
88                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith \
89                 -Wdeclaration-after-statement -Wformat=2 -Winit-self \
90                 -Waggregate-return -Wmissing-format-attribute"
91
92         for option in -Wmissing-include-dirs -Wundef; do
93                 SAVE_CFLAGS="$CFLAGS"
94                 CFLAGS="$CFLAGS $option"
95                 AC_MSG_CHECKING([whether gcc understands $option])
96                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
97                                   [has_option=yes],
98                                   [has_option=no])
99                 AC_MSG_RESULT($has_option)
100                 if test $has_option = no; then
101                         CFLAGS="$SAVE_CFLAGS"
102                 fi
103         done
104 fi
105
106 AC_ARG_ENABLE(strict, [
107                AS_HELP_STRING([--enable-strict], [Strict code compilation])
108              ])
109
110 AC_MSG_CHECKING([build strict])
111
112 if test "$enable_strict" = "yes"; then
113         CFLAGS="$CFLAGS -Werror \
114                 -DGTK_DISABLE_DEPRECATED \
115                 -DGDK_DISABLE_DEPRECATED \
116                 -DG_DISABLE_DEPRECATED \
117                 -DGDK_PIXBUF_DISABLE_DEPRECATED"
118         TEST_MODE="thorough"
119 else 
120         TEST_MODE="quick"
121         $enable_strict="no"
122 fi
123
124 AC_MSG_RESULT($enable_strict)
125 AC_SUBST(TEST_MODE)
126
127 AC_MSG_CHECKING([for debug mode])
128 AC_ARG_ENABLE(debug,
129               AC_HELP_STRING([--enable-debug=no/default/yes],
130                              [Turn on or off debugging])
131              )
132
133 if test "$enable_debug" != "no"; then
134         AC_DEFINE_UNQUOTED(WITH_DEBUG, 1, [Print debug output])
135         AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode])
136         CFLAGS="$CFLAGS -g"
137 fi
138 if test "$enable_debug" = "yes"; then
139         debug_status="yes"
140         CFLAGS="$CFLAGS -O0"
141 elif test "$enable_debug" = "no"; then
142         debug_status="no"
143         AC_DEFINE_UNQUOTED(G_DISABLE_ASSERT, 1, [Disable glib assertions])
144 else
145         debug_status="default"
146 fi
147
148 AC_MSG_RESULT($debug_status)
149
150 AC_MSG_CHECKING([whether to build with gcov testing])
151 AC_ARG_ENABLE([coverage],
152               AS_HELP_STRING([--enable-coverage],
153                              [Whether to enable coverage testing ]),
154               [], [enable_coverage=no])
155 AC_MSG_RESULT([$enable_coverage])
156
157 if test "$enable_coverage" = "yes"; then
158         if test "$GCC" != "yes"; then
159                 AC_MSG_ERROR(Coverage testing requires GCC)
160         fi
161
162         AC_PATH_PROG(GCOV, gcov, no)
163         if test "$GCOV" = "no" ; then
164                 AC_MSG_ERROR(gcov tool is not available)
165         fi
166
167         AC_PATH_PROG(LCOV, lcov, no)
168         if test "$LCOV" = "no" ; then
169                 AC_MSG_ERROR(lcov tool is not installed)
170         fi
171
172         AC_PATH_PROG(GENHTML, genhtml, no)
173         if test "$GENHTML" = "no" ; then
174                 AC_MSG_ERROR(lcov's genhtml tool is not installed)
175         fi
176
177         CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
178         LDFLAGS="$LDFLAGS -lgcov"
179 fi
180
181 AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_coverage" = "yes"])
182 AC_SUBST(LCOV)
183 AC_SUBST(GCOV)
184 AC_SUBST(GENHTML)
185
186 # ------------------------------------------------------------------------------
187 # Results
188 #
189
190 AC_CONFIG_FILES([
191         Makefile
192         egg/Makefile
193         egg/tests/Makefile
194         po/Makefile.in
195         po/Makefile
196         library/Makefile
197         library/tests/Makefile
198 ])
199 AC_OUTPUT
200
201 echo
202 echo "CFLAGS: $CFLAGS"
203 echo
204 echo "OPTIONS:"
205 echo "  libgcrypt:            $gcrypt_status"
206 echo "  Debug:                $debug_status"
207 echo "  Coverage:             $enable_coverage"
208 echo