File: configure.ac

package info (click to toggle)
libsecrecy 0.0.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 372 kB
  • sloc: cpp: 3,524; sh: 221; makefile: 67
file content (521 lines) | stat: -rw-r--r-- 17,271 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
AC_INIT(libsecrecy,0.0.2,[germant@miltenyibiotec.de],[libsecrecy],[https://gitlab.com/german.tischler/libsecrecy])
LIBRARY_VERSION=0:2:0
AC_MSG_NOTICE([Configuring for source in directory ${srcdir}])
AC_CANONICAL_SYSTEM
AC_CANONICAL_HOST
AC_PROG_LIBTOOL

abs_builddir="${PWD}"

AM_INIT_AUTOMAKE([std-options subdir-objects tar-pax parallel-tests])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])

if test \( "${ac_cv_build}" = "${ac_cv_host}" \) -a \( "${ac_cv_build}" = "${ac_cv_target}" \) ; then
	LIBSECRECY_IS_NATIVE=1
	AC_MSG_RESULT([no])
else
	LIBSECRECY_IS_NATIVE=0
	AC_MSG_RESULT([yes])
fi

AC_PATH_PROG(BASHPROG,bash,no)
AC_PATH_PROG(BASE64PROG,base64,no)

TESTDIR=
if test \( "${LIBSECRECY_IS_NATIVE}" -eq 1 \) -a \( "${BASHPROG}" != "no" \) -a \( "${BASE64PROG}" != "no" \) ; then
	TESTDIR=test
fi

CFLAGS_SAVE="${CFLAGS}"
CFLAGS=""
AC_PROG_CC
AM_PROG_CC_C_O
CFLAGS="${CFLAGS_SAVE}"

CXXFLAGS_SAVE="${CXXFLAGS}"
CXXFLAGS=""
AC_PROG_CXX
CXXFLAGS="${CXXFLAGS_SAVE}"

