libopts.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. dnl -*- buffer-read-only: t -*- vi: set ro:
  2. dnl
  3. dnl DO NOT EDIT THIS FILE (libopts.m4)
  4. dnl
  5. dnl It has been AutoGen-ed Sunday April 17, 2005 at 11:55:00 AM PDT
  6. dnl From the definitions libopts.def
  7. dnl and the template file conftest.tpl
  8. dnl
  9. dnl @synopsis INVOKE_LIBOPTS_MACROS
  10. dnl
  11. dnl This macro will invoke the AutoConf macros specified in libopts.def
  12. dnl that have not been disabled with "omit-invocation".
  13. dnl
  14. AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
  15. AC_ARG_WITH([regex-header],
  16. AC_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
  17. [libopts_cv_with_regex_header=${with_regex_header}],
  18. AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
  19. libopts_cv_with_regex_header=no)
  20. ) # end of AC_ARG_WITH
  21. if test "X${libopts_cv_with_regex_header}" != Xno
  22. then
  23. AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
  24. else
  25. AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
  26. fi
  27. ]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
  28. AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
  29. AC_ARG_WITH([libregex],
  30. AC_HELP_STRING([--with-libregex], [libregex installation prefix]),
  31. [libopts_cv_with_libregex_root=${with_libregex}],
  32. AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
  33. libopts_cv_with_libregex_root=no)
  34. ) # end of AC_ARG_WITH libregex
  35. if test "${with_libguile+set}" = set && \
  36. test "${withval}" = no
  37. then ## disabled by request
  38. libopts_cv_with_libregex_root=no
  39. libopts_cv_with_libregex_cflags=no
  40. libopts_cv_with_libregex_libs=no
  41. else
  42. AC_ARG_WITH([libregex-cflags],
  43. AC_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
  44. [libopts_cv_with_libregex_cflags=${with_regex_cflags}],
  45. AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
  46. libopts_cv_with_libregex_cflags=no)
  47. ) # end of AC_ARG_WITH libregex-cflags
  48. AC_ARG_WITH([libregex-libs],
  49. AC_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
  50. [libopts_cv_with_libregex_libs=${with_regex_libs}],
  51. AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
  52. libopts_cv_with_libregex_libs=no)
  53. ) # end of AC_ARG_WITH libregex-libs
  54. case "X${libopts_cv_with_libregex_cflags}" in
  55. Xyes|Xno|X )
  56. case "X${libopts_cv_with_libregex_root}" in
  57. Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
  58. * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
  59. esac
  60. esac
  61. case "X${libopts_cv_with_libregex_libs}" in
  62. Xyes|Xno|X )
  63. case "X${libopts_cv_with_libregex_root}" in
  64. Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
  65. * ) libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex";;
  66. esac
  67. esac
  68. libopts_save_CPPFLAGS="${CPPFLAGS}"
  69. libopts_save_LIBS="${LIBS}"
  70. fi ## disabled by request
  71. case "X${libopts_cv_with_libregex_cflags}" in
  72. Xyes|Xno|X )
  73. libopts_cv_with_libregex_cflags="" ;;
  74. * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
  75. esac
  76. case "X${libopts_cv_with_libregex_libs}" in
  77. Xyes|Xno|X )
  78. libopts_cv_with_libregex_libs="" ;;
  79. * )
  80. LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
  81. esac
  82. LIBREGEX_CFLAGS=""
  83. LIBREGEX_LIBS=""
  84. AC_MSG_CHECKING([whether libregex functions properly])
  85. AC_CACHE_VAL([libopts_cv_with_libregex],[
  86. AC_TRY_RUN([@%:@include <stdio.h>
  87. @%:@include <stdlib.h>
  88. @%:@include <sys/types.h>
  89. @%:@include REGEX_HEADER
  90. static regex_t re;
  91. void comp_re( const char* pzPat ) {
  92. int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
  93. if (res == 0) return;
  94. exit( res ); }
  95. int main() {
  96. regmatch_t m@<:@2@:>@;
  97. comp_re( "^.*\@S|@" );
  98. comp_re( "()|no.*" );
  99. comp_re( "." );
  100. if (regexec( &re, "X", 2, m, 0 ) != 0) return 1;
  101. if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
  102. fputs( "error: regex -->.<-- did not match\n", stderr );
  103. return 1;
  104. }
  105. return 0; }],
  106. [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
  107. [libopts_cv_with_libregex=no]) # end of AC_TRY_RUN
  108. ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
  109. AC_MSG_RESULT([${libopts_cv_with_libregex}])
  110. if test "X${libopts_cv_with_libregex}" = Xno
  111. then
  112. CPPFLAGS="${libopts_save_CPPFLAGS}"
  113. LIBS="${libopts_save_LIBS}"
  114. cat >&2 <<'_EOF_'
  115. I cannot detect POSIX compliant regcomp/regexec routines.
  116. These are required for AutoGen to work correctly. If you have
  117. such a library present on your system, you must specify it by
  118. setting the LIBS environment variable, e.g., "LIBS='-lregex'".
  119. If you do not have such a library on your system, then you should
  120. download and install, for example, the one from:
  121. ftp://ftp.gnu.org/gnu/rx/
  122. _EOF_
  123. AC_MSG_ERROR([Cannot find working POSIX regex library])
  124. fi
  125. ]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
  126. AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
  127. AC_MSG_CHECKING([whether pathfind(3) works])
  128. AC_CACHE_VAL([libopts_cv_run_pathfind],[
  129. AC_TRY_RUN([@%:@include <string.h>
  130. @%:@include <stdlib.h>
  131. int main (int argc, char** argv) {
  132. char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
  133. return (pz == 0) ? 1 : 0;
  134. }],
  135. [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
  136. ) # end of TRY_RUN
  137. ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
  138. AC_MSG_RESULT([${libopts_cv_run_pathfind}])
  139. if test "X${libopts_cv_run_pathfind}" != Xno
  140. then
  141. AC_DEFINE([HAVE_PATHFIND],[1],
  142. [Define this if pathfind(3) works])
  143. fi
  144. ]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
  145. AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
  146. AC_MSG_CHECKING([whether strftime() works])
  147. AC_CACHE_VAL([libopts_cv_run_strftime],[
  148. AC_TRY_RUN([@%:@include <time.h>
  149. @%:@include <string.h>
  150. char t_buf@<:@ 64 @:>@;
  151. int main() {
  152. static const char z@<:@@:>@ = "Thursday Aug 28 240";
  153. struct tm tm;
  154. tm.tm_sec = 36; /* seconds after the minute @<:@0, 61@:>@ */
  155. tm.tm_min = 44; /* minutes after the hour @<:@0, 59@:>@ */
  156. tm.tm_hour = 12; /* hour since midnight @<:@0, 23@:>@ */
  157. tm.tm_mday = 28; /* day of the month @<:@1, 31@:>@ */
  158. tm.tm_mon = 7; /* months since January @<:@0, 11@:>@ */
  159. tm.tm_year = 86; /* years since 1900 */
  160. tm.tm_wday = 4; /* days since Sunday @<:@0, 6@:>@ */
  161. tm.tm_yday = 239; /* days since January 1 @<:@0, 365@:>@ */
  162. tm.tm_isdst = 1; /* flag for daylight savings time */
  163. strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
  164. return (strcmp( t_buf, z ) != 0); }],
  165. [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
  166. ) # end of TRY_RUN
  167. ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
  168. AC_MSG_RESULT([${libopts_cv_run_strftime}])
  169. if test "X${libopts_cv_run_strftime}" != Xno
  170. then
  171. AC_DEFINE([HAVE_STRFTIME],[1],
  172. [Define this if strftime() works])
  173. fi
  174. ]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
  175. AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
  176. AC_MSG_CHECKING([whether fopen accepts "b" mode])
  177. AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
  178. AC_TRY_RUN([@%:@include <stdio.h>
  179. int main (int argc, char** argv) {
  180. FILE* fp = fopen("conftest.@S|@ac_ext", "rb");
  181. return (fp == NULL) ? 1 : fclose(fp); }],
  182. [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
  183. ) # end of TRY_RUN
  184. ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
  185. AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
  186. if test "X${libopts_cv_run_fopen_binary}" != Xno
  187. then
  188. AC_DEFINE([FOPEN_BINARY_FLAG],"b",
  189. [fopen(3) accepts a 'b' in the mode flag])
  190. else
  191. AC_DEFINE([FOPEN_BINARY_FLAG],"",
  192. [fopen(3) accepts a 'b' in the mode flag])
  193. fi
  194. ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
  195. AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
  196. AC_MSG_CHECKING([whether fopen accepts "t" mode])
  197. AC_CACHE_VAL([libopts_cv_run_fopen_text],[
  198. AC_TRY_RUN([@%:@include <stdio.h>
  199. int main (int argc, char** argv) {
  200. FILE* fp = fopen("conftest.@S|@ac_ext", "rt");
  201. return (fp == NULL) ? 1 : fclose(fp); }],
  202. [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
  203. ) # end of TRY_RUN
  204. ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
  205. AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
  206. if test "X${libopts_cv_run_fopen_text}" != Xno
  207. then
  208. AC_DEFINE([FOPEN_TEXT_FLAG],"t",
  209. [fopen(3) accepts a 't' in the mode flag])
  210. else
  211. AC_DEFINE([FOPEN_TEXT_FLAG],"",
  212. [fopen(3) accepts a 't' in the mode flag])
  213. fi
  214. ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
  215. AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
  216. # Check to see if a reg expr header is specified.
  217. LIBOPTS_WITH_REGEX_HEADER
  218. # Check to see if a working libregex can be found.
  219. LIBOPTS_WITHLIB_REGEX
  220. # Check to see if pathfind(3) works.
  221. LIBOPTS_RUN_PATHFIND
  222. # Check to see if strftime() works.
  223. LIBOPTS_RUN_STRFTIME
  224. # Check to see if fopen accepts "b" mode.
  225. LIBOPTS_RUN_FOPEN_BINARY
  226. # Check to see if fopen accepts "t" mode.
  227. LIBOPTS_RUN_FOPEN_TEXT
  228. # ----------------------------------------------------------------------
  229. # Check for standard headers.
  230. # ----------------------------------------------------------------------
  231. # =================
  232. # AC_HEADER_STDC
  233. # =================
  234. AC_HEADER_STDC
  235. # =================
  236. # AC_HEADER_DIRENT
  237. # =================
  238. AC_HEADER_DIRENT
  239. # ----------------------------------------------------------------------
  240. # AC_CHECK_HEADERS Check for list of headers.
  241. # ----------------------------------------------------------------------
  242. AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
  243. setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
  244. sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h)
  245. # --------------------------------------------
  246. # Verify certain entries from AC_CHECK_HEADERS
  247. # --------------------------------------------
  248. for f in sys_types sys_mman sys_param sys_stat sys_wait \
  249. string errno stdlib memory setjmp
  250. do eval as_ac_var=\${ac_cv_header_${f}_h+set}
  251. test "${as_ac_var}" = set || \
  252. AC_MSG_ERROR([You must have ${f}.h on your system])
  253. done
  254. # =================
  255. # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
  256. # if varargs.h is present define HAVE_VARARGS_H.
  257. # =================
  258. AC_CHECK_HEADERS(stdarg.h varargs.h, break)
  259. if test `eval echo '${'$as_ac_Header'}'` != yes; then
  260. AC_MSG_ERROR([You must have stdarg.h or varargs.h on your system])
  261. fi
  262. # =================
  263. # Similarly for the string.h and strings.h headers
  264. # =================
  265. AC_CHECK_HEADERS(string.h strings.h, break)
  266. if test `eval echo '${'$as_ac_Header'}'` != yes; then
  267. AC_MSG_ERROR([You must have string.h or strings.h on your system])
  268. fi
  269. # =================
  270. # ...and limits headers
  271. # =================
  272. AC_CHECK_HEADERS(limits.h sys/limits.h values.h, break)
  273. if test `eval echo '${'$as_ac_Header'}'` != yes; then
  274. AC_MSG_ERROR([You must have one of limits.h, sys/limits.h or values.h])
  275. fi
  276. # =================
  277. # ...and int types headers
  278. # =================
  279. AC_CHECK_HEADERS(stdint.h inttypes.h, break)
  280. if test `eval echo '${'$as_ac_Header'}'` != yes; then
  281. AC_MSG_ERROR([You must have stdint.h or inttypes.h on your system])
  282. fi
  283. # =================
  284. # ...and directory read headers
  285. # =================
  286. AC_CHECK_HEADERS(dirent.h ndir.h sys/ndir.h, break)
  287. # ----------------------------------------------------------------------
  288. # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
  289. # ----------------------------------------------------------------------
  290. AC_CHECK_LIB(gen, pathfind)
  291. AC_CHECK_FUNCS(mmap)
  292. ]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
  293. dnl @synopsis LIBOPTS_CHECK
  294. dnl
  295. dnl If autoopts-config works, add the linking information to LIBS.
  296. dnl Otherwise, add \`\`libopts-${AO_CURRENT}.${AO_REVISION}.${AO_AGE}''
  297. dnl to SUBDIRS and run all the config tests that the library needs.
  298. dnl
  299. dnl Default to system libopts
  300. NEED_LIBOPTS_DIR=''
  301. AC_DEFUN([LIBOPTS_CHECK],[
  302. AC_ARG_ENABLE([local-libopts],
  303. AC_HELP_STRING([--enable-local-libopts],
  304. [Force using the supplied libopts tearoff code]),
  305. [ if test x$enableval = xyes ; then
  306. AC_MSG_NOTICE([Using supplied libopts tearoff])
  307. LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
  308. LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
  309. INVOKE_LIBOPTS_MACROS
  310. NEED_LIBOPTS_DIR=true
  311. fi])
  312. if test -z "${NEED_LIBOPTS_DIR}" ; then
  313. AC_MSG_CHECKING([whether autoopts-config can be found])
  314. AC_ARG_WITH([autoopts-config],
  315. AC_HELP_STRING([--with-autoopts-config],
  316. [specify the config-info script]),
  317. [lo_cv_with_autoopts_config=${with_autoopts_config}],
  318. AC_CACHE_CHECK([whether autoopts-config is specified],
  319. lo_cv_with_autoopts_config,
  320. lo_cv_with_autoopts_config=autoopts-config)
  321. ) # end of AC_ARG_WITH
  322. AC_CACHE_VAL([lo_cv_test_autoopts],[
  323. aoconfig=${lo_cv_with_autoopts_config}
  324. lo_cv_test_autoopts=`${aoconfig} --libs` 2> /dev/null
  325. if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
  326. then lo_cv_test_autoopts=no ; fi
  327. ]) # end of CACHE_VAL
  328. AC_MSG_RESULT([${lo_cv_test_autoopts}])
  329. if test "X${lo_cv_test_autoopts}" != Xno
  330. then
  331. LIBOPTS_LDADD="${lo_cv_test_autoopts}"
  332. LIBOPTS_CFLAGS="`${aoconfig} --cflags`"
  333. else
  334. LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
  335. LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
  336. INVOKE_LIBOPTS_MACROS
  337. NEED_LIBOPTS_DIR=true
  338. fi
  339. fi # end of if test -z "${NEED_LIBOPTS_DIR}"
  340. AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
  341. AC_SUBST(LIBOPTS_LDADD)
  342. AC_SUBST(LIBOPTS_CFLAGS)
  343. AC_CONFIG_FILES([libopts/Makefile])
  344. ]) # end of AC_DEFUN of LIBOPTS_CHECK