acinclude.m4 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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. AC_DEFUN(EGG_CHECK_CC, [dnl
  8. if test "${cross_compiling-x}" = "x"
  9. then
  10. cat << 'EOF' >&2
  11. configure: error:
  12. This system does not appear to have a working C compiler.
  13. A working C compiler is required to compile Eggdrop.
  14. EOF
  15. exit 1
  16. fi
  17. if test -n "$GXX"; then
  18. CXXFLAGS="$CXXFLAGS -O3"
  19. fi
  20. ])dnl
  21. dnl EGG_IPV6_OPTIONS()
  22. dnl
  23. AC_DEFUN(EGG_IPV6_OPTIONS, [dnl
  24. AC_MSG_CHECKING(whether or not you disabled IPv6 support)
  25. AC_ARG_ENABLE(ipv6, [ --disable-ipv6 disable IPv6 support],
  26. [ ac_cv_dipv6="yes"
  27. AC_MSG_RESULT(yes)
  28. ],
  29. [ ac_cv_dipv6="no"
  30. if test "$egg_cv_ipv6_supported" = "no"; then
  31. ac_cv_dipv6="no"
  32. fi
  33. AC_MSG_RESULT($ac_cv_dipv6)
  34. ])
  35. if ! test "$EGG_CYGWIN" = "yes"; then
  36. if test "$ac_cv_dipv6" = "no"; then
  37. AC_DEFINE(USE_IPV6, 1, [Define if you want ipv6 support])
  38. fi
  39. fi
  40. ])dnl
  41. dnl EGG_CHECK_SOCKLEN_T()
  42. dnl
  43. AC_DEFUN(EGG_CHECK_SOCKLEN_T, [dnl
  44. AC_MSG_CHECKING(for socklen_t)
  45. AC_CACHE_VAL(egg_cv_socklen_t,[
  46. AC_TRY_RUN([
  47. #include <unistd.h>
  48. #include <sys/types.h>
  49. #include <sys/socket.h>
  50. #include <netinet/in.h>
  51. #include <arpa/inet.h>
  52. int main()
  53. {
  54. socklen_t test = sizeof(int);
  55. return 0;
  56. }
  57. ],
  58. egg_cv_socklen_t=yes, egg_cv_socklen_t=no, egg_cv_socklen_t=no)])
  59. if test "$egg_cv_socklen_t" = "yes"; then
  60. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define if you have support for socklen_t])
  61. AC_MSG_RESULT(yes)
  62. else
  63. AC_MSG_RESULT(no)
  64. fi
  65. ])dnl
  66. dnl EGG_CHECK_CCPIPE()
  67. dnl
  68. dnl This function checks whether or not the compiler supports the `-pipe' flag,
  69. dnl which speeds up the compilation.
  70. dnl
  71. AC_DEFUN([EGG_CHECK_CCPIPE],
  72. [
  73. if test -n "$GXX" && test -z "$no_pipe"; then
  74. AC_CACHE_CHECK([whether the compiler understands -pipe], egg_cv_var_ccpipe, [
  75. ac_old_CXX="$CXX"
  76. CXX="$CXX -pipe"
  77. AC_COMPILE_IFELSE([[
  78. int main ()
  79. {
  80. return(0);
  81. }
  82. ]], [
  83. egg_cv_var_ccpipe="yes"
  84. ], [
  85. egg_cv_var_ccpipe="no"
  86. ])
  87. CXX="$ac_old_CXX"
  88. ])
  89. if test "$egg_cv_var_ccpipe" = "yes"; then
  90. CXX="$CXX -pipe"
  91. fi
  92. fi
  93. ])
  94. dnl EGG_CHECK_CCWALL()
  95. dnl
  96. dnl See if the compiler supports -Wall.
  97. dnl
  98. AC_DEFUN([EGG_CHECK_CCWALL],
  99. [
  100. if test -n "$GXX" && test -z "$no_wall"; then
  101. AC_CACHE_CHECK([whether the compiler understands -Wall], egg_cv_var_ccwall, [
  102. ac_old_CXXFLAGS="$CXXFLAGS"
  103. CXXFLAGS="$CXXFLAGS -Wall"
  104. AC_COMPILE_IFELSE([[
  105. int main ()
  106. {
  107. return(0);
  108. }
  109. ]], [
  110. egg_cv_var_ccwall="yes"
  111. ], [
  112. egg_cv_var_ccwall="no"
  113. ])
  114. CXXFLAGS="$ac_old_CXXFLAGS"
  115. ])
  116. if test "$egg_cv_var_ccwall" = "yes"; then
  117. CXXFLAGS="$CXXFLAGS -Wall"
  118. fi
  119. fi
  120. ])
  121. dnl EGG_CHECK_CCSTATIC()
  122. dnl
  123. dnl Checks whether the compiler supports the `-static' flag.
  124. AC_DEFUN(EGG_CHECK_CCSTATIC, [dnl
  125. if test -z "$no_static"
  126. then
  127. if test -n "$GXX"
  128. then
  129. AC_CACHE_CHECK(whether the compiler understands -static, egg_cv_var_ccstatic, [dnl
  130. ac_old_CXX="$CXX"
  131. CXX="$CXX -static"
  132. AC_TRY_COMPILE(,, egg_cv_var_ccstatic="yes", egg_cv_var_ccstatic="no")
  133. CXX="$ac_old_CXX"
  134. ])
  135. if test "$egg_cv_var_ccstatic" = "yes"
  136. then
  137. CCDEBUG="$CXX"
  138. CXX="$CXX -static"
  139. else
  140. cat << 'EOF' >&2
  141. configure: error:
  142. Your C compiler does not support -static.
  143. This compile flag is required for the botpack.
  144. EOF
  145. exit 1
  146. fi
  147. fi
  148. fi
  149. ])dnl
  150. dnl EGG_PROG_HEAD_1()
  151. dnl
  152. AC_DEFUN(EGG_PROG_HEAD_1,
  153. [cat << 'EOF' > conftest.head
  154. a
  155. b
  156. c
  157. EOF
  158. for ac_prog in 'head -1' 'head -n 1' 'sed 1q';
  159. do
  160. AC_MSG_CHECKING([whether $ac_prog works])
  161. AC_CACHE_VAL(ac_cv_prog_HEAD_1,
  162. [ if test -n "$HEAD_1"
  163. then
  164. ac_cv_prog_HEAD_1="$HEAD_1" # Let the user override the test.
  165. else
  166. if test "`cat conftest.head | $ac_prog`" = "a";
  167. then
  168. AC_MSG_RESULT([yes])
  169. ac_cv_prog_HEAD_1=$ac_prog
  170. else
  171. AC_MSG_RESULT([no])
  172. fi
  173. fi])dnl
  174. test -n "$ac_cv_prog_HEAD_1" && break
  175. done
  176. if test "${ac_cv_prog_HEAD_1-x}" = "x"
  177. then
  178. cat << 'EOF' >&2
  179. configure: error:
  180. This system seems to lack a working 'head -1' or 'head -n 1' command.
  181. A working 'head -1' (or equivalent) command is required to compile Eggdrop.
  182. EOF
  183. exit 1
  184. fi
  185. rm -f conftest.head
  186. HEAD_1=$ac_cv_prog_HEAD_1
  187. AC_SUBST(HEAD_1)dnl
  188. ])dnl
  189. dnl EGG_PROG_AWK()
  190. dnl
  191. AC_DEFUN(EGG_PROG_AWK, [dnl
  192. # awk is needed for Tcl library and header checks, and eggdrop version subst
  193. AC_PROG_AWK
  194. if test "${AWK-x}" = "x"
  195. then
  196. cat << 'EOF' >&2
  197. configure: error:
  198. This system seems to lack a working 'awk' command.
  199. A working 'awk' command is required to compile Eggdrop.
  200. EOF
  201. exit 1
  202. fi
  203. ])dnl
  204. dnl EGG_PROG_BASENAME()
  205. dnl
  206. AC_DEFUN(EGG_PROG_BASENAME, [dnl
  207. # basename is needed for Tcl library and header checks
  208. AC_CHECK_PROG(BASENAME, basename, basename)
  209. if test "${BASENAME-x}" = "x"
  210. then
  211. cat << 'EOF' >&2
  212. configure: error:
  213. This system seems to lack a working 'basename' command.
  214. A working 'basename' command is required to compile Eggdrop.
  215. EOF
  216. exit 1
  217. fi
  218. ])dnl
  219. dnl EGG_CHECK_OS()
  220. dnl
  221. dnl
  222. AC_DEFUN(EGG_CHECK_OS, [dnl
  223. EGG_CYGWIN=no
  224. AC_CACHE_CHECK(system type, egg_cv_var_system_type, egg_cv_var_system_type=`$UNAME -s`)
  225. AC_CACHE_CHECK(system release, egg_cv_var_system_release, egg_cv_var_system_release=`$UNAME -r`)
  226. case "$egg_cv_var_system_type" in
  227. BSD/OS)
  228. ;;
  229. CYGWI*)
  230. AC_PROG_CC_WIN32
  231. CXX="$CXX $WIN32FLAGS"
  232. EGG_CYGWIN="yes"
  233. EGG_CYGWIN_BINMODE
  234. AC_DEFINE(CYGWIN_HACKS, 1, [Define if running under cygwin])
  235. AC_DEFINE(WIN32_LEAN_AND_MEAN, 1, [Define if windows])
  236. ;;
  237. IRIX)
  238. ;;
  239. Ultrix)
  240. SHELL=/bin/sh5
  241. ;;
  242. SINIX*)
  243. ;;
  244. BeOS)
  245. ;;
  246. Linux)
  247. ;;
  248. Lynx)
  249. ;;
  250. QNX)
  251. ;;
  252. OSF1)
  253. case "`echo $egg_cv_var_system_release | cut -d . -f 1`" in
  254. V*)
  255. if test "$AWK" = "gawk"
  256. then
  257. AWK=awk
  258. fi
  259. ;;
  260. 1.0|1.1|1.2)
  261. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  262. ;;
  263. 1.*)
  264. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  265. ;;
  266. *)
  267. ;;
  268. esac
  269. AC_DEFINE(STOP_UAC, 1, [Define if running on OSF/1 platform])dnl
  270. AC_DEFINE(BROKEN_SNPRINTF, 1, [Define to use Eggdrop's snprintf functions without regard to HAVE_SNPRINTF])dnl
  271. ;;
  272. SunOS)
  273. ;;
  274. *BSD)
  275. # FreeBSD/OpenBSD/NetBSD
  276. ;;
  277. *)
  278. AC_MSG_CHECKING(if system is Mach based)
  279. if test -r /mach
  280. then
  281. AC_MSG_RESULT(yes)
  282. AC_DEFINE(BORGCUBES, 1, [Define if running on NeXT Step])dnl
  283. else
  284. AC_MSG_RESULT(no)
  285. AC_MSG_CHECKING(if system is QNX)
  286. if test -r /cmds
  287. then
  288. AC_MSG_RESULT(yes)
  289. else
  290. AC_MSG_RESULT(no)
  291. AC_MSG_RESULT(Something unknown!)
  292. AC_MSG_RESULT([If you get dynamic modules to work, be sure to let the devel team know HOW :)])
  293. fi
  294. fi
  295. ;;
  296. esac
  297. ])dnl
  298. dnl EGG_CYGWIN_BINMODE
  299. dnl
  300. dnl Check for binmode.o on Cygwin.
  301. dnl
  302. AC_DEFUN([EGG_CYGWIN_BINMODE],
  303. [
  304. if test $EGG_CYGWIN = "yes"; then
  305. AC_MSG_CHECKING([for /usr/lib/binmode.o])
  306. if test -r /usr/lib/binmode.o; then
  307. AC_MSG_RESULT([yes])
  308. LIBS="$LIBS /usr/lib/binmode.o"
  309. else
  310. AC_MSG_RESULT([no])
  311. AC_MSG_WARN([Make sure the directory Eggdrop is installed into is mounted in binary mode.])
  312. fi
  313. fi
  314. ])
  315. dnl EGG_CHECK_LIBS()
  316. dnl
  317. AC_DEFUN(EGG_CHECK_LIBS, [dnl
  318. AC_CHECK_LIB(socket, socket)
  319. # AC_CHECK_LIB(nsl, connect)
  320. AC_CHECK_LIB(dns, gethostbyname)
  321. # AC_CHECK_LIB(z, gzopen, ZLIB="-lz")
  322. # AC_CHECK_LIB(ssl, SSL_accept, SSL="-lssl -lcrypto", SSL="", -lcrypto)
  323. # AC_CHECK_LIB(ssl, SSL_accept, SSL="-lcrypto", SSL="", -lcrypto)
  324. # This is needed for Tcl libraries compiled with thread support
  325. # AC_CHECK_LIB(pthread, pthread_mutex_init, [dnl
  326. # ac_cv_lib_pthread_pthread_mutex_init=yes
  327. # ac_cv_lib_pthread="-lpthread"], [dnl
  328. # AC_CHECK_LIB(pthread, __pthread_mutex_init, [dnl
  329. # ac_cv_lib_pthread_pthread_mutex_init=yes
  330. # ac_cv_lib_pthread="-lpthread"], [dnl
  331. # AC_CHECK_LIB(pthreads, pthread_mutex_init, [dnl
  332. # ac_cv_lib_pthread_pthread_mutex_init=yes
  333. # ac_cv_lib_pthread="-lpthreads"], [dnl
  334. # AC_CHECK_FUNC(pthread_mutex_init, [dnl
  335. # ac_cv_lib_pthread_pthread_mutex_init=yes
  336. # ac_cv_lib_pthread=""],
  337. # ac_cv_lib_pthread_pthread_mutex_init=no)])])])
  338. ])dnl
  339. dnl EGG_CHECK_FUNC_VSPRINTF()
  340. dnl
  341. AC_DEFUN(EGG_CHECK_FUNC_VSPRINTF, [dnl
  342. AC_CHECK_FUNCS(vsprintf)
  343. if test "$ac_cv_func_vsprintf" = "no"
  344. then
  345. cat << 'EOF' >&2
  346. configure: error:
  347. Your system does not have the sprintf/vsprintf libraries.
  348. These are required to compile almost anything. Sorry.
  349. EOF
  350. exit 1
  351. fi
  352. ])dnl
  353. dnl EGG_CHECK_FUNC_UNAME()
  354. dnl
  355. AC_DEFUN(EGG_CHECK_FUNC_UNAME, [dnl
  356. AC_CHECK_FUNCS(uname)
  357. if test "$ac_cv_func_uname" = "no"
  358. then
  359. cat << 'EOF' >&2
  360. configure: error:
  361. Your system does not have the uname() function.
  362. This is required for the botpack.
  363. EOF
  364. exit 1
  365. fi
  366. ])dnl
  367. dnl EGG_CHECK_ZLIB()
  368. dnl
  369. AC_DEFUN(EGG_CHECK_ZLIB, [dnl
  370. if test "x${ZLIB}" = x; then
  371. cat >&2 <<EOF
  372. configure: error:
  373. Your system does not provide a working zlib compression library.
  374. It is required.
  375. EOF
  376. exit 1
  377. else
  378. if test "${ac_cv_header_zlib_h}" != yes; then
  379. cat >&2 <<EOF
  380. configure: error:
  381. Your system does not provide the necessary zlib header file.
  382. It is required.
  383. EOF
  384. exit 1
  385. fi
  386. fi
  387. ])dnl
  388. dnl EGG_CHECK_SSL()
  389. dnl
  390. AC_DEFUN(EGG_CHECK_SSL, [dnl
  391. if test "x${SSL}" = x; then
  392. cat >&2 <<EOF
  393. configure: error:
  394. Your system does not provide a working ssl library.
  395. It is required. Download openssl at www.openssl.org
  396. EOF
  397. exit 1
  398. else
  399. if test "${ac_cv_header_openssl_ssl_h}" != yes; then
  400. cat >&2 <<EOF
  401. configure: error:
  402. Your system does not provide the necessary ssl header file.
  403. It is required. Download openssl at www.openssl.org
  404. EOF
  405. exit 1
  406. fi
  407. fi
  408. ])dnl
  409. dnl EGG_HEADER_STDC()
  410. dnl
  411. AC_DEFUN(EGG_HEADER_STDC, [dnl
  412. if test "$ac_cv_header_stdc" = "no"
  413. then
  414. cat << 'EOF' >&2
  415. configure: error:
  416. Your system must support ANSI C Header files.
  417. These are required for the language support. Sorry.
  418. EOF
  419. exit 1
  420. fi
  421. ])dnl
  422. dnl EGG_CACHE_UNSET(CACHE-ID)
  423. dnl
  424. dnl Unsets a certain cache item. Typically called before using
  425. dnl the AC_CACHE_*() macros.
  426. AC_DEFUN(EGG_CACHE_UNSET, [dnl
  427. unset $1
  428. ])
  429. dnl EGG_SUBST_VERSION()
  430. dnl
  431. AC_DEFUN(EGG_SUBST_VERSION, [dnl
  432. VERSION=`grep "char" $srcdir/src/main.c | $AWK '/egg_version/ {print [$]5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
  433. version_num=`echo $VERSION | $AWK 'BEGIN {FS = "."} {printf("%d%02d%02d", [$]1, [$]2, [$]3)}'`
  434. AC_DEFINE_UNQUOTED(EGG_VERSION, $version_num, [Defines the current pack version])dnl
  435. AC_SUBST(VERSION)dnl
  436. AC_SUBST(NUMVER)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_CXX="$CXX"
  522. ac_compile="$ac_compile -mwin32"
  523. CXX="$CXX -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. CXX="$save_CC"
  534. WIN32FLAGS="-mwin32"
  535. ], [
  536. ac_compile="$ac_compile_save"
  537. CXX="$save_CC"
  538. AC_MSG_RESULT([not found])
  539. ])
  540. ])
  541. ])
  542. dnl
  543. AC_DEFUN([EGG_CHECK_RANDOM_MAX],
  544. [
  545. AC_MSG_CHECKING([for random limit])
  546. case "$egg_cv_var_system_type" in
  547. SunOS) RMAX=0x7FFFFFFF
  548. ;;
  549. *) RMAX=RAND_MAX
  550. ;;
  551. esac
  552. AC_MSG_RESULT([$RMAX])
  553. AC_DEFINE_UNQUOTED(RANDOM_MAX, $RMAX, [Define limit of random() function.])
  554. ])