AC_LANG_PUSH([C++])
CXXFLAGS_SAVE="${CXXFLAGS}"
CXXFLAGS="-std=c++17"
AC_MSG_CHECKING([whether the C++ compiler supports the -std=c++17 flag])
AC_TRY_COMPILE([#include <cstdint>],[],[seventeen=yes],[seventeen=no])
AC_MSG_RESULT([${seventeen}])
CXXFLAGS="${CXXFLAGS_SAVE}"
AC_LANG_POP

if test "${seventeen}" != "yes" ; then
	AC_MSG_ERROR([Required flag -std=c++17 is not supported.]);
fi

AC_LANG_PUSH([C++])
AC_CHECK_HEADER(sys/mman.h, [sys_mman_h=yes], [sys_mman_h=no])
AC_CHECK_HEADER(sys/random.h, [sys_random_h=yes], [sys_random_h=no])
AC_LANG_POP

if test "${sys_mman_h}" != "yes" ; then
	AC_MSG_ERROR([Required header sys/mman.h not found.]);
fi
if test "${sys_random_h}" != "yes" ; then
	AC_MSG_ERROR([Required header sys/random.h not found.]);
fi

LIBSECRECYCPPFLAGS="${CPPFLAGS}"
LIBSECRECYLDFLAGS="${LDFLAGS}"

dnl check whether we have the pkg-config program
PKG_PROG_PKG_CONFIG

AC_LANG_PUSH([C++])
AC_CHECK_FUNC(mlock,[have_mlock=yes],[have_mlock=no])
AC_CHECK_FUNC(munlock,[have_munlock=yes],[have_munlock=no])
AC_CHECK_FUNC(getrandom,[have_getrandom=yes],[have_getrandom=no])
AC_LANG_POP

if test "${have_mlock}" != "yes" ; then
	AC_MSG_ERROR([Required function mlock cannot be found.]);
fi
if test "${have_munlock}" != "yes" ; then
	AC_MSG_ERROR([Required function munlock cannot be found.]);
fi
if test "${have_getrandom}" != "yes" ; then
	AC_MSG_ERROR([Required function getrandom cannot be found.]);
fi

if test "${seventeen}" = "yes" ; then
	CXXFLAGS_SAVE="${CXXFLAGS}"
	CPPFLAGS_SAVE="${CPPFLAGS}"
	CXXFLAGS="-std=c++17"
	CPPFLAGS="-std=c++17"
	AC_LANG_PUSH([C++])
	AC_CHECK_HEADER(cstdint, [cstdint=yes], [cstdint=no])
	AC_LANG_POP
	CXXFLAGS="${CXXFLAGS_SAVE}"
	CPPFLAGS="${CPPFLAGS_SAVE}"

	LIBSECRECYCXXFLAGS="${LIBSECRECYCXXFLAGS} -std=c++17"
	LIBSECRECYPKGCXXFLAGS="${LIBSECRECYPKGCXXFLAGS} -std=c++17"
fi

WARNCXXFLAGS=

# effc++ strict-null-sentinel no-non-template-friend old-style-cast overloaded-virtual sign-promo non-virtual-dtor abi extra abi

for flag in "" all non-virtual-dtor ; do
	AC_LANG_PUSH([C++])
	CXXFLAGS_SAVE="${CXXFLAGS}"
	CXXFLAGS="-W${flag}"
	AC_MSG_CHECKING([whether the C++ compiler supports the -W${flag} flag])
	AC_TRY_COMPILE([],[int c = 0;],[wflag=yes],[wflag=no])
	AC_MSG_RESULT([${wflag}])
	CXXFLAGS="${CXXFLAGS_SAVE}"
	AC_LANG_POP

	if test "${wflag}" = "yes" ; then
		WARNCXXFLAGS="${WARNCXXFLAGS} -W${flag}"
	fi
done

if test "${CXX}" = "cl.exe" ; then
	CXXFLAGS="${CXXFLAGS} -EHsc -Gr"
	CPPFLAGS="${CPPFLAGS} -W1" # -Wall
fi

AC_ARG_ENABLE(optimization,
        AS_HELP_STRING([--enable-optimization],[use compiler optimization (default yes)]),
        [optimization=${enableval}],[optimization=yes])
AC_ARG_ENABLE(debug,
        AS_HELP_STRING([--enable-debug],[use compiler debug flags (default no)]),
        [debug=${enableval}],[debug=no])
AC_ARG_ENABLE(werror,
        AS_HELP_STRING([--enable-werror],[treat compiler warnings as errors (default no)]),
        [werror=${enableval}],[werror=no])
AC_ARG_ENABLE(profile,
        AS_HELP_STRING([--enable-profile],[use compiler profiling flags (default no)]),
        [profile=${enableval}],[profile=no])

if test "${werror}" = "yes" ; then
	CXXFLAGS="${CXXFLAGS} -Werror"
fi

AC_ARG_ENABLE(asan,
        AS_HELP_STRING([--enable-asan],[enable address sanitizer in debug mode (default no)]),
        [enableasan=${enableval}],[enableasan=no])

if test "${enableasan}" = "yes" ; then
	AC_LANG_PUSH([C++])
	CXXFLAGS_SAVE="${CXXFLAGS}"
	CXXFLAGS="-fsanitize=address"
	AC_MSG_CHECKING([whether the C++ compiler supports the -fsanitize=address flag])
	AC_TRY_COMPILE([],[],[sanitizeaddress=yes],[sanitizeaddress=no])
	AC_MSG_RESULT([${sanitizeaddress}])
	CXXFLAGS="${CXXFLAGS_SAVE}"
	AC_LANG_POP

	if test "${sanitizeaddress}" = "yes" ; then
		CXXFLAGS="${CXXFLAGS} -fsanitize=address"
		CFLAGS="${CFLAGS} -fsanitize=address"
	fi
fi

COMPILER_SUPPORTS_DYNAMIC=
AC_LANG_PUSH([C++])
CXXFLAGS_SAVE="${CXXFLAGS}"
CXXFLAGS="-rdynamic"
AC_MSG_CHECKING([whether the C++ compiler supports the -rdynamic flag])
AC_TRY_COMPILE([],[],[compiler_supports_rdynamic=yes],[compiler_supports_rdynamic=no])
AC_MSG_RESULT([${compiler_supports_rdynamic}])
CXXFLAGS="${CXXFLAGS_SAVE}"
AC_LANG_POP

if test "${compiler_supports_rdynamic}" = "yes" ; then
	COMPILER_SUPPORTS_DYNAMIC="-rdynamic"
fi

if test "${debug}" = "yes" ; then
        CXXFLAGS="${CXXFLAGS} -g -O0"
        CFLAGS="${CFLAGS} -g -O0"
        LDFLAGS="${LDFLAGS} ${COMPILER_SUPPORTS_DYNAMIC}"

	AC_LANG_PUSH([C++])
	CXXFLAGS_SAVE="${CXXFLAGS}"
	CXXFLAGS="-fstack-protector"
	AC_MSG_CHECKING([whether the C++ compiler supports the -fstack-protector flag])
	AC_TRY_COMPILE([],[],[stackprotect=yes],[stackprotect=no])
	AC_MSG_RESULT([${stackprotect}])
	CXXFLAGS="${CXXFLAGS_SAVE}"
	AC_LANG_POP

	if test "${stackprotect}" = "yes" ; then
		STACKPROTECT="-fstack-protector"
		CXXFLAGS="${CXXFLAGS} ${STACKPROTECT}"
		CFLAGS="${CFLAGS} ${STACKPROTECT}"
	fi
elif test "${optimization}" = "yes" ; then
	case ${CXX} in
		g++)
			CXXFLAGS="${CXXFLAGS} -O3"
			CFLAGS="${CFLAGS} -O3"
			LDFLAGS="${LDFLAGS} -rdynamic"
			;;
		*-mingw32msvc-g++)
			CXXFLAGS="${CXXFLAGS} -O3"
			CFLAGS="${CFLAGS} -O3"
			LDFLAGS="${LDFLAGS} -rdynamic"
			;;
		cl.exe)
			CXXFLAGS="${CXXFLAGS} -O2 -Ob2 -Ot -Oy"
			;;
	esac
