1181834Srobertodnl  -*- buffer-read-only: t -*- vi: set ro:
2285612Sdelphijdnl
3181834Srobertodnl DO NOT EDIT THIS FILE   (libopts.m4)
4285612Sdelphijdnl
5285612Sdelphijdnl It has been AutoGen-ed
6181834Srobertodnl From the definitions    libopts.def
7181834Srobertodnl and the template file   conftest.tpl
8181834Srobertodnl
9181834Srobertodnl do always before generated macros:
10181834Srobertodnl
11181834SrobertoAC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
12285612Sdelphij  AC_REQUIRE([AC_HEADER_STDC])
13181834Sroberto  AC_HEADER_DIRENT
14285612Sdelphij
15181834Sroberto  # =================
16181834Sroberto  # AC_CHECK_HEADERS
17181834Sroberto  # =================
18285612Sdelphij  AC_CHECK_HEADERS([ \
19285612Sdelphij      sys/mman.h    sys/param.h   sys/poll.h    sys/procset.h \
20285612Sdelphij      sys/select.h  sys/socket.h  sys/stropts.h sys/time.h \
21285612Sdelphij      sys/un.h      sys/wait.h    dlfcn.h       errno.h \
22285612Sdelphij      fcntl.h       libgen.h      libintl.h     memory.h \
23285612Sdelphij      netinet/in.h  setjmp.h      stdbool.h     sysexits.h \
24285612Sdelphij      unistd.h      utime.h])
25285612Sdelphij
26285612Sdelphij  AC_CHECK_HEADERS([stdarg.h     varargs.h],
27285612Sdelphij      [lo_have_arg_hdr=true;break],
28285612Sdelphij      [lo_have_arg_hdr=false])
29285612Sdelphij
30285612Sdelphij  AC_CHECK_HEADERS([string.h     strings.h],
31285612Sdelphij      [lo_have_str_hdr=true;break],
32285612Sdelphij      [lo_have_str_hdr=false])
33285612Sdelphij
34285612Sdelphij  AC_CHECK_HEADERS([limits.h     sys/limits.h  values.h],
35285612Sdelphij      [lo_have_lim_hdr=true;break],
36285612Sdelphij      [lo_have_lim_hdr=false])
37285612Sdelphij
38285612Sdelphij  AC_CHECK_HEADERS([inttypes.h   stdint.h],
39285612Sdelphij      [lo_have_typ_hdr=true;break],
40285612Sdelphij      [lo_have_typ_hdr=false])
41285612Sdelphij  gl_STDNORETURN_H
42285612Sdelphij
43285612Sdelphij  # ----------------------------------------------------------------------
44285612Sdelphij  # check for various programs used during the build.
45285612Sdelphij  # On OS/X, "wchar.h" needs "runetype.h" to work properly.
46285612Sdelphij  # ----------------------------------------------------------------------
47285612Sdelphij  AC_CHECK_HEADERS([runetype.h wchar.h], [], [],[
48285612Sdelphij  AC_INCLUDES_DEFAULT
49285612Sdelphij  #if HAVE_RUNETYPE_H
50285612Sdelphij  # include <runetype.h>
51285612Sdelphij  #endif
52285612Sdelphij  ])
53285612Sdelphij
54285612Sdelphij  AC_ARG_ENABLE([nls],
55285612Sdelphij  AS_HELP_STRING([--disable-nls],[disable nls support in libopts]))
56285612Sdelphij  AS_IF([test "x$enable_nls" != "xno" && \
57285612Sdelphij  test "X${ac_cv_header_libintl_h}" = Xyes], [
58285612Sdelphij  AC_DEFINE([ENABLE_NLS],[1],[nls support in libopts])])
59285612Sdelphij
60181834Sroberto  # --------------------------------------------
61181834Sroberto  # Verify certain entries from AC_CHECK_HEADERS
62181834Sroberto  # --------------------------------------------
63285612Sdelphij  [${lo_have_arg_hdr} || \
64285612Sdelphij    ]AC_MSG_ERROR([you must have stdarg.h or varargs.h on your system])[
65285612Sdelphij
66285612Sdelphij  ${lo_have_str_hdr} || \
67285612Sdelphij    ]AC_MSG_ERROR([you must have string.h or strings.h on your system])[
68285612Sdelphij
69285612Sdelphij  ${lo_have_lim_hdr} || \
70285612Sdelphij    ]AC_MSG_ERROR(
71285612Sdelphij      [you must have one of limits.h, sys/limits.h or values.h])[
72285612Sdelphij
73285612Sdelphij  ${lo_have_typ_hdr} || \
74285612Sdelphij    ]AC_MSG_ERROR([you must have inttypes.h or stdint.h on your system])[
75285612Sdelphij
76285612Sdelphij  for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
77285612Sdelphij  do eval as_ac_var=\${ac_cv_header_${f}_h}
78285612Sdelphij     test "X${as_ac_var}" = Xyes || {
79285612Sdelphij       ]AC_MSG_ERROR([you must have ${f}.h on your system])[
80285612Sdelphij     }
81181834Sroberto  done
82285612Sdelphij  test "X${ac_cv_header_inttypes_h-no}" = Xyes || \
83285612Sdelphij    echo '#include <stdint.h>' > inttypes.h]
84285612Sdelphij
85181834Sroberto  # ----------------------------------------------------------------------
86285612Sdelphij  # Checks for typedefs
87181834Sroberto  # ----------------------------------------------------------------------
88285612Sdelphij  AC_CHECK_TYPES(wchar_t)
89285612Sdelphij  AC_CHECK_TYPES(wint_t, [], [], [
90285612Sdelphij    AC_INCLUDES_DEFAULT
91285612Sdelphij    #if HAVE_RUNETYPE_H
92285612Sdelphij    # include <runetype.h>
93285612Sdelphij    #endif
94285612Sdelphij    #if HAVE_WCHAR_H
95285612Sdelphij    # include <wchar.h>
96285612Sdelphij    #endif
97285612Sdelphij  ])
98285612Sdelphij  AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
99285612Sdelphij  intptr_t, uintptr_t, uint_t, pid_t, size_t, ptrdiff_t])
100285612Sdelphij  AC_CHECK_SIZEOF(char *, 8)
101285612Sdelphij  AC_CHECK_SIZEOF(int,    4)
102285612Sdelphij  AC_CHECK_SIZEOF(long,   8)
103285612Sdelphij  AC_CHECK_SIZEOF(short,  2)
104285612Sdelphij
105285612Sdelphij  # ------------
106285612Sdelphij  # AC_CHECK_LIB
107285612Sdelphij  # ------------
108181834Sroberto  AC_CHECK_LIB(gen, pathfind)
109285612Sdelphij  AC_CHECK_LIB(intl,gettext)
110181834Sroberto  AC_FUNC_VPRINTF
111285612Sdelphij  AC_FUNC_FORK
112285612Sdelphij  AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
113285612Sdelphij                 strrchr strsignal fchmod fstat chmod])
114285612Sdelphij  AC_PROG_SED
115285612Sdelphij  [while :
116285612Sdelphij  do
117285612Sdelphij      POSIX_SHELL=`which bash`
118285612Sdelphij      test -x "$POSIX_SHELL" && break
119285612Sdelphij      POSIX_SHELL=`which dash`
120285612Sdelphij      test -x "$POSIX_SHELL" && break
121285612Sdelphij      POSIX_SHELL=/usr/xpg4/bin/sh
122285612Sdelphij      test -x "$POSIX_SHELL" && break
123285612Sdelphij      POSIX_SHELL=`/bin/sh -c '
124285612Sdelphij          exec 2>/dev/null
125285612Sdelphij          if ! true ; then exit 1 ; fi
126285612Sdelphij          echo /bin/sh'`
127285612Sdelphij      test -x "$POSIX_SHELL" && break
128285612Sdelphij      ]AC_MSG_ERROR([cannot locate a working POSIX shell])[
129285612Sdelphij  done]
130285612Sdelphij  AC_DEFINE_UNQUOTED([POSIX_SHELL], ["${POSIX_SHELL}"],
131285612Sdelphij           [define to a working POSIX compliant shell])
132285612Sdelphij  AC_SUBST([POSIX_SHELL])
133285612Sdelphij])
134181834Sroberto
135181834Srobertodnl
136181834Srobertodnl @synopsis  INVOKE_LIBOPTS_MACROS
137181834Srobertodnl
138181834Srobertodnl  This macro will invoke the AutoConf macros specified in libopts.def
139181834Srobertodnl  that have not been disabled with "omit-invocation".
140181834Srobertodnl
141181834SrobertoAC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
142181834Sroberto  AC_ARG_WITH([regex-header],
143285612Sdelphij    AS_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
144181834Sroberto    [libopts_cv_with_regex_header=${with_regex_header}],
145181834Sroberto    AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
146181834Sroberto      libopts_cv_with_regex_header=no)
147181834Sroberto  ) # end of AC_ARG_WITH
148181834Sroberto  if test "X${libopts_cv_with_regex_header}" != Xno
149181834Sroberto  then
150181834Sroberto    AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
151181834Sroberto  else
152181834Sroberto    AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
153181834Sroberto  fi
154285612Sdelphij
155181834Sroberto]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
156181834Sroberto
157181834Sroberto
158181834SrobertoAC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
159181834Sroberto  AC_ARG_WITH([libregex],
160285612Sdelphij    AS_HELP_STRING([--with-libregex], [libregex installation prefix]),
161181834Sroberto    [libopts_cv_with_libregex_root=${with_libregex}],
162181834Sroberto    AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
163181834Sroberto      libopts_cv_with_libregex_root=no)
164181834Sroberto  ) # end of AC_ARG_WITH libregex
165181834Sroberto
166285612Sdelphij  if test "${with_libregex+set}" = set && \
167285612Sdelphij     test "X${withval}" = Xno
168181834Sroberto  then ## disabled by request
169181834Sroberto    libopts_cv_with_libregex_root=no
170181834Sroberto    libopts_cv_with_libregex_cflags=no
171181834Sroberto    libopts_cv_with_libregex_libs=no
172181834Sroberto  else
173181834Sroberto
174181834Sroberto  AC_ARG_WITH([libregex-cflags],
175285612Sdelphij    AS_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
176285612Sdelphij    [libopts_cv_with_libregex_cflags=${with_libregex_cflags}],
177181834Sroberto    AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
178181834Sroberto      libopts_cv_with_libregex_cflags=no)
179181834Sroberto  ) # end of AC_ARG_WITH libregex-cflags
180181834Sroberto
181181834Sroberto  AC_ARG_WITH([libregex-libs],
182285612Sdelphij    AS_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
183285612Sdelphij    [libopts_cv_with_libregex_libs=${with_libregex_libs}],
184181834Sroberto    AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
185181834Sroberto      libopts_cv_with_libregex_libs=no)
186181834Sroberto  ) # end of AC_ARG_WITH libregex-libs
187181834Sroberto
188181834Sroberto  case "X${libopts_cv_with_libregex_cflags}" in
189181834Sroberto  Xyes|Xno|X )
190181834Sroberto    case "X${libopts_cv_with_libregex_root}" in
191181834Sroberto    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
192285612Sdelphij    * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
193181834Sroberto    esac
194181834Sroberto  esac
195181834Sroberto  case "X${libopts_cv_with_libregex_libs}" in
196181834Sroberto  Xyes|Xno|X )
197181834Sroberto    case "X${libopts_cv_with_libregex_root}" in
198181834Sroberto    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
199285612Sdelphij    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex" ;;
200181834Sroberto    esac
201181834Sroberto  esac
202181834Sroberto  libopts_save_CPPFLAGS="${CPPFLAGS}"
203181834Sroberto  libopts_save_LIBS="${LIBS}"
204181834Sroberto  case "X${libopts_cv_with_libregex_cflags}" in
205181834Sroberto  Xyes|Xno|X )
206181834Sroberto    libopts_cv_with_libregex_cflags="" ;;
207181834Sroberto  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
208181834Sroberto  esac
209181834Sroberto  case "X${libopts_cv_with_libregex_libs}" in
210181834Sroberto  Xyes|Xno|X )
211181834Sroberto    libopts_cv_with_libregex_libs="" ;;
212181834Sroberto  * )
213181834Sroberto    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
214181834Sroberto  esac
215181834Sroberto  LIBREGEX_CFLAGS=""
216181834Sroberto  LIBREGEX_LIBS=""
217181834Sroberto  AC_MSG_CHECKING([whether libregex functions properly])
218181834Sroberto  AC_CACHE_VAL([libopts_cv_with_libregex],[
219285612Sdelphij  AC_RUN_IFELSE([@%:@include <stdio.h>
220181834Sroberto@%:@include <stdlib.h>
221181834Sroberto@%:@include <sys/types.h>
222181834Sroberto@%:@include REGEX_HEADER
223181834Srobertostatic regex_t re;
224285612Sdelphijvoid comp_re(char const * pzPat) {
225181834Sroberto  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
226181834Sroberto  if (res == 0) return;
227181834Sroberto  exit( res ); }
228181834Srobertoint main() {
229181834Sroberto  regmatch_t m@<:@2@:>@;
230181834Sroberto  comp_re( "^.*\@S|@"   );
231181834Sroberto  comp_re( "()|no.*" );
232181834Sroberto  comp_re( "."       );
233181834Sroberto  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
234181834Sroberto  if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
235181834Sroberto    fputs( "error: regex -->.<-- did not match\n", stderr );
236181834Sroberto    return 1;
237181834Sroberto  }
238181834Sroberto  return 0; }],
239181834Sroberto    [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
240285612Sdelphij    [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE 
241181834Sroberto  ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
242285612Sdelphij  fi ## disabled by request
243181834Sroberto  AC_MSG_RESULT([${libopts_cv_with_libregex}])
244181834Sroberto  if test "X${libopts_cv_with_libregex}" != Xno
245181834Sroberto  then
246181834Sroberto    AC_DEFINE([WITH_LIBREGEX],[1],
247181834Sroberto        [Define this if a working libregex can be found])
248181834Sroberto  else
249181834Sroberto    CPPFLAGS="${libopts_save_CPPFLAGS}"
250181834Sroberto    LIBS="${libopts_save_LIBS}"
251285612Sdelphij    libopts_cv_with_libregex_root=no
252285612Sdelphijlibopts_cv_with_libregex_cflags=no
253285612Sdelphijlibopts_cv_with_libregex_libs=no
254285612Sdelphijlibopts_cv_with_libregex=no
255181834Sroberto  fi
256285612Sdelphij
257181834Sroberto]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
258181834Sroberto
259181834Sroberto
260181834SrobertoAC_DEFUN([LIBOPTS_RUN_PATHFIND],[
261181834Sroberto  AC_MSG_CHECKING([whether pathfind(3) works])
262181834Sroberto  AC_CACHE_VAL([libopts_cv_run_pathfind],[
263285612Sdelphij  AC_RUN_IFELSE([@%:@include <string.h>
264181834Sroberto@%:@include <stdlib.h>
265285612Sdelphijint main (int argc, char ** argv) {
266285612Sdelphij   char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
267181834Sroberto   return (pz == 0) ? 1 : 0;
268181834Sroberto}],
269181834Sroberto    [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
270285612Sdelphij  ) # end of RUN_IFELSE
271181834Sroberto  ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
272181834Sroberto  AC_MSG_RESULT([${libopts_cv_run_pathfind}])
273181834Sroberto  if test "X${libopts_cv_run_pathfind}" != Xno
274181834Sroberto  then
275181834Sroberto    AC_DEFINE([HAVE_PATHFIND],[1],
276181834Sroberto        [Define this if pathfind(3) works])
277181834Sroberto  fi
278285612Sdelphij
279181834Sroberto]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
280181834Sroberto
281181834Sroberto
282181834SrobertoAC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
283181834Sroberto  AC_MSG_CHECKING([whether /dev/zero is readable device])
284181834Sroberto  AC_CACHE_VAL([libopts_cv_test_dev_zero],[
285181834Sroberto    libopts_cv_test_dev_zero=`exec 2> /dev/null
286181834Srobertodzero=\`ls -lL /dev/zero | egrep ^c......r\`
287181834Srobertotest -z "${dzero}" && exit 1
288181834Srobertoecho ${dzero}`
289285612Sdelphij    if test $? -ne 0 || test -z "$libopts_cv_test_dev_zero"
290181834Sroberto    then libopts_cv_test_dev_zero=no
291181834Sroberto    fi
292181834Sroberto  ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
293181834Sroberto  AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
294181834Sroberto  if test "X${libopts_cv_test_dev_zero}" != Xno
295181834Sroberto  then
296181834Sroberto    AC_DEFINE([HAVE_DEV_ZERO],[1],
297181834Sroberto        [Define this if /dev/zero is readable device])
298181834Sroberto  fi
299285612Sdelphij
300181834Sroberto]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
301181834Sroberto
302181834Sroberto
303181834SrobertoAC_DEFUN([LIBOPTS_RUN_REALPATH],[
304181834Sroberto  AC_MSG_CHECKING([whether we have a functional realpath(3C)])
305181834Sroberto  AC_CACHE_VAL([libopts_cv_run_realpath],[
306285612Sdelphij  AC_RUN_IFELSE([@%:@include <limits.h>
307181834Sroberto@%:@include <stdlib.h>
308285612Sdelphijint main (int argc, char ** argv) {
309181834Sroberto@%:@ifndef PATH_MAX
310181834Srobertochoke me!!
311181834Sroberto@%:@else
312181834Sroberto   char zPath@<:@PATH_MAX+1@:>@;
313181834Sroberto@%:@endif
314181834Sroberto   char *pz = realpath(argv@<:@0@:>@, zPath);
315181834Sroberto   return (pz == zPath) ? 0 : 1;
316181834Sroberto}],
317181834Sroberto    [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
318285612Sdelphij  ) # end of RUN_IFELSE
319181834Sroberto  ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
320181834Sroberto  AC_MSG_RESULT([${libopts_cv_run_realpath}])
321181834Sroberto  if test "X${libopts_cv_run_realpath}" != Xno
322181834Sroberto  then
323181834Sroberto    AC_DEFINE([HAVE_REALPATH],[1],
324181834Sroberto        [Define this if we have a functional realpath(3C)])
325181834Sroberto  fi
326285612Sdelphij
327181834Sroberto]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
328181834Sroberto
329181834Sroberto
330181834SrobertoAC_DEFUN([LIBOPTS_RUN_STRFTIME],[
331181834Sroberto  AC_MSG_CHECKING([whether strftime() works])
332181834Sroberto  AC_CACHE_VAL([libopts_cv_run_strftime],[
333285612Sdelphij  AC_RUN_IFELSE([@%:@include <time.h>
334181834Sroberto@%:@include <string.h>
335181834Srobertochar t_buf@<:@ 64 @:>@;
336181834Srobertoint main() {
337181834Sroberto  static char const z@<:@@:>@ = "Thursday Aug 28 240";
338181834Sroberto  struct tm tm;
339181834Sroberto  tm.tm_sec   = 36;  /* seconds after the minute @<:@0, 61@:>@  */
340181834Sroberto  tm.tm_min   = 44;  /* minutes after the hour @<:@0, 59@:>@ */
341181834Sroberto  tm.tm_hour  = 12;  /* hour since midnight @<:@0, 23@:>@ */
342181834Sroberto  tm.tm_mday  = 28;  /* day of the month @<:@1, 31@:>@ */
343181834Sroberto  tm.tm_mon   =  7;  /* months since January @<:@0, 11@:>@ */
344181834Sroberto  tm.tm_year  = 86;  /* years since 1900 */
345181834Sroberto  tm.tm_wday  =  4;  /* days since Sunday @<:@0, 6@:>@ */
346181834Sroberto  tm.tm_yday  = 239; /* days since January 1 @<:@0, 365@:>@ */
347181834Sroberto  tm.tm_isdst =  1;  /* flag for daylight savings time */
348181834Sroberto  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
349181834Sroberto  return (strcmp( t_buf, z ) != 0); }],
350181834Sroberto    [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
351285612Sdelphij  ) # end of RUN_IFELSE
352181834Sroberto  ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
353181834Sroberto  AC_MSG_RESULT([${libopts_cv_run_strftime}])
354181834Sroberto  if test "X${libopts_cv_run_strftime}" != Xno
355181834Sroberto  then
356181834Sroberto    AC_DEFINE([HAVE_STRFTIME],[1],
357181834Sroberto        [Define this if strftime() works])
358181834Sroberto  fi
359285612Sdelphij
360181834Sroberto]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
361181834Sroberto
362181834Sroberto
363181834SrobertoAC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
364181834Sroberto  AC_MSG_CHECKING([whether fopen accepts "b" mode])
365181834Sroberto  AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
366285612Sdelphij  AC_RUN_IFELSE([@%:@include <stdio.h>
367285612Sdelphijint main (int argc, char ** argv) {
368285612SdelphijFILE * fp = fopen("conftest.@S|@ac_ext", "rb");
369181834Srobertoreturn (fp == NULL) ? 1 : fclose(fp); }],
370181834Sroberto    [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
371285612Sdelphij  ) # end of RUN_IFELSE
372181834Sroberto  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
373181834Sroberto  AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
374181834Sroberto  if test "X${libopts_cv_run_fopen_binary}" != Xno
375181834Sroberto  then
376181834Sroberto    AC_DEFINE([FOPEN_BINARY_FLAG],"b",
377181834Sroberto	[fopen(3) accepts a 'b' in the mode flag])
378181834Sroberto  else
379181834Sroberto    AC_DEFINE([FOPEN_BINARY_FLAG],"",
380181834Sroberto	[fopen(3) accepts a 'b' in the mode flag])
381181834Sroberto  fi
382285612Sdelphij
383181834Sroberto]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
384181834Sroberto
385181834Sroberto
386181834SrobertoAC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
387181834Sroberto  AC_MSG_CHECKING([whether fopen accepts "t" mode])
388181834Sroberto  AC_CACHE_VAL([libopts_cv_run_fopen_text],[
389285612Sdelphij  AC_RUN_IFELSE([@%:@include <stdio.h>
390285612Sdelphijint main (int argc, char ** argv) {
391285612SdelphijFILE * fp = fopen("conftest.@S|@ac_ext", "rt");
392181834Srobertoreturn (fp == NULL) ? 1 : fclose(fp); }],
393181834Sroberto    [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
394285612Sdelphij  ) # end of RUN_IFELSE
395181834Sroberto  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
396181834Sroberto  AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
397181834Sroberto  if test "X${libopts_cv_run_fopen_text}" != Xno
398181834Sroberto  then
399181834Sroberto    AC_DEFINE([FOPEN_TEXT_FLAG],"t",
400181834Sroberto	[fopen(3) accepts a 't' in the mode flag])
401181834Sroberto  else
402181834Sroberto    AC_DEFINE([FOPEN_TEXT_FLAG],"",
403181834Sroberto	[fopen(3) accepts a 't' in the mode flag])
404181834Sroberto  fi
405285612Sdelphij
406181834Sroberto]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
407181834Sroberto
408181834Sroberto
409181834SrobertoAC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
410181834Sroberto  AC_ARG_ENABLE([optional-args],
411285612Sdelphij    AS_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
412181834Sroberto    [libopts_cv_enable_optional_args=${enable_optional_args}],
413181834Sroberto    AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
414181834Sroberto      libopts_cv_enable_optional_args=yes)
415181834Sroberto  ) # end of AC_ARG_ENABLE
416181834Sroberto  if test "X${libopts_cv_enable_optional_args}" = Xno
417181834Sroberto  then
418181834Sroberto    AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
419181834Sroberto          [Define this if optional arguments are disallowed])
420181834Sroberto  fi
421285612Sdelphij
422181834Sroberto]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
423181834Sroberto
424181834Sroberto
425181834SrobertoAC_DEFUN([INVOKE_LIBOPTS_MACROS],[
426285612Sdelphij  AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
427181834Sroberto  # Check to see if a reg expr header is specified.
428181834Sroberto  LIBOPTS_WITH_REGEX_HEADER
429181834Sroberto
430181834Sroberto  # Check to see if a working libregex can be found.
431181834Sroberto  LIBOPTS_WITHLIB_REGEX
432181834Sroberto
433181834Sroberto  # Check to see if pathfind(3) works.
434181834Sroberto  LIBOPTS_RUN_PATHFIND
435181834Sroberto
436181834Sroberto  # Check to see if /dev/zero is readable device.
437181834Sroberto  LIBOPTS_TEST_DEV_ZERO
438181834Sroberto
439181834Sroberto  # Check to see if we have a functional realpath(3C).
440181834Sroberto  LIBOPTS_RUN_REALPATH
441181834Sroberto
442181834Sroberto  # Check to see if strftime() works.
443181834Sroberto  LIBOPTS_RUN_STRFTIME
444181834Sroberto
445181834Sroberto  # Check to see if fopen accepts "b" mode.
446181834Sroberto  LIBOPTS_RUN_FOPEN_BINARY
447181834Sroberto
448181834Sroberto  # Check to see if fopen accepts "t" mode.
449181834Sroberto  LIBOPTS_RUN_FOPEN_TEXT
450181834Sroberto
451181834Sroberto  # Check to see if not wanting optional option args.
452181834Sroberto  LIBOPTS_DISABLE_OPTIONAL_ARGS
453181834Sroberto
454181834Sroberto]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
455181834Sroberto
456181834Srobertodnl @synopsis  LIBOPTS_CHECK
457181834Srobertodnl
458181834Srobertodnl If autoopts-config works, add the linking information to LIBS.
459181834Srobertodnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
460181834Srobertodnl the config tests that the library needs.  Invoke the
461181834Srobertodnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
462181834Srobertodnl
463285612Sdelphijdnl  This file is part of AutoGen.
464285612Sdelphijdnl  AutoGen Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
465285612Sdelphijdnl
466285612Sdelphijdnl  AutoGen is free software: you can redistribute it and/or modify it
467285612Sdelphijdnl  under the terms of the GNU General Public License as published by the
468285612Sdelphijdnl  Free Software Foundation, either version 3 of the License, or
469285612Sdelphijdnl  (at your option) any later version.
470285612Sdelphijdnl
471285612Sdelphijdnl  AutoGen is distributed in the hope that it will be useful, but
472285612Sdelphijdnl  WITHOUT ANY WARRANTY; without even the implied warranty of
473285612Sdelphijdnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
474285612Sdelphijdnl  See the GNU General Public License for more details.
475285612Sdelphijdnl
476285612Sdelphijdnl  You should have received a copy of the GNU General Public License along
477285612Sdelphijdnl  with this program.  If not, see <http://www.gnu.org/licenses/>.
478285612Sdelphijdnl
479181834Srobertodnl Default to system libopts
480181834Srobertodnl
481285612SdelphijAC_DEFUN([LIBOPTS_CHECK_COMMON],[
482285612Sdelphij  AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
483181834Sroberto  [NEED_LIBOPTS_DIR='']
484181834Sroberto  m4_pushdef([AO_Libopts_Dir],
485181834Sroberto	    [ifelse($1, , [libopts], [$1])])
486181834Sroberto  AC_ARG_ENABLE([local-libopts],
487181834Sroberto    AC_HELP_STRING([--enable-local-libopts],
488285612Sdelphij       [Use the supplied libopts tearoff code]),[
489181834Sroberto    if test x$enableval = xyes ; then
490181834Sroberto       AC_MSG_NOTICE([Using supplied libopts tearoff])
491181834Sroberto       LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
492181834Sroberto       NEED_LIBOPTS_DIR=true
493285612Sdelphij       LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
494181834Sroberto    fi])
495181834Sroberto
496181834Sroberto  AC_ARG_ENABLE([libopts-install],
497285612Sdelphij    AC_HELP_STRING([--enable-libopts-install],
498285612Sdelphij       [Install libopts with client installation]))
499285612Sdelphij  AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" = Xyes])
500181834Sroberto
501181834Sroberto  [if test -z "${NEED_LIBOPTS_DIR}" ; then]
502181834Sroberto     AC_MSG_CHECKING([whether autoopts-config can be found])
503181834Sroberto     AC_ARG_WITH([autoopts-config],
504181834Sroberto        AC_HELP_STRING([--with-autoopts-config],
505181834Sroberto             [specify the config-info script]),
506181834Sroberto        [lo_cv_with_autoopts_config=${with_autoopts_config}],
507181834Sroberto        AC_CACHE_CHECK([whether autoopts-config is specified],
508181834Sroberto             [lo_cv_with_autoopts_config],
509181834Sroberto             [if autoopts-config --help 2>/dev/null 1>&2
510181834Sroberto        then lo_cv_with_autoopts_config=autoopts-config
511181834Sroberto        elif libopts-config --help 2>/dev/null 1>&2
512181834Sroberto        then lo_cv_with_autoopts_config=libopts-config
513181834Sroberto        else lo_cv_with_autoopts_config=no ; fi])
514181834Sroberto     ) # end of AC_ARG_WITH
515181834Sroberto
516181834Sroberto     AC_CACHE_VAL([lo_cv_test_autoopts],[
517181834Sroberto        if test -z "${lo_cv_with_autoopts_config}" \
518181834Sroberto                -o X"${lo_cv_with_autoopts_config}" = Xno
519181834Sroberto        then
520181834Sroberto           if autoopts-config --help 2>/dev/null 1>&2
521181834Sroberto           then lo_cv_with_autoopts_config=autoopts-config
522181834Sroberto           elif libopts-config --help 2>/dev/null 1>&2
523181834Sroberto           then lo_cv_with_autoopts_config=libopts-config
524181834Sroberto           else lo_cv_with_autoopts_config=false ; fi
525181834Sroberto        fi
526181834Sroberto        lo_cv_test_autoopts=`
527181834Sroberto            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
528181834Sroberto        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
529181834Sroberto        then lo_cv_test_autoopts=no ; fi
530181834Sroberto     ]) # end of CACHE_VAL
531181834Sroberto     AC_MSG_RESULT([${lo_cv_test_autoopts}])
532181834Sroberto
533181834Sroberto     [if test "X${lo_cv_test_autoopts}" != Xno
534181834Sroberto     then
535181834Sroberto        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
536181834Sroberto        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
537181834Sroberto     else
538181834Sroberto        LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
539181834Sroberto        LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
540181834Sroberto        NEED_LIBOPTS_DIR=true
541181834Sroberto     fi
542285612Sdelphij  fi # end of if test -z "${NEED_LIBOPTS_DIR}"
543285612Sdelphij  if test -n "${LIBOPTS_BUILD_BLOCKED}" ; then
544285612Sdelphij    NEED_LIBOPTS_DIR=''
545285612Sdelphij  fi]
546181834Sroberto  AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
547181834Sroberto  AC_SUBST(LIBOPTS_LDADD)
548181834Sroberto  AC_SUBST(LIBOPTS_CFLAGS)
549181834Sroberto  AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
550181834Sroberto  m4_popdef([AO_Libopts_Dir])
551285612Sdelphij[# end of AC_DEFUN of LIBOPTS_CHECK_COMMON]
552285612Sdelphij])
553285612Sdelphijdnl
554285612Sdelphijdnl AC_CONFIG_FILES conditionalization requires using AM_COND_IF, however
555285612Sdelphijdnl AM_COND_IF is new to Automake 1.11.  To use it on new Automake without
556285612Sdelphijdnl requiring same, a fallback implementation for older Automake is provided.
557285612Sdelphijdnl Note that disabling of AC_CONFIG_FILES requires Automake 1.11, this code
558285612Sdelphijdnl is correct only in terms of m4sh generated script.
559285612Sdelphijdnl
560285612Sdelphijm4_ifndef([AM_COND_IF],
561285612Sdelphij  [AC_DEFUN([AM_COND_IF], [
562285612Sdelphij    if test -z "$$1_TRUE"; then :
563285612Sdelphij      m4_n([$2])[]dnl
564285612Sdelphij      m4_ifval([$3],[
565285612Sdelphij    else
566285612Sdelphij      $3
567285612Sdelphij    ])dnl
568285612Sdelphij    fi[]dnl
569285612Sdelphij  ])dnl
570285612Sdelphij])
571285612Sdelphijdnl
572285612SdelphijAC_DEFUN([LIBOPTS_CHECK_NOBUILD], [
573285612Sdelphij  m4_pushdef([AO_Libopts_Dir],
574285612Sdelphij	      [ifelse($1, , [libopts], [$1])])
575285612Sdelphij  LIBOPTS_BUILD_BLOCKED=true
576285612Sdelphij  LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
577285612Sdelphij  m4_popdef([AO_Libopts_Dir])dnl
578285612Sdelphij# end of AC_DEFUN of LIBOPTS_CHECK_NOBUILD
579285612Sdelphij])
580285612Sdelphijdnl
581285612SdelphijAC_DEFUN([LIBOPTS_CHECK], [
582285612Sdelphij  m4_pushdef([AO_Libopts_Dir],
583285612Sdelphij	      [ifelse($1, , [libopts], [$1])])
584285612Sdelphij  LIBOPTS_BUILD_BLOCKED=''
585285612Sdelphij  LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
586285612Sdelphij  AM_COND_IF([NEED_LIBOPTS], [
587181834Sroberto    INVOKE_LIBOPTS_MACROS
588285612Sdelphij  ])
589285612Sdelphij  AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
590285612Sdelphij  m4_popdef([AO_Libopts_Dir])dnl
591285612Sdelphij# end of AC_DEFUN of LIBOPTS_CHECK
592181834Sroberto])
593