root/releases/opensc-0.5.0/configure.in

Revision 196, 13.2 KB (checked in by jey, 7 years ago)

- added opensc-config script
- added ATR string for Cryptoflex 8k

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1dnl -*- mode: m4; -*-
2dnl Process this file with autoconf to produce a configure script.
3dnl $Id$
4
5# Require autoconf 2.52
6AC_PREREQ(2.52)
7
8AC_INIT(src/libopensc/sc.c)
9AM_INIT_AUTOMAKE(opensc, 0.5.0)
10AM_CONFIG_HEADER(config.h)
11
12AC_CANONICAL_HOST
13case $host in
14  darwin* | rhapsody*)
15  AC_DEFINE(OS_MACOSX,1,[MacOS X])
16  ;;
17  beos*)
18  AC_DEFINE(OS_BEOS,1,[BeOS])
19  ;;
20  cygwin* | mingw* | pw32*)
21  AC_DEFINE(OS_CYGWIN,1,[Cywin32 and friends])
22  ;;
23  *irix*)
24  AC_DEFINE(OS_IRIX,1,[SGI IRIX])
25  ;;
26  *hpux*)
27  AC_DEFINE(OS_HPUX,1,[HP-UX])
28  ;;
29  *solaris* | *sunos*)
30  AC_DEFINE(OS_SOLARIS,1,[Sun Solaris])
31  ;;
32  *osf*)
33  AC_DEFINE(OS_DUNIX,1,[Digital UNIX])
34  ;;
35  *aix*)
36  AC_DEFINE(OS_AIX,1,[IBM AIX])
37  ;;
38  *freebsd*)
39  AC_DEFINE(OS_FREEBSD,1,[FreeBSD])
40  ;;
41  *netbsd*)
42  AC_DEFINE(OS_NETBSD,1,[NetBSD])
43  ;;
44  *openbsd*)
45  AC_DEFINE(OS_OPENBSD,1,[OpenBSD])
46  ;;
47  *linux*)
48  AC_DEFINE(OS_LINUX,1,[Linux])
49  ;;
50esac
51AC_PROG_CC
52AC_C_BIGENDIAN
53
54dnl Check for some target-specific stuff
55case "$host" in
56*-*-hpux*)
57        CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
58        AC_DEFINE(PAM_SUN_CODEBASE, 1, [PAM based on SUN codebase])
59        ;;
60*-*-solaris*)
61        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
62        LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
63        need_dash_r=1
64        AC_DEFINE(PAM_SUN_CODEBASE, 1, [PAM based on SUN codebase])
65        ;;
66*-*-sunos4*)
67        CPPFLAGS="$CPPFLAGS -DSUNOS4"
68        AC_CHECK_FUNCS(getpwanam)
69        AC_DEFINE(PAM_SUN_CODEBASE, 1, [PAM based on SUN codebase])
70        ;;
71*-*-aix*)
72        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
73        LDFLAGS="$LDFLAGS -L/usr/local/lib"
74        if (test "$LD" != "gcc" && test -z "$blibpath"); then
75                blibpath="/usr/lib:/lib:/usr/local/lib"
76        fi
77        ;;
78*-*-linux*)
79        ;;
80esac
81
82dnl Allow user to specify flags
83AC_ARG_WITH(cflags,
84        [  --with-cflags           Specify additional flags to pass to compiler],
85        [
86                if test "x$withval" != "xno" ; then
87                        CFLAGS="$CFLAGS $withval"
88                fi
89        ]
90)
91AC_ARG_WITH(cppflags,
92        [  --with-cppflags         Specify additional flags to pass to preprocessor] ,
93        [
94                if test "x$withval" != "xno"; then
95                        CPPFLAGS="$CPPFLAGS $withval"
96                fi
97        ]
98)
99AC_ARG_WITH(ldflags,
100        [  --with-ldflags          Specify additional flags to pass to linker],
101        [
102                if test "x$withval" != "xno" ; then
103                        LDFLAGS="$LDFLAGS $withval"
104                fi
105        ]
106)
107AC_ARG_WITH(libs,
108        [  --with-libs             Specify additional libraries to link with],
109        [
110                if test "x$withval" != "xno" ; then
111                        LIBS="$LIBS $withval"
112                fi
113        ]
114)
115
116dnl Checks for programs.
117AC_PROG_CPP
118AC_PROG_INSTALL
119AC_PROG_LN_S
120AC_PROG_MAKE_SET
121
122dnl Special check for pthread support.
123ACX_PTHREAD(
124[
125 AC_DEFINE(HAVE_PTHREAD,1,
126  [Define if you have POSIX threads libraries and header files.])
127], [
128 AC_MSG_ERROR([POSIX thread support required])
129])
130LIBS="$PTHREAD_LIBS $LIBS"
131CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
132CC="$PTHREAD_CC"
133
134dnl Add libtool support.
135AM_PROG_LIBTOOL
136dnl Automatically update the libtool script if it becomes out-of-date.
137#AC_SUBST(LIBTOOL_DEPS)
138
139dnl Checks for header files.
140AC_HEADER_STDC
141AC_CHECK_HEADERS([errno.h fcntl.h malloc.h stdlib.h string.h sys/time.h unistd.h syslog.h getopt.h security/pam_appl.h security/_pam_macros.h])
142
143dnl Checks for typedefs, structures, and compiler characteristics.
144AC_C_CONST
145AC_TYPE_SIZE_T
146AC_HEADER_TIME
147
148AC_SUBST(GETOPTSRC)
149AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT_LONG, 1, [Define if you have the `getopt_long' function.]),
150              [GETOPTSRC="$GETOPTSRC \$(top_srcdir)/src/common/getopt.c \$(top_srcdir)/src/common/getopt1.c"
151               CPPFLAGS="-I\$(top_srcdir)/src/common $CPPFLAGS"
152               AC_DEFINE(HAVE_GETOPT_H, 1, [Define if you have the <getopt.h> header file.])])
153
154dnl Checks for library functions.
155AC_FUNC_ERROR_AT_LINE
156AC_FUNC_MALLOC
157AC_FUNC_MEMCMP
158AC_FUNC_STAT
159AC_FUNC_VPRINTF
160AC_CHECK_FUNCS([getpass gettimeofday memset mkdir strdup strerror])
161
162dnl C Compiler features
163AC_C_INLINE
164if test "$GCC" = "yes"; then
165        CFLAGS="$CFLAGS -Wall -Werror"
166fi
167
168dnl OS specific options
169case "$host_os" in
170  hpux*)
171    CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
172    ;;
173  osf*)
174    CFLAGS="$CFLAGS -D_POSIX_PII_SOCKET"
175    ;;
176  *)
177    ;;
178esac
179
180AC_ARG_WITH(common-dir,
181        [  --with-common-dir=PATH  Specify path for common installation libraries],
182        [
183                if test "x$withval" != "xno" ; then
184                        trycommondir=$withval
185                fi
186        ]
187)
188
189saved_LDFLAGS="$LDFLAGS"
190saved_CPPFLAGS="$CPPFLAGS"
191AC_CACHE_CHECK([for common directory], ac_cv_commondir, [
192        for commondir in $trycommondir "" /usr/local /usr/pkg /opt ; do
193                # Skip directories if they don't exist
194                if test ! -z "$commondir" -a ! -d "$commondir" ; then
195                        continue;
196                fi
197                CPPFLAGS="$saved_CPPFLAGS"
198                LDFLAGS="$saved_LDFLAGS"
199
200                if test ! -z "$commondir" -a "x$commondir" != "x/usr"; then
201                        # Try to use $commondir/lib if it exists, otherwise
202                        # $commondir
203                        if test -d "$commondir/lib" ; then
204                                LDFLAGS="-L$commondir/lib $saved_LDFLAGS"
205                                if test ! -z "$need_dash_r" ; then
206                                        LDFLAGS="-R$commondir/lib $LDFLAGS"
207                                fi
208                        else
209                                LDFLAGS="-L$commondir $saved_LDFLAGS"
210                                if test ! -z "$need_dash_r" ; then
211                                        LDFLAGS="-R$commondir $LDFLAGS"
212                                fi
213                        fi
214                        # Try to use $commondir/include if it exists, otherwise
215                        # $commondir
216                        if test -d "$commondir/include" ; then
217                                CPPFLAGS="-I$commondir/include $saved_CPPFLAGS"
218                        else
219                                CPPFLAGS="-I$commondir $saved_CPPFLAGS"
220                        fi
221                fi
222                break;
223        done
224
225        if test -z "$commondir" ; then
226                commondir="(system)"
227        fi
228
229        ac_cv_commondir=$commondir
230])
231
232if (test ! -z "$ac_cv_commondir" && test "x$ac_cv_commondir" != "x(system)") ; then
233        dnl Need to recover commondir - test above runs in subshell
234        commondir=$ac_cv_commondir
235        if test ! -z "$commondir" -a "x$commondir" != "x/usr"; then
236                # Try to use $commondir/lib if it exists, otherwise
237                # $commondir
238                if test -d "$commondir/lib" ; then
239                        LDFLAGS="-L$commondir/lib $saved_LDFLAGS"
240                        if test ! -z "$need_dash_r" ; then
241                                LDFLAGS="-R$commondir/lib $LDFLAGS"
242                        fi
243                else
244                        LDFLAGS="-L$commondir $saved_LDFLAGS"
245                        if test ! -z "$need_dash_r" ; then
246                                LDFLAGS="-R$commondir $LDFLAGS"
247                        fi
248                fi
249                # Try to use $commondir/include if it exists, otherwise
250                # $commondir
251                if test -d "$commondir/include" ; then
252                        CPPFLAGS="-I$commondir/include $saved_CPPFLAGS"
253                else
254                        CPPFLAGS="-I$commondir $saved_CPPFLAGS"
255                fi
256        fi
257fi
258
259AC_SUBST(CFLAGS_PCSC)
260AC_SUBST(LIBPCSC)
261LIBPCSC="-lpcsclite"
262found_pcsclite=no
263saved_LIBS="$LIBS"
264saved_LDFLAGS="$LDFLAGS"
265saved_CPPFLAGS="$CPPFLAGS"
266LIBS="$LIBPCSC $saved_LIBS"
267AC_ARG_WITH(pcsclite,
268        [  --with-pcsclite=PATH    use PC/SC Lite in PATH],
269        [
270        AC_MSG_CHECKING([for SCardEstablishContext])
271        for pcscdir in /pcsc ""; do
272                LDFLAGS="$saved_LDFLAGS"
273
274                if test -d "$withval/lib$pcscdir"; then
275                        if test -n "${need_dash_r}"; then
276                                LDFLAGS="-L${withval}/lib${pcscdir}/ -R${withval}/lib${pcscdir}/ ${LDFLAGS}"
277                        else
278                                LDFLAGS="-L${withval}/lib${pcscdir} ${LDFLAGS}"
279                        fi
280                else
281                        if test -n "${need_dash_r}"; then
282                                LDFLAGS="-L${withval}${pcscdir} -R${withval}${pcscdir} ${LDFLAGS}"
283                        else
284                                LDFLAGS="-L${withval}${pcscdir} ${LDFLAGS}"
285                        fi
286                fi
287                if test -d "$withval/include"; then
288                        CFLAGS_PCSC="-I${withval}/include${pcscdir} ${CFLAGS_PCSC}"
289                else
290                        CFLAGS_PCSC="-I${withval}${pcscdir} ${CFLAGS_PCSC}"
291                fi
292                CPPFLAGS="$CFLAGS_PCSC $saved_CPPFLAGS"
293                AC_TRY_LINK([#include <stdlib.h>
294#include <winscard.h>],[SCardEstablishContext(0, NULL, NULL, NULL);], ac_cv_lib_pcsclite_SCardEstablishContext=yes)
295                CPPFLAGS="$saved_CPPFLAGS"
296                if test "x$ac_cv_lib_pcsclite_SCardEstablishContext" = "xyes"; then
297                        found_pcsclite=yes
298                        break;
299                fi
300        done
301        if test "x$found_pcsclite" != "xyes" ; then
302                AC_MSG_RESULT(no)
303        else
304                AC_MSG_RESULT(yes)
305        fi
306        ]
307)
308if test "x$found_pcsclite" != "xyes" ; then
309        AC_CHECK_LIB(pcsclite, SCardEstablishContext, , AC_MSG_ERROR([*** PC/SC Lite missing - please install first]))
310fi
311LIBS="$saved_LIBS"
312AM_CONDITIONAL(HAVE_PCSCLITE, test "x$found_pcsclite" = "xyes")
313
314AC_SUBST(LIBDL)
315AC_CHECK_LIB(dl, dlopen, [LIBDL="$LIBDL -ldl" ac_cv_func_dlopen_ldl=yes], ac_cv_func_dlopen_ldl=no)
316
317dnl The big search for OpenSSL
318AC_ARG_WITH(ssl-dir,
319        [  --with-ssl-dir=PATH     Specify path to OpenSSL installation],
320        [
321                if test "x$withval" != "xno" ; then
322                        tryssldir=$withval
323                fi
324        ]
325)
326
327SSL_MSG="no"
328saved_LIBS="$LIBS"
329saved_LDFLAGS="$LDFLAGS"
330saved_CPPFLAGS="$CPPFLAGS"
331AC_SUBST(LIBCRYPTO)
332AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
333        for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
334                # Skip directories if they don't exist
335                if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
336                        continue;
337                fi
338                LIBCRYPTO="-lcrypto"
339                CPPFLAGS="$saved_CPPFLAGS"
340                LDFLAGS="$saved_LDFLAGS"
341                LIBS="$saved_LIBS $LIBCRYPTO"
342
343                if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
344                        # Try to use $ssldir/lib if it exists, otherwise
345                        # $ssldir
346                        if test -d "$ssldir/lib" ; then
347                                LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
348                                if test ! -z "$need_dash_r" ; then
349                                        LDFLAGS="-R$ssldir/lib $LDFLAGS"
350                                fi
351                        else
352                                LDFLAGS="-L$ssldir $saved_LDFLAGS"
353                                if test ! -z "$need_dash_r" ; then
354                                        LDFLAGS="-R$ssldir $LDFLAGS"
355                                fi
356                        fi
357                        # Try to use $ssldir/include if it exists, otherwise
358                        # $ssldir
359                        if test -d "$ssldir/include" ; then
360                                CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
361                        else
362                                CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
363                        fi
364                fi
365
366                # Basic test to check for compatible version and correct linking
367                # *does not* test for RSA - that comes later.
368                AC_TRY_RUN(
369                        [
370#include <string.h>
371#include <openssl/rand.h>
372int main(void)
373{
374        char a[2048];
375        memset(a, 0, sizeof(a));
376        RAND_add(a, sizeof(a), sizeof(a));
377        return(RAND_status() <= 0);
378}
379                        ],
380                        [
381                                found_crypto=1
382                                break;
383                        ], []
384                )
385
386                if test ! -z "$found_crypto" ; then
387                        break;
388                fi
389        done
390
391        if test -n "$found_crypto" ; then
392                if test -z "$ssldir" ; then
393                        ssldir="(system)"
394                fi
395                ac_cv_openssldir=$ssldir
396                SSL_MSG="yes"
397        fi
398])
399
400if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then
401        AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL libraries])
402        dnl Need to recover ssldir - test above runs in subshell
403        ssldir=$ac_cv_openssldir
404        if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
405                # Try to use $ssldir/lib if it exists, otherwise
406                # $ssldir
407                if test -d "$ssldir/lib" ; then
408                        LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
409                        if test ! -z "$need_dash_r" ; then
410                                LDFLAGS="-R$ssldir/lib $LDFLAGS"
411                        fi
412                else
413                        LDFLAGS="-L$ssldir $saved_LDFLAGS"
414                        if test ! -z "$need_dash_r" ; then
415                                LDFLAGS="-R$ssldir $LDFLAGS"
416                        fi
417                fi
418                # Try to use $ssldir/include if it exists, otherwise
419                # $ssldir
420                if test -d "$ssldir/include" ; then
421                        CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
422                else
423                        CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
424                fi
425        fi
426fi
427LIBS="$saved_LIBS"
428AM_CONDITIONAL(HAVE_SSL, test "x$SSL_MSG" = "xyes")
429
430dnl Check for PAM libs
431PAM_MSG="no"
432no_pam=""
433AC_SUBST(LIBPAM)
434saved_LIBS="$LIBS"
435AC_MSG_CHECKING([PAM support])
436AC_ARG_WITH(pam,
437        [  --with-pam              Enable PAM support],
438        [
439                if test "x$withval" = "xno" ; then
440                        AC_MSG_RESULT(disabled)
441                        no_pam=1
442                fi
443        ],
444)
445if test -z "$no_pam" ; then
446        if test "x$ac_cv_header_security_pam_appl_h" = "xyes" ; then
447                AC_MSG_RESULT(yes)
448                PAM_MSG="yes"
449                AC_CHECK_LIB(pam, pam_set_item, [LIBPAM="$LIBPAM -lpam"], AC_MSG_ERROR([*** libpam missing]))
450                LIBS="$LIBS $LIBPAM"
451                AC_CHECK_FUNCS(pam_getenvlist)
452                AC_CHECK_FUNCS(pam_putenv)
453                disable_shadow=yes
454                AC_DEFINE(HAVE_PAM, 1, [Have Pluggable Authentication Modules])
455        else
456                AC_MSG_RESULT(no)
457        fi
458fi
459
460dnl Check for older PAM
461if test "x$PAM_MSG" = "xyes" ; then
462        # Check PAM strerror arguments (old PAM)
463        AC_MSG_CHECKING([whether pam_strerror takes only one argument])
464        AC_TRY_COMPILE(
465                [
466#include <stdlib.h>
467#include <security/pam_appl.h>
468                ],
469                [(void)pam_strerror((pam_handle_t *)NULL, -1);],
470                [AC_MSG_RESULT(no)],
471                [
472                        AC_DEFINE(HAVE_OLD_PAM, 1, [Have OLD Pluggable Authentication Modules])
473                        AC_MSG_RESULT(yes)
474                        PAM_MSG="yes (old library)"
475                ]
476        )
477fi
478LIBS="$saved_LIBS"
479AM_CONDITIONAL(HAVE_PAM, test "x$PAM_MSG" = "xyes")
480AM_CONDITIONAL(HAVE_PAM_AND_SSL, test "x$PAM_MSG" = "xyes" -a "x$SSL_MSG" = "xyes")
481
482dnl Enable/disable debugging messages.
483AC_ARG_ENABLE(debug,
484[  --enable-debug          enable debug messages. [default=no]],
485        , enable_debug=no)
486if (test x$enable_debug = xyes); then
487        AC_DEFINE(DEBUG, 1, [Enable debug messages.])
488fi
489
490AC_SUBST(CFLAGS_OPENSC)
491CFLAGS_OPENSC="-I\${top_srcdir}/src/libopensc"
492AC_SUBST(LIBOPENSC)
493LIBOPENSC="\${top_srcdir}/src/libopensc/libopensc.la"
494
495
496# Pass information about installed OpenSC requirements, so that
497# a proper opensc-config file will be build.
498OPENSC_LIBS="-L${libdir} -lopensc"
499OPENSC_CFLAGS=""
500AC_SUBST(OPENSC_LIBS)
501AC_SUBST(OPENSC_CFLAGS)
502
503
504AC_OUTPUT([
505Makefile
506aclocal/Makefile
507src/Makefile
508src/common/Makefile
509src/libopensc/Makefile
510src/libopensc/opensc-config
511src/openssh/Makefile
512src/pam/Makefile
513src/pkcs11/Makefile
514src/pkcs11/rsaref/Makefile
515src/tests/Makefile
516src/tools/Makefile
517])
518
519dnl Someone please show me a better way :)
520A=`eval echo ${prefix}` ; A=`eval echo ${A}`
521B=`eval echo ${bindir}` ; B=`eval echo ${B}`
522
523echo ""
524echo "OpenSC has been configured with the following options"
525
526echo ""
527echo "User binaries:       ${B}"
528
529echo ""
530echo "Host:                ${host}"
531echo "Compiler:            ${CC}"
532echo "Compiler flags:      ${CFLAGS}"
533echo "Preprocessor flags:  ${CPPFLAGS}"
534echo "Linker flags:        ${LDFLAGS}"
535echo "Libraries:           ${LIBS}"
536
537echo ""
538echo "OpenSSL support:     ${SSL_MSG}"
539echo "PAM support:         ${PAM_MSG}"
540
541echo ""
Note: See TracBrowser for help on using the browser.