acinclude.m4 13 KB

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