| 1 | dnl $Id: configure.in,v 1.15 2007/10/11 01:46:34 mrsam Exp $ |
| 2 | dnl |
| 3 | dnl Copyright 1998 - 2004 Double Precision, Inc. See COPYING for |
| 4 | dnl distribution information. |
| 5 | dnl $Id: configure.in,v 1.15 2007/10/11 01:46:34 mrsam Exp $ |
| 6 | |
| 7 | AC_PREREQ(2.59) |
| 8 | AC_INIT(liblock, 0.60, courier-users@lists.sourceforge.net) |
| 9 | |
| 10 | >confdefs.h # Kill PACKAGE_ macros |
| 11 | |
| 12 | AC_CONFIG_SRCDIR([liblock.h]) |
| 13 | AM_CONFIG_HEADER([config.h]) |
| 14 | AM_INIT_AUTOMAKE([foreign no-define]) |
| 15 | |
| 16 | dnl Checks for programs. |
| 17 | AC_PROG_AWK |
| 18 | AC_PROG_CC |
| 19 | AC_PROG_INSTALL |
| 20 | AC_PROG_LN_S |
| 21 | AC_PROG_LIBTOOL |
| 22 | |
| 23 | dnl Checks for libraries. |
| 24 | |
| 25 | dnl Checks for header files. |
| 26 | AC_CHECK_HEADERS(errno.h fcntl.h sys/fcntl.h sys/ioctl.h sys/file.h unistd.h sysexits.h) |
| 27 | AC_HEADER_STDC |
| 28 | AC_HEADER_SYS_WAIT |
| 29 | |
| 30 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 31 | |
| 32 | AC_C_CONST |
| 33 | AC_TYPE_OFF_T |
| 34 | AC_TYPE_PID_T |
| 35 | AC_TYPE_SIGNAL |
| 36 | |
| 37 | AC_CACHE_CHECK( [for off64_t], liblock_cv_hasoff64t, |
| 38 | |
| 39 | liblock_cv_hasoff64t="no" |
| 40 | AC_TRY_COMPILE([ |
| 41 | #include <sys/types.h> |
| 42 | ],[ |
| 43 | off64_t n; |
| 44 | |
| 45 | n=0; |
| 46 | ], liblock_cv_hasoff64t="yes") |
| 47 | |
| 48 | ) |
| 49 | |
| 50 | if test "$liblock_cv_hasoff64t" = "yes" |
| 51 | then |
| 52 | LL_OFFSET_TYPE=off64_t |
| 53 | else |
| 54 | LL_OFFSET_TYPE=off_t |
| 55 | fi |
| 56 | AC_DEFINE_UNQUOTED(LL_OFFSET_TYPE,$LL_OFFSET_TYPE, |
| 57 | [ Either off64_t or off_t ]) |
| 58 | |
| 59 | AC_CACHE_CHECK( [for flock_t], liblock_cv_hasflock_t, |
| 60 | liblock_cv_hasflock_t="no" |
| 61 | AC_TRY_COMPILE([ |
| 62 | #if HAVE_CONFIG_H |
| 63 | #include "config.h" |
| 64 | #endif |
| 65 | #include <sys/types.h> |
| 66 | #if HAVE_FCNTL_H |
| 67 | #include <fcntl.h> |
| 68 | #endif |
| 69 | #if HAVE_SYS_FCNTL_H |
| 70 | #include <sys/fcntl.h> |
| 71 | #endif |
| 72 | ],[ |
| 73 | flock_t t; |
| 74 | ], liblock_cv_hasflock_t="yes")) |
| 75 | |
| 76 | if test "$liblock_cv_hasflock_t" = "yes" |
| 77 | then |
| 78 | AC_DEFINE_UNQUOTED(HAS_FLOCK_T,1,[ Whether flock_t is defined ]) |
| 79 | fi |
| 80 | |
| 81 | dnl Checks for library functions. |
| 82 | |
| 83 | AC_CHECK_FUNCS(getdtablesize setpgrp sysconf) |
| 84 | AC_CHECK_FUNC(setpgrp, |
| 85 | [ |
| 86 | AC_FUNC_SETPGRP |
| 87 | ] |
| 88 | ) |
| 89 | |
| 90 | AC_CACHE_CHECK( [for fcntl], liblock_cv_hasfcntl, |
| 91 | liblock_cv_hasfcntl="no" |
| 92 | AC_TRY_LINK([ |
| 93 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 94 | #include "${srcdir}/lockfcntl.c" |
| 95 | ],[ |
| 96 | int n; |
| 97 | ], liblock_cv_hasfcntl="yes")) |
| 98 | if test "$liblock_cv_hasfcntl" = "yes" |
| 99 | then |
| 100 | AC_DEFINE_UNQUOTED(HAS_FCNTL,1, |
| 101 | [ Whether fcntl() available ]) |
| 102 | fi |
| 103 | |
| 104 | AC_CACHE_CHECK( [for flock], liblock_cv_hasflock, |
| 105 | liblock_cv_hasflock="no" |
| 106 | AC_TRY_LINK([ |
| 107 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 108 | #include "${srcdir}/lockflock.c" |
| 109 | ],[ |
| 110 | int n; |
| 111 | ], liblock_cv_hasflock="yes")) |
| 112 | if test "$liblock_cv_hasflock" = "yes" |
| 113 | then |
| 114 | AC_DEFINE_UNQUOTED(HAS_FLOCK,1, |
| 115 | [ Whether flock() is available ]) |
| 116 | fi |
| 117 | |
| 118 | AC_CACHE_CHECK( [for lockf], liblock_cv_haslockf, |
| 119 | liblock_cv_haslockf="no" |
| 120 | AC_TRY_LINK([ |
| 121 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 122 | #include "${srcdir}/locklockf.c" |
| 123 | ],[ |
| 124 | int n; |
| 125 | ], liblock_cv_haslockf="yes")) |
| 126 | if test "$liblock_cv_haslockf" = "yes" |
| 127 | then |
| 128 | AC_DEFINE_UNQUOTED(HAS_LOCKF,1, |
| 129 | [ Whether lockf() is available ]) |
| 130 | fi |
| 131 | |
| 132 | AC_MSG_CHECKING(for locking method) |
| 133 | AC_ARG_WITH(locking-method, [], lockmethod="$withval", lockmethod="") |
| 134 | |
| 135 | case x$lockmethod in |
| 136 | xfcntl) |
| 137 | AC_TRY_RUN([ |
| 138 | #define USE_FCNTL 1 |
| 139 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 140 | #include "${srcdir}/locktest.c" |
| 141 | ], , AC_MSG_ERROR(fcntl test failed.), |
| 142 | : |
| 143 | ) |
| 144 | ;; |
| 145 | x) |
| 146 | AC_TRY_RUN([ |
| 147 | #define USE_FCNTL 1 |
| 148 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 149 | #include "${srcdir}/locktest.c" |
| 150 | ], lockmethod=fcntl, ,AC_MSG_ERROR(--with-locking-method option required)) |
| 151 | ;; |
| 152 | esac |
| 153 | |
| 154 | case x$lockmethod in |
| 155 | xlockf) |
| 156 | AC_TRY_RUN([ |
| 157 | #define USE_LOCKF 1 |
| 158 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 159 | #include "${srcdir}/locktest.c" |
| 160 | ], , AC_MSG_ERROR(lockf test failed.), |
| 161 | : |
| 162 | ) |
| 163 | ;; |
| 164 | x) |
| 165 | AC_TRY_RUN([ |
| 166 | #define USE_LOCKF 1 |
| 167 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 168 | #include "${srcdir}/locktest.c" |
| 169 | ], lockmethod=lockf, , AC_MSG_ERROR(--with-locking-method option required)) |
| 170 | ;; |
| 171 | esac |
| 172 | |
| 173 | |
| 174 | case x$lockmethod in |
| 175 | xflock) |
| 176 | AC_TRY_RUN([ |
| 177 | #define USE_FLOCK 1 |
| 178 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 179 | #include "${srcdir}/locktest.c" |
| 180 | ], , AC_MSG_ERROR(flock test failed.), |
| 181 | : |
| 182 | ) |
| 183 | ;; |
| 184 | x) |
| 185 | AC_TRY_RUN([ |
| 186 | #define USE_FLOCK 1 |
| 187 | #define LL_OFFSET_TYPE $LL_OFFSET_TYPE |
| 188 | #include "${srcdir}/locktest.c" |
| 189 | ], lockmethod=flock, , AC_MSG_ERROR(--with-locking-method option required)) |
| 190 | ;; |
| 191 | esac |
| 192 | |
| 193 | case x$lockmethod in |
| 194 | xlockf) |
| 195 | ;; |
| 196 | xflock) |
| 197 | ;; |
| 198 | xfcntl) |
| 199 | ;; |
| 200 | *) |
| 201 | AC_MSG_ERROR(must specify --with-locking-method option) |
| 202 | ;; |
| 203 | esac |
| 204 | |
| 205 | AC_MSG_RESULT($lockmethod) |
| 206 | |
| 207 | AM_CONDITIONAL(USE_FCNTL, test "$lockmethod" = "fcntl") |
| 208 | AM_CONDITIONAL(USE_FLOCK, test "$lockmethod" = "flock") |
| 209 | AM_CONDITIONAL(USE_LOCKF, test "$lockmethod" = "lockf") |
| 210 | |
| 211 | AM_CONDITIONAL(HAVE_SGML, test -d ${srcdir}/../docbook) |
| 212 | |
| 213 | AC_DEFINE_UNQUOTED(liblock_config_h,1, [liblock/config.h has been read]) |
| 214 | |
| 215 | AC_OUTPUT(Makefile) |