configure.ac 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776
  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(format-diag)
  999. #AC_CHECK_COMPILER_WFLAG(format-truncation=2)
  1000. AC_CHECK_COMPILER_WFLAG(missing-include-dirs)
  1001. AC_CHECK_COMPILER_WFLAG(suggest-attribute=noreturn)
  1002. AC_CHECK_COMPILER_WFLAG(suggest-attribute=format)
  1003. AC_CHECK_COMPILER_WFLAG(undef)
  1004. #AC_CHECK_COMPILER_WFLAG(cast-align)
  1005. #AC_CHECK_COMPILER_WFLAG(logical-op) # some useless warnings
  1006. AC_CHECK_COMPILER_WFLAG(nested-externs)
  1007. AC_CHECK_COMPILER_WFLAG(old-style-definition)
  1008. AC_CHECK_COMPILER_WFLAG(overlength-strings)
  1009. AC_CHECK_COMPILER_WFLAG(redundant-decls)
  1010. AC_CHECK_COMPILER_WFLAG(cast-qual)
  1011. AC_CHECK_COMPILER_WFLAG(misleading-indentation)
  1012. AC_CHECK_COMPILER_WFLAG(null-dereference)
  1013. AC_CHECK_COMPILER_WFLAG(vla)
  1014. AC_CHECK_COMPILER_WNOFLAG(format-nonliteral)
  1015. AC_CHECK_COMPILER_WNOFLAG(switch)
  1016. AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
  1017. AC_CHECK_COMPILER_WNOFLAG(suggest-attribute=format)
  1018. # Certain versions of gcc make -Wshadow completely useless by making it flood
  1019. # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
  1020. # Let's check if we can really use it
  1021. SAVED_OLD_CFLAGS="$CFLAGS"
  1022. AC_CHECK_COMPILER_WFLAG(shadow)
  1023. if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
  1024. AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
  1025. NEW_CFLAGS="$CFLAGS"
  1026. CFLAGS="$CFLAGS -Werror -Wshadow"
  1027. AC_COMPILE_IFELSE(
  1028. [AC_LANG_SOURCE([
  1029. int foo(void) {
  1030. return 0;
  1031. }
  1032. int bar(void) {
  1033. int foo = 0;
  1034. return foo + 1;
  1035. }
  1036. ])],
  1037. [
  1038. AC_MSG_RESULT([yes])
  1039. CFLAGS="$NEW_CFLAGS"
  1040. ],
  1041. [
  1042. AC_MSG_RESULT([no])
  1043. CFLAGS="$SAVED_OLD_CFLAGS"
  1044. ]
  1045. )
  1046. fi
  1047. AC_MSG_CHECKING([whether $CC supports -fPIC])
  1048. OLD_CFLAGS="$CFLAGS"
  1049. CFLAGS="$CFLAGS -fPIC"
  1050. AC_COMPILE_IFELSE(
  1051. [AC_LANG_SOURCE([int foo;])],
  1052. [
  1053. AC_MSG_RESULT([yes])
  1054. SOFLAGS="$SOFLAGS -fPIC"
  1055. ],
  1056. [
  1057. AC_MSG_RESULT([no])
  1058. ]
  1059. )
  1060. CFLAGS="$OLD_CFLAGS"
  1061. #
  1062. # option for shared objects
  1063. #
  1064. AC_MSG_CHECKING([how to make shared objects])
  1065. OLD_CFLAGS="$CFLAGS"
  1066. compiler_shared_objects=""
  1067. compiler_supports_shared_objects="no"
  1068. my_shared_test_flags="$CFLAGS $SOFLAGS"
  1069. # default
  1070. CFLAGS="$my_shared_test_flags -shared"
  1071. AC_LINK_IFELSE(
  1072. [AC_LANG_SOURCE([
  1073. int bar = 0;
  1074. int foo(void)
  1075. {
  1076. return bar;
  1077. }
  1078. ])],
  1079. [
  1080. compiler_shared_objects="-shared"
  1081. compiler_supports_shared_objects="yes"
  1082. ]
  1083. )
  1084. # BeOS specific
  1085. CFLAGS="$my_shared_test_flags -nostart"
  1086. AC_LINK_IFELSE(
  1087. [AC_LANG_SOURCE([
  1088. int bar = 0;
  1089. int foo(void)
  1090. {
  1091. return bar;
  1092. }
  1093. ])],
  1094. [
  1095. compiler_shared_objects="-nostart"
  1096. compiler_supports_shared_objects="yes"
  1097. ]
  1098. )
  1099. CFLAGS="$OLD_CFLAGS"
  1100. if test "$compiler_supports_shared_objects" = "no" ; then
  1101. AC_MSG_RESULT([not supported])
  1102. AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
  1103. WITH_PLUGINS="no"
  1104. else
  1105. AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
  1106. SOFLAGS="$SOFLAGS $compiler_shared_objects"
  1107. WITH_PLUGINS="yes"
  1108. #
  1109. # On certain platforms, undefined references on shared libraries won't be checked
  1110. # unless explicitly required with the --no-undefined linker option
  1111. #
  1112. AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
  1113. OLD_CFLAGS="$CFLAGS"
  1114. CFLAGS="$SOFLAGS"
  1115. AC_LINK_IFELSE(
  1116. [AC_LANG_SOURCE([
  1117. void foo(void) {
  1118. foobar();
  1119. }
  1120. ])],
  1121. [
  1122. CFLAGS="$SOFLAGS -Wl,--no-undefined"
  1123. AC_LINK_IFELSE(
  1124. [AC_LANG_SOURCE([
  1125. int bar = 0;
  1126. int foo(void) {
  1127. return bar;
  1128. }
  1129. ])],
  1130. [
  1131. AC_MSG_RESULT([yes])
  1132. SOFLAGS="$SOFLAGS -Wl,--no-undefined"
  1133. ],
  1134. [
  1135. AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
  1136. ]
  1137. )
  1138. ],
  1139. [
  1140. AC_MSG_RESULT([no])
  1141. ]
  1142. )
  1143. CFLAGS="$OLD_CFLAGS"
  1144. fi
  1145. my_shared_test_flags=""
  1146. AC_SUBST([WITH_PLUGINS])
  1147. AC_SUBST([SOFLAGS])
  1148. #
  1149. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  1150. #
  1151. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  1152. OLD_CFLAGS="$CFLAGS"
  1153. CFLAGS="$CFLAGS -fno-strict-aliasing"
  1154. AC_COMPILE_IFELSE(
  1155. [AC_LANG_SOURCE([int foo;])],
  1156. [AC_MSG_RESULT([yes])],
  1157. [
  1158. AC_MSG_RESULT([no])
  1159. CFLAGS="$OLD_CFLAGS"
  1160. ]
  1161. )
  1162. ###############################################################################
  1163. # Check for libraries and header files.
  1164. #
  1165. #
  1166. # setrlimit - used to set the socket limit
  1167. #
  1168. AC_CHECK_FUNC([setrlimit],[CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT"])
  1169. #
  1170. # strnlen - string length with upper scan bound
  1171. #
  1172. AC_CHECK_FUNC([strnlen],[CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN"])
  1173. # libconfig
  1174. AC_CHECK_FUNCS([uselocale])
  1175. AC_CHECK_FUNCS([newlocale])
  1176. AC_CHECK_FUNCS([freelocale])
  1177. AC_CHECK_HEADERS([xlocale.h])
  1178. #
  1179. # Memory manager
  1180. #
  1181. case $enable_manager in
  1182. "no")
  1183. CPPFLAGS="$CPPFLAGS -DNO_MEMMGR"
  1184. ;;
  1185. "builtin")
  1186. # enabled by default
  1187. ;;
  1188. "memwatch")
  1189. CPPFLAGS="$CPPFLAGS -DMEMWATCH"
  1190. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  1191. ;;
  1192. "dmalloc")
  1193. CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  1194. LIBS="$LIBS -ldmalloc"
  1195. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  1196. ;;
  1197. "gcollect")
  1198. CPPFLAGS="$CPPFLAGS -DGCOLLECT"
  1199. LIBS="$LIBS -lgc"
  1200. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  1201. ;;
  1202. "bcheck")
  1203. CPPFLAGS="$CPPFLAGS -DBCHECK"
  1204. ;;
  1205. esac
  1206. #
  1207. # Packetver
  1208. #
  1209. if test -n "$enable_packetver" ; then
  1210. CPPFLAGS="$CPPFLAGS -DPACKETVER=$enable_packetver"
  1211. fi
  1212. #
  1213. # Packetver-RE
  1214. #
  1215. case $enable_packetver_re in
  1216. "yes")
  1217. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_RE"
  1218. ;;
  1219. "no")
  1220. # default value
  1221. ;;
  1222. esac
  1223. #
  1224. # Packetver-Zero
  1225. #
  1226. case $enable_packetver_zero in
  1227. "yes")
  1228. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_ZERO"
  1229. ;;
  1230. "no")
  1231. # default value
  1232. ;;
  1233. esac
  1234. #
  1235. # Packetver-Sak
  1236. #
  1237. case $enable_packetver_sak in
  1238. "yes")
  1239. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_SAK"
  1240. ;;
  1241. "no")
  1242. # default value
  1243. ;;
  1244. esac
  1245. #
  1246. # Packetver-ad
  1247. #
  1248. case $enable_packetver_ad in
  1249. "yes")
  1250. CPPFLAGS="$CPPFLAGS -DENABLE_PACKETVER_AD"
  1251. ;;
  1252. "no")
  1253. # default value
  1254. ;;
  1255. esac
  1256. #
  1257. # Epoll
  1258. #
  1259. case $have_linux_epoll in
  1260. "yes")
  1261. CPPFLAGS="$CPPFLAGS -DSOCKET_EPOLL"
  1262. ;;
  1263. "no")
  1264. # default value
  1265. ;;
  1266. esac
  1267. #
  1268. # Obfuscation keys
  1269. #
  1270. if test -n "$obfuscationkey1" -a -n "$obfuscationkey2" -a -n "$obfuscationkey3"; then
  1271. CPPFLAGS="$CPPFLAGS -DOBFUSCATIONKEY1=$obfuscationkey1 -DOBFUSCATIONKEY2=$obfuscationkey2 -DOBFUSCATIONKEY3=$obfuscationkey3"
  1272. fi
  1273. #
  1274. # Debug
  1275. #
  1276. case $enable_debug in
  1277. "no")
  1278. # default value
  1279. # CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
  1280. ;;
  1281. "yes")
  1282. CFLAGS="$CFLAGS -g"
  1283. CPPFLAGS="$CPPFLAGS -DDEBUG"
  1284. AC_CHECK_FLAG(-fno-omit-frame-pointer)
  1285. ;;
  1286. "gdb")
  1287. CFLAGS="$CFLAGS -ggdb"
  1288. CPPFLAGS="$CPPFLAGS -DDEBUG"
  1289. AC_CHECK_FLAG(-fno-omit-frame-pointer)
  1290. ;;
  1291. esac
  1292. #
  1293. # Buildbot
  1294. #
  1295. case $enable_buildbot in
  1296. "no")
  1297. # default value
  1298. ;;
  1299. "yes")
  1300. CPPFLAGS="$CPPFLAGS -DBUILDBOT"
  1301. ;;
  1302. esac
  1303. #
  1304. # RDTSC
  1305. #
  1306. case $enable_rdtsc in
  1307. 0)
  1308. #default value
  1309. ;;
  1310. 1)
  1311. CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
  1312. ;;
  1313. esac
  1314. #
  1315. # Profiler
  1316. #
  1317. case $enable_profiler in
  1318. "no")
  1319. # default value
  1320. ;;
  1321. "gprof")
  1322. CFLAGS="$CFLAGS -pg"
  1323. LDFLAGS="$LDFLAGS -pg"
  1324. ;;
  1325. esac
  1326. #
  1327. # Renewal
  1328. #
  1329. case $enable_renewal in
  1330. "no")
  1331. CPPFLAGS="$CPPFLAGS -DDISABLE_RENEWAL"
  1332. ;;
  1333. "yes")
  1334. # default value
  1335. ;;
  1336. esac
  1337. AC_CHECK_FLAG(-fno-var-tracking)
  1338. #
  1339. # Host specific stuff
  1340. #
  1341. AC_MSG_CHECKING([host OS])
  1342. host_os="`uname`"
  1343. AC_MSG_RESULT([$host_os])
  1344. fd_setsize=""
  1345. DLLEXT=".so"
  1346. case $host_os in
  1347. Solaris* )
  1348. LIBS="$LIBS -lsocket -lnsl -ldl"
  1349. ;;
  1350. Linux* )
  1351. LIBS="$LIBS -ldl"
  1352. ;;
  1353. FreeBSD*)
  1354. CPPFLAGS="$CPPFLAGS -D__FREEBSD__ -fvisibility=hidden"
  1355. ;;
  1356. NetBSD*)
  1357. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  1358. ;;
  1359. CYGWIN*)
  1360. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  1361. fd_setsize="done"
  1362. DLLEXT=".dll"
  1363. ;;
  1364. Darwin*)
  1365. DLLEXT=".dylib"
  1366. ;;
  1367. esac
  1368. AC_SUBST([DLLEXT])
  1369. AC_MSG_CHECKING([for MinGW])
  1370. if test -n "`$CC --version 2>/dev/null | grep -i mingw`" ; then
  1371. AC_MSG_RESULT([yes])
  1372. CPPFLAGS="$CPPFLAGS -DMINGW"
  1373. if test -z "$fd_setsize" ; then
  1374. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  1375. fi
  1376. LIBS="$LIBS -lws2_32"
  1377. else
  1378. AC_MSG_RESULT([no])
  1379. fi
  1380. #
  1381. # zlib library (required)
  1382. #
  1383. AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible... stopping])])
  1384. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with... stopping])])
  1385. #
  1386. # math library (required)
  1387. #
  1388. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  1389. #
  1390. # clock_gettime (optional, rt on Debian)
  1391. #
  1392. AC_SEARCH_LIBS([clock_gettime], [rt])
  1393. #
  1394. # CLOCK_MONOTONIC clock for clock_gettime
  1395. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  1396. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  1397. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  1398. # checked but some systems define them even when they do not support it
  1399. # (ref. bugreport:1003).
  1400. #
  1401. if test "$ac_cv_search_clock_gettime" != "no" ; then
  1402. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  1403. AC_RUN_IFELSE(
  1404. [AC_LANG_SOURCE([
  1405. #include <sys/time.h>
  1406. #include <time.h>
  1407. #include <unistd.h>
  1408. int main(int argc, char** argv)
  1409. {
  1410. struct timespec tval;
  1411. return clock_gettime(CLOCK_MONOTONIC, &tval);
  1412. }
  1413. ])],
  1414. [
  1415. AC_MSG_RESULT([yes])
  1416. CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
  1417. ],
  1418. [
  1419. # either it failed to compile (CLOCK_MONOTONIC undefined)
  1420. # or clock_gettime has returned a non-zero value
  1421. AC_MSG_RESULT([no])
  1422. ],
  1423. [
  1424. AC_MSG_RESULT([guessing no])
  1425. ]
  1426. )
  1427. fi
  1428. #
  1429. # pthread
  1430. #
  1431. AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1432. AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1433. AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1434. AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1435. AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1436. AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1437. AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1438. # execinfo (backtrace)
  1439. AC_CHECK_HEADERS([execinfo.h],
  1440. [
  1441. AC_SEARCH_LIBS([backtrace],
  1442. [execinfo],
  1443. [
  1444. CFLAGS="$CFLAGS -DHAVE_EXECINFO"
  1445. ],
  1446. [
  1447. ]
  1448. )
  1449. ],
  1450. [
  1451. ]
  1452. )
  1453. #
  1454. # MySQL library
  1455. #
  1456. if test -z "$MYSQL_CONFIG_HOME"; then
  1457. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  1458. fi
  1459. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  1460. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  1461. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  1462. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  1463. fi
  1464. if test "$manual_MYSQL_LIBS" = "no" ; then
  1465. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  1466. fi
  1467. else
  1468. MYSQL_VERSION="unknown"
  1469. fi
  1470. MYSQL_OLD_LIBS="$LIBS" ; LIBS="$LIBS $MYSQL_LIBS"
  1471. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  1472. AC_CHECK_FUNC([mysql_init], [HAVE_MYSQL="yes"])
  1473. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  1474. AC_MSG_CHECKING([whether my_bool is supported (MySQL)])
  1475. AC_RUN_IFELSE(
  1476. [AC_LANG_SOURCE([
  1477. #ifdef WIN32
  1478. #include "common/winapi.h" // Needed before mysql.h
  1479. #endif
  1480. #include <mysql.h>
  1481. int main(int argc, char **argv){
  1482. my_bool val = (my_bool)0;
  1483. return (int)val;
  1484. }
  1485. ])],
  1486. [
  1487. AC_MSG_RESULT([yes])
  1488. ],
  1489. [
  1490. AC_MSG_RESULT([no (converting my_bool to bool)])
  1491. MYSQL_CFLAGS="$MYSQL_CFLAGS -Dmy_bool=bool"
  1492. ]
  1493. )
  1494. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  1495. LIBS="$MYSQL_OLD_LIBS"
  1496. AC_MSG_CHECKING([MySQL library (required)])
  1497. if test "$HAVE_MYSQL" = "yes" ; then
  1498. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  1499. else
  1500. AC_MSG_RESULT([no])
  1501. AC_MSG_ERROR([MySQL not found or incompatible])
  1502. fi
  1503. AC_SUBST([HAVE_MYSQL])
  1504. AC_SUBST([MYSQL_VERSION])
  1505. AC_SUBST([MYSQL_CFLAGS])
  1506. AC_SUBST([MYSQL_LIBS])
  1507. #
  1508. # PCRE library (optional)
  1509. #
  1510. AC_MSG_CHECKING([PCRE library])
  1511. AC_CHECK_HEADER([pcre.h], [], [AC_MSG_ERROR([PCRE header not found])])
  1512. AC_SEARCH_LIBS([pcre_study], [pcre], [], AC_MSG_ERROR([PCRE not found or incompatible]))
  1513. #
  1514. # static Support test
  1515. #
  1516. if test "$enable_static" != "no" ; then
  1517. STATIC="-static"
  1518. PLUGINSTATIC="-static-libgcc"
  1519. OLD_CFLAGS="$CFLAGS"
  1520. OLD_LDFLAGS="$LDFLAGS"
  1521. OLD_LIBS="$LIBS"
  1522. CFLAGS="$OLD_CFLAGS $MYSQL_CFLAGS -static"
  1523. LDFLAGS="$OLD_LDFLAGS -static"
  1524. LIBS="$OLD_LIBS $MYSQL_LIBS"
  1525. AC_MSG_CHECKING([whether $CC supports -static])
  1526. AC_RUN_IFELSE(
  1527. [AC_LANG_SOURCE([
  1528. int main(int argc, char **argv){
  1529. return 0;
  1530. }
  1531. ])],
  1532. [
  1533. AC_MSG_RESULT([yes])
  1534. ],
  1535. [
  1536. AC_MSG_RESULT([no])
  1537. STATIC=""
  1538. ],
  1539. [
  1540. AC_MSG_RESULT([guessing no])
  1541. STATIC=""
  1542. ]
  1543. )
  1544. CFLAGS="$OLD_CFLAGS -static-libgcc"
  1545. LDFLAGS="$OLD_LDFLAGS -static-libgcc"
  1546. AC_MSG_CHECKING([whether $CC supports -static-libgcc])
  1547. AC_RUN_IFELSE(
  1548. [AC_LANG_SOURCE([
  1549. int main(int argc, char **argv){
  1550. return 0;
  1551. }
  1552. ])],
  1553. [
  1554. AC_MSG_RESULT([yes])
  1555. ],
  1556. [
  1557. AC_MSG_RESULT([no])
  1558. PLUGINSTATIC=""
  1559. ],
  1560. [
  1561. AC_MSG_RESULT([guessing no])
  1562. PLUGINSTATIC=""
  1563. ]
  1564. )
  1565. CFLAGS="$OLD_CFLAGS"
  1566. LDFLAGS="$OLD_LDFLAGS"
  1567. LIBS="$OLD_LIBS"
  1568. fi
  1569. #
  1570. # -Werror compiler flag
  1571. #
  1572. if test "$enable_Werror" != "no" ; then
  1573. OLD_CFLAGS="$CFLAGS"
  1574. CFLAGS="$CFLAGS -Werror"
  1575. AC_MSG_CHECKING([whether $CC supports -Werror])
  1576. AC_RUN_IFELSE(
  1577. [AC_LANG_SOURCE([
  1578. int main(int argc, char **argv){
  1579. return 0;
  1580. }
  1581. ])],
  1582. [
  1583. AC_MSG_RESULT([yes])
  1584. ],
  1585. [
  1586. AC_MSG_RESULT([no])
  1587. CFLAGS="$OLD_CFLAGS"
  1588. LDFLAGS="$OLD_LDFLAGS"
  1589. ],
  1590. [
  1591. AC_MSG_RESULT([guessing no])
  1592. ]
  1593. )
  1594. fi
  1595. AC_SUBST(STATIC, ${STATIC})
  1596. AC_SUBST(PLUGINSTATIC, ${PLUGINSTATIC})
  1597. #
  1598. # Doxygen, perl (for HPMHookGen)
  1599. #
  1600. AC_CHECK_PROG([HAVE_DOXYGEN],[doxygen],[yes],[no])
  1601. AC_CHECK_PROG([HAVE_PERL],[perl],[yes],[no])
  1602. #
  1603. # OpenSSL library
  1604. #
  1605. AC_MSG_CHECKING([OpenSSL library])
  1606. dnl Order matters!
  1607. if test "$PORTNAME" != "win32"; then
  1608. AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_WARN([library 'crypto' is required for OpenSSL])])
  1609. FOUND_SSL_LIB="no"
  1610. AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
  1611. AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
  1612. AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_WARN([library 'ssl' is required for OpenSSL])])
  1613. else
  1614. AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
  1615. FOUND_SSL_LIB="no"
  1616. AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
  1617. AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
  1618. AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
  1619. fi
  1620. ###############################################################################
  1621. AC_OUTPUT