acinclude.m4 13 KB

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