Blame configure.ac

Packit 8681c6
dnl Process this file with autoconf to produce a configure script.
Packit 8681c6
AC_PREREQ([2.69])
Packit 8681c6
AC_INIT([openCryptoki],[3.14.0],[opencryptoki-tech@lists.sourceforge.net],[],[https://github.com/opencryptoki/opencryptoki])
Packit 8681c6
AC_CONFIG_SRCDIR([testcases/common/common.c])
Packit 8681c6
Packit 8681c6
dnl Needed for $target!
Packit 8681c6
AC_CANONICAL_TARGET
Packit 8681c6
Packit 8681c6
AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
Packit 8681c6
Packit 8681c6
dnl Checks for header files.
Packit 8681c6
AC_DISABLE_STATIC
Packit 8681c6
LT_INIT
Packit 8681c6
Packit 8681c6
AC_HEADER_STDC
Packit 8681c6
AC_CHECK_HEADER_STDBOOL
Packit 8681c6
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h malloc.h \
Packit 8681c6
		  nl_types.h stddef.h sys/file.h sys/socket.h sys/time.h   \
Packit 8681c6
		  sys/timeb.h syslog.h termios.h])
Packit 8681c6
Packit 8681c6
dnl Checks for typedefs, structures, and compiler characteristics.
Packit 8681c6
AC_C_INLINE
Packit 8681c6
AC_C_RESTRICT
Packit 8681c6
AC_C_CONST
Packit 8681c6
AC_TYPE_UID_T
Packit 8681c6
AC_TYPE_PID_T
Packit 8681c6
AC_TYPE_SIZE_T
Packit 8681c6
AC_TYPE_MODE_T
Packit 8681c6
AC_TYPE_INT8_T
Packit 8681c6
AC_TYPE_INT16_T
Packit 8681c6
AC_TYPE_INT32_T
Packit 8681c6
AC_TYPE_UINT8_T
Packit 8681c6
AC_TYPE_UINT16_T
Packit 8681c6
AC_TYPE_UINT32_T
Packit 8681c6
AC_TYPE_UINT64_T
Packit 8681c6
AC_STRUCT_TM
Packit 8681c6
Packit 8681c6
dnl Checks for library functions.
Packit 8681c6
AC_FUNC_ALLOCA
Packit 8681c6
AC_FUNC_CHOWN
Packit 8681c6
AC_FUNC_FORK
Packit 8681c6
AC_FUNC_MALLOC
Packit 8681c6
AC_FUNC_MKTIME
Packit 8681c6
AC_FUNC_MMAP
Packit 8681c6
AC_FUNC_REALLOC
Packit 8681c6
AC_FUNC_STRERROR_R
Packit 8681c6
AC_CHECK_FUNCS([atexit ftruncate gettimeofday localtime_r memchr memmove \
Packit 8681c6
		memset mkdir munmap regcomp select socket strchr strcspn \
Packit 8681c6
		strdup strerror strncasecmp strrchr strstr strtol strtoul])
Packit 8681c6
Packit 8681c6
dnl Used in various scripts
Packit 8681c6
AC_PATH_PROG([ID], [id], [/us/bin/id])
Packit 8681c6
AC_PATH_PROG([USERMOD], [usermod], [/usr/sbin/usermod])
Packit 8681c6
AC_PATH_PROG([GROUPADD], [groupadd], [/usr/sbin/groupadd])
Packit 8681c6
AC_PATH_PROG([CAT], [cat], [/bin/cat])
Packit 8681c6
AC_PATH_PROG([CHMOD], [chmod], [/bin/chmod])
Packit 8681c6
AC_PATH_PROG([CHGRP], [chgrp], [/bin/chgrp])
Packit 8681c6
AC_PROG_AWK
Packit 8681c6
AC_PROG_INSTALL
Packit 8681c6
AC_PROG_LN_S
Packit 8681c6
AC_PROG_MAKE_SET
Packit 8681c6
Packit 8681c6
AM_PROG_LEX
Packit 8681c6
if test "x$LEX" != "xflex"; then
Packit 8681c6
    AC_MSG_ERROR(['flex' is missing on your system. Please install 'flex'.])
Packit 8681c6
fi
Packit 8681c6
Packit 8681c6
AC_PROG_YACC
Packit 8681c6
if test "x$YACC" = "xyacc"; then
Packit 8681c6
    # AC_PROG_YACC only checks for yacc replacements, not for yacc itself
Packit 8681c6
    AC_CHECK_PROG([YACC_FOUND], [yacc], [yes], [no])
Packit 8681c6
    if test "x$YACC_FOUND" = "xno"; then
