acinclude.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. AC_CACHE_CHECK(system machine, egg_cv_var_system_machine, egg_cv_var_system_machine=`$UNAME -m`)
  227. case "$egg_cv_var_system_machine" in
  228. i*)
  229. CXX="$CXX -march=i486"
  230. ;;
  231. *)
  232. ;;
  233. esac
  234. case "$egg_cv_var_system_type" in
  235. BSD/OS)
  236. ;;
  237. CYGWI*)
  238. AC_PROG_CC_WIN32
  239. CXX="$CXX $WIN32FLAGS"
  240. EGG_CYGWIN="yes"
  241. EGG_CYGWIN_BINMODE
  242. AC_DEFINE(CYGWIN_HACKS, 1, [Define if running under cygwin])
  243. AC_DEFINE(WIN32_LEAN_AND_MEAN, 1, [Define if windows])
  244. ;;
  245. IRIX)
  246. ;;
  247. Ultrix)
  248. SHELL=/bin/sh5
  249. ;;
  250. SINIX*)
  251. ;;
  252. BeOS)
  253. ;;
  254. Linux)
  255. ;;
  256. Lynx)
  257. ;;
  258. QNX)
  259. ;;
  260. OSF1)
  261. case "`echo $egg_cv_var_system_release | cut -d . -f 1`" in
  262. V*)
  263. if test "$AWK" = "gawk"
  264. then
  265. AWK=awk
  266. fi
  267. ;;
  268. 1.0|1.1|1.2)
  269. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  270. ;;
  271. 1.*)
  272. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  273. ;;
  274. *)
  275. ;;
  276. esac
  277. AC_DEFINE(STOP_UAC, 1, [Define if running on OSF/1 platform])dnl
  278. AC_DEFINE(BROKEN_SNPRINTF, 1, [Define to use Eggdrop's snprintf functions without regard to HAVE_SNPRINTF])dnl
  279. ;;
  280. SunOS)
  281. ;;
  282. *BSD)
  283. # FreeBSD/OpenBSD/NetBSD
  284. ;;
  285. *)
  286. AC_MSG_CHECKING(if system is Mach based)
  287. if test -r /mach
  288. then
  289. AC_MSG_RESULT(yes)
  290. AC_DEFINE(BORGCUBES, 1, [Define if running on NeXT Step])dnl
  291. else
  292. AC_MSG_RESULT(no)
  293. AC_MSG_CHECKING(if system is QNX)
  294. if test -r /cmds
  295. then
  296. AC_MSG_RESULT(yes)
  297. else
  298. AC_MSG_RESULT(no)
  299. AC_MSG_RESULT(Something unknown!)
  300. AC_MSG_RESULT([If you get dynamic modules to work, be sure to let the devel team know HOW :)])
  301. fi
  302. fi
  303. ;;
  304. esac
  305. ])dnl
  306. dnl EGG_CYGWIN_BINMODE
  307. dnl
  308. dnl Check for binmode.o on Cygwin.
  309. dnl
  310. AC_DEFUN([EGG_CYGWIN_BINMODE],
  311. [
  312. if test $EGG_CYGWIN = "yes"; then
  313. AC_MSG_CHECKING([for /usr/lib/binmode.o])
  314. if test -r /usr/lib/binmode.o; then
  315. AC_MSG_RESULT([yes])
  316. LIBS="$LIBS /usr/lib/binmode.o"
  317. else
  318. AC_MSG_RESULT([no])
  319. AC_MSG_WARN([Make sure the directory Eggdrop is installed into is mounted in binary mode.])
  320. fi
  321. fi
  322. ])
  323. dnl EGG_CHECK_LIBS()
  324. dnl
  325. AC_DEFUN(EGG_CHECK_LIBS, [dnl
  326. AC_CHECK_LIB(socket, socket)
  327. # AC_CHECK_LIB(nsl, connect)
  328. AC_CHECK_LIB(dns, gethostbyname)
  329. # AC_CHECK_LIB(z, gzopen, ZLIB="-lz")
  330. # AC_CHECK_LIB(ssl, SSL_accept, SSL="-lssl -lcrypto", SSL="", -lcrypto)
  331. # AC_CHECK_LIB(ssl, SSL_accept, SSL="-lcrypto", SSL="", -lcrypto)
  332. # This is needed for Tcl libraries compiled with thread support
  333. # AC_CHECK_LIB(pthread, pthread_mutex_init, [dnl
  334. # ac_cv_lib_pthread_pthread_mutex_init=yes
  335. # ac_cv_lib_pthread="-lpthread"], [dnl
  336. # AC_CHECK_LIB(pthread, __pthread_mutex_init, [dnl
  337. # ac_cv_lib_pthread_pthread_mutex_init=yes
  338. # ac_cv_lib_pthread="-lpthread"], [dnl
  339. # AC_CHECK_LIB(pthreads, pthread_mutex_init, [dnl
  340. # ac_cv_lib_pthread_pthread_mutex_init=yes
  341. # ac_cv_lib_pthread="-lpthreads"], [dnl
  342. # AC_CHECK_FUNC(pthread_mutex_init, [dnl
  343. # ac_cv_lib_pthread_pthread_mutex_init=yes
  344. # ac_cv_lib_pthread=""],
  345. # ac_cv_lib_pthread_pthread_mutex_init=no)])])])
  346. ])dnl
  347. dnl EGG_CHECK_FUNC_VSPRINTF()
  348. dnl
  349. AC_DEFUN(EGG_CHECK_FUNC_VSPRINTF, [dnl
  350. AC_CHECK_FUNCS(vsprintf)
  351. if test "$ac_cv_func_vsprintf" = "no"
  352. then
  353. cat << 'EOF' >&2
  354. configure: error:
  355. Your system does not have the sprintf/vsprintf libraries.
  356. These are required to compile almost anything. Sorry.
  357. EOF
  358. exit 1
  359. fi
  360. ])dnl
  361. dnl EGG_CHECK_FUNC_UNAME()
  362. dnl
  363. AC_DEFUN(EGG_CHECK_FUNC_UNAME, [dnl
  364. AC_CHECK_FUNCS(uname)
  365. if test "$ac_cv_func_uname" = "no"
  366. then
  367. cat << 'EOF' >&2
  368. configure: error:
  369. Your system does not have the uname() function.
  370. This is required for the botpack.
  371. EOF
  372. exit 1
  373. fi
  374. ])dnl
  375. dnl EGG_CHECK_ZLIB()
  376. dnl
  377. AC_DEFUN(EGG_CHECK_ZLIB, [dnl
  378. if test "x${ZLIB}" = x; then
  379. cat >&2 <<EOF
  380. configure: error:
  381. Your system does not provide a working zlib compression library.
  382. It is required.
  383. EOF
  384. exit 1
  385. else
  386. if test "${ac_cv_header_zlib_h}" != yes; then
  387. cat >&2 <<EOF
  388. configure: error:
  389. Your system does not provide the necessary zlib header file.
  390. It is required.
  391. EOF
  392. exit 1
  393. fi
  394. fi
  395. ])dnl
  396. dnl EGG_CHECK_SSL()
  397. dnl
  398. AC_DEFUN(EGG_CHECK_SSL, [dnl
  399. if test "x${SSL}" = x; then
  400. cat >&2 <<EOF
  401. configure: error:
  402. Your system does not provide a working ssl library.
  403. It is required. Download openssl at www.openssl.org
  404. EOF
  405. exit 1
  406. else
  407. if test "${ac_cv_header_openssl_ssl_h}" != yes; then
  408. cat >&2 <<EOF
  409. configure: error:
  410. Your system does not provide the necessary ssl header file.
  411. It is required. Download openssl at www.openssl.org
  412. EOF
  413. exit 1
  414. fi
  415. fi
  416. ])dnl
  417. dnl EGG_HEADER_STDC()
  418. dnl
  419. AC_DEFUN(EGG_HEADER_STDC, [dnl
  420. if test "$ac_cv_header_stdc" = "no"
  421. then
  422. cat << 'EOF' >&2
  423. configure: error:
  424. Your system must support ANSI C Header files.
  425. These are required for the language support. Sorry.
  426. EOF
  427. exit 1
  428. fi
  429. ])dnl
  430. dnl EGG_CACHE_UNSET(CACHE-ID)
  431. dnl
  432. dnl Unsets a certain cache item. Typically called before using
  433. dnl the AC_CACHE_*() macros.
  434. AC_DEFUN(EGG_CACHE_UNSET, [dnl
  435. unset $1
  436. ])
  437. dnl EGG_SUBST_VERSION()
  438. dnl
  439. AC_DEFUN(EGG_SUBST_VERSION, [dnl
  440. VERSION=`grep "char" $srcdir/src/main.c | $AWK '/egg_version/ {print [$]5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
  441. version_num=`echo $VERSION | $AWK 'BEGIN {FS = "."} {printf("%d%02d%02d", [$]1, [$]2, [$]3)}'`
  442. AC_DEFINE_UNQUOTED(EGG_VERSION, $version_num, [Defines the current pack version])dnl
  443. AC_SUBST(VERSION)dnl
  444. AC_SUBST(NUMVER)dnl
  445. ])dnl
  446. dnl EGG_SUBST_MOD_UPDIR()
  447. dnl
  448. dnl Since module's Makefiles aren't generated by configure, some
  449. dnl paths in src/mod/Makefile.in take care of them. For correct
  450. dnl path "calculation", we need to keep absolute paths in mind
  451. dnl (which don't need a "../" pre-pended).
  452. AC_DEFUN(EGG_SUBST_MOD_UPDIR, [dnl
  453. case "$srcdir" in
  454. [[\\/]]* | ?:[[\\/]]*)
  455. MOD_UPDIR=""
  456. ;;
  457. *)
  458. MOD_UPDIR="../"
  459. ;;
  460. esac
  461. AC_SUBST(MOD_UPDIR)dnl
  462. ])dnl
  463. dnl EGG_REPLACE_IF_CHANGED(FILE-NAME, CONTENTS-CMDS, INIT-CMDS)
  464. dnl
  465. dnl Replace FILE-NAME if the newly created contents differs from the existing
  466. dnl file contents. Otherwise, leave the file alone. This avoids needless
  467. dnl recompiles.
  468. m4_define(EGG_REPLACE_IF_CHANGED,
  469. [
  470. AC_CONFIG_COMMANDS([replace-if-changed],
  471. [[
  472. egg_replace_file="$1"
  473. $2
  474. if test -f "$egg_replace_file" && cmp -s conftest.out $egg_replace_file; then
  475. echo "$1 is unchanged"
  476. else
  477. echo "creating $1"
  478. mv conftest.out $egg_replace_file
  479. fi
  480. rm -f conftest.out
  481. ]],
  482. [[$3]])
  483. ])
  484. dnl EGG_SAVE_PARAMETERS()
  485. dnl
  486. AC_DEFUN(EGG_SAVE_PARAMETERS, [dnl
  487. # Remove --cache-file and --srcdir arguments so they do not pile up.
  488. egg_ac_parameters=
  489. ac_prev=
  490. for ac_arg in $ac_configure_args; do
  491. if test -n "$ac_prev"; then
  492. ac_prev=
  493. continue
  494. fi
  495. case $ac_arg in
  496. -cache-file | --cache-file | --cache-fil | --cache-fi \
  497. | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
  498. ac_prev=cache_file ;;
  499. -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  500. | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
  501. | --c=*)
  502. ;;
  503. --config-cache | -C)
  504. ;;
  505. -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  506. ac_prev=srcdir ;;
  507. -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  508. ;;
  509. *) egg_ac_parameters="$egg_ac_parameters $ac_arg" ;;
  510. esac
  511. done
  512. AC_SUBST(egg_ac_parameters)dnl
  513. ])dnl
  514. AC_DEFUN([AC_PROG_CC_WIN32], [
  515. AC_MSG_CHECKING([how to access the Win32 API])
  516. WIN32FLAGS=
  517. AC_TRY_COMPILE(,[
  518. #ifndef WIN32
  519. # ifndef _WIN32
  520. # error WIN32 or _WIN32 not defined
  521. # endif
  522. #endif], [
  523. dnl found windows.h with the current config.
  524. AC_MSG_RESULT([present by default])
  525. ], [
  526. dnl try -mwin32
  527. ac_compile_save="$ac_compile"
  528. dnl we change CC so config.log looks correct
  529. save_CXX="$CXX"
  530. ac_compile="$ac_compile -mwin32"
  531. CXX="$CXX -mwin32"
  532. AC_TRY_COMPILE(,[
  533. #ifndef WIN32
  534. # ifndef _WIN32
  535. # error WIN32 or _WIN32 not defined
  536. # endif
  537. #endif], [
  538. dnl found windows.h using -mwin32
  539. AC_MSG_RESULT([found via -mwin32])
  540. ac_compile="$ac_compile_save"
  541. CXX="$save_CC"
  542. WIN32FLAGS="-mwin32"
  543. ], [
  544. ac_compile="$ac_compile_save"
  545. CXX="$save_CC"
  546. AC_MSG_RESULT([not found])
  547. ])
  548. ])
  549. ])
  550. dnl
  551. AC_DEFUN([EGG_CHECK_RANDOM_MAX],
  552. [
  553. AC_MSG_CHECKING([for random limit])
  554. case "$egg_cv_var_system_type" in
  555. SunOS) RMAX=0x7FFFFFFF
  556. ;;
  557. *) RMAX=RAND_MAX
  558. ;;
  559. esac
  560. AC_MSG_RESULT([$RMAX])
  561. AC_DEFINE_UNQUOTED(RANDOM_MAX, $RMAX, [Define limit of random() function.])
  562. ])