695ca8de088e036f98df61b5d5b4bf58a00bdbe9
[pinentry.git] / configure.in.in
1 #MIN_CONFIG
2         
3 AM_INIT_AUTOMAKE(pinentry,0.1)
4
5 AC_PATH_PROG(SETCAP, setcap, no, "$PATH:/sbin:/usr/sbin")
6 AC_CHECK_LIB(cap, cap_set_proc, [
7   AC_DEFINE(USE_CAPABILITIES)
8   LIBCAP=-lcap
9 ])
10 AC_SUBST(LIBCAP)
11
12
13 dnl Check for assuan library
14 AC_DEFUN(AC_PATH_ASSUAN,
15 [
16         LIBASSUAN="-lassuan"
17         AC_MSG_CHECKING([for assuan])
18         ac_assuan_includes=NO
19         ac_assuan_libraries=NO
20         assuan_libraries=""
21         assuan_includes=""
22         AC_ARG_WITH(assuan-dir,
23                 [  --with-assuan-dir=DIR   path to assuan lib and include files],
24                 [  ac_assuan_includes="$withval"
25                    ac_assuan_libraries="$withval"
26                 ])
27         assuan_incdirs="$ac_assuan_includes /usr/include /usr/local/include /opt/include $prefix/include"
28         AC_FIND_FILE(assuan.h,$assuan_incdirs,assuan_incdir)
29         ac_assuan_includes="$assuan_incdir"
30
31         assuan_libdirs="/usr/lib /usr/local/lib /opt/lib $prefix/lib"
32         if test ! "$ac_assuan_libraries" = "NO" ; then
33                 assuan_libdirs="$ac_assuan_libraries $assuan_libdirs"
34         fi
35         assuan_libdir=NONE
36         save_cflags="$CFLAGS"
37         CFLAGS="-I$ac_assuan_includes $CFLAGS"
38         for dir in $assuan_libdirs; do
39                 save_ldflags="$LDFLAGS"
40                 LDFLAGS="-L$dir $LDFLAGS"
41                 AC_TRY_LINK([
42                 #include <stdio.h> 
43                 #include <assuan.h>],,[ assuan_libdir=$dir; break; ])
44                 LDFLAGS="$save_ldflags"
45         done
46         LDFLAGS="$save_ldflags"
47         CFLAGS="$save_cflags"
48         
49         ac_assuan_libraries="$assuan_libdir"
50
51         if test "$ac_assuan_includes" = "NO" || test "$ac_assuan_libraries" = "NO"; then
52                 AC_MSG_RESULT([Could not find assuan])
53                 exit -1
54         else
55             ASSUAN_INCLUDES="-I$ac_assuan_includes "
56             ASSUAN_LDFLAGS="-L$ac_assuan_libraries -lassuan"
57         fi
58         AC_MSG_RESULT([yes])
59
60 AC_SUBST(ASSUAN_INCLUDES)
61 AC_SUBST(ASSUAN_LDFLAGS)
62 AC_SUBST(LIBASSUAN)
63 ])
64
65 AC_PATH_ASSUAN
66
67 AC_CHECK_FUNCS(getdelim seteuid strsignal vsnprintf)
68 AC_REPLACE_FUNCS(asprintf getline setenv strdup)
69
70 dnl this one stolen from GnuPG
71 ######################################################################
72 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
73 # is not called from uid 0 (not tested whether uid 0 works)
74 ######################################################################
75 dnl GNUPG_CHECK_MLOCK
76 dnl
77 AC_DEFUN(GNUPG_CHECK_MLOCK,
78   [ AC_CHECK_FUNCS(mlock)
79     if test "$ac_cv_func_mlock" = "yes"; then
80         AC_MSG_CHECKING(whether mlock is broken)
81           AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
82              AC_TRY_RUN([
83                 #include <stdlib.h>
84                 #include <unistd.h>
85                 #include <errno.h>
86                 #include <sys/mman.h>
87                 #include <sys/types.h>
88                 #include <fcntl.h>
89  
90                 int main()
91                 {
92                     char *pool;
93                     int err;
94                     long int pgsize = getpagesize();
95  
96                     pool = malloc( 4096 + pgsize );
97                     if( !pool )
98                         return 2;
99                     pool += (pgsize - ((long int)pool % pgsize));
100  
101                     err = mlock( pool, 4096 );
102                     if( !err || errno == EPERM )
103                         return 0; /* okay */
104  
105                     return 1;  /* hmmm */
106                 }
107  
108             ],
109             gnupg_cv_have_broken_mlock="no",
110             gnupg_cv_have_broken_mlock="yes",
111             gnupg_cv_have_broken_mlock="assume-no"
112            )
113          )
114          if test "$gnupg_cv_have_broken_mlock" = "yes"; then
115              AC_DEFINE(HAVE_BROKEN_MLOCK)
116              AC_MSG_RESULT(yes)
117          else
118             if test "$gnupg_cv_have_broken_mlock" = "no"; then
119                 AC_MSG_RESULT(no)
120             else
121                 AC_MSG_RESULT(assuming no)
122             fi
123          fi
124     fi
125   ])
126
127 GNUPG_CHECK_MLOCK
128