libopts.m4 20 KB

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