Packit 8681c6
	AC_MSG_ERROR(['YACC' program is missing on your system. Please install 'bison'.])
Packit 8681c6
    fi
Packit 8681c6
fi
Packit 8681c6
Packit 8681c6
AC_CHECK_LIB([itm], [_ITM_commitTransaction], [itm=yes], [itm=no])
Packit 8681c6
Packit 8681c6
OPENLDAP_LIBS=
Packit 8681c6
AC_CHECK_HEADERS([lber.h ldap.h],
Packit 8681c6
		[OPENLDAP_LIBS="-llber -lldap"],
Packit 8681c6
		[AC_MSG_ERROR([lber.h and ldap.h are missing. Please install
Packit 8681c6
			      'openldap-devel'.])])
Packit 8681c6
LIBS="$LIBS $OPENLDAP_LIBS"
Packit 8681c6
AC_SUBST([OPENLDAP_LIBS])
Packit 8681c6
Packit 8681c6
dnl Define custom variables
Packit 8681c6
Packit 88445f
lockdir=/run/lock/opencryptoki
Packit 8681c6
AC_SUBST(lockdir)
Packit 8681c6
Packit 8681c6
logdir=$localstatedir/log/opencryptoki
Packit 8681c6
AC_SUBST(logdir)
Packit 8681c6
Packit 8681c6
dnl ---
Packit 8681c6
dnl --- Check all --enable/--disable-features
Packit 8681c6
dnl ---
Packit 8681c6
Packit 8681c6
dnl --- Debugging support
Packit 8681c6
AC_ARG_ENABLE([debug],
Packit 8681c6
	AS_HELP_STRING([--enable-debug],[enable debugging build @<:@default=no@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_debug=no])
Packit 8681c6
Packit 8681c6
dnl --- build testcases
Packit 8681c6
AC_ARG_ENABLE([testcases],
Packit 8681c6
	AS_HELP_STRING([--enable-testcases],[build the test cases @<:@default=no@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_testcases=no])
Packit 8681c6
Packit 8681c6
dnl --- Check if building daemon
Packit 8681c6
AC_ARG_ENABLE([daemon],
Packit 8681c6
	AS_HELP_STRING([--enable-daemon],[build pkcsslotd daemon @<:@default=yes@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_daemon=yes])
Packit 8681c6
Packit 8681c6
dnl --- Check if building library
Packit 8681c6
AC_ARG_ENABLE([library],
Packit 8681c6
	AS_HELP_STRING([--enable-library],[build opencryptoki libraries @<:@default=yes@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_library=yes])
Packit 8681c6
Packit 8681c6
dnl --- Enable/disable tokens
Packit 8681c6
dnl --- those have an additional 'check' state, which essentially means
Packit 8681c6
dnl --- that it will enable it by default it dependencies are met
Packit 8681c6
Packit 8681c6
dnl --- ICA token
Packit 8681c6
AC_ARG_ENABLE([icatok],
Packit 8681c6
	AS_HELP_STRING([--enable-icatok],[build ica token @<:@default=enabled if
Packit 8681c6
	libica is present@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_icatok=check])
Packit 8681c6
Packit 8681c6
dnl --- CCA token
Packit 8681c6
AC_ARG_ENABLE([ccatok],
Packit 8681c6
	AS_HELP_STRING([--enable-ccatok],[build cca token (IBM Common Cryptographic
Packit 8681c6
	Architecture) @<:@default=enabled@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_ccatok=yes])
Packit 8681c6
Packit 8681c6
dnl --- software token
Packit 8681c6
AC_ARG_ENABLE([swtok],
Packit 8681c6
	AS_HELP_STRING([--enable-swtok],[build software token @<:@default=enabled@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_swtok=yes])
Packit 8681c6
Packit 8681c6
dnl --- EP11 token
Packit 8681c6
AC_ARG_ENABLE([ep11tok],
Packit 8681c6
    AS_HELP_STRING([--enable-ep11tok],[build ep11 token @<:@default=enabled
Packit 8681c6
	if zcrypt is present@:>@]),
Packit 8681c6
    [],
Packit 8681c6
    [enable_ep11tok=check])
Packit 8681c6
Packit 8681c6
dnl --- TPM token
Packit 8681c6
AC_ARG_ENABLE([tpmtok],
Packit 8681c6
	AS_HELP_STRING([--enable-tpmtok],[build tpm token (Trusted Platform Module)
Packit 8681c6
	@<:@default=enabled if TrouSerS is present@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_tpmtok=check])
Packit 8681c6
Packit 8681c6
dnl -- icsf token (Integrated Cryptographic Service Facility remote token)
Packit 8681c6
AC_ARG_ENABLE([icsftok],
Packit 8681c6
	AS_HELP_STRING([--enable-icsftok],[build icsf token (Integrated
Packit 8681c6
	Cryptographic Service Facility) @<:@default=enabled if OpenLDAP library
Packit 8681c6
	is present@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_icsftok=check])
Packit 8681c6
Packit 8681c6
dnl --- token-specific stuff
Packit 8681c6
dnl --- pkcsep11_migrate
Packit 8681c6
AC_ARG_ENABLE([pkcsep11_migrate],
Packit 8681c6
	AS_HELP_STRING([--enable-pkcsep11_migrate],[build pkcsep11_migrate (EP11 token key migration tool) @<:@default=enabled if EP11 library is present@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_pkcsep11_migrate=check])
Packit 8681c6
Packit 8681c6
dnl --- pkcsep11_session
Packit 8681c6
AC_ARG_ENABLE([pkcsep11_session],
Packit 8681c6
	AS_HELP_STRING([--enable-pkcsep11_session],[build pkcsep11_session (EP11 token session logout tool) @<:@default=enabled if EP11 library is present@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_pkcsep11_session=check])
Packit 8681c6
Packit 8681c6
dnl --- locking support
Packit 8681c6
AC_ARG_ENABLE([locks],
Packit 8681c6
	AS_HELP_STRING([--disable-locks],[build opencryptoki with transactional memory instead of locks]))
Packit 8681c6
Packit 8681c6
dnl --- p11sak tool
Packit 8681c6
AC_ARG_ENABLE([p11sak],
Packit 8681c6
	AS_HELP_STRING([--enable-p11sak],[build p11sak tool @<:@default=enabled@:>@]),
Packit 8681c6
	[],
Packit 8681c6
	[enable_p11sak=yes])
Packit 8681c6
Packit 8681c6
dnl ---
Packit 8681c6
dnl --- Check for external software
Packit 8681c6
dnl --- Define what to check based on enabled features
Packit 8681c6
Packit 8681c6
dnl --- Openssl development files
Packit 8681c6
AC_ARG_WITH([openssl],
Packit 8681c6
	AS_HELP_STRING([--with-openssl@<:@=DIR@:>@],[OpenSSL development files location]),
Packit 8681c6
	[],
Packit 8681c6
	[with_openssl=check])
Packit 8681c6
Packit 8681c6
dnl --- Libica development files
Packit 8681c6
AC_ARG_WITH([libica],
Packit 8681c6
	AS_HELP_STRING([--with-libica@<:@=DIR@:>@],[libica development files location]),
Packit 8681c6
	[],
Packit 8681c6
	[with_libica=check])
Packit 8681c6
Packit 8681c6
dnl --- zcrypt development files
Packit 8681c6
AC_ARG_WITH([zcrypt],
Packit 8681c6
	AS_HELP_STRING([--with-zcrypt@<:@=DIR@:>@],[zcrypt development files location]),
Packit 8681c6
	[],
Packit 8681c6
	[with_zcrypt=check])
Packit 8681c6
Packit 8681c6
dnl --- TSS (TrouSerS) development files
Packit 8681c6
AC_ARG_WITH([tss],
Packit 8681c6
	AS_HELP_STRING([--with-tss@<:@=DIR@:>@],[TrouSerS development files location]),
Packit 8681c6
	[],
Packit 8681c6
	[with_tss=check])
Packit 8681c6
Packit 8681c6
dnl --- xcryptolinz development files (IBM CCA development files)
Packit 8681c6
AC_ARG_WITH([xcryptolinz],
Packit 8681c6
	AS_HELP_STRING([--with-xcryptolinz@<:@=DIR@:>@],[CCA library (xcryptolinz) location]),
Packit 8681c6
	[],
Packit 8681c6
	[with_xcryptolinz=check])
Packit 8681c6
Packit 8681c6
dnl --- systemd system unit files location
Packit 8681c6
AC_ARG_WITH([systemd],
Packit 8681c6
	AS_HELP_STRING([--with-systemd@<:@=DIR@:>@],[systemd system unit files location]),
Packit 8681c6
	[],
Packit 8681c6
	[with_systemd=no])
Packit 8681c6
Packit 8681c6
dnl ---
Packit 8681c6
dnl ---
Packit 8681c6
dnl --- Now that we have all the options, let's check for a valid build
Packit 8681c6
dnl ---
Packit 8681c6
Packit 8681c6
case $target in
Packit 8681c6
     *s390x*)
Packit 8681c6
	  ;;
Packit 8681c6
     *s390*)
Packit 8681c6
	  CFLAGS="$CFLAGS -m31"
Packit 8681c6
	  ;;
Packit 8681c6
     *ppc64* | *x86_64*)
Packit 8681c6
	  ;;
Packit 8681c6
     *ppc* | i*86*)
Packit 8681c6
	  CFLAGS="$CFLAGS -m32"
Packit 8681c6
	  ;;
Packit 8681c6
esac
Packit 8681c6
Packit 8681c6
dnl --- enable_debug
Packit 8681c6
if test "x$enable_debug" = "xyes"; then
Packit 8681c6
	CFLAGS="$CFLAGS -gdwarf-2 -g3 -O0 -DDEBUG"
Packit 8681c6
fi
Packit 8681c6
Packit 8681c6
dnl --- first, check what external software is present or specified
Packit 8681c6
dnl --- with --with-package=DIR
Packit 8681c6
Packit 8681c6
dnl --- with_openssl
Packit 8681c6
OPENSSL_CFLAGS=
Packit 8681c6
OPENSSL_LIBS=
Packit 8681c6
if test "x$with_openssl" != "xno"; then
Packit 8681c6
	if test "x$with_openssl" != "xyes" -a "x$with_openssl" != "xcheck"; then
Packit 8681c6
		OPENSSL_CFLAGS="-I$with_openssl"
Packit 8681c6
		OPENSSL_LIBS="-L$with_openssl"
Packit 8681c6
	fi
Packit 8681c6
	old_cflags="$CFLAGS"
Packit 8681c6
	old_libs="$LIBS"
Packit 8681c6
	CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
Packit 8681c6
	LIBS="$LIBS $OPENSSL_LIBS"
Packit 8681c6
	AC_CHECK_HEADER([openssl/ssl.h], [], [
Packit 8681c6
		if test "x$with_openssl" != "xcheck"; then
Packit 8681c6
			AC_MSG_ERROR([Build with OpenSSL requested but OpenSSL headers couldn't be found])
Packit 8681c6
		fi
Packit 8681c6
		with_openssl=no
Packit 8681c6
	])
Packit 8681c6
	if test "x$with_openssl" != "xno"; then
Packit 8681c6
		AC_CHECK_LIB([crypto], [RSA_generate_key], [
Packit 8681c6
			OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto"
Packit 8681c6
			with_openssl=yes
Packit 8681c6
			], [
Packit 8681c6
				if test "x$with_openssl" != "xcheck"; then
Packit 8681c6
					AC_MSG_ERROR([Build with OpenSSL requested but OpenSSL libraries couldn't be found])
Packit 8681c6
				fi
Packit 8681c6
				with_openssl=no
Packit 8681c6
		])
Packit 8681c6
	fi
Packit 8681c6
	if test "x$with_openssl" = "xno"; then
Packit 8681c6
		CFLAGS="$old_cflags"
Packit 8681c6
		LIBS="$old_libs"
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
AC_SUBST([OPENSSL_CFLAGS])
Packit 8681c6
AC_SUBST([OPENSSL_LIBS])
Packit 8681c6
Packit 8681c6
dnl --- with_libica
Packit 8681c6
LIBICA_CFLAGS=
Packit 8681c6
LIBICA_LIBS=
Packit 8681c6
if test "x$with_libica" != "xno"; then
Packit 8681c6
	if test "x$with_libica" != "xyes" -a "x$with_libica" != "xcheck"; then
Packit 8681c6
		LIBICA_CFLAGS="-I$with_libica"
Packit 8681c6
		LIBICA_LIBS="-L$with_libica"
Packit 8681c6
	fi
Packit 8681c6
	old_cflags="$CFLAGS"
Packit 8681c6
	old_libs="$LIBS"
Packit 8681c6
	CFLAGS="$CFLAGS $LIBICA_CFLAGS"
Packit 8681c6
	LIBS="$LIBS $LIBICA_LIBS"
Packit 8681c6
	AC_CHECK_HEADER([ica_api.h], [], [
Packit 8681c6
		if test "x$with_libica" != "xcheck"; then
Packit 8681c6
			AC_MSG_ERROR([Build with Libica requested but Libica headers couldn't be found])
Packit 8681c6
		fi
Packit 8681c6
		with_libica=no
Packit 8681c6
	])
Packit 8681c6
	if test "x$with_libica" != "xno"; then
Packit 8681c6
		AC_CHECK_LIB([ica], [ica_open_adapter],
Packit 8681c6
			[with_libica=yes], [
Packit 8681c6
				if test "x$with_libica" != "xcheck"; then
Packit 8681c6
					AC_MSG_ERROR([Build with Libica requested but Libica libraries (v 2.x or higher) couldn't be found])
Packit 8681c6
				fi
Packit 8681c6
				with_libica=no
Packit 8681c6
		])
Packit 8681c6
	fi
Packit 8681c6
	if test "x$with_libica" = "xno"; then
Packit 8681c6
		CFLAGS="$old_cflags"
Packit 8681c6
		LIBS="$old_libs"
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
AC_SUBST([LIBICA_CFLAGS])
Packit 8681c6
AC_SUBST([LIBICA_LIBS])
Packit 8681c6
Packit 8681c6
Packit 8681c6
dnl --- with_zcrypt
Packit 8681c6
ZCRYPT_CFLAGS=
Packit 8681c6
ZCRYPT_LIBS=
Packit 8681c6
if test "x$with_zcrypt" != "xno"; then
Packit 8681c6
	if test "x$with_zcrypt" != "xyes" -a "x$with_zcrypt" != "xcheck"; then
Packit 8681c6
		ZCRYPT_CFLAGS="-I$with_zcrypt"
Packit 8681c6
		ZCRYPT_LIBS="-L$with_zcrypt"
Packit 8681c6
	fi
Packit 8681c6
	old_cflags="$CFLAGS"
Packit 8681c6
	old_libs="$LIBS"
Packit 8681c6
	CFLAGS="$CFLAGS $ZCRYPT_CFLAGS"
Packit 8681c6
	LIBS="$LIBS $ZCRYPT_LIBS"
Packit 8681c6
	AC_CHECK_HEADER([asm/zcrypt.h], [], [
Packit 8681c6
		if test "x$with_zcrypt" != "xcheck"; then
Packit 8681c6
			AC_MSG_ERROR([Build with zcrypt requested but zcrypt headers couldn't be found])
Packit 8681c6
		fi
Packit 8681c6
		with_zcrypt=no
Packit 8681c6
	])
Packit 8681c6
Packit 8681c6
	if test "x$with_zcrypt" != "xno"; then
Packit 8681c6
		with_zcrypt=yes
Packit 8681c6
	fi
Packit 8681c6
Packit 8681c6
	if test "x$with_zcrypt" = "xno"; then
Packit 8681c6
		CFLAGS="$old_cflags"
Packit 8681c6
		LIBS="$old_libs"
Packit 8681c6
	fi
Packit 8681c6
Packit 8681c6
fi
Packit 8681c6
AC_SUBST([ZCRYPT_CFLAGS])
Packit 8681c6
AC_SUBST([ZCRYPT_LIBS])
Packit 8681c6
Packit 8681c6
Packit 8681c6
dnl --- with_tss
Packit 8681c6
TSS_CFLAGS=
Packit 8681c6
TSS_LIBS=
Packit 8681c6
if test "x$with_tss" != "xno"; then
Packit 8681c6
	if test "x$with_tss" != "xyes" -a "x$with_tss" != "xcheck"; then
Packit 8681c6
		TSS_CFLAGS="-I$with_tss"
Packit 8681c6
		TSS_LIBS="-L$with_tss"
Packit 8681c6
	fi
Packit 8681c6
	old_cflags="$CFLAGS"
Packit 8681c6
	old_libs="$LIBS"
Packit 8681c6
	CFLAGS="$CFLAGS $TSS_CFLAGS"
Packit 8681c6
	LIBS="$LIBS $TSS_LIBS"
Packit 8681c6
	AC_CHECK_HEADER([tss/platform.h], [], [
Packit 8681c6
		if test "x$with_tss" != "xcheck"; then
Packit 8681c6
			AC_MSG_ERROR([Build with TSS requested but TSS headers couldn't be found])
Packit 8681c6
		fi
Packit 8681c6
		with_tss=no
Packit 8681c6
	])
Packit 8681c6
	if test "x$with_tss" != "xno"; then
Packit 8681c6
		AC_CHECK_LIB([tspi], [Tspi_Context_Create],
Packit 8681c6
			[with_tss=yes], [
Packit 8681c6
				if test "x$with_tss" != "xcheck"; then
Packit 8681c6
					AC_MSG_ERROR([Build with TSS requested but TSS libraries couldn't be found])
Packit 8681c6
				fi
Packit 8681c6
				with_tss=no
Packit 8681c6
		])
Packit 8681c6
	fi
Packit 8681c6
	if test "x$with_tss" = "xno"; then
Packit 8681c6
		CFLAGS="$old_cflags"
Packit 8681c6
		LIBS="$old_libs"
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
AC_SUBST([TSS_CFLAGS])
Packit 8681c6
AC_SUBST([TSS_LIBS])
Packit 8681c6
Packit 8681c6
dnl --- with_xcryptolinz
Packit 8681c6
XCRYPTOLINZ_CFLAGS=
Packit 8681c6
XCRYPTOLINZ_LIBS=
Packit 8681c6
if test "x$with_xcryptolinz" != "xno"; then
Packit 8681c6
	if test "x$with_xcryptolinz" != "xyes" -a "x$with_xcryptolinz" != "xcheck"; then
Packit 8681c6
		XCRYPTOLINZ_CFLAGS="-I$with_xcryptolinz"
Packit 8681c6
		XCRYPTOLINZ_LIBS="-L$with_xcryptolinz"
Packit 8681c6
	fi
Packit 8681c6
	old_cflags="$CFLAGS"
Packit 8681c6
	old_libs="$LIBS"
Packit 8681c6
	CFLAGS="$CFLAGS $XCRYPTOLINZ_CFLAGS"
Packit 8681c6
	LIBS="$LIBS $XCRYPTOLINZ_LIBS"
Packit 8681c6
dnl - The above may not be necessary since opencryptoki brings this header file anyway.
Packit 8681c6
	AC_CHECK_HEADER([csulincl.h], [], [
Packit 8681c6
		if test "x$with_xcryptolinz" != "xcheck"; then
Packit 8681c6
			AC_MSG_ERROR([Build with xcryptolinz requested but xcryptolinz headers couldn't be found])
Packit 8681c6
		fi
Packit 8681c6
		with_xcryptolinz=no
Packit 8681c6
	])
Packit 8681c6
	if test "x$with_xcryptolinz" != "xno"; then
Packit 8681c6
		AC_CHECK_LIB([csulcca], [CSNBKTC],
Packit 8681c6
			[with_xcryptolinz=yes], [
Packit 8681c6
				if test "x$with_xcryptolinz" != "xcheck"; then
Packit 8681c6
					AC_MSG_ERROR([Build with xcryptolinz requested but xcryptolinz libraries couldn't be found])
Packit 8681c6
				fi
Packit 8681c6
				with_xcryptolinz=no
Packit 8681c6
		])
Packit 8681c6
	fi
Packit 8681c6
	if test "x$with_xcryptolinz" = "xno"; then
Packit 8681c6
		CFLAGS="$old_cflags"
Packit 8681c6
		LIBS="$old_libs"
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
AC_SUBST([XCRYPTOLINZ_CFLAGS])
Packit 8681c6
AC_SUBST([XCRYPTOLINZ_LIBS])
Packit 8681c6
Packit 8681c6
Packit 8681c6
dnl ---
Packit 8681c6
dnl --- Now check enabled features, while making sure every required
Packit 8681c6
dnl --- package is available
Packit 8681c6
dnl ---
Packit 8681c6
Packit 8681c6
dnl --- enable_testcases
Packit 8681c6
if test "x$enable_testcases" = "xyes"; then
Packit 8681c6
	AC_CHECK_PROG([HAVE_EXPECT], [expect], [yes], [no])
Packit 8681c6
Packit 8681c6
	if test "x$HAVE_EXPECT" = "xno"; then
Packit 8681c6
		AC_MSG_ERROR([*** testcases requires 'expect' interpreter, which wasn't found])
Packit 8681c6
		enable_testcases=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_TESTCASES], [test "x$enable_testcases" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_daemon
Packit 8681c6
AM_CONDITIONAL([ENABLE_DAEMON], [test "x$enable_daemon" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_library
Packit 8681c6
AM_CONDITIONAL([ENABLE_LIBRARY], [test "x$enable_library" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable systemd and set unit dir
Packit 8681c6
if test "x$with_systemd" != "xno"; then
Packit 8681c6
	if test "x$with_systemd" != "xyes" -a "x$with_systemd" != "xcheck"; then
Packit 8681c6
		unitdir=$with_systemd
Packit 8681c6
		enable_systemd=yes
Packit 8681c6
	else
Packit 8681c6
		if test "x$with_systemd" = "xyes"; then
Packit 8681c6
			unitdir=${ac_default_prefix}/lib/systemd/system
Packit 8681c6
			enable_systemd=yes
Packit 8681c6
		else
Packit 8681c6
			enable_systemd=no
Packit 8681c6
		fi
Packit 8681c6
	fi
Packit 8681c6
else
Packit 8681c6
	enable_systemd=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x$enable_systemd" = "xyes"])
Packit 8681c6
AC_SUBST(unitdir)
Packit 8681c6
Packit 8681c6
dnl --- enable_icatok
Packit 8681c6
if test "x$enable_icatok" = "xyes"; then
Packit 8681c6
	if test "x$with_libica" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([ica token build requested but libica development files not found])
Packit 8681c6
		enable_icatok=no
Packit 8681c6
	fi
Packit 8681c6
Packit 8681c6
	if test "x$with_openssl" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([ica token build requested but OpenSSL development files not found])
Packit 8681c6
		enable_icatok=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_icatok" != "xno" -a "x$with_libica" != "xno" -a "x$with_openssl" != "xno"; then
Packit 8681c6
	enable_icatok=yes
Packit 8681c6
else
Packit 8681c6
	enable_icatok=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_ICATOK], [test "x$enable_icatok" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_ccatok
Packit 8681c6
AM_CONDITIONAL([ENABLE_CCATOK], [test "x$enable_ccatok" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_swtok
Packit 8681c6
if test "x$enable_swtok" = "xyes"; then
Packit 8681c6
	if test "x$with_openssl" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([software token build requested but OpenSSL development files not found])
Packit 8681c6
		enable_swtok=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_swtok" != "xno" -a "x$with_openssl" != "xno"; then
Packit 8681c6
	enable_swtok=yes
Packit 8681c6
else
Packit 8681c6
	enable_swtok=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_SWTOK], [test "x$enable_swtok" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_ep11tok
Packit 8681c6
if test "x$enable_ep11tok" = "xyes"; then
Packit 8681c6
	if test "x$with_zcrypt" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([ep11 token build requested but ep11 development files not found])
Packit 8681c6
		enable_ep11=no
Packit 8681c6
	fi
Packit 8681c6
	AC_CHECK_HEADER([ica_api.h], [], [
Packit 8681c6
		AC_MSG_ERROR([ep11 token build requested but Libica headers couldn't be found])
Packit 8681c6
	])
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_ep11tok" != "xno" -a "x$with_zcrypt" != "xno"; then
Packit 8681c6
	enable_ep11tok=yes
Packit 8681c6
	AC_CHECK_HEADER([ica_api.h], [], [
Packit 8681c6
		enable_ep11tok=no
Packit 8681c6
	])
Packit 8681c6
else
Packit 8681c6
	enable_ep11tok=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_EP11TOK], [test "x$enable_ep11tok" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_icsftok
Packit 8681c6
if test "x$enable_icsftok" = "xyes"; then
Packit 8681c6
	if test "x$with_openssl" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([ICSF token build requested but OpenSSL development files not found])
Packit 8681c6
		enable_icsftok=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_icsftok" != "xno" -a "x$with_openssl" != "xno"; then
Packit 8681c6
	enable_icsftok=yes
Packit 8681c6
else
Packit 8681c6
	enable_icsftok=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_ICSFTOK], [test "x$enable_icsftok" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_tpmtok
Packit 8681c6
if test "x$enable_tpmtok" = "xyes"; then
Packit 8681c6
	if test "x$with_tss" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([tpm token build requested but TSS development files not found])
Packit 8681c6
		enable_tpmtok=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_tpmtok" != "xno" -a "x$with_tss" != "xno"; then
Packit 8681c6
	enable_tpmtok=yes
Packit 8681c6
else
Packit 8681c6
	enable_tpmtok=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_TPMTOK], [test "x$enable_tpmtok" = "xyes"])
Packit 8681c6
Packit 8681c6
Packit 8681c6
dnl --- enable_pkcsep11_migrate
Packit 8681c6
if test "x$enable_pkcsep11_migrate" = "xyes"; then
Packit 8681c6
	if test "x$with_zcrypt" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([pkcsep11_migrate build requested but no ep11 libraries found])
Packit 8681c6
		enable_pkcsep11_migrate=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_pkcsep11_migrate" != "xno" -a "x$with_zcrypt" != "xno"; then
Packit 8681c6
	enable_pkcsep11_migrate=yes
Packit 8681c6
else
Packit 8681c6
	enable_pkcsep11_migrate=no
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_PKCSEP11_MIGRATE], [test "x$enable_pkcsep11_migrate" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_pkcsep11_session
Packit 8681c6
if test "x$enable_pkcsep11_session" = "xyes"; then
Packit 8681c6
	if test "x$with_zcrypt" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([pkcsep11_session build requested but no ep11 libraries found])
Packit 8681c6
		enable_pkcsep11_session=no
Packit 8681c6
	fi
Packit 8681c6
fi
Packit 8681c6
Packit 8681c6
if test "x$enable_pkcsep11_session" != "xno" -a "x$with_zcrypt" != "xno"; then
Packit 8681c6
	enable_pkcsep11_session=yes
Packit 8681c6
else
Packit 8681c6
	enable_pkcsep11_session=no
Packit 8681c6
fi
Packit 8681c6
Packit 8681c6
AM_CONDITIONAL([ENABLE_PKCSEP11_SESSION], [test "x$enable_pkcsep11_session" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_p11sak
Packit 8681c6
AM_CONDITIONAL([ENABLE_P11SAK], [test "x$enable_p11sak" = "xyes"])
Packit 8681c6
Packit 8681c6
dnl --- enable_locks
Packit 8681c6
if test "x$enable_locks" != "xno"; then
Packit 8681c6
	enable_locks=yes
Packit 8681c6
	CFLAGS="$CFLAGS -DENABLE_LOCKS"
Packit 8681c6
else
Packit 8681c6
	enable_locks=no
Packit 8681c6
	CFLAGS="$CFLAGS -fgnu-tm"
Packit 8681c6
fi
Packit 8681c6
if test "x$enable_locks" = "xno"; then
Packit 8681c6
	if test "x$itm" != "xyes"; then
Packit 8681c6
		AC_MSG_ERROR([in order to build opencryptoki with transactional memory,
Packit 8681c6
libitm and gcc>=4.7 is required])
Packit 8681c6
    fi
Packit 8681c6
fi
Packit 8681c6
AM_CONDITIONAL([ENABLE_LOCKS], [test "x$enable_locks" = "xyes"])
Packit 8681c6
Packit 8681c6
CFLAGS="$CFLAGS -DPKCS64 -D_XOPEN_SOURCE=600 -Wall -Wextra"
Packit 8681c6
Packit 8681c6
CFLAGS+=' -DCONFIG_PATH=\"$(localstatedir)/lib/opencryptoki\" -DSBIN_PATH=\"$(sbindir)\" -DLIB_PATH=\"$(libdir)\" -DLOCKDIR_PATH=\"$(lockdir)\" -DOCK_CONFDIR=\"$(sysconfdir)/opencryptoki\" -DOCK_LOGDIR=\"$(logdir)\"'
Packit 8681c6
Packit 8681c6
# At this point, CFLAGS is set to something sensible
Packit 8681c6
AC_PROG_CC
Packit 8681c6
Packit 8681c6
AC_CONFIG_MACRO_DIRS([m4])
Packit 8681c6
Packit 8681c6
AC_CONFIG_FILES([Makefile				\
Packit 8681c6
		 usr/lib/api/shrd_mem.c			\
Packit 8681c6
		 man/man1/pkcsconf.1			\
Packit 8681c6
		 man/man1/pkcsicsf.1			\
Packit 8681c6
		 man/man1/pkcscca.1			\
Packit 8681c6
		 man/man1/p11sak.1			\
Packit 8681c6
		 man/man1/pkcsep11_migrate.1		\
Packit 8681c6
		 man/man1/pkcsep11_session.1		\
Packit 8681c6
		 man/man5/opencryptoki.conf.5		\
Packit 8681c6
		 man/man7/opencryptoki.7		\
Packit 8681c6
		 man/man8/pkcsslotd.8])
Packit 8681c6
Packit 8681c6
AC_OUTPUT
Packit 8681c6
Packit 8681c6
echo "Enabled features:"
Packit 8681c6
echo "	Debug build:		$enable_debug"
Packit 8681c6
echo "	Testcases:		$enable_testcases"
Packit 8681c6
echo "	Daemon build:		$enable_daemon"
Packit 8681c6
echo "	Library build:		$enable_library"
Packit 8681c6
echo "	Systemd service:	$enable_systemd"
Packit 8681c6
echo "	Build with locks:	$enable_locks"
Packit 8681c6
echo "	Build p11sak tool:	$enable_p11sak"
Packit 8681c6
echo
Packit 8681c6
echo "Enabled token types:"
Packit 8681c6
echo "	ICA token:		$enable_icatok"
Packit 8681c6
echo "	CCA token:		$enable_ccatok"
Packit 8681c6
echo "	Software token:		$enable_swtok"
Packit 8681c6
echo "	EP11 token:		$enable_ep11tok"
Packit 8681c6
echo "	TPM token:		$enable_tpmtok"
Packit 8681c6
echo "	ICSF token:		$enable_icsftok"
Packit 8681c6
echo
Packit 8681c6
echo "Token-specific features:"
Packit 8681c6
echo "	pkcsep11migrate build:	$enable_pkcsep11_migrate"
Packit 8681c6
echo "	pkcsep11session build:	$enable_pkcsep11_session"
Packit 8681c6
echo
Packit 8681c6
echo "CFLAGS=$CFLAGS"
Packit 8681c6
echo