root/releases/opensc-0.4.0/configure.in

Revision 114, 12.0 KB (checked in by aet, 7 years ago)

Use -Werror if compiling with gcc
Add check for getopt.h

  • 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.4.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
148dnl Checks for library functions.
149AC_FUNC_ERROR_AT_LINE
150AC_FUNC_MALLOC
151AC_FUNC_MEMCMP
152AC_FUNC_STAT
153AC_FUNC_VPRINTF
154AC_CHECK_FUNCS([getpass gettimeofday memset mkdir strdup strerror])
155
156dnl C Compiler features
157AC_C_INLINE
158if test "$GCC" = "yes"; then
159        CFLAGS="$CFLAGS -Wall -Werror"
160fi
161
162dnl OS specific options
163case "$host_os" in
164  hpux*)
165    CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
166    ;;
167  osf*)
168    CFLAGS="$CFLAGS -D_POSIX_PII_SOCKET"
169    ;;
170  *)
171    ;;
172esac
173
174AC_ARG_WITH(common-dir,
175        [  --with-common-dir=PATH  Specify path for common installation libraries],
176        [
177                if test "x$withval" != "xno" ; then
178                        trycommondir=$withval
179                fi
180        ]
181)
182
183saved_LDFLAGS="$LDFLAGS"
184saved_CPPFLAGS="$CPPFLAGS"
185AC_CACHE_CHECK([for common directory], ac_cv_commondir, [
186        for commondir in $trycommondir "" /usr/local /usr/pkg /opt ; do
187                # Skip directories if they don't exist
188                if test ! -z "$commondir" -a ! -d "$commondir" ; then
189                        continue;
190                fi
191                CPPFLAGS="$saved_CPPFLAGS"
192                LDFLAGS="$saved_LDFLAGS"
193
194                if test ! -z "$commondir" -a "x$commondir" != "x/usr"; then
195                        # Try to use $commondir/lib if it exists, otherwise
196                        # $commondir
197                        if test -d "$commondir/lib" ; then
198                                LDFLAGS="-L$commondir/lib $saved_LDFLAGS"
199                                if test ! -z "$need_dash_r" ; then
200                                        LDFLAGS="-R$commondir/lib $LDFLAGS"
201                                fi
202                        else
203                                LDFLAGS="-L$commondir $saved_LDFLAGS"
204                                if test ! -z "$need_dash_r" ; then
205                                        LDFLAGS="-R$commondir $LDFLAGS"
206                                fi
207                        fi
208                        # Try to use $commondir/include if it exists, otherwise
209                        # $commondir
210                        if test -d "$commondir/include" ; then
211                                CPPFLAGS="-I$commondir/include $saved_CPPFLAGS"
212                        else
213                                CPPFLAGS="-I$commondir $saved_CPPFLAGS"
214                        fi
215                fi
216                break;
217        done
218
219        if test -z "$commondir" ; then
220                commondir="(system)"
221        fi
222
223        ac_cv_commondir=$commondir
224])
225
226if (test ! -z "$ac_cv_commondir" && test "x$ac_cv_commondir" != "x(system)") ; then
227        dnl Need to recover commondir - test above runs in subshell
228        commondir=$ac_cv_commondir
229        if test ! -z "$commondir" -a "x$commondir" != "x/usr"; then
230                # Try to use $commondir/lib if it exists, otherwise
231                # $commondir
232                if test -d "$commondir/lib" ; then
233                        LDFLAGS="-L$commondir/lib $saved_LDFLAGS"
234                        if test ! -z "$need_dash_r" ; then
235                                LDFLAGS="-R$commondir/lib $LDFLAGS"
236                        fi
237                else
238                        LDFLAGS="-L$commondir $saved_LDFLAGS"
239                        if test ! -z "$need_dash_r" ; then
240                                LDFLAGS="-R$commondir $LDFLAGS"
241                        fi
242                fi
243                # Try to use $commondir/include if it exists, otherwise
244                # $commondir
245                if test -d "$commondir/include" ; then
246                        CPPFLAGS="-I$commondir/include $saved_CPPFLAGS"
247                else
248                        CPPFLAGS="-I$commondir $saved_CPPFLAGS"
249                fi
250        fi
251fi
252
253AC_SUBST(LIBPCSC)
254LIBPCSC="-lpcsclite"
255found_pcsclite=no
256saved_LIBS="$LIBS"
257saved_LDFLAGS="$LDFLAGS"
258saved_CPPFLAGS="$CPPFLAGS"
259AC_ARG_WITH(pcsclite,
260        [  --with-pcsclite=PATH    use PC/SC Lite in PATH],
261        [
262        for pcscdir in /pcsc ""; do
263                CPPFLAGS="$saved_CPPFLAGS"
264                LDFLAGS="$saved_LDFLAGS"
265                LIBS="$saved_LIBS"
266
267                if test -d "$withval/lib$pcscdir"; then
268                        if test -n "${need_dash_r}"; then
269                                LDFLAGS="-L${withval}/lib${pcscdir}/ -R${withval}/lib${pcscdir}/ ${LDFLAGS}"
270                        else
271                                LDFLAGS="-L${withval}/lib${pcscdir} ${LDFLAGS}"
272                        fi
273                else
274                        if test -n "${need_dash_r}"; then
275                                LDFLAGS="-L${withval}${pcscdir} -R${withval}${pcscdir} ${LDFLAGS}"
276                        else
277                                LDFLAGS="-L${withval}${pcscdir} ${LDFLAGS}"
278                        fi
279                fi
280                if test -d "$withval/include"; then
281                        CPPFLAGS="-I${withval}/include${pcscdir} ${CPPFLAGS}"
282                else
283                        CPPFLAGS="-I${withval}${pcscdir} ${CPPFLAGS}"
284                fi
285                AC_CHECK_LIB(pcsclite, SCardEstablishContext, found_pcsclite=yes, found_pcsclite=no)
286                if test "x$found_pcsclite" = "xyes" ; then
287                        break;
288                fi
289        done
290        ]
291)
292if test "x$found_pcsclite" != "xyes" ; then
293        AC_CHECK_LIB(pcsclite, SCardEstablishContext, , AC_MSG_ERROR([*** PC/SC Lite missing - please install first]))
294fi
295LIBS="$saved_LIBS"
296AM_CONDITIONAL(HAVE_PCSCLITE, test "x$found_pcsclite" = "xyes")
297
298AC_SUBST(LIBDL)
299AC_CHECK_LIB(dl, dlopen, [LIBDL="$LIBDL -ldl" ac_cv_func_dlopen_ldl=yes], ac_cv_func_dlopen_ldl=no)
300
301dnl The big search for OpenSSL
302AC_ARG_WITH(ssl-dir,
303        [  --with-ssl-dir=PATH     Specify path to OpenSSL installation],
304        [
305                if test "x$withval" != "xno" ; then
306                        tryssldir=$withval
307                fi
308        ]
309)
310
311SSL_MSG="no"
312saved_LIBS="$LIBS"
313saved_LDFLAGS="$LDFLAGS"
314saved_CPPFLAGS="$CPPFLAGS"
315AC_SUBST(LIBCRYPTO)
316AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
317        for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
318                # Skip directories if they don't exist
319                if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
320                        continue;
321                fi
322                LIBCRYPTO="-lcrypto"
323                CPPFLAGS="$saved_CPPFLAGS"
324                LDFLAGS="$saved_LDFLAGS"
325                LIBS="$saved_LIBS $LIBCRYPTO"
326
327                if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
328                        # Try to use $ssldir/lib if it exists, otherwise
329                        # $ssldir
330                        if test -d "$ssldir/lib" ; then
331                                LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
332                                if test ! -z "$need_dash_r" ; then
333                                        LDFLAGS="-R$ssldir/lib $LDFLAGS"
334                                fi
335                        else
336                                LDFLAGS="-L$ssldir $saved_LDFLAGS"
337                                if test ! -z "$need_dash_r" ; then
338                                        LDFLAGS="-R$ssldir $LDFLAGS"
339                                fi
340                        fi
341                        # Try to use $ssldir/include if it exists, otherwise
342                        # $ssldir
343                        if test -d "$ssldir/include" ; then
344                                CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
345                        else
346                                CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
347                        fi
348                fi
349
350                # Basic test to check for compatible version and correct linking
351                # *does not* test for RSA - that comes later.
352                AC_TRY_RUN(
353                        [
354#include <string.h>
355#include <openssl/rand.h>
356int main(void)
357{
358        char a[2048];
359        memset(a, 0, sizeof(a));
360        RAND_add(a, sizeof(a), sizeof(a));
361        return(RAND_status() <= 0);
362}
363                        ],
364                        [
365                                found_crypto=1
366                                break;
367                        ], []
368                )
369
370                if test ! -z "$found_crypto" ; then
371                        break;
372                fi
373        done
374
375        if test -n "$found_crypto" ; then
376                if test -z "$ssldir" ; then
377                        ssldir="(system)"
378                fi
379                ac_cv_openssldir=$ssldir
380                SSL_MSG="yes"
381        fi
382])
383
384if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then
385        AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL libraries])
386        dnl Need to recover ssldir - test above runs in subshell
387        ssldir=$ac_cv_openssldir
388        if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
389                # Try to use $ssldir/lib if it exists, otherwise
390                # $ssldir
391                if test -d "$ssldir/lib" ; then
392                        LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
393                        if test ! -z "$need_dash_r" ; then
394                                LDFLAGS="-R$ssldir/lib $LDFLAGS"
395                        fi
396                else
397                        LDFLAGS="-L$ssldir $saved_LDFLAGS"
398                        if test ! -z "$need_dash_r" ; then
399                                LDFLAGS="-R$ssldir $LDFLAGS"
400                        fi
401                fi
402                # Try to use $ssldir/include if it exists, otherwise
403                # $ssldir
404                if test -d "$ssldir/include" ; then
405                        CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
406                else
407                        CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
408                fi
409        fi
410fi
411LIBS="$saved_LIBS"
412AM_CONDITIONAL(HAVE_SSL, test "x$SSL_MSG" = "xyes")
413
414dnl Check for PAM libs
415PAM_MSG="no"
416no_pam=""
417AC_SUBST(LIBPAM)
418saved_LIBS="$LIBS"
419AC_MSG_CHECKING([PAM support])
420AC_ARG_WITH(pam,
421        [  --with-pam              Enable PAM support],
422        [
423                if test "x$withval" = "xno" ; then
424                        AC_MSG_RESULT(disabled)
425                        no_pam=1
426                fi
427        ],
428)
429if test -z "$no_pam" ; then
430        if test "x$ac_cv_header_security_pam_appl_h" = "xyes" ; then
431                AC_MSG_RESULT(yes)
432                PAM_MSG="yes"
433                AC_CHECK_LIB(pam, pam_set_item, [LIBPAM="$LIBPAM -lpam"], AC_MSG_ERROR([*** libpam missing]))
434                LIBS="$LIBS $LIBPAM"
435                AC_CHECK_FUNCS(pam_getenvlist)
436                AC_CHECK_FUNCS(pam_putenv)
437                disable_shadow=yes
438                AC_DEFINE(HAVE_PAM, 1, [Have Pluggable Authentication Modules])
439        else
440                AC_MSG_RESULT(no)
441        fi
442fi
443
444dnl Check for older PAM
445if test "x$PAM_MSG" = "xyes" ; then
446        # Check PAM strerror arguments (old PAM)
447        AC_MSG_CHECKING([whether pam_strerror takes only one argument])
448        AC_TRY_COMPILE(
449                [
450#include <stdlib.h>
451#include <security/pam_appl.h>
452                ],
453                [(void)pam_strerror((pam_handle_t *)NULL, -1);],
454                [AC_MSG_RESULT(no)],
455                [
456                        AC_DEFINE(HAVE_OLD_PAM, 1, [Have OLD Pluggable Authentication Modules])
457                        AC_MSG_RESULT(yes)
458                        PAM_MSG="yes (old library)"
459                ]
460        )
461fi
462LIBS="$saved_LIBS"
463AM_CONDITIONAL(HAVE_PAM, test "x$PAM_MSG" = "xyes")
464AM_CONDITIONAL(HAVE_PAM_AND_SSL, test "x$PAM_MSG" = "xyes" -a "x$SSL_MSG" = "xyes")
465
466dnl Enable/disable debugging messages.
467AC_ARG_ENABLE(debug,
468[  --enable-debug          enable debug messages. [default=no]],
469        , enable_debug=no)
470if (test x$enable_debug = xyes); then
471        AC_DEFINE(DEBUG, 1, [Enable debug messages.])
472fi
473
474AC_OUTPUT([
475Makefile
476aclocal/Makefile
477src/Makefile
478src/libopensc/Makefile
479src/openssh/Makefile
480src/pam/Makefile
481src/pkcs11/Makefile
482src/pkcs11/pkcs11/Makefile
483src/tests/Makefile
484src/tools/Makefile
485])
486
487dnl Someone please show me a better way :)
488A=`eval echo ${prefix}` ; A=`eval echo ${A}`
489B=`eval echo ${bindir}` ; B=`eval echo ${B}`
490
491echo ""
492echo "OpenSC has been configured with the following options"
493
494echo ""
495echo "User binaries:       ${B}"
496
497echo ""
498echo "Host:                ${host}"
499echo "Compiler:            ${CC}"
500echo "Compiler flags:      ${CFLAGS}"
501echo "Preprocessor flags:  ${CPPFLAGS}"
502echo "Linker flags:        ${LDFLAGS}"
503echo "Libraries:           ${LIBS}"
504
505echo ""
506echo "OpenSSL support:     ${SSL_MSG}"
507echo "PAM support:         ${PAM_MSG}"
508
509echo ""
Note: See TracBrowser for help on using the browser.