configure.ac 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270
  1. #
  2. # Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
  3. # SPDX-License-Identifier: GPL-3.0-or-later
  4. #
  5. AC_PREREQ(2.60)
  6. # We do not use m4_esyscmd_s to support older autoconf.
  7. define([VERSION_STRING], m4_esyscmd([git describe 2>/dev/null | tr -d '\n']))
  8. define([VERSION_FROM_FILE], m4_esyscmd([cat packaging/version | tr -d '\n']))
  9. m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_FROM_FILE)])
  10. AC_INIT([netdata], VERSION_STRING[])
  11. AM_MAINTAINER_MODE([disable])
  12. if test x"$USE_MAINTAINER_MODE" = xyes; then
  13. AC_MSG_NOTICE(***************** MAINTAINER MODE *****************)
  14. fi
  15. PACKAGE_RPM_VERSION="VERSION_STRING"
  16. AC_SUBST([PACKAGE_RPM_VERSION])
  17. # -----------------------------------------------------------------------------
  18. # autoconf initialization
  19. AC_CONFIG_AUX_DIR([.])
  20. AC_CONFIG_HEADERS([config.h])
  21. AC_CONFIG_MACRO_DIR([build/m4])
  22. AC_CONFIG_SRCDIR([daemon/main.c])
  23. define([AUTOMATE_INIT_OPTIONS], [tar-pax subdir-objects])
  24. m4_ifdef([AM_SILENT_RULES], [
  25. define([AUTOMATE_INIT_OPTIONS], [tar-pax silent-rules subdir-objects])
  26. ])
  27. AM_INIT_AUTOMAKE(AUTOMATE_INIT_OPTIONS)
  28. m4_ifdef([AM_SILENT_RULES], [
  29. AM_SILENT_RULES([yes])
  30. ])
  31. AC_CANONICAL_HOST
  32. AC_PROG_CC
  33. AC_PROG_CC_C99
  34. AM_PROG_CC_C_O
  35. AC_PROG_CXX
  36. AC_PROG_INSTALL
  37. PKG_PROG_PKG_CONFIG
  38. AC_USE_SYSTEM_EXTENSIONS
  39. AC_LANG_PUSH([C])
  40. AX_COMPILER_VENDOR
  41. AC_LANG_POP([C])
  42. if test "$ax_cv_c_compiler_vendor" = "clang"; then
  43. AC_CHECK_PROG([AR], [llvm-ar], [llvm-ar], [ar])
  44. AC_CHECK_PROG([RANLIB], [llvm-ranlib], [llvm-ranlib], [ranlib])
  45. else
  46. AC_CHECK_TOOL([RANLIB], [ranlib])
  47. AC_CHECK_TOOL([AR], [ar])
  48. fi
  49. CFLAGS="$CFLAGS -fexceptions"
  50. # -----------------------------------------------------------------------------
  51. # configurable options
  52. AC_ARG_ENABLE(
  53. [plugin-nfacct],
  54. [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin @<:@default autodetect@:>@])],
  55. ,
  56. [enable_plugin_nfacct="detect"]
  57. )
  58. AC_ARG_ENABLE(
  59. [plugin-freeipmi],
  60. [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin @<:@default autodetect@:>@])],
  61. ,
  62. [enable_plugin_freeipmi="detect"]
  63. )
  64. AC_ARG_ENABLE(
  65. [plugin-systemd-journal],
  66. [AS_HELP_STRING([--enable-plugin-systemd-journal], [enable systemd-journal plugin @<:@default autodetect@:>@])],
  67. ,
  68. [enable_plugin_systemd_journal="detect"]
  69. )
  70. AC_ARG_ENABLE(
  71. [logsmanagement],
  72. [AS_HELP_STRING([--disable-logsmanagement], [Disable logsmanagement @<:@default autodetect@:>@])],
  73. ,
  74. [enable_logsmanagement="detect"]
  75. )
  76. AC_ARG_ENABLE(
  77. [logsmanagement_tests],
  78. [AS_HELP_STRING([--enable-logsmanagement-tests], [Enable logsmanagement tests @<:@default disabled@:>@])],
  79. ,
  80. [enable_logsmanagement_tests="no"]
  81. )
  82. AC_ARG_ENABLE(
  83. [plugin-cups],
  84. [AS_HELP_STRING([--enable-plugin-cups], [enable cups plugin @<:@default autodetect@:>@])],
  85. ,
  86. [enable_plugin_cups="detect"]
  87. )
  88. AC_ARG_ENABLE(
  89. [plugin-xenstat],
  90. [AS_HELP_STRING([--enable-plugin-xenstat], [enable xenstat plugin @<:@default autodetect@:>@])],
  91. ,
  92. [enable_plugin_xenstat="detect"]
  93. )
  94. AC_ARG_ENABLE(
  95. [exporting-kinesis],
  96. [AS_HELP_STRING([--enable-exporting-kinesis], [enable kinesis exporting connector @<:@default autodetect@:>@])],
  97. ,
  98. [enable_exporting_kinesis="detect"]
  99. )
  100. AC_ARG_ENABLE(
  101. [exporting-pubsub],
  102. [AS_HELP_STRING([--enable-exporting-pubsub], [enable pubsub exporting connector @<:@default autodetect@:>@])],
  103. ,
  104. [enable_exporting_pubsub="detect"]
  105. )
  106. AC_ARG_ENABLE(
  107. [exporting-prometheus-remote-write],
  108. [AS_HELP_STRING([--enable-exporting-prometheus-remote-write], [enable prometheus remote write exporting connector @<:@default autodetect@:>@])],
  109. ,
  110. [enable_exporting_prometheus_remote_write="detect"]
  111. )
  112. AC_ARG_ENABLE(
  113. [exporting-mongodb],
  114. [AS_HELP_STRING([--enable-exporting-mongodb], [enable mongodb exporting @<:@default autodetect@:>@])],
  115. ,
  116. [enable_exporting_mongodb="detect"]
  117. )
  118. AC_ARG_ENABLE(
  119. [pedantic],
  120. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
  121. ,
  122. [enable_pedantic="no"]
  123. )
  124. AC_ARG_ENABLE(
  125. [accept4],
  126. [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
  127. ,
  128. [enable_accept4="detect"]
  129. )
  130. AC_ARG_WITH(
  131. [webdir],
  132. [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
  133. [webdir="${withval}"],
  134. [webdir="\$(pkgdatadir)/web"]
  135. )
  136. AC_ARG_WITH(
  137. [libcap],
  138. [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
  139. ,
  140. [with_libcap="detect"]
  141. )
  142. AC_ARG_WITH(
  143. [math],
  144. [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
  145. ,
  146. [with_math="yes"]
  147. )
  148. AC_ARG_WITH(
  149. [user],
  150. [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
  151. ,
  152. [with_user="nobody"]
  153. )
  154. AC_ARG_ENABLE(
  155. [x86-sse],
  156. [AS_HELP_STRING([--disable-x86-sse], [SSE/SS2 optimizations on x86 @<:@default enabled@:>@])],
  157. ,
  158. [enable_x86_sse="yes"]
  159. )
  160. AC_ARG_ENABLE(
  161. [lto],
  162. [AS_HELP_STRING([--enable-lto], [Link Time Optimizations @<:@default disabled@:>@])],
  163. ,
  164. [enable_lto="no"]
  165. )
  166. AC_ARG_ENABLE(
  167. [openssl],
  168. [AS_HELP_STRING([--enable-openssl], [Enable OpenSSL support @<:@default autodetect@:>@])],
  169. ,
  170. [enable_openssl="detect"]
  171. )
  172. AC_ARG_ENABLE(
  173. [lz4],
  174. [AS_HELP_STRING([--enable-lz4], [Enable LZ4 support @<:@default autodetect@:>@])],
  175. ,
  176. [enable_lz4="detect"]
  177. )
  178. AC_ARG_ENABLE(
  179. [dbengine],
  180. [AS_HELP_STRING([--disable-dbengine], [disable netdata dbengine @<:@default autodetect@:>@])],
  181. ,
  182. [enable_dbengine="detect"]
  183. )
  184. AC_ARG_ENABLE(
  185. [jsonc],
  186. [AS_HELP_STRING([--enable-jsonc], [Enable JSON-C support @<:@default autodetect@:>@])],
  187. ,
  188. [enable_jsonc="detect"]
  189. )
  190. AC_ARG_ENABLE(
  191. [ebpf],
  192. [AS_HELP_STRING([--disable-ebpf], [Disable eBPF support @<:@default autodetect@:>@])],
  193. ,
  194. [enable_ebpf="detect"]
  195. )
  196. AC_ARG_WITH(
  197. [bundled-lws],
  198. [AS_HELP_STRING([--with-bundled-lws], [Use the bundled version of libwebsockets library @<:@default use system library@:>@])],
  199. [with_bundled_lws="yes"], [with_bundled_lws="no"]
  200. )
  201. AC_ARG_WITH(
  202. [bundled-protobuf],
  203. [AS_HELP_STRING([--with-bundled-protobuf],
  204. [Uses the bundled version of Google Protocol Buffers @<:@default bundled if present@:>@])],
  205. [with_bundled_protobuf="$withval"],
  206. [with_bundled_protobuf="detect"]
  207. )
  208. AC_ARG_ENABLE(
  209. [ml],
  210. [AS_HELP_STRING([--enable-ml], [Enable anomaly detection @<:@default autodetect@:>@])],
  211. ,
  212. [enable_ml="detect"]
  213. )
  214. AC_ARG_ENABLE(
  215. [gtests],
  216. [AS_HELP_STRING([--enable-gtests], [Enable google tests @<:@default no@:>@])],
  217. ,
  218. [enable_gtests="no"]
  219. )
  220. AC_ARG_ENABLE(
  221. [aclk_ssl_debug],
  222. [AS_HELP_STRING([--enable-aclk-ssl-debug], [Enables possibility for SSL key logging @<:@default no@:>@])],
  223. [aclk_ssl_debug="yes"],
  224. [aclk_ssl_debug="no"]
  225. )
  226. AC_ARG_ENABLE(
  227. [h2o],
  228. [AS_HELP_STRING([--disable-h2o], [Disable H2O webserver @<:@default autodetect@:>@])],
  229. ,
  230. [enable_h2o="detect"]
  231. )
  232. # -----------------------------------------------------------------------------
  233. # Enforce building with C99, bail early if we can't.
  234. test "${ac_cv_prog_cc_c99}" = "no" && AC_MSG_ERROR([Netdata requires a compiler that supports C99 to build])
  235. # -----------------------------------------------------------------------------
  236. # Check if cloud is enabled and if the functionality is available
  237. AC_ARG_ENABLE(
  238. [cloud],
  239. [AS_HELP_STRING([--disable-cloud],
  240. [Disables all cloud functionality])],
  241. [ enable_cloud="$enableval" ],
  242. [ enable_cloud="detect" ]
  243. )
  244. if test "${enable_cloud}" = "no"; then
  245. AC_DEFINE([DISABLE_CLOUD], [1], [disable netdata cloud functionality])
  246. fi
  247. # -----------------------------------------------------------------------------
  248. # C++ version check
  249. # Check for C++17 support (optional)
  250. # AX_CXX_COMPILE_STDCXX(17, noext, optional)
  251. if test "x$HAVE_CXX17" != "x1"; then
  252. # Check for C++11 support (optional)
  253. AX_CXX_COMPILE_STDCXX(11, noext, optional)
  254. fi
  255. AC_MSG_CHECKING([c++ standard to use])
  256. if test "x$HAVE_CXX17" = "x1"; then
  257. have_cxx17="yes"
  258. have_cxx11="yes"
  259. CPP_STD_FLAG="-std=c++17"
  260. cpp_std_to_use="c++17"
  261. AM_CONDITIONAL([HAVE_CXX17], [true])
  262. AM_CONDITIONAL([HAVE_CXX11], [true])
  263. elif test "x$HAVE_CXX11" = "x1"; then
  264. have_cxx17="no"
  265. have_cxx11="yes"
  266. CPP_STD_FLAG="-std=c++11"
  267. cpp_std_to_use="c++11"
  268. AM_CONDITIONAL([HAVE_CXX17], [false])
  269. AM_CONDITIONAL([HAVE_CXX11], [true])
  270. else
  271. have_cxx17="no"
  272. have_cxx11="no"
  273. CPP_STD_FLAG=""
  274. cpp_std_to_use="no c++"
  275. AM_CONDITIONAL([HAVE_CXX17], [false])
  276. AM_CONDITIONAL([HAVE_CXX11], [false])
  277. fi
  278. # PPC64LE needs -std=gnu++11 in order to build dlib. However, the rest of
  279. # the agent's components use and have been tested only with -std=c++11.
  280. # Skip ML compilation on that CPU until we reorganize and test the C++ flags.
  281. if test "${host_cpu}" = "powerpc64le"; then
  282. have_cxx17="no"
  283. have_cxx11="no"
  284. CPP_STD_FLAG=""
  285. cpp_std_to_use="no c++ on powerpc64le"
  286. AM_CONDITIONAL([HAVE_CXX17], [false])
  287. AM_CONDITIONAL([HAVE_CXX11], [false])
  288. fi
  289. AC_MSG_RESULT([${cpp_std_to_use}])
  290. # -----------------------------------------------------------------------------
  291. # netdata required checks
  292. # fails on centos6
  293. #AX_CHECK_ENABLE_DEBUG()
  294. AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
  295. AX_GCC_FUNC_ATTRIBUTE([malloc])
  296. AX_GCC_FUNC_ATTRIBUTE([noreturn])
  297. AX_GCC_FUNC_ATTRIBUTE([noinline])
  298. AX_GCC_FUNC_ATTRIBUTE([format])
  299. AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
  300. AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
  301. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  302. AC_CHECK_FUNCS([clock_gettime])
  303. AC_CHECK_FUNCS([sched_setscheduler sched_getscheduler sched_getparam sched_get_priority_min sched_get_priority_max getpriority setpriority nice])
  304. AC_CHECK_FUNCS([recvmmsg])
  305. AC_CHECK_FUNCS([close_range])
  306. AC_TYPE_INT8_T
  307. AC_TYPE_INT16_T
  308. AC_TYPE_INT32_T
  309. AC_TYPE_INT64_T
  310. AC_TYPE_UINT8_T
  311. AC_TYPE_UINT16_T
  312. AC_TYPE_UINT32_T
  313. AC_TYPE_UINT64_T
  314. AC_C_INLINE
  315. AC_FUNC_STRERROR_R
  316. AC_C__GENERIC
  317. # AC_C_STMT_EXPR
  318. AC_CANONICAL_HOST
  319. AC_HEADER_MAJOR
  320. AC_HEADER_RESOLV
  321. AC_CHECK_HEADERS_ONCE([sys/prctl.h])
  322. AC_CHECK_HEADERS_ONCE([sys/vfs.h])
  323. AC_CHECK_HEADERS_ONCE([sys/statfs.h])
  324. AC_CHECK_HEADERS_ONCE([linux/magic.h])
  325. AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
  326. AC_CHECK_HEADERS_ONCE([sys/mount.h])
  327. if test "${enable_accept4}" != "no"; then
  328. AC_CHECK_FUNCS_ONCE(accept4)
  329. fi
  330. AC_CHECK_FUNCS_ONCE(malloc_usable_size)
  331. # -----------------------------------------------------------------------------
  332. # operating system detection
  333. originalCFLAGS="${CFLAGS}"
  334. AC_MSG_CHECKING([operating system])
  335. case "$host_os" in
  336. freebsd*)
  337. build_target=freebsd
  338. OPTIONAL_OS_DEP_CFLAGS="-I/usr/local/include"
  339. CFLAGS="${CFLAGS} ${OPTIONAL_OS_DEP_CFLAGS}"
  340. LDFLAGS="${LDFLAGS} -L/usr/local/lib"
  341. ;;
  342. darwin*)
  343. build_target=macos
  344. LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
  345. # -----------------------------------------------------------------------------
  346. # Pull in OpenSSL properly if on macOS
  347. if brew --prefix > /dev/null 2>&1; then
  348. if brew --prefix --installed openssl > /dev/null 2>&1; then
  349. HOMEBREW_OPENSSL_PREFIX=$(brew --prefix --installed openssl)
  350. elif brew --prefix --installed openssl@3 > /dev/null 2>&1; then
  351. HOMEBREW_OPENSSL_PREFIX=$(brew --prefix --installed openssl@3)
  352. elif brew --prefix --installed openssl@1.1 > /dev/null 2>&1; then
  353. HOMEBREW_OPENSSL_PREFIX=$(brew --prefix --installed openssl@1.1)
  354. fi
  355. if test -n "${HOMEBREW_OPENSSL_PREFIX}"; then
  356. OPTIONAL_OS_DEP_CFLAGS="-I${HOMEBREW_OPENSSL_PREFIX}/include"
  357. CFLAGS="${CFLAGS} ${OPTIONAL_OS_DEP_CFLAGS}"
  358. LDFLAGS="${LDFLAGS} -L${HOMEBREW_OPENSSL_PREFIX}/lib"
  359. fi
  360. HOMEBREW_PREFIX=$(brew --prefix)
  361. OPTIONAL_OS_DEP_CFLAGS="${OPTIONAL_OS_DEP_CFLAGS} -I${HOMEBREW_PREFIX}/include"
  362. CFLAGS="${CFLAGS} -I${HOMEBREW_PREFIX}/include"
  363. LDFLAGS="${LDFLAGS} -L${HOMEBREW_PREFIX}/lib"
  364. fi
  365. ;;
  366. *)
  367. build_target=linux
  368. ;;
  369. esac
  370. AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
  371. if test "${build_target}" = "freebsd"
  372. then
  373. AC_DEFINE([COMPILED_FOR_FREEBSD], [1], [Compiled for FreeBSD])
  374. fi
  375. AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
  376. if test "${build_target}" = "macos"
  377. then
  378. AC_DEFINE([COMPILED_FOR_MACOS], [1], [Compiled for MacOS])
  379. fi
  380. AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
  381. if test "${build_target}" = "linux"
  382. then
  383. AC_DEFINE([COMPILED_FOR_LINUX], [1], [Compiled for Linux])
  384. fi
  385. AM_CONDITIONAL([ENABLE_PLUGIN_LOCAL_LISTENERS], [test "${build_target}" = "linux"])
  386. AC_MSG_RESULT([Host OS: ${build_target}])
  387. # -----------------------------------------------------------------------------
  388. # hardening
  389. HARDENING_CFLAGS=""
  390. if ! echo "${originalCFLAGS}" | grep -q '\-fstack-protector'; then
  391. AX_CHECK_COMPILE_FLAG(
  392. [-fstack-protector-strong],
  393. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -fstack-protector-strong"],
  394. [AX_CHECK_COMPILE_FLAG(
  395. [-fstack-protector],
  396. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -fstack-protector"],
  397. ,
  398. [-Werror],
  399. )],
  400. [-Werror],
  401. )
  402. fi
  403. if ! echo "${originalCFLAGS}" | grep -q '\-fno-stack-clash-protection'; then
  404. AX_CHECK_COMPILE_FLAG(
  405. [-fstack-clash-protection],
  406. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -fstack-clash-protection"],
  407. ,
  408. [-Werror],
  409. )
  410. fi
  411. if ! echo "${originalCFLAGS}" | grep -q '\-fcf-protection'; then
  412. AX_CHECK_COMPILE_FLAG(
  413. [-fcf-protection=full],
  414. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -fcf-protection=full"],
  415. ,
  416. [-Werror],
  417. )
  418. fi
  419. if ! echo "${originalCFLAGS}" | grep -q '\-mbranch-protection'; then
  420. AX_CHECK_COMPILE_FLAG(
  421. [-mbranch-protection=standard],
  422. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -mbranch-protection=standard"],
  423. ,
  424. [-Werror],
  425. )
  426. fi
  427. if ! echo "${originalCFLAGS}" | grep -q '\-D_FORTIFY_SOURCE'; then
  428. # This complex set of checks is needed because there is no clean
  429. # way to verify _FORTIFY_SOURCE support without having to check for
  430. # the required compiler builtins.
  431. AC_CHECK_DECLS(
  432. [__builtin_constant_p, __builtin_object_size, __builtin___memcpy_chk, __builtin___memmove_chk, __builtin___mempcpy_chk,
  433. __builtin___memset_chk, __builtin___snprintf_chk, __builtin___sprintf_chk, __builtin___stpcpy_chk, __builtin___strcat_chk,
  434. __builtin___strcpy_chk, __builtin___strncat_chk, __builtin___strncpy_chk, __builtin___vsnprintf_chk, __builtin___vsprintf_chk],
  435. [HAVE_FORTIFY_SOURCE=2]
  436. )
  437. if test "x${HAVE_FORTIFY_SOURCE}" = "x2" && echo "${originalCFLAGS}" | grep -qv '\-O0'; then
  438. AC_CHECK_DECL(
  439. __builtin_dynamic_object_size,
  440. [AX_CHECK_COMPILE_FLAG(
  441. [-D_FORTIFY_SOURCE=3],
  442. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -D_FORTIFY_SOURCE=3"],
  443. ,
  444. [-Werror],
  445. )],
  446. [AX_CHECK_COMPILE_FLAG(
  447. [-D_FORTIFY_SOURCE=2],
  448. [HARDENING_CFLAGS="${HARDENING_CFLAGS} -D_FORTIFY_SOURCE=2"],
  449. ,
  450. [-Werror],
  451. )],
  452. )
  453. fi
  454. fi
  455. # -----------------------------------------------------------------------------
  456. # backtrace
  457. AC_SEARCH_LIBS([backtrace], [execinfo], [AC_DEFINE([HAVE_BACKTRACE], [1], [backtrace availability])])
  458. # -----------------------------------------------------------------------------
  459. # pthreads
  460. ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
  461. LIBS="${PTHREAD_LIBS} ${LIBS}"
  462. CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
  463. CC="${PTHREAD_CC}"
  464. AC_CHECK_LIB(
  465. [pthread],
  466. [pthread_getname_np],
  467. [AC_DEFINE([HAVE_PTHREAD_GETNAME_NP], [1], [Is set if pthread_getname_np is available])]
  468. )
  469. # -----------------------------------------------------------------------------
  470. # libdatachannel
  471. AC_CHECK_LIB([datachannel], [rtcCreatePeerConnection],
  472. [LIBDATACHANNEL_FOUND=yes],
  473. [LIBDATACHANNEL_FOUND=no])
  474. if test "x$LIBDATACHANNEL_FOUND" = "xyes"; then
  475. AC_DEFINE([HAVE_LIBDATACHANNEL], [1], [libdatachannel usability])
  476. OPTIONAL_DATACHANNEL_LIBS="-ldatachannel"
  477. fi
  478. # -----------------------------------------------------------------------------
  479. # libm
  480. AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
  481. AC_ARG_VAR([MATH_LIBS], [linker flags for math])
  482. if test -z "${MATH_LIBS}"; then
  483. AC_CHECK_LIB(
  484. [m],
  485. [sin],
  486. [MATH_LIBS="-lm"]
  487. )
  488. fi
  489. test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
  490. AC_MSG_CHECKING([if libm should be used])
  491. if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
  492. with_math="yes"
  493. AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
  494. OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
  495. OPTIONAL_MATH_LIBS="${MATH_LIBS}"
  496. else
  497. with_math="no"
  498. fi
  499. AC_MSG_RESULT([${with_math}])
  500. AC_CHECK_FUNCS([isfinite])
  501. AC_CHECK_FUNCS([finite])
  502. # -----------------------------------------------------------------------------
  503. # libuv multi-platform support library with a focus on asynchronous I/O
  504. # TODO: check version, uv_fs_scandir_next only available in version >= 1.0
  505. AC_CHECK_LIB(
  506. [uv],
  507. [uv_fs_scandir_next],
  508. [UV_LIBS="-luv"]
  509. )
  510. test -z "${UV_LIBS}" && \
  511. AC_MSG_ERROR([libuv required but not found. Try installing 'libuv1-dev' or 'libuv-devel'.])
  512. OPTIONAL_UV_CFLAGS="${UV_CFLAGS}"
  513. OPTIONAL_UV_LIBS="${UV_LIBS}"
  514. # -----------------------------------------------------------------------------
  515. # lz4
  516. AC_CHECK_LIB(
  517. [lz4],
  518. [LZ4_createStream],
  519. [LZ4_LIBS_FAST="-llz4"]
  520. )
  521. AC_CHECK_LIB(
  522. [lz4],
  523. [LZ4_compress_fast_continue],
  524. [LZ4_LIBS="-llz4"]
  525. )
  526. # -----------------------------------------------------------------------------
  527. # libcurl
  528. PKG_CHECK_MODULES(
  529. [LIBCURL],
  530. [libcurl],
  531. [AC_CHECK_LIB(
  532. [curl],
  533. [curl_easy_init],
  534. [have_libcurl=yes],
  535. [have_libcurl=no]
  536. )],
  537. [have_libcurl=no]
  538. )
  539. if test "x$have_libcurl" = "xyes"; then
  540. AC_DEFINE([HAVE_CURL], [1], [libcurl usability])
  541. OPTIONAL_CURL_LIBS="-lcurl"
  542. fi
  543. # -----------------------------------------------------------------------------
  544. # PCRE2
  545. PKG_CHECK_MODULES(
  546. [LIBPCRE2],
  547. [libpcre2-8],
  548. [AC_CHECK_LIB(
  549. [pcre2-8],
  550. [pcre2_compile_8],
  551. [have_libpcre2=yes],
  552. [have_libpcre2=no]
  553. )],
  554. [have_libpcre2=no]
  555. )
  556. if test "x$have_libpcre2" = "xyes"; then
  557. AC_DEFINE([HAVE_PCRE2], [1], [PCRE2 usability])
  558. OPTIONAL_PCRE2_LIBS="-lpcre2-8"
  559. fi
  560. AM_CONDITIONAL([ENABLE_LOG2JOURNAL], [test "${have_libpcre2}" = "yes"])
  561. # -----------------------------------------------------------------------------
  562. # zstd
  563. AC_CHECK_LIB([zstd], [ZSTD_createCStream, ZSTD_createDStream],
  564. [LIBZSTD_FOUND=yes],
  565. [LIBZSTD_FOUND=no])
  566. if test "x$LIBZSTD_FOUND" = "xyes"; then
  567. AC_DEFINE([ENABLE_ZSTD], [1], [libzstd usability])
  568. OPTIONAL_ZSTD_LIBS="-lzstd"
  569. fi
  570. # -----------------------------------------------------------------------------
  571. # brotli
  572. AC_CHECK_LIB([brotlienc], [BrotliEncoderCreateInstance, BrotliEncoderCompressStream],
  573. [LIBBROTLIENC_FOUND=yes],
  574. [LIBBROTLIENC_FOUND=no])
  575. if test "x$LIBBROTLIENC_FOUND" = "xyes"; then
  576. AC_DEFINE([ENABLE_BROTLIENC], [1], [libbrotlienc usability])
  577. OPTIONAL_BROTLIENC_LIBS="-lbrotlienc"
  578. fi
  579. AC_CHECK_LIB([brotlidec], [BrotliDecoderCreateInstance, BrotliDecoderDecompressStream],
  580. [LIBBROTLIDEC_FOUND=yes],
  581. [LIBBROTLIDEC_FOUND=no])
  582. if test "x$LIBBROTLIDEC_FOUND" = "xyes"; then
  583. AC_DEFINE([ENABLE_BROTLIDEC], [1], [libbrotlidec usability])
  584. OPTIONAL_BROTLIDEC_LIBS="-lbrotlidec"
  585. fi
  586. # -----------------------------------------------------------------------------
  587. # zlib
  588. PKG_CHECK_MODULES(
  589. [ZLIB],
  590. [zlib],
  591. [have_zlib=yes],
  592. [have_zlib=no]
  593. )
  594. test "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
  595. # -----------------------------------------------------------------------------
  596. # libuuid
  597. PKG_CHECK_MODULES(
  598. [UUID],
  599. [uuid],
  600. [have_uuid=yes],
  601. [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]
  602. )
  603. OPTIONAL_UUID_CFLAGS="${UUID_CFLAGS}"
  604. OPTIONAL_UUID_LIBS="${UUID_LIBS}"
  605. # -----------------------------------------------------------------------------
  606. # OpenSSL Cryptography and SSL/TLS Toolkit
  607. AC_CHECK_LIB(
  608. [crypto],
  609. [SHA256_Init],
  610. [SSL_LIBS="-lcrypto -lssl"]
  611. )
  612. AC_CHECK_LIB(
  613. [crypto],
  614. [X509_VERIFY_PARAM_set1_host],
  615. [ssl_host_validation="yes"],
  616. [ssl_host_validation="no"]
  617. )
  618. test -z "${SSL_LIBS}" || \
  619. AC_DEFINE([HAVE_CRYPTO], [1], [libcrypto availability])
  620. if test "${ssl_host_validation}" = "no"; then
  621. AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [0], [ssl host validation])
  622. AC_MSG_WARN([DISABLING SSL HOSTNAME VALIDATION BECAUSE IT IS NOT AVAILABLE ON THIS SYSTEM.])
  623. else
  624. AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [1], [ssl host validation])
  625. fi
  626. # -----------------------------------------------------------------------------
  627. # JSON-C library
  628. PKG_CHECK_MODULES([JSON],[json-c],AC_CHECK_LIB(
  629. [json-c],
  630. [json_object_get_type],
  631. [JSONC_LIBS="-ljson-c"]),AC_CHECK_LIB(
  632. [json],
  633. [json_object_get_type],
  634. [JSONC_LIBS="-ljson"])
  635. )
  636. OPTIONAL_JSONC_LIBS="${JSONC_LIBS}"
  637. # -----------------------------------------------------------------------------
  638. # YAML library
  639. AC_CHECK_LIB(
  640. [yaml],
  641. [yaml_parser_initialize],
  642. [YAML_LIBS="-lyaml"]
  643. )
  644. OPTIONAL_YAML_LIBS="${YAML_LIBS}"
  645. # -----------------------------------------------------------------------------
  646. # DB engine and OpenSSL
  647. test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \
  648. AC_MSG_ERROR([liblz4 required but not found. Try installing 'liblz4-dev' or 'lz4-devel'.])
  649. AC_C_BIGENDIAN([],
  650. [LIBJUDY_CFLAGS="-DJU_LITTLE_ENDIAN"],
  651. [AC_MSG_ERROR([Could not find out system endiannnes])])
  652. AC_CHECK_SIZEOF(void *)
  653. if test "$ac_cv_sizeof_void_p" = 8; then
  654. AC_MSG_RESULT(Detected 64-bit Build Environment)
  655. LIBJUDY_CFLAGS="$LIBJUDY_CFLAGS -DJU_64BIT"
  656. else
  657. AC_MSG_RESULT(Detected 32-bit Build Environment)
  658. LIBJUDY_CFLAGS="$LIBJUDY_CFLAGS -UJU_64BIT"
  659. fi
  660. AC_SUBST([LIBJUDY_CFLAGS])
  661. JUDY_CFLAGS="-I \$(abs_top_srcdir)/libnetdata/libjudy/src"
  662. test "${enable_openssl}" = "yes" -a -z "${SSL_LIBS}" && \
  663. AC_MSG_ERROR([OpenSSL required but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  664. test "${enable_dbengine}" = "yes" -a -z "${SSL_LIBS}" && \
  665. AC_MSG_ERROR([OpenSSL required for DBENGINE but not found. Try installing 'libssl-dev' or 'openssl-devel'.])
  666. AC_MSG_CHECKING([if netdata dbengine should be used])
  667. if test "${enable_dbengine}" != "no" -a "${UV_LIBS}" -a "${LZ4_LIBS}" -a "${SSL_LIBS}"; then
  668. enable_dbengine="yes"
  669. AC_DEFINE([ENABLE_DBENGINE], [1], [netdata dbengine usability])
  670. OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
  671. OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
  672. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  673. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  674. else
  675. enable_dbengine="no"
  676. fi
  677. AC_MSG_RESULT([${enable_dbengine}])
  678. AM_CONDITIONAL([ENABLE_DBENGINE], [test "${enable_dbengine}" = "yes"])
  679. AC_MSG_CHECKING([if openssl should be used])
  680. if test "${enable_openssl}" != "no" -a "${SSL_LIBS}"; then
  681. enable_openssl="yes"
  682. AC_DEFINE([ENABLE_OPENSSL], [1], [openssl usability])
  683. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  684. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  685. else
  686. enable_openssl="no"
  687. fi
  688. AC_MSG_RESULT([${enable_openssl}])
  689. AM_CONDITIONAL([ENABLE_OPENSSL], [test "${enable_openssl}" = "yes"])
  690. AC_MSG_CHECKING([if lz4 should be used])
  691. if test "${enable_lz4}" != "no"; then
  692. if test "${LZ4_LIBS_FAST}"; then
  693. LIBS_BKP="${LIBS}"
  694. LIBS="${LZ4_LIBS_FAST}"
  695. AC_TRY_LINK(
  696. [ #include <lz4.h> ],
  697. [
  698. LZ4_stream_t* stream = LZ4_createStream();
  699. ],
  700. [ enable_lz4="yes"],
  701. [ enable_lz4="no" ]
  702. )
  703. LIBS="${LIBS_BKP}"
  704. if test "${enable_lz4}" == "yes"; then
  705. OPTIONAL_LZ4_LIBS="${LZ4_LIBS_FAST}"
  706. AC_DEFINE([ENABLE_LZ4], [1], [lz4 usability])
  707. fi
  708. else
  709. if test "${enable_lz4}" == "yes"; then
  710. AC_MSG_ERROR([liblz4 with version >= 1.9.0 required to enable lz4. Try installing the required version of 'liblz4-dev' or 'liblz4-devel'.])
  711. enable_lz4="no"
  712. fi
  713. enable_lz4="no"
  714. fi
  715. else
  716. enable_lz4="no"
  717. fi
  718. AC_MSG_RESULT([${enable_lz4}])
  719. AM_CONDITIONAL([ENABLE_LZ4], [test "${enable_lz4}" = "yes"])
  720. # -----------------------------------------------------------------------------
  721. # JSON-C
  722. if test "${enable_jsonc}" != "no" -a -z "${JSONC_LIBS}"; then
  723. # Try and detect manual static build presence (from netdata-installer.sh)
  724. AC_MSG_CHECKING([if statically built json-c is present])
  725. HAVE_libjson_c_a="no"
  726. if test -f "externaldeps/jsonc/libjson-c.a"; then
  727. LIBS_BKP="${LIBS}"
  728. LIBS="externaldeps/jsonc/libjson-c.a"
  729. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/jsonc/json-c/json.h"
  730. int main (int argc, char **argv) {
  731. struct json_object *jobj;
  732. char *str = "{ \"msg-type\": \"random\" }";
  733. jobj = json_tokener_parse(str);
  734. json_object_get_type(jobj);
  735. }]])],
  736. [HAVE_libjson_c_a="yes"],
  737. [HAVE_libjson_c_a="no"])
  738. LIBS="${LIBS_BKP}"
  739. fi
  740. if test "${HAVE_libjson_c_a}" = "yes"; then
  741. AC_DEFINE([LINK_STATIC_JSONC], [1], [static json-c should be used])
  742. JSONC_LIBS="static"
  743. OPTIONAL_JSONC_STATIC_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/jsonc"
  744. fi
  745. AC_MSG_RESULT([${HAVE_libjson_c_a}])
  746. fi
  747. AM_CONDITIONAL([LINK_STATIC_JSONC], [test "${JSONC_LIBS}" = "static"])
  748. test "${enable_jsonc}" = "yes" -a -z "${JSONC_LIBS}" && \
  749. AC_MSG_ERROR([JSON-C required but not found. Try installing 'libjson-c-dev' or 'json-c'.])
  750. AC_MSG_CHECKING([if json-c should be used])
  751. if test "${enable_jsonc}" != "no" -a "${JSONC_LIBS}"; then
  752. enable_jsonc="yes"
  753. AC_DEFINE([ENABLE_JSONC], [1], [netdata json-c usability])
  754. else
  755. enable_jsonc="no"
  756. fi
  757. AC_MSG_RESULT([${enable_jsonc}])
  758. AM_CONDITIONAL([ENABLE_JSONC], [test "${enable_jsonc}" = "yes"])
  759. # -----------------------------------------------------------------------------
  760. # libyaml
  761. PKG_CHECK_MODULES(
  762. [LIBYAML],
  763. [yaml-0.1],
  764. [AC_CHECK_LIB(
  765. [yaml],
  766. [yaml_parser_initialize],
  767. [have_libyaml=yes],
  768. [have_libyaml=no]
  769. )],
  770. [have_libyaml=no]
  771. )
  772. if test "x$have_libyaml" = "xyes"; then
  773. AC_DEFINE([HAVE_LIBYAML], [1], [libyaml usability])
  774. OPTIONAL_YAML_LIBS="-lyaml"
  775. fi
  776. # -----------------------------------------------------------------------------
  777. # YAML
  778. if test -z "${YAML_LIBS}"; then
  779. # Try and detect manual static build presence (from netdata-installer.sh)
  780. AC_MSG_CHECKING([if statically built libyaml is present])
  781. HAVE_libyaml_a="no"
  782. if test -f "externaldeps/libyaml/libyaml.a"; then
  783. LIBS_BKP="${LIBS}"
  784. LIBS="externaldeps/libyaml/libyaml.a"
  785. AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/libyaml/yaml.h"
  786. int main (int argc, char **argv) {
  787. yaml_parser_t parser;
  788. yaml_parser_initialize(&parser);
  789. }]])],
  790. [HAVE_libyaml_a="yes"],
  791. [HAVE_libyaml_a="no"])
  792. LIBS="${LIBS_BKP}"
  793. fi
  794. if test "${HAVE_libyaml_a}" = "yes"; then
  795. AC_DEFINE([LINK_STATIC_YAML], [1], [static yaml should be used])
  796. YAML_LIBS="static"
  797. OPTIONAL_YAML_STATIC_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/libyaml"
  798. fi
  799. AC_MSG_RESULT([${HAVE_libyaml_a}])
  800. fi
  801. AM_CONDITIONAL([LINK_STATIC_YAML], [test "${YAML_LIBS}" = "static"])
  802. test -z "${YAML_LIBS}" && \
  803. AC_MSG_ERROR([LIBYAML required but not found. Try installing 'libyaml-dev'.])
  804. # -----------------------------------------------------------------------------
  805. # compiler options
  806. AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE])
  807. AS_CASE([$host_cpu],
  808. [i?86], [SSE_CANDIDATE="yes"]
  809. )
  810. AC_SUBST([SSE_CANDIDATE])
  811. if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then
  812. opt="-msse2 -mfpmath=sse"
  813. AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], [])
  814. fi
  815. if test "${GCC}" = "yes"; then
  816. AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
  817. AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
  818. else
  819. AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
  820. AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
  821. fi
  822. if test "${GCC}" = "yes"; then
  823. AC_DEFINE([__always_unused], [__attribute__((unused))], [gcc unused attribute])
  824. AC_DEFINE([__maybe_unused], [__attribute__((unused))], [gcc unused attribute])
  825. else
  826. AC_DEFINE([__always_unused], [], [dummy unused attribute])
  827. AC_DEFINE([__maybe_unused], [], [dummy unused attribute])
  828. fi
  829. if test "${enable_pedantic}" = "yes"; then
  830. enable_strict="yes"
  831. CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
  832. fi
  833. # -----------------------------------------------------------------------------
  834. # dlsym check
  835. AC_MSG_CHECKING(whether we can use dlsym)
  836. OLD_LIBS="${LIBS}"
  837. LIBS="-ldl"
  838. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  839. #include <dlfcn.h>
  840. static void *(*libc_malloc)(size_t);
  841. int main() {
  842. libc_malloc = dlsym(RTLD_NEXT, "malloc");
  843. }
  844. ]])], CAN_USE_DLSYM=yes, CAN_USE_DLSYM=no)
  845. LIBS="${OLD_LIBS}"
  846. AC_MSG_RESULT($CAN_USE_DLSYM)
  847. if test "x$CAN_USE_DLSYM" = xyes; then
  848. AC_DEFINE([HAVE_DLSYM], [1], [dlsym usability])
  849. OPTIONAL_DL_LIBS="-ldl"
  850. fi
  851. AC_SUBST([OPTIONAL_DL_LIBS])
  852. # -----------------------------------------------------------------------------
  853. # memory allocation library
  854. AC_MSG_CHECKING([for memory allocator])
  855. TS_CHECK_JEMALLOC
  856. if test "$has_jemalloc" = "1"; then
  857. AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
  858. AC_MSG_RESULT([jemalloc])
  859. else
  860. TS_CHECK_TCMALLOC
  861. if test "$has_tcmalloc" = "1"; then
  862. AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
  863. AC_MSG_RESULT([tcmalloc])
  864. else
  865. AC_MSG_RESULT([system])
  866. AC_C_MALLOPT
  867. AC_C_MALLINFO
  868. fi
  869. fi
  870. # -----------------------------------------------------------------------------
  871. # libcap
  872. PKG_CHECK_MODULES(
  873. [LIBCAP],
  874. [libcap],
  875. [AC_CHECK_LIB([cap], [cap_get_proc, cap_set_proc],
  876. [AC_CHECK_HEADER(
  877. [sys/capability.h],
  878. [have_libcap=yes],
  879. [have_libcap=no]
  880. )],
  881. [have_libcap=no]
  882. )],
  883. [have_libcap=no]
  884. )
  885. test "${with_libcap}" = "yes" -a "${have_libcap}" != "yes" && AC_MSG_ERROR([libcap required but not found.])
  886. AC_MSG_CHECKING([if libcap should be used])
  887. if test "${with_libcap}" != "no" -a "${have_libcap}" = "yes"; then
  888. with_libcap="yes"
  889. AC_DEFINE([HAVE_CAPABILITY], [1], [libcap usability])
  890. OPTIONAL_LIBCAP_CFLAGS="${LIBCAP_CFLAGS}"
  891. OPTIONAL_LIBCAP_LIBS="${LIBCAP_LIBS}"
  892. else
  893. with_libcap="no"
  894. fi
  895. AC_MSG_RESULT([${with_libcap}])
  896. AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
  897. # -----------------------------------------------------------------------------
  898. # H2O related
  899. can_build_h2o="no"
  900. if test "${enable_h2o}" != "no"; then
  901. can_build_h2o="yes"
  902. AC_MSG_CHECKING([can build H2O])
  903. if test -z "${UV_LIBS}"; then
  904. can_build_h2o="no"
  905. fi
  906. if test -n "${SSL_LIBS}"; then
  907. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  908. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  909. else
  910. can_build_h2o="no"
  911. fi
  912. AC_MSG_RESULT([${can_build_h2o}])
  913. if test "${can_build_h2o}" = "no" -a "${enable_h2o}" = "yes"; then
  914. AC_MSG_ERROR([H2O was requested but it cannot be built])
  915. fi
  916. if test "${can_build_h2o}" = "yes"; then
  917. AC_DEFINE([ENABLE_H2O], [1], [H2O web server])
  918. H2O_CFLAGS="-Wno-unused-result -Wno-misleading-indentation -Wno-format-security -Wno-format -Wno-unused-function -Wno-unused-parameter -Wno-type-limits -Wno-unused-but-set-variable -Wno-implicit-fallthrough -I\$(abs_top_srcdir)/web/server/h2o/libh2o/include -I\$(abs_top_srcdir)/web/server/h2o/libh2o/deps/picotls/include -I\$(abs_top_srcdir)/web/server/h2o/libh2o/deps/quicly/include -DH2O_USE_LIBUV=0"
  919. fi
  920. fi
  921. AM_CONDITIONAL([ENABLE_H2O], [test "${can_build_h2o}" = "yes"])
  922. # -----------------------------------------------------------------------------
  923. # ACLK
  924. bundled_proto_avail="no"
  925. if test "${with_bundled_protobuf}" != "no"; then
  926. AC_MSG_CHECKING([is bundled protobuf available])
  927. if test -f "externaldeps/protobuf/src/protoc"; then
  928. bundled_proto_avail="yes"
  929. fi
  930. AC_MSG_RESULT([${bundled_proto_avail}])
  931. if test "${with_bundled_protobuf}" == "yes" -a "${bundled_proto_avail}" != "yes"; then
  932. AC_MSG_ERROR([Bundled protobuf requested using --with-bundled-protobuf but it cannot be used/found])
  933. fi
  934. if test "${with_bundled_protobuf}" == "detect" -a "${bundled_proto_avail}" == "yes"; then
  935. with_bundled_protobuf="yes"
  936. fi
  937. fi
  938. AM_CONDITIONAL([MQTT_WSS_DEBUG], [test "${aclk_ssl_debug}" = "yes"])
  939. if test "${aclk_ssl_debug}" = "yes"; then
  940. AC_DEFINE([MQTT_WSS_DEBUG], [1], [ACLK SSL allow debugging])
  941. fi
  942. if test "${with_bundled_protobuf}" != "yes"; then
  943. PKG_CHECK_MODULES(
  944. [PROTOBUF],
  945. [protobuf >= 3],
  946. [have_libprotobuf=yes],
  947. [have_libprotobuf=no]
  948. )
  949. AC_PATH_PROG([PROTOC], [protoc], [no])
  950. AS_IF(
  951. [test x"${PROTOC}" == x"no"],
  952. [have_protoc=no],
  953. [have_protoc=yes]
  954. )
  955. else
  956. AC_MSG_NOTICE([using bundled protobuf])
  957. AC_DEFINE([BUNDLED_PROTOBUF], [1], [Using a bundled copy of protobuf])
  958. PROTOC="\$(abs_top_srcdir)/externaldeps/protobuf/src/protoc"
  959. PROTOBUF_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/protobuf/src"
  960. PROTOBUF_LIBS="\$(abs_top_srcdir)/externaldeps/protobuf/src/.libs/libprotobuf.a"
  961. have_libprotobuf="yes"
  962. have_protoc="yes"
  963. fi
  964. AC_PATH_PROG([CXX_BINARY], [${CXX}], [no])
  965. AS_IF(
  966. [test x"${CXX_BINARY}" == x"no"],
  967. [have_CXX_compiler=no],
  968. [have_CXX_compiler=yes]
  969. )
  970. if test "${have_libprotobuf}" == "yes" && test "${have_CXX_compiler}" == "yes"; then
  971. AC_DEFINE([HAVE_PROTOBUF], [1], [Protobuf is available])
  972. fi
  973. AC_MSG_CHECKING([if Cloud functionality should be enabled])
  974. AC_MSG_RESULT([${enable_cloud}])
  975. if test "$enable_cloud" != "no"; then
  976. AC_MSG_NOTICE([Checking if ACLK can be built])
  977. can_enable_ng="yes"
  978. AC_MSG_CHECKING([if git submodules present for ACLK])
  979. if test -f "mqtt_websockets/src/mqtt_wss_client.c"; then
  980. AC_MSG_RESULT([yes])
  981. else
  982. AC_MSG_RESULT([no])
  983. can_enable_ng="no"
  984. fi
  985. AC_MSG_CHECKING([if SSL available for ACLK])
  986. if test -n "${SSL_LIBS}"; then
  987. AC_MSG_RESULT([yes])
  988. OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
  989. OPTIONAL_SSL_LIBS="${SSL_LIBS}"
  990. else
  991. AC_MSG_RESULT([no])
  992. fi
  993. AC_MSG_CHECKING([if JSON-C available for ACLK])
  994. if test "$enable_jsonc" != "yes"; then
  995. AC_MSG_RESULT([no])
  996. can_enable_ng="no"
  997. else
  998. AC_MSG_RESULT([yes])
  999. fi
  1000. AC_MSG_CHECKING([if protobuf available for ACLK New Cloud Protocol])
  1001. if test "${have_libprotobuf}" != "yes"; then
  1002. AC_MSG_RESULT([no])
  1003. can_enable_ng="no"
  1004. else
  1005. AC_MSG_RESULT([yes])
  1006. fi
  1007. AC_MSG_CHECKING([if protoc available for ACLK New Cloud Protocol])
  1008. if test "${have_protoc}" != "yes"; then
  1009. AC_MSG_RESULT([no])
  1010. can_enable_ng="no"
  1011. else
  1012. AC_MSG_RESULT([yes])
  1013. fi
  1014. AC_MSG_CHECKING([if C++ compiler available for ACLK New Cloud Protocol])
  1015. if test "${have_CXX_compiler}" != "yes"; then
  1016. AC_MSG_RESULT([no])
  1017. can_enable_ng="no"
  1018. else
  1019. AC_MSG_RESULT([yes])
  1020. fi
  1021. AC_MSG_CHECKING([ACLK Next Generation can be built])
  1022. AC_MSG_RESULT([${can_enable_ng}])
  1023. if test "$can_enable_ng" = "no" -a "$enable_cloud" = "yes"; then
  1024. AC_MSG_ERROR([You have requested --with-cloud but ACLK can't be built. See reasons in lines above])
  1025. fi
  1026. if test "$can_enable_ng" = "yes"; then
  1027. enable_aclk="yes"
  1028. AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
  1029. OPTIONAL_ACLK_CFLAGS="-I \$(abs_top_srcdir)/mqtt_websockets/src/include -I \$(abs_top_srcdir)/mqtt_websockets/c-rbuf/include -I \$(abs_top_srcdir)/aclk/aclk-schemas"
  1030. OPTIONAL_PROTOBUF_CFLAGS="${PROTOBUF_CFLAGS}"
  1031. OPTIONAL_PROTOBUF_LIBS="${PROTOBUF_LIBS}"
  1032. fi
  1033. fi
  1034. if test "$enable_cloud" = "yes" -a "$enable_aclk" != "yes"; then
  1035. AC_MSG_ERROR([ACLK can't be built but --enable-cloud was requested])
  1036. fi
  1037. AC_SUBST([enable_cloud])
  1038. AC_SUBST([enable_aclk])
  1039. AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
  1040. # -----------------------------------------------------------------------------
  1041. # apps.plugin
  1042. AC_MSG_CHECKING([if apps.plugin should be enabled])
  1043. if test "${build_target}" != "macos"; then
  1044. AC_DEFINE([ENABLE_APPS_PLUGIN], [1], [apps.plugin])
  1045. enable_plugin_apps="yes"
  1046. else
  1047. enable_plugin_apps="no"
  1048. fi
  1049. AC_MSG_RESULT([${enable_plugin_apps}])
  1050. AM_CONDITIONAL([ENABLE_PLUGIN_APPS], [test "${enable_plugin_apps}" = "yes"])
  1051. # -----------------------------------------------------------------------------
  1052. # freeipmi.plugin - libipmimonitoring
  1053. PKG_CHECK_MODULES(
  1054. [IPMIMONITORING],
  1055. [libipmimonitoring],
  1056. [AC_CHECK_LIB([ipmimonitoring], [
  1057. ipmi_monitoring_sensor_readings_by_record_id,
  1058. ipmi_monitoring_sensor_readings_by_sensor_type,
  1059. ipmi_monitoring_sensor_read_sensor_number,
  1060. ipmi_monitoring_sensor_read_sensor_name,
  1061. ipmi_monitoring_sensor_read_sensor_state,
  1062. ipmi_monitoring_sensor_read_sensor_units,
  1063. ipmi_monitoring_sensor_iterator_next,
  1064. ipmi_monitoring_ctx_sensor_config_file,
  1065. ipmi_monitoring_ctx_sdr_cache_directory,
  1066. ipmi_monitoring_ctx_errormsg,
  1067. ipmi_monitoring_ctx_create
  1068. ],
  1069. [AC_CHECK_HEADER(
  1070. [ipmi_monitoring.h],
  1071. [AC_CHECK_HEADER(
  1072. [ipmi_monitoring_bitmasks.h],
  1073. [have_ipmimonitoring=yes],
  1074. [have_ipmimonitoring=no]
  1075. )],
  1076. [have_ipmimonitoring=no]
  1077. )],
  1078. [have_ipmimonitoring=no]
  1079. )],
  1080. [have_ipmimonitoring=no]
  1081. )
  1082. test "${enable_plugin_freeipmi}" = "yes" -a "${have_ipmimonitoring}" != "yes" && \
  1083. AC_MSG_ERROR([ipmimonitoring required but not found. Try installing 'libipmimonitoring-dev' or 'libipmimonitoring-devel'])
  1084. AC_MSG_CHECKING([if freeipmi.plugin should be enabled])
  1085. if test "${enable_plugin_freeipmi}" != "no" -a "${have_ipmimonitoring}" = "yes"; then
  1086. enable_plugin_freeipmi="yes"
  1087. AC_DEFINE([HAVE_FREEIPMI], [1], [ipmimonitoring usability])
  1088. OPTIONAL_IPMIMONITORING_CFLAGS="${IPMIMONITORING_CFLAGS}"
  1089. OPTIONAL_IPMIMONITORING_LIBS="${IPMIMONITORING_LIBS}"
  1090. else
  1091. enable_plugin_freeipmi="no"
  1092. fi
  1093. AC_MSG_RESULT([${enable_plugin_freeipmi}])
  1094. AM_CONDITIONAL([ENABLE_PLUGIN_FREEIPMI], [test "${enable_plugin_freeipmi}" = "yes"])
  1095. # -----------------------------------------------------------------------------
  1096. # systemd-journal.plugin - systemd
  1097. LIBS_BAK="${LIBS}"
  1098. AC_CHECK_LIB([systemd], [sd_journal_open], [have_systemd_libs=yes], [have_systemd_libs=no])
  1099. AC_CHECK_HEADERS([systemd/sd-journal.h], [have_systemd_journal_header=yes], [have_systemd_journal_header=no])
  1100. if test "${have_systemd_libs}" = "yes" -a "${have_systemd_journal_header}" = "yes"; then
  1101. have_systemd="yes"
  1102. else
  1103. have_systemd="no"
  1104. fi
  1105. test "${enable_plugin_systemd_journal}" = "yes" -a "${have_systemd}" != "yes" && \
  1106. AC_MSG_ERROR([systemd is required but not found. Try installing 'libsystemd-dev' or 'libsystemd-devel'])
  1107. AC_MSG_CHECKING([if systemd-journal.plugin should be enabled])
  1108. if test "${enable_plugin_systemd_journal}" != "no" -a "${have_systemd}" = "yes"; then
  1109. enable_plugin_systemd_journal="yes"
  1110. AC_DEFINE([HAVE_SYSTEMD], [1], [systemd usability])
  1111. OPTIONAL_SYSTEMD_CFLAGS="-I/usr/include"
  1112. OPTIONAL_SYSTEMD_LIBS="-lsystemd"
  1113. else
  1114. enable_plugin_systemd_journal="no"
  1115. fi
  1116. AC_MSG_RESULT([${enable_plugin_systemd_journal}])
  1117. AM_CONDITIONAL([ENABLE_PLUGIN_SYSTEMD_JOURNAL], [test "${enable_plugin_systemd_journal}" = "yes"])
  1118. AC_CHECK_LIB([systemd], [sd_journal_open_files_fd], [have_sd_journal_open_files_fd=yes], [have_sd_journal_open_files_fd=no])
  1119. if test "${have_sd_journal_open_files_fd}" = "yes"; then
  1120. AC_DEFINE([HAVE_SD_JOURNAL_OPEN_FILES_FD], [1], [sd_journal_open_files_fd usability])
  1121. fi
  1122. AC_CHECK_LIB([systemd], [sd_journal_restart_fields], [have_sd_journal_restart_fields=yes], [have_sd_journal_restart_fields=no])
  1123. if test "${have_sd_journal_restart_fields}" = "yes"; then
  1124. AC_DEFINE([HAVE_SD_JOURNAL_RESTART_FIELDS], [1], [sd_journal_restart_fields usability])
  1125. fi
  1126. AC_CHECK_LIB([systemd], [sd_journal_get_seqnum], [have_sd_journal_get_seqnum=yes], [have_sd_journal_get_seqnum=no])
  1127. if test "${have_sd_journal_get_seqnum}" = "yes"; then
  1128. AC_DEFINE([HAVE_SD_JOURNAL_GET_SEQNUM], [1], [sd_journal_get_seqnum usability])
  1129. fi
  1130. AC_CHECK_LIB([systemd], [sd_bus_default_system, sd_bus_call_method, sd_bus_message_enter_container, sd_bus_message_read, sd_bus_message_exit_container],
  1131. [SYSTEMD_DBUS_FOUND=yes],
  1132. [SYSTEMD_DBUS_FOUND=no])
  1133. if test "x$SYSTEMD_DBUS_FOUND" = "xyes"; then
  1134. AC_DEFINE([ENABLE_SYSTEMD_DBUS], [1], [libsystemd dbus usability])
  1135. fi
  1136. AC_MSG_NOTICE([OPTIONAL_SYSTEMD_LIBS is set to: ${OPTIONAL_SYSTEMD_LIBS}])
  1137. if test "${enable_plugin_systemd_journal}" = "yes"; then
  1138. AC_MSG_CHECKING([for SD_JOURNAL_OS_ROOT in systemd])
  1139. AC_COMPILE_IFELSE(
  1140. [AC_LANG_PROGRAM(
  1141. [[#include <systemd/sd-journal.h>]],
  1142. [[int x = SD_JOURNAL_OS_ROOT;]]
  1143. )],
  1144. [AC_DEFINE(HAVE_SD_JOURNAL_OS_ROOT, 1, [Define if SD_JOURNAL_OS_ROOT is available])
  1145. AC_MSG_RESULT(yes)],
  1146. [AC_MSG_RESULT(no)]
  1147. )
  1148. fi
  1149. LIBS="${LIBS_BAK}"
  1150. # -----------------------------------------------------------------------------
  1151. # cups.plugin - libcups
  1152. # Only check most recently added method of cups
  1153. AC_CHECK_LIB([cups], [httpConnect2],
  1154. [AC_CHECK_HEADER(
  1155. [cups/cups.h],
  1156. [have_cups=yes],
  1157. [have_cups=no]
  1158. )],
  1159. [have_cups=no]
  1160. )
  1161. test "${enable_plugin_cups}" = "yes" -a "${have_cups}" != "yes" && \
  1162. AC_MSG_ERROR([cups required but not found. Try installing 'cups'])
  1163. AC_ARG_WITH([cups-config],
  1164. [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
  1165. [with_cups_config="$withval"],
  1166. [with_cups_config=system]
  1167. )
  1168. AS_IF([test "x$with_cups_config" != "xsystem"], [
  1169. CUPSCONFIG=$with_cups_config
  1170. ], [
  1171. AC_PATH_TOOL(CUPSCONFIG, [cups-config])
  1172. AS_IF([test -z "$CUPSCONFIG"], [
  1173. have_cups=no
  1174. ])
  1175. ])
  1176. AC_MSG_CHECKING([if cups.plugin should be enabled])
  1177. if test "${enable_plugin_cups}" != "no" -a "${have_cups}" = "yes"; then
  1178. enable_plugin_cups="yes"
  1179. AC_DEFINE([HAVE_CUPS], [1], [cups usability])
  1180. CUPS_CFLAGS="${CUPS_CFLAGS} `$CUPSCONFIG --cflags`"
  1181. CUPS_LIBS="${CUPS_LIBS} `$CUPSCONFIG --libs`"
  1182. OPTIONAL_CUPS_CFLAGS="${CUPS_CFLAGS}"
  1183. OPTIONAL_CUPS_LIBS="${CUPS_LIBS}"
  1184. else
  1185. enable_plugin_cups="no"
  1186. fi
  1187. AC_MSG_RESULT([${enable_plugin_cups}])
  1188. AM_CONDITIONAL([ENABLE_PLUGIN_CUPS], [test "${enable_plugin_cups}" = "yes"])
  1189. # -----------------------------------------------------------------------------
  1190. # nfacct.plugin - libmnl, libnetfilter_acct
  1191. AC_CHECK_HEADER(
  1192. [linux/netfilter/nfnetlink_conntrack.h],
  1193. [AC_CHECK_DECL(
  1194. [CTA_STATS_MAX],
  1195. [have_nfnetlink_conntrack=yes],
  1196. [have_nfnetlink_conntrack=no],
  1197. [#include <linux/netfilter/nfnetlink_conntrack.h>]
  1198. )],
  1199. [have_nfnetlink_conntrack=no]
  1200. )
  1201. LIBS_BAK="${LIBS}"
  1202. LIBS="${LIBS} -lmnl"
  1203. PKG_CHECK_MODULES(
  1204. [LIBMNL],
  1205. [libmnl],
  1206. [AC_CHECK_LIB(
  1207. [mnl],
  1208. [mnl_socket_open],
  1209. [have_libmnl=yes],
  1210. [have_libmnl=no]
  1211. )],
  1212. [have_libmnl=no]
  1213. )
  1214. LIBS="${LIBS}"
  1215. PKG_CHECK_MODULES(
  1216. [NFACCT],
  1217. [libnetfilter_acct],
  1218. AC_SEARCH_LIBS(
  1219. [nfacct_alloc],
  1220. [netfilter_acct libnetfilter_acct],
  1221. [have_libnetfilter_acct=yes],
  1222. [have_libnetfilter_acct=no],
  1223. [${LIBS} -L/libnetfilter-acct-static/lib/libnetfilter_acct.a]
  1224. )],
  1225. [have_libnetfilter_acct=no]
  1226. )
  1227. LIBS="${LIBS_BAK}"
  1228. test "${enable_plugin_nfacct}" = "yes" -a "${have_nfnetlink_conntrack}" != "yes" && \
  1229. AC_MSG_ERROR([nfnetlink_conntrack.h required but not found or too old])
  1230. test "${enable_plugin_nfacct}" = "yes" -a "${have_libnetfilter_acct}" != "yes" && \
  1231. AC_MSG_ERROR([netfilter_acct required but not found])
  1232. test "${enable_plugin_nfacct}" = "yes" -a "${have_libmnl}" != "yes" && \
  1233. AC_MSG_ERROR([libmnl required but not found. Try installing 'libmnl-dev' or 'libmnl-devel'])
  1234. AC_MSG_CHECKING([if nfacct.plugin should be enabled])
  1235. if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes" \
  1236. -a "${have_libmnl}" = "yes" \
  1237. -a "${have_nfnetlink_conntrack}" = "yes"; then
  1238. enable_plugin_nfacct="yes"
  1239. AC_DEFINE([HAVE_NFACCT], [1], [netfilter accounting usability])
  1240. OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
  1241. OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
  1242. else
  1243. enable_plugin_nfacct="no"
  1244. fi
  1245. AC_MSG_RESULT([${enable_plugin_nfacct}])
  1246. AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"])
  1247. # -----------------------------------------------------------------------------
  1248. # xenstat.plugin - libxenstat
  1249. PKG_CHECK_MODULES(
  1250. [YAJL],
  1251. [yajl],
  1252. [AC_CHECK_LIB(
  1253. [yajl],
  1254. [yajl_tree_get],
  1255. [have_libyajl=yes],
  1256. [have_libyajl=no]
  1257. )],
  1258. [have_libyajl=no]
  1259. )
  1260. AC_CHECK_LIB(
  1261. [xenstat],
  1262. [xenstat_init],
  1263. [AC_CHECK_HEADER(
  1264. [xenstat.h],
  1265. [have_libxenstat=yes],
  1266. [have_libxenstat=no]
  1267. )],
  1268. [have_libxenstat=no],
  1269. [-lyajl]
  1270. )
  1271. PKG_CHECK_MODULES(
  1272. [XENLIGHT],
  1273. [xenlight],
  1274. [AC_CHECK_LIB(
  1275. [xenlight],
  1276. [libxl_domain_info],
  1277. [AC_CHECK_HEADER(
  1278. [libxl.h],
  1279. [have_libxenlight=yes],
  1280. [have_libxenlight=no]
  1281. )],
  1282. [have_libxenlight=no]
  1283. )],
  1284. [have_libxenlight=no]
  1285. )
  1286. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenstat}" != "yes" && \
  1287. AC_MSG_ERROR([libxenstat required but not found. try installing 'xen-dom0-libs-devel'])
  1288. test "${enable_plugin_xenstat}" = "yes" -a "${have_libxenlight}" != "yes" && \
  1289. AC_MSG_ERROR([libxenlight required but not found. try installing 'xen-dom0-libs-devel'])
  1290. test "${enable_plugin_xenstat}" = "yes" -a "${have_libyajl}" != "yes" && \
  1291. AC_MSG_ERROR([libyajl required but not found. Try installing 'yajl-devel'])
  1292. AC_MSG_CHECKING([if xenstat.plugin should be enabled])
  1293. if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
  1294. enable_plugin_xenstat="yes"
  1295. AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
  1296. OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
  1297. OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
  1298. else
  1299. enable_plugin_xenstat="no"
  1300. fi
  1301. AC_MSG_RESULT([${enable_plugin_xenstat}])
  1302. AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"])
  1303. if test "${enable_plugin_xenstat}" == "yes"; then
  1304. AC_MSG_CHECKING([for xenstat_vbd_error in -lxenstat])
  1305. AC_TRY_LINK(
  1306. [ #include <xenstat.h> ],
  1307. [
  1308. xenstat_vbd * vbd;
  1309. int out = xenstat_vbd_error(vbd);
  1310. ],
  1311. [
  1312. have_xenstat_vbd_error=yes
  1313. AC_DEFINE([HAVE_XENSTAT_VBD_ERROR], [1], [xenstat_vbd_error usability])
  1314. ],
  1315. [ have_xenstat_vbd_error=no ]
  1316. )
  1317. AC_MSG_RESULT([${have_xenstat_vbd_error}])
  1318. fi
  1319. # -----------------------------------------------------------------------------
  1320. # perf.plugin
  1321. AC_CHECK_HEADER(
  1322. [linux/perf_event.h],
  1323. [AC_CHECK_DECL(
  1324. [PERF_COUNT_HW_REF_CPU_CYCLES],
  1325. [have_perf_event=yes],
  1326. [have_perf_event=no],
  1327. [#include <linux/perf_event.h>]
  1328. )],
  1329. [have_perf_event=no]
  1330. )
  1331. AC_MSG_CHECKING([if perf.plugin should be enabled])
  1332. if test "${build_target}" == "linux" -a "${have_perf_event}" = "yes"; then
  1333. AC_DEFINE([ENABLE_PERF_PLUGIN], [1], [perf.plugin])
  1334. enable_plugin_perf="yes"
  1335. else
  1336. enable_plugin_perf="no"
  1337. fi
  1338. AC_MSG_RESULT([${enable_plugin_perf}])
  1339. AM_CONDITIONAL([ENABLE_PLUGIN_PERF], [test "${enable_plugin_perf}" = "yes"])
  1340. # -----------------------------------------------------------------------------
  1341. # gtest/gmock
  1342. if test "${enable_gtests}" = "yes"; then
  1343. AC_MSG_CHECKING([if gtest can be found])
  1344. PKG_CHECK_MODULES([GTEST], [gtest], [have_gtest=yes], [have_gtest=no])
  1345. if test "${have_gtest}" = "yes"; then
  1346. OPTIONAL_GTEST_CFLAGS="${GTEST_CFLAGS}"
  1347. OPTIONAL_GTEST_LIBS="${GTEST_LIBS}"
  1348. AC_DEFINE([HAVE_GTEST], [1], [gtest availability])
  1349. fi
  1350. fi
  1351. # -----------------------------------------------------------------------------
  1352. # ml - anomaly detection
  1353. # Check if uuid is available. Fail if ML was explicitly requested.
  1354. if test "${enable_ml}" = "yes" -a "${have_uuid}" != "yes"; then
  1355. AC_MSG_ERROR([You have explicitly requested --enable-ml functionality but libuuid can not be found.])
  1356. fi
  1357. # Check if submodules have not been fetched. Fail if ML was explicitly requested.
  1358. AC_MSG_CHECKING([if git submodules are present for machine learning functionality])
  1359. if test -f "ml/dlib/dlib/all/source.cpp"; then
  1360. AC_MSG_RESULT([yes])
  1361. have_ml_submodules="yes"
  1362. AC_DEFINE([HAVE_DLIB], [1], [dlib availability])
  1363. else
  1364. AC_MSG_RESULT([no])
  1365. have_ml_submodules="no"
  1366. fi
  1367. if test "${enable_ml}" = "yes" -a "${have_ml_submodules}" = "no"; then
  1368. AC_MSG_ERROR([You have explicitly requested --enable-ml functionality but it cannot be built because the required git submodules are missing.])
  1369. fi
  1370. if test "${enable_ml}" = "yes" -a "${have_cxx11}" = "no"; then
  1371. AC_MSG_ERROR([You have explicitly requested --enable-ml functionality but it cannot be built without a C++11 toolchain.])
  1372. fi
  1373. # Decide if we should build ML
  1374. if test "${enable_ml}" != "no" -a "${have_ml_submodules}" = "yes" -a "${have_cxx11}" = "yes" -a "${have_uuid}" = "yes"; then
  1375. build_ml="yes"
  1376. else
  1377. build_ml="no"
  1378. fi
  1379. AM_CONDITIONAL([ENABLE_ML], [test "${build_ml}" = "yes"])
  1380. if test "${build_ml}" = "yes"; then
  1381. AC_DEFINE([ENABLE_ML], [1], [anomaly detection usability])
  1382. OPTIONAL_ML_CFLAGS="-DDLIB_NO_GUI_SUPPORT -I \$(abs_top_srcdir)/ml/dlib"
  1383. OPTIONAL_ML_LIBS=""
  1384. fi
  1385. # -----------------------------------------------------------------------------
  1386. # logsmanagement
  1387. LIBS_BAK="${LIBS}"
  1388. # Check if submodules have not been fetched. Fail if Logs Management was explicitly requested.
  1389. AC_MSG_CHECKING([if git submodules are present for logs management functionality])
  1390. if test -f "fluent-bit/CMakeLists.txt"; then
  1391. AC_MSG_RESULT([yes])
  1392. have_logsmanagement_submodules="yes"
  1393. else
  1394. AC_MSG_RESULT([no])
  1395. have_logsmanagement_submodules="no"
  1396. fi
  1397. if test "${enable_logsmanagement}" != "no" -a "${have_logsmanagement_submodules}" = "no"; then
  1398. AC_MSG_WARN([Logs management cannot be built because the required git submodules are missing.])
  1399. fi
  1400. if test "${enable_logsmanagement}" != "no" -a "x$CAN_USE_DLSYM" = xno; then
  1401. AC_MSG_WARN([Logs management cannot be built because dlsym cannot be used.])
  1402. fi
  1403. # Decide if we should build Logs Management
  1404. if test "${enable_logsmanagement}" != "no" -a "${have_logsmanagement_submodules}" = "yes" -a "x$CAN_USE_DLSYM" = xyes; then
  1405. build_logsmanagement="yes"
  1406. else
  1407. build_logsmanagement="no"
  1408. fi
  1409. AM_CONDITIONAL([ENABLE_LOGSMANAGEMENT], [test "${build_logsmanagement}" = "yes"])
  1410. if test "${build_logsmanagement}" = "yes"; then
  1411. AC_DEFINE([ENABLE_LOGSMANAGEMENT], [1], [enable logs management functionality])
  1412. fi
  1413. # Decide if we should build Logs Management tests.
  1414. if test "${build_logsmanagement}" = "yes" -a "${enable_logsmanagement_tests}" = "yes"; then
  1415. build_logsmanagement_tests="yes"
  1416. else
  1417. build_logsmanagement_tests="no"
  1418. fi
  1419. AM_CONDITIONAL([ENABLE_LOGSMANAGEMENT_TESTS], [test "${build_logsmanagement_tests}" = "yes"])
  1420. if test "${build_logsmanagement_tests}" = "yes"; then
  1421. AC_DEFINE([ENABLE_LOGSMANAGEMENT_TESTS], [1], [logs management tests])
  1422. fi
  1423. LIBS="${LIBS_BAK}"
  1424. # -----------------------------------------------------------------------------
  1425. # debugfs.plugin
  1426. if test "${build_target}" = "linux"; then
  1427. AC_DEFINE([ENABLE_DEBUGFS_PLUGIN], [1], [debugfs.plugin])
  1428. enable_plugin_debugfs="yes"
  1429. else
  1430. enable_plugin_debugfs="no"
  1431. fi
  1432. AC_MSG_CHECKING([if debugfs.plugin should be enabled])
  1433. AC_MSG_RESULT([${enable_plugin_debugfs}])
  1434. AM_CONDITIONAL([ENABLE_PLUGIN_DEBUGFS], [test "${enable_plugin_debugfs}" = "yes"])
  1435. # -----------------------------------------------------------------------------
  1436. # ebpf.plugin
  1437. if test "${build_target}" = "linux" -a "${enable_ebpf}" != "no"; then
  1438. PKG_CHECK_MODULES(
  1439. [LIBELF],
  1440. [libelf],
  1441. [have_libelf=yes],
  1442. [have_libelf=no]
  1443. )
  1444. AC_CHECK_TYPE(
  1445. [struct bpf_prog_info],
  1446. [have_bpf=yes],
  1447. [have_bpf=no],
  1448. [#include <linux/bpf.h>]
  1449. )
  1450. AC_CHECK_FILE(
  1451. externaldeps/libbpf/libbpf.a,
  1452. [have_libbpf=yes],
  1453. [have_libbpf=no]
  1454. )
  1455. if test "${have_libelf}" = "yes" -a \
  1456. "${have_bpf}" = "yes" -a \
  1457. "${have_libbpf}" = "yes"; then
  1458. OPTIONAL_BPF_CFLAGS="${LIBELF_CFLAGS} -I \$(abs_top_srcdir)/externaldeps/libbpf/include -I \$(abs_top_srcdir)/externaldeps/libbpf/include/uapi"
  1459. OPTIONAL_BPF_LIBS="\$(abs_top_srcdir)/externaldeps/libbpf/libbpf.a ${LIBELF_LIBS}"
  1460. AC_DEFINE([HAVE_LIBBPF], [1], [libbpf usability])
  1461. enable_ebpf="yes"
  1462. else
  1463. enable_ebpf="no"
  1464. fi
  1465. else
  1466. enable_ebpf="no"
  1467. fi
  1468. AC_MSG_CHECKING([if ebpf.plugin should be enabled])
  1469. AC_MSG_RESULT([${enable_ebpf}])
  1470. AM_CONDITIONAL([ENABLE_PLUGIN_EBPF], [test "${enable_ebpf}" = "yes"])
  1471. # -----------------------------------------------------------------------------
  1472. # slabinfo.plugin
  1473. AC_MSG_CHECKING([if slabinfo.plugin should be enabled])
  1474. if test "${build_target}" == "linux"; then
  1475. AC_DEFINE([ENABLE_SLABINFO], [1], [slabinfo plugin])
  1476. enable_plugin_slabinfo="yes"
  1477. else
  1478. enable_plugin_slabinfo="no"
  1479. fi
  1480. AC_MSG_RESULT([${enable_plugin_slabinfo}])
  1481. AM_CONDITIONAL([ENABLE_PLUGIN_SLABINFO], [test "${enable_plugin_slabinfo}" = "yes"])
  1482. # -----------------------------------------------------------------------------
  1483. # AWS Kinesis exporting connector - libaws-cpp-sdk-kinesis, libaws-cpp-sdk-core, libssl, libcrypto, libcurl
  1484. PKG_CHECK_MODULES(
  1485. [LIBCRYPTO],
  1486. [libcrypto],
  1487. [AC_CHECK_LIB(
  1488. [crypto],
  1489. [CRYPTO_new_ex_data],
  1490. [have_libcrypto=yes],
  1491. [have_libcrypto=no]
  1492. )],
  1493. [have_libcrypto=no]
  1494. )
  1495. PKG_CHECK_MODULES(
  1496. [LIBSSL],
  1497. [libssl],
  1498. [AC_CHECK_LIB(
  1499. [ssl],
  1500. [SSL_connect],
  1501. [have_libssl=yes],
  1502. [have_libssl=no]
  1503. )],
  1504. [have_libssl=no]
  1505. )
  1506. PKG_CHECK_MODULES(
  1507. [AWS_CPP_SDK_CORE],
  1508. [aws-cpp-sdk-core],
  1509. [have_libaws_cpp_sdk_core=yes],
  1510. [have_libaws_cpp_sdk_core=no]
  1511. )
  1512. PKG_CHECK_MODULES(
  1513. [AWS_CPP_SDK_KINESIS],
  1514. [aws-cpp-sdk-kinesis],
  1515. [have_libaws_cpp_sdk_kinesis=yes],
  1516. [have_libaws_cpp_sdk_kinesis=no]
  1517. )
  1518. test "${enable_exporting_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_kinesis}" != "yes" && \
  1519. AC_MSG_ERROR([libaws-cpp-sdk-kinesis required but not found. try installing AWS C++ SDK])
  1520. test "${enable_exporting_kinesis}" = "yes" -a "${have_libaws_cpp_sdk_core}" != "yes" && \
  1521. AC_MSG_ERROR([libaws-cpp-sdk-core required but not found. try installing AWS C++ SDK])
  1522. test "${enable_exporting_kinesis}" = "yes" -a "${have_libcurl}" != "yes" && \
  1523. AC_MSG_ERROR([libcurl required but not found])
  1524. test "${enable_exporting_kinesis}" = "yes" -a "${have_libssl}" != "yes" && \
  1525. AC_MSG_ERROR([libssl required but not found])
  1526. test "${enable_exporting_kinesis}" = "yes" -a "${have_libcrypto}" != "yes" && \
  1527. AC_MSG_ERROR([libcrypto required but not found])
  1528. AC_MSG_CHECKING([if kinesis exporting connector should be enabled])
  1529. if test "${enable_exporting_kinesis}" != "no" -a "${have_libaws_cpp_sdk_kinesis}" = "yes" \
  1530. -a "${have_libaws_cpp_sdk_core}" = "yes" \
  1531. -a "${have_libcurl}" = "yes" \
  1532. -a "${have_libssl}" = "yes" \
  1533. -a "${have_libcrypto}" = "yes"; then
  1534. enable_exporting_kinesis="yes"
  1535. AC_DEFINE([HAVE_KINESIS], [1], [libaws-cpp-sdk-kinesis usability])
  1536. OPTIONAL_KINESIS_CFLAGS="${LIBCRYPTO_CFLAGS} ${LIBSSL_CFLAGS} ${LIBCURL_CFLAGS}"
  1537. OPTIONAL_KINESIS_CXXFLAGS="${AWS_CPP_SDK_KINESIS_CFLAGS} ${AWS_CPP_SDK_CORE_CFLAGS}"
  1538. OPTIONAL_KINESIS_LIBS="${AWS_CPP_SDK_KINESIS_LIBS} ${AWS_CPP_SDK_CORE_LIBS} \
  1539. ${LIBCRYPTO_LIBS} ${LIBSSL_LIBS} ${LIBCURL_LIBS}"
  1540. else
  1541. enable_exporting_kinesis="no"
  1542. fi
  1543. AC_MSG_RESULT([${enable_exporting_kinesis}])
  1544. AM_CONDITIONAL([ENABLE_EXPORTING_KINESIS], [test "${enable_exporting_kinesis}" = "yes"])
  1545. # -----------------------------------------------------------------------------
  1546. # Pub/Sub exporting connector - googleapis
  1547. PKG_CHECK_MODULES(
  1548. [GRPC],
  1549. [grpc],
  1550. [have_libgrpc=yes],
  1551. [have_libgrpc=no]
  1552. )
  1553. if test "${enable_exporting_pubsub}" != "no"; then
  1554. PKG_CHECK_MODULES(
  1555. [PUBSUB],
  1556. [google_cloud_cpp_pubsub_protos],
  1557. [have_pubsub_protos=yes],
  1558. [have_pubsub_protos=no]
  1559. )
  1560. fi
  1561. AC_PATH_PROG([CXX_BINARY], [${CXX}], [no])
  1562. AS_IF(
  1563. [test x"${CXX_BINARY}" == x"no"],
  1564. [have_CXX_compiler=no],
  1565. [have_CXX_compiler=yes]
  1566. )
  1567. test "${enable_pubsub}" = "yes" -a "${have_grpc}" != "yes" && \
  1568. AC_MSG_ERROR([libgrpc required but not found. try installing grpc])
  1569. test "${enable_pubsub}" = "yes" -a "${have_pubsub_protos}" != "yes" && \
  1570. AC_MSG_ERROR([libgoogleapis_cpp_pubsub_protos required but not found. try installing googleapis])
  1571. test "${enable_exporting_prometheus_remote_write}" = "yes" -a "${have_CXX_compiler}" != "yes" && \
  1572. AC_MSG_ERROR([C++ compiler required but not found. try installing g++])
  1573. AC_MSG_CHECKING([if pubsub exporting connector should be enabled])
  1574. if test "${enable_exporting_pubsub}" != "no" -a "${have_pubsub_protos}" = "yes" -a "${have_CXX_compiler}" = "yes"; then
  1575. enable_exporting_pubsub="yes"
  1576. AC_DEFINE([ENABLE_EXPORTING_PUBSUB], [1], [Pub/Sub API usability])
  1577. OPTIONAL_PUBSUB_CFLAGS="${GRPC_CFLAGS} ${PUBSUB_CFLAGS}"
  1578. OPTIONAL_PUBSUB_LIBS="${GRPC_LIBS} ${PUBSUB_LIBS}"
  1579. else
  1580. enable_pubsub="no"
  1581. fi
  1582. AC_MSG_RESULT([${enable_exporting_pubsub}])
  1583. AM_CONDITIONAL([ENABLE_EXPORTING_PUBSUB], [test "${enable_exporting_pubsub}" = "yes"])
  1584. # -----------------------------------------------------------------------------
  1585. # Prometheus remote write exporting connector - libprotobuf, libsnappy, protoc
  1586. AC_MSG_CHECKING([for snappy::RawCompress in -lsnappy])
  1587. AC_LANG_SAVE
  1588. AC_LANG_CPLUSPLUS
  1589. save_LIBS="${LIBS}"
  1590. LIBS="-lsnappy"
  1591. save_CXXFLAGS="${CXXFLAGS}"
  1592. CXXFLAGS="${CXXFLAGS} ${CPP_STD_FLAG}"
  1593. AC_TRY_LINK(
  1594. [
  1595. #include <stdlib.h>
  1596. #include <snappy.h>
  1597. ],
  1598. [
  1599. const char *input = "test";
  1600. size_t compressed_length;
  1601. char *buffer = (char *)malloc(5 * sizeof(char));
  1602. snappy::RawCompress(input, 4, buffer, &compressed_length);
  1603. free(buffer);
  1604. ],
  1605. [
  1606. have_libsnappy=yes
  1607. SNAPPY_CFLAGS=""
  1608. SNAPPY_LIBS="-lsnappy"
  1609. ],
  1610. [have_libsnappy=no]
  1611. )
  1612. LIBS="${save_LIBS}"
  1613. CXXFLAGS="${save_CXXFLAGS}"
  1614. AC_LANG_RESTORE
  1615. AC_MSG_RESULT([${have_libsnappy}])
  1616. test "${enable_exporting_prometheus_remote_write}" = "yes" -a "${have_libprotobuf}" != "yes" && \
  1617. AC_MSG_ERROR([libprotobuf required but not found. try installing protobuf])
  1618. test "${enable_exporting_prometheus_remote_write}" = "yes" -a "${have_libsnappy}" != "yes" && \
  1619. AC_MSG_ERROR([libsnappy required but not found. try installing snappy])
  1620. test "${enable_exporting_prometheus_remote_write}" = "yes" -a "${have_protoc}" != "yes" && \
  1621. AC_MSG_ERROR([protoc compiler required but not found. try installing protobuf])
  1622. test "${enable_exporting_prometheus_remote_write}" = "yes" -a "${have_CXX_compiler}" != "yes" && \
  1623. AC_MSG_ERROR([C++ compiler required but not found. try installing g++])
  1624. AC_MSG_CHECKING([if prometheus remote write exporting connector should be enabled])
  1625. if test "${enable_exporting_prometheus_remote_write}" != "no" -a "${have_libprotobuf}" = "yes" -a "${have_libsnappy}" = "yes" \
  1626. -a "${have_protoc}" = "yes" -a "${have_CXX_compiler}" = "yes"; then
  1627. enable_exporting_prometheus_remote_write="yes"
  1628. AC_DEFINE([ENABLE_PROMETHEUS_REMOTE_WRITE], [1], [Prometheus remote write API usability])
  1629. OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS="${SNAPPY_CFLAGS} -I \$(abs_top_srcdir)/exporting/prometheus/remote_write"
  1630. OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS="${SNAPPY_LIBS}"
  1631. OPTIONAL_PROTOBUF_CFLAGS="${PROTOBUF_CFLAGS}"
  1632. OPTIONAL_PROTOBUF_LIBS="${PROTOBUF_LIBS}"
  1633. else
  1634. enable_exporting_prometheus_remote_write="no"
  1635. fi
  1636. AC_MSG_RESULT([${enable_exporting_prometheus_remote_write}])
  1637. AM_CONDITIONAL([ENABLE_EXPORTING_PROMETHEUS_REMOTE_WRITE], [test "${enable_exporting_prometheus_remote_write}" = "yes"])
  1638. # -----------------------------------------------------------------------------
  1639. # MongoDB exporting connector - libmongoc
  1640. PKG_CHECK_MODULES(
  1641. [LIBMONGOC],
  1642. [libmongoc-1.0 >= 1.7],
  1643. [have_libmongoc=yes],
  1644. [have_libmongoc=no]
  1645. )
  1646. test "${enable_exporting_mongodb}" = "yes" -a "${have_libmongoc}" != "yes" && \
  1647. AC_MSG_ERROR([libmongoc required but not found. Try installing `mongoc`.])
  1648. AC_MSG_CHECKING([if mongodb exporting connector should be enabled])
  1649. if test "${enable_exporting_mongodb}" != "no" -a "${have_libmongoc}" = "yes"; then
  1650. enable_exporting_mongodb="yes"
  1651. AC_DEFINE([HAVE_MONGOC], [1], [libmongoc usability])
  1652. OPTIONAL_MONGOC_CFLAGS="${LIBMONGOC_CFLAGS}"
  1653. OPTIONAL_MONGOC_LIBS="${LIBMONGOC_LIBS}"
  1654. else
  1655. enable_exporting_mongodb="no"
  1656. fi
  1657. AC_MSG_RESULT([${enable_exporting_mongodb}])
  1658. AM_CONDITIONAL([ENABLE_EXPORTING_MONGODB], [test "${enable_exporting_mongodb}" = "yes"])
  1659. # -----------------------------------------------------------------------------
  1660. # check for setns() - cgroup-network
  1661. AC_CHECK_FUNC([setns])
  1662. AC_MSG_CHECKING([if cgroup-network can be enabled])
  1663. if test "$ac_cv_func_setns" = "yes" ; then
  1664. have_setns="yes"
  1665. AC_DEFINE([HAVE_SETNS], [1], [Define 1 if you have setns() function])
  1666. else
  1667. have_setns="no"
  1668. fi
  1669. AC_MSG_RESULT([${have_setns}])
  1670. AM_CONDITIONAL([ENABLE_PLUGIN_CGROUP_NETWORK], [test "${have_setns}" = "yes"])
  1671. # -----------------------------------------------------------------------------
  1672. # Link-Time-Optimization
  1673. if test "${enable_lto}" != "no"; then
  1674. opt="-flto"
  1675. AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no])
  1676. fi
  1677. if test "${have_lto}" = "yes"; then
  1678. oCFLAGS="${CFLAGS}"
  1679. CFLAGS="${CFLAGS} -flto"
  1680. ac_cv_c_lto_cross_compile="${enable_lto}"
  1681. test "${ac_cv_c_lto_cross_compile}" != "yes" && ac_cv_c_lto_cross_compile="no"
  1682. AC_C_LTO
  1683. CFLAGS="${oCFLAGS}"
  1684. test "${ac_cv_c_lto}" != "yes" && have_lto="no"
  1685. fi
  1686. test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \
  1687. AC_MSG_ERROR([LTO is required but is not available.])
  1688. AC_MSG_CHECKING([if LTO should be enabled])
  1689. if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then
  1690. enable_lto="yes"
  1691. OPTIONAL_LTO_CFLAGS="-flto"
  1692. else
  1693. enable_lto="no"
  1694. fi
  1695. AC_MSG_RESULT([${enable_lto}])
  1696. # -----------------------------------------------------------------------------
  1697. # Try to unconditionally link with -latomic. If the compiler can satisfy
  1698. # all the atomic ops with builtins then, the library will be left unused.
  1699. # Otherwise, some ops will be covered by the compiler's intrinsics and some
  1700. # will be picked up by the linker from -latomic. In the later case, if
  1701. # -latomic is not available there will be a build failure, which would
  1702. # have happened either way before this change.
  1703. AC_LANG_PUSH([C++])
  1704. AC_MSG_CHECKING(whether we can use -latomic)
  1705. OLD_LIBS="${LIBS}"
  1706. LIBS="-latomic"
  1707. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  1708. #include <atomic>
  1709. #include <cstdint>
  1710. std::atomic<std::int64_t> v;
  1711. int main() {
  1712. return v;
  1713. }
  1714. ]])], CAN_USE_LIBATOMIC=yes, CAN_USE_LIBATOMIC=no)
  1715. LIBS="${OLD_LIBS}"
  1716. AC_MSG_RESULT($CAN_USE_LIBATOMIC)
  1717. if test "x$CAN_USE_LIBATOMIC" = xyes; then
  1718. OPTIONAL_ATOMIC_LIBS="-latomic"
  1719. fi
  1720. AC_SUBST([OPTIONAL_ATOMIC_LIBS])
  1721. AC_LANG_POP([C++])
  1722. # -----------------------------------------------------------------------------
  1723. AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
  1724. varlibdir="${localstatedir}/lib/netdata"
  1725. registrydir="${localstatedir}/lib/netdata/registry"
  1726. cachedir="${localstatedir}/cache/netdata"
  1727. chartsdir="${libexecdir}/netdata/charts.d"
  1728. pythondir="${libexecdir}/netdata/python.d"
  1729. configdir="${sysconfdir}/netdata"
  1730. libconfigdir="${libdir}/netdata/conf.d"
  1731. logdir="${localstatedir}/log/netdata"
  1732. pluginsdir="${libexecdir}/netdata/plugins.d"
  1733. netdata_user="${with_user}"
  1734. libsysdir="${libdir}/netdata/system"
  1735. AC_SUBST([varlibdir])
  1736. AC_SUBST([registrydir])
  1737. AC_SUBST([cachedir])
  1738. AC_SUBST([chartsdir])
  1739. AC_SUBST([pythondir])
  1740. AC_SUBST([configdir])
  1741. AC_SUBST([libconfigdir])
  1742. AC_SUBST([logdir])
  1743. AC_SUBST([pluginsdir])
  1744. AC_SUBST([webdir])
  1745. AC_SUBST([netdata_user])
  1746. AC_SUBST([libsysdir])
  1747. CFLAGS="${originalCFLAGS} ${OPTIONAL_LTO_CFLAGS} ${OPTIONAL_PROTOBUF_CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} \
  1748. ${ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
  1749. ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
  1750. ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PUBSUB_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} \
  1751. ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_YAML_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${JUDY_CFLAGS} \
  1752. ${OPTIONAL_ACLK_CFLAGS} ${OPTIONAL_ML_CFLAGS} ${OPTIONAL_OS_DEP_CFLAGS} ${H2O_CFLAGS} ${HARDENING_CFLAGS}"
  1753. CXXFLAGS="${CFLAGS} ${OPTIONAL_KINESIS_CXXFLAGS} ${CPP_STD_FLAG}"
  1754. CPPFLAGS="\
  1755. -DVARLIB_DIR=\"\\\"${varlibdir}\\\"\" \
  1756. -DCACHE_DIR=\"\\\"${cachedir}\\\"\" \
  1757. -DCONFIG_DIR=\"\\\"${configdir}\\\"\" \
  1758. -DLIBCONFIG_DIR=\"\\\"${libconfigdir}\\\"\" \
  1759. -DLOG_DIR=\"\\\"${logdir}\\\"\" \
  1760. -DPLUGINS_DIR=\"\\\"${pluginsdir}\\\"\" \
  1761. -DRUN_DIR=\"\\\"${localstatedir}/run/netdata\\\"\" \
  1762. -DWEB_DIR=\"\\\"${webdir}\\\"\" \
  1763. "
  1764. AC_SUBST([OPTIONAL_MATH_CFLAGS])
  1765. AC_SUBST([OPTIONAL_MATH_LIBS])
  1766. AC_SUBST([OPTIONAL_DATACHANNEL_LIBS])
  1767. AC_SUBST([OPTIONAL_UV_LIBS])
  1768. AC_SUBST([OPTIONAL_LZ4_LIBS])
  1769. AC_SUBST([OPTIONAL_BROTLIENC_LIBS])
  1770. AC_SUBST([OPTIONAL_BROTLIDEC_LIBS])
  1771. AC_SUBST([OPTIONAL_YAML_LIBS])
  1772. AC_SUBST([OPTIONAL_CURL_LIBS])
  1773. AC_SUBST([OPTIONAL_PCRE2_LIBS])
  1774. AC_SUBST([OPTIONAL_ZSTD_LIBS])
  1775. AC_SUBST([OPTIONAL_SSL_LIBS])
  1776. AC_SUBST([OPTIONAL_JSONC_LIBS])
  1777. AC_SUBST([OPTIONAL_YAML_LIBS])
  1778. AC_SUBST([OPTIONAL_NFACCT_CFLAGS])
  1779. AC_SUBST([OPTIONAL_NFACCT_LIBS])
  1780. AC_SUBST([ZLIB_CFLAGS])
  1781. AC_SUBST([ZLIB_LIBS])
  1782. AC_SUBST([OPTIONAL_UUID_CFLAGS])
  1783. AC_SUBST([OPTIONAL_UUID_LIBS])
  1784. AC_SUBST([OPTIONAL_BPF_CFLAGS])
  1785. AC_SUBST([OPTIONAL_BPF_LIBS])
  1786. AC_SUBST([OPTIONAL_MQTT_LIBS])
  1787. AC_SUBST([OPTIONAL_LIBCAP_CFLAGS])
  1788. AC_SUBST([OPTIONAL_LIBCAP_LIBS])
  1789. AC_SUBST([OPTIONAL_IPMIMONITORING_CFLAGS])
  1790. AC_SUBST([OPTIONAL_IPMIMONITORING_LIBS])
  1791. AC_SUBST([OPTIONAL_CUPS_CFLAGS])
  1792. AC_SUBST([OPTIONAL_CUPS_LIBS])
  1793. AC_SUBST([OPTIONAL_XENSTAT_CFLAGS])
  1794. AC_SUBST([OPTIONAL_XENSTAT_LIBS])
  1795. AC_SUBST([OPTIONAL_KINESIS_CFLAGS])
  1796. AC_SUBST([OPTIONAL_KINESIS_LIBS])
  1797. AC_SUBST([OPTIONAL_PUBSUB_CFLAGS])
  1798. AC_SUBST([OPTIONAL_PUBSUB_LIBS])
  1799. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS])
  1800. AC_SUBST([OPTIONAL_PROMETHEUS_REMOTE_WRITE_LIBS])
  1801. AC_SUBST([OPTIONAL_MONGOC_CFLAGS])
  1802. AC_SUBST([OPTIONAL_MONGOC_LIBS])
  1803. AC_SUBST([OPTIONAL_LWS_LIBS])
  1804. AC_SUBST([OPTIONAL_ACLK_CFLAGS])
  1805. AC_SUBST([OPTIONAL_PROTOBUF_CFLAGS])
  1806. AC_SUBST([OPTIONAL_PROTOBUF_LIBS])
  1807. AC_SUBST([OPTIONAL_GTEST_CFLAGS])
  1808. AC_SUBST([OPTIONAL_GTEST_LIBS])
  1809. AC_SUBST([OPTIONAL_ML_CFLAGS])
  1810. AC_SUBST([OPTIONAL_ML_LIBS])
  1811. AC_SUBST(OPTIONAL_SYSTEMD_LIBS)
  1812. # -----------------------------------------------------------------------------
  1813. # Check if cmocka is available - needed for unit testing
  1814. AC_ARG_ENABLE(
  1815. [unit-tests],
  1816. [AS_HELP_STRING([--disable-unit-tests],
  1817. [Disables building and running the unit tests suite])],
  1818. [],
  1819. [enable_unit_tests="yes"]
  1820. )
  1821. PKG_CHECK_MODULES(
  1822. [CMOCKA],
  1823. [cmocka],
  1824. [have_cmocka="yes"],
  1825. [AC_MSG_NOTICE([CMocka not found on the system. Unit tests disabled])]
  1826. )
  1827. AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ])
  1828. AC_SUBST([ENABLE_UNITTESTS])
  1829. TEST_CFLAGS="${CFLAGS} ${CMOCKA_CFLAGS}"
  1830. TEST_LIBS="${CMOCKA_LIBS}"
  1831. AC_SUBST([TEST_CFLAGS])
  1832. AC_SUBST([TEST_LIBS])
  1833. # -----------------------------------------------------------------------------
  1834. # save configure options for build info
  1835. AC_DEFINE_UNQUOTED(
  1836. [CONFIGURE_COMMAND],
  1837. ["$ac_configure_args"],
  1838. [options passed to configure script]
  1839. )
  1840. AC_CONFIG_FILES([
  1841. Makefile
  1842. netdata.spec
  1843. collectors/Makefile
  1844. collectors/apps.plugin/Makefile
  1845. collectors/cgroups.plugin/Makefile
  1846. collectors/charts.d.plugin/Makefile
  1847. collectors/debugfs.plugin/Makefile
  1848. collectors/diskspace.plugin/Makefile
  1849. collectors/timex.plugin/Makefile
  1850. collectors/ioping.plugin/Makefile
  1851. collectors/freebsd.plugin/Makefile
  1852. collectors/freeipmi.plugin/Makefile
  1853. collectors/cups.plugin/Makefile
  1854. collectors/log2journal/Makefile
  1855. collectors/idlejitter.plugin/Makefile
  1856. collectors/macos.plugin/Makefile
  1857. collectors/nfacct.plugin/Makefile
  1858. collectors/plugins.d/Makefile
  1859. collectors/proc.plugin/Makefile
  1860. collectors/python.d.plugin/Makefile
  1861. collectors/slabinfo.plugin/Makefile
  1862. collectors/statsd.plugin/Makefile
  1863. collectors/ebpf.plugin/Makefile
  1864. collectors/tc.plugin/Makefile
  1865. collectors/xenstat.plugin/Makefile
  1866. collectors/perf.plugin/Makefile
  1867. collectors/systemd-journal.plugin/Makefile
  1868. daemon/Makefile
  1869. database/Makefile
  1870. database/contexts/Makefile
  1871. database/engine/Makefile
  1872. database/ram/Makefile
  1873. database/sqlite/Makefile
  1874. diagrams/Makefile
  1875. exporting/Makefile
  1876. exporting/graphite/Makefile
  1877. exporting/json/Makefile
  1878. exporting/opentsdb/Makefile
  1879. exporting/prometheus/Makefile
  1880. exporting/prometheus/remote_write/Makefile
  1881. exporting/aws_kinesis/Makefile
  1882. exporting/pubsub/Makefile
  1883. exporting/mongodb/Makefile
  1884. exporting/tests/Makefile
  1885. health/Makefile
  1886. health/notifications/Makefile
  1887. libnetdata/Makefile
  1888. libnetdata/tests/Makefile
  1889. libnetdata/adaptive_resortable_list/Makefile
  1890. libnetdata/aral/Makefile
  1891. libnetdata/avl/Makefile
  1892. libnetdata/buffer/Makefile
  1893. libnetdata/buffered_reader/Makefile
  1894. libnetdata/clocks/Makefile
  1895. libnetdata/completion/Makefile
  1896. libnetdata/config/Makefile
  1897. libnetdata/datetime/Makefile
  1898. libnetdata/dictionary/Makefile
  1899. libnetdata/ebpf/Makefile
  1900. libnetdata/eval/Makefile
  1901. libnetdata/facets/Makefile
  1902. libnetdata/functions_evloop/Makefile
  1903. libnetdata/july/Makefile
  1904. libnetdata/line_splitter/Makefile
  1905. libnetdata/locks/Makefile
  1906. libnetdata/log/Makefile
  1907. libnetdata/onewayalloc/Makefile
  1908. libnetdata/popen/Makefile
  1909. libnetdata/procfile/Makefile
  1910. libnetdata/simple_pattern/Makefile
  1911. libnetdata/socket/Makefile
  1912. libnetdata/statistical/Makefile
  1913. libnetdata/string/Makefile
  1914. libnetdata/storage_number/Makefile
  1915. libnetdata/storage_number/tests/Makefile
  1916. libnetdata/threads/Makefile
  1917. libnetdata/url/Makefile
  1918. libnetdata/uuid/Makefile
  1919. libnetdata/json/Makefile
  1920. libnetdata/health/Makefile
  1921. libnetdata/worker_utilization/Makefile
  1922. registry/Makefile
  1923. streaming/Makefile
  1924. system/Makefile
  1925. tests/Makefile
  1926. web/Makefile
  1927. web/api/Makefile
  1928. web/api/badges/Makefile
  1929. web/api/ilove/Makefile
  1930. web/api/exporters/Makefile
  1931. web/api/exporters/shell/Makefile
  1932. web/api/exporters/prometheus/Makefile
  1933. web/api/formatters/Makefile
  1934. web/api/formatters/csv/Makefile
  1935. web/api/formatters/json/Makefile
  1936. web/api/formatters/ssv/Makefile
  1937. web/api/formatters/value/Makefile
  1938. web/api/queries/Makefile
  1939. web/api/queries/average/Makefile
  1940. web/api/queries/countif/Makefile
  1941. web/api/queries/des/Makefile
  1942. web/api/queries/incremental_sum/Makefile
  1943. web/api/queries/max/Makefile
  1944. web/api/queries/median/Makefile
  1945. web/api/queries/min/Makefile
  1946. web/api/queries/percentile/Makefile
  1947. web/api/queries/ses/Makefile
  1948. web/api/queries/stddev/Makefile
  1949. web/api/queries/sum/Makefile
  1950. web/api/queries/trimmed_mean/Makefile
  1951. web/api/health/Makefile
  1952. web/gui/Makefile
  1953. web/gui/v1/Makefile
  1954. web/gui/v2/Makefile
  1955. web/rtc/Makefile
  1956. web/server/Makefile
  1957. web/server/static/Makefile
  1958. claim/Makefile
  1959. spawn/Makefile
  1960. logsmanagement/Makefile
  1961. ])
  1962. AC_OUTPUT
  1963. test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :