1AC_PREREQ(2.63)
2
3m4_define([libsecret_major_version], 0)
4m4_define([libsecret_minor_version], 20)
5m4_define([libsecret_micro_version], 4)
6m4_define([libsecret_version],
7          [libsecret_major_version.libsecret_minor_version.libsecret_micro_version])
8AC_INIT([libsecret],[libsecret_version],
9        [https://gitlab.gnome.org/GNOME/libsecret/issues/],
10        [libsecret])
11
12AC_SUBST(SECRET_MAJOR_VERSION, libsecret_major_version)
13AC_SUBST(SECRET_MINOR_VERSION, libsecret_minor_version)
14AC_SUBST(SECRET_MICRO_VERSION, libsecret_micro_version)
15
16dnl ****************************************************************************
17dnl Dependency versions
18
19# Required
20
21GLIB_REQ=2.44.0
22GLIB_MIN=GLIB_VERSION_2_44
23GLIB_MAX=GLIB_VERSION_2_44
24
25# Optional
26
27VALA_WANT=0.17.2.12
28
29GCRYPT_WANT=1.2.2
30
31GTKDOC_WANT=1.9
32
33GIR_WANT=1.29
34
35dnl ****************************************************************************
36dnl Library package and libtool versioning
37dnl
38dnl Updating the libtool versions, follow these instructions sequentially:
39dnl  1. If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
40dnl  2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
41dnl  3. If any interfaces have been added since the last public release, then increment age.
42dnl  4. If any interfaces have been removed or changed since the last public release, then set age to 0.
43
44SECRET_MAJOR=1
45SECRET_MINOR=0
46SECRET_MICRO=0
47
48SECRET_CURRENT=0
49SECRET_REVISION=0
50SECRET_AGE=0
51
52# -----------------------------------------------------------------------------
53
54AC_CONFIG_MACRO_DIR([build/m4])
55AC_CONFIG_AUX_DIR([build/litter])
56AC_REQUIRE_AUX_FILE([tap-driver.sh])
57AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip tar-ustar foreign -Wno-portability subdir-objects])
58AM_SANITY_CHECK
59AC_CONFIG_HEADERS(config.h)
60AC_CONFIG_SRCDIR([libsecret/secret-value.c])
61m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
62AM_MAINTAINER_MODE([enable])
63
64# -----------------------------------------------------------------------------
65# Basic tools
66
67AC_GNU_SOURCE
68AC_ISC_POSIX
69AC_PROG_CC
70AC_PROG_CPP
71AM_PROG_CC_C_O
72AC_PROG_INSTALL
73AC_PROG_LN_S
74AC_PROG_MAKE_SET
75AM_PROG_LIBTOOL
76PKG_PROG_PKG_CONFIG
77
78# --------------------------------------------------------------------
79# i18n
80
81AM_GNU_GETTEXT([external])
82# FIXME: Remove AM_GNU_GETTEXT_VERSION once autoreconf supports REQUIRE_VERSION
83AM_GNU_GETTEXT_VERSION([0.19.8])
84m4_ifdef([AM_GNU_GETTEXT_REQUIRE_VERSION],[
85AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8])
86])
87
88GETTEXT_PACKAGE=libsecret
89AC_SUBST([GETTEXT_PACKAGE])
90AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[The gettext domain name])
91
92# --------------------------------------------------------------------
93# Checks for functions
94
95AC_CHECK_FUNCS(mlock)
96
97# --------------------------------------------------------------------
98# GLib
99
100PKG_CHECK_MODULES(GLIB,
101	glib-2.0 >= $GLIB_REQ
102	gio-2.0
103	gio-unix-2.0)
104LIBS="$LIBS $GLIB_LIBS"
105CFLAGS="$CFLAGS $GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=$GLIB_MIN -DGLIB_VERSION_MAX_ALLOWED=$GLIB_MAX"
106
107GTK_DOC_CHECK($GTKDOC_WANT)
108
109GOBJECT_INTROSPECTION_CHECK($GIR_WANT)
110AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
111
112# --------------------------------------------------------------------
113# Manual pages
114
115AC_ARG_ENABLE(manpages,
116              AC_HELP_STRING([--disable-manpages], [Build manual pages]))
117if test "$enable_manpages" != "no"; then
118	enable_manpages="yes"
119	AC_PATH_PROG([XSLTPROC], [xsltproc])
120	if test x$XSLTPROC = x; then
121		AC_MSG_ERROR([xsltproc is required to build manual pages])
122	fi
123fi
124AM_CONDITIONAL(WITH_MANPAGES, test x$enable_manpages = xyes)
125
126# --------------------------------------------------------------------
127# Vala
128
129VAPIGEN_CHECK($VALA_WANT)
130
131if test "$enable_vala" != "no"; then
132	AC_PATH_PROG([VALAC], [valac], [])
133fi
134AM_CONDITIONAL(HAVE_VALAC, test "x$VALAC" != "x")
135
136# --------------------------------------------------------------------
137# libgcrypt
138
139GCRYPT_LIBVER=1
140
141AC_ARG_ENABLE(gcrypt,
142              [AC_HELP_STRING([--disable-gcrypt],
143                              [without gcrypt and transport encryption])
144              ])
145
146if test "$enable_gcrypt" != "no"; then
147
148	have_gcrypt="no"
149	m4_ifdef([AM_PATH_LIBGCRYPT],
150	         [AM_PATH_LIBGCRYPT($GCRYPT_LIBVER:$GCRYPT_WANT, have_gcrypt=yes)])
151
152	if test $have_gcrypt != "yes"; then
153		AC_MSG_ERROR([[
154***
155*** libgcrypt was not found. You may want to get it from
156*** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
157***
158		]])
159	fi
160
161	AC_DEFINE(WITH_GCRYPT, 1, [Build with libgcypt and transport encryption])
162	AC_DEFINE_UNQUOTED(LIBGCRYPT_VERSION, "$GCRYPT_WANT",
163	                   [Version of GCRYPT we expect])
164
165	AC_SUBST([LIBGCRYPT_CFLAGS])
166	AC_SUBST([LIBGCRYPT_LIBS])
167
168	gcrypt_status="yes"
169	enable_gcrypt="yes"
170else
171	gcrypt_status="no"
172fi
173
174AM_CONDITIONAL(WITH_GCRYPT, test "$enable_gcrypt" = "yes")
175
176# --------------------------------------------------------------------
177# Compilation options
178
179if test "$GCC" = "yes"; then
180	CFLAGS="$CFLAGS \
181		-Wall -Wmissing-declarations \
182		-Wmissing-prototypes -Wnested-externs -Wpointer-arith \
183		-Wdeclaration-after-statement -Wformat=2 -Winit-self \
184		-Waggregate-return"
185
186	for option in -Wmissing-include-dirs -Wundef; do
187		SAVE_CFLAGS="$CFLAGS"
188		CFLAGS="$CFLAGS $option"
189		AC_MSG_CHECKING([whether gcc understands $option])
190		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
191				  [has_option=yes],
192				  [has_option=no])
193		AC_MSG_RESULT($has_option)
194		if test $has_option = no; then
195			CFLAGS="$SAVE_CFLAGS"
196		fi
197	done
198fi
199
200AC_ARG_ENABLE(strict, [
201               AS_HELP_STRING([--enable-strict], [Strict code compilation])
202             ])
203
204AC_MSG_CHECKING([build strict])
205
206if test "$enable_strict" = "yes"; then
207	CFLAGS="$CFLAGS -Werror -DG_DISABLE_DEPRECATED"
208	INTROSPECTION_FLAGS="--warn-error"
209	TEST_MODE="thorough"
210else
211	CFLAGS="$CFLAGS -Wno-error"
212	TEST_MODE="quick"
213	INTROSPECTION_FLAGS=""
214	enable_strict="no"
215fi
216
217AC_MSG_RESULT($enable_strict)
218AC_SUBST(INTROSPECTION_FLAGS)
219AC_SUBST(TEST_MODE)
220
221AC_MSG_CHECKING([for debug mode])
222AC_ARG_ENABLE(debug,
223              AC_HELP_STRING([--enable-debug=no/default/yes],
224                             [Turn on or off debugging])
225             )
226
227if test "$enable_debug" != "no"; then
228	AC_DEFINE_UNQUOTED(WITH_DEBUG, 1, [Print debug output])
229	AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode])
230	CFLAGS="$CFLAGS -g"
231fi
232if test "$enable_debug" = "yes"; then
233	debug_status="yes"
234	CFLAGS="$CFLAGS -O0"
235elif test "$enable_debug" = "no"; then
236	debug_status="no"
237	CFLAGS="$CFLAGS -O2"
238	AC_DEFINE_UNQUOTED(G_DISABLE_ASSERT, 1, [Disable glib assertions])
239else
240	debug_status="default"
241fi
242
243AC_MSG_RESULT($debug_status)
244
245AC_MSG_CHECKING([whether to build with gcov testing])
246AC_ARG_ENABLE([coverage],
247              AS_HELP_STRING([--enable-coverage],
248                             [Whether to enable coverage testing ]),
249              [], [enable_coverage=no])
250AC_MSG_RESULT([$enable_coverage])
251
252if test "$enable_coverage" = "yes"; then
253	if test "$GCC" != "yes"; then
254		AC_MSG_ERROR(Coverage testing requires GCC)
255	fi
256
257	AC_PATH_PROG(GCOV, gcov, no)
258	if test "$GCOV" = "no" ; then
259		AC_MSG_ERROR(gcov tool is not available)
260	fi
261
262	AC_PATH_PROG(LCOV, lcov, no)
263	if test "$LCOV" = "no" ; then
264		AC_MSG_ERROR(lcov tool is not installed)
265	fi
266
267	AC_PATH_PROG(GENHTML, genhtml, no)
268	if test "$GENHTML" = "no" ; then
269		AC_MSG_ERROR(lcov's genhtml tool is not installed)
270	fi
271
272	CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
273	LDFLAGS="$LDFLAGS -lgcov"
274fi
275
276AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_coverage" = "yes"])
277AC_SUBST(LCOV)
278AC_SUBST(GCOV)
279AC_SUBST(GENHTML)
280
281# ------------------------------------------------------------------------------
282# Results
283#
284
285SECRET_LT_RELEASE=$SECRET_CURRENT:$SECRET_REVISION:$SECRET_AGE
286AC_SUBST(SECRET_LT_RELEASE)
287AC_SUBST(SECRET_MAJOR)
288AC_SUBST(SECRET_MINOR)
289
290AC_CONFIG_FILES([
291	Makefile
292	docs/reference/libsecret/Makefile
293	docs/reference/libsecret/version.xml
294	po/Makefile.in
295	po/Makefile
296	libsecret/libsecret.pc
297	libsecret/libsecret-unstable.pc
298	libsecret/secret-version.h
299])
300AC_OUTPUT
301
302echo
303echo "CFLAGS: $CFLAGS"
304echo
305echo "OPTIONS:"
306echo "  libgcrypt:     $gcrypt_status"
307echo "  vala:          $enable_vala"
308echo "  Debug:         $debug_status"
309echo "  Coverage:      $enable_coverage"
310echo "  Manual Page:   $enable_manpages"
311echo
312