configure.in 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_INIT(rAthena)
  4. AC_REVISION($Revision$)
  5. AC_PREREQ([2.59])
  6. AC_CONFIG_SRCDIR([src/common/cbasetypes.h])
  7. AC_CONFIG_FILES([Makefile src/common/Makefile])
  8. AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile])
  9. AC_CONFIG_FILES([src/char/Makefile src/login/Makefile])
  10. AC_CONFIG_FILES([src/map/Makefile src/tool/Makefile])
  11. AC_GNU_SOURCE
  12. #
  13. # Memory managers
  14. #
  15. AC_ARG_ENABLE(
  16. [manager],
  17. AC_HELP_STRING(
  18. [--enable-manager=ARG],
  19. [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
  20. ),
  21. [
  22. enable_manager="$enableval"
  23. case $enableval in
  24. "no");;
  25. "builtin");;
  26. "memwatch");;
  27. "dmalloc");;
  28. "gcollect");;
  29. "bcheck");;
  30. *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
  31. esac
  32. ],
  33. [enable_manager="builtin"]
  34. )
  35. #
  36. # packetver
  37. #
  38. AC_ARG_ENABLE(
  39. [packetver],
  40. AC_HELP_STRING(
  41. [--enable-packetver=ARG],
  42. [Sets the PACKETVER define. (see src/common/mmo.h)]
  43. ),
  44. [enable_packetver="$enableval"],
  45. [enable_packetver=""]
  46. )
  47. #
  48. # debug
  49. #
  50. AC_ARG_ENABLE(
  51. [debug],
  52. AC_HELP_STRING(
  53. [--enable-debug@<:@=ARG@:>@],
  54. [
  55. Compiles extra debug code. (disabled by default)
  56. (available options: yes, no, gdb)
  57. ]
  58. ),
  59. [
  60. enable_debug="$enableval"
  61. case $enableval in
  62. "no");;
  63. "yes");;
  64. "gdb");;
  65. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
  66. esac
  67. ],
  68. [enable_debug="no"]
  69. )
  70. #
  71. # renewal
  72. #
  73. AC_ARG_ENABLE(
  74. [prere],
  75. AC_HELP_STRING(
  76. [--enable-prere@<:@=ARG@:>@],
  77. [
  78. Compiles serv in prere mode. (disabled by default)
  79. (available options: yes, no)
  80. ]
  81. ),
  82. [
  83. enable_prere="$enableval"
  84. case $enableval in
  85. "no");;
  86. "yes");;
  87. *) AC_MSG_ERROR([[invalid argument --enable-prere=$enableval... stopping]]);;
  88. esac
  89. ],
  90. [enable_prere="no"]
  91. )
  92. #
  93. # warn
  94. #
  95. AC_ARG_ENABLE(
  96. [warn],
  97. AC_HELP_STRING(
  98. [--enable-warn@<:@=ARG@:>@],
  99. [
  100. Compiles with warnings. (disabled by default)
  101. (available options: yes, no, extra)
  102. ]
  103. ),
  104. [
  105. enable_warn="$enableval"
  106. case $enableval in
  107. "no");;
  108. "yes");;
  109. "extra");;
  110. *) AC_MSG_ERROR([[invalid argument --enable-warn=$enableval... stopping]]);;
  111. esac
  112. ],
  113. [enable_warn="no"]
  114. )
  115. #
  116. # Buildbot
  117. #
  118. AC_ARG_ENABLE(
  119. [buildbot],
  120. AC_HELP_STRING(
  121. [--enable-buildbot@<:@=ARG@:>@],
  122. [(available options: yes, no)]
  123. ),
  124. [
  125. enable_buildbot="$enableval"
  126. case $enableval in
  127. "no");;
  128. "yes");;
  129. *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);;
  130. esac
  131. ],
  132. [enable_buildbot="no"]
  133. )
  134. #
  135. # RDTSC as Tick Source
  136. #
  137. AC_ARG_ENABLE(
  138. [rdtsc],
  139. AC_HELP_STRING(
  140. [--enable-rdtsc],
  141. [
  142. Uses rdtsc as timing source (disabled by default)
  143. Enable it when you've timing issues.
  144. (For example: in conjunction with XEN or Other Virtualization mechanisms)
  145. Note:
  146. Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
  147. (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual
  148. how to disable it)
  149. ]
  150. ),
  151. [
  152. enable_rdtsc=1
  153. ],
  154. [enable_rdtsc=0]
  155. )
  156. #
  157. # Profiler
  158. #
  159. AC_ARG_ENABLE(
  160. [profiler],
  161. AC_HELP_STRING(
  162. [--enable-profiler=ARG],
  163. [Profilers: no, gprof (disabled by default)]
  164. ),
  165. [
  166. enable_profiler="$enableval"
  167. case $enableval in
  168. "no");;
  169. "gprof");;
  170. *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
  171. esac
  172. ],
  173. [enable_profiler="no"]
  174. )
  175. #
  176. # 64bit
  177. #
  178. AC_ARG_ENABLE(
  179. [64bit],
  180. AC_HELP_STRING(
  181. [--disable-64bit],
  182. [
  183. Enforce 32bit output on x86_64 systems.
  184. ]
  185. ),
  186. [
  187. enable_64bit="$enableval"
  188. case $enableval in
  189. "no");;
  190. "yes");;
  191. *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);;
  192. esac
  193. ],
  194. [enable_64bit="yes"]
  195. )
  196. #
  197. # LTO
  198. #
  199. AC_ARG_ENABLE(
  200. [lto],
  201. AC_HELP_STRING(
  202. [--enable-lto],
  203. [
  204. Enables or Disables Linktime Code Optimization (LTO is enabled by default)
  205. ]
  206. ),
  207. [
  208. enable_lto="$enableval"
  209. case $enableval in
  210. "no");;
  211. "yes");;
  212. *) AC_MSG_ERROR([[invalid argument --enable-lto=$disableval... stopping]]);;
  213. esac
  214. ],
  215. [enable_lto="yes"]
  216. )
  217. #
  218. # Optionally set the max number of network conenctions
  219. # the core will be support
  220. #
  221. AC_ARG_WITH(
  222. [maxconn],
  223. AC_HELP_STRING(
  224. [--with-maxconn@<:@=ARG@:>@],
  225. [optionally set the maximum connections the core can handle (default: 16384) NOT USED YET - EXPERIMENTAL]
  226. ),
  227. [
  228. if test "$withval" == "no"; then
  229. CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
  230. else
  231. if ! test "$withval" -ge 0 -o "$withval" -lt 0 2>&- ; then
  232. AC_MSG_ERROR([Invalid argument --with-maxconn=$withval ... stopping])
  233. else
  234. CPPFLAGS="$CPPFLAGS -DMAXCONN=$withval"
  235. fi
  236. fi
  237. ],
  238. [
  239. CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
  240. ]
  241. )
  242. #
  243. # output bin name
  244. #
  245. AC_ARG_WITH(
  246. [outputlogin],
  247. AC_HELP_STRING(
  248. [--with-outputlogin@<:@=ARG@:>@],
  249. [Specify the login-serv output name (defaults to login-server)]
  250. ),
  251. [output_login="$withval"],
  252. [output_login="login-server"]
  253. )
  254. AC_SUBST([OLOG],$output_login)
  255. AC_ARG_WITH(
  256. [outputchar],
  257. AC_HELP_STRING(
  258. [--with-outputchar@<:@=ARG@:>@],
  259. [Specify the char-serv output name (defaults to char-server)]
  260. ),
  261. [output_char="$withval"],
  262. [output_char="char-server"]
  263. )
  264. AC_SUBST([OCHR],$output_char)
  265. AC_ARG_WITH(
  266. [outputmap],
  267. AC_HELP_STRING(
  268. [--with-outputmap@<:@=ARG@:>@],
  269. [Specify the map-serv output name (defaults to map-server)]
  270. ),
  271. [output_map="$withval"],
  272. [output_map="map-server"]
  273. )
  274. AC_SUBST([OMAP],$output_map)
  275. #
  276. # Optionally specify the path to mysql_config
  277. #
  278. AC_ARG_WITH(
  279. [mysql],
  280. AC_HELP_STRING(
  281. [--with-mysql@<:@=ARG@:>@],
  282. [optionally specify the path to the mysql_config executable]
  283. ),
  284. [
  285. if test "$withval" != "no" ; then
  286. if test ! -x "$withval" ; then
  287. AC_MSG_ERROR([$withval is not an executable file])
  288. fi
  289. MYSQL_CONFIG_HOME="$withval"
  290. fi
  291. ]
  292. )
  293. #
  294. # Manual MYSQL_CFLAGS (optional)
  295. #
  296. AC_ARG_WITH(
  297. [MYSQL_CFLAGS],
  298. AC_HELP_STRING(
  299. [--with-MYSQL_CFLAGS=ARG],
  300. [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
  301. ),
  302. [
  303. manual_MYSQL_CFLAGS="yes"
  304. MYSQL_CFLAGS="$withval"
  305. ],
  306. [manual_MYSQL_CFLAGS="no"]
  307. )
  308. #
  309. # Manual MYSQL_LIBS (optional)
  310. #
  311. AC_ARG_WITH(
  312. [MYSQL_LIBS],
  313. AC_HELP_STRING(
  314. [--with-MYSQL_LIBS=ARG],
  315. [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
  316. ),
  317. [
  318. manual_MYSQL_LIBS="yes"
  319. MYSQL_LIBS="$withval"
  320. ],
  321. [manual_MYSQL_LIBS="no"]
  322. )
  323. #
  324. # Enable/disable PCRE and optionally specify the path (optional library)
  325. #
  326. AC_ARG_WITH(
  327. [pcre],
  328. AC_HELP_STRING(
  329. [--with-pcre@<:@=ARG@:>@],
  330. [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
  331. ),
  332. [
  333. if test "$withval" = "no" ; then
  334. want_pcre="no"
  335. else
  336. want_pcre="yes"
  337. require_pcre="yes"
  338. if test "$withval" != "yes" ; then
  339. if test ! -d "$withval" ; then
  340. AC_MSG_ERROR([$withval is not a directoy])
  341. fi
  342. PCRE_HOME="$withval"
  343. fi
  344. fi
  345. ],
  346. [want_pcre="yes" require_pcre="no"]
  347. )
  348. #
  349. # Specify the path of the zlib library (required library)
  350. #
  351. AC_ARG_WITH(
  352. [zlib],
  353. AC_HELP_STRING(
  354. [--with-zlib=DIR],
  355. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
  356. Assumes that the header files are in DIR/include and the library files are in DIR/lib]
  357. ),
  358. [
  359. test -n "$withval" && ZLIB_HOME="$withval"
  360. ],
  361. [
  362. ZLIB_HOME=/usr/local
  363. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  364. ]
  365. )
  366. ###############################################################################
  367. # Check for programs and types.
  368. #
  369. AC_PROG_MAKE_SET
  370. AC_PROG_CC
  371. AC_PROG_CPP
  372. AC_PATH_PROG(AR, ar)
  373. AC_LANG([C])
  374. CFLAGS="$CFLAGS -pipe -ffast-math -Wall"
  375. CPPFLAGS="$CPPFLAGS -I../common"
  376. AC_C_BIGENDIAN(
  377. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  378. ,
  379. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  380. )
  381. if test "$enable_64bit" = "no" ; then
  382. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  383. pointers_fit_in_ints="no"
  384. AC_COMPILE_IFELSE(
  385. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  386. [pointers_fit_in_ints="yes"],
  387. []
  388. )
  389. if test "$pointers_fit_in_ints" = "no" ; then
  390. CFLAGS="$CFLAGS -m32"
  391. LDFLAGS="$LDFLAGS -m32"
  392. AC_COMPILE_IFELSE(
  393. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  394. [pointers_fit_in_ints="yes (with -m32)"],
  395. []
  396. )
  397. fi
  398. AC_MSG_RESULT($pointers_fit_in_ints)
  399. if test "$pointers_fit_in_ints" = "no" ; then
  400. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  401. fi
  402. fi
  403. #
  404. # check if we're producing 32bit code - so well produce binarys for at least i686 (speedup: cmovs, and cmpchg8 support)
  405. #
  406. AC_MSG_CHECKING([whether $CC produces 32bit code])
  407. AC_RUN_IFELSE(
  408. [AC_LANG_SOURCE([
  409. int main(int argc, char **argv){
  410. if(sizeof(void*) == 4) return 0;
  411. else return 1;
  412. }
  413. ])],
  414. [
  415. AC_MSG_RESULT([yes])
  416. AC_MSG_CHECKING([whether $CC supports -march=i686 (and we can run it)])
  417. OLD_CFLAGS="$CFLAGS"
  418. OLD_LDFLAGS="$LDFLAGS"
  419. CFLAGS="$CFLAGS -march=i686"
  420. LDFLAGS="$LDFLAGS -march=i686"
  421. AC_RUN_IFELSE(
  422. [AC_LANG_SOURCE([
  423. int main(int argc, char **argv) { return 0; }
  424. ])],
  425. [
  426. AC_MSG_RESULT([yes])
  427. ],
  428. [
  429. AC_MSG_RESULT([no])
  430. CFLAGS="$OLD_CFLAGS"
  431. LDFLAGS="$OLD_LDFLAGS"
  432. ],
  433. [
  434. AC_MSG_RESULT([guessing no])
  435. CFLAGS="$OLD_CFLAGS"
  436. LDFLAGS="$OLD_LDFLAGS"
  437. ]
  438. )
  439. ],
  440. [
  441. AC_MSG_RESULT([no])
  442. ],
  443. [
  444. AC_MSG_RESULT([guessing no])
  445. ]
  446. )
  447. #
  448. # Check if CC supports __thread attribute (Thread Local Storage)
  449. # (Usually our OSX friends 're lacking support of it in older llvm versions ..)
  450. #
  451. AC_MSG_CHECKING([whether $CC supports __thread specifier (TLS)])
  452. AC_RUN_IFELSE(
  453. [AC_LANG_SOURCE([
  454. __thread int g_Test = -1;
  455. int main(int argc, char **argv){
  456. g_Test = 0;
  457. return g_Test;
  458. }
  459. ])],
  460. [
  461. AC_MSG_RESULT([yes])
  462. CPPFLAGS="$CPPFLAGS -DHAS_TLS"
  463. ],
  464. [
  465. AC_MSG_RESULT([no])
  466. ]
  467. )
  468. #
  469. # LTO Support test
  470. #
  471. if test "$enable_lto" != "no" ; then
  472. OPT_LTO_AR=""
  473. OPT_LTO=""
  474. OLD_CFLAGS="$CFLAGS"
  475. CFLAGS="$CFLAGS -flto -fuse-linker-plugin -ffat-lto-objects"
  476. OLD_LDFLAGS="$LDFLAGS"
  477. LDFLAGS="$LDFLAGS -flto -fuse-linker-plugin -ffat-lto-objects"
  478. AC_MSG_CHECKING([whether $CC supports -ffat-lto-objects])
  479. AC_RUN_IFELSE(
  480. [AC_LANG_SOURCE([
  481. int main(int argc, char **argv){
  482. return 0;
  483. }
  484. ])],
  485. [
  486. AC_MSG_RESULT([yes])
  487. OPT_LTO_AR="-ffat-lto-objects"
  488. ],
  489. [
  490. AC_MSG_RESULT([no])
  491. ],
  492. [
  493. AC_MSG_RESULT([guessing no])
  494. ]
  495. )
  496. CFLAGS="$OLD_CFLAGS"
  497. LDFLAGS="$OLD_LDFLAGS"
  498. CFLAGS="$CFLAGS -flto -fuse-linker-plugin"
  499. LDFLAGS="$LDFLAGS -flto -fuse-linker-plugin"
  500. AC_MSG_CHECKING([whether $CC supports -flto -fuse-linker-plugin])
  501. AC_RUN_IFELSE(
  502. [AC_LANG_SOURCE([
  503. int main(int argc, char **argv){
  504. return 0;
  505. }
  506. ])],
  507. [
  508. AC_MSG_RESULT([yes])
  509. OPT_LTO_AR="-flto -fuse-linker-plugin $OPT_LTO_AR"
  510. OPT_LTO="-flto -fuse-linker-plugin"
  511. ],
  512. [
  513. AC_MSG_RESULT([no])
  514. ],
  515. [
  516. AC_MSG_RESULT([guessing no])
  517. ]
  518. )
  519. CFLAGS="$OLD_CFLAGS"
  520. LDFLAGS="$OLD_LDFLAGS"
  521. fi
  522. AC_DEFUN(AC_CHECK_COMPILER_WFLAG,
  523. [
  524. AC_MSG_CHECKING([whether $CC supports -W$1])
  525. OLD_CFLAGS="$CFLAGS"
  526. CFLAGS="$CFLAGS -Werror -W$1"
  527. AC_COMPILE_IFELSE(
  528. [AC_LANG_SOURCE([int foo;])],
  529. [
  530. AC_MSG_RESULT([yes])
  531. CFLAGS="$OLD_CFLAGS -W$1"
  532. # Optionally, run a test
  533. if test "x$2" != "x"; then
  534. AC_MSG_CHECKING([whether $CC can actually use -W$1])
  535. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  536. AC_COMPILE_IFELSE(
  537. [AC_LANG_SOURCE([$2])],
  538. [
  539. AC_MSG_RESULT([no])
  540. CFLAGS="$OLD_CFLAGS"
  541. ]
  542. [
  543. AC_MSG_RESULT([yes])
  544. CFLAGS="$OLD_CFLAGS -W$1"
  545. ],
  546. )
  547. fi
  548. ],
  549. [
  550. AC_MSG_RESULT([no])
  551. CFLAGS="$OLD_CFLAGS"
  552. ]
  553. )
  554. ]
  555. )
  556. AC_DEFUN(AC_CHECK_COMPILER_WNOFLAG,
  557. [
  558. AC_MSG_CHECKING([whether $CC supports -Wno-$1])
  559. OLD_CFLAGS="$CFLAGS"
  560. CFLAGS="$CFLAGS -Werror -Wno-$1"
  561. AC_COMPILE_IFELSE(
  562. [AC_LANG_SOURCE([int foo;])],
  563. [
  564. # Recent versions of gcc don't fail if -Wno-foo is not recognized
  565. # (unless there are also other warnings), so we also check for -Wfoo
  566. # which always fails if not supported
  567. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  568. AC_COMPILE_IFELSE(
  569. [AC_LANG_SOURCE([int foo;])],
  570. [
  571. AC_MSG_RESULT([yes])
  572. CFLAGS="$OLD_CFLAGS -Wno-$1"
  573. # Optionally, run a test
  574. if test "x$2" != "x"; then
  575. AC_MSG_CHECKING([whether $CC can actually use -Wno-$1])
  576. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  577. AC_COMPILE_IFELSE(
  578. [AC_LANG_SOURCE([$2])],
  579. [
  580. AC_MSG_RESULT([not needed but enabled])
  581. CFLAGS="$OLD_CFLAGS"
  582. ],
  583. [
  584. CFLAGS="$OLD_CFLAGS -Werror -Wno-$1"
  585. AC_COMPILE_IFELSE(
  586. [AC_LANG_SOURCE([$2])],
  587. [
  588. AC_MSG_RESULT([yes])
  589. CFLAGS="$OLD_CFLAGS -Wno-$1"
  590. ],
  591. [
  592. AC_MSG_RESULT([no])
  593. CFLAGS="$OLD_CFLAGS"
  594. ]
  595. )
  596. ]
  597. )
  598. fi
  599. ],
  600. [
  601. AC_MSG_RESULT([no])
  602. CFLAGS="$OLD_CFLAGS"
  603. ]
  604. )
  605. ],
  606. [
  607. AC_MSG_RESULT([no])
  608. CFLAGS="$OLD_CFLAGS"
  609. ]
  610. )
  611. ]
  612. )
  613. AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
  614. AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
  615. AC_CHECK_COMPILER_WNOFLAG(clobbered)
  616. AC_CHECK_COMPILER_WFLAG(empty-body)
  617. AC_CHECK_COMPILER_WFLAG(newline-eof)
  618. AC_CHECK_COMPILER_WFLAG(int-conversion)
  619. AC_CHECK_COMPILER_WFLAG(enum-conversion)
  620. AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
  621. AC_CHECK_COMPILER_WFLAG(constant-conversion)
  622. AC_CHECK_COMPILER_WFLAG(bool-conversion)
  623. AC_CHECK_COMPILER_WNOFLAG(switch)
  624. AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
  625. # Certain versions of gcc make -Wshadow completely useless by making it flood
  626. # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
  627. # Let's check if we can really use it
  628. SAVED_OLD_CFLAGS="$CFLAGS"
  629. AC_CHECK_COMPILER_WFLAG(shadow)
  630. if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
  631. AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
  632. NEW_CFLAGS="$CFLAGS"
  633. CFLAGS="$CFLAGS -Werror -Wshadow"
  634. AC_COMPILE_IFELSE(
  635. [AC_LANG_SOURCE([
  636. int foo(void) {
  637. return 0;
  638. }
  639. int bar(void) {
  640. int foo = 0;
  641. return foo + 1;
  642. }
  643. ])],
  644. [
  645. AC_MSG_RESULT([yes])
  646. CFLAGS="$NEW_CFLAGS"
  647. ],
  648. [
  649. AC_MSG_RESULT([no])
  650. CFLAGS="$SAVED_OLD_CFLAGS"
  651. ]
  652. )
  653. fi
  654. AC_MSG_CHECKING([whether $CC supports -fPIC])
  655. OLD_CFLAGS="$CFLAGS"
  656. CFLAGS="$CFLAGS -fPIC"
  657. AC_COMPILE_IFELSE(
  658. [AC_LANG_SOURCE([int foo;])],
  659. [
  660. AC_MSG_RESULT([yes])
  661. compiler_supports_pic="yes"
  662. ],
  663. [
  664. AC_MSG_RESULT([no])
  665. compiler_supports_pic="no"
  666. ]
  667. )
  668. CFLAGS="$OLD_CFLAGS"
  669. #
  670. # option for shared objects
  671. #
  672. AC_MSG_CHECKING([how to make shared objects])
  673. OLD_CFLAGS="$CFLAGS"
  674. compiler_shared_objects=""
  675. compiler_supports_shared_objects="no"
  676. if test "$compiler_supports_pic" = "yes" ; then
  677. my_shared_test_flags="$CFLAGS -fPIC"
  678. fi
  679. # default
  680. CFLAGS="$my_shared_test_flags -shared"
  681. AC_LINK_IFELSE(
  682. [AC_LANG_SOURCE([
  683. int bar = 0;
  684. int foo(void)
  685. {
  686. return bar;
  687. }
  688. ])],
  689. [
  690. compiler_shared_objects="-shared"
  691. compiler_supports_shared_objects="yes"
  692. ]
  693. )
  694. # BeOS specific
  695. CFLAGS="$my_shared_test_flags -nostart"
  696. AC_LINK_IFELSE(
  697. [AC_LANG_SOURCE([
  698. int bar = 0;
  699. int foo(void)
  700. {
  701. return bar;
  702. }
  703. ])],
  704. [
  705. compiler_shared_objects="-nostart"
  706. compiler_supports_shared_objects="yes"
  707. ]
  708. )
  709. CFLAGS="$OLD_CFLAGS"
  710. if test "$compiler_supports_shared_objects" = "no" ; then
  711. AC_MSG_RESULT([not supported])
  712. AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
  713. WITH_PLUGINS="no"
  714. else
  715. AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
  716. SOFLAGS="$SOFLAGS $compiler_shared_objects"
  717. AC_SUBST([SOFLAGS])
  718. #
  719. # On certain platforms, undefined references on shared libraries won't be checked
  720. # unless explicitly required with the --no-undefined linker option
  721. #
  722. AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
  723. OLD_CFLAGS="$CFLAGS"
  724. CFLAGS="$SOFLAGS"
  725. AC_LINK_IFELSE(
  726. [AC_LANG_SOURCE([
  727. void foo(void) {
  728. foobar();
  729. }
  730. ])],
  731. [
  732. CFLAGS="$SOFLAGS -Wl,--no-undefined"
  733. AC_LINK_IFELSE(
  734. [AC_LANG_SOURCE([
  735. int bar = 0;
  736. int foo(void) {
  737. return bar;
  738. }
  739. ])],
  740. [
  741. AC_MSG_RESULT([yes])
  742. SOFLAGS="$SOFLAGS -Wl,--no-undefined"
  743. ],
  744. [
  745. AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
  746. ]
  747. )
  748. ],
  749. [
  750. AC_MSG_RESULT([no])
  751. ]
  752. )
  753. CFLAGS="$OLD_CFLAGS"
  754. #
  755. # shared objects need position independent code; some platforms emit
  756. # it always, others need -fPIC
  757. #
  758. AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
  759. OLD_CFLAGS="$CFLAGS"
  760. CFLAGS="$CFLAGS $SOFLAGS"
  761. WITH_PLUGINS="yes"
  762. AC_LINK_IFELSE(
  763. [AC_LANG_SOURCE([
  764. int bar = 0;
  765. int foo(void)
  766. {
  767. return bar;
  768. }
  769. ])],
  770. [
  771. AC_MSG_RESULT([no])
  772. CFLAGS="$OLD_CFLAGS"
  773. ],
  774. [
  775. if test "$compiler_supports_pic" = "yes" ; then
  776. # Verify if -shared really fails due to lack of -fPIC or something else
  777. CFLAGS="$CFLAGS -fPIC"
  778. AC_LINK_IFELSE(
  779. [AC_LANG_SOURCE([
  780. int bar = 0;
  781. int foo(void)
  782. {
  783. return bar;
  784. }
  785. ])],
  786. [
  787. AC_MSG_RESULT([yes])
  788. CFLAGS="$OLD_CFLAGS -fPIC"
  789. ],
  790. [
  791. AC_MSG_RESULT([no, but fails for another reason])
  792. AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
  793. ]
  794. )
  795. else
  796. # Disable compilation of plugins (optional), so 'make all' does not fail
  797. AC_MSG_RESULT([yes, but unsupported])
  798. AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
  799. WITH_PLUGINS="no"
  800. fi
  801. ]
  802. )
  803. fi
  804. my_shared_test_flags=""
  805. AC_SUBST([WITH_PLUGINS])
  806. #
  807. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  808. #
  809. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  810. OLD_CFLAGS="$CFLAGS"
  811. CFLAGS="$CFLAGS -fno-strict-aliasing"
  812. AC_COMPILE_IFELSE(
  813. [AC_LANG_SOURCE([int foo;])],
  814. [AC_MSG_RESULT([yes])],
  815. [
  816. AC_MSG_RESULT([no])
  817. CFLAGS="$OLD_CFLAGS"
  818. ]
  819. )
  820. ###############################################################################
  821. # Check for libraries and header files.
  822. #
  823. #
  824. # setrlimit - used to set the socket limit
  825. #
  826. AC_CHECK_FUNC([setrlimit],[CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT"])
  827. #
  828. # strnlen - string length with upper scan bound
  829. #
  830. AC_CHECK_FUNC([strnlen],[CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN"])
  831. # libconfig
  832. AC_CHECK_FUNCS([uselocale])
  833. AC_CHECK_FUNCS([newlocale])
  834. AC_CHECK_FUNCS([freelocale])
  835. AC_CHECK_HEADERS([xlocale.h], [], [], [
  836. AC_LANG_SOURCE([#ifdef HAVE_XLOCALE_H
  837. # include <xlocale.h>
  838. #endif
  839. ])])
  840. #
  841. # Memory manager
  842. #
  843. case $enable_manager in
  844. "no")
  845. CPPFLAGS="$CPPFLAGS -DNO_MEMMGR"
  846. ;;
  847. "builtin")
  848. # enabled by default
  849. ;;
  850. "memwatch")
  851. CPPFLAGS="$CPPFLAGS -DMEMWATCH"
  852. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  853. ;;
  854. "dmalloc")
  855. CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  856. LIBS="$LIBS -ldmalloc"
  857. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  858. ;;
  859. "gcollect")
  860. CPPFLAGS="$CPPFLAGS -DGCOLLECT"
  861. LIBS="$LIBS -lgc"
  862. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  863. ;;
  864. "bcheck")
  865. CPPFLAGS="$CPPFLAGS -DBCHECK"
  866. ;;
  867. esac
  868. #
  869. # Packetver
  870. #
  871. if test -n "$enable_packetver" ; then
  872. CPPFLAGS="$CPPFLAGS -DPACKETVER=$enable_packetver"
  873. fi
  874. #
  875. # Debug
  876. #
  877. case $enable_debug in
  878. "no")
  879. # default value
  880. CPPFLAGS="$CPPFLAGS"
  881. ;;
  882. "yes")
  883. if test $ac_cv_prog_cc_g = yes; then
  884. CPPFLAGS="$CPPFLAGS -g -DDEBUG"
  885. LDFLAGS="$LDFLAGS -g"
  886. else
  887. echo "error: --enable-debug flag=$enable_debug entered but the compiler does not support -g"
  888. exit 1
  889. fi
  890. ;;
  891. "gdb")
  892. if test $ac_cv_prog_cc_g = yes; then
  893. CPPFLAGS="$CPPFLAGS -ggdb -DDEBUG"
  894. LDFLAGS="$LDFLAGS -g"
  895. else
  896. echo "error: --enable-debug flag=$enable_debug entered but the compiler does not support -g"
  897. exit 1
  898. fi
  899. ;;
  900. esac
  901. #
  902. # Renewal
  903. #
  904. case $enable_prere in
  905. "no")
  906. # default value
  907. CPPFLAGS="$CPPFLAGS"
  908. ;;
  909. "yes")
  910. CPPFLAGS="$CPPFLAGS -DPRERE"
  911. ;;
  912. esac
  913. #
  914. # Warnings
  915. #
  916. case $enable_warn in
  917. "no") #default
  918. CPPFLAGS="$CPPFLAGS $PROD_WARN"
  919. ;;
  920. "yes")
  921. CPPFLAGS="$CPPFLAGS"
  922. ;;
  923. "extra")
  924. CPPFLAGS="$CPPFLAGS $EXTRA_WARN"
  925. ;;
  926. esac
  927. #
  928. # Buildbot
  929. #
  930. case $enable_buildbot in
  931. "no")
  932. # default value
  933. ;;
  934. "yes")
  935. CPPFLAGS="$CPPFLAGS -DBUILDBOT"
  936. ;;
  937. esac
  938. #
  939. # RDTSC
  940. #
  941. case $enable_rdtsc in
  942. 0)
  943. #default value
  944. ;;
  945. 1)
  946. CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
  947. ;;
  948. esac
  949. #
  950. # Profiler
  951. #
  952. case $enable_profiler in
  953. "no")
  954. # default value
  955. ;;
  956. "gprof")
  957. CFLAGS="$CFLAGS -pg"
  958. LDFLAGS="$LDFLAGS -pg"
  959. ;;
  960. esac
  961. #
  962. # zlib library (required)
  963. #
  964. if test -n "${ZLIB_HOME}" ; then
  965. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  966. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  967. fi
  968. AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  969. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])],
  970. [AC_LANG_SOURCE([#ifdef HAVE_ZLIB_H
  971. # include <zlib.h>
  972. #endif
  973. ])])
  974. #
  975. # math library (required)
  976. #
  977. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  978. #
  979. # clock_gettime (optional, rt on Debian)
  980. #
  981. AC_SEARCH_LIBS([clock_gettime], [rt])
  982. #
  983. # CLOCK_MONOTONIC clock for clock_gettime
  984. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  985. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  986. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  987. # checked but some systems define them even when they do not support it
  988. # (ref. bugreport:1003).
  989. #
  990. if test "$ac_cv_search_clock_gettime" != "no" ; then
  991. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  992. AC_RUN_IFELSE(
  993. [AC_LANG_SOURCE([
  994. #include <sys/time.h>
  995. #include <time.h>
  996. #include <unistd.h>
  997. int main(int argc, char** argv)
  998. {
  999. struct timespec tval;
  1000. return clock_gettime(CLOCK_MONOTONIC, &tval);
  1001. }
  1002. ])],
  1003. [
  1004. AC_MSG_RESULT([yes])
  1005. CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
  1006. ],
  1007. [
  1008. # either it failed to compile (CLOCK_MONOTONIC undefined)
  1009. # or clock_gettime has returned a non-zero value
  1010. AC_MSG_RESULT([no])
  1011. ],
  1012. [
  1013. AC_MSG_RESULT([guessing no])
  1014. ]
  1015. )
  1016. fi
  1017. #
  1018. # pthread
  1019. #
  1020. AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1021. AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1022. AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1023. AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1024. AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1025. AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1026. AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1027. #
  1028. # MySQL library
  1029. #
  1030. if test -z "$MYSQL_CONFIG_HOME"; then
  1031. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  1032. fi
  1033. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  1034. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  1035. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  1036. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  1037. fi
  1038. if test "$manual_MYSQL_LIBS" = "no" ; then
  1039. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  1040. fi
  1041. else
  1042. MYSQL_VERSION="unknown"
  1043. fi
  1044. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  1045. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  1046. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  1047. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  1048. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  1049. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  1050. AC_MSG_CHECKING([MySQL library (required)])
  1051. if test "$HAVE_MYSQL" = "yes" ; then
  1052. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  1053. else
  1054. AC_MSG_RESULT([no])
  1055. AC_MSG_ERROR([MySQL not found or incompatible])
  1056. fi
  1057. AC_SUBST([HAVE_MYSQL])
  1058. AC_SUBST([MYSQL_VERSION])
  1059. AC_SUBST([MYSQL_CFLAGS])
  1060. AC_SUBST([MYSQL_LIBS])
  1061. #
  1062. # PCRE library (optional)
  1063. #
  1064. PCRE_LIBS=""
  1065. PCRE_CFLAGS=""
  1066. if test "$want_pcre" = "no" ; then
  1067. AC_MSG_NOTICE([ignoring PCRE (optional)])
  1068. else
  1069. host_os="`uname`"
  1070. if test "$host_os" = "FreeBSD" ; then
  1071. if test -z "$PCRE_HOME" ; then PCRE_HOME="/usr/local"; fi
  1072. fi
  1073. if test -z "$PCRE_HOME" ; then
  1074. AC_SEARCH_LIBS([pcre_study], [pcre], [HAVE_PCRE="yes"], [])
  1075. if test "$HAVE_PCRE" = "yes" ; then
  1076. PCRE_LIBS="-lpcre"
  1077. fi
  1078. else
  1079. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  1080. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  1081. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  1082. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  1083. LDFLAGS="$PCRE_OLD_LDFLAGS"
  1084. if test "$HAVE_PCRE" = "yes" ; then
  1085. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  1086. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  1087. fi
  1088. fi
  1089. AC_MSG_CHECKING([PCRE library (optional)])
  1090. if test "$HAVE_PCRE" = "yes" ; then
  1091. PCRE_VERSION="`pcre-config --version`"
  1092. AC_MSG_RESULT([yes ($PCRE_VERSION)])
  1093. else
  1094. AC_MSG_RESULT([no])
  1095. if test "$require_pcre" = "yes" ; then
  1096. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  1097. else
  1098. AC_MSG_NOTICE([disabling PCRE (optional)])
  1099. fi
  1100. fi
  1101. fi
  1102. AC_SUBST([HAVE_PCRE])
  1103. AC_SUBST([PCRE_VERSION])
  1104. AC_SUBST([PCRE_LIBS])
  1105. AC_SUBST([PCRE_CFLAGS])
  1106. #
  1107. # Host specific stuff
  1108. #
  1109. AC_MSG_CHECKING([host OS])
  1110. host_os="`uname`"
  1111. AC_MSG_RESULT([$host_os])
  1112. fd_setsize=""
  1113. DLLEXT=".so"
  1114. case $host_os in
  1115. Solaris* )
  1116. LIBS="$LIBS -lsocket -lnsl -ldl"
  1117. ;;
  1118. Linux* )
  1119. LIBS="$LIBS -ldl"
  1120. ;;
  1121. FreeBSD*)
  1122. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  1123. ;;
  1124. NetBSD*)
  1125. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  1126. ;;
  1127. CYGWIN*)
  1128. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  1129. fd_setsize="done"
  1130. DLLEXT=".dll"
  1131. ;;
  1132. esac
  1133. AC_SUBST([DLLEXT])
  1134. AC_MSG_CHECKING([for MinGW])
  1135. if test -n "`$CC --version | grep -i mingw`" ; then
  1136. AC_MSG_RESULT([yes])
  1137. CPPFLAGS="$CPPFLAGS -DMINGW"
  1138. if test -z "$fd_setsize" ; then
  1139. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  1140. fi
  1141. LIBS="$LIBS -lws2_32"
  1142. else
  1143. AC_MSG_RESULT([no])
  1144. fi
  1145. CFLAGS="$OPT_LTO $CFLAGS"
  1146. CFLAGS_AR="$OPT_LTO_AR $CFLAGS"
  1147. AC_SUBST([CFLAGS_AR])
  1148. AC_MSG_NOTICE([Configure finish])
  1149. AC_MSG_NOTICE([CPPFLAGS= $CPPFLAGS])
  1150. AC_MSG_NOTICE([CFLAGS= $CFLAGS])
  1151. AC_MSG_NOTICE([CFLAGS_AR= $CFLAGS_AR])
  1152. AC_MSG_NOTICE([LDFLAGS= $LDFLAGS])
  1153. #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
  1154. #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
  1155. AC_MSG_NOTICE([output name = $output_login, $output_char, $output_map])
  1156. ###############################################################################
  1157. AC_OUTPUT