libopts.m4 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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
  6. dnl From the definitions libopts.def
  7. dnl and the template file conftest.tpl
  8. dnl
  9. dnl do always before generated macros:
  10. dnl
  11. AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
  12. AC_HEADER_DIRENT
  13. # =================
  14. # AC_CHECK_HEADERS
  15. # =================
  16. AC_CHECK_HEADERS([ \
  17. sys/mman.h sys/param.h sys/poll.h sys/procset.h \
  18. sys/select.h sys/socket.h sys/stropts.h sys/time.h \
  19. sys/un.h sys/wait.h dlfcn.h errno.h \
  20. fcntl.h libgen.h libintl.h memory.h \
  21. netinet/in.h setjmp.h stdbool.h sysexits.h \
  22. unistd.h utime.h])
  23. AC_CHECK_HEADERS([stdarg.h varargs.h],
  24. [lo_have_arg_hdr=true;break],
  25. [lo_have_arg_hdr=false])
  26. AC_CHECK_HEADERS([string.h strings.h],
  27. [lo_have_str_hdr=true;break],
  28. [lo_have_str_hdr=false])
  29. AC_CHECK_HEADERS([limits.h sys/limits.h values.h],
  30. [lo_have_lim_hdr=true;break],
  31. [lo_have_lim_hdr=false])
  32. AC_CHECK_HEADERS([inttypes.h stdint.h],
  33. [lo_have_typ_hdr=true;break],
  34. [lo_have_typ_hdr=false])
  35. gl_STDNORETURN_H
  36. # ----------------------------------------------------------------------
  37. # check for various programs used during the build.
  38. # On OS/X, "wchar.h" needs "runetype.h" to work properly.
  39. # ----------------------------------------------------------------------
  40. AC_CHECK_HEADERS([runetype.h wchar.h], [], [],[
  41. AC_INCLUDES_DEFAULT
  42. #if HAVE_RUNETYPE_H
  43. # include <runetype.h>
  44. #endif
  45. ])
  46. AC_ARG_ENABLE([nls],
  47. AS_HELP_STRING([--disable-nls],[disable nls support in libopts]))
  48. AS_IF([test "x$enable_nls" != "xno" && \
  49. test "X${ac_cv_header_libintl_h}" = Xyes], [
  50. AC_DEFINE([ENABLE_NLS],[1],[nls support in libopts])])
  51. # --------------------------------------------
  52. # Verify certain entries from AC_CHECK_HEADERS
  53. # --------------------------------------------
  54. [${lo_have_arg_hdr} || \
  55. ]AC_MSG_ERROR([you must have stdarg.h or varargs.h on your system])[
  56. ${lo_have_str_hdr} || \
  57. ]AC_MSG_ERROR([you must have string.h or strings.h on your system])[
  58. ${lo_have_lim_hdr} || \
  59. ]AC_MSG_ERROR(
  60. [you must have one of limits.h, sys/limits.h or values.h])[
  61. ${lo_have_typ_hdr} || \
  62. ]AC_MSG_ERROR([you must have inttypes.h or stdint.h on your system])[
  63. for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
  64. do eval as_ac_var=\${ac_cv_header_${f}_h}
  65. test "X${as_ac_var}" = Xyes || {
  66. ]AC_MSG_ERROR([you must have ${f}.h on your system])[
  67. }
  68. done
  69. test "X${ac_cv_header_inttypes_h-no}" = Xyes || \
  70. echo '#include <stdint.h>' > inttypes.h]
  71. # ----------------------------------------------------------------------
  72. # Checks for typedefs
  73. # ----------------------------------------------------------------------
  74. AC_CHECK_TYPES(wchar_t)
  75. AC_CHECK_TYPES(wint_t, [], [], [
  76. AC_INCLUDES_DEFAULT
  77. #if HAVE_RUNETYPE_H
  78. # include <runetype.h>
  79. #endif
  80. #if HAVE_WCHAR_H
  81. # include <wchar.h>
  82. #endif
  83. ])
  84. AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
  85. intptr_t, uintptr_t, uint_t, pid_t, size_t, ptrdiff_t])
  86. AC_CHECK_SIZEOF(char *, 8)
  87. AC_CHECK_SIZEOF(int, 4)
  88. AC_CHECK_SIZEOF(long, 8)
  89. AC_CHECK_SIZEOF(short, 2)
  90. # ------------
  91. # AC_CHECK_LIB
  92. # ------------
  93. AC_CHECK_LIB(gen, pathfind)
  94. AC_CHECK_LIB(intl,gettext)
  95. AC_FUNC_VPRINTF
  96. AC_FUNC_FORK
  97. AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
  98. strrchr strsignal fchmod fstat chmod])
  99. AC_PROG_SED
  100. [while :
  101. do
  102. POSIX_SHELL=`which bash`
  103. test -x "$POSIX_SHELL" && break
  104. POSIX_SHELL=`which dash`
  105. test -x "$POSIX_SHELL" && break
  106. POSIX_SHELL=/usr/xpg4/bin/sh
  107. test -x "$POSIX_SHELL" && break
  108. POSIX_SHELL=`/bin/sh -c '
  109. exec 2>/dev/null
  110. if ! true ; then exit 1 ; fi
  111. echo /bin/sh'`
  112. test -x "$POSIX_SHELL" && break
  113. ]AC_MSG_ERROR([cannot locate a working POSIX shell])[
  114. done]
  115. AC_DEFINE_UNQUOTED([POSIX_SHELL], ["${POSIX_SHELL}"],
  116. [define to a working POSIX compliant shell])
  117. AC_SUBST([POSIX_SHELL])
  118. ])
  119. dnl
  120. dnl @synopsis INVOKE_LIBOPTS_MACROS
  121. dnl
  122. dnl This macro will invoke the AutoConf macros specified in libopts.def
  123. dnl that have not been disabled with "omit-invocation".
  124. dnl
  125. AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
  126. AC_ARG_WITH([regex-header],
  127. AS_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
  128. [libopts_cv_with_regex_header=${with_regex_header}],
  129. AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
  130. libopts_cv_with_regex_header=no)
  131. ) # end of AC_ARG_WITH
  132. if test "X${libopts_cv_with_regex_header}" != Xno
  133. then
  134. AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
  135. else
  136. AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
  137. fi
  138. ]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
  139. AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
  140. AC_ARG_WITH([libregex],
  141. AS_HELP_STRING([--with-libregex], [libregex installation prefix]),
  142. [libopts_cv_with_libregex_root=${with_libregex}],
  143. AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
  144. libopts_cv_with_libregex_root=no)
  145. ) # end of AC_ARG_WITH libregex
  146. if test "${with_libregex+set}" = set && \
  147. test "X${withval}" = Xno
  148. then ## disabled by request
  149. libopts_cv_with_libregex_root=no
  150. libopts_cv_with_libregex_cflags=no
  151. libopts_cv_with_libregex_libs=no
  152. else
  153. AC_ARG_WITH([libregex-cflags],
  154. AS_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
  155. [libopts_cv_with_libregex_cflags=${with_libregex_cflags}],
  156. AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
  157. libopts_cv_with_libregex_cflags=no)
  158. ) # end of AC_ARG_WITH libregex-cflags
  159. AC_ARG_WITH([libregex-libs],
  160. AS_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
  161. [libopts_cv_with_libregex_libs=${with_libregex_libs}],
  162. AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
  163. libopts_cv_with_libregex_libs=no)
  164. ) # end of AC_ARG_WITH libregex-libs
  165. case "X${libopts_cv_with_libregex_cflags}" in
  166. Xyes|Xno|X )
  167. case "X${libopts_cv_with_libregex_root}" in
  168. Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
  169. * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
  170. esac
  171. esac
  172. case "X${libopts_cv_with_libregex_libs}" in
  173. Xyes|Xno|X )
  174. case "X${libopts_cv_with_libregex_root}" in
  175. Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
  176. * ) libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex" ;;
  177. esac
  178. esac
  179. libopts_save_CPPFLAGS="${CPPFLAGS}"
  180. libopts_save_LIBS="${LIBS}"
  181. case "X${libopts_cv_with_libregex_cflags}" in
  182. Xyes|Xno|X )
  183. libopts_cv_with_libregex_cflags="" ;;
  184. * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
  185. esac
  186. case "X${libopts_cv_with_libregex_libs}" in
  187. Xyes|Xno|X )
  188. libopts_cv_with_libregex_libs="" ;;
  189. * )
  190. LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
  191. esac
  192. LIBREGEX_CFLAGS=""
  193. LIBREGEX_LIBS=""
  194. AC_MSG_CHECKING([whether libregex functions properly])
  195. AC_CACHE_VAL([libopts_cv_with_libregex],[
  196. AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
  197. @%:@include <stdlib.h>
  198. @%:@include <sys/types.h>
  199. @%:@include REGEX_HEADER
  200. static regex_t re;
  201. void comp_re(char const * pzPat) {
  202. int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
  203. if (res == 0) return;
  204. exit( res ); }
  205. int main() {
  206. regmatch_t m@<:@2@:>@;
  207. comp_re( "^.*\@S|@" );
  208. comp_re( "()|no.*" );
  209. comp_re( "." );
  210. if (regexec( &re, "X", 2, m, 0 ) != 0) return 1;
  211. if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
  212. fputs( "error: regex -->.<-- did not match\n", stderr );
  213. return 1;
  214. }
  215. return 0; }])],
  216. [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
  217. [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE
  218. ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
  219. fi ## disabled by request
  220. AC_MSG_RESULT([${libopts_cv_with_libregex}])
  221. if test "X${libopts_cv_with_libregex}" != Xno
  222. then
  223. AC_DEFINE([WITH_LIBREGEX],[1],
  224. [Define this if a working libregex can be found])
  225. else
  226. CPPFLAGS="${libopts_save_CPPFLAGS}"
  227. LIBS="${libopts_save_LIBS}"
  228. libopts_cv_with_libregex_root=no
  229. libopts_cv_with_libregex_cflags=no
  230. libopts_cv_with_libregex_libs=no
  231. libopts_cv_with_libregex=no
  232. fi
  233. ]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
  234. AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
  235. AC_MSG_CHECKING([whether pathfind(3) works])
  236. AC_CACHE_VAL([libopts_cv_run_pathfind],[
  237. AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <string.h>
  238. @%:@include <stdlib.h>
  239. int main (int argc, char ** argv) {
  240. char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
  241. return (pz == 0) ? 1 : 0;
  242. }])],
  243. [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
  244. ) # end of RUN_IFELSE
  245. ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
  246. AC_MSG_RESULT([${libopts_cv_run_pathfind}])
  247. if test "X${libopts_cv_run_pathfind}" != Xno
  248. then
  249. AC_DEFINE([HAVE_PATHFIND],[1],
  250. [Define this if pathfind(3) works])
  251. fi
  252. ]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
  253. AC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
  254. AC_MSG_CHECKING([whether /dev/zero is readable device])
  255. AC_CACHE_VAL([libopts_cv_test_dev_zero],[
  256. libopts_cv_test_dev_zero=`exec 2> /dev/null
  257. dzero=\`ls -lL /dev/zero | egrep ^c......r\`
  258. test -z "${dzero}" && exit 1
  259. echo ${dzero}`
  260. if test $? -ne 0 || test -z "$libopts_cv_test_dev_zero"
  261. then libopts_cv_test_dev_zero=no
  262. fi
  263. ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
  264. AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
  265. if test "X${libopts_cv_test_dev_zero}" != Xno
  266. then
  267. AC_DEFINE([HAVE_DEV_ZERO],[1],
  268. [Define this if /dev/zero is readable device])
  269. fi
  270. ]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
  271. AC_DEFUN([LIBOPTS_RUN_REALPATH],[
  272. AC_MSG_CHECKING([whether we have a functional realpath(3C)])
  273. AC_CACHE_VAL([libopts_cv_run_realpath],[
  274. AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <limits.h>
  275. @%:@include <stdlib.h>
  276. int main (int argc, char ** argv) {
  277. @%:@ifndef PATH_MAX
  278. choke me!!
  279. @%:@else
  280. char zPath@<:@PATH_MAX+1@:>@;
  281. @%:@endif
  282. char *pz = realpath(argv@<:@0@:>@, zPath);
  283. return (pz == zPath) ? 0 : 1;
  284. }])],
  285. [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
  286. ) # end of RUN_IFELSE
  287. ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
  288. AC_MSG_RESULT([${libopts_cv_run_realpath}])
  289. if test "X${libopts_cv_run_realpath}" != Xno
  290. then
  291. AC_DEFINE([HAVE_REALPATH],[1],
  292. [Define this if we have a functional realpath(3C)])
  293. fi
  294. ]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
  295. AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
  296. AC_MSG_CHECKING([whether strftime() works])
  297. AC_CACHE_VAL([libopts_cv_run_strftime],[
  298. AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <time.h>
  299. @%:@include <string.h>
  300. char t_buf@<:@ 64 @:>@;
  301. int main() {
  302. static char const z@<:@@:>@ = "Thursday Aug 28 240";
  303. struct tm tm;
  304. tm.tm_sec = 36; /* seconds after the minute @<:@0, 61@:>@ */
  305. tm.tm_min = 44; /* minutes after the hour @<:@0, 59@:>@ */
  306. tm.tm_hour = 12; /* hour since midnight @<:@0, 23@:>@ */
  307. tm.tm_mday = 28; /* day of the month @<:@1, 31@:>@ */
  308. tm.tm_mon = 7; /* months since January @<:@0, 11@:>@ */
  309. tm.tm_year = 86; /* years since 1900 */
  310. tm.tm_wday = 4; /* days since Sunday @<:@0, 6@:>@ */
  311. tm.tm_yday = 239; /* days since January 1 @<:@0, 365@:>@ */
  312. tm.tm_isdst = 1; /* flag for daylight savings time */
  313. strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
  314. return (strcmp( t_buf, z ) != 0); }])],
  315. [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
  316. ) # end of RUN_IFELSE
  317. ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
  318. AC_MSG_RESULT([${libopts_cv_run_strftime}])
  319. if test "X${libopts_cv_run_strftime}" != Xno
  320. then
  321. AC_DEFINE([HAVE_STRFTIME],[1],
  322. [Define this if strftime() works])
  323. fi
  324. ]) # 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_RUN_IFELSE([AC_LANG_SOURCE([@%:@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]
  333. ) # end of RUN_IFELSE
  334. ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
  335. AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
  336. if test "X${libopts_cv_run_fopen_binary}" != Xno
  337. then
  338. AC_DEFINE([FOPEN_BINARY_FLAG],"b",
  339. [fopen(3) accepts a 'b' in the mode flag])
  340. else
  341. AC_DEFINE([FOPEN_BINARY_FLAG],"",
  342. [fopen(3) accepts a 'b' in the mode flag])
  343. fi
  344. ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
  345. AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
  346. AC_MSG_CHECKING([whether fopen accepts "t" mode])
  347. AC_CACHE_VAL([libopts_cv_run_fopen_text],[
  348. AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
  349. int main (int argc, char ** argv) {
  350. FILE * fp = fopen("conftest.@S|@ac_ext", "rt");
  351. return (fp == NULL) ? 1 : fclose(fp); }])],
  352. [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
  353. ) # end of RUN_IFELSE
  354. ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
  355. AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
  356. if test "X${libopts_cv_run_fopen_text}" != Xno
  357. then
  358. AC_DEFINE([FOPEN_TEXT_FLAG],"t",
  359. [fopen(3) accepts a 't' in the mode flag])
  360. else
  361. AC_DEFINE([FOPEN_TEXT_FLAG],"",
  362. [fopen(3) accepts a 't' in the mode flag])
  363. fi
  364. ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
  365. AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
  366. AC_ARG_ENABLE([optional-args],
  367. AS_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
  368. [libopts_cv_enable_optional_args=${enable_optional_args}],
  369. AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
  370. libopts_cv_enable_optional_args=yes)
  371. ) # end of AC_ARG_ENABLE
  372. if test "X${libopts_cv_enable_optional_args}" = Xno
  373. then
  374. AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
  375. [Define this if optional arguments are disallowed])
  376. fi
  377. ]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
  378. AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
  379. AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
  380. # Check to see if a reg expr header is specified.
  381. LIBOPTS_WITH_REGEX_HEADER
  382. # Check to see if a working libregex can be found.
  383. LIBOPTS_WITHLIB_REGEX
  384. # Check to see if pathfind(3) works.
  385. LIBOPTS_RUN_PATHFIND
  386. # Check to see if /dev/zero is readable device.
  387. LIBOPTS_TEST_DEV_ZERO
  388. # Check to see if we have a functional realpath(3C).
  389. LIBOPTS_RUN_REALPATH
  390. # Check to see if strftime() works.
  391. LIBOPTS_RUN_STRFTIME
  392. # Check to see if fopen accepts "b" mode.
  393. LIBOPTS_RUN_FOPEN_BINARY
  394. # Check to see if fopen accepts "t" mode.
  395. LIBOPTS_RUN_FOPEN_TEXT
  396. # Check to see if not wanting optional option args.
  397. LIBOPTS_DISABLE_OPTIONAL_ARGS
  398. ]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
  399. dnl @synopsis LIBOPTS_CHECK
  400. dnl
  401. dnl If autoopts-config works, add the linking information to LIBS.
  402. dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
  403. dnl the config tests that the library needs. Invoke the
  404. dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
  405. dnl
  406. dnl This file is part of AutoGen.
  407. dnl AutoGen Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
  408. dnl
  409. dnl AutoGen is free software: you can redistribute it and/or modify it
  410. dnl under the terms of the GNU General Public License as published by the
  411. dnl Free Software Foundation, either version 3 of the License, or
  412. dnl (at your option) any later version.
  413. dnl
  414. dnl AutoGen is distributed in the hope that it will be useful, but
  415. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  416. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  417. dnl See the GNU General Public License for more details.
  418. dnl
  419. dnl You should have received a copy of the GNU General Public License along
  420. dnl with this program. If not, see <http://www.gnu.org/licenses/>.
  421. dnl
  422. dnl Default to system libopts
  423. dnl
  424. AC_DEFUN([LIBOPTS_CHECK_COMMON],[
  425. AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
  426. [NEED_LIBOPTS_DIR='']
  427. m4_pushdef([AO_Libopts_Dir],
  428. [ifelse($1, , [libopts], [$1])])
  429. AC_ARG_ENABLE([local-libopts],
  430. AS_HELP_STRING([--enable-local-libopts],[Use the supplied libopts tearoff code]),[
  431. if test x$enableval = xyes ; then
  432. AC_MSG_NOTICE([Using supplied libopts tearoff])
  433. LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
  434. NEED_LIBOPTS_DIR=true
  435. LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
  436. fi])
  437. AC_ARG_ENABLE([libopts-install],
  438. AS_HELP_STRING([--enable-libopts-install],[Install libopts with client installation]))
  439. AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" = Xyes])
  440. [if test -z "${NEED_LIBOPTS_DIR}" ; then]
  441. AC_MSG_CHECKING([whether autoopts-config can be found])
  442. AC_ARG_WITH([autoopts-config],
  443. AS_HELP_STRING([--with-autoopts-config],[specify the config-info script]),
  444. [lo_cv_with_autoopts_config=${with_autoopts_config}],
  445. AC_CACHE_CHECK([whether autoopts-config is specified],
  446. [lo_cv_with_autoopts_config],
  447. [if autoopts-config --help 2>/dev/null 1>&2
  448. then lo_cv_with_autoopts_config=autoopts-config
  449. elif libopts-config --help 2>/dev/null 1>&2
  450. then lo_cv_with_autoopts_config=libopts-config
  451. else lo_cv_with_autoopts_config=no ; fi])
  452. ) # end of AC_ARG_WITH
  453. AC_CACHE_VAL([lo_cv_test_autoopts],[
  454. if test -z "${lo_cv_with_autoopts_config}" \
  455. -o X"${lo_cv_with_autoopts_config}" = Xno
  456. then
  457. if autoopts-config --help 2>/dev/null 1>&2
  458. then lo_cv_with_autoopts_config=autoopts-config
  459. elif libopts-config --help 2>/dev/null 1>&2
  460. then lo_cv_with_autoopts_config=libopts-config
  461. else lo_cv_with_autoopts_config=false ; fi
  462. fi
  463. lo_cv_test_autoopts=`
  464. ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
  465. if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
  466. then lo_cv_test_autoopts=no ; fi
  467. ]) # end of CACHE_VAL
  468. AC_MSG_RESULT([${lo_cv_test_autoopts}])
  469. [if test "X${lo_cv_test_autoopts}" != Xno
  470. then
  471. LIBOPTS_LDADD="${lo_cv_test_autoopts}"
  472. LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
  473. else
  474. LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
  475. LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
  476. NEED_LIBOPTS_DIR=true
  477. fi
  478. fi # end of if test -z "${NEED_LIBOPTS_DIR}"
  479. if test -n "${LIBOPTS_BUILD_BLOCKED}" ; then
  480. NEED_LIBOPTS_DIR=''
  481. fi]
  482. AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
  483. AC_SUBST(LIBOPTS_LDADD)
  484. AC_SUBST(LIBOPTS_CFLAGS)
  485. AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
  486. m4_popdef([AO_Libopts_Dir])
  487. [# end of AC_DEFUN of LIBOPTS_CHECK_COMMON]
  488. ])
  489. dnl
  490. dnl AC_CONFIG_FILES conditionalization requires using AM_COND_IF, however
  491. dnl AM_COND_IF is new to Automake 1.11. To use it on new Automake without
  492. dnl requiring same, a fallback implementation for older Automake is provided.
  493. dnl Note that disabling of AC_CONFIG_FILES requires Automake 1.11, this code
  494. dnl is correct only in terms of m4sh generated script.
  495. dnl
  496. m4_ifndef([AM_COND_IF],
  497. [AC_DEFUN([AM_COND_IF], [
  498. if test -z "$$1_TRUE"; then :
  499. m4_n([$2])[]dnl
  500. m4_ifval([$3],[
  501. else
  502. $3
  503. ])dnl
  504. fi[]dnl
  505. ])dnl
  506. ])
  507. dnl
  508. AC_DEFUN([LIBOPTS_CHECK_NOBUILD], [
  509. m4_pushdef([AO_Libopts_Dir],
  510. [ifelse($1, , [libopts], [$1])])
  511. LIBOPTS_BUILD_BLOCKED=true
  512. LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
  513. m4_popdef([AO_Libopts_Dir])dnl
  514. # end of AC_DEFUN of LIBOPTS_CHECK_NOBUILD
  515. ])
  516. dnl
  517. AC_DEFUN([LIBOPTS_CHECK], [
  518. m4_pushdef([AO_Libopts_Dir],
  519. [ifelse($1, , [libopts], [$1])])
  520. LIBOPTS_BUILD_BLOCKED=''
  521. LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
  522. AM_COND_IF([NEED_LIBOPTS], [
  523. INVOKE_LIBOPTS_MACROS
  524. ])
  525. AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
  526. m4_popdef([AO_Libopts_Dir])dnl
  527. # end of AC_DEFUN of LIBOPTS_CHECK
  528. ])