1 dnl -*- buffer-read-only: t -*- vi: set ro:
3 dnl DO NOT EDIT THIS FILE (libopts.m4)
5 dnl It has been AutoGen-ed Saturday May 5, 2007 at 12:02:37 PM PDT
6 dnl From the definitions libopts.def
7 dnl and the template file conftest.tpl
9 dnl do always before generated macros:
11 AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
12 [if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then]
25 AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
26 setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
27 sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h \
30 # --------------------------------------------
31 # Verify certain entries from AC_CHECK_HEADERS
32 # --------------------------------------------
33 [for f in sys_types sys_mman sys_param sys_stat sys_wait \
34 string errno stdlib memory setjmp
35 do eval as_ac_var=\${ac_cv_header_${f}_h+set}
36 test "${as_ac_var}" = set] || \
37 AC_MSG_ERROR([You must have ${f}.h on your system])
40 # ================================================
41 # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
42 # if varargs.h is present define HAVE_VARARGS_H.
43 # ================================================
44 AC_CHECK_HEADERS(stdarg.h varargs.h, break)
45 [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
46 AC_MSG_ERROR([You must have stdarg.h or varargs.h on your system])
49 # ================================================
50 # Similarly for the string.h and strings.h headers
51 # ================================================
52 AC_CHECK_HEADERS(string.h strings.h, break)
53 [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
54 AC_MSG_ERROR([You must have string.h or strings.h on your system])
57 # =====================
58 # ...and limits headers
59 # =====================
60 AC_CHECK_HEADERS(limits.h sys/limits.h values.h, break)
61 [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
62 AC_MSG_ERROR([You must have one of limits.h, sys/limits.h or values.h])
65 # ========================
66 # ...and int types headers
67 # ========================
68 AC_CHECK_HEADERS(stdint.h inttypes.h, break)
69 AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
72 # ====================
73 # uintptr type & sizes
74 # ====================
75 AC_CHECK_TYPES([uintptr_t], ,
76 [AC_DEFINE([uintptr_t], unsigned long,
77 [Alternate uintptr_t for systems without it.])])
78 AC_CHECK_SIZEOF(char*, 4)
79 AC_CHECK_SIZEOF(int, 4)
80 AC_CHECK_SIZEOF(long, 4)
81 AC_CHECK_SIZEOF(short, 2)
83 # ----------------------------------------------------------------------
84 # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
85 # ----------------------------------------------------------------------
86 AC_CHECK_LIB(gen, pathfind)
88 AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr strrchr])
89 [ INVOKE_LIBOPTS_MACROS_FIRST_done=yes
93 dnl @synopsis INVOKE_LIBOPTS_MACROS
95 dnl This macro will invoke the AutoConf macros specified in libopts.def
96 dnl that have not been disabled with "omit-invocation".
98 AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
99 AC_ARG_WITH([regex-header],
100 AC_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
101 [libopts_cv_with_regex_header=${with_regex_header}],
102 AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
103 libopts_cv_with_regex_header=no)
104 ) # end of AC_ARG_WITH
106 if test "X${libopts_cv_with_regex_header}" != Xno
108 AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
110 AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
113 ]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
116 AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
117 AC_ARG_WITH([libregex],
118 AC_HELP_STRING([--with-libregex], [libregex installation prefix]),
119 [libopts_cv_with_libregex_root=${with_libregex}],
120 AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
121 libopts_cv_with_libregex_root=no)
122 ) # end of AC_ARG_WITH libregex
124 if test "${with_libguile+set}" = set && \
125 test "${withval}" = no
126 then ## disabled by request
127 libopts_cv_with_libregex_root=no
128 libopts_cv_with_libregex_cflags=no
129 libopts_cv_with_libregex_libs=no
132 AC_ARG_WITH([libregex-cflags],
133 AC_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
134 [libopts_cv_with_libregex_cflags=${with_regex_cflags}],
135 AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
136 libopts_cv_with_libregex_cflags=no)
137 ) # end of AC_ARG_WITH libregex-cflags
139 AC_ARG_WITH([libregex-libs],
140 AC_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
141 [libopts_cv_with_libregex_libs=${with_regex_libs}],
142 AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
143 libopts_cv_with_libregex_libs=no)
144 ) # end of AC_ARG_WITH libregex-libs
146 case "X${libopts_cv_with_libregex_cflags}" in
148 case "X${libopts_cv_with_libregex_root}" in
149 Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
150 * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
153 case "X${libopts_cv_with_libregex_libs}" in
155 case "X${libopts_cv_with_libregex_root}" in
156 Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
157 * ) libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex";;
160 libopts_save_CPPFLAGS="${CPPFLAGS}"
161 libopts_save_LIBS="${LIBS}"
162 fi ## disabled by request
164 case "X${libopts_cv_with_libregex_cflags}" in
166 libopts_cv_with_libregex_cflags="" ;;
167 * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
169 case "X${libopts_cv_with_libregex_libs}" in
171 libopts_cv_with_libregex_libs="" ;;
173 LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
177 AC_MSG_CHECKING([whether libregex functions properly])
178 AC_CACHE_VAL([libopts_cv_with_libregex],[
179 AC_TRY_RUN([@%:@include <stdio.h>
180 @%:@include <stdlib.h>
181 @%:@include <sys/types.h>
182 @%:@include REGEX_HEADER
184 void comp_re( char const* pzPat ) {
185 int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
186 if (res == 0) return;
189 regmatch_t m@<:@2@:>@;
190 comp_re( "^.*\@S|@" );
191 comp_re( "()|no.*" );
193 if (regexec( &re, "X", 2, m, 0 ) != 0) return 1;
194 if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
195 fputs( "error: regex -->.<-- did not match\n", stderr );
199 [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
200 [libopts_cv_with_libregex=no]) # end of AC_TRY_RUN
201 ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
202 AC_MSG_RESULT([${libopts_cv_with_libregex}])
204 if test "X${libopts_cv_with_libregex}" != Xno
206 AC_DEFINE([WITH_LIBREGEX],[1],
207 [Define this if a working libregex can be found])
209 CPPFLAGS="${libopts_save_CPPFLAGS}"
210 LIBS="${libopts_save_LIBS}"
213 ]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
216 AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
217 AC_MSG_CHECKING([whether pathfind(3) works])
218 AC_CACHE_VAL([libopts_cv_run_pathfind],[
219 AC_TRY_RUN([@%:@include <string.h>
220 @%:@include <stdlib.h>
221 int main (int argc, char** argv) {
222 char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
223 return (pz == 0) ? 1 : 0;
225 [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
227 ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
228 AC_MSG_RESULT([${libopts_cv_run_pathfind}])
230 if test "X${libopts_cv_run_pathfind}" != Xno
232 AC_DEFINE([HAVE_PATHFIND],[1],
233 [Define this if pathfind(3) works])
236 ]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
239 AC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
240 AC_MSG_CHECKING([whether /dev/zero is readable device])
241 AC_CACHE_VAL([libopts_cv_test_dev_zero],[
242 libopts_cv_test_dev_zero=`exec 2> /dev/null
243 dzero=\`ls -lL /dev/zero | egrep ^c......r\`
244 test -z "${dzero}" && exit 1
247 then libopts_cv_test_dev_zero=no
248 elif test -z "$libopts_cv_test_dev_zero"
249 then libopts_cv_test_dev_zero=no
251 ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
252 AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
254 if test "X${libopts_cv_test_dev_zero}" != Xno
256 AC_DEFINE([HAVE_DEV_ZERO],[1],
257 [Define this if /dev/zero is readable device])
260 ]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
263 AC_DEFUN([LIBOPTS_RUN_REALPATH],[
264 AC_MSG_CHECKING([whether we have a functional realpath(3C)])
265 AC_CACHE_VAL([libopts_cv_run_realpath],[
266 AC_TRY_RUN([@%:@include <limits.h>
267 @%:@include <stdlib.h>
268 int main (int argc, char** argv) {
272 char zPath@<:@PATH_MAX+1@:>@;
274 char *pz = realpath(argv@<:@0@:>@, zPath);
275 return (pz == zPath) ? 0 : 1;
277 [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
279 ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
280 AC_MSG_RESULT([${libopts_cv_run_realpath}])
282 if test "X${libopts_cv_run_realpath}" != Xno
284 AC_DEFINE([HAVE_REALPATH],[1],
285 [Define this if we have a functional realpath(3C)])
288 ]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
291 AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
292 AC_MSG_CHECKING([whether strftime() works])
293 AC_CACHE_VAL([libopts_cv_run_strftime],[
294 AC_TRY_RUN([@%:@include <time.h>
295 @%:@include <string.h>
296 char t_buf@<:@ 64 @:>@;
298 static char const z@<:@@:>@ = "Thursday Aug 28 240";
300 tm.tm_sec = 36; /* seconds after the minute @<:@0, 61@:>@ */
301 tm.tm_min = 44; /* minutes after the hour @<:@0, 59@:>@ */
302 tm.tm_hour = 12; /* hour since midnight @<:@0, 23@:>@ */
303 tm.tm_mday = 28; /* day of the month @<:@1, 31@:>@ */
304 tm.tm_mon = 7; /* months since January @<:@0, 11@:>@ */
305 tm.tm_year = 86; /* years since 1900 */
306 tm.tm_wday = 4; /* days since Sunday @<:@0, 6@:>@ */
307 tm.tm_yday = 239; /* days since January 1 @<:@0, 365@:>@ */
308 tm.tm_isdst = 1; /* flag for daylight savings time */
309 strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
310 return (strcmp( t_buf, z ) != 0); }],
311 [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
313 ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
314 AC_MSG_RESULT([${libopts_cv_run_strftime}])
316 if test "X${libopts_cv_run_strftime}" != Xno
318 AC_DEFINE([HAVE_STRFTIME],[1],
319 [Define this if strftime() works])
322 ]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
325 AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
326 AC_MSG_CHECKING([whether fopen accepts "b" mode])
327 AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
328 AC_TRY_RUN([@%:@include <stdio.h>
329 int main (int argc, char** argv) {
330 FILE* fp = fopen("conftest.@S|@ac_ext", "rb");
331 return (fp == NULL) ? 1 : fclose(fp); }],
332 [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
334 ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
335 AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
337 if test "X${libopts_cv_run_fopen_binary}" != Xno
339 AC_DEFINE([FOPEN_BINARY_FLAG],"b",
340 [fopen(3) accepts a 'b' in the mode flag])
342 AC_DEFINE([FOPEN_BINARY_FLAG],"",
343 [fopen(3) accepts a 'b' in the mode flag])
346 ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
349 AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
350 AC_MSG_CHECKING([whether fopen accepts "t" mode])
351 AC_CACHE_VAL([libopts_cv_run_fopen_text],[
352 AC_TRY_RUN([@%:@include <stdio.h>
353 int main (int argc, char** argv) {
354 FILE* fp = fopen("conftest.@S|@ac_ext", "rt");
355 return (fp == NULL) ? 1 : fclose(fp); }],
356 [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
358 ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
359 AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
361 if test "X${libopts_cv_run_fopen_text}" != Xno
363 AC_DEFINE([FOPEN_TEXT_FLAG],"t",
364 [fopen(3) accepts a 't' in the mode flag])
366 AC_DEFINE([FOPEN_TEXT_FLAG],"",
367 [fopen(3) accepts a 't' in the mode flag])
370 ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
373 AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
374 AC_ARG_ENABLE([optional-args],
375 AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
376 [libopts_cv_enable_optional_args=${enable_optional_args}],
377 AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
378 libopts_cv_enable_optional_args=yes)
379 ) # end of AC_ARG_ENABLE
381 if test "X${libopts_cv_enable_optional_args}" = Xno
383 AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
384 [Define this if optional arguments are disallowed])
387 ]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
390 AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
391 INVOKE_LIBOPTS_MACROS_FIRST
392 # Check to see if a reg expr header is specified.
393 LIBOPTS_WITH_REGEX_HEADER
395 # Check to see if a working libregex can be found.
396 LIBOPTS_WITHLIB_REGEX
398 # Check to see if pathfind(3) works.
401 # Check to see if /dev/zero is readable device.
402 LIBOPTS_TEST_DEV_ZERO
404 # Check to see if we have a functional realpath(3C).
407 # Check to see if strftime() works.
410 # Check to see if fopen accepts "b" mode.
411 LIBOPTS_RUN_FOPEN_BINARY
413 # Check to see if fopen accepts "t" mode.
414 LIBOPTS_RUN_FOPEN_TEXT
416 # Check to see if not wanting optional option args.
417 LIBOPTS_DISABLE_OPTIONAL_ARGS
419 ]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
421 dnl @synopsis LIBOPTS_CHECK
423 dnl Time-stamp: "2006-09-23 19:36:24 bkorb"
424 dnl Last Committed: $Date: 2007/06/24 15:49:29 $
426 dnl If autoopts-config works, add the linking information to LIBS.
427 dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
428 dnl the config tests that the library needs. Invoke the
429 dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
431 dnl Default to system libopts
433 AC_DEFUN([LIBOPTS_CHECK],[
434 [NEED_LIBOPTS_DIR='']
435 m4_pushdef([AO_Libopts_Dir],
436 [ifelse($1, , [libopts], [$1])])
437 AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
438 AC_ARG_ENABLE([local-libopts],
439 AC_HELP_STRING([--enable-local-libopts],
440 [Force using the supplied libopts tearoff code]),[
441 if test x$enableval = xyes ; then
442 AC_MSG_NOTICE([Using supplied libopts tearoff])
443 LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
444 LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
445 NEED_LIBOPTS_DIR=true
448 AC_ARG_ENABLE([libopts-install],
449 AC_HELP_STRING([--disable-libopts-install],
450 [Do not install libopts with client installation]))
451 AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" != Xno])
453 [if test -z "${NEED_LIBOPTS_DIR}" ; then]
454 AC_MSG_CHECKING([whether autoopts-config can be found])
455 AC_ARG_WITH([autoopts-config],
456 AC_HELP_STRING([--with-autoopts-config],
457 [specify the config-info script]),
458 [lo_cv_with_autoopts_config=${with_autoopts_config}],
459 AC_CACHE_CHECK([whether autoopts-config is specified],
460 [lo_cv_with_autoopts_config],
461 [if autoopts-config --help 2>/dev/null 1>&2
462 then lo_cv_with_autoopts_config=autoopts-config
463 elif libopts-config --help 2>/dev/null 1>&2
464 then lo_cv_with_autoopts_config=libopts-config
465 else lo_cv_with_autoopts_config=no ; fi])
466 ) # end of AC_ARG_WITH
468 AC_CACHE_VAL([lo_cv_test_autoopts],[
469 if test -z "${lo_cv_with_autoopts_config}" \
470 -o X"${lo_cv_with_autoopts_config}" = Xno
472 if autoopts-config --help 2>/dev/null 1>&2
473 then lo_cv_with_autoopts_config=autoopts-config
474 elif libopts-config --help 2>/dev/null 1>&2
475 then lo_cv_with_autoopts_config=libopts-config
476 else lo_cv_with_autoopts_config=false ; fi
478 lo_cv_test_autoopts=`
479 ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
480 if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
481 then lo_cv_test_autoopts=no ; fi
482 ]) # end of CACHE_VAL
483 AC_MSG_RESULT([${lo_cv_test_autoopts}])
485 [if test "X${lo_cv_test_autoopts}" != Xno
487 LIBOPTS_LDADD="${lo_cv_test_autoopts}"
488 LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
490 LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
491 LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
492 NEED_LIBOPTS_DIR=true
494 fi # end of if test -z "${NEED_LIBOPTS_DIR}"]
496 AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
497 AC_SUBST(LIBOPTS_LDADD)
498 AC_SUBST(LIBOPTS_CFLAGS)
499 AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
500 AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
501 m4_popdef([AO_Libopts_Dir])
503 [if test -n "${NEED_LIBOPTS_DIR}" ; then]
504 INVOKE_LIBOPTS_MACROS
506 INVOKE_LIBOPTS_MACROS_FIRST
508 # end of AC_DEFUN of LIBOPTS_CHECK]