acinclude.m4 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  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. dnl FIXME: make a better test
  8. dnl
  9. AC_DEFUN(EGG_CHECK_CC, [dnl
  10. if test "${cross_compiling-x}" = "x"
  11. then
  12. cat << 'EOF' >&2
  13. configure: error:
  14. This system does not appear to have a working C compiler.
  15. A working C compiler is required to compile Eggdrop.
  16. EOF
  17. exit 1
  18. fi
  19. ])dnl
  20. dnl EGG_IPV6_OPTIONS()
  21. dnl
  22. AC_DEFUN(EGG_IPV6_OPTIONS, [dnl
  23. AC_MSG_CHECKING(whether or not you disabled IPv6 support)
  24. AC_ARG_ENABLE(ipv6, [ --disable-ipv6 disable IPv6 support],
  25. [ ac_cv_dipv6="yes"
  26. AC_MSG_RESULT(yes)
  27. ],
  28. [ ac_cv_dipv6="no"
  29. if test "$egg_cv_ipv6_supported" = "no"; then
  30. ac_cv_dipv6="no"
  31. fi
  32. AC_MSG_RESULT($ac_cv_dipv6)
  33. ])
  34. if test "$ac_cv_dipv6" = "no"; then
  35. AC_DEFINE(USE_IPV6, 1, [Define if you want ipv6 support])
  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_STRIP()
  154. dnl
  155. AC_DEFUN(EGG_PROG_STRIP, [dnl
  156. AC_CHECK_PROG(STRIP, strip, strip)
  157. if test "${STRIP-x}" = "x"
  158. then
  159. STRIP=touch
  160. fi
  161. ])dnl
  162. dnl EGG_PROG_CCACHE()
  163. dnl
  164. AC_DEFUN(EGG_PROG_CCACHE, [dnl
  165. AC_CHECK_PROG(CCACHE, ccache, ccache)
  166. if test "${CCACHE-x}" = "x"
  167. then
  168. CCACHE=ccache
  169. fi
  170. ])dnl
  171. dnl EGG_PROG_AWK()
  172. dnl
  173. AC_DEFUN(EGG_PROG_AWK, [dnl
  174. # awk is needed for Tcl library and header checks, and eggdrop version subst
  175. AC_PROG_AWK
  176. if test "${AWK-x}" = "x"
  177. then
  178. cat << 'EOF' >&2
  179. configure: error:
  180. This system seems to lack a working 'awk' command.
  181. A working 'awk' command is required to compile Eggdrop.
  182. EOF
  183. exit 1
  184. fi
  185. ])dnl
  186. dnl EGG_PROG_BASENAME()
  187. dnl
  188. AC_DEFUN(EGG_PROG_BASENAME, [dnl
  189. # basename is needed for Tcl library and header checks
  190. AC_CHECK_PROG(BASENAME, basename, basename)
  191. if test "${BASENAME-x}" = "x"
  192. then
  193. cat << 'EOF' >&2
  194. configure: error:
  195. This system seems to lack a working 'basename' command.
  196. A working 'basename' command is required to compile Eggdrop.
  197. EOF
  198. exit 1
  199. fi
  200. ])dnl
  201. dnl EGG_CHECK_OS()
  202. dnl
  203. dnl FIXME/NOTICE:
  204. dnl This function is obsolete. Any NEW code/checks should be written
  205. dnl as individual tests that will be checked on ALL operating systems.
  206. dnl
  207. AC_DEFUN(EGG_CHECK_OS, [dnl
  208. LINUX=no
  209. IRIX=no
  210. SUNOS=no
  211. HPUX=no
  212. EGG_CYGWIN=no
  213. AC_CACHE_CHECK(system type, egg_cv_var_system_type, egg_cv_var_system_type=`$UNAME -s`)
  214. AC_CACHE_CHECK(system release, egg_cv_var_system_release, egg_cv_var_system_release=`$UNAME -r`)
  215. case "$egg_cv_var_system_type" in
  216. BSD/OS)
  217. case "`echo $egg_cv_var_system_release | cut -d . -f 1`" in
  218. 2)
  219. ;;
  220. *)
  221. CFLAGS="$CFLAGS -Wall"
  222. ;;
  223. esac
  224. ;;
  225. CYGWI*)
  226. case "`echo $egg_cv_var_system_release | cut -c 1-3`" in
  227. 1.*)
  228. AC_PROG_CC_WIN32
  229. CC="$CC $WIN32FLAGS"
  230. AC_MSG_CHECKING(for /usr/lib/binmode.o)
  231. if test -r /usr/lib/binmode.o
  232. then
  233. AC_MSG_RESULT(yes)
  234. LIBS="$LIBS /usr/lib/binmode.o"
  235. else
  236. AC_MSG_RESULT(no)
  237. AC_MSG_WARN(Make sure the directory Eggdrop is installed into is mounted in binary mode.)
  238. fi
  239. ;;
  240. *)
  241. AC_MSG_WARN(Make sure the directory Eggdrop is installed into is mounted in binary mode.)
  242. ;;
  243. esac
  244. EGG_CYGWIN=yes
  245. AC_DEFINE(CYGWIN_HACKS, 1, [Define if running under cygwin])
  246. ;;
  247. HP-UX)
  248. HPUX=yes
  249. AC_DEFINE(HPUX_HACKS, 1, [Define if running on hpux that supports dynamic linking])dnl
  250. if test "`echo $egg_cv_var_system_release | cut -d . -f 2`" = "10"
  251. then
  252. AC_DEFINE(HPUX10_HACKS, 1, [Define if running on hpux 10.x])dnl
  253. fi
  254. ;;
  255. dell)
  256. AC_MSG_RESULT(Dell SVR4)
  257. ;;
  258. IRIX)
  259. IRIX=yes
  260. ;;
  261. Ultrix)
  262. SHELL=/bin/sh5
  263. ;;
  264. SINIX*)
  265. ;;
  266. BeOS)
  267. ;;
  268. Linux)
  269. LINUX=yes
  270. CFLAGS="$CFLAGS -Wall"
  271. ;;
  272. Lynx)
  273. ;;
  274. QNX)
  275. ;;
  276. OSF1)
  277. case "`echo $egg_cv_var_system_release | cut -d . -f 1`" in
  278. V*)
  279. # FIXME: we should check this in a separate test
  280. # Digital OSF uses an ancient version of gawk
  281. if test "$AWK" = "gawk"
  282. then
  283. AWK=awk
  284. fi
  285. ;;
  286. 1.0|1.1|1.2)
  287. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  288. ;;
  289. 1.*)
  290. AC_DEFINE(OSF1_HACKS, 1, [Define if running on OSF/1 platform])dnl
  291. ;;
  292. *)
  293. ;;
  294. esac
  295. AC_DEFINE(STOP_UAC, 1, [Define if running on OSF/1 platform])dnl
  296. AC_DEFINE(BROKEN_SNPRINTF, 1, [Define to use Eggdrop's snprintf functions without regard to HAVE_SNPRINTF])dnl
  297. ;;
  298. SunOS)
  299. if ! test "`echo $egg_cv_var_system_release | cut -d . -f 1`" = "5"
  300. then
  301. # SunOS 4
  302. SUNOS=yes
  303. fi
  304. ;;
  305. *BSD)
  306. # FreeBSD/OpenBSD/NetBSD
  307. ;;
  308. *)
  309. AC_MSG_CHECKING(if system is Mach based)
  310. if test -r /mach
  311. then
  312. AC_MSG_RESULT(yes)
  313. AC_DEFINE(BORGCUBES, 1, [Define if running on NeXT Step])dnl
  314. else
  315. AC_MSG_RESULT(no)
  316. AC_MSG_CHECKING(if system is QNX)
  317. if test -r /cmds
  318. then
  319. AC_MSG_RESULT(yes)
  320. else
  321. AC_MSG_RESULT(no)
  322. AC_MSG_RESULT(Something unknown!)
  323. AC_MSG_RESULT([If you get dynamic modules to work, be sure to let the devel team know HOW :)])
  324. fi
  325. fi
  326. ;;
  327. esac
  328. ])dnl
  329. dnl EGG_CHECK_LIBS()
  330. dnl
  331. AC_DEFUN(EGG_CHECK_LIBS, [dnl
  332. # FIXME: this needs to be fixed so that it works on IRIX
  333. if test "$IRIX" = "yes"
  334. then
  335. AC_MSG_WARN(Skipping library tests because they CONFUSE Irix.)
  336. else
  337. AC_CHECK_LIB(socket, socket)
  338. AC_CHECK_LIB(nsl, connect)
  339. AC_CHECK_LIB(dns, gethostbyname)
  340. AC_CHECK_LIB(z, gzopen, ZLIB="-lz")
  341. AC_CHECK_LIB(ssl, SSL_accept, SSL="-lssl -lcrypto", SSL="", -lcrypto)
  342. AC_CHECK_LIB(dl, dlopen)
  343. AC_CHECK_LIB(m, tan, EGG_MATH_LIB="-lm")
  344. # This is needed for Tcl libraries compiled with thread support
  345. AC_CHECK_LIB(pthread, pthread_mutex_init, [dnl
  346. ac_cv_lib_pthread_pthread_mutex_init=yes
  347. ac_cv_lib_pthread="-lpthread"], [dnl
  348. AC_CHECK_LIB(pthread, __pthread_mutex_init, [dnl
  349. ac_cv_lib_pthread_pthread_mutex_init=yes
  350. ac_cv_lib_pthread="-lpthread"], [dnl
  351. AC_CHECK_LIB(pthreads, pthread_mutex_init, [dnl
  352. ac_cv_lib_pthread_pthread_mutex_init=yes
  353. ac_cv_lib_pthread="-lpthreads"], [dnl
  354. AC_CHECK_FUNC(pthread_mutex_init, [dnl
  355. ac_cv_lib_pthread_pthread_mutex_init=yes
  356. ac_cv_lib_pthread=""],
  357. ac_cv_lib_pthread_pthread_mutex_init=no)])])])
  358. if test "$SUNOS" = "yes"
  359. then
  360. # For suns without yp or something like that
  361. AC_CHECK_LIB(dl, main)
  362. else
  363. if test "$HPUX" = "yes"
  364. then
  365. AC_CHECK_LIB(dld, shl_load)
  366. fi
  367. fi
  368. fi
  369. ])dnl
  370. dnl EGG_CHECK_FUNC_VSPRINTF()
  371. dnl
  372. AC_DEFUN(EGG_CHECK_FUNC_VSPRINTF, [dnl
  373. AC_CHECK_FUNCS(vsprintf)
  374. if test "$ac_cv_func_vsprintf" = "no"
  375. then
  376. cat << 'EOF' >&2
  377. configure: error:
  378. Your system does not have the sprintf/vsprintf libraries.
  379. These are required to compile almost anything. Sorry.
  380. EOF
  381. exit 1
  382. fi
  383. ])dnl
  384. dnl EGG_CHECK_FUNC_UNAME()
  385. dnl
  386. AC_DEFUN(EGG_CHECK_FUNC_UNAME, [dnl
  387. AC_CHECK_FUNCS(uname)
  388. if test "$ac_cv_func_uname" = "no"
  389. then
  390. cat << 'EOF' >&2
  391. configure: error:
  392. Your system does not have the uname() function.
  393. This is required for the botpack.
  394. EOF
  395. exit 1
  396. fi
  397. ])dnl
  398. dnl EGG_CHECK_ZLIB()
  399. dnl
  400. AC_DEFUN(EGG_CHECK_ZLIB, [dnl
  401. if test "x${ZLIB}" = x; then
  402. cat >&2 <<EOF
  403. configure: error:
  404. Your system does not provide a working zlib compression library.
  405. It is required.
  406. EOF
  407. exit 1
  408. else
  409. if test "${ac_cv_header_zlib_h}" != yes; then
  410. cat >&2 <<EOF
  411. configure: error:
  412. Your system does not provide the necessary zlib header file.
  413. It is required.
  414. EOF
  415. exit 1
  416. fi
  417. fi
  418. ])dnl
  419. dnl EGG_CHECK_SSL()
  420. dnl
  421. AC_DEFUN(EGG_CHECK_SSL, [dnl
  422. if test "x${SSL}" = x; then
  423. cat >&2 <<EOF
  424. configure: error:
  425. Your system does not provide a working ssl library.
  426. It is required. Download openssl at www.openssl.org
  427. EOF
  428. exit 1
  429. else
  430. if test "${ac_cv_header_openssl_ssl_h}" != yes; then
  431. cat >&2 <<EOF
  432. configure: error:
  433. Your system does not provide the necessary ssl header file.
  434. It is required. Download openssl at www.openssl.org
  435. EOF
  436. exit 1
  437. fi
  438. fi
  439. ])dnl
  440. dnl EGG_HEADER_STDC()
  441. dnl
  442. AC_DEFUN(EGG_HEADER_STDC, [dnl
  443. if test "$ac_cv_header_stdc" = "no"
  444. then
  445. cat << 'EOF' >&2
  446. configure: error:
  447. Your system must support ANSI C Header files.
  448. These are required for the language support. Sorry.
  449. EOF
  450. exit 1
  451. fi
  452. ])dnl
  453. dnl EGG_TCL_ARG_WITH()
  454. dnl
  455. AC_DEFUN(EGG_TCL_ARG_WITH, [dnl
  456. # oohh new configure --variables for those with multiple Tcl libs
  457. AC_ARG_WITH(tcllib, [ --with-tcllib=PATH full path to Tcl library], tcllibname="$withval")
  458. AC_ARG_WITH(tclinc, [ --with-tclinc=PATH full path to Tcl header], tclincname="$withval")
  459. WARN=0
  460. # Make sure either both or neither $tcllibname and $tclincname are set
  461. if test ! "${tcllibname-x}" = "x"
  462. then
  463. if test "${tclincname-x}" = "x"
  464. then
  465. WARN=1
  466. tcllibname=""
  467. TCLLIB=""
  468. TCLINC=""
  469. fi
  470. else
  471. if test ! "${tclincname-x}" = "x"
  472. then
  473. WARN=1
  474. tclincname=""
  475. TCLLIB=""
  476. TCLINC=""
  477. fi
  478. fi
  479. if test "$WARN" = 1
  480. then
  481. cat << 'EOF' >&2
  482. configure: warning:
  483. You must specify both --with-tcllib and --with-tclinc for them to work.
  484. configure will now attempt to autodetect both the Tcl library and header...
  485. EOF
  486. fi
  487. ])dnl
  488. dnl EGG_TCL_ENV()
  489. dnl
  490. AC_DEFUN(EGG_TCL_ENV, [dnl
  491. WARN=0
  492. # Make sure either both or neither $TCLLIB and $TCLINC are set
  493. if test ! "${TCLLIB-x}" = "x"
  494. then
  495. if test "${TCLINC-x}" = "x"
  496. then
  497. WARN=1
  498. WVAR1=TCLLIB
  499. WVAR2=TCLINC
  500. TCLLIB=""
  501. fi
  502. else
  503. if test ! "${TCLINC-x}" = "x"
  504. then
  505. WARN=1
  506. WVAR1=TCLINC
  507. WVAR2=TCLLIB
  508. TCLINC=""
  509. fi
  510. fi
  511. if test "$WARN" = 1
  512. then
  513. cat << EOF >&2
  514. configure: warning:
  515. Environment variable $WVAR1 was set, but I did not detect ${WVAR2}.
  516. Please set both TCLLIB and TCLINC correctly if you wish to use them.
  517. configure will now attempt to autodetect both the Tcl library and header...
  518. EOF
  519. fi
  520. ])dnl
  521. dnl EGG_TCL_WITH_TCLLIB()
  522. dnl
  523. AC_DEFUN(EGG_TCL_WITH_TCLLIB, [dnl
  524. # Look for Tcl library: if $tcllibname is set, check there first
  525. if test ! "${tcllibname-x}" = "x"
  526. then
  527. if test -f "$tcllibname" && test -r "$tcllibname"
  528. then
  529. TCLLIB=`echo $tcllibname | sed 's%/[[^/]][[^/]]*$%%'`
  530. TCLLIBFN=`$BASENAME $tcllibname | cut -c4-`
  531. TCLLIBEXT=".`echo $TCLLIBFN | $AWK '{j=split([$]1, i, "."); print i[[j]]}'`"
  532. TCLLIBFNS=`$BASENAME $tcllibname $TCLLIBEXT | cut -c4-`
  533. else
  534. cat << EOF >&2
  535. configure: warning:
  536. The file '$tcllibname' given to option --with-tcllib is not valid.
  537. configure will now attempt to autodetect both the Tcl library and header...
  538. EOF
  539. tcllibname=""
  540. tclincname=""
  541. TCLLIB=""
  542. TCLLIBFN=""
  543. TCLINC=""
  544. TCLINCFN=""
  545. fi
  546. fi
  547. ])dnl
  548. dnl EGG_TCL_WITH_TCLINC()
  549. dnl
  550. AC_DEFUN(EGG_TCL_WITH_TCLINC, [dnl
  551. # Look for Tcl header: if $tclincname is set, check there first
  552. if test ! "${tclincname-x}" = "x"
  553. then
  554. if test -f "$tclincname" && test -r "$tclincname"
  555. then
  556. TCLINC=`echo $tclincname | sed 's%/[[^/]][[^/]]*$%%'`
  557. TCLINCFN=`$BASENAME $tclincname`
  558. else
  559. cat << EOF >&2
  560. configure: warning:
  561. The file '$tclincname' given to option --with-tclinc is not valid.
  562. configure will now attempt to autodetect both the Tcl library and header...
  563. EOF
  564. tcllibname=""
  565. tclincname=""
  566. TCLLIB=""
  567. TCLLIBFN=""
  568. TCLINC=""
  569. TCLINCFN=""
  570. fi
  571. fi
  572. ])dnl
  573. dnl EGG_TCL_FIND_LIBRARY()
  574. dnl
  575. AC_DEFUN(EGG_TCL_FIND_LIBRARY, [dnl
  576. # Look for Tcl library: if $TCLLIB is set, check there first
  577. if test "${TCLLIBFN-x}" = "x"
  578. then
  579. if test ! "${TCLLIB-x}" = "x"
  580. then
  581. if test -d "$TCLLIB"
  582. then
  583. for tcllibfns in $tcllibnames
  584. do
  585. for tcllibext in $tcllibextensions
  586. do
  587. if test -r "$TCLLIB/lib$tcllibfns$tcllibext"
  588. then
  589. TCLLIBFN="$tcllibfns$tcllibext"
  590. TCLLIBEXT="$tcllibext"
  591. TCLLIBFNS="$tcllibfns"
  592. break 2
  593. fi
  594. done
  595. done
  596. fi
  597. if test "${TCLLIBFN-x}" = "x"
  598. then
  599. cat << 'EOF' >&2
  600. configure: warning:
  601. Environment variable TCLLIB was set, but incorrect.
  602. Please set both TCLLIB and TCLINC correctly if you wish to use them.
  603. configure will now attempt to autodetect both the Tcl library and header...
  604. EOF
  605. TCLLIB=""
  606. TCLLIBFN=""
  607. TCLINC=""
  608. TCLINCFN=""
  609. fi
  610. fi
  611. fi
  612. ])dnl
  613. dnl EGG_TCL_FIND_HEADER()
  614. dnl
  615. AC_DEFUN(EGG_TCL_FIND_HEADER, [dnl
  616. # Look for Tcl header: if $TCLINC is set, check there first
  617. if test "${TCLINCFN-x}" = "x"
  618. then
  619. if test ! "${TCLINC-x}" = "x"
  620. then
  621. if test -d "$TCLINC"
  622. then
  623. for tclheaderfn in $tclheadernames
  624. do
  625. if test -r "$TCLINC/$tclheaderfn"
  626. then
  627. TCLINCFN="$tclheaderfn"
  628. break
  629. fi
  630. done
  631. fi
  632. if test "${TCLINCFN-x}" = "x"
  633. then
  634. cat << 'EOF' >&2
  635. configure: warning:
  636. Environment variable TCLINC was set, but incorrect.
  637. Please set both TCLLIB and TCLINC correctly if you wish to use them.
  638. configure will now attempt to autodetect both the Tcl library and header...
  639. EOF
  640. TCLLIB=""
  641. TCLLIBFN=""
  642. TCLINC=""
  643. TCLINCFN=""
  644. fi
  645. fi
  646. fi
  647. ])dnl
  648. dnl EGG_TCL_CHECK_LIBRARY()
  649. dnl
  650. AC_DEFUN(EGG_TCL_CHECK_LIBRARY, [dnl
  651. AC_MSG_CHECKING(for Tcl library)
  652. # Attempt autodetect for $TCLLIBFN if it's not set
  653. if test ! "${TCLLIBFN-x}" = "x"
  654. then
  655. AC_MSG_RESULT(using $TCLLIB/lib$TCLLIBFN)
  656. else
  657. for tcllibfns in $tcllibnames
  658. do
  659. for tcllibext in $tcllibextensions
  660. do
  661. for tcllibpath in $tcllibpaths
  662. do
  663. if test -r "$tcllibpath/lib$tcllibfns$tcllibext"
  664. then
  665. AC_MSG_RESULT(found $tcllibpath/lib$tcllibfns$tcllibext)
  666. TCLLIB="$tcllibpath"
  667. TCLLIBFN="$tcllibfns$tcllibext"
  668. TCLLIBEXT="$tcllibext"
  669. TCLLIBFNS="$tcllibfns"
  670. break 3
  671. fi
  672. done
  673. done
  674. done
  675. fi
  676. # Show if $TCLLIBFN wasn't found
  677. if test "${TCLLIBFN-x}" = "x"
  678. then
  679. AC_MSG_RESULT(not found)
  680. fi
  681. AC_SUBST(TCLLIB)dnl
  682. AC_SUBST(TCLLIBFN)dnl
  683. ])dnl
  684. dnl EGG_TCL_CHECK_HEADER()
  685. dnl
  686. AC_DEFUN(EGG_TCL_CHECK_HEADER, [dnl
  687. AC_MSG_CHECKING(for Tcl header)
  688. # Attempt autodetect for $TCLINCFN if it's not set
  689. if test ! "${TCLINCFN-x}" = "x"
  690. then
  691. AC_MSG_RESULT(using $TCLINC/$TCLINCFN)
  692. else
  693. for tclheaderpath in $tclheaderpaths
  694. do
  695. for tclheaderfn in $tclheadernames
  696. do
  697. if test -r "$tclheaderpath/$tclheaderfn"
  698. then
  699. AC_MSG_RESULT(found $tclheaderpath/$tclheaderfn)
  700. TCLINC="$tclheaderpath"
  701. TCLINCFN="$tclheaderfn"
  702. break 2
  703. fi
  704. done
  705. done
  706. # FreeBSD hack ...
  707. if test "${TCLINCFN-x}" = "x"
  708. then
  709. for tcllibfns in $tcllibnames
  710. do
  711. for tclheaderpath in $tclheaderpaths
  712. do
  713. for tclheaderfn in $tclheadernames
  714. do
  715. if test -r "$tclheaderpath/$tcllibfns/$tclheaderfn"
  716. then
  717. AC_MSG_RESULT(found $tclheaderpath/$tcllibfns/$tclheaderfn)
  718. TCLINC="$tclheaderpath/$tcllibfns"
  719. TCLINCFN="$tclheaderfn"
  720. break 3
  721. fi
  722. done
  723. done
  724. done
  725. fi
  726. fi
  727. # Show if $TCLINCFN wasn't found
  728. if test "${TCLINCFN-x}" = "x"
  729. then
  730. AC_MSG_RESULT(not found)
  731. fi
  732. AC_SUBST(TCLINC)dnl
  733. AC_SUBST(TCLINCFN)dnl
  734. ])dnl
  735. dnl EGG_CACHE_UNSET(CACHE-ID)
  736. dnl
  737. dnl Unsets a certain cache item. Typically called before using
  738. dnl the AC_CACHE_*() macros.
  739. AC_DEFUN(EGG_CACHE_UNSET, [dnl
  740. unset $1
  741. ])
  742. dnl EGG_TCL_DETECT_CHANGE()
  743. dnl
  744. dnl Detect whether the Tcl system has changed since our last
  745. dnl configure run. Set egg_tcl_changed accordingly.
  746. dnl
  747. dnl Tcl related feature and version checks should re-run their
  748. dnl checks as soon as egg_tcl_changed is set to "yes".
  749. AC_DEFUN(EGG_TCL_DETECT_CHANGE, [dnl
  750. AC_MSG_CHECKING(whether the Tcl system has changed)
  751. egg_tcl_changed=yes
  752. egg_tcl_id="$TCLLIB:$TCLLIBFN:$TCLINC:$TCLINCFN"
  753. if test ! "$egg_tcl_id" = ":::"
  754. then
  755. egg_tcl_cached=yes
  756. AC_CACHE_VAL(egg_cv_var_tcl_id, [dnl
  757. egg_cv_var_tcl_id="$egg_tcl_id"
  758. egg_tcl_cached=no
  759. ])
  760. if test "$egg_tcl_cached" = "yes"
  761. then
  762. if test "${egg_cv_var_tcl_id-x}" = "${egg_tcl_id-x}"
  763. then
  764. egg_tcl_changed=no
  765. else
  766. egg_cv_var_tcl_id="$egg_tcl_id"
  767. fi
  768. fi
  769. fi
  770. if test "$egg_tcl_changed" = "yes"
  771. then
  772. AC_MSG_RESULT(yes)
  773. else
  774. AC_MSG_RESULT(no)
  775. fi
  776. ])
  777. dnl EGG_TCL_CHECK_VERSION()
  778. dnl
  779. AC_DEFUN(EGG_TCL_CHECK_VERSION, [dnl
  780. # Both TCLLIBFN & TCLINCFN must be set, or we bail
  781. TCL_FOUND=0
  782. if test ! "${TCLLIBFN-x}" = "x" && test ! "${TCLINCFN-x}" = "x"
  783. then
  784. TCL_FOUND=1
  785. # Check Tcl's version
  786. if test "$egg_tcl_changed" = "yes"
  787. then
  788. EGG_CACHE_UNSET(egg_cv_var_tcl_version)
  789. fi
  790. AC_MSG_CHECKING(for Tcl version)
  791. AC_CACHE_VAL(egg_cv_var_tcl_version, [dnl
  792. egg_cv_var_tcl_version=`grep TCL_VERSION $TCLINC/$TCLINCFN | $HEAD_1 | $AWK '{gsub(/\"/, "", [$]3); print [$]3}'`
  793. ])
  794. if test ! "${egg_cv_var_tcl_version-x}" = "x"
  795. then
  796. AC_MSG_RESULT($egg_cv_var_tcl_version)
  797. else
  798. AC_MSG_RESULT(not found)
  799. TCL_FOUND=0
  800. fi
  801. # Check Tcl's patch level (if available)
  802. if test "$egg_tcl_changed" = "yes"
  803. then
  804. EGG_CACHE_UNSET(egg_cv_var_tcl_patch_level)
  805. fi
  806. AC_MSG_CHECKING(for Tcl patch level)
  807. AC_CACHE_VAL(egg_cv_var_tcl_patch_level, [dnl
  808. eval "egg_cv_var_tcl_patch_level=`grep TCL_PATCH_LEVEL $TCLINC/$TCLINCFN | $HEAD_1 | $AWK '{gsub(/\"/, "", [$]3); print [$]3}'`"
  809. ])
  810. if test ! "${egg_cv_var_tcl_patch_level-x}" = "x"
  811. then
  812. AC_MSG_RESULT($egg_cv_var_tcl_patch_level)
  813. else
  814. egg_cv_var_tcl_patch_level="unknown"
  815. AC_MSG_RESULT(unknown)
  816. fi
  817. fi
  818. # Check if we found Tcl's version
  819. if test "$TCL_FOUND" = 0
  820. then
  821. cat << 'EOF' >&2
  822. configure: error:
  823. I can't find Tcl on this system.
  824. The download website is at:
  825. http://www.tcl.tk/software/tcltk/download84.html
  826. A nice direct link for the tarball is:
  827. http://aleron.dl.sourceforge.net/sourceforge/tcl/tcl8.4.4-src.tar.gz
  828. OR
  829. Just type: ./build -T
  830. EOF
  831. exit 1
  832. fi
  833. ])dnl
  834. dnl EGG_TCL_CHECK_PRE80()
  835. dnl
  836. AC_DEFUN(EGG_TCL_CHECK_PRE80, [dnl
  837. # Is this version of Tcl too old for us to use ?
  838. TCL_VER_PRE80=`echo $egg_cv_var_tcl_version | $AWK '{split([$]1, i, "."); if (i[[1]] < 8) print "yes"; else print "no"}'`
  839. if test "$TCL_VER_PRE80" = "yes"
  840. then
  841. cat << EOF >&2
  842. configure: error:
  843. Your Tcl version is much too old for Eggdrop to use.
  844. I suggest you download and compile a more recent version.
  845. The most reliable current version is $tclrecommendver and
  846. can be downloaded from $tclrecommendsite
  847. EOF
  848. exit 1
  849. fi
  850. ])dnl
  851. dnl EGG_TCL_TESTLIBS()
  852. dnl
  853. AC_DEFUN(EGG_TCL_TESTLIBS, [dnl
  854. # Set variables for Tcl library tests
  855. TCL_TEST_LIB="$TCLLIBFNS"
  856. TCL_TEST_OTHERLIBS="-L$TCLLIB $EGG_MATH_LIB"
  857. if test ! "${ac_cv_lib_pthread-x}" = "x"
  858. then
  859. TCL_TEST_OTHERLIBS="$TCL_TEST_OTHERLIBS $ac_cv_lib_pthread"
  860. fi
  861. ])dnl
  862. dnl EGG_TCL_CHECK_FREE()
  863. dnl
  864. AC_DEFUN(EGG_TCL_CHECK_FREE, [dnl
  865. if test "$egg_tcl_changed" = "yes"
  866. then
  867. EGG_CACHE_UNSET(egg_cv_var_tcl_free)
  868. fi
  869. # Check for Tcl_Free()
  870. AC_CHECK_LIB($TCL_TEST_LIB, Tcl_Free, egg_cv_var_tcl_free="yes", egg_cv_var_tcl_free="no", $TCL_TEST_OTHERLIBS)
  871. if test "$egg_cv_var_tcl_free" = "yes"
  872. then
  873. AC_DEFINE(HAVE_TCL_FREE, 1, [Define for Tcl that has Tcl_Free() (7.5p1 and later)])dnl
  874. fi
  875. ])dnl
  876. dnl EGG_TCL_CHECK_THREADS()
  877. dnl
  878. AC_DEFUN(EGG_TCL_CHECK_THREADS, [dnl
  879. if test "$egg_tcl_changed" = "yes"
  880. then
  881. EGG_CACHE_UNSET(egg_cv_var_tcl_threaded)
  882. fi
  883. # Check for TclpFinalizeThreadData()
  884. AC_CHECK_LIB($TCL_TEST_LIB, TclpFinalizeThreadData, egg_cv_var_tcl_threaded="yes", egg_cv_var_tcl_threaded="no", $TCL_TEST_OTHERLIBS)
  885. enable_tcl_threads=no
  886. if test "$egg_cv_var_tcl_threaded" = "yes"
  887. then
  888. if test "$enable_tcl_threads" = "no"
  889. then
  890. cat << 'EOF' >&2
  891. configure: warning:
  892. You have disabled threads support on a system with a threaded Tcl library.
  893. Tcl features that rely on scheduled events may not function properly.
  894. EOF
  895. fi
  896. # Add pthread library to $LIBS if we need it
  897. if test ! "${ac_cv_lib_pthread-x}" = "x"
  898. then
  899. LIBS="$ac_cv_lib_pthread $LIBS"
  900. fi
  901. fi
  902. ])dnl
  903. dnl EGG_TCL_LIB_REQS()
  904. dnl
  905. AC_DEFUN(EGG_TCL_LIB_REQS, [dnl
  906. if test "$EGG_CYGWIN" = "yes"
  907. then
  908. TCL_REQS="$TCLLIB/lib$TCLLIBFN"
  909. TCL_LIBS="-L$TCLLIB -l$TCLLIBFNS $EGG_MATH_LIB"
  910. else
  911. if test ! "$TCLLIBEXT" = ".a"
  912. then
  913. cat << 'EOF' >&2
  914. configure: warning:
  915. Your Tcl library is not compiled statically.
  916. You will need to compile Tcl statically to successfully compile wraith.
  917. EOF
  918. exit 1
  919. else
  920. # Was the --with-tcllib option given ?
  921. if test ! "${tcllibname-x}" = "x"
  922. then
  923. TCL_REQS="$TCLLIB/lib$TCLLIBFN"
  924. TCL_LIBS="$TCLLIB/lib$TCLLIBFN $EGG_MATH_LIB"
  925. else
  926. TCL_REQS="$TCLLIB/lib$TCLLIBFN"
  927. TCL_LIBS="-L$TCLLIB -l$TCLLIBFNS $EGG_MATH_LIB"
  928. fi
  929. fi
  930. fi
  931. AC_SUBST(TCL_REQS)dnl
  932. AC_SUBST(TCL_LIBS)dnl
  933. ])dnl
  934. dnl EGG_SUBST_VERSION()
  935. dnl
  936. AC_DEFUN(EGG_SUBST_VERSION, [dnl
  937. VERSION=`grep "char" $srcdir/src/main.c | $AWK '/egg_version/ {print [$]5}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
  938. NUMVER=`grep "int" $srcdir/src/main.c | $AWK '/egg_numver =/ {print [$]5}' | sed -e 's/\;//g'`
  939. if ! test -f $srcdir/pack/pack.cfg; then
  940. cat << 'EOF' >&2
  941. configure: error:
  942. Your pack cfg is missing, please copy it to $srcdir/pack/pack.cfg
  943. EOF
  944. exit 1
  945. fi
  946. PACKNAME=`grep "PACKNAME " $srcdir/pack/pack.cfg | $AWK '/PACKNAME/ {print [$]2}'`
  947. version_num=`echo $VERSION | $AWK 'BEGIN {FS = "."} {printf("%d%02d%02d", [$]1, [$]2, [$]3)}'`
  948. AC_DEFINE_UNQUOTED(EGG_VERSION, $version_num, [Defines the current pack version])dnl
  949. AC_SUBST(VERSION)dnl
  950. AC_SUBST(NUMVER)dnl
  951. AC_SUBST(PACKNAME)dnl
  952. ])dnl
  953. dnl EGG_SUBST_MOD_UPDIR()
  954. dnl
  955. dnl Since module's Makefiles aren't generated by configure, some
  956. dnl paths in src/mod/Makefile.in take care of them. For correct
  957. dnl path "calculation", we need to keep absolute paths in mind
  958. dnl (which don't need a "../" pre-pended).
  959. AC_DEFUN(EGG_SUBST_MOD_UPDIR, [dnl
  960. case "$srcdir" in
  961. [[\\/]]* | ?:[[\\/]]*)
  962. MOD_UPDIR=""
  963. ;;
  964. *)
  965. MOD_UPDIR="../"
  966. ;;
  967. esac
  968. AC_SUBST(MOD_UPDIR)dnl
  969. ])dnl
  970. dnl EGG_REPLACE_IF_CHANGED(FILE-NAME, CONTENTS-CMDS, INIT-CMDS)
  971. dnl
  972. dnl Replace FILE-NAME if the newly created contents differs from the existing
  973. dnl file contents. Otherwise, leave the file alone. This avoids needless
  974. dnl recompiles.
  975. m4_define(EGG_REPLACE_IF_CHANGED,
  976. [
  977. AC_CONFIG_COMMANDS([replace-if-changed],
  978. [[
  979. egg_replace_file="$1"
  980. $2
  981. if test -f "$egg_replace_file" && cmp -s conftest.out $egg_replace_file; then
  982. echo "$1 is unchanged"
  983. else
  984. echo "creating $1"
  985. mv conftest.out $egg_replace_file
  986. fi
  987. rm -f conftest.out
  988. ]],
  989. [[$3]])
  990. ])
  991. dnl EGG_TCL_LUSH()
  992. AC_DEFUN([EGG_TCL_LUSH],
  993. [
  994. EGG_REPLACE_IF_CHANGED(lush.h,
  995. [
  996. cat > conftest.out << EOF
  997. /* Ignore me but do not erase me. I am a kludge. */
  998. #include "${egg_tclinc}/${egg_tclincfn}"
  999. EOF
  1000. ], [
  1001. egg_tclinc="$TCLINC"
  1002. egg_tclincfn="$TCLINCFN"
  1003. ])
  1004. ])
  1005. dnl EGG_CATCH_MAKEFILE_REBUILD()
  1006. AC_DEFUN([EGG_CATCH_MAKEFILE_REBUILD],
  1007. [
  1008. AC_CONFIG_COMMANDS([catch-make-rebuild],
  1009. [[
  1010. if test -f .modules; then
  1011. $srcdir/misc/modconfig --top_srcdir="$srcdir/src" Makefile
  1012. fi
  1013. ]])
  1014. ])
  1015. dnl EGG_SAVE_PARAMETERS()
  1016. dnl
  1017. AC_DEFUN(EGG_SAVE_PARAMETERS, [dnl
  1018. # Remove --cache-file and --srcdir arguments so they do not pile up.
  1019. egg_ac_parameters=
  1020. ac_prev=
  1021. for ac_arg in $ac_configure_args; do
  1022. if test -n "$ac_prev"; then
  1023. ac_prev=
  1024. continue
  1025. fi
  1026. case $ac_arg in
  1027. -cache-file | --cache-file | --cache-fil | --cache-fi \
  1028. | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
  1029. ac_prev=cache_file ;;
  1030. -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  1031. | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
  1032. | --c=*)
  1033. ;;
  1034. --config-cache | -C)
  1035. ;;
  1036. -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  1037. ac_prev=srcdir ;;
  1038. -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  1039. ;;
  1040. *) egg_ac_parameters="$egg_ac_parameters $ac_arg" ;;
  1041. esac
  1042. done
  1043. AC_SUBST(egg_ac_parameters)dnl
  1044. ])dnl
  1045. AC_DEFUN([AC_PROG_CC_WIN32], [
  1046. AC_MSG_CHECKING([how to access the Win32 API])
  1047. WIN32FLAGS=
  1048. AC_TRY_COMPILE(,[
  1049. #ifndef WIN32
  1050. # ifndef _WIN32
  1051. # error WIN32 or _WIN32 not defined
  1052. # endif
  1053. #endif], [
  1054. dnl found windows.h with the current config.
  1055. AC_MSG_RESULT([present by default])
  1056. ], [
  1057. dnl try -mwin32
  1058. ac_compile_save="$ac_compile"
  1059. dnl we change CC so config.log looks correct
  1060. save_CC="$CC"
  1061. ac_compile="$ac_compile -mwin32"
  1062. CC="$CC -mwin32"
  1063. AC_TRY_COMPILE(,[
  1064. #ifndef WIN32
  1065. # ifndef _WIN32
  1066. # error WIN32 or _WIN32 not defined
  1067. # endif
  1068. #endif], [
  1069. dnl found windows.h using -mwin32
  1070. AC_MSG_RESULT([found via -mwin32])
  1071. ac_compile="$ac_compile_save"
  1072. CC="$save_CC"
  1073. WIN32FLAGS="-mwin32"
  1074. ], [
  1075. ac_compile="$ac_compile_save"
  1076. CC="$save_CC"
  1077. AC_MSG_RESULT([not found])
  1078. ])
  1079. ])
  1080. ])
  1081. dnl