1#
2# configure.in
3#
4#       The Initial Developer of the Original Code is International
5#       Business Machines Corporation. Portions created by IBM
6#       Corporation are Copyright (C) 2005, 2006 International Business
7#       Machines Corporation. All Rights Reserved.
8#
9#       This program is free software; you can redistribute it and/or modify
10#       it under the terms of the Common Public License as published by
11#       IBM Corporation; either version 1 of the License, or (at your option)
12#       any later version.
13#
14#       This program is distributed in the hope that it will be useful,
15#       but WITHOUT ANY WARRANTY; without even the implied warranty of
16#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17#       Common Public License for more details.
18#
19#       You should have received a copy of the Common Public License
20#       along with this program; if not, a copy can be viewed at
21#       http://www.opensource.org/licenses/cpl1.0.php.
22#
23
24AC_INIT(tpm-tools, 1.3.9, trousers-tech@lists.sf.net)
25AC_PREREQ(2.12)dnl
26AC_CONFIG_SRCDIR(Makefile.am)
27AM_CONFIG_HEADER(config.h)
28
29AC_CONFIG_MACRO_DIR([m4])
30AC_CANONICAL_TARGET
31AM_INIT_AUTOMAKE([foreign 1.6])
32
33
34DEBUG=""
35AC_MSG_CHECKING([for debug-enabled build])
36AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [create a debug build that outputs debug messages]),
37 [if test "$enableval" = "yes"; then
38    DEBUG="yes"
39    AC_MSG_RESULT([yes])
40  else
41    DEBUG="no"
42    AC_MSG_RESULT([no])
43  fi],
44 [DEBUG="no"
45  AC_MSG_RESULT([no])])
46
47# If the user has not set CFLAGS, do something appropriate
48test_CFLAGS=${CFLAGS+set}
49if test "$test_CFLAGS" != set; then
50	if test "$DEBUG" == "yes"; then
51		CFLAGS="-O0 -g -DDEBUG"
52	else
53		CFLAGS="-g -O2"
54	fi
55elif test "$DEBUG" == "yes"; then
56	CFLAGS="$CFLAGS -O0 -g -DDEBUG"
57fi
58
59
60AC_PROG_CC
61AC_PROG_INSTALL
62AC_PROG_LIBTOOL
63
64AC_CHECK_PROGS(COPY, cp)
65AC_CHECK_PROGS(ECHO, echo)
66AC_CHECK_PROGS(MKDIR, mkdir)
67AC_CHECK_PROGS(RM, rm)
68
69AM_GNU_GETTEXT_VERSION([0.15])
70AM_GNU_GETTEXT([external])
71
72# Arch specific stuff
73case $target in
74	*ppc64* | *powerpc64* | *x86_64* | *s390x*)
75		CFLAGS="$CFLAGS -m64"
76		;;
77	*)
78		;;
79esac
80
81
82
83# Non-standard OpenSSL location
84AC_MSG_CHECKING([Non-standard OpenSSL location])
85AC_ARG_WITH(openssl,
86	    AC_HELP_STRING([--with-openssl=PATH], [Location of openssl libs/includes]),
87	    [OPENSSL_INCLUDE_DIR="$withval/include"
88	     OPENSSL_LIB_DIR="$withval/lib"
89	    if test ! -d $OPENSSL_INCLUDE_DIR -o ! -d $OPENSSL_LIB_DIR; then
90		    AC_MSG_ERROR([$OPENSSL_INCLUDE_DIR or $OPENSSL_LIB_DIR doen't exist!])
91	    else
92		    AC_MSG_RESULT([yes])
93		    CFLAGS="$CFLAGS -L$OPENSSL_LIB_DIR -I$OPENSSL_INCLUDE_DIR"
94		    AC_SUBST([OPENSSL_LIB_DIR])
95	    fi],
96	    [AC_MSG_RESULT([no])
97	    AC_SUBST([OPENSSL_LIB_DIR], []) ] )
98
99AC_CHECK_LIB(tspi, Tspi_Context_Create, [TSS_LIB="1"], [AC_MSG_ERROR([tss lib not found: libtspi.so])])
100AC_CHECK_LIB(tspi, Tspi_TPM_SetOperatorAuth, [TSS_12="1"], [TSS_12="0"])
101if test "$TSS_12" = "1"; then
102	AM_CONDITIONAL(TSS_LIB_IS_12, true)
103	AC_MSG_NOTICE([Configuring tpm-tools for TSS 1.2])
104else
105	AM_CONDITIONAL(TSS_LIB_IS_12, false)
106	AC_MSG_NOTICE([Configuring tpm-tools for TSS 1.1])
107fi
108AC_CHECK_HEADER(trousers/tss.h, [TSS_INC="1"], [AC_MSG_ERROR([tss header not found: trousers/tss.h])])
109
110AC_CHECK_LIB(crypto, PEM_read_X509, [OPENSSL_LIB="1"], [AC_MSG_ERROR([openssl lib not found: libcrypto.so])])
111AC_CHECK_HEADER(openssl/evp.h, [OPENSSL_INC="1"], [AC_MSG_ERROR([openssl header not found: openssl/evp.h])])
112
113OPENCRYPTOKI="0"
114AC_ARG_ENABLE(pkcs11_support,
115  AC_HELP_STRING([--disable-pkcs11-support], [don't build data_mgmt commands [[default=no]]]),
116  [disable_pkcs11_support="yes"
117   AC_MSG_RESULT([*** Not building data_mgmt at user request ***])],)
118
119if test "x$disable_pkcs11_support" != "xyes"; then
120  AC_CHECK_HEADER(opencryptoki/pkcs11.h, [OPENCRYPTOKI_INC="1"], [OPENCRYPTOKI_INC="0"])
121  if test "$OPENCRYPTOKI_INC" = "1"; then
122    OPENCRYPTOKI="1"
123  fi
124fi
125AM_CONDITIONAL([P11_SUPPORT], [test "$OPENCRYPTOKI" = "1"])
126
127AC_HEADER_STDC
128
129AC_C_CONST
130AC_C_INLINE
131
132AC_SYS_LONG_FILE_NAMES
133
134AC_TYPE_MODE_T
135AC_TYPE_OFF_T
136AC_TYPE_PID_T
137AC_TYPE_SIZE_T
138AC_TYPE_SIGNAL
139AC_TYPE_UID_T
140
141CFLAGS="$CFLAGS -Wall -Wreturn-type -Wsign-compare"
142
143AC_CONFIG_FILES(Makefile		\
144		po/Makefile.in		\
145		m4/Makefile		\
146		include/Makefile	\
147		lib/Makefile		\
148		src/Makefile		\
149		src/tpm_mgmt/Makefile	\
150		src/cmds/Makefile	\
151		src/data_mgmt/Makefile  \
152		dist/tpm-tools.spec	\
153		man/Makefile            \
154		man/man1/Makefile       \
155		man/man3/Makefile       \
156		man/man8/Makefile)
157AC_OUTPUT
158
159echo "CFLAGS=$CFLAGS"
160echo "LDFLAGS=$LDFLAGS"
161