configure.ac 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. # This file is part of Hercules.
  4. # http://herc.ws - http://github.com/HerculesWS/Hercules
  5. #
  6. # Copyright (C) 2012-2015 Hercules Dev Team
  7. # Copyright (C) Athena Dev Teams
  8. #
  9. # Hercules is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. AC_INIT(Hercules)
  22. AC_REVISION([m4_esyscmd_s([type git >/dev/null 2>&1 && git describe --always 2>/dev/null || echo '(unknown version)'])])
  23. AC_PREREQ([2.59])
  24. AC_CONFIG_SRCDIR([src/common/cbasetypes.h])
  25. AC_CONFIG_FILES([Makefile src/common/Makefile])
  26. AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile])
  27. AC_CONFIG_FILES([src/char/Makefile src/login/Makefile])
  28. AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile])
  29. AC_CONFIG_FILES([src/test/Makefile])
  30. AC_CONFIG_FILES([tools/HPMHookGen/Makefile])
  31. AC_CONFIG_FILES([tools/doxygen/Makefile])
  32. dnl AC_USE_SYSTEM_EXTENSIONS requires autoconf 2.60 or newer. Fall back to AC_GNU_SOURCE otherwise.
  33. m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
  34. [AC_USE_SYSTEM_EXTENSIONS],
  35. [AC_GNU_SOURCE]
  36. )
  37. # Root-check
  38. host_is="`uname`"
  39. case $host_os in
  40. CYGWIN*)
  41. ;;
  42. *)
  43. if type id >/dev/null 2>&1 && test -z "$CI"; then
  44. euid="`id -u`"
  45. if test "$euid" == "0"; then
  46. echo ""
  47. echo "********************************************************************************"
  48. echo '* W A R N I N G /!\ *'
  49. echo "********************************************************************************"
  50. echo "* It appears that you're planning to run Hercules with root privileges. That's *"
  51. echo "* not necessary, nor recommended, and it may open your machine to unnecessary *"
  52. echo "* security risks. You should never ever run software as root unless it *"
  53. echo "* requires the extra privileges (which Hercules does not.) *"
  54. echo "* *"
  55. echo "* More info: *"
  56. echo "* http://www.tldp.org/HOWTO/Security-HOWTO/local-security.html *"
  57. echo "* https://wiki.debian.org/sudo *"
  58. echo "* http://wiki.centos.org/TipsAndTricks/BecomingRoot *"
  59. echo "* http://fedoraproject.org/wiki/Configuring_Sudo *"
  60. echo "* https://help.ubuntu.com/community/RootSudo *"
  61. echo "* http://www.freebsdwiki.net/index.php/Root *"
  62. echo "* *"
  63. echo "* If your service provider forces (or encourages) you to run server software *"
  64. echo "* as root, please complain to them. It is a very bad idea. *"
  65. echo "********************************************************************************"
  66. echo "Execution will be paused for 60 seconds... Press Ctrl-C now if you wish to stop."
  67. for j in 1 2 3 4 5 6; do
  68. for i in 1 2 3 4 5 6 7 8 9 10; do
  69. printf "\a. "
  70. sleep 1
  71. done
  72. echo ""
  73. done
  74. echo ""
  75. echo "Resuming as root. If anything breaks, you'll get to keep the pieces."
  76. sleep 2
  77. fi
  78. fi
  79. ;;
  80. esac
  81. #
  82. # Memory managers
  83. #
  84. AC_ARG_ENABLE(
  85. [manager],
  86. AC_HELP_STRING(
  87. [--enable-manager=ARG],
  88. [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
  89. ),
  90. [
  91. enable_manager="$enableval"
  92. case $enableval in
  93. "no");;
  94. "builtin");;
  95. "memwatch");;
  96. "dmalloc");;
  97. "gcollect");;
  98. "bcheck");;
  99. *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
  100. esac
  101. ],
  102. [enable_manager="builtin"]
  103. )
  104. #
  105. # packetver
  106. #
  107. AC_ARG_ENABLE(
  108. [packetver],
  109. AC_HELP_STRING(
  110. [--enable-packetver=ARG],
  111. [Sets the PACKETVER define. (see src/common/mmo.h)]
  112. ),
  113. [enable_packetver="$enableval"],
  114. [enable_packetver=""]
  115. )
  116. #
  117. # packetver-RE
  118. #
  119. AC_ARG_ENABLE(
  120. [packetver-re],
  121. AC_HELP_STRING(
  122. [--enable-packetver-re],
  123. [Sets or unsets the PACKETVER_RE define - see src/common/mmo.h (currently disabled by default)]
  124. ),
  125. [
  126. enable_packetver_re="$enableval"
  127. case $enableval in
  128. "no");;
  129. "yes");;
  130. *) AC_MSG_ERROR([[invalid argument --enable-packetver-re=$enableval... stopping]]);;
  131. esac
  132. ],
  133. [enable_packetver_re="no"]
  134. )
  135. #
  136. # packetver-Zero
  137. #
  138. AC_ARG_ENABLE(
  139. [packetver-zero],
  140. AC_HELP_STRING(
  141. [--enable-packetver-zero],
  142. [Sets or unsets the PACKETVER_ZERO define - see src/common/mmo.h (currently disabled by default)]
  143. ),
  144. [
  145. enable_packetver_zero="$enableval"
  146. case $enableval in
  147. "no");;
  148. "yes");;
  149. *) AC_MSG_ERROR([[invalid argument --enable-packetver-zero=$enableval... stopping]]);;
  150. esac
  151. ],
  152. [enable_packetver_zero="no"]
  153. )
  154. #
  155. # packetver-Sak
  156. #
  157. AC_ARG_ENABLE(
  158. [packetver-sak],
  159. AC_HELP_STRING(
  160. [--enable-packetver-sak],
  161. [Sets or unsets the PACKETVER_SAK define - see src/common/mmo.h (currently disabled by default)]
  162. ),
  163. [
  164. enable_packetver_sak="$enableval"
  165. case $enableval in
  166. "no");;
  167. "yes");;
  168. *) AC_MSG_ERROR([[invalid argument --enable-packetver-sak=$enableval... stopping]]);;
  169. esac
  170. ],
  171. [enable_packetver_sak="no"]
  172. )
  173. #
  174. # packetver-Ad
  175. #
  176. AC_ARG_ENABLE(
  177. [packetver-ad],
  178. AC_HELP_STRING(
  179. [--enable-packetver-ad],
  180. [Sets or unsets the PACKETVER_AD define - see src/common/mmo.h (currently disabled by default)]
  181. ),
  182. [
  183. enable_packetver_ad="$enableval"
  184. case $enableval in
  185. "no");;
  186. "yes");;
  187. *) AC_MSG_ERROR([[invalid argument --enable-packetver-ad=$enableval... stopping]]);;
  188. esac
  189. ],
  190. [enable_packetver_ad="no"]
  191. )
  192. #
  193. # Epoll
  194. #
  195. AC_ARG_ENABLE([epoll],
  196. [AS_HELP_STRING([--enable-epoll],[use epoll(4) on Linux])],
  197. [enable_epoll=$enableval],
  198. [enable_epoll=no]
  199. )
  200. if test x$enable_epoll = xno; then
  201. have_linux_epoll=no
  202. else
  203. AC_MSG_CHECKING([for Linux epoll(4)])
  204. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  205. [
  206. #ifndef __linux__
  207. #error This is not Linux
  208. #endif
  209. #include <sys/epoll.h>
  210. ],
  211. [epoll_create1 (EPOLL_CLOEXEC);])],
  212. [have_linux_epoll=yes],
  213. [have_linux_epoll=no]
  214. )
  215. AC_MSG_RESULT([$have_linux_epoll])
  216. fi
  217. if test x$enable_epoll,$have_linux_epoll = xyes,no; then
  218. AC_MSG_ERROR([epoll support explicitly enabled but not available])
  219. fi
  220. #
  221. # Obfuscation keys
  222. #
  223. AC_ARG_WITH(
  224. [key1],
  225. AC_HELP_STRING(
  226. [--with-key1@<:@=ARG@:>@],
  227. [Set the first obfuscation key (ignored unless the other two are also specified)]
  228. ),
  229. [
  230. obfuscationkey1="$( expr "0x$withval" : '0*x*\(0x@<:@A-Fa-f0-9@:>@\{8\}\)' )"
  231. if ! expr "x$obfuscationkey1" : 'x0x@<:@A-Fa-f0-9@:>@\{8\}' >/dev/null 2>&1; then
  232. obfuscationkey1=""
  233. fi
  234. ],
  235. [
  236. obfuscationkey1=""
  237. ]
  238. )
  239. AC_ARG_WITH(
  240. [key2],
  241. AC_HELP_STRING(
  242. [--with-key2@<:@=ARG@:>@],
  243. [Set the second obfuscation key (ignored unless the other two are also specified)]
  244. ),
  245. [
  246. obfuscationkey2="$( expr "0x$withval" : '0*x*\(0x@<:@A-Fa-f0-9@:>@\{8\}\)' )"
  247. if ! expr "x$obfuscationkey2" : 'x0x@<:@A-Fa-f0-9@:>@\{8\}' >/dev/null 2>&1; then
  248. obfuscationkey2=""
  249. fi
  250. ],
  251. [
  252. obfuscationkey2=""
  253. ]
  254. )
  255. AC_ARG_WITH(
  256. [key3],
  257. AC_HELP_STRING(
  258. [--with-key3@<:@=ARG@:>@],
  259. [Set the third obfuscation key (ignored unless the other two are also specified)]
  260. ),
  261. [
  262. obfuscationkey3="$( expr "0x$withval" : '0*x*\(0x@<:@A-Fa-f0-9@:>@\{8\}\)' )"
  263. if ! expr "x$obfuscationkey3" : 'x0x@<:@A-Fa-f0-9@:>@\{8\}' >/dev/null 2>&1; then
  264. obfuscationkey3=""
  265. fi
  266. ],
  267. [
  268. obfuscationkey3=""
  269. ]
  270. )
  271. #
  272. # debug
  273. #
  274. AC_ARG_ENABLE(
  275. [debug],
  276. AC_HELP_STRING(
  277. [--enable-debug@<:@=ARG@:>@],
  278. [
  279. Compiles extra debug code. (yes by default)
  280. (available options: yes, no, gdb)
  281. ]
  282. ),
  283. [
  284. enable_debug="$enableval"
  285. case $enableval in
  286. "no");;
  287. "yes");;
  288. "gdb");;
  289. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
  290. esac
  291. ],
  292. [enable_debug="yes"]
  293. )
  294. #
  295. # Buildbot
  296. #
  297. AC_ARG_ENABLE(
  298. [buildbot],
  299. AC_HELP_STRING(
  300. [--enable-buildbot@<:@=ARG@:>@],
  301. [(available options: yes, no)]
  302. ),
  303. [
  304. enable_buildbot="$enableval"
  305. case $enableval in
  306. "no");;
  307. "yes");;
  308. *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);;
  309. esac
  310. ],
  311. [enable_buildbot="no"]
  312. )
  313. #
  314. # RDTSC as Tick Source
  315. #
  316. AC_ARG_ENABLE(
  317. [rdtsc],
  318. AC_HELP_STRING(
  319. [--enable-rdtsc],
  320. [
  321. Uses rdtsc as timing source (disabled by default)
  322. Enable it when you've timing issues.
  323. (For example: in conjunction with XEN or Other Virtualization mechanisms)
  324. Note:
  325. Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
  326. (On most modern Dedicated Servers cpufreq is preconfigured, see your distribution's
  327. manual how to disable it).
  328. Furthermore, If your CPU has built-in CPU-Frequency scaling features (such as Intel's
  329. SpeedStep(R)), do not enable this option. Recent CPUs (Intel Core or newer) guarantee
  330. a fixed increment rate for their TSC, so it should be safe to use, but please doublecheck
  331. the documentation of both your CPU and OS before enabling this option.
  332. ]
  333. ),
  334. [
  335. enable_rdtsc=1
  336. ],
  337. [enable_rdtsc=0]
  338. )
  339. #
  340. # Profiler
  341. #
  342. AC_ARG_ENABLE(
  343. [profiler],
  344. AC_HELP_STRING(
  345. [--enable-profiler=ARG],
  346. [Profilers: no, gprof (disabled by default)]
  347. ),
  348. [
  349. enable_profiler="$enableval"
  350. case $enableval in
  351. "no");;
  352. "gprof");;
  353. *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
  354. esac
  355. ],
  356. [enable_profiler="no"]
  357. )
  358. #
  359. # 64bit
  360. #
  361. AC_ARG_ENABLE(
  362. [64bit],
  363. AC_HELP_STRING(
  364. [--disable-64bit],
  365. [
  366. Enforce 32bit output on x86_64 systems.
  367. ]
  368. ),
  369. [
  370. enable_64bit="$enableval"
  371. case $enableval in
  372. "no");;
  373. "yes");;
  374. *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);;
  375. esac
  376. ],
  377. [enable_64bit="yes"]
  378. )
  379. #
  380. # LTO
  381. #
  382. AC_ARG_ENABLE(
  383. [lto],
  384. AC_HELP_STRING(
  385. [--enable-lto],
  386. [
  387. Enables or Disables Linktime Code Optimization (LTO is disabled by default)
  388. ]
  389. ),
  390. [
  391. enable_lto="$enableval"
  392. case $enableval in
  393. "no");;
  394. "yes");;
  395. *) AC_MSG_ERROR([[invalid argument --enable-lto=$enableval... stopping]]);;
  396. esac
  397. ],
  398. [enable_lto="no"]
  399. )
  400. #
  401. # static linking
  402. #
  403. AC_ARG_ENABLE(
  404. [static],
  405. AC_HELP_STRING(
  406. [--enable-static],
  407. [
  408. Enables or Disables Statick Linking (STATIC is disabled by default)
  409. ]
  410. ),
  411. [
  412. enable_static="$enableval"
  413. case $enableval in
  414. "no");;
  415. "yes");;
  416. *) AC_MSG_ERROR([[invalid argument --enable-static=$enableval... stopping]]);;
  417. esac
  418. ],
  419. [enable_static="no"]
  420. )
  421. #
  422. # adress sanitize
  423. #
  424. AC_ARG_ENABLE(
  425. [sanitize],
  426. AC_HELP_STRING(
  427. [--enable-sanitize@<:@=ARG@:>@],
  428. [
  429. Enables sanitizer. (disabled by default)
  430. (available options: yes, no, full)
  431. ]
  432. ),
  433. [
  434. enable_sanitize="$enableval"
  435. case $enableval in
  436. "no");;
  437. "yes");;
  438. "full");;
  439. *) AC_MSG_ERROR([[invalid argument --enable-sanitize=$enableval... stopping]]);;
  440. esac
  441. ],
  442. [enable_sanitize="no"]
  443. )
  444. #
  445. # -Werror compiler flag
  446. # It's not always possible (if at all) to pass -Werror in the CFLAGS, since
  447. # autoconf often generates test-code that produces warnings.
  448. # Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734104
  449. #
  450. AC_ARG_ENABLE(
  451. [Werror],
  452. AC_HELP_STRING(
  453. [--enable-Werror],
  454. [
  455. Enables -Werror in the compiler flags. (disabled by default)
  456. ]
  457. ),
  458. [
  459. enable_Werror="$enableval"
  460. case $enableval in
  461. "no");;
  462. "yes");;
  463. *) AC_MSG_ERROR([[invalid argument --enable-Werror=$enableval... stopping]]);;
  464. esac
  465. ],
  466. [enable_Werror="no"]
  467. )
  468. #
  469. # Renewal
  470. #
  471. AC_ARG_ENABLE(
  472. [renewal],
  473. AC_HELP_STRING(
  474. [--disable-renewal],
  475. [
  476. Disable Ragnarok Renewal support (override settings in src/config/renewal.h)
  477. ]
  478. ),
  479. [
  480. enable_renewal="$enableval"
  481. case $enableval in
  482. "no");;
  483. "yes");;
  484. *) AC_MSG_ERROR([[invalid argument --enable-renewal=$enableval... stopping]]);;
  485. esac
  486. ],
  487. [enable_renewal="yes"]
  488. )
  489. #
  490. # Optionally set the max number of network conenctions
  491. # the core will be support
  492. #
  493. AC_ARG_WITH(
  494. [maxconn],
  495. AC_HELP_STRING(
  496. [--with-maxconn@<:@=ARG@:>@],
  497. [optionally set the maximum connections the core can handle (default: 16384) NOT USED YET - EXPERIMENTAL]
  498. ),
  499. [
  500. if test "$withval" == "no"; then
  501. CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
  502. else
  503. if ! test "$withval" -ge 0 -o "$withval" -lt 0 2>&- ; then
  504. AC_MSG_ERROR([Invalid argument --with-maxconn=$withval ... stopping])
  505. else
  506. CPPFLAGS="$CPPFLAGS -DMAXCONN=$withval"
  507. fi
  508. fi
  509. ],
  510. [
  511. CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
  512. ]
  513. )
  514. #
  515. # Optionally specify the path to mysql_config
  516. #
  517. AC_ARG_WITH(
  518. [mysql],
  519. AC_HELP_STRING(
  520. [--with-mysql@<:@=ARG@:>@],
  521. [optionally specify the path to the mysql_config executable]
  522. ),
  523. [
  524. if test "$withval" != "no" ; then
  525. if test ! -x "$withval" ; then
  526. AC_MSG_ERROR([$withval is not an executable file])
  527. fi
  528. MYSQL_CONFIG_HOME="$withval"
  529. fi
  530. ]
  531. )
  532. #
  533. # Manual MYSQL_CFLAGS (optional)
  534. #
  535. AC_ARG_WITH(
  536. [MYSQL_CFLAGS],
  537. AC_HELP_STRING(
  538. [--with-MYSQL_CFLAGS=ARG],
  539. [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
  540. ),
  541. [
  542. manual_MYSQL_CFLAGS="yes"
  543. MYSQL_CFLAGS="$withval"
  544. ],
  545. [manual_MYSQL_CFLAGS="no"]
  546. )
  547. #
  548. # Manual MYSQL_LIBS (optional)
  549. #
  550. AC_ARG_WITH(
  551. [MYSQL_LIBS],
  552. AC_HELP_STRING(
  553. [--with-MYSQL_LIBS=ARG],
  554. [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
  555. ),
  556. [
  557. manual_MYSQL_LIBS="yes"
  558. MYSQL_LIBS="$withval"
  559. ],
  560. [manual_MYSQL_LIBS="no"]
  561. )
  562. ###############################################################################
  563. # Check for programs and types.
  564. #
  565. AC_PROG_MAKE_SET
  566. AC_PROG_CC
  567. AC_PROG_CPP
  568. AC_PATH_PROG(AR, ar)
  569. AC_LANG([C])
  570. # -Wcast-qual use for check wrong casts. It cant be added by default, because some casts must be wrong.
  571. # -Wconversion warning: conversion to 'long unsigned int' from 'int' may change the sign of the result
  572. # -Wfloat-equal comparing floating point with == or != is unsafe
  573. # -Wunsuffixed-float-constants float issues
  574. # -Wpedantic different pedantic checks. Not all can be fixed in nice way.
  575. # -Wtraditional-conversion some conversion issues
  576. # -Wunsafe-loop-optimizations possible optimisation issues
  577. # -Wunused-parameter -Wunused-but-set-parameter unused parameters
  578. # -Wunused-macros unused macro warnings, but it also enable unused parameters
  579. # -Wstrict-prototypes show warning in grammar.y
  580. # -wdiscarded-qualifiers show different const removal
  581. # attributes suggestion
  582. # -Wsuggest-attribute=const -Wsuggest-attribute=format -Wsuggest-attribute=pure
  583. # flags what can be used but now return no warnings:
  584. # -Wchkp -Wdisabled-optimization
  585. # -Werror-implicit-function-declaration -Wtrampolines
  586. # -Wjump-misses-init
  587. AC_MSG_CHECKING([whether $CC supports -std=c11])
  588. OLD_CFLAGS="$CFLAGS"
  589. CFLAGS="$CFLAGS -std=c11"
  590. AC_COMPILE_IFELSE(
  591. [AC_LANG_SOURCE([int foo;])],
  592. [
  593. AC_MSG_RESULT([yes])
  594. ],
  595. [
  596. AC_MSG_RESULT([no])
  597. AC_MSG_CHECKING([whether $CC supports -std=c1x])
  598. CFLAGS="$OLD_CFLAGS -std=c1x"
  599. AC_COMPILE_IFELSE(
  600. [AC_LANG_SOURCE([int foo;])],
  601. [
  602. AC_MSG_RESULT([yes])
  603. ],
  604. [
  605. AC_MSG_RESULT([no, falling back to -std=c99])
  606. CFLAGS="$OLD_CFLAGS -std=c99"
  607. ]
  608. )
  609. ],
  610. [
  611. AC_MSG_RESULT([guessing no])
  612. CFLAGS="$OLD_CFLAGS -std=c99"
  613. ]
  614. )
  615. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wextra -Wno-sign-compare"
  616. CPPFLAGS="$CPPFLAGS -I../common"
  617. LDFLAGS="$LDFLAGS"
  618. # Add /usr/local to the library and header search path, where appropriate
  619. case `uname` in
  620. Darwin*|*BSD*)
  621. if test -d /usr/local/include ; then
  622. CPPFLAGS="$CPPFLAGS -I/usr/local/include"
  623. fi
  624. if test -d /usr/local/lib ; then
  625. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  626. fi
  627. ;;
  628. esac
  629. AC_C_BIGENDIAN(
  630. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  631. ,
  632. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  633. )
  634. if test "$enable_64bit" = "no" ; then
  635. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  636. pointers_fit_in_ints="no"
  637. AC_COMPILE_IFELSE(
  638. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  639. [pointers_fit_in_ints="yes"],
  640. []
  641. )
  642. if test "$pointers_fit_in_ints" = "no" ; then
  643. CFLAGS="$CFLAGS -m32"
  644. LDFLAGS="$LDFLAGS -m32"
  645. AC_COMPILE_IFELSE(
  646. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  647. [pointers_fit_in_ints="yes (with -m32)"],
  648. []
  649. )
  650. fi
  651. AC_MSG_RESULT($pointers_fit_in_ints)
  652. if test "$pointers_fit_in_ints" = "no" ; then
  653. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  654. fi
  655. fi
  656. #
  657. # check if we're producing 32bit code - so well produce binarys for at least i686 (speedup: cmovs, and cmpchg8 support)
  658. #
  659. AC_MSG_CHECKING([whether $CC produces 32bit code])
  660. AC_RUN_IFELSE(
  661. [AC_LANG_SOURCE([
  662. int main(int argc, char **argv){
  663. if(sizeof(void*) == 4) return 0;
  664. else return 1;
  665. }
  666. ])],
  667. [
  668. AC_MSG_RESULT([yes])
  669. AC_MSG_CHECKING([whether $CC supports -march=i686 (and we can run it)])
  670. OLD_CFLAGS="$CFLAGS"
  671. OLD_LDFLAGS="$LDFLAGS"
  672. CFLAGS="$CFLAGS -march=i686"
  673. LDFLAGS="$LDFLAGS -march=i686"
  674. AC_RUN_IFELSE(
  675. [AC_LANG_SOURCE([
  676. int main(int argc, char **argv) { return 0; }
  677. ])],
  678. [
  679. AC_MSG_RESULT([yes])
  680. ],
  681. [
  682. AC_MSG_RESULT([no])
  683. CFLAGS="$OLD_CFLAGS"
  684. LDFLAGS="$OLD_LDFLAGS"
  685. ],
  686. [
  687. AC_MSG_RESULT([guessing no])
  688. CFLAGS="$OLD_CFLAGS"
  689. LDFLAGS="$OLD_LDFLAGS"
  690. ]
  691. )
  692. ],
  693. [
  694. AC_MSG_RESULT([no])
  695. ],
  696. [
  697. AC_MSG_RESULT([guessing no])
  698. ]
  699. )
  700. #
  701. # Check if CC supports __thread attribute (Thread Local Storage)
  702. # (Usually our OSX friends 're lacking support of it in older llvm versions ..)
  703. #
  704. AC_MSG_CHECKING([whether $CC supports __thread specifier (TLS)])
  705. AC_RUN_IFELSE(
  706. [AC_LANG_SOURCE([
  707. __thread int g_Test = -1;
  708. int main(int argc, char **argv){
  709. g_Test = 0;
  710. return g_Test;
  711. }
  712. ])],
  713. [
  714. AC_MSG_RESULT([yes])
  715. CPPFLAGS="$CPPFLAGS -DHAS_TLS"
  716. ],
  717. [
  718. AC_MSG_RESULT([no])
  719. ]
  720. )
  721. #
  722. # Check if the linker supports/accepts -rdynamic
  723. # Generally only needed by the ELF linker, in order to produce backtraces.
  724. # On non-ELF platforms, some compilers (i.e. gcc < 5 and clang on OSX) are able to ignore it, others will error out.
  725. #
  726. OLD_LDFLAGS="$LDFLAGS"
  727. LDFLAGS="$LDFLAGS -rdynamic"
  728. AC_MSG_CHECKING([whether $CC accepts -rdynamic])
  729. AC_LINK_IFELSE(
  730. [AC_LANG_SOURCE([
  731. int main(int argc, char **argv)
  732. {
  733. return 0;
  734. }
  735. ])],
  736. [
  737. AC_MSG_RESULT([yes])
  738. ],
  739. [
  740. AC_MSG_RESULT([no])
  741. LDFLAGS="$OLD_LDFLAGS"
  742. ],
  743. [
  744. AC_MSG_RESULT([guessing no])
  745. ]
  746. )
  747. #
  748. # LTO Support test
  749. #
  750. if test "$enable_lto" != "no" ; then
  751. OLD_CFLAGS="$CFLAGS"
  752. CFLAGS="$CFLAGS -flto -ffat-lto-objects -Werror"
  753. OLD_LDFLAGS="$LDFLAGS"
  754. LDFLAGS="$LDFLAGS -flto -ffat-lto-objects"
  755. AC_MSG_CHECKING([whether $CC supports -flto -ffat-lto-objects])
  756. AC_RUN_IFELSE(
  757. [AC_LANG_SOURCE([
  758. int main(int argc, char **argv){
  759. (void)argc;
  760. (void)argv;
  761. return 0;
  762. }
  763. ])],
  764. [
  765. AC_MSG_RESULT([yes])
  766. CFLAGS="$OLD_CFLAGS -flto -ffat-lto-objects"
  767. LDFLAGS="$OLD_LDFLAGS -flto -ffat-lto-objects"
  768. ],
  769. [
  770. AC_MSG_RESULT([no])
  771. CFLAGS="$OLD_CFLAGS -flto"
  772. LDFLAGS="$OLD_LDFLAGS -flto"
  773. AC_MSG_CHECKING([whether $CC supports -flto])
  774. AC_RUN_IFELSE(
  775. [AC_LANG_SOURCE([
  776. int main(int argc, char **argv){
  777. (void)argc;
  778. (void)argv;
  779. return 0;
  780. }
  781. ])],
  782. [
  783. AC_MSG_RESULT([yes])
  784. ],
  785. [
  786. AC_MSG_RESULT([no])
  787. CFLAGS="$OLD_CFLAGS"
  788. LDFLAGS="$OLD_LDFLAGS"
  789. ],
  790. [
  791. AC_MSG_RESULT([guessing no])
  792. CFLAGS="$OLD_CFLAGS"
  793. LDFLAGS="$OLD_LDFLAGS"
  794. ]
  795. )
  796. ],
  797. [
  798. AC_MSG_RESULT([guessing no])
  799. CFLAGS="$OLD_CFLAGS"
  800. LDFLAGS="$OLD_LDFLAGS"
  801. ]
  802. )
  803. fi
  804. AC_DEFUN([AC_CHECK_SANITIZER_FLAG],
  805. [
  806. AC_MSG_CHECKING([whether $CC supports -fsanitize=$1])
  807. OLD_CFLAGS="$CFLAGS"
  808. CFLAGS="$CFLAGS -fsanitize=$1"
  809. OLD_LDFLAGS="$LDFLAGS"
  810. LDFLAGS="$LDFLAGS -fsanitize=$1"
  811. AC_COMPILE_IFELSE(
  812. [AC_LANG_SOURCE([int foo;])],
  813. [
  814. AC_MSG_RESULT([yes])
  815. ],
  816. [
  817. AC_MSG_RESULT([no])
  818. AC_MSG_CHECKING([whether $CC requires -fsanitize-undefined-trap-on-error for -fsanitize=$1])
  819. CFLAGS="$CFLAGS -fsanitize-undefined-trap-on-error"
  820. AC_COMPILE_IFELSE(
  821. [AC_LANG_SOURCE([int foo;])],
  822. [
  823. AC_MSG_RESULT([yes])
  824. ],
  825. [
  826. AC_MSG_RESULT([no])
  827. CFLAGS="$OLD_CFLAGS"
  828. LDFLAGS="$OLD_LDFLAGS"
  829. ]
  830. )
  831. ],
  832. [
  833. AC_MSG_RESULT([guessing no])
  834. CFLAGS="$OLD_CFLAGS"
  835. LDFLAGS="$OLD_LDFLAGS"
  836. ]
  837. )
  838. ]
  839. )
  840. AC_DEFUN([AC_CHECK_FLAG],
  841. [
  842. AC_MSG_CHECKING([whether $CC supports $1])
  843. OLD_CFLAGS="$CFLAGS"
  844. CFLAGS="$CFLAGS $1"
  845. OLD_LDFLAGS="$LDFLAGS"
  846. LDFLAGS="$LDFLAGS $1"
  847. AC_COMPILE_IFELSE(
  848. [AC_LANG_SOURCE([int foo;])],
  849. [
  850. AC_MSG_RESULT([yes])
  851. ],
  852. [
  853. AC_MSG_RESULT([no])
  854. CFLAGS="$OLD_CFLAGS"
  855. LDFLAGS="$OLD_LDFLAGS"
  856. ],
  857. [
  858. AC_MSG_RESULT([guessing no])
  859. CFLAGS="$OLD_CFLAGS"
  860. LDFLAGS="$OLD_LDFLAGS"
  861. ]
  862. )
  863. ]
  864. )
  865. #
  866. # sanitize Support test
  867. #
  868. if test "$enable_sanitize" != "no" ; then
  869. AC_CHECK_SANITIZER_FLAG(address)
  870. if test "$enable_sanitize" == "full" ; then
  871. # skipped because server have multiple issues: -fsanitize=alignment
  872. AC_CHECK_SANITIZER_FLAG(shift)
  873. AC_CHECK_SANITIZER_FLAG(integer-divide-by-zero)
  874. AC_CHECK_SANITIZER_FLAG(unreachable)
  875. AC_CHECK_SANITIZER_FLAG(vla-bound)
  876. AC_CHECK_SANITIZER_FLAG(null)
  877. AC_CHECK_SANITIZER_FLAG(return)
  878. AC_CHECK_SANITIZER_FLAG(signed-integer-overflow)
  879. AC_CHECK_SANITIZER_FLAG(bounds)
  880. AC_CHECK_SANITIZER_FLAG(bounds-strict)
  881. AC_CHECK_SANITIZER_FLAG(object-size)
  882. AC_CHECK_SANITIZER_FLAG(float-divide-by-zero)
  883. AC_CHECK_SANITIZER_FLAG(float-cast-overflow)
  884. AC_CHECK_SANITIZER_FLAG(nonnull-attribute)
  885. AC_CHECK_SANITIZER_FLAG(returns-nonnull-attribute)
  886. AC_CHECK_SANITIZER_FLAG(bool)
  887. AC_CHECK_SANITIZER_FLAG(enum)
  888. AC_CHECK_SANITIZER_FLAG(vptr)
  889. fi
  890. fi
  891. AC_DEFUN([AC_CHECK_COMPILER_WFLAG],
  892. [
  893. AC_MSG_CHECKING([whether $CC supports -W$1])
  894. OLD_CFLAGS="$CFLAGS"
  895. CFLAGS="$CFLAGS -Werror -W$1"
  896. AC_COMPILE_IFELSE(
  897. [AC_LANG_SOURCE([int foo;])],
  898. [
  899. AC_MSG_RESULT([yes])
  900. CFLAGS="$OLD_CFLAGS -W$1"
  901. # Optionally, run a test
  902. if test "x$2" != "x"; then
  903. AC_MSG_CHECKING([whether $CC can actually use -W$1])
  904. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  905. AC_COMPILE_IFELSE(
  906. [AC_LANG_SOURCE([$2])],
  907. [
  908. AC_MSG_RESULT([no])
  909. CFLAGS="$OLD_CFLAGS"
  910. ]
  911. [
  912. AC_MSG_RESULT([yes])
  913. CFLAGS="$OLD_CFLAGS -W$1"
  914. ],
  915. )
  916. fi
  917. ],
  918. [
  919. AC_MSG_RESULT([no])
  920. CFLAGS="$OLD_CFLAGS"
  921. ]
  922. )
  923. ]
  924. )
  925. AC_DEFUN([AC_CHECK_COMPILER_WNOFLAG],
  926. [
  927. AC_MSG_CHECKING([whether $CC supports -Wno-$1])
  928. OLD_CFLAGS="$CFLAGS"
  929. CFLAGS="$CFLAGS -Werror -Wno-$1"
  930. AC_COMPILE_IFELSE(
  931. [AC_LANG_SOURCE([int foo;])],
  932. [
  933. # Recent versions of gcc don't fail if -Wno-foo is not recognized
  934. # (unless there are also other warnings), so we also check for -Wfoo
  935. # which always fails if not supported
  936. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  937. AC_COMPILE_IFELSE(
  938. [AC_LANG_SOURCE([int foo;])],
  939. [
  940. AC_MSG_RESULT([yes])
  941. CFLAGS="$OLD_CFLAGS -Wno-$1"
  942. # Optionally, run a test
  943. if test "x$2" != "x"; then
  944. AC_MSG_CHECKING([whether $CC can actually use -Wno-$1])
  945. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  946. AC_COMPILE_IFELSE(
  947. [AC_LANG_SOURCE([$2])],
  948. [
  949. AC_MSG_RESULT([not needed but enabled])
  950. CFLAGS="$OLD_CFLAGS"
  951. ],
  952. [
  953. CFLAGS="$OLD_CFLAGS -Werror -Wno-$1"
  954. AC_COMPILE_IFELSE(
  955. [AC_LANG_SOURCE([$2])],
  956. [
  957. AC_MSG_RESULT([yes])
  958. CFLAGS="$OLD_CFLAGS -Wno-$1"
  959. ],
  960. [
  961. AC_MSG_RESULT([no])
  962. CFLAGS="$OLD_CFLAGS"
  963. ]
  964. )
  965. ]
  966. )
  967. fi
  968. ],
  969. [
  970. AC_MSG_RESULT([no])
  971. CFLAGS="$OLD_CFLAGS"
  972. ]
  973. )
  974. ],
  975. [
  976. AC_MSG_RESULT([no])
  977. CFLAGS="$OLD_CFLAGS"
  978. ]
  979. )
  980. ]
  981. )
  982. AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
  983. AC_CHECK_COMPILER_WNOFLAG(clobbered)
  984. AC_CHECK_COMPILER_WFLAG(empty-body)
  985. AC_CHECK_COMPILER_WFLAG(newline-eof)
  986. AC_CHECK_COMPILER_WFLAG(int-conversion)
  987. AC_CHECK_COMPILER_WFLAG(init-self)
  988. AC_CHECK_COMPILER_WFLAG(pointer-arith)
  989. AC_CHECK_COMPILER_WFLAG(switch-bool)
  990. AC_CHECK_COMPILER_WFLAG(enum-conversion)
  991. AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
  992. AC_CHECK_COMPILER_WFLAG(constant-conversion)
  993. AC_CHECK_COMPILER_WFLAG(bool-conversion)
  994. AC_CHECK_COMPILER_WFLAG(format-security)
  995. AC_CHECK_COMPILER_WFLAG(format)
  996. AC_CHECK_COMPILER_WFLAG(format-signedness)
  997. AC_CHECK_COMPILER_WFLAG(format-y2k)
  998. AC_CHECK_COMPILER_WFLAG(missing-include-dirs)
  999. AC_CHECK_COMPILER_WFLAG(suggest-attribute=noreturn)
  1000. AC_CHECK_COMPILER_WFLAG(undef)
  1001. #AC_CHECK_COMPILER_WFLAG(cast-align)
  1002. #AC_CHECK_COMPILER_WFLAG(logical-op) # some useless warnings
  1003. AC_CHECK_COMPILER_WFLAG(nested-externs)
  1004. AC_CHECK_COMPILER_WFLAG(old-style-definition)
  1005. AC_CHECK_COMPILER_WFLAG(overlength-strings)
  1006. AC_CHECK_COMPILER_WFLAG(redundant-decls)
  1007. AC_CHECK_COMPILER_WFLAG(cast-qual)
  1008. AC_CHECK_COMPILER_WFLAG(misleading-indentation)
  1009. AC_CHECK_COMPILER_WFLAG(null-dereference)
  1010. AC_CHECK_COMPILER_WFLAG(vla)
  1011. AC_CHECK_COMPILER_WNOFLAG(format-nonliteral)
  1012. AC_CHECK_COMPILER_WNOFLAG(switch)
  1013. AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
  1014. AC_CHECK_COMPILER_WNOFLAG(suggest-attribute=format)
  1015. # Certain versions of gcc make -Wshadow completely useless by making it flood
  1016. # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
  1017. # Let's check if we can really use it
  1018. SAVED_OLD_CFLAGS="$CFLAGS"
  1019. AC_CHECK_COMPILER_WFLAG(shadow)
  1020. if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
  1021. AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
  1022. NEW_CFLAGS="$CFLAGS"
  1023. CFLAGS="$CFLAGS -Werror -Wshadow"
  1024. AC_COMPILE_IFELSE(
  1025. [AC_LANG_SOURCE([
  1026. int foo(void) {
  1027. return 0;
  1028. }
  1029. int bar(void) {
  1030. int foo = 0;
  1031. return foo + 1;
  1032. }
  1033. ])],
  1034. [
  1035. AC_MSG_RESULT([yes])
  1036. CFLAGS="$NEW_CFLAGS"
  1037. ],
  1038. [
  1039. AC_MSG_RESULT([no])
  1040. CFLAGS="$SAVED_OLD_CFLAGS"
  1041. ]
  1042. )
  1043. fi
  1044. AC_MSG_CHECKING([whether $CC supports -fPIC])
  1045. OLD_CFLAGS="$CFLAGS"
  1046. CFLAGS="$CFLAGS -fPIC"
  1047. AC_COMPILE_IFELSE(
  1048. [AC_LANG_SOURCE([int foo;])],
  1049. [
  1050. AC_MSG_RESULT([yes])
  1051. SOFLAGS="$SOFLAGS -fPIC"
  1052. ],
  1053. [
  1054. AC_MSG_RESULT([no])
  1055. ]
  1056. )
  1057. CFLAGS="$OLD_CFLAGS"
  1058. #
  1059. # option for shared objects
  1060. #
  1061. AC_MSG_CHECKING([how to make shared objects])
  1062. OLD_CFLAGS="$CFLAGS"
  1063. compiler_shared_objects=""
  1064. compiler_supports_shared_objects="no"
  1065. my_shared_test_flags="$CFLAGS $SOFLAGS"
  1066. # default
  1067. CFLAGS="$my_shared_test_flags -shared"
  1068. AC_LINK_IFELSE(
  1069. [AC_LANG_SOURCE([
  1070. int bar = 0;
  1071. int foo(void)
  1072. {
  1073. return bar;
  1074. }
  1075. ])],
  1076. [
  1077. compiler_shared_objects="-shared"
  1078. compiler_supports_shared_objects="yes"
  1079. ]
  1080. )
  1081. # BeOS specific
  1082. CFLAGS="$my_shared_test_flags -nostart"
  1083. AC_LINK_IFELSE(
  1084. [AC_LANG_SOURCE([
  1085. int bar = 0;
  1086. int foo(void)
  1087. {
  1088. return bar;
  1089. }
  1090. ])],
  1091. [
  1092. compiler_shared_objects="-nostart"
  1093. compiler_supports_shared_objects="yes"
  1094. ]
  1095. )
  1096. CFLAGS="$OLD_CFLAGS"
  1097. if test "$compiler_supports_shared_objects" = "no" ; then
  1098. AC_MSG_RESULT([not supported])
  1099. AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
  1100. WITH_PLUGINS="no"
  1101. else
  1102. AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
  1103. SOFLAGS="$SOFLAGS $compiler_shared_objects"
  1104. WITH_PLUGINS="yes"
  1105. #
  1106. # On certain platforms, undefined references on shared libraries won't be checked
  1107. # unless explicitly required with the --no-undefined linker option
  1108. #
  1109. AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
  1110. OLD_CFLAGS="$CFLAGS"
  1111. CFLAGS="$SOFLAGS"
  1112. AC_LINK_IFELSE(
  1113. [AC_LANG_SOURCE([
  1114. void foo(void) {
  1115. foobar();
  1116. }
  1117. ])],
  1118. [
  1119. CFLAGS="$SOFLAGS -Wl,--no-undefined"
  1120. AC_LINK_IFELSE(
  1121. [AC_LANG_SOURCE([
  1122. int bar = 0;
  1123. int foo(void) {
  1124. return bar;
  1125. }
  1126. ])],
  1127. [
  1128. AC_MSG_RESULT([yes])
  1129. SOFLAGS="$SOFLAGS -Wl,--no-undefined"
  1130. ],
  1131. [
  1132. AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
  1133. ]
  1134. )
  1135. ],
  1136. [
  1137. AC_MSG_RESULT([no])
  1138. ]
  1139. )
  1140. CFLAGS="$OLD_CFLAGS"
  1141. fi
  1142. my_shared_test_flags=""
  1143. AC_SUBST([WITH_PLUGINS])
  1144. AC_SUBST([SOFLAGS])
  1145. #
  1146. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  1147. #
  1148. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  1149. OLD_CFLAGS="$CFLAGS"
  1150. CFLAGS="$CFLAGS -fno-strict-aliasing"
  1151. AC_COMPILE_IFELSE(
  1152. [AC_LANG_SOURCE([int foo;])],
  1153. [AC_MSG_RESULT([yes])],
  1154. [
  1155. AC_MSG_RESULT([no])
  1156. CFLAGS="$OLD_CFLAGS"
  1157. ]
  1158. )
  1159. ###############################################################################
  1160. # Check for libraries and header files.
  1161. #
  1162. #
  1163. # setrlimit - used to set the socket limit
  1164. #
  1165. AC_CHECK_FUNC([setrlimit],[CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT"])
  1166. #
  1167. # strnlen - string length with upper scan bound
  1168. #
  1169. AC_CHECK_FUNC([strnlen],[CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN"])
  1170. # libconfig
  1171. AC_CHECK_FUNCS([uselocale])
  1172. AC_CHECK_FUNCS([newlocale])
  1173. AC_CHECK_FUNCS([freelocale])
  1174. AC_CHECK_HEADERS([xlocale.h])
  1175. #
  1176. # Memory manager
  1177. #
  1178. case $enable_manager in
  1179. "no")
  1180. CPPFLAGS="$CPPFLAGS -DNO_MEMMGR"
  1181. ;;
  1182. "builtin")
  1183. # enabled by default
  1184. ;;
  1185. "memwatch")
  1186. CPPFLAGS="$CPPFLAGS -DMEMWATCH"
  1187. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  1188. ;;
  1189. "dmalloc")
  1190. CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  1191. LIBS="$LIBS -ldmalloc"
  1192. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  1193. ;;
  1194. "gcollect")
  1195. CPPFLAGS="$CPPFLAGS -DGCOLLECT"
  1196. LIBS="$LIBS -lgc"
  1197. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  1198. ;;
  1199. "bcheck")
  1200. CPPFLAGS="$CPPFLAGS -DBCHECK"
  1201. ;;
  1202. esac
  1203. #
  1204. # Packetver
  1205. #
  1206. if test -n "$enable_packetver" ; then
  1207. CPPFLAGS="$CPPFLAGS -DPACKETVER=$enable_packetver"
  1208. fi
  1209. #
  1210. # Packetver-RE
  1211. #
  1212. case $enable_packetver_re in
  1213. "yes")
  1214. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_RE"
  1215. ;;
  1216. "no")
  1217. # default value
  1218. ;;
  1219. esac
  1220. #
  1221. # Packetver-Zero
  1222. #
  1223. case $enable_packetver_zero in
  1224. "yes")
  1225. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_ZERO"
  1226. ;;
  1227. "no")
  1228. # default value
  1229. ;;
  1230. esac
  1231. #
  1232. # Packetver-Sak
  1233. #
  1234. case $enable_packetver_sak in
  1235. "yes")
  1236. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_SAK"
  1237. ;;
  1238. "no")
  1239. # default value
  1240. ;;
  1241. esac
  1242. #
  1243. # Packetver-ad
  1244. #
  1245. case $enable_packetver_ad in
  1246. "yes")
  1247. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_AD"
  1248. ;;
  1249. "no")
  1250. # default value
  1251. ;;
  1252. esac
  1253. #
  1254. # Epoll
  1255. #
  1256. case $have_linux_epoll in
  1257. "yes")
  1258. CPPFLAGS="$CPPFLAGS -DSOCKET_EPOLL"
  1259. ;;
  1260. "no")
  1261. # default value
  1262. ;;
  1263. esac
  1264. #
  1265. # Obfuscation keys
  1266. #
  1267. if test -n "$obfuscationkey1" -a -n "$obfuscationkey2" -a -n "$obfuscationkey3"; then
  1268. CPPFLAGS="$CPPFLAGS -DOBFUSCATIONKEY1=$obfuscationkey1 -DOBFUSCATIONKEY2=$obfuscationkey2 -DOBFUSCATIONKEY3=$obfuscationkey3"
  1269. fi
  1270. #
  1271. # Debug
  1272. #
  1273. case $enable_debug in
  1274. "no")
  1275. # default value
  1276. # CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
  1277. ;;
  1278. "yes")
  1279. CFLAGS="$CFLAGS -g"
  1280. CPPFLAGS="$CPPFLAGS -DDEBUG"
  1281. AC_CHECK_FLAG(-fno-omit-frame-pointer)
  1282. ;;
  1283. "gdb")
  1284. CFLAGS="$CFLAGS -ggdb"
  1285. CPPFLAGS="$CPPFLAGS -DDEBUG"
  1286. AC_CHECK_FLAG(-fno-omit-frame-pointer)
  1287. ;;
  1288. esac
  1289. #
  1290. # Buildbot
  1291. #
  1292. case $enable_buildbot in
  1293. "no")
  1294. # default value
  1295. ;;
  1296. "yes")
  1297. CPPFLAGS="$CPPFLAGS -DBUILDBOT"
  1298. ;;
  1299. esac
  1300. #
  1301. # RDTSC
  1302. #
  1303. case $enable_rdtsc in
  1304. 0)
  1305. #default value
  1306. ;;
  1307. 1)
  1308. CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
  1309. ;;
  1310. esac
  1311. #
  1312. # Profiler
  1313. #
  1314. case $enable_profiler in
  1315. "no")
  1316. # default value
  1317. ;;
  1318. "gprof")
  1319. CFLAGS="$CFLAGS -pg"
  1320. LDFLAGS="$LDFLAGS -pg"
  1321. ;;
  1322. esac
  1323. #
  1324. # Renewal
  1325. #
  1326. case $enable_renewal in
  1327. "no")
  1328. CPPFLAGS="$CPPFLAGS -DDISABLE_RENEWAL"
  1329. ;;
  1330. "yes")
  1331. # default value
  1332. ;;
  1333. esac
  1334. AC_CHECK_FLAG(-fno-var-tracking)
  1335. #
  1336. # Host specific stuff
  1337. #
  1338. AC_MSG_CHECKING([host OS])
  1339. host_os="`uname`"
  1340. AC_MSG_RESULT([$host_os])
  1341. fd_setsize=""
  1342. DLLEXT=".so"
  1343. case $host_os in
  1344. Solaris* )
  1345. LIBS="$LIBS -lsocket -lnsl -ldl"
  1346. ;;
  1347. Linux* )
  1348. LIBS="$LIBS -ldl"
  1349. ;;
  1350. FreeBSD*)
  1351. CPPFLAGS="$CPPFLAGS -D__FREEBSD__ -fvisibility=hidden"
  1352. ;;
  1353. NetBSD*)
  1354. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  1355. ;;
  1356. CYGWIN*)
  1357. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  1358. fd_setsize="done"
  1359. DLLEXT=".dll"
  1360. ;;
  1361. Darwin*)
  1362. DLLEXT=".dylib"
  1363. ;;
  1364. esac
  1365. AC_SUBST([DLLEXT])
  1366. AC_MSG_CHECKING([for MinGW])
  1367. if test -n "`$CC --version 2>/dev/null | grep -i mingw`" ; then
  1368. AC_MSG_RESULT([yes])
  1369. CPPFLAGS="$CPPFLAGS -DMINGW"
  1370. if test -z "$fd_setsize" ; then
  1371. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  1372. fi
  1373. LIBS="$LIBS -lws2_32"
  1374. else
  1375. AC_MSG_RESULT([no])
  1376. fi
  1377. #
  1378. # zlib library (required)
  1379. #
  1380. AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible... stopping])])
  1381. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with... stopping])])
  1382. #
  1383. # math library (required)
  1384. #
  1385. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  1386. #
  1387. # clock_gettime (optional, rt on Debian)
  1388. #
  1389. AC_SEARCH_LIBS([clock_gettime], [rt])
  1390. #
  1391. # CLOCK_MONOTONIC clock for clock_gettime
  1392. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  1393. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  1394. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  1395. # checked but some systems define them even when they do not support it
  1396. # (ref. bugreport:1003).
  1397. #
  1398. if test "$ac_cv_search_clock_gettime" != "no" ; then
  1399. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  1400. AC_RUN_IFELSE(
  1401. [AC_LANG_SOURCE([
  1402. #include <sys/time.h>
  1403. #include <time.h>
  1404. #include <unistd.h>
  1405. int main(int argc, char** argv)
  1406. {
  1407. struct timespec tval;
  1408. return clock_gettime(CLOCK_MONOTONIC, &tval);
  1409. }
  1410. ])],
  1411. [
  1412. AC_MSG_RESULT([yes])
  1413. CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
  1414. ],
  1415. [
  1416. # either it failed to compile (CLOCK_MONOTONIC undefined)
  1417. # or clock_gettime has returned a non-zero value
  1418. AC_MSG_RESULT([no])
  1419. ],
  1420. [
  1421. AC_MSG_RESULT([guessing no])
  1422. ]
  1423. )
  1424. fi
  1425. #
  1426. # pthread
  1427. #
  1428. AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1429. AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1430. AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1431. AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1432. AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1433. AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1434. AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1435. # execinfo (backtrace)
  1436. AC_CHECK_HEADERS([execinfo.h],
  1437. [
  1438. AC_SEARCH_LIBS([backtrace],
  1439. [execinfo],
  1440. [
  1441. CFLAGS="$CFLAGS -DHAVE_EXECINFO"
  1442. ],
  1443. [
  1444. ]
  1445. )
  1446. ],
  1447. [
  1448. ]
  1449. )
  1450. #
  1451. # MySQL library
  1452. #
  1453. if test -z "$MYSQL_CONFIG_HOME"; then
  1454. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  1455. fi
  1456. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  1457. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  1458. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  1459. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  1460. fi
  1461. if test "$manual_MYSQL_LIBS" = "no" ; then
  1462. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  1463. fi
  1464. else
  1465. MYSQL_VERSION="unknown"
  1466. fi
  1467. MYSQL_OLD_LIBS="$LIBS" ; LIBS="$LIBS $MYSQL_LIBS"
  1468. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  1469. AC_CHECK_FUNC([mysql_init], [HAVE_MYSQL="yes"])
  1470. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  1471. AC_MSG_CHECKING([whether my_bool is supported (MySQL)])
  1472. AC_RUN_IFELSE(
  1473. [AC_LANG_SOURCE([
  1474. #ifdef WIN32
  1475. #include "common/winapi.h" // Needed before mysql.h
  1476. #endif
  1477. #include <mysql.h>
  1478. int main(int argc, char **argv){
  1479. my_bool val = (my_bool)0;
  1480. return (int)val;
  1481. }
  1482. ])],
  1483. [
  1484. AC_MSG_RESULT([yes])
  1485. ],
  1486. [
  1487. AC_MSG_RESULT([no (converting my_bool to bool)])
  1488. MYSQL_CFLAGS="$MYSQL_CFLAGS -Dmy_bool=bool"
  1489. ]
  1490. )
  1491. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  1492. LIBS="$MYSQL_OLD_LIBS"
  1493. AC_MSG_CHECKING([MySQL library (required)])
  1494. if test "$HAVE_MYSQL" = "yes" ; then
  1495. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  1496. else
  1497. AC_MSG_RESULT([no])
  1498. AC_MSG_ERROR([MySQL not found or incompatible])
  1499. fi
  1500. AC_SUBST([HAVE_MYSQL])
  1501. AC_SUBST([MYSQL_VERSION])
  1502. AC_SUBST([MYSQL_CFLAGS])
  1503. AC_SUBST([MYSQL_LIBS])
  1504. #
  1505. # PCRE library (optional)
  1506. #
  1507. AC_MSG_CHECKING([PCRE library])
  1508. AC_CHECK_HEADER([pcre.h], [], [AC_MSG_ERROR([PCRE header not found])])
  1509. AC_SEARCH_LIBS([pcre_study], [pcre], [], AC_MSG_ERROR([PCRE not found or incompatible]))
  1510. #
  1511. # static Support test
  1512. #
  1513. if test "$enable_static" != "no" ; then
  1514. STATIC="-static"
  1515. PLUGINSTATIC="-static-libgcc"
  1516. OLD_CFLAGS="$CFLAGS"
  1517. OLD_LDFLAGS="$LDFLAGS"
  1518. OLD_LIBS="$LIBS"
  1519. CFLAGS="$OLD_CFLAGS $MYSQL_CFLAGS -static"
  1520. LDFLAGS="$OLD_LDFLAGS -static"
  1521. LIBS="$OLD_LIBS $MYSQL_LIBS"
  1522. AC_MSG_CHECKING([whether $CC supports -static])
  1523. AC_RUN_IFELSE(
  1524. [AC_LANG_SOURCE([
  1525. int main(int argc, char **argv){
  1526. return 0;
  1527. }
  1528. ])],
  1529. [
  1530. AC_MSG_RESULT([yes])
  1531. ],
  1532. [
  1533. AC_MSG_RESULT([no])
  1534. STATIC=""
  1535. ],
  1536. [
  1537. AC_MSG_RESULT([guessing no])
  1538. STATIC=""
  1539. ]
  1540. )
  1541. CFLAGS="$OLD_CFLAGS -static-libgcc"
  1542. LDFLAGS="$OLD_LDFLAGS -static-libgcc"
  1543. AC_MSG_CHECKING([whether $CC supports -static-libgcc])
  1544. AC_RUN_IFELSE(
  1545. [AC_LANG_SOURCE([
  1546. int main(int argc, char **argv){
  1547. return 0;
  1548. }
  1549. ])],
  1550. [
  1551. AC_MSG_RESULT([yes])
  1552. ],
  1553. [
  1554. AC_MSG_RESULT([no])
  1555. PLUGINSTATIC=""
  1556. ],
  1557. [
  1558. AC_MSG_RESULT([guessing no])
  1559. PLUGINSTATIC=""
  1560. ]
  1561. )
  1562. CFLAGS="$OLD_CFLAGS"
  1563. LDFLAGS="$OLD_LDFLAGS"
  1564. LIBS="$OLD_LIBS"
  1565. fi
  1566. #
  1567. # -Werror compiler flag
  1568. #
  1569. if test "$enable_Werror" != "no" ; then
  1570. OLD_CFLAGS="$CFLAGS"
  1571. CFLAGS="$CFLAGS -Werror"
  1572. AC_MSG_CHECKING([whether $CC supports -Werror])
  1573. AC_RUN_IFELSE(
  1574. [AC_LANG_SOURCE([
  1575. int main(int argc, char **argv){
  1576. return 0;
  1577. }
  1578. ])],
  1579. [
  1580. AC_MSG_RESULT([yes])
  1581. ],
  1582. [
  1583. AC_MSG_RESULT([no])
  1584. CFLAGS="$OLD_CFLAGS"
  1585. LDFLAGS="$OLD_LDFLAGS"
  1586. ],
  1587. [
  1588. AC_MSG_RESULT([guessing no])
  1589. ]
  1590. )
  1591. fi
  1592. AC_SUBST(STATIC, ${STATIC})
  1593. AC_SUBST(PLUGINSTATIC, ${PLUGINSTATIC})
  1594. #
  1595. # Doxygen, perl (for HPMHookGen)
  1596. #
  1597. AC_CHECK_PROG([HAVE_DOXYGEN],[doxygen],[yes],[no])
  1598. AC_CHECK_PROG([HAVE_PERL],[perl],[yes],[no])
  1599. #
  1600. # OpenSSL library
  1601. #
  1602. AC_MSG_CHECKING([OpenSSL library])
  1603. dnl Order matters!
  1604. if test "$PORTNAME" != "win32"; then
  1605. AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_WARN([library 'crypto' is required for OpenSSL])])
  1606. FOUND_SSL_LIB="no"
  1607. AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
  1608. AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
  1609. AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_WARN([library 'ssl' is required for OpenSSL])])
  1610. else
  1611. AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
  1612. FOUND_SSL_LIB="no"
  1613. AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
  1614. AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
  1615. AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
  1616. fi
  1617. ###############################################################################
  1618. AC_OUTPUT