fi

if test "${profile}" = "yes" ; then
	CXXFLAGS="${CXXFLAGS} -g -pg"
	CFLAGS="${CFLAGS} -g -pg"
fi

AC_LANG_PUSH([C++])
CPPFLAGS_SAVE="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS}"
if test "${seventeen}" = "yes" ; then
	CPPFLAGS="${CPPFLAGS} -std=c++17"
fi
LIBS_SAVE="${LIBS}"
LIBS="${LIBS}"

AC_ARG_WITH([nettle],
	[AS_HELP_STRING([--with-nettle@<:@=PATH@:>@], [path to installed nettle library @<:@default=@:>@])],
	[with_nettle=${withval}],
	[with_nettle=])

if test "${with_nettle}" = "no" ; then
	AC_MSG_ERROR([Flag --with-nettle is set to no, but libnettle is required.]);
fi

NETTLEREQ=
if test ! -z "${with_nettle}" ; then
	PKGCONFIGPATHSAVE="${PKG_CONFIG_PATH}"
	if test -z "${PKG_CONFIG_PATH}" ; then
		export PKG_CONFIG_PATH="${with_nettle}/lib/pkgconfig"
	else
		export PKG_CONFIG_PATH="${with_nettle}/lib/pkgconfig:${PKG_CONFIG_PATH}"
	fi
fi

PKG_CHECK_MODULES([nettle],[nettle >= 2.4],[nettlepkg=yes],[nettlepkg=no])

if test ! -z "${with_nettle}" ; then
	if test ! -z "${PKGCONFIGPATHSAVE}" ; then
		export PKG_CONFIG_PATH="${PKGCONFIGPATHSAVE}"
	fi
fi

if test "${nettlepkg}" = "yes" ; then
	AC_LANG_PUSH([C++])
	LIBS_SAVE="${LIBS}"
	LIBS="${LIBS} ${nettle_LIBS}"
	CPPFLAGSSAVE="${CPPFLAGS}"
	CPPFLAGS="${CPPFLAGS} ${nettle_CFLAGS}"

	AC_MSG_CHECKING([whether we can compile a nettle program])
	AC_TRY_LINK([#include <nettle/gcm.h>
#include <nettle/sha.h>
],[;],[nettle=yes],[nettle=no])
	AC_MSG_RESULT([${nettle}])
	LIBS="${LIBS_SAVE}"
	CPPFLAGS="${CPPFLAGSSAVE}"

	AC_LANG_POP

	if test "$nettle" = "no" ; then
		AC_MSG_ERROR([Failed to compile nettle program.]);
	else
		NETTLELDFLAGS=""
		NETTLELIBS="${nettle_LIBS}"
		NETTLECPPFLAGS="${nettle_CFLAGS}"
		NETTLEREQ="nettle"
	fi
