acinclude.m4 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. dnl aclocal.m4
  2. dnl macros autoconf uses when building configure from configure.in
  3. dnl
  4. dnl
  5. dnl EGG_CHECK_CC()
  6. dnl
  7. dnl FIXME: make a better test
  8. dnl
  9. AC_DEFUN(EGG_CHECK_CC, [dnl
  10. if test "${cross_compiling-x}" = "x"
  11. then
  12. cat << 'EOF' >&2
  13. configure: error:
  14. This system does not appear to have a working C compiler.
  15. A working C compiler is required to compile Eggdrop.
  16. EOF
  17. exit 1
  18. fi
  19. ])dnl
  20. dnl EGG_IPV6_OPTIONS()
  21. dnl
  22. AC_DEFUN(EGG_IPV6_OPTIONS, [dnl
  23. AC_MSG_CHECKING(whether or not you disabled IPv6 support)
  24. AC_ARG_ENABLE(ipv6, [ --disable-ipv6 disable IPv6 support],
  25. [ ac_cv_dipv6="yes"
  26. AC_MSG_RESULT(yes)
  27. ],
  28. [ ac_cv_dipv6="no"
  29. if test "$egg_cv_ipv6_supported" = "no"; then
  30. ac_cv_dipv6="no"
  31. fi
  32. AC_MSG_RESULT($ac_cv_dipv6)
  33. ])
  34. if test "$ac_cv_dipv6" = "no"; then
  35. AC_DEFINE(USE_IPV6, 1, [Define if you want ipv6 support])
  36. fi
  37. ])dnl
  38. dnl EGG_CHECK_SOCKLEN_T()
  39. dnl
  40. AC_DEFUN(EGG_CHECK_SOCKLEN_T, [dnl
  41. AC_MSG_CHECKING(for socklen_t)
  42. AC_CACHE_VAL(egg_cv_socklen_t,[
  43. AC_TRY_RUN([
  44. #include <unistd.h>
  45. #include <sys/types.h>
  46. #include <sys/socket.h>
  47. #include <netinet/in.h>
  48. #include <arpa/inet.h>
  49. int main()
  50. {
  51. socklen_t test = sizeof(int);
  52. return 0;
  53. }
  54. ],
  55. egg_cv_socklen_t=yes, egg_cv_socklen_t=no, egg_cv_socklen_t=no)])
  56. if test "$egg_cv_socklen_t" = "yes"; then
  57. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define if you have support for socklen_t])
  58. AC_MSG_RESULT(yes)
  59. else
  60. AC_MSG_RESULT(no)
  61. fi
  62. ])dnl
  63. dnl EGG_CHECK_CCPIPE()
  64. dnl
  65. dnl Checks whether the compiler supports the `-pipe' flag, which
  66. dnl speeds up the compilation.
  67. AC_DEFUN(EGG_CHECK_CCPIPE, [dnl
  68. if test -z "$no_pipe"
  69. then
  70. if test -n "$GCC"
  71. then
  72. AC_CACHE_CHECK(whether the compiler understands -pipe, egg_cv_var_ccpipe, [dnl
  73. ac_old_CC="$CC"
  74. CC="$CC -pipe"
  75. AC_TRY_COMPILE(,, egg_cv_var_ccpipe="yes", egg_cv_var_ccpipe="no")
  76. CC="$ac_old_CC"
  77. ])
  78. if test "$egg_cv_var_ccpipe" = "yes"
  79. then
  80. CC="$CC -pipe"
  81. fi
  82. fi
  83. fi
  84. ])dnl
  85. dnl EGG_CHECK_CCSTATIC()
  86. dnl
  87. dnl Checks whether the compiler supports the `-static' flag.
  88. AC_DEFUN(EGG_CHECK_CCSTATIC, [dnl
  89. if test -z "$no_static"
  90. then
  91. if test -n "$GCC"
  92. then
  93. AC_CACHE_CHECK(whether the compiler understands -static, egg_cv_var_ccstatic, [dnl
  94. ac_old_CC="$CC"
  95. CC="$CC -static"
  96. AC_TRY_COMPILE(,, egg_cv_var_ccstatic="yes", egg_cv_var_ccstatic="no")
  97. CC="$ac_old_CC"
  98. ])
  99. if test "$egg_cv_var_ccstatic" = "yes"
  100. then
  101. CCDEBUG="$CC"
  102. CC="$CC -static"
  103. else
  104. cat << 'EOF' >&2
  105. configure: error:
  106. Your C compiler does not support -static.
  107. This compile flag is required for the botpack.
  108. EOF
  109. exit 1
  110. fi
  111. fi
  112. fi
  113. ])dnl
  114. dnl EGG_PROG_HEAD_1()
  115. dnl
  116. AC_DEFUN(EGG_PROG_HEAD_1,
  117. [cat << 'EOF' > conftest.head
  118. a
  119. b
  120. c
  121. EOF
  122. for ac_prog in 'head -1' 'head -n 1' 'sed 1q';
  123. do
  124. AC_MSG_CHECKING([whether $ac_prog works])
  125. AC_CACHE_VAL(ac_cv_prog_HEAD_1,
  126. [ if test -n "$HEAD_1"
  127. then
  128. ac_cv_prog_HEAD_1="$HEAD_1" # Let the user override the test.
  129. else
  130. if test "`cat conftest.head | $ac_prog`" = "a";
  131. then
  132. AC_MSG_RESULT([yes])
  133. ac_cv_prog_HEAD_1=$ac_prog
  134. else
  135. AC_MSG_RESULT([no])
  136. fi
  137. fi])dnl
  138. test -n "$ac_cv_prog_HEAD_1" && break
  139. done
  140. if test "${ac_cv_prog_HEAD_1-x}" = "x"
  141. then
  142. cat << 'EOF' >&2
  143. configure: error:
  144. This system seems to lack a working 'head -1' or 'head -n 1' command.
  145. A working 'head -1' (or equivalent) command is required to compile Eggdrop.
  146. EOF
  147. exit 1
  148. fi
  149. rm -f conftest.head
  150. HEAD_1=$ac_cv_prog_HEAD_1
  151. AC_SUBST(HEAD_1)dnl
  152. ])dnl
  153. dnl EGG_PROG_AWK()
  154. dnl
  155. AC_DEFUN(EGG_PROG_AWK, [dnl
  156. # awk is needed for Tcl library and header checks, and eggdrop version subst
  157. AC_PROG_AWK
  158. if test "${AWK-x}" = "x"
  159. then
  160. cat << 'EOF' >&2
  161. configure: error:
  162. This system seems to lack a working 'awk' command.
  163. A working 'awk' command is required to compile Eggdrop.
  164. EOF
  165. exit 1
  166. fi
  167. ])dnl
  168. dnl EGG_PROG_BASENAME()
  169. dnl
  170. AC_DEFUN(EGG_PROG_BASENAME, [dnl
  171. # basename is needed for Tcl library and header checks
  172. AC_CHECK_PROG(BASENAME, basename, basename)
  173. if test "${BASENAME-x}" = "x"
  174. then
  175. cat << 'EOF' >&2
  176. configure: error:
  177. This system seems to lack a working 'basename' command.
  178. A working 'basename' command is required to compile Eggdrop.
  179. EOF
  180. exit 1
  181. fi
  182. ])dnl
  183. dnl EGG_CHECK_OS()
  184. dnl
  185. dnl FIXME/NOTICE:
  186. dnl This function is obsolete. Any NEW code/checks should be written
  187. dnl as individual tests that will be checked on ALL operating systems.
  188. dnl
  189. AC_DEFUN(EGG_CHECK_OS, [dnl
  190. LINUX=no
  191. IRIX=no
  192. SUNOS=no
  193. EGG_CYGWIN=no
  194. AC_CACHE_CHECK(system type, egg_cv_var_system_type, egg_cv_var_system_type=`$UNAME -s`)
  195. AC_CACHE_CHECK(system release, egg_cv_var_system_release, egg_cv_var_system_release=`$UNAME -r`)
  196. case "$egg_cv_var_system_type" in
  197. BSD/OS)
  198. case "`echo $egg_cv_var_system_release | cut -d . -f 1`" in
  199. 2)
  200. ;;
  201. *)
  202. CFLAGS="$CFLAGS -Wall"
  203. ;;
  204. esac
  205. ;;
  206. CYGWI*)
  207. case "`echo $egg_cv_var_system_release | cut -c 1-3`" in
  208. 1.*)
  209. AC_PROG_CC_WIN32
  210. CC="$CC $WIN32FLAGS"
  211. AC_MSG_CHECKING(for /usr/lib/binmode.o)
  212. if test -r /usr/lib/binmode.o
  213. then
  214. AC_MSG_RESULT(yes)
  215. LIBS="$LIBS /usr/lib/binmode.o"
  216. else
  217. AC_MSG_RESULT(no)
  218. AC_MSG_WARN(Make sure the directory Eggdrop is installed into is mounted in binary mode.)
  219. fi
  220. ;;
  221. *)
  222. AC_MSG_WARN(Make sure the directory Eggdrop is installed into is mounted in binary mode.)
  223. ;;
  224. esac
  225. EGG_CYGWIN=yes
  226. AC_DEFINE(CYGWIN_HACKS, 1, [Define if running under cygwin])
  227. ;;
  228. IRIX)
  229. IRIX=yes
  230. ;;
  231. Ultrix)
  232. SHELL=/bin/sh5
  233. ;;
  234. SINIX*)
  235. ;;
  236. BeOS)
  237. ;;
  238. Linux)
  239. LINUX=yes
  240. CFLAGS="$CFLAGS -Wall"
  241. ;;
  242. Lynx)
  243. ;;
  244. QNX)
  245. ;;
  246. OSF1)
  247. case "`echo $egg_cv_var_system_release | cut -d . -f 1`" in
  248. V*)
  249. # FIXME: we should check this in a separate test
  250. # Digital OSF uses an ancient version of gawk
  251. if test "$AWK" = "gawk"
  252. then
  253. AWK=awk
  254. fi
  255. ;;
  256. 1.0|1.1|1.2)
  257. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  258. ;;
  259. 1.*)
  260. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  261. ;;
  262. *)
  263. ;;
  264. esac
  265. AC_DEFINE(STOP_UAC, 1, [Define if running on OSF/1 platform])dnl
  266. AC_DEFINE(BROKEN_SNPRINTF, 1, [Define to use Eggdrop's snprintf functions without regard to HAVE_SNPRINTF])dnl
  267. ;;
  268. SunOS)
  269. if ! test "`echo $egg_cv_var_system_release | cut -d . -f 1`" = "5"
  270. then
  271. # SunOS 4
  272. SUNOS=yes
  273. fi
  274. ;;
  275. *BSD)
  276. # FreeBSD/OpenBSD/NetBSD
  277. ;;
  278. *)
  279. AC_MSG_CHECKING(if system is Mach based)
  280. if test -r /mach
  281. then
  282. AC_MSG_RESULT(yes)
  283. AC_DEFINE(BORGCUBES, 1, [Define if running on NeXT Step])dnl
  284. else
  285. AC_MSG_RESULT(no)
  286. AC_MSG_CHECKING(if system is QNX)
  287. if test -r /cmds
  288. then
  289. AC_MSG_RESULT(yes)
  290. else
  291. AC_MSG_RESULT(no)
  292. AC_MSG_RESULT(Something unknown!)
  293. AC_MSG_RESULT([If you get dynamic modules to work, be sure to let the devel team know HOW :)])
  294. fi
  295. fi
  296. ;;
  297. esac
  298. ])dnl
  299. dnl EGG_CHECK_LIBS()
  300. dnl
  301. AC_DEFUN(EGG_CHECK_LIBS, [dnl
  302. # FIXME: this needs to be fixed so that it works on IRIX
  303. if test "$IRIX" = "yes"
  304. then
  305. AC_MSG_WARN(Skipping library tests because they CONFUSE Irix.)
  306. else
  307. AC_CHECK_LIB(socket, socket)
  308. # AC_CHECK_LIB(nsl, connect)
  309. AC_CHECK_LIB(dns, gethostbyname)
  310. AC_CHECK_LIB(z, gzopen, ZLIB="-lz")
  311. # AC_CHECK_LIB(ssl, SSL_accept, SSL="-lssl -lcrypto", SSL="", -lcrypto)
  312. # AC_CHECK_LIB(ssl, SSL_accept, SSL="-lcrypto", SSL="", -lcrypto)
  313. # This is needed for Tcl libraries compiled with thread support
  314. # AC_CHECK_LIB(pthread, pthread_mutex_init, [dnl
  315. # ac_cv_lib_pthread_pthread_mutex_init=yes
  316. # ac_cv_lib_pthread="-lpthread"], [dnl
  317. # AC_CHECK_LIB(pthread, __pthread_mutex_init, [dnl
  318. # ac_cv_lib_pthread_pthread_mutex_init=yes
  319. # ac_cv_lib_pthread="-lpthread"], [dnl
  320. # AC_CHECK_LIB(pthreads, pthread_mutex_init, [dnl
  321. # ac_cv_lib_pthread_pthread_mutex_init=yes
  322. # ac_cv_lib_pthread="-lpthreads"], [dnl
  323. # AC_CHECK_FUNC(pthread_mutex_init, [dnl
  324. # ac_cv_lib_pthread_pthread_mutex_init=yes
  325. # ac_cv_lib_pthread=""],
  326. # ac_cv_lib_pthread_pthread_mutex_init=no)])])])
  327. fi
  328. ])dnl
  329. dnl EGG_CHECK_FUNC_VSPRINTF()
  330. dnl
  331. AC_DEFUN(EGG_CHECK_FUNC_VSPRINTF, [dnl
  332. AC_CHECK_FUNCS(vsprintf)
  333. if test "$ac_cv_func_vsprintf" = "no"
  334. then
  335. cat << 'EOF' >&2
  336. configure: error:
  337. Your system does not have the sprintf/vsprintf libraries.
  338. These are required to compile almost anything. Sorry.
  339. EOF
  340. exit 1
  341. fi
  342. ])dnl
  343. dnl EGG_CHECK_FUNC_UNAME()
  344. dnl
  345. AC_DEFUN(EGG_CHECK_FUNC_UNAME, [dnl
  346. AC_CHECK_FUNCS(uname)
  347. if test "$ac_cv_func_uname" = "no"
  348. then
  349. cat << 'EOF' >&2
  350. configure: error:
  351. Your system does not have the uname() function.
  352. This is required for the botpack.
  353. EOF
  354. exit 1
  355. fi
  356. ])dnl
  357. dnl EGG_CHECK_ZLIB()
  358. dnl
  359. AC_DEFUN(EGG_CHECK_ZLIB, [dnl
  360. if test "x${ZLIB}" = x; then
  361. cat >&2 <<EOF
  362. configure: error:
  363. Your system does not provide a working zlib compression library.
  364. It is required.
  365. EOF
  366. exit 1
  367. else
  368. if test "${ac_cv_header_zlib_h}" != yes; then
  369. cat >&2 <<EOF
  370. configure: error:
  371. Your system does not provide the necessary zlib header file.
  372. It is required.
  373. EOF
  374. exit 1
  375. fi
  376. fi
  377. ])dnl
  378. dnl EGG_CHECK_SSL()
  379. dnl
  380. AC_DEFUN(EGG_CHECK_SSL, [dnl
  381. if test "x${SSL}" = x; then
  382. cat >&2 <<EOF
  383. configure: error:
  384. Your system does not provide a working ssl library.
  385. It is required. Download openssl at www.openssl.org
  386. EOF
  387. exit 1
  388. else
  389. if test "${ac_cv_header_openssl_ssl_h}" != yes; then
  390. cat >&2 <<EOF
  391. configure: error:
  392. Your system does not provide the necessary ssl header file.
  393. It is required. Download openssl at www.openssl.org
  394. EOF
  395. exit 1
  396. fi
  397. fi
  398. ])dnl
  399. dnl EGG_HEADER_STDC()
  400. dnl
  401. AC_DEFUN(EGG_HEADER_STDC, [dnl
  402. if test "$ac_cv_header_stdc" = "no"
  403. then
  404. cat << 'EOF' >&2
  405. configure: error:
  406. Your system must support ANSI C Header files.
  407. These are required for the language support. Sorry.
  408. EOF
  409. exit 1
  410. fi
  411. ])dnl
  412. dnl EGG_CACHE_UNSET(CACHE-ID)
  413. dnl
  414. dnl Unsets a certain cache item. Typically called before using
  415. dnl the AC_CACHE_*() macros.
  416. AC_DEFUN(EGG_CACHE_UNSET, [dnl
  417. unset $1
  418. ])
  419. dnl EGG_SUBST_VERSION()
  420. dnl
  421. AC_DEFUN(EGG_SUBST_VERSION, [dnl
  422. VERSION=`grep "char" $srcdir/src/main.c | $AWK '/egg_version/ {print [$]5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
  423. if ! test -f $cfg; then
  424. cat << EOF >&2
  425. configure: error:
  426. Your pack cfg is missing, please copy it to $srcdir/$cfg
  427. Or specify the path to it with: --with-cfg=
  428. EOF
  429. exit 1
  430. fi
  431. PACKNAME=`grep "PACKNAME " $cfg | $AWK '/PACKNAME/ {print [$]2}'`
  432. version_num=`echo $VERSION | $AWK 'BEGIN {FS = "."} {printf("%d%02d%02d", [$]1, [$]2, [$]3)}'`
  433. AC_DEFINE_UNQUOTED(EGG_VERSION, $version_num, [Defines the current pack version])dnl
  434. AC_SUBST(VERSION)dnl
  435. AC_SUBST(NUMVER)dnl
  436. AC_SUBST(PACKNAME)dnl
  437. ])dnl
  438. dnl EGG_SUBST_MOD_UPDIR()
  439. dnl
  440. dnl Since module's Makefiles aren't generated by configure, some
  441. dnl paths in src/mod/Makefile.in take care of them. For correct
  442. dnl path "calculation", we need to keep absolute paths in mind
  443. dnl (which don't need a "../" pre-pended).
  444. AC_DEFUN(EGG_SUBST_MOD_UPDIR, [dnl
  445. case "$srcdir" in
  446. [[\\/]]* | ?:[[\\/]]*)
  447. MOD_UPDIR=""
  448. ;;
  449. *)
  450. MOD_UPDIR="../"
  451. ;;
  452. esac
  453. AC_SUBST(MOD_UPDIR)dnl
  454. ])dnl
  455. dnl EGG_REPLACE_IF_CHANGED(FILE-NAME, CONTENTS-CMDS, INIT-CMDS)
  456. dnl
  457. dnl Replace FILE-NAME if the newly created contents differs from the existing
  458. dnl file contents. Otherwise, leave the file alone. This avoids needless
  459. dnl recompiles.
  460. m4_define(EGG_REPLACE_IF_CHANGED,
  461. [
  462. AC_CONFIG_COMMANDS([replace-if-changed],
  463. [[
  464. egg_replace_file="$1"
  465. $2
  466. if test -f "$egg_replace_file" && cmp -s conftest.out $egg_replace_file; then
  467. echo "$1 is unchanged"
  468. else
  469. echo "creating $1"
  470. mv conftest.out $egg_replace_file
  471. fi
  472. rm -f conftest.out
  473. ]],
  474. [[$3]])
  475. ])
  476. dnl EGG_SAVE_PARAMETERS()
  477. dnl
  478. AC_DEFUN(EGG_SAVE_PARAMETERS, [dnl
  479. # Remove --cache-file and --srcdir arguments so they do not pile up.
  480. egg_ac_parameters=
  481. ac_prev=
  482. for ac_arg in $ac_configure_args; do
  483. if test -n "$ac_prev"; then
  484. ac_prev=
  485. continue
  486. fi
  487. case $ac_arg in
  488. -cache-file | --cache-file | --cache-fil | --cache-fi \
  489. | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
  490. ac_prev=cache_file ;;
  491. -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  492. | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
  493. | --c=*)
  494. ;;
  495. --config-cache | -C)
  496. ;;
  497. -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  498. ac_prev=srcdir ;;
  499. -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  500. ;;
  501. *) egg_ac_parameters="$egg_ac_parameters $ac_arg" ;;
  502. esac
  503. done
  504. AC_SUBST(egg_ac_parameters)dnl
  505. ])dnl
  506. AC_DEFUN([AC_PROG_CC_WIN32], [
  507. AC_MSG_CHECKING([how to access the Win32 API])
  508. WIN32FLAGS=
  509. AC_TRY_COMPILE(,[
  510. #ifndef WIN32
  511. # ifndef _WIN32
  512. # error WIN32 or _WIN32 not defined
  513. # endif
  514. #endif], [
  515. dnl found windows.h with the current config.
  516. AC_MSG_RESULT([present by default])
  517. ], [
  518. dnl try -mwin32
  519. ac_compile_save="$ac_compile"
  520. dnl we change CC so config.log looks correct
  521. save_CC="$CC"
  522. ac_compile="$ac_compile -mwin32"
  523. CC="$CC -mwin32"
  524. AC_TRY_COMPILE(,[
  525. #ifndef WIN32
  526. # ifndef _WIN32
  527. # error WIN32 or _WIN32 not defined
  528. # endif
  529. #endif], [
  530. dnl found windows.h using -mwin32
  531. AC_MSG_RESULT([found via -mwin32])
  532. ac_compile="$ac_compile_save"
  533. CC="$save_CC"
  534. WIN32FLAGS="-mwin32"
  535. ], [
  536. ac_compile="$ac_compile_save"
  537. CC="$save_CC"
  538. AC_MSG_RESULT([not found])
  539. ])
  540. ])
  541. ])
  542. dnl