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