else
	AC_MSG_ERROR([nettle not found in required version])
fi

LIBS_SAVE="${LIBS}"
LIBS="${LIBS} ${nettle_LIBS}"
CPPFLAGSSAVE="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${nettle_CFLAGS}"

AC_MSG_CHECKING([whether we can compile a program using aes128_set_encrypt_key])
AC_TRY_LINK([#include <nettle/aes.h>],[aes128_set_encrypt_key((aes128_ctx *)nullptr,(unsigned char *)nullptr);],[have_aes128_set_encrypt_key=yes],[have_aes128_set_encrypt_key=no])
AC_MSG_RESULT([${have_aes128_set_encrypt_key}])

if test "${have_aes128_set_encrypt_key}" = "no" ; then
	AC_MSG_ERROR([aes128_set_encrypt_key function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using aes128_encrypt])
AC_TRY_LINK([#include <nettle/aes.h>],[aes128_encrypt((aes128_ctx *)nullptr,1,(uint8_t *)nullptr,(uint8_t *)nullptr);],[have_aes128_encrypt=yes],[have_aes128_encrypt=no])
AC_MSG_RESULT([${have_aes128_encrypt}])

if test "${have_aes128_encrypt}" = "no" ; then
	AC_MSG_ERROR([aes128_encrypt function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using aes256_set_encrypt_key])
AC_TRY_LINK([#include <nettle/aes.h>],[aes256_set_encrypt_key((aes256_ctx *)nullptr,(unsigned char *)nullptr);],[have_aes256_set_encrypt_key=yes],[have_aes256_set_encrypt_key=no])
AC_MSG_RESULT([${have_aes256_set_encrypt_key}])

if test "${have_aes256_set_encrypt_key}" = "no" ; then
	AC_MSG_ERROR([aes256_set_encrypt_key function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using aes256_encrypt])
AC_TRY_LINK([#include <nettle/aes.h>],[aes256_encrypt((aes256_ctx *)nullptr,1,(uint8_t *)nullptr,(uint8_t *)nullptr);],[have_aes256_encrypt=yes],[have_aes256_encrypt=no])
AC_MSG_RESULT([${have_aes256_encrypt}])

if test "${have_aes256_encrypt}" = "no" ; then
	AC_MSG_ERROR([aes256_encrypt function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using gcm_set_key])
AC_TRY_LINK([#include <nettle/gcm.h>],[gcm_set_key((gcm_key*)nullptr,nullptr,(nettle_cipher_func const *)nullptr);],[have_gcm_set_key=yes],[have_gcm_set_key=no])
AC_MSG_RESULT([${have_gcm_set_key}])

if test "${have_gcm_set_key}" = "no" ; then
	AC_MSG_ERROR([gcm_set_key function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using gcm_set_iv])
AC_TRY_LINK([#include <nettle/gcm.h>],[gcm_set_iv((gcm_ctx*)nullptr,(gcm_key*)nullptr,0,(unsigned char *)nullptr);],[have_gcm_set_iv=yes],[have_gcm_set_iv=no])
AC_MSG_RESULT([${have_gcm_set_iv}])

if test "${have_gcm_set_iv}" = "no" ; then
	AC_MSG_ERROR([gcm_set_iv function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using gcm_update])
AC_TRY_LINK([#include <nettle/gcm.h>],[gcm_update((gcm_ctx*)nullptr,(gcm_key*)nullptr,0,(unsigned char *)nullptr);],[have_gcm_update=yes],[have_gcm_update=no])
AC_MSG_RESULT([${have_gcm_update}])

if test "${have_gcm_update}" = "no" ; then
	AC_MSG_ERROR([gcm_update function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using gcm_encrypt])
AC_TRY_LINK([#include <nettle/gcm.h>],[gcm_encrypt((gcm_ctx*)nullptr,(gcm_key*)nullptr,nullptr,(nettle_cipher_func const *)nullptr,0,(unsigned char *)nullptr,(unsigned char *)nullptr);],[have_gcm_encrypt=yes],[have_gcm_encrypt=no])
AC_MSG_RESULT([${have_gcm_encrypt}])

if test "${have_gcm_encrypt}" = "no" ; then
	AC_MSG_ERROR([gcm_encrypt function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using gcm_decrypt])
AC_TRY_LINK([#include <nettle/gcm.h>],[gcm_decrypt((gcm_ctx*)nullptr,(gcm_key*)nullptr,nullptr,(nettle_cipher_func const *)nullptr,0,(unsigned char *)nullptr,(unsigned char *)nullptr);],[have_gcm_decrypt=yes],[have_gcm_decrypt=no])
AC_MSG_RESULT([${have_gcm_decrypt}])

if test "${have_gcm_decrypt}" = "no" ; then
	AC_MSG_ERROR([gcm_decrypt function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using gcm_digest])
AC_TRY_LINK([#include <nettle/gcm.h>],[gcm_digest((gcm_ctx*)nullptr,(gcm_key*)nullptr,nullptr,(nettle_cipher_func const *)nullptr,0,(unsigned char *)nullptr);],[have_gcm_digest=yes],[have_gcm_digest=no])
AC_MSG_RESULT([${have_gcm_digest}])

if test "${have_gcm_digest}" = "no" ; then
	AC_MSG_ERROR([gcm_digest function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using sha512_init])
AC_TRY_LINK([#include <nettle/sha.h>],[sha512_init((sha512_ctx *)nullptr);],[have_sha512_init=yes],[have_sha512_init=no])
AC_MSG_RESULT([${have_sha512_init}])

if test "${have_sha512_init}" = "no" ; then
	AC_MSG_ERROR([sha512_init function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using sha512_update])
AC_TRY_LINK([#include <nettle/sha.h>],[sha512_update((sha512_ctx *)nullptr,0,(uint8_t const *)nullptr);],[have_sha512_update=yes],[have_sha512_update=no])
AC_MSG_RESULT([${have_sha512_update}])

if test "${have_sha512_update}" = "no" ; then
	AC_MSG_ERROR([sha512_update function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using sha512_digest])
AC_TRY_LINK([#include <nettle/sha.h>],[sha512_digest((sha512_ctx *)nullptr,0,(uint8_t *)nullptr);],[have_sha512_digest=yes],[have_sha512_digest=no])
AC_MSG_RESULT([${have_sha512_digest}])

if test "${have_sha512_digest}" = "no" ; then
	AC_MSG_ERROR([sha512_digest function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using sha256_init])
AC_TRY_LINK([#include <nettle/sha.h>],[sha256_init((sha256_ctx *)nullptr);],[have_sha256_init=yes],[have_sha256_init=no])
AC_MSG_RESULT([${have_sha256_init}])

if test "${have_sha256_init}" = "no" ; then
	AC_MSG_ERROR([sha256_init function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using sha256_update])
AC_TRY_LINK([#include <nettle/sha.h>],[sha256_update((sha256_ctx *)nullptr,0,(uint8_t const *)nullptr);],[have_sha256_update=yes],[have_sha256_update=no])
AC_MSG_RESULT([${have_sha256_update}])

if test "${have_sha256_update}" = "no" ; then
	AC_MSG_ERROR([sha256_update function not found in libnettle])
fi

AC_MSG_CHECKING([whether we can compile a program using sha256_digest])
AC_TRY_LINK([#include <nettle/sha.h>],[sha256_digest((sha256_ctx *)nullptr,0,(uint8_t *)nullptr);],[have_sha256_digest=yes],[have_sha256_digest=no])
AC_MSG_RESULT([${have_sha256_digest}])

if test "${have_sha256_digest}" = "no" ; then
	AC_MSG_ERROR([sha256_digest function not found in libnettle])
fi

LIBS="${LIBS_SAVE}"
CPPFLAGS="${CPPFLAGSSAVE}"

AC_ARG_WITH([gpgme],
	[AS_HELP_STRING([--with-gpgme@<:@=PATH@:>@], [path to installed gpgme library @<:@default=@:>@])],
	[with_gpgme=${withval}],
	[with_gpgme=])

if test "${with_gpgme}" = "no" ; then
	AC_MSG_ERROR([Flag --with-gpgme is set to no, but libnettle is required.]);
fi

GPGMEREQ=
if test ! -z "${with_gpgme}" ; then
	PKGCONFIGPATHSAVE="${PKG_CONFIG_PATH}"
	if test -z "${PKG_CONFIG_PATH}" ; then
		export PKG_CONFIG_PATH="${with_gpgme}/lib/pkgconfig"
	else
		export PKG_CONFIG_PATH="${with_gpgme}/lib/pkgconfig:${PKG_CONFIG_PATH}"
	fi
fi

PKG_CHECK_MODULES([gpgme],[gpgme >= 1.13.1],[gpgmepkg=yes],[gpgmepkg=no])

if test ! -z "${with_gpgme}" ; then
	if test ! -z "${PKGCONFIGPATHSAVE}" ; then
		export PKG_CONFIG_PATH="${PKGCONFIGPATHSAVE}"
	fi
fi

if test "${gpgmepkg}" = "yes" ; then
	AC_LANG_PUSH([C++])
	LIBS_SAVE="${LIBS}"
	LIBS="${LIBS} ${gpgme_LIBS}"
	CPPFLAGSSAVE="${CPPFLAGS}"
	CPPFLAGS="${CPPFLAGS} ${gpgme_CFLAGS}"

	AC_MSG_CHECKING([whether we can compile a gpgme program])
	AC_TRY_LINK([#include <gpgme.h>
],[;],[gpgme=yes],[gpgme=no])
	AC_MSG_RESULT([${gpgme}])
	LIBS="${LIBS_SAVE}"
	CPPFLAGS="${CPPFLAGSSAVE}"

	AC_LANG_POP

	if test "$gpgme" = "no" ; then
		AC_MSG_ERROR([Failed to compile gpgme program.]);
	else
		GPGMELDFLAGS=""
		GPGMELIBS="${gpgme_LIBS}"
		GPGMECPPFLAGS="${gpgme_CFLAGS}"
		GPGMEREQ="gpgme"
	fi
else
	AC_MSG_ERROR([gpgme not found in required version])
fi

LIBS_SAVE="${LIBS}"
LIBS="${LIBS} ${gpgme_LIBS}"
CPPFLAGSSAVE="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${gpgme_CFLAGS}"

AC_MSG_CHECKING([whether we can compile a program using gpgme_check_version])
AC_TRY_LINK([#include <gpgme.h>],[gpgme_check_version("1.14.0");],[have_gpgme_check_version=yes],[have_gpgme_check_version=no])
AC_MSG_RESULT([${have_gpgme_check_version}])

if test "${have_gpgme_check_version}" = "no" ; then
	AC_MSG_ERROR([gpgme_check_version function not found in gpgme])
fi

LIBS="${LIBS_SAVE}"
CPPFLAGS="${CPPFLAGSSAVE}"

PACKAGE_NAME=${PACKAGE}
PACKAGE_VERSION=${VERSION}

CPPFLAGS="${CPPFLAGS} ${LIBSECRECYCPPFLAGS}"
CFLAGS="${CFLAGS} ${LIBSECRECYCFLAGS}"
CXXFLAGS="${CXXFLAGS} ${LIBSECRECYCXXFLAGS}"
LIBS="${LIBS} ${LIBSECRECYLIBS}"

AC_SUBST([abs_builddir])
AC_SUBST([PACKAGE_NAME])
AC_SUBST([PACKAGE_VERSION])
AC_SUBST([LIBRARY_VERSION])
AC_SUBST([LIBSECRECYCPPFLAGS])
AC_SUBST([LIBSECRECYCXXFLAGS])
AC_SUBST([LIBSECRECYLDFLAGS])
AC_SUBST([LIBSECRECYLIBS])
AC_SUBST([LIBSECRECYPKGCPPFLAGS])
AC_SUBST([LIBSECRECYPKGCXXFLAGS])
AC_SUBST([LIBSECRECYPKGLIBS])
AC_SUBST([WARNCXXFLAGS])
AC_SUBST([NETTLELIBS])
AC_SUBST([NETTLECPPFLAGS])
AC_SUBST([NETTLELDFLAGS])
AC_SUBST([NETTLEREQ])
AC_SUBST([GPGMELIBS])
AC_SUBST([GPGMECPPFLAGS])
AC_SUBST([GPGMELDFLAGS])
AC_SUBST([GPGMEREQ])
AC_SUBST([TESTDIR])
AC_OUTPUT(Makefile src/Makefile libsecrecy.pc src/libsecrecy/libsecrecy.hpp test/Makefile)