1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ([2.69])
3AC_INIT([openCryptoki],[3.11.0],[opencryptoki-tech@lists.sourceforge.net],[],[https://github.com/opencryptoki/opencryptoki])
4AC_CONFIG_SRCDIR([testcases/common/common.c])
5
6dnl Needed for $target!
7AC_CANONICAL_TARGET
8
9AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
10
11dnl Checks for header files.
12AC_DISABLE_STATIC
13LT_INIT
14
15AC_DEFINE(_BSD_SOURCE, 1, BSD functions)
16AC_DEFINE(__BSD_VISIBLE, 1, BSD extensions)
17
18AC_HEADER_STDC
19AC_CHECK_HEADER_STDBOOL
20AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h malloc.h \
21		  nl_types.h stddef.h sys/file.h sys/socket.h sys/time.h   \
22		  sys/timeb.h syslog.h termios.h])
23
24dnl Checks for typedefs, structures, and compiler characteristics.
25AC_C_INLINE
26AC_C_RESTRICT
27AC_C_CONST
28AC_TYPE_UID_T
29AC_TYPE_PID_T
30AC_TYPE_SIZE_T
31AC_TYPE_MODE_T
32AC_TYPE_INT8_T
33AC_TYPE_INT16_T
34AC_TYPE_INT32_T
35AC_TYPE_UINT8_T
36AC_TYPE_UINT16_T
37AC_TYPE_UINT32_T
38AC_TYPE_UINT64_T
39AC_STRUCT_TM
40
41dnl Checks for library functions.
42AC_FUNC_ALLOCA
43AC_FUNC_CHOWN
44AC_FUNC_FORK
45AC_FUNC_MALLOC
46AC_FUNC_MKTIME
47AC_FUNC_MMAP
48AC_FUNC_REALLOC
49AC_FUNC_STRERROR_R
50AC_CHECK_FUNCS([atexit ftruncate gettimeofday localtime_r memchr memmove \
51		memset mkdir munmap regcomp select socket strchr strcspn \
52		strdup strerror strncasecmp strrchr strstr strtol strtoul])
53
54dnl Used in various scripts
55AC_PATH_PROG([ID], [id], [/us/bin/id])
56AC_PATH_PROG([USERMOD], [usermod], [/usr/sbin/usermod])
57AC_PATH_PROG([GROUPADD], [groupadd], [/usr/sbin/groupadd])
58AC_PATH_PROG([CAT], [cat], [/bin/cat])
59AC_PATH_PROG([CHMOD], [chmod], [/bin/chmod])
60AC_PATH_PROG([CHGRP], [chgrp], [/bin/chgrp])
61AC_PROG_AWK
62AC_PROG_INSTALL
63AC_PROG_LN_S
64AC_PROG_MAKE_SET
65
66AM_PROG_LEX
67if test "x$LEX" != "xflex"; then
68    AC_MSG_ERROR(['flex' is missing on your system. Please install 'flex'.])
69fi
70
71AC_PROG_YACC
72if test "x$YACC" = "xyacc"; then
73    # AC_PROG_YACC only checks for yacc replacements, not for yacc itself
74    AC_CHECK_PROG([YACC_FOUND], [yacc], [yes], [no])
75    if test "x$YACC_FOUND" = "xno"; then
76        AC_MSG_ERROR(['YACC' program is missing on your system. Please install 'bison'.])
77    fi
78fi
79
80AC_CHECK_LIB([itm], [_ITM_commitTransaction], [itm=yes], [itm=no])
81
82OPENLDAP_LIBS=
83if test "x$enable_icsftok" = "xyes"; then
84    AC_CHECK_HEADERS([lber.h ldap.h],
85                [OPENLDAP_LIBS="-llber -lldap"],
86                [AC_MSG_ERROR([lber.h and ldap.h are missing. Please install
87                              'openldap-devel'.])])
88    LIBS="$LIBS $OPENLDAP_LIBS"
89fi
90AC_SUBST([OPENLDAP_LIBS])
91
92dnl Define custom variables
93
94AC_ARG_WITH([lockdir],
95	[AS_HELP_STRING([--with-lockdir],[lock directory])],
96	[lockdir=$withval],
97	[lockdir=$localstatedir/lock/opencryptoki])
98AC_SUBST(lockdir)
99
100AC_ARG_WITH([logdir],
101	[AS_HELP_STRING([--with-logdir],[log directory])],
102	[logdir=$withval],
103	[logdir=$localstatedir/log/opencryptoki])
104logdir=$localstatedir/log/opencryptoki
105AC_SUBST(logdir)
106
107dnl ---
108dnl --- Check all --enable/--disable-features
109dnl ---
110
111dnl --- Debugging support
112AC_ARG_ENABLE([debug],
113	AS_HELP_STRING([--enable-debug],[enable debugging build @<:@default=no@:>@]),
114	[],
115	[enable_debug=no])
116
117dnl --- build testcases
118AC_ARG_ENABLE([testcases],
119	AS_HELP_STRING([--enable-testcases],[build the test cases @<:@default=no@:>@]),
120	[],
121	[enable_testcases=no])
122
123dnl --- Check if building daemon
124AC_ARG_ENABLE([daemon],
125	AS_HELP_STRING([--enable-daemon],[build pkcsslotd daemon @<:@default=yes@:>@]),
126	[],
127	[enable_daemon=yes])
128
129dnl --- Check if building library
130AC_ARG_ENABLE([library],
131	AS_HELP_STRING([--enable-library],[build opencryptoki libraries @<:@default=yes@:>@]),
132	[],
133	[enable_library=yes])
134
135dnl --- Enable/disable tokens
136dnl --- those have an additional 'check' state, which essentially means
137dnl --- that it will enable it by default it dependencies are met
138
139dnl --- ICA token
140AC_ARG_ENABLE([icatok],
141	AS_HELP_STRING([--enable-icatok],[build ica token @<:@default=enabled if
142        libica is present@:>@]),
143	[],
144	[enable_icatok=check])
145
146dnl --- CCA token
147AC_ARG_ENABLE([ccatok],
148	AS_HELP_STRING([--enable-ccatok],[build cca token (IBM Common Cryptographic
149        Architecture) @<:@default=enabled@:>@]),
150	[],
151	[enable_ccatok=yes])
152
153dnl --- software token
154AC_ARG_ENABLE([swtok],
155	AS_HELP_STRING([--enable-swtok],[build software token @<:@default=enabled@:>@]),
156	[],
157	[enable_swtok=yes])
158
159dnl --- EP11 token
160AC_ARG_ENABLE([ep11tok],
161    AS_HELP_STRING([--enable-ep11tok],[build ep11 token @<:@default=enabled
162        if zcrypt is present@:>@]),
163    [],
164    [enable_ep11tok=check])
165
166dnl --- TPM token
167AC_ARG_ENABLE([tpmtok],
168	AS_HELP_STRING([--enable-tpmtok],[build tpm token (Trusted Platform Module)
169        @<:@default=enabled if TrouSerS is present@:>@]),
170	[],
171	[enable_tpmtok=check])
172
173dnl -- icsf token (Integrated Cryptographic Service Facility remote token)
174AC_ARG_ENABLE([icsftok],
175	AS_HELP_STRING([--enable-icsftok],[build icsf token (Integrated
176        Cryptographic Service Facility) @<:@default=enabled if OpenLDAP library
177        is present@:>@]),
178	[],
179	[enable_icsftok=check])
180
181dnl --- token-specific stuff
182dnl --- pkcsep11_migrate
183AC_ARG_ENABLE([pkcsep11_migrate],
184	AS_HELP_STRING([--enable-pkcsep11_migrate],[build pkcsep11_migrate (EP11 token key migration tool) @<:@default=enabled if EP11 library is present@:>@]),
185	[],
186	[enable_pkcsep11_migrate=check])
187
188dnl --- pkcsep11_session
189AC_ARG_ENABLE([pkcsep11_session],
190	AS_HELP_STRING([--enable-pkcsep11_session],[build pkcsep11_session (EP11 token session logout tool) @<:@default=enabled if EP11 library is present@:>@]),
191	[],
192	[enable_pkcsep11_session=check])
193
194dnl --- locking support
195AC_ARG_ENABLE([locks],
196	AS_HELP_STRING([--enable-locks],[build opencryptoki with locks instead of transactional memory @<:@default=disabled@:>@]),
197	[enable_locks=yes],
198	[enable_locks=no])
199
200dnl ---
201dnl --- Check for external software
202dnl --- Define what to check based on enabled features
203
204dnl --- Openssl development files
205AC_ARG_WITH([openssl],
206	AS_HELP_STRING([--with-openssl@<:@=DIR@:>@],[OpenSSL development files location]),
207	[],
208	[with_openssl=check])
209
210dnl --- Libica development files
211AC_ARG_WITH([libica],
212	AS_HELP_STRING([--with-libica@<:@=DIR@:>@],[libica development files location]),
213	[],
214	[with_libica=check])
215
216dnl --- zcrypt development files
217AC_ARG_WITH([zcrypt],
218        AS_HELP_STRING([--with-zcrypt@<:@=DIR@:>@],[zcrypt development files location]),
219        [],
220        [with_zcrypt=check])
221
222dnl --- TSS (TrouSerS) development files
223AC_ARG_WITH([tss],
224	AS_HELP_STRING([--with-tss@<:@=DIR@:>@],[TrouSerS development files location]),
225	[],
226	[with_tss=check])
227
228dnl --- xcryptolinz development files (IBM CCA development files)
229AC_ARG_WITH([xcryptolinz],
230	AS_HELP_STRING([--with-xcryptolinz@<:@=DIR@:>@],[CCA library (xcryptolinz) location]),
231	[],
232	[with_xcryptolinz=check])
233
234dnl --- systemd system unit files location
235AC_ARG_WITH([systemd],
236	AS_HELP_STRING([--with-systemd@<:@=DIR@:>@],[systemd system unit files location]),
237	[],
238	[with_systemd=no])
239
240dnl --- check for pkcs11 user
241AC_ARG_WITH([pkcs11user],
242	AC_HELP_STRING([--with-pkcs11user[[=USER]]], [set pkcs11 user [[pkcs11]]]),
243	[pkcs11_user=$withval],
244	[pkcs11_user=pkcs11])
245dnl --- check for pkcs11 group
246AC_ARG_WITH(pkcs11group,
247	AC_HELP_STRING([--with-pkcs11group[[=GROUP]]], [set pkcs11 group [[pkcs11]]]),
248	[pkcs11_group=$withval],
249	[pkcs11_group=pkcs11])
250AC_SUBST(PKCS11USER, $pkcs11_user)
251AC_SUBST(PKCS11GROUP, $pkcs11_group)
252
253dnl ---
254dnl ---
255dnl --- Now that we have all the options, let's check for a valid build
256dnl ---
257
258case $target in
259     *s390x*)
260          ;;
261     *s390*)
262          CFLAGS="$CFLAGS -m31"
263          ;;
264     *ppc64* | *x86_64*)
265	  ;;
266     *ppc* | i*86*)
267	  CFLAGS="$CFLAGS -m32"
268	  ;;
269esac
270
271dnl --- enable_debug
272if test "x$enable_debug" = "xyes"; then
273	CFLAGS="$CFLAGS -gdwarf-2 -g3 -O0 -DDEBUG"
274fi
275
276dnl --- first, check what external software is present or specified
277dnl --- with --with-package=DIR
278
279dnl --- with_openssl
280OPENSSL_CFLAGS=
281OPENSSL_LIBS=
282if test "x$with_openssl" != "xno"; then
283	if test "x$with_openssl" != "xyes" -a "x$with_openssl" != "xcheck"; then
284		OPENSSL_CFLAGS="-I$with_openssl"
285		OPENSSL_LIBS="-L$with_openssl"
286	fi
287	old_cflags="$CFLAGS"
288	old_libs="$LIBS"
289	CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
290	LIBS="$LIBS $OPENSSL_LIBS"
291	AC_CHECK_HEADER([openssl/ssl.h], [], [
292		if test "x$with_openssl" != "xcheck"; then
293			AC_MSG_ERROR([Build with OpenSSL requested but OpenSSL headers couldn't be found])
294		fi
295		with_openssl=no
296	])
297	if test "x$with_openssl" != "xno"; then
298		AC_CHECK_LIB([crypto], [RSA_generate_key], [
299			OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto"
300			with_openssl=yes
301			], [
302				if test "x$with_openssl" != "xcheck"; then
303					AC_MSG_ERROR([Build with OpenSSL requested but OpenSSL libraries couldn't be found])
304				fi
305				with_openssl=no
306		])
307	fi
308	if test "x$with_openssl" = "xno"; then
309		CFLAGS="$old_cflags"
310		LIBS="$old_libs"
311	fi
312fi
313AC_SUBST([OPENSSL_CFLAGS])
314AC_SUBST([OPENSSL_LIBS])
315
316dnl --- with_libica
317LIBICA_CFLAGS=
318LIBICA_LIBS=
319if test "x$with_libica" != "xno"; then
320	if test "x$with_libica" != "xyes" -a "x$with_libica" != "xcheck"; then
321		LIBICA_CFLAGS="-I$with_libica"
322		LIBICA_LIBS="-L$with_libica"
323	fi
324	old_cflags="$CFLAGS"
325	old_libs="$LIBS"
326	CFLAGS="$CFLAGS $LIBICA_CFLAGS"
327	LIBS="$LIBS $LIBICA_LIBS"
328	AC_CHECK_HEADER([ica_api.h], [], [
329		if test "x$with_libica" != "xcheck"; then
330			AC_MSG_ERROR([Build with Libica requested but Libica headers couldn't be found])
331		fi
332		with_libica=no
333	])
334	if test "x$with_libica" != "xno"; then
335		AC_CHECK_LIB([ica], [ica_open_adapter],
336			[with_libica=yes], [
337				if test "x$with_libica" != "xcheck"; then
338					AC_MSG_ERROR([Build with Libica requested but Libica libraries (v 2.x or higher) couldn't be found])
339				fi
340				with_libica=no
341		])
342	fi
343	if test "x$with_libica" = "xno"; then
344		CFLAGS="$old_cflags"
345		LIBS="$old_libs"
346	fi
347fi
348AC_SUBST([LIBICA_CFLAGS])
349AC_SUBST([LIBICA_LIBS])
350
351
352dnl --- with_zcrypt
353ZCRYPT_CFLAGS=
354ZCRYPT_LIBS=
355if test "x$with_zcrypt" != "xno"; then
356	if test "x$with_zcrypt" != "xyes" -a "x$with_zcrypt" != "xcheck"; then
357		ZCRYPT_CFLAGS="-I$with_zcrypt"
358		ZCRYPT_LIBS="-L$with_zcrypt"
359	fi
360	old_cflags="$CFLAGS"
361	old_libs="$LIBS"
362	CFLAGS="$CFLAGS $ZCRYPT_CFLAGS"
363	LIBS="$LIBS $ZCRYPT_LIBS"
364	AC_CHECK_HEADER([asm/zcrypt.h], [], [
365		if test "x$with_zcrypt" != "xcheck"; then
366			AC_MSG_ERROR([Build with zcrypt requested but zcrypt headers couldn't be found])
367		fi
368		with_zcrypt=no
369	])
370
371	if test "x$with_zcrypt" != "xno"; then
372		with_zcrypt=yes
373	fi
374
375	if test "x$with_zcrypt" = "xno"; then
376		CFLAGS="$old_cflags"
377		LIBS="$old_libs"
378	fi
379
380fi
381AC_SUBST([ZCRYPT_CFLAGS])
382AC_SUBST([ZCRYPT_LIBS])
383
384
385dnl --- with_tss
386TSS_CFLAGS=
387TSS_LIBS=
388if test "x$with_tss" != "xno"; then
389	if test "x$with_tss" != "xyes" -a "x$with_tss" != "xcheck"; then
390		TSS_CFLAGS="-I$with_tss"
391		TSS_LIBS="-L$with_tss"
392	fi
393	old_cflags="$CFLAGS"
394	old_libs="$LIBS"
395	CFLAGS="$CFLAGS $TSS_CFLAGS"
396	LIBS="$LIBS $TSS_LIBS"
397	AC_CHECK_HEADER([tss/platform.h], [], [
398		if test "x$with_tss" != "xcheck"; then
399			AC_MSG_ERROR([Build with TSS requested but TSS headers couldn't be found])
400		fi
401		with_tss=no
402	])
403	if test "x$with_tss" != "xno"; then
404		AC_CHECK_LIB([tspi], [Tspi_Context_Create],
405			[with_tss=yes], [
406				if test "x$with_tss" != "xcheck"; then
407					AC_MSG_ERROR([Build with TSS requested but TSS libraries couldn't be found])
408				fi
409				with_tss=no
410		])
411	fi
412	if test "x$with_tss" = "xno"; then
413		CFLAGS="$old_cflags"
414		LIBS="$old_libs"
415	fi
416fi
417AC_SUBST([TSS_CFLAGS])
418AC_SUBST([TSS_LIBS])
419
420dnl --- with_xcryptolinz
421XCRYPTOLINZ_CFLAGS=
422XCRYPTOLINZ_LIBS=
423if test "x$with_xcryptolinz" != "xno"; then
424	if test "x$with_xcryptolinz" != "xyes" -a "x$with_xcryptolinz" != "xcheck"; then
425		XCRYPTOLINZ_CFLAGS="-I$with_xcryptolinz"
426		XCRYPTOLINZ_LIBS="-L$with_xcryptolinz"
427	fi
428	old_cflags="$CFLAGS"
429	old_libs="$LIBS"
430	CFLAGS="$CFLAGS $XCRYPTOLINZ_CFLAGS"
431	LIBS="$LIBS $XCRYPTOLINZ_LIBS"
432dnl - The above may not be necessary since opencryptoki brings this header file anyway.
433	AC_CHECK_HEADER([csulincl.h], [], [
434		if test "x$with_xcryptolinz" != "xcheck"; then
435			AC_MSG_ERROR([Build with xcryptolinz requested but xcryptolinz headers couldn't be found])
436		fi
437		with_xcryptolinz=no
438	])
439	if test "x$with_xcryptolinz" != "xno"; then
440		AC_CHECK_LIB([csulcca], [CSNBKTC],
441			[with_xcryptolinz=yes], [
442				if test "x$with_xcryptolinz" != "xcheck"; then
443					AC_MSG_ERROR([Build with xcryptolinz requested but xcryptolinz libraries couldn't be found])
444				fi
445				with_xcryptolinz=no
446		])
447	fi
448	if test "x$with_xcryptolinz" = "xno"; then
449		CFLAGS="$old_cflags"
450		LIBS="$old_libs"
451	fi
452fi
453AC_SUBST([XCRYPTOLINZ_CFLAGS])
454AC_SUBST([XCRYPTOLINZ_LIBS])
455
456
457dnl ---
458dnl --- Now check enabled features, while making sure every required
459dnl --- package is available
460dnl ---
461
462dnl --- enable_testcases
463if test "x$enable_testcases" = "xyes"; then
464	AC_CHECK_PROG([HAVE_EXPECT], [expect], [yes], [no])
465
466	if test "x$HAVE_EXPECT" = "xno"; then
467		AC_MSG_ERROR([*** testcases requires 'expect' interpreter, which wasn't found])
468                enable_testcases=no
469	fi
470fi
471AM_CONDITIONAL([ENABLE_TESTCASES], [test "x$enable_testcases" = "xyes"])
472
473dnl --- enable_daemon
474AM_CONDITIONAL([ENABLE_DAEMON], [test "x$enable_daemon" = "xyes"])
475
476dnl --- enable_library
477AM_CONDITIONAL([ENABLE_LIBRARY], [test "x$enable_library" = "xyes"])
478
479dnl --- enable systemd and set unit dir
480if test "x$with_systemd" != "xno"; then
481	if test "x$with_systemd" != "xyes" -a "x$with_systemd" != "xcheck"; then
482		unitdir=$with_systemd
483		enable_systemd=yes
484	else
485		if test "x$with_systemd" = "xyes"; then
486			unitdir=${ac_default_prefix}/lib/systemd/system
487			enable_systemd=yes
488		else
489			enable_systemd=no
490		fi
491	fi
492else
493	enable_systemd=no
494fi
495AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x$enable_systemd" = "xyes"])
496AC_SUBST(unitdir)
497
498dnl --- enable_icatok
499if test "x$enable_icatok" = "xyes"; then
500	if test "x$with_libica" != "xyes"; then
501		AC_MSG_ERROR([ica token build requested but libica development files not found])
502		enable_icatok=no
503	fi
504
505	if test "x$with_openssl" != "xyes"; then
506		AC_MSG_ERROR([ica token build requested but OpenSSL development files not found])
507		enable_icatok=no
508	fi
509fi
510if test "x$enable_icatok" != "xno" -a "x$with_libica" != "xno" -a "x$with_openssl" != "xno"; then
511	enable_icatok=yes
512else
513	enable_icatok=no
514fi
515AM_CONDITIONAL([ENABLE_ICATOK], [test "x$enable_icatok" = "xyes"])
516
517dnl --- enable_ccatok
518AM_CONDITIONAL([ENABLE_CCATOK], [test "x$enable_ccatok" = "xyes"])
519
520dnl --- enable_swtok
521if test "x$enable_swtok" = "xyes"; then
522	if test "x$with_openssl" != "xyes"; then
523		AC_MSG_ERROR([software token build requested but OpenSSL development files not found])
524		enable_swtok=no
525	fi
526fi
527if test "x$enable_swtok" != "xno" -a "x$with_openssl" != "xno"; then
528	enable_swtok=yes
529else
530	enable_swtok=no
531fi
532AM_CONDITIONAL([ENABLE_SWTOK], [test "x$enable_swtok" = "xyes"])
533
534dnl --- enable_ep11tok
535if test "x$enable_ep11tok" = "xyes"; then
536	if test "x$with_zcrypt" != "xyes"; then
537		AC_MSG_ERROR([ep11 token build requested but ep11 development files not found])
538		enable_ep11=no
539	fi
540	AC_CHECK_HEADER([ica_api.h], [], [
541		AC_MSG_ERROR([ep11 token build requested but Libica headers couldn't be found])
542	])
543fi
544if test "x$enable_ep11tok" != "xno" -a "x$with_zcrypt" != "xno"; then
545        enable_ep11tok=yes
546else
547        enable_ep11tok=no
548fi
549AM_CONDITIONAL([ENABLE_EP11TOK], [test "x$enable_ep11tok" = "xyes"])
550
551dnl --- enable_icsftok
552if test "x$enable_icsftok" = "xyes"; then
553	if test "x$with_openssl" != "xyes"; then
554		AC_MSG_ERROR([ICSF token build requested but OpenSSL development files not found])
555		enable_icsftok=no
556	fi
557fi
558if test "x$enable_icsftok" != "xno" -a "x$with_openssl" != "xno"; then
559	enable_icsftok=yes
560else
561	enable_icsftok=no
562fi
563AM_CONDITIONAL([ENABLE_ICSFTOK], [test "x$enable_icsftok" = "xyes"])
564
565dnl --- enable_tpmtok
566if test "x$enable_tpmtok" = "xyes"; then
567	if test "x$with_tss" != "xyes"; then
568		AC_MSG_ERROR([tpm token build requested but TSS development files not found])
569		enable_tpmtok=no
570	fi
571fi
572if test "x$enable_tpmtok" != "xno" -a "x$with_tss" != "xno"; then
573	enable_tpmtok=yes
574else
575	enable_tpmtok=no
576fi
577AM_CONDITIONAL([ENABLE_TPMTOK], [test "x$enable_tpmtok" = "xyes"])
578
579
580dnl --- enable_pkcsep11_migrate
581if test "x$enable_pkcsep11_migrate" = "xyes"; then
582	if test "x$with_zcrypt" != "xyes"; then
583		AC_MSG_ERROR([pkcsep11_migrate build requested but no ep11 libraries found])
584		enable_pkcsep11_migrate=no
585	fi
586fi
587if test "x$enable_pkcsep11_migrate" != "xno" -a "x$with_zcrypt" != "xno"; then
588        enable_pkcsep11_migrate=yes
589else
590        enable_pkcsep11_migrate=no
591fi
592AM_CONDITIONAL([ENABLE_PKCSEP11_MIGRATE], [test "x$enable_pkcsep11_migrate" = "xyes"])
593
594dnl --- enable_pkcsep11_session
595if test "x$enable_pkcsep11_session" = "xyes"; then
596	if test "x$with_zcrypt" != "xyes"; then
597		AC_MSG_ERROR([pkcsep11_session build requested but no ep11 libraries found])
598		enable_pkcsep11_session=no
599	fi
600fi
601
602if test "x$enable_pkcsep11_session" != "xno" -a "x$with_zcrypt" != "xno"; then
603        enable_pkcsep11_session=yes
604else
605        enable_pkcsep11_session=no
606fi
607
608AM_CONDITIONAL([ENABLE_PKCSEP11_SESSION], [test "x$enable_pkcsep11_session" = "xyes"])
609
610dnl --- enable_locks
611if test "x$enable_locks" = "xno"; then
612	if test "x$itm" != "xyes"; then
613		AC_MSG_ERROR([in order to build opencryptoki with transactional memory,
614libitm and gcc>=4.7 is required])
615    fi
616fi
617if test "x$enable_locks" != "xno"; then
618        enable_locks=yes
619        CFLAGS="$CFLAGS -DENABLE_LOCKS"
620else
621        enable_locks=no
622        CFLAGS="$CFLAGS -fgnu-tm"
623fi
624AM_CONDITIONAL([ENABLE_LOCKS], [test "x$enable_locks" = "xyes"])
625
626CFLAGS="$CFLAGS \
627 -Wall \
628 -Wextra \
629 -Wno-pointer-sign \
630"
631CPPFX=' \
632 -DCONFIG_PATH=\"$(localstatedir)/lib/opencryptoki\" \
633 -DSBIN_PATH=\"$(sbindir)\" \
634 -DLIB_PATH=\"$(libdir)\" \
635 -DLOCKDIR_PATH=\"$(lockdir)\" \
636 -DOCK_CONFDIR=\"$(sysconfdir)/opencryptoki\" \
637 -DOCK_LOGDIR=\"$(logdir)\" \
638'
639CPPFLAGS="$CPPFLAGS \
640 -DPKCS64 \
641 -D_XOPEN_SOURCE=600 \
642 $CPPFX \
643 -DPKCS11USER=\\\"${pkcs11_user}\\\" \
644 -DPKCS11GROUP=\\\"${pkcs11_group}\\\" \
645"
646
647# At this point, CFLAGS is set to something sensible
648AC_PROG_CC
649
650AC_SUBST(FPIC, $lt_prog_compiler_pic)
651
652AC_CONFIG_MACRO_DIRS([m4])
653
654AC_CONFIG_FILES([Makefile				\
655		 usr/lib/api/shrd_mem.c			\
656		 man/man1/pkcsconf.1			\
657		 man/man1/pkcsicsf.1			\
658		 man/man1/pkcscca.1			\
659		 man/man1/pkcsep11_migrate.1		\
660		 man/man1/pkcsep11_session.1		\
661		 man/man5/opencryptoki.conf.5		\
662		 man/man7/opencryptoki.7		\
663		 man/man8/pkcsslotd.8])
664
665AC_OUTPUT
666
667echo "Enabled features:"
668echo "	Debug build:		$enable_debug"
669echo "	Testcases:		$enable_testcases"
670echo "	Daemon build:		$enable_daemon"
671echo "	Library build:		$enable_library"
672echo "	Systemd service:	$enable_systemd"
673echo
674echo "Enabled token types:"
675echo "	ICA token:		$enable_icatok"
676echo "	CCA token:		$enable_ccatok"
677echo "	Software token:		$enable_swtok"
678echo "	EP11 token:		$enable_ep11tok"
679echo "	TPM token:		$enable_tpmtok"
680echo "	ICSF token:		$enable_icsftok"
681echo
682echo "Token-specific features:"
683echo "	pkcsep11migrate build:	$enable_pkcsep11_migrate"
684echo "	pkcsep11session build:	$enable_pkcsep11_session"
685echo
686echo "CFLAGS=$CFLAGS"
687echo
688