1
0

libopts.m4 20 KB

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