root/releases/opensc-0.6.0/configure.in

Revision 314, 14.0 KB (checked in by jey, 7 years ago)

- added docs/Makefile to AC_OUTPUT

  • 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.6.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 readline/readline.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                        AC_DEFINE(HAVE_LIBPCSCLITE)
298                        found_pcsclite=yes
299                        break;
300                fi
301        done
302        if test "x$found_pcsclite" != "xyes" ; then
303                AC_MSG_RESULT(no)
304        else
305                AC_MSG_RESULT(yes)
306        fi
307        ]
308)
309if test "x$found_pcsclite" != "xyes" ; then
310        AC_CHECK_LIB(pcsclite, SCardEstablishContext, , AC_MSG_ERROR([*** PC/SC Lite missing - please install first]))
311fi
312LIBS="$saved_LIBS"
313AM_CONDITIONAL(HAVE_PCSCLITE, test "x$ac_cv_lib_pcsclite_SCardEstablishContext" = "xyes")
314
315AC_SUBST(LIBDL)
316AC_CHECK_LIB(dl, dlopen, [LIBDL="$LIBDL -ldl" ac_cv_func_dlopen_ldl=yes], ac_cv_func_dlopen_ldl=no)
317
318AC_SUBST(LIBREADLINE)
319# libreadline will also need libtermcap on some OSes
320saved_LIBS="$LIBS"
321for add in "" "-ltermcap"; do
322        if test "X$add" != "X"; then
323                AC_MSG_CHECKING([whether -lreadline requires $add])
324        fi
325        LIBS="$saved_LIBS $add"
326        unset ac_cv_lib_readline_readline
327        AC_CHECK_LIB(readline, readline, [
328                LIBREADLINE="-lreadline $add"
329                ac_cv_func_readline_lreadline=yes
330        ], ac_cv_func_readline_lreadline=no)
331        test "$ac_cv_func_readline_lreadline" = yes && break
332done
333
334LIBS="$LIBS $LIBREADLINE"
335AC_CHECK_FUNCS(readline)
336LIBS="$saved_LIBS"
337
338dnl The big search for OpenSSL
339AC_ARG_WITH(ssl-dir,
340        [  --with-ssl-dir=PATH     Specify path to OpenSSL installation],
341        [
342                if test "x$withval" != "xno" ; then
343                        tryssldir=$withval
344                fi
345        ]
346)
347
348SSL_MSG="no"
349saved_LIBS="$LIBS"
350saved_LDFLAGS="$LDFLAGS"
351saved_CPPFLAGS="$CPPFLAGS"
352AC_SUBST(LIBCRYPTO)
353AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
354        for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
355                # Skip directories if they don't exist
356                if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
357                        continue;
358                fi
359                LIBCRYPTO="-lcrypto"
360                CPPFLAGS="$saved_CPPFLAGS"
361                LDFLAGS="$saved_LDFLAGS"
362                LIBS="$saved_LIBS $LIBCRYPTO"
363
364                if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
365                        # Try to use $ssldir/lib if it exists, otherwise
366                        # $ssldir
367                        if test -d "$ssldir/lib" ; then
368                                LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
369                                if test ! -z "$need_dash_r" ; then
370                                        LDFLAGS="-R$ssldir/lib $LDFLAGS"
371                                fi
372                        else
373                                LDFLAGS="-L$ssldir $saved_LDFLAGS"
374                                if test ! -z "$need_dash_r" ; then
375                                        LDFLAGS="-R$ssldir $LDFLAGS"
376                                fi
377                        fi
378                        # Try to use $ssldir/include if it exists, otherwise
379                        # $ssldir
380                        if test -d "$ssldir/include" ; then
381                                CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
382                        else
383                                CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
384                        fi
385                fi
386
387                # Basic test to check for compatible version and correct linking
388                # *does not* test for RSA - that comes later.
389                AC_TRY_RUN(
390                        [
391#include <string.h>
392#include <openssl/rand.h>
393int main(void)
394{
395        char a[2048];
396        memset(a, 0, sizeof(a));
397        RAND_add(a, sizeof(a), sizeof(a));
398        return(RAND_status() <= 0);
399}
400                        ],
401                        [
402                                found_crypto=1
403                                break;
404                        ], []
405                )
406
407                if test ! -z "$found_crypto" ; then
408                        break;
409                fi
410        done
411
412#       if test -z "$found_crypto" ; then
413#               AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
414#       fi
415        if test -n "$found_crypto" ; then
416                if test -z "$ssldir" ; then
417                        ssldir="(system)"
418                fi
419                ac_cv_openssldir=$ssldir
420                SSL_MSG="yes"
421        fi
422], [SSL_MSG=yes])
423
424if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then
425        dnl Need to recover ssldir - test above runs in subshell
426        ssldir=$ac_cv_openssldir
427        if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
428                # Try to use $ssldir/lib if it exists, otherwise
429                # $ssldir
430                if test -d "$ssldir/lib" ; then
431                        LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
432                        if test ! -z "$need_dash_r" ; then
433                                LDFLAGS="-R$ssldir/lib $LDFLAGS"
434                        fi
435                else
436                        LDFLAGS="-L$ssldir $saved_LDFLAGS"
437                        if test ! -z "$need_dash_r" ; then
438                                LDFLAGS="-R$ssldir $LDFLAGS"
439                        fi
440                fi
441                # Try to use $ssldir/include if it exists, otherwise
442                # $ssldir
443                if test -d "$ssldir/include" ; then
444                        CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
445                else
446                        CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
447                fi
448        fi
449fi
450LIBS="$saved_LIBS"
451if test "x$SSL_MSG" = "xyes" ; then
452  AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL libraries])
453fi
454AM_CONDITIONAL(HAVE_SSL, test "x$SSL_MSG" = "xyes")
455
456dnl Check for PAM libs
457PAM_MSG="no"
458no_pam=""
459AC_SUBST(LIBPAM)
460saved_LIBS="$LIBS"
461AC_MSG_CHECKING([PAM support])
462AC_ARG_WITH(pam,
463        [  --with-pam              Enable PAM support],
464        [
465                if test "x$withval" = "xno" ; then
466                        AC_MSG_RESULT(disabled)
467                        no_pam=1
468                fi
469        ],
470)
471if test -z "$no_pam" ; then
472        if test "x$ac_cv_header_security_pam_appl_h" = "xyes" ; then
473                AC_MSG_RESULT(yes)
474                PAM_MSG="yes"
475                AC_CHECK_LIB(pam, pam_set_item, [LIBPAM="$LIBPAM -lpam"], AC_MSG_ERROR([*** libpam missing]))
476                LIBS="$LIBS $LIBPAM"
477                AC_CHECK_FUNCS(pam_getenvlist)
478                AC_CHECK_FUNCS(pam_putenv)
479                disable_shadow=yes
480                AC_DEFINE(HAVE_PAM, 1, [Have Pluggable Authentication Modules])
481        else
482                AC_MSG_RESULT(no)
483        fi
484fi
485
486dnl Check for older PAM
487if test "x$PAM_MSG" = "xyes" ; then
488        # Check PAM strerror arguments (old PAM)
489        AC_MSG_CHECKING([whether pam_strerror takes only one argument])
490        AC_TRY_COMPILE(
491                [
492#include <stdlib.h>
493#include <security/pam_appl.h>
494                ],
495                [(void)pam_strerror((pam_handle_t *)NULL, -1);],
496                [AC_MSG_RESULT(no)],
497                [
498                        AC_DEFINE(HAVE_OLD_PAM, 1, [Have OLD Pluggable Authentication Modules])
499                        AC_MSG_RESULT(yes)
500                        PAM_MSG="yes (old library)"
501                ]
502        )
503fi
504LIBS="$saved_LIBS"
505AM_CONDITIONAL(HAVE_PAM, test "x$PAM_MSG" = "xyes")
506AM_CONDITIONAL(HAVE_PAM_AND_SSL, test "x$PAM_MSG" = "xyes" -a "x$SSL_MSG" = "xyes")
507
508dnl Enable/disable debugging messages.
509AC_ARG_ENABLE(debug,
510[  --enable-debug          enable debug messages. [default=no]],
511        , enable_debug=no)
512if (test x$enable_debug = xyes); then
513        AC_DEFINE(DEBUG, 1, [Enable debug messages.])
514fi
515
516AC_SUBST(CFLAGS_OPENSC)
517CFLAGS_OPENSC="-I\${top_srcdir}/src/libopensc"
518AC_SUBST(LIBOPENSC)
519LIBOPENSC="\${top_srcdir}/src/libopensc/libopensc.la"
520
521# Pass information about installed OpenSC requirements, so that
522# a proper opensc-config file will be build.
523OPENSC_LIBS="-L${libdir} -lopensc"
524OPENSC_CFLAGS=""
525AC_SUBST(OPENSC_LIBS)
526AC_SUBST(OPENSC_CFLAGS)
527
528AC_OUTPUT([
529Makefile
530aclocal/Makefile
531docs/Makefile
532src/Makefile
533src/common/Makefile
534src/libopensc/Makefile
535src/libopensc/opensc-config
536src/openssh/Makefile
537src/pam/Makefile
538src/pkcs11/Makefile
539src/pkcs11/rsaref/Makefile
540src/tests/Makefile
541src/tools/Makefile
542])
543
544dnl Someone please show me a better way :)
545A=`eval echo ${prefix}` ; A=`eval echo ${A}`
546B=`eval echo ${bindir}` ; B=`eval echo ${B}`
547
548echo ""
549echo "OpenSC has been configured with the following options"
550
551echo ""
552echo "User binaries:       ${B}"
553
554echo ""
555echo "Host:                ${host}"
556echo "Compiler:            ${CC}"
557echo "Compiler flags:      ${CFLAGS}"
558echo "Preprocessor flags:  ${CPPFLAGS}"
559echo "Linker flags:        ${LDFLAGS}"
560echo "Libraries:           ${LIBS}"
561
562echo ""
563echo "OpenSSL support:     ${SSL_MSG}"
564echo "PAM support:         ${PAM_MSG}"
565
566echo ""
Note: See TracBrowser for help on using the browser.