]> git.proxmox.com Git - swtpm.git/blame - configure.ac
merging swtpm-tools into this project
[swtpm.git] / configure.ac
CommitLineData
f163b202
SB
1#
2# configure.ac
3#
4# The Initial Developer of the Original Code is International
5# Business Machines Corporation. Portions created by IBM
6# Corporation are Copyright (C) 2014 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# This file is derived from tpm-tool's configure.in.
24#
25
26AC_INIT(swtpm, 0.1.0)
27AC_PREREQ(2.12)
28AC_CONFIG_SRCDIR(Makefile.am)
29AC_CONFIG_HEADER(config.h)
30
31SWTPM_VER_MAJOR=`echo $PACKAGE_VERSION | cut -d "." -f1`
32SWTPM_VER_MINOR=`echo $PACKAGE_VERSION | cut -d "." -f2`
33SWTPM_VER_MICRO=`echo $PACKAGE_VERSION | cut -d "." -f3`
34
35AC_SUBST([SWTPM_VER_MAJOR])
36AC_SUBST([SWTPM_VER_MINOR])
37AC_SUBST([SWTPM_VER_MICRO])
38
39dnl Check for programs
40AC_PROG_CC
41AC_PROG_INSTALL
42AC_PROG_LN_S
43AC_PROG_LIBTOOL
44
f163b202
SB
45AC_CONFIG_MACRO_DIR([m4])
46AC_CANONICAL_TARGET
47AM_INIT_AUTOMAKE([foreign 1.6])
48
49DEBUG=""
50AC_MSG_CHECKING([for debug-enabled build])
51AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [create a debug build]),
52 [if test "$enableval" = "yes"; then
53 DEBUG="yes"
54 AC_MSG_RESULT([yes])
55 else
56 DEBUG="no"
57 AC_MSG_RESULT([no])
58 fi],
59 [DEBUG="no",
60 AC_MSG_RESULT([no])])
61
62# If the user has not set CFLAGS, do something appropriate
63test_CFLAGS=${CFLAGS+set}
64if test "$test_CFLAGS" != set; then
65 if test "$DEBUG" == "yes"; then
66 CFLAGS="-O0 -g -DDEBUG"
67 else
68 CFLAGS="-g -O2"
69 fi
70elif test "$DEBUG" == "yes"; then
71 CFLAGS="$CFLAGS -O0 -g -DDEBUG"
72fi
73
e46a2b66
SB
74AC_HEADER_STDC
75AC_C_CONST
76AC_C_INLINE
77
78AC_TYPE_SIZE_T
79AC_TYPE_SIGNAL
80
81
f163b202
SB
82GLIB_CFLAGS=$(pkg-config --cflags glib-2.0)
83if test $? -ne 0; then
84 AC_MSG_ERROR("Is glib-2.0 installed? -- could not get cflags")
85fi
86
87GLIB_LDFLAGS=$(pkg-config --libs glib-2.0)
88if test $? -ne 0; then
89 AC_MSG_ERROR("Is glib-2.0 installed? -- could not get libs")
90fi
91
92GTHREAD_LDFLAGS=$(pkg-config --libs gthread-2.0)
93if test $? -ne 0; then
94 AC_MSG_ERROR("Is glib-2.0 installed? -- could not get libs for gthread-2.0")
95fi
96
97NSS_CFLAGS=$(pkg-config --cflags nss)
98if test $? -ne 0; then
99 AC_MSG_ERROR("Is nss-softokn-freebl-devel installed? -- could not get cflags for nss")
100fi
101
102NSS_LDFLAGS=$(pkg-config --libs nss)
103if test $? -ne 0; then
104 AC_MSG_ERROR("Is nss-softokn-freebl-devel installed? -- could not get libs for nss")
105fi
106
107CFLAGS="$CFLAGS $GLIB_CFLAGS $NSS_CFLAGS"
108LDFLAGS="$LDFLAGS $GLIB_LDFLAGS $GTHREAD_LDFLAGS $NSS_LDFLAGS"
109
110CPPFLAGS=$GLIB_CFLAGS
111AC_CHECK_HEADERS([glib.h],[],
112 AC_MSG_ERROR([You must install glib2-devel]))
113
114AC_PROG_CC
115AC_PROG_INSTALL
116
117#AM_GNU_GETTEXT_VERSION([0.15])
118#AM_GNU_GETTEXT([external])
119
e46a2b66
SB
120AC_PATH_PROG([TPM_NVDEFINE], tpm_nvdefine)
121if test "x$TPM_NVDEFINE" == "x"; then
122 AC_MSG_ERROR([NVRAM area tools are need: tpm-tools package])
123fi
124
f163b202
SB
125AC_CHECK_LIB([tpms], [TPMLIB_MainInit], [],
126 [AC_MSG_ERROR([TPM library not found: libtpms.so])])
127AC_CHECK_HEADER(libtpms/tpm_library.h, [], \
128 [AC_MSG_ERROR([TPM library header not found: libtpms/tpm_library.h])])
129
130saved_CFLAGS="$CFLAGS"
131CFLAGS=`pkg-config fuse --cflags`
132CPPFLAGS=$CFLAGS
133AC_CHECK_LIB([fuse], [cuse_lowlevel_main], [],
134 [AC_MSG_ERROR([FUSE library not found: libfuse.so])])
135AC_CHECK_HEADER(cuse_lowlevel.h, [], \
136 [AC_MSG_ERROR([FUSE library header not found: fuse/cuse_lowlevel.h])])
137CFLAGS="$saved_CFLAGS"
138
e46a2b66
SB
139if test "x$with_gnutls" != "xno"; then
140 GNUTLS_LDFLAGS=$(pkg-config --libs gnutls)
141 if test $? -ne 0; then
142 if "x$with_gnutls" == "xyes"; then
143 AC_MSG_ERROR("Is gnutls installed? -- could not get libs for gnutls")
144 else
145 with_gnutls=no
146 fi
147 fi
148fi
f163b202 149
e46a2b66
SB
150saved_CFLAGS="$CFLAGS"
151if test "x$with_gnutls" != "xno"; then
152 CFLAGS=`pkg-config gnutls --cflags`
153 AC_CHECK_LIB([gnutls], [gnutls_x509_crt_set_key], [],
154 [if test "x$with_gnutls" == "xyes"; then
155 AC_MSG_ERROR([GNUTLS >= 3.1.0 library not found: libgnutls.so])
156 else
157 with_gnutls="no"
158 fi])
159fi
160
161if test "x$with_gnutls" != "xno"; then
162 AC_CHECK_HEADER(gnutls/abstract.h, [], \
163 [if test "x$with_gnutls" == "xyes"; then
164 AC_MSG_ERROR([GNUTLS >= 3.1.0 library header not found: gnutls/abstract.h])
165 else
166 with_gnutls="no"
167 fi])
168fi
169
170if test "x$with_gnutls" != "xno"; then
171 with_gnutls="yes"
172fi
173AM_CONDITIONAL([WITH_GNUTLS], [test "x$with_gnutls" == "xyes"])
174
175CFLAGS="$saved_CFLAGS"
f163b202
SB
176
177CFLAGS="$CFLAGS -Wreturn-type -Wsign-compare -Wswitch-enum"
178CFLAGS="$CFLAGS -Wmissing-prototypes -Wall -Werror"
179
180AC_CONFIG_FILES(Makefile \
181 dist/swtpm.spec \
e46a2b66
SB
182 etc/Makefile \
183 samples/Makefile \
f163b202
SB
184 include/Makefile \
185 include/swtpm/Makefile \
186 src/Makefile \
187 src/selinux/Makefile \
188 src/swtpm/Makefile \
189 src/swtpm/swtpm.h \
e46a2b66
SB
190 src/swtpm_bios/Makefile \
191 src/swtpm_cert/Makefile \
192 src/swtpm_ioctl/Makefile \
193 src/swtpm_setup/Makefile \
f163b202
SB
194 man/Makefile \
195 man/man8/Makefile \
e46a2b66 196 tests/Makefile \
f163b202
SB
197 )
198AC_OUTPUT
199
e46a2b66
SB
200echo
201echo "with_gnutls : $with_gnutls (no = swtpm_cert will NOT be built)"
202echo
f163b202
SB
203echo "CFLAGS=$CFLAGS"
204echo "LDFLAGS=$LDFLAGS"