acinclude.m4 13 KB

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