]> git.sur5r.net Git - openldap/blob - build/openldap.m4
Minor change to signal handler. Changed _shutdown flag to
[openldap] / build / openldap.m4
1 dnl
2 dnl OpenLDAP Autoconf Macros
3 dnl
4 dnl builtin(include, build/libtool.m4)dnl
5 dnl --------------------------------------------------------------------
6 dnl Restricted form of AC_ARG_ENABLE that limits user options
7 dnl
8 dnl $1 = option name
9 dnl $2 = help-string
10 dnl $3 = default value  (auto)
11 dnl $4 = allowed values (auto yes no)
12 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
13         AC_ARG_ENABLE($1,[$2 (]ifelse($3,,auto,$3)[)],[
14         ol_arg=invalid
15         for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
16                 if test "$enableval" = "$ol_val" ; then
17                         ol_arg="$ol_val"
18                 fi
19         done
20         if test "$ol_arg" = "invalid" ; then
21                 AC_MSG_ERROR(bad value $enableval for --enable-$1)
22         fi
23         ol_enable_$1="$ol_arg"
24 ],
25 [       ol_enable_$1=ifelse($3,,"auto","$3")])dnl
26 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
27 # end --enable-$1
28 ])dnl
29 dnl
30 dnl --------------------------------------------------------------------
31 dnl Restricted form of AC_ARG_WITH that limits user options
32 dnl
33 dnl $1 = option name
34 dnl $2 = help-string
35 dnl $3 = default value (no)
36 dnl $4 = allowed values (yes or no)
37 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
38         AC_ARG_WITH($1,[$2 (]ifelse($3,,yes,$3)[)],[
39         ol_arg=invalid
40         for ol_val in ifelse($4,,[yes no],[$4]) ; do
41                 if test "$withval" = "$ol_val" ; then
42                         ol_arg="$ol_val"
43                 fi
44         done
45         if test "$ol_arg" = "invalid" ; then
46                 AC_MSG_ERROR(bad value $withval for --with-$1)
47         fi
48         ol_with_$1="$ol_arg"
49 ],
50 [       ol_with_$1=ifelse($3,,"no","$3")])dnl
51 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
52 # end --with-$1
53 ])dnl
54 dnl
55 dnl ====================================================================
56 dnl Check if db.h is Berkeley DB2
57 dnl
58 dnl defines ol_cv_header_db2 to 'yes' or 'no'
59 dnl
60 dnl uses:
61 dnl             AC_CHECK_HEADERS(db.h)
62 dnl
63 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
64 [AC_CHECK_HEADERS(db.h)
65 if test $ac_cv_header_db_h = yes ; then
66         AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
67                 AC_EGREP_CPP(__db_version_2,[
68 #                       include <db.h>
69                         /* this check could be improved */
70 #                       ifdef DB_VERSION_MAJOR
71 #                               if DB_VERSION_MAJOR == 2
72                                         __db_version_2
73 #                               endif
74 #                       endif
75                 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
76 else
77         ol_cv_header_db2=no
78 fi
79 ])dnl
80 dnl --------------------------------------------------------------------
81 dnl Check if Berkeley DB2 library exists
82 dnl Check for dbopen in standard libraries or -ldb
83 dnl
84 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
85 dnl
86 dnl uses:
87 dnl             AC_CHECK_LIB(db,db_open)
88 dnl
89 AC_DEFUN([OL_LIB_BERKELEY_DB2],
90 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
91 [       ol_LIBS="$LIBS"
92         AC_CHECK_LIB(db,db_open,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
93         LIBS="$ol_LIBS"
94 ])
95 ])dnl
96 dnl
97 dnl --------------------------------------------------------------------
98 dnl Check if Berkeley db2 exists
99 dnl
100 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
101 dnl 
102 dnl uses:
103 dnl             OL_LIB_BERKELEY_DB2
104 dnl             OL_HEADER_BERKELEY_DB2
105 dnl
106 AC_DEFUN([OL_BERKELEY_DB2],
107 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
108  AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
109  AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
110         if test $ol_cv_lib_db2 = no -o $ol_cv_header_db2 = no ; then
111                 ol_cv_berkeley_db2=no
112         else
113                 ol_cv_berkeley_db2=yes
114         fi
115 ])
116  if test $ol_cv_berkeley_db2 = yes ; then
117         AC_DEFINE(HAVE_BERKELEY_DB2,1)
118  fi
119 ])dnl
120 dnl
121 dnl ====================================================================
122 dnl Check for db.h/db_185.h is Berkeley DB
123 dnl
124 dnl defines ol_cv_header_db to 'yes' or 'no'
125 dnl
126 dnl uses:
127 dnl             OL_HEADER_BERKELEY_DB2
128 dnl             AC_CHECK_HEADERS(db_185.h)
129 dnl
130 AC_DEFUN([OL_HEADER_BERKELEY_DB],
131 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
132 AC_CHECK_HEADERS(db_185.h)
133 if test $ol_cv_header_db2 = yes ; then
134         dnl db.h is db2! 
135
136         ol_cv_header_db=$ac_cv_header_db_185_h
137 else
138         ol_cv_header_db=$ac_cv_header_db_h
139 fi
140 ])dnl
141 dnl
142 dnl --------------------------------------------------------------------
143 dnl Check if Berkeley DB library exists
144 dnl Check for dbopen in standard libraries or -ldb
145 dnl
146 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
147 dnl             'yes' implies dbopen is in $LIBS
148 dnl
149 dnl uses:
150 dnl             AC_CHECK_FUNC(dbopen)
151 dnl             AC_CHECK_LIB(db,dbopen)
152 dnl
153 AC_DEFUN([OL_LIB_BERKELEY_DB],
154 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
155 [       ol_LIBS="$LIBS"
156         AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
157                 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],[ol_cv_lib_db=no])
158         ])
159         LIBS="$ol_LIBS"
160 ])
161 ])dnl
162 dnl
163 dnl --------------------------------------------------------------------
164 dnl Check if Berkeley DB exists
165 dnl
166 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
167 dnl 
168 dnl uses:
169 dnl             OL_LIB_BERKELEY_DB
170 dnl             OL_HEADER_BERKELEY_DB
171 dnl
172 AC_DEFUN([OL_BERKELEY_DB],
173 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
174  AC_REQUIRE([OL_HEADER_BERKELEY_DB])
175  AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
176         if test $ol_cv_lib_db = no -o $ol_cv_header_db = no ; then
177                 ol_cv_berkeley_db=no
178         else
179                 ol_cv_berkeley_db=yes
180         fi
181 ])
182  if test $ol_cv_berkeley_db = yes ; then
183         AC_DEFINE(HAVE_BERKELEY_DB,1)
184  fi
185 ])dnl
186 dnl
187 dnl ====================================================================
188 dnl Check if GDBM library exists
189 dnl Check for gdbm_open in standard libraries or -lgdbm
190 dnl
191 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
192 dnl             'yes' implies gdbm_open is in $LIBS
193 dnl
194 dnl uses:
195 dnl             AC_CHECK_FUNC(gdbm_open)
196 dnl             AC_CHECK_LIB(gdbm,gdbm_open)
197 dnl
198 AC_DEFUN([OL_LIB_GDBM],
199 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
200 [       ol_LIBS="$LIBS"
201         AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
202                 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
203         ])
204         LIBS="$ol_LIBS"
205 ])
206 ])dnl
207 dnl
208 dnl --------------------------------------------------------------------
209 dnl Check if GDBM exists
210 dnl
211 dnl defines ol_cv_gdbm to 'yes' or 'no'
212 dnl 
213 dnl uses:
214 dnl             OL_LIB_GDBM
215 dnl             AC_CHECK_HEADERS(gdbm.h)
216 dnl
217 AC_DEFUN([OL_GDBM],
218 [AC_REQUIRE([OL_LIB_GDBM])
219  AC_CHECK_HEADERS(gdbm.h)
220  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
221         if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
222                 ol_cv_gdbm=no
223         else
224                 ol_cv_gdbm=yes
225         fi
226 ])
227  if test $ol_cv_gdbm = yes ; then
228         AC_DEFINE(HAVE_GDBM,1)
229  fi
230 ])dnl
231 dnl
232 dnl ====================================================================
233 dnl Check if NDBM library exists
234 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
235 dnl
236 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
237 dnl             'yes' implies ndbm_open is in $LIBS
238 dnl
239 dnl uses:
240 dnl             AC_CHECK_FUNC(dbm_open)
241 dnl             AC_CHECK_LIB(ndbm,dbm_open)
242 dnl             AC_CHECK_LIB(dbm,dbm_open)
243 dnl
244 dnl restrictions:
245 dnl             should also check SVR4 case: dbm_open() in -lucb but that
246 dnl             would requiring dealing with -L/usr/ucblib
247 dnl
248 AC_DEFUN([OL_LIB_NDBM],
249 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
250 [       ol_LIBS="$LIBS"
251         AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
252                 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
253                         AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
254                                 [ol_cv_lib_ndbm=no])dnl
255                 ])
256         ])
257         LIBS="$ol_LIBS"
258 ])
259 ])dnl
260 dnl
261 dnl --------------------------------------------------------------------
262 dnl Check if NDBM exists
263 dnl
264 dnl defines ol_cv_ndbm to 'yes' or 'no'
265 dnl 
266 dnl uses:
267 dnl             OL_LIB_NDBM
268 dnl             AC_CHECK_HEADERS(ndbm.h)
269 dnl
270 dnl restrictions:
271 dnl             Doesn't handle SVR4 case (see above)
272 dnl
273 AC_DEFUN([OL_NDBM],
274 [AC_REQUIRE([OL_LIB_NDBM])
275  AC_CHECK_HEADERS(ndbm.h)
276  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
277         if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
278                 ol_cv_ndbm=no
279         else
280                 ol_cv_ndbm=yes
281         fi
282 ])
283  if test $ol_cv_ndbm = yes ; then
284         AC_DEFINE(HAVE_NDBM,1)
285  fi
286 ])dnl
287 dnl
288 dnl ====================================================================
289 dnl Check POSIX Thread version 
290 dnl
291 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
292 dnl     'unknown' implies that the version could not be detected
293 dnl             or that pthreads.h does exist.  Existance of pthreads.h
294 dnl             should be tested separately.
295 dnl
296 AC_DEFUN([OL_POSIX_THREAD_VERSION],
297 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
298         AC_EGREP_CPP(pthread_version_final,[
299 #               include <pthread.h>
300                 /* this check could be improved */
301 #               ifdef PTHREAD_ONCE_INIT
302                         pthread_version_final
303 #               endif
304         ], ol_pthread_final=yes, ol_pthread_final=no)
305
306         AC_EGREP_CPP(pthread_version_draft4,[
307 #               include <pthread.h>
308                 /* this check could be improved */
309 #               ifdef pthread_once_init
310                         pthread_version_draft4
311 #               endif
312         ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
313
314         if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
315                 ol_cv_pthread_version=final
316         elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
317                 ol_cv_pthread_version=draft4
318         else
319                 ol_cv_pthread_version=unknown
320         fi
321 ])
322 ])dnl
323 dnl
324 dnl --------------------------------------------------------------------
325 dnl Check LinuxThread
326 dnl
327 dnl defines ol_cv_linux_threads to 'yes' or 'no'
328 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
329 dnl             doesn't exists.  Existance of pthread.h should separately
330 dnl             checked.
331 dnl 
332 AC_DEFUN([OL_LINUX_THREADS],
333 [
334 AC_CACHE_CHECK([for LinuxThreads], [ol_cv_linux_threads], [
335         res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
336         if test "$res" -gt 0 ; then
337                 ol_cv_linux_threads=yes
338         else
339                 ol_cv_linux_threads=no
340         fi
341 ])
342 ])dnl
343 dnl
344 dnl ====================================================================
345 dnl Check if toupper() requires islower() to be called first
346 AC_DEFUN([OL_C_UPPER_LOWER],
347 [
348 AC_MSG_CHECKING([if toupper() requires islower()])
349 AC_CACHE_VAL(ol_cv_c_upper_lower,[
350         AC_TRY_RUN([
351 #include <ctype.h>
352 main()
353 {
354         if ('C' == toupper('C'))
355                 exit(0);
356         else
357                 exit(1);
358 }],
359         [ol_cv_c_upper_lower=no],
360         [ol_cv_c_upper_lower=yes],
361         [ol_cv_c_upper_lower=safe])])
362 AC_MSG_RESULT($ol_cv_c_upper_lower)
363 if test $ol_cv_c_upper_lower != no ; then
364         AC_DEFINE(C_UPPER_LOWER,1)
365 fi
366 ])
367
368 dnl ====================================================================
369 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
370 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
371 dnl Reported by Keith Bostic.
372 AC_DEFUN([OL_SYS_ERRLIST],
373 [
374 AC_MSG_CHECKING([declaration of sys_errlist])
375 AC_CACHE_VAL(ol_cv_dcl_sys_errlist,[
376         AC_TRY_COMPILE([
377 #include <stdio.h>
378 #include <sys/types.h>
379 #include <errno.h> ],
380         [char *c = (char *) *sys_errlist],
381         [ol_cv_dcl_sys_errlist=yes],
382         [ol_cv_dcl_sys_errlist=no])])
383 AC_MSG_RESULT($ol_cv_dcl_sys_errlist)
384
385 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
386 if test $ol_cv_dcl_sys_errlist = no ; then
387         AC_DEFINE(DECL_SYS_ERRLIST,1)
388         AC_MSG_CHECKING([existence of sys_errlist])
389         AC_CACHE_VAL(ol_cv_have_sys_errlist,[
390                 AC_TRY_LINK([#include <errno.h>],
391                         [char *c = (char *) *sys_errlist],
392                         [ol_cv_have_sys_errlist=yes],
393                         [ol_cv_have_sys_errlist=no])])
394         AC_MSG_RESULT($ol_cv_have_sys_errlist)
395 fi
396 ])dnl
397
398 dnl ====================================================================
399 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
400 dnl "int x; int *volatile a = &x; *a = 0;"
401 dnl     -- borrowed from PDKSH
402 AC_DEFUN(OL_C_VOLATILE,
403  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
404     [AC_TRY_COMPILE([int x, y, z;],
405       [volatile int a; int * volatile b = x ? &y : &z;
406       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
407       *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
408   if test $ol_cv_c_volatile = yes; then
409     : 
410   else
411     AC_DEFINE(volatile, )
412   fi
413  ])dnl
414
415 dnl ====================================================================
416 dnl Define sig_atomic_t if not defined in signal.h
417 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
418  [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
419     [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
420                 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
421   if test $ol_cv_type_sig_atomic_t = no; then
422     AC_DEFINE(sig_atomic_t, int)
423   fi
424  ])dnl
425