configure.ac 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. # ----------------------------------------------------------------------
  4. # Build version string.
  5. # ----------------------------------------------------------------------
  6. m4_define([htop_git_version],
  7. m4_normalize(m4_esyscmd([git describe --abbrev=7 --dirty --always --tags 2> /dev/null || echo ''])))
  8. m4_define([htop_release_version], [3.4.1-dev])
  9. # ----------------------------------------------------------------------
  10. # Autoconf initialization.
  11. # ----------------------------------------------------------------------
  12. AC_PREREQ([2.69])
  13. AC_INIT([htop], [m4_join([-],m4_defn([htop_release_version]),m4_defn([htop_git_version]))], [htop@groups.io], [], [https://htop.dev/])
  14. AC_CONFIG_SRCDIR([htop.c])
  15. AC_CONFIG_AUX_DIR([build-aux])
  16. AC_CONFIG_HEADERS([config.h])
  17. AC_CANONICAL_HOST
  18. AM_INIT_AUTOMAKE([-Wall std-options subdir-objects])
  19. # ----------------------------------------------------------------------
  20. # ----------------------------------------------------------------------
  21. # Checks for platform.
  22. # ----------------------------------------------------------------------
  23. case "$host_os" in
  24. linux*|gnu*)
  25. my_htop_platform=linux
  26. AC_DEFINE([HTOP_LINUX], [], [Building for Linux.])
  27. ;;
  28. freebsd*|kfreebsd*)
  29. my_htop_platform=freebsd
  30. AC_DEFINE([HTOP_FREEBSD], [], [Building for FreeBSD.])
  31. ;;
  32. netbsd*)
  33. my_htop_platform=netbsd
  34. AC_DEFINE([HTOP_NETBSD], [], [Building for NetBSD.])
  35. ;;
  36. openbsd*)
  37. my_htop_platform=openbsd
  38. AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD.])
  39. ;;
  40. dragonfly*)
  41. my_htop_platform=dragonflybsd
  42. AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD.])
  43. ;;
  44. darwin*)
  45. my_htop_platform=darwin
  46. AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin.])
  47. ;;
  48. solaris*)
  49. my_htop_platform=solaris
  50. AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris.])
  51. ;;
  52. *)
  53. my_htop_platform=unsupported
  54. AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform.])
  55. ;;
  56. esac
  57. # Enable extensions, required by hwloc scripts
  58. AC_USE_SYSTEM_EXTENSIONS
  59. # The header of ncurses exposes wide-character interfaces only if
  60. # _XOPEN_SOURCE_EXTENDED is defined or _XOPEN_SOURCE defined to be
  61. # >= 500. In DragonFly BSD, FreeBSD and OpenBSD, defining
  62. # _XOPEN_SOURCE to any value *hides* interfaces that would be useful
  63. # for htop.
  64. dnl
  65. dnl Note: The "#undef" in AH_VERBATIM will be replaced with "#define"
  66. dnl when config.h is generated.
  67. AH_VERBATIM([_XOPEN_SOURCE_EXTENDED],
  68. [/* Enables XPG4v2 (SUSv1) interfaces if they are not enabled already with _XOPEN_SOURCE */
  69. #ifndef _XOPEN_SOURCE_EXTENDED
  70. #undef _XOPEN_SOURCE_EXTENDED
  71. #endif
  72. ])
  73. AC_DEFINE([_XOPEN_SOURCE_EXTENDED], 1)
  74. # Activate some more of the missing global defines
  75. AC_SYS_LARGEFILE
  76. # ----------------------------------------------------------------------
  77. # ----------------------------------------------------------------------
  78. # Checks for compiler.
  79. # ----------------------------------------------------------------------
  80. AC_PROG_CC
  81. AM_PROG_CC_C_O
  82. m4_version_prereq([2.70], [], [AC_PROG_CC_C99])
  83. AS_IF([test "x$ac_cv_prog_cc_c99" = xno], [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])])
  84. AM_CFLAGS="-std=c99 -pedantic"
  85. # ----------------------------------------------------------------------
  86. # ----------------------------------------------------------------------
  87. # Checks for static build.
  88. # ----------------------------------------------------------------------
  89. AC_ARG_ENABLE([static],
  90. [AS_HELP_STRING([--enable-static],
  91. [build a static htop binary @<:@default=no@:>@])],
  92. [],
  93. [enable_static=no])
  94. case "$enable_static" in
  95. no)
  96. ;;
  97. yes)
  98. AC_DEFINE([BUILD_STATIC], [1], [Define if building static binary.])
  99. CFLAGS="$CFLAGS -static"
  100. LDFLAGS="$LDFLAGS -static"
  101. ;;
  102. *)
  103. AC_MSG_ERROR([bad value '$enable_static' for --enable-static option])
  104. ;;
  105. esac
  106. # ----------------------------------------------------------------------
  107. # ----------------------------------------------------------------------
  108. # Checks for a PCP-based htop build. (https://pcp.io)
  109. # ----------------------------------------------------------------------
  110. AC_ARG_ENABLE([pcp],
  111. [AS_HELP_STRING([--enable-pcp],
  112. [build a pcp-htop binary @<:@default=no@:>@])],
  113. [],
  114. [enable_pcp=no])
  115. case "$enable_pcp" in
  116. no)
  117. ;;
  118. yes)
  119. AC_CHECK_HEADERS([pcp/pmapi.h], [my_htop_platform=pcp],
  120. [AC_MSG_ERROR([can not find PCP header file])])
  121. AC_SEARCH_LIBS([pmNewContext], [pcp], [], [AC_MSG_ERROR([can not find PCP library])])
  122. AC_DEFINE([HTOP_PCP], [1], [Define if building pcp-htop binary.])
  123. AC_CONFIG_FILES([pcp-htop.5])
  124. ;;
  125. *)
  126. AC_MSG_ERROR([bad value '$enable_pcp' for --enable-pcp option])
  127. ;;
  128. esac
  129. # ----------------------------------------------------------------------
  130. # ----------------------------------------------------------------------
  131. # Checks for generic header files.
  132. # ----------------------------------------------------------------------
  133. AC_HEADER_DIRENT
  134. m4_version_prereq([2.70], [AC_CHECK_INCLUDES_DEFAULT], [AC_HEADER_STDC])
  135. AC_CHECK_HEADERS([ \
  136. stdlib.h \
  137. string.h \
  138. strings.h \
  139. sys/param.h \
  140. sys/time.h \
  141. sys/utsname.h \
  142. unistd.h
  143. ], [], [AC_MSG_ERROR([can not find required generic header files])])
  144. AC_HEADER_MAJOR
  145. dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
  146. dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
  147. dnl been updated in Autoconf 2.69, so use a workaround:
  148. m4_version_prereq([2.70], [],
  149. [if test "x$ac_cv_header_sys_mkdev_h" != xyes; then
  150. AC_CHECK_HEADER([sys/sysmacros.h], [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
  151. [Define to 1 if 'major', 'minor', and 'makedev' are declared in <sys/sysmacros.h>.])])
  152. fi])
  153. # Optional Section
  154. AC_CHECK_HEADERS([execinfo.h])
  155. if test "$my_htop_platform" = darwin; then
  156. AC_CHECK_HEADERS([mach/mach_time.h])
  157. fi
  158. # ----------------------------------------------------------------------
  159. # ----------------------------------------------------------------------
  160. # Checks for typedefs, structures, and compiler characteristics.
  161. # ----------------------------------------------------------------------
  162. AC_TYPE_MBSTATE_T
  163. AC_TYPE_MODE_T
  164. AC_TYPE_OFF_T
  165. AC_TYPE_PID_T
  166. AC_TYPE_SIZE_T
  167. AC_TYPE_SSIZE_T
  168. AC_TYPE_UID_T
  169. AC_TYPE_UINT8_T
  170. AC_TYPE_UINT16_T
  171. AC_TYPE_UINT32_T
  172. AC_TYPE_UINT64_T
  173. AC_MSG_CHECKING(for alloc_size)
  174. old_CFLAGS="$CFLAGS"
  175. CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
  176. AC_COMPILE_IFELSE([
  177. AC_LANG_SOURCE(
  178. [
  179. /* Attribute supported in GCC 4.3 or later */
  180. __attribute__((alloc_size(1))) char* my_alloc(int size) { return 0; }
  181. ],[]
  182. )],
  183. AC_DEFINE([HAVE_ATTR_ALLOC_SIZE], 1, [The alloc_size attribute is supported.])
  184. AC_MSG_RESULT(yes),
  185. AC_MSG_RESULT(no))
  186. CFLAGS="$old_CFLAGS"
  187. AC_MSG_CHECKING(for access)
  188. old_CFLAGS="$CFLAGS"
  189. CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
  190. AC_COMPILE_IFELSE([
  191. AC_LANG_SOURCE(
  192. [
  193. /* Attribute supported in GCC 10 or later */
  194. __attribute__((access(read_only, 1, 2))) extern int foo(const char* str, unsigned len);
  195. ],[]
  196. )],
  197. AC_DEFINE([HAVE_ATTR_ACCESS], 1, [The access attribute is supported.])
  198. AC_MSG_RESULT(yes),
  199. AC_MSG_RESULT(no))
  200. CFLAGS="$old_CFLAGS"
  201. AC_MSG_CHECKING(for nonnull)
  202. old_CFLAGS="$CFLAGS"
  203. CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
  204. AC_COMPILE_IFELSE([
  205. AC_LANG_SOURCE(
  206. [[
  207. /* Attribute supported in GCC 3.3 or later */
  208. __attribute__((nonnull)) int my_strcmp(const char* a, const char* b);
  209. __attribute__((nonnull(1))) long my_strtol(const char* str, char** endptr, int base);
  210. ]]
  211. )],
  212. AC_DEFINE([HAVE_ATTR_NONNULL], 1, [The nonnull attribute is supported.])
  213. AC_MSG_RESULT(yes),
  214. AC_MSG_RESULT(no))
  215. CFLAGS="$old_CFLAGS"
  216. AC_MSG_CHECKING(for returns_nonnull)
  217. old_CFLAGS="$CFLAGS"
  218. CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
  219. AC_COMPILE_IFELSE([
  220. AC_LANG_SOURCE(
  221. [[
  222. /* Attribute supported in GCC 4.9 or later */
  223. __attribute__((returns_nonnull)) void* foo(void);
  224. ]]
  225. )],
  226. AC_DEFINE([HAVE_ATTR_RETNONNULL], 1, [The returns_nonnull attribute is supported.])
  227. AC_MSG_RESULT(yes),
  228. AC_MSG_RESULT(no))
  229. CFLAGS="$old_CFLAGS"
  230. AC_MSG_CHECKING(for NaN support)
  231. dnl Note: AC_RUN_IFELSE does not try compiling the program at all when
  232. dnl $cross_compiling is 'yes'.
  233. AC_LINK_IFELSE([
  234. AC_LANG_PROGRAM(
  235. [[
  236. #include <math.h>
  237. ]],
  238. [[
  239. double x = NAN;
  240. /* Both should evaluate to false -> 0 (exit success) */
  241. return isgreater(x, x) || isgreaterequal(x, x);
  242. ]]
  243. )],
  244. [flag_finite_math_only=unknown
  245. if test "$cross_compiling" = yes; then
  246. AC_COMPILE_IFELSE([
  247. AC_LANG_SOURCE([[
  248. /* __FINITE_MATH_ONLY__ is documented in Clang. */
  249. #ifdef __FINITE_MATH_ONLY__
  250. #error "should not enable -ffinite-math-only"
  251. #endif
  252. ]])],
  253. AC_MSG_RESULT([assume yes (cross compiling)]),
  254. flag_finite_math_only=yes)
  255. elif ./conftest$EXEEXT >&AS_MESSAGE_LOG_FD; then
  256. flag_finite_math_only=no
  257. AC_MSG_RESULT(yes)
  258. else
  259. flag_finite_math_only=yes
  260. fi
  261. if test "$flag_finite_math_only" = yes; then
  262. AC_MSG_RESULT(no)
  263. AC_MSG_WARN([runtime behavior with NaN is not compliant - some functionality might break; consider using '-fno-finite-math-only'])
  264. fi],
  265. [AC_MSG_RESULT(no)
  266. AC_MSG_ERROR([can not find required macros: NAN, isgreater() and isgreaterequal()])])
  267. AC_MSG_CHECKING(for __builtin_ctz)
  268. AC_COMPILE_IFELSE([
  269. AC_LANG_PROGRAM([], [[__builtin_ctz(1); /* Supported in GCC 3.4 or later */]])],
  270. [AC_DEFINE([HAVE_BUILTIN_CTZ], 1, [Define to 1 if the compiler supports '__builtin_ctz' function.])
  271. AC_MSG_RESULT(yes)],
  272. AC_MSG_RESULT(no))
  273. # ----------------------------------------------------------------------
  274. # ----------------------------------------------------------------------
  275. # Checks for generic library functions.
  276. # ----------------------------------------------------------------------
  277. AC_SEARCH_LIBS([ceil], [m], [], [AC_MSG_ERROR([can not find required function ceil()])])
  278. if test "$my_htop_platform" = dragonflybsd; then
  279. AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
  280. AC_SEARCH_LIBS([getdevs], [devstat], [], [AC_MSG_ERROR([can not find required function getdevs()])])
  281. fi
  282. if test "$my_htop_platform" = freebsd; then
  283. if test "$enable_static" = yes; then
  284. AC_SEARCH_LIBS([elf_version], [elf], [], [AC_MSG_ERROR([can not find required function elf_version()])])
  285. fi
  286. AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
  287. AC_SEARCH_LIBS([devstat_checkversion], [devstat], [], [AC_MSG_ERROR([can not find required function devstat_checkversion()])])
  288. fi
  289. if test "$my_htop_platform" = linux; then
  290. if test "$enable_static" != yes; then
  291. AC_SEARCH_LIBS([dlopen], [dl dld], [], [AC_MSG_ERROR([can not find required function dlopen()])])
  292. fi
  293. fi
  294. if test "$my_htop_platform" = netbsd; then
  295. AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
  296. AC_SEARCH_LIBS([prop_dictionary_get], [prop], [], [AC_MSG_ERROR([can not find required function prop_dictionary_get()])])
  297. fi
  298. if test "$my_htop_platform" = openbsd; then
  299. AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
  300. fi
  301. if test "$my_htop_platform" = solaris; then
  302. AC_SEARCH_LIBS([kstat_open], [kstat], [], [AC_MSG_ERROR([can not find required function kstat_open()])])
  303. AC_SEARCH_LIBS([Pgrab_error], [proc], [], [AC_MSG_ERROR([can not find required function Pgrab_error()])])
  304. AC_SEARCH_LIBS([free], [malloc], [], [AC_MSG_ERROR([can not find required function free()])])
  305. fi
  306. # Optional Section
  307. AC_SEARCH_LIBS([clock_gettime], [rt])
  308. AC_CHECK_FUNCS([ \
  309. clock_gettime \
  310. dladdr \
  311. faccessat \
  312. fstatat \
  313. host_get_clock_service \
  314. memfd_create\
  315. openat \
  316. readlinkat \
  317. sched_getscheduler \
  318. sched_setscheduler \
  319. strchrnul \
  320. ])
  321. if test "$my_htop_platform" = darwin; then
  322. AC_CHECK_FUNCS([host_statistics64], [
  323. AC_CHECK_TYPES([struct vm_statistics64], [], [], [[#include <mach/vm_statistics.h>]])
  324. ], [])
  325. fi
  326. if test "$my_htop_platform" = pcp; then
  327. AC_CHECK_FUNCS([pmLookupDescs])
  328. fi
  329. if test "$my_htop_platform" = linux && test "x$enable_static" = xyes; then
  330. AC_CHECK_LIB([systemd], [sd_bus_open_system], [], [], [-lcap])
  331. fi
  332. # ----------------------------------------------------------------------
  333. # ----------------------------------------------------------------------
  334. # Checks for cross-platform features and flags.
  335. # ----------------------------------------------------------------------
  336. dnl PKG_PROG_PKG_CONFIG initializes $PKG_CONFIG and related variables.
  337. dnl If the macro is not called, some pkg-config checks might be skipped
  338. dnl and $PKG_CONFIG might be unset.
  339. m4_ifdef([PKG_PROG_PKG_CONFIG], [
  340. PKG_PROG_PKG_CONFIG()
  341. pkg_m4_included=1 # Makefile might grep this keyword. Don't remove.
  342. ], [
  343. m4_warn(
  344. [syntax],
  345. [pkg.m4 is absent or older than version 0.16; this 'configure' would have incomplete pkg-config support])
  346. ])
  347. AC_ARG_ENABLE([unicode],
  348. [AS_HELP_STRING([--enable-unicode],
  349. [enable Unicode support @<:@default=yes@:>@])],
  350. [],
  351. [enable_unicode=yes])
  352. AC_ARG_VAR([CURSES_CFLAGS], [C compiler flags for curses; this overrides auto detected values])
  353. AC_ARG_VAR([CURSES_LIBS], [linker flags for curses; this overrides auto detected values])
  354. curses_pkg_names="ncurses6 ncurses5 ncurses ncursest6 ncursest5 \
  355. ncursest curses"
  356. if test "x$enable_unicode" = xyes; then
  357. curses_pkg_names="ncursesw6 ncursesw5 ncursesw ncursestw6 ncursestw5 \
  358. ncursestw $curses_pkg_names"
  359. fi
  360. AC_ARG_WITH([curses],
  361. [AS_HELP_STRING([--with-curses=NAME],
  362. [select curses package NAME to link with; e.g. ncursesw6])],
  363. [],
  364. [with_curses=check])
  365. case $with_curses in
  366. check|yes)
  367. : # No-op. Use default list.
  368. ;;
  369. no)
  370. AC_MSG_ERROR([bad value '$with_curses' for --with-curses option])
  371. ;;
  372. *)
  373. if test "x${CURSES_CFLAGS+y}${CURSES_LIBS+y}" = xyy; then
  374. AC_MSG_WARN([ignoring --with-curses value due to override])
  375. fi
  376. curses_pkg_names=`echo "x$with_curses" | sed 's/^x\(lib\)\{0,1\}//'`
  377. ;;
  378. esac
  379. # $1: C preprocessor and compiler flags for curses library
  380. # $2: linker flags for curses library
  381. htop_check_curses_capability () {
  382. htop_curses_cflags=${CURSES_CFLAGS-"$1"}
  383. htop_curses_libs=${CURSES_LIBS-"$2"}
  384. echo "curses cflags${CURSES_CFLAGS+ (override)}: $htop_curses_cflags" >&AS_MESSAGE_LOG_FD
  385. echo "curses libs${CURSES_LIBS+ (override)}: $htop_curses_libs" >&AS_MESSAGE_LOG_FD
  386. htop_msg_linker_flags=$htop_curses_libs
  387. if test "`echo x $htop_msg_linker_flags`" = x; then
  388. htop_msg_linker_flags="(no linker flags)"
  389. fi
  390. htop_curses_status=0 # 0 for success; nonzero for failure
  391. htop_save_CFLAGS=$CFLAGS
  392. htop_save_LIBS=$LIBS
  393. CFLAGS="$AM_CFLAGS $htop_curses_cflags $CFLAGS"
  394. LIBS="$htop_curses_libs $LIBS"
  395. # At this point we have not checked the name of curses header, so
  396. # use forward declaration for the linking tests below.
  397. # htop uses keypad(), but for ncurses implementation, the symbol is
  398. # in "-ltinfo" and not "-lncurses".
  399. # Check "-ltinfo" symbols first, as libncurses might require
  400. # explicit "-ltinfo" to link (for internal dependency).
  401. AC_MSG_CHECKING([for keypad in $htop_msg_linker_flags])
  402. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  403. /* int keypad(WINDOW* win, bool enable); */
  404. int keypad(void* win, int enable);
  405. ]], [[
  406. static char dummy;
  407. keypad((void*)&dummy, 0);
  408. ]])],
  409. [AC_MSG_RESULT(yes)],
  410. [AC_MSG_RESULT(no)
  411. htop_curses_status=1])
  412. # htop calls refresh(), which might be implemented as a macro.
  413. # It is more reliable to test linking with doupdate(), which
  414. # refresh() would call internally.
  415. if test "$htop_curses_status" -eq 0; then
  416. AC_MSG_CHECKING([for doupdate in $htop_msg_linker_flags])
  417. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  418. int doupdate(void);
  419. ]], [[
  420. doupdate();
  421. ]])],
  422. [AC_MSG_RESULT(yes)
  423. htop_curses_capability=nonwide],
  424. [AC_MSG_RESULT(no)
  425. htop_curses_status=1])
  426. fi
  427. # htop calls mvadd_wchnstr(), which might be implemented as a macro.
  428. # It is more reliable to test linking with wadd_wchnstr().
  429. if test "x$htop_curses_status$enable_unicode" = x0yes; then
  430. AC_MSG_CHECKING([for wadd_wchnstr in $htop_msg_linker_flags])
  431. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  432. /* int wadd_wchnstr(WINDOW* win, const cchar_t* wchstr, int n); */
  433. int wadd_wchnstr(void* win, const void* wchstr, int n);
  434. ]], [[
  435. static char dummy1;
  436. static char dummy2;
  437. wadd_wchnstr((void*)&dummy1, (void*)&dummy2, 0);
  438. ]])],
  439. [AC_MSG_RESULT(yes)
  440. htop_curses_capability=wide],
  441. [AC_MSG_RESULT(no)
  442. htop_curses_status=1])
  443. fi
  444. if test "$htop_curses_status" -eq 0; then
  445. AM_CFLAGS="$AM_CFLAGS $htop_curses_cflags"
  446. if test "$htop_curses_capability" = wide; then
  447. AC_DEFINE([HAVE_LIBNCURSESW], 1, [libncursesw is present])
  448. else
  449. AC_DEFINE([HAVE_LIBNCURSES], 1, [libcurses is present])
  450. fi
  451. else
  452. LIBS=$htop_save_LIBS
  453. fi
  454. CFLAGS=$htop_save_CFLAGS
  455. return "$htop_curses_status"
  456. } # htop_check_curses_capability
  457. htop_curses_capability=none
  458. if test "x${CURSES_CFLAGS+y}${CURSES_LIBS+y}" = xyy; then
  459. curses_pkg_names=""
  460. htop_check_curses_capability "$CURSES_CFLAGS" "$CURSES_LIBS"
  461. fi
  462. # Prioritize $PKG_CONFIG over ncurses*-config, as users might need to
  463. # cross-compile htop.
  464. if test "x$PKG_CONFIG" != x; then
  465. pkg_config_static_flag=""
  466. if test "$enable_static" = yes; then
  467. pkg_config_static_flag=--static
  468. fi
  469. for curses_name in $curses_pkg_names; do
  470. echo retrieving $curses_name information through $PKG_CONFIG >&AS_MESSAGE_LOG_FD
  471. $PKG_CONFIG --exists --print-errors $curses_name >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD || continue
  472. : # Resets "$?" to 0
  473. htop_config_cflags=`$PKG_CONFIG --cflags $pkg_config_static_flag $curses_name 2>/dev/null` || continue
  474. : # Resets "$?" to 0
  475. htop_config_libs=`$PKG_CONFIG --libs $pkg_config_static_flag $curses_name 2>/dev/null` || continue
  476. AC_MSG_RESULT([found $curses_name information through $PKG_CONFIG])
  477. if htop_check_curses_capability "$htop_config_cflags" "$htop_config_libs"; then
  478. break
  479. fi
  480. done
  481. fi
  482. case ${htop_curses_capability}-$enable_unicode in
  483. none-*|nonwide-yes)
  484. for curses_name in $curses_pkg_names; do
  485. echo retrieving $curses_name information through ${curses_name}-config >&AS_MESSAGE_LOG_FD
  486. ${curses_name}-config --cflags >/dev/null 2>&AS_MESSAGE_LOG_FD || continue
  487. : # Resets "$?" to 0
  488. htop_config_cflags=`${curses_name}-config --cflags 2>/dev/null` || continue
  489. : # Resets "$?" to 0
  490. htop_config_libs=`${curses_name}-config --libs 2>/dev/null` || continue
  491. AC_MSG_RESULT([found $curses_name information through ${curses_name}-config])
  492. if htop_check_curses_capability "$htop_config_cflags" "$htop_config_libs"; then
  493. break
  494. fi
  495. done
  496. ;;
  497. esac
  498. case ${htop_curses_capability}-$enable_unicode in
  499. none-*|nonwide-yes)
  500. if test "x$PKG_CONFIG" = x; then (
  501. # Friendly warning to advise user to install pkg-config.
  502. # The local variables get discarded when done.
  503. list=""
  504. echo "" >conftest.c
  505. if test "$cross_compiling" != yes; then
  506. # "-print-multi-directory" supported in GCC 3.0 or later
  507. name=""
  508. if $CC $CPPFLAGS $CFLAGS -print-multi-directory -E conftest.c >/dev/null 2>&1; then
  509. name=`$CC $CPPFLAGS $CFLAGS -print-multi-directory -E conftest.c 2>/dev/null |
  510. sed '/^ *#/ d; s/^\.$//; q'`
  511. fi
  512. list="/usr/lib${name}/pkgconfig $list"
  513. case $host_os in
  514. darwin*)
  515. list="/opt/homebrew/Library/Homebrew/os/mac/pkgconfig $list"
  516. ;;
  517. freebsd*)
  518. list="/usr/libdata/pkgconfig $list"
  519. ;;
  520. netbsd*)
  521. list="/usr/pkg/lib/pkgconfig $list"
  522. ;;
  523. esac
  524. fi
  525. if test "x$host_alias" != x; then
  526. list="/usr/lib/${host_alias}/pkgconfig $list"
  527. fi
  528. # "-print-multiarch" supported in GCC 4.6 or later
  529. if $CC $CPPFLAGS $CFLAGS -print-multiarch -E conftest.c >/dev/null 2>&1; then
  530. name=`$CC $CPPFLAGS $CFLAGS -print-multiarch -E conftest.c 2>/dev/null |
  531. sed '/^ *#/ d; q'`
  532. if test "x$name" != x; then
  533. list="/usr/lib/${name}/pkgconfig $list"
  534. fi
  535. fi
  536. rm -f conftest.*
  537. for d in $list; do
  538. result=`find "$d" -name '*curses*.pc' 2>/dev/null | sed '1 q'`
  539. if test "x$result" != x; then
  540. echo detected a .pc file: "$result" >&AS_MESSAGE_LOG_FD
  541. AC_MSG_WARN([your system supports pkg-config; installing pkg-config is recommended before configuring htop])
  542. m4_ifdef([PKG_PROG_PKG_CONFIG], [], [
  543. AC_MSG_WARN([this configure script would also need to be regenerated])
  544. ])
  545. break
  546. fi
  547. done
  548. ) fi
  549. # OpenBSD and Solaris are known to not provide '*curses*.pc' files.
  550. AC_MSG_RESULT([no curses information found through '*-config' utilities; will guess the linker flags])
  551. for curses_name in $curses_pkg_names; do
  552. if htop_check_curses_capability "" "-l$curses_name"; then
  553. break
  554. fi
  555. # For ncurses implementation, an extra terminfo library might be
  556. # needed. Guess the terminfo library name based on the ncurses
  557. # library file name (e.g. "-ltinfow" for "-lncursesw"), before
  558. # trying the "-ltinfo" name.
  559. tinfo_name=`echo x$curses_name | sed 's/^xncurses/tinfo/p; d'`
  560. case x$tinfo_name in
  561. x|xtinfo)
  562. ;;
  563. *)
  564. if htop_check_curses_capability "" "-l$curses_name -l$tinfo_name"; then
  565. break
  566. fi
  567. ;;
  568. esac
  569. if htop_check_curses_capability "" "-l$curses_name -ltinfo"; then
  570. break
  571. fi
  572. done
  573. ;;
  574. esac
  575. case ${htop_curses_capability}-$enable_unicode in
  576. nonwide-yes)
  577. AC_MSG_ERROR([cannot find required ncursesw library; you may want to use --disable-unicode])
  578. ;;
  579. none-*)
  580. AC_MSG_ERROR([cannot find required curses/ncurses library])
  581. ;;
  582. esac
  583. htop_save_CFLAGS=$CFLAGS
  584. CFLAGS="$AM_CFLAGS $CFLAGS"
  585. if test "x$enable_unicode" = xyes; then
  586. AC_CHECK_HEADERS([ncursesw/curses.h], [],
  587. [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
  588. [AC_CHECK_HEADERS([ncurses/curses.h], [],
  589. [AC_CHECK_HEADERS([ncurses.h], [],
  590. [AC_MSG_ERROR([can not find required ncurses header file])])])])])
  591. AC_CHECK_HEADERS([ncursesw/term.h], [],
  592. [AC_CHECK_HEADERS([ncurses/term.h], [],
  593. [AC_CHECK_HEADERS([term.h], [],
  594. [AC_MSG_ERROR([can not find required term header file])])])])
  595. else
  596. AC_CHECK_HEADERS([curses.h], [],
  597. [AC_CHECK_HEADERS([ncurses/curses.h], [],
  598. [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
  599. [AC_CHECK_HEADERS([ncurses.h], [],
  600. [AC_MSG_ERROR([can not find required ncurses header file])])])])])
  601. AC_CHECK_HEADERS([ncurses/term.h], [],
  602. [AC_CHECK_HEADERS([term.h], [],
  603. [AC_MSG_ERROR([can not find required term header file])])])
  604. fi
  605. CFLAGS="-I$srcdir $CFLAGS"
  606. # Check for things that might be macros.
  607. # "stdscr" is a macro in ncursest (reentrant version of ncurses).
  608. AC_MSG_CHECKING([whether the curses header works])
  609. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  610. /* Checks if the "bool" definition in curses is ISO C compatible */
  611. #include <stdbool.h>
  612. #include "ProvideCurses.h"
  613. ]], [[
  614. keypad(stdscr, false);
  615. refresh();
  616. #if defined(HAVE_LIBNCURSESW)
  617. {
  618. static cchar_t dummy;
  619. mvadd_wchnstr(0, 0, &dummy, 0);
  620. }
  621. #endif
  622. ]])],
  623. [AC_MSG_RESULT(yes)],
  624. [AC_MSG_RESULT(no)
  625. AC_MSG_FAILURE([there are problems with the curses header])]
  626. )
  627. CFLAGS=$htop_save_CFLAGS
  628. if test "$enable_static" = yes; then
  629. AC_SEARCH_LIBS([Gpm_GetEvent], [gpm])
  630. fi
  631. if test "$my_htop_platform" = "solaris"; then
  632. # On OmniOS /usr/include/sys/regset.h redefines ERR to 13 - \r, breaking the Enter key.
  633. # Since ncurses macros use the ERR macro, we can not use another name.
  634. AC_DEFINE([ERR], [(-1)], [Predefine ncurses macro.])
  635. fi
  636. AC_CHECK_FUNCS( [set_escdelay] )
  637. AC_CHECK_FUNCS( [getmouse] )
  638. AC_DEFINE([NCURSES_ENABLE_STDBOOL_H], [1], [Define to enable stdbool.h in ncurses])
  639. AC_ARG_ENABLE([affinity],
  640. [AS_HELP_STRING([--enable-affinity],
  641. [enable sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
  642. [],
  643. [enable_affinity=check])
  644. if test "x$enable_affinity" = xcheck; then
  645. if test "x$enable_hwloc" = xyes; then
  646. enable_affinity=no
  647. else
  648. AC_MSG_CHECKING([for usable sched_setaffinity])
  649. AC_RUN_IFELSE([
  650. AC_LANG_PROGRAM([[
  651. #include <sched.h>
  652. #include <errno.h>
  653. static cpu_set_t cpuset;
  654. ]], [[
  655. CPU_ZERO(&cpuset);
  656. sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
  657. if (errno == ENOSYS) return 1;
  658. ]])],
  659. [enable_affinity=yes
  660. AC_MSG_RESULT([yes])],
  661. [enable_affinity=no
  662. AC_MSG_RESULT([no])],
  663. [AC_MSG_RESULT([assume yes (cross compiling)])])
  664. fi
  665. fi
  666. if test "x$enable_affinity" = xyes; then
  667. if test "x$enable_hwloc" = xyes; then
  668. AC_MSG_ERROR([--enable-hwloc and --enable-affinity are mutual exclusive. Specify at most one of them.])
  669. fi
  670. AC_DEFINE([HAVE_AFFINITY], [1], [Define if sched_setaffinity and sched_getaffinity are to be used.])
  671. fi
  672. AC_ARG_ENABLE([unwind],
  673. [AS_HELP_STRING([--enable-unwind],
  674. [enable unwind support for printing backtraces; requires libunwind @<:@default=check@:>@])],
  675. [],
  676. [enable_unwind=check])
  677. case "$enable_unwind" in
  678. check)
  679. enable_unwind=yes
  680. if test "$enable_static" = yes; then
  681. AC_CHECK_LIB([lzma], [lzma_index_buffer_decode])
  682. fi
  683. AC_CHECK_LIB([unwind], [backtrace], [], [enable_unwind=no])
  684. AC_CHECK_HEADERS([libunwind.h], [], [
  685. old_CFLAGS="$CFLAGS"
  686. CFLAGS="$CFLAGS -I/usr/include/libunwind"
  687. AC_CHECK_HEADERS([libunwind/libunwind.h], [], [
  688. enable_unwind=no
  689. CFLAGS="$old_CFLAGS"
  690. ])
  691. ])
  692. ;;
  693. no)
  694. ;;
  695. yes)
  696. AC_CHECK_LIB([unwind], [backtrace], [], [AC_MSG_ERROR([can not find required library libunwind])])
  697. AC_CHECK_HEADERS([libunwind.h], [], [
  698. AM_CFLAGS="$AM_CFLAGS -I/usr/include/libunwind"
  699. AC_CHECK_HEADERS([libunwind/libunwind.h], [], [AC_MSG_ERROR([can not find required header file libunwind.h])])
  700. ])
  701. ;;
  702. *)
  703. AC_MSG_ERROR([bad value '$enable_unwind' for --enable-unwind])
  704. ;;
  705. esac
  706. if test "x$enable_unwind" = xno; then
  707. # Fall back to backtrace(3) and add -lexecinfo if needed
  708. AC_SEARCH_LIBS([backtrace], [execinfo])
  709. fi
  710. AC_ARG_ENABLE([hwloc],
  711. [AS_HELP_STRING([--enable-hwloc],
  712. [enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
  713. [],
  714. [enable_hwloc=no])
  715. case "$enable_hwloc" in
  716. no)
  717. ;;
  718. yes)
  719. m4_ifdef([PKG_PROG_PKG_CONFIG], [
  720. PKG_CHECK_MODULES(HWLOC, hwloc, [
  721. AM_CFLAGS="$AM_CFLAGS $HWLOC_CFLAGS"
  722. LIBS="$LIBS $HWLOC_LIBS"
  723. AC_DEFINE([HAVE_LIBHWLOC], [1], [Define to 1 if you have the 'hwloc' library (-lhwloc).])
  724. ], [
  725. AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
  726. AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
  727. ])
  728. ], [
  729. AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
  730. AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
  731. ])
  732. ;;
  733. *)
  734. AC_MSG_ERROR([bad value '$enable_hwloc' for --enable-hwloc])
  735. ;;
  736. esac
  737. AC_ARG_WITH([os-release],
  738. [AS_HELP_STRING([--with-os-release=FILE],
  739. [location of an os-release file @<:@default=/etc/os-release@:>@])],
  740. [],
  741. [with_os_release=/etc/os-release])
  742. if test -n "$with_os_release" && test ! -f "$with_os_release"; then
  743. if test -f "/usr/lib/os-release"; then
  744. with_os_release="/usr/lib/os-release"
  745. fi
  746. fi
  747. AC_DEFINE_UNQUOTED([OSRELEASEFILE], ["$with_os_release"], [File with OS release details.])
  748. AC_ARG_WITH([config],
  749. [AS_HELP_STRING([--with-config=DIR],
  750. [configuration path @<:@default=/.config@:>@])],
  751. [],
  752. [with_config="/.config"])
  753. dnl Performance Co-Pilot configuration location to prevent overwrite
  754. if test "$my_htop_platform" = pcp -a "$with_config" = /.config; then
  755. with_config="/.pcp"
  756. elif test -z "$with_config"; then
  757. AC_MSG_ERROR([bad empty value for --with-config option])
  758. fi
  759. AC_DEFINE_UNQUOTED([CONFIGDIR], ["$with_config"], [Configuration path.])
  760. # ----------------------------------------------------------------------
  761. # ----------------------------------------------------------------------
  762. # Checks for Linux features and flags.
  763. # ----------------------------------------------------------------------
  764. AC_ARG_WITH([proc],
  765. [AS_HELP_STRING([--with-proc=DIR],
  766. [location of a Linux-compatible proc filesystem @<:@default=/proc@:>@])],
  767. [],
  768. [with_proc=/proc])
  769. if test -z "$with_proc"; then
  770. AC_MSG_ERROR([bad empty value for --with-proc option])
  771. fi
  772. AC_DEFINE_UNQUOTED([PROCDIR], ["$with_proc"], [Path of proc filesystem.])
  773. AC_ARG_ENABLE([openvz],
  774. [AS_HELP_STRING([--enable-openvz],
  775. [enable OpenVZ support @<:@default=no@:>@])],
  776. [],
  777. [enable_openvz=no])
  778. if test "x$enable_openvz" = xyes; then
  779. AC_DEFINE([HAVE_OPENVZ], [1], [Define if openvz support enabled.])
  780. fi
  781. AC_ARG_ENABLE([vserver],
  782. [AS_HELP_STRING([--enable-vserver],
  783. [enable VServer support @<:@default=no@:>@])],
  784. [],
  785. [enable_vserver=no])
  786. if test "x$enable_vserver" = xyes; then
  787. AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
  788. fi
  789. AC_ARG_ENABLE([ancient_vserver],
  790. [AS_HELP_STRING([--enable-ancient-vserver],
  791. [enable ancient VServer support (implies --enable-vserver) @<:@default=no@:>@])],
  792. [],
  793. [enable_ancient_vserver=no])
  794. if test "x$enable_ancient_vserver" = xyes; then
  795. if test "x$enable_vserver" != xyes; then
  796. enable_vserver=implied
  797. fi
  798. AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
  799. AC_DEFINE([HAVE_ANCIENT_VSERVER], [1], [Define if ancient vserver support enabled.])
  800. fi
  801. AC_ARG_ENABLE([capabilities],
  802. [AS_HELP_STRING([--enable-capabilities],
  803. [enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
  804. [],
  805. [enable_capabilities=check])
  806. case "$enable_capabilities" in
  807. no)
  808. ;;
  809. check)
  810. enable_capabilities=yes
  811. AC_CHECK_LIB([cap], [cap_init], [], [enable_capabilities=no])
  812. AC_CHECK_HEADERS([sys/capability.h], [], [enable_capabilities=no])
  813. ;;
  814. yes)
  815. AC_CHECK_LIB([cap], [cap_init], [], [AC_MSG_ERROR([can not find required library libcap])])
  816. AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([can not find required header file sys/capability.h])])
  817. ;;
  818. *)
  819. AC_MSG_ERROR([bad value '$enable_capabilities' for --enable-capabilities])
  820. ;;
  821. esac
  822. AC_ARG_ENABLE([delayacct],
  823. [AS_HELP_STRING([--enable-delayacct],
  824. [enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@default=check@:>@])],
  825. [],
  826. [enable_delayacct=check])
  827. case "$enable_delayacct" in
  828. no)
  829. ;;
  830. check)
  831. if test "$my_htop_platform" != linux; then
  832. enable_delayacct=no
  833. elif test "$enable_static" = yes; then
  834. enable_delayacct=no
  835. else
  836. old_CFLAGS="$CFLAGS"
  837. CFLAGS="$CFLAGS -I/usr/include/libnl3"
  838. AC_CHECK_HEADERS([netlink/attr.h netlink/handlers.h netlink/msg.h], [enable_delayacct=yes], [enable_delayacct=no])
  839. CFLAGS="$old_CFLAGS"
  840. fi
  841. ;;
  842. yes)
  843. old_CFLAGS="$CFLAGS"
  844. CFLAGS="$CFLAGS -I/usr/include/libnl3"
  845. AC_CHECK_HEADERS([netlink/attr.h netlink/handlers.h netlink/msg.h], [], [AC_MSG_ERROR([can not find required header files netlink/attr.h, netlink/handlers.h, netlink/msg.h])])
  846. CFLAGS="$old_CFLAGS"
  847. ;;
  848. *)
  849. AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct])
  850. ;;
  851. esac
  852. if test "$enable_delayacct" = yes; then
  853. AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
  854. AM_CFLAGS="$AM_CFLAGS -I/usr/include/libnl3"
  855. fi
  856. AM_CONDITIONAL([HAVE_DELAYACCT], [test "$enable_delayacct" = yes])
  857. AC_ARG_ENABLE([sensors],
  858. [AS_HELP_STRING([--enable-sensors],
  859. [enable libsensors support for reading temperature data; requires only libsensors headers at compile time, at runtime libsensors is loaded via dlopen @<:@default=check@:>@])],
  860. [],
  861. [enable_sensors=check])
  862. case "$enable_sensors" in
  863. no)
  864. ;;
  865. check)
  866. enable_sensors=yes
  867. if test "$enable_static" = yes; then
  868. AC_CHECK_LIB([sensors], [sensors_init], [], [enable_sensors=no])
  869. fi
  870. AC_CHECK_HEADERS([sensors/sensors.h], [], [enable_sensors=no])
  871. ;;
  872. yes)
  873. if test "$enable_static" = yes; then
  874. AC_CHECK_LIB([sensors], [sensors_init], [], [AC_MSG_ERROR([can not find required library libsensors])])
  875. fi
  876. AC_CHECK_HEADERS([sensors/sensors.h], [], [AC_MSG_ERROR([can not find required header file sensors/sensors.h])])
  877. ;;
  878. *)
  879. AC_MSG_ERROR([bad value '$enable_sensors' for --enable-sensors])
  880. ;;
  881. esac
  882. if test "$enable_sensors" = yes || test "$my_htop_platform" = freebsd; then
  883. AC_DEFINE([BUILD_WITH_CPU_TEMP], [1], [Define if CPU temperature option should be enabled.])
  884. fi
  885. # ----------------------------------------------------------------------
  886. # ----------------------------------------------------------------------
  887. # Checks for compiler warnings.
  888. # ----------------------------------------------------------------------
  889. AM_CFLAGS="$AM_CFLAGS\
  890. -Wall\
  891. -Wcast-align\
  892. -Wcast-qual\
  893. -Wextra\
  894. -Wfloat-equal\
  895. -Wformat=2\
  896. -Winit-self\
  897. -Wmissing-format-attribute\
  898. -Wmissing-noreturn\
  899. -Wmissing-prototypes\
  900. -Wpointer-arith\
  901. -Wshadow\
  902. -Wstrict-prototypes\
  903. -Wundef\
  904. -Wunused\
  905. -Wwrite-strings"
  906. dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
  907. AC_DEFUN([AX_CHECK_COMPILE_FLAG],
  908. [
  909. AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
  910. AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
  911. ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
  912. _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
  913. AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
  914. [AS_VAR_SET(CACHEVAR,[yes])],
  915. [AS_VAR_SET(CACHEVAR,[no])])
  916. _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
  917. AS_VAR_IF(CACHEVAR,yes,
  918. [m4_default([$2], :)],
  919. [m4_default([$3], :)])
  920. AS_VAR_POPDEF([CACHEVAR])dnl
  921. ])dnl AX_CHECK_COMPILE_FLAGS
  922. AX_CHECK_COMPILE_FLAG([-Wextra-semi-stmt], [AM_CFLAGS="$AM_CFLAGS -Wextra-semi-stmt"], , [-Werror=unknown-warning-option]) dnl the autoconf check itself generates -Wextra-semi-stmt
  923. AX_CHECK_COMPILE_FLAG([-Wimplicit-int-conversion], [AM_CFLAGS="$AM_CFLAGS -Wimplicit-int-conversion"], , [-Werror])
  924. AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
  925. AC_ARG_ENABLE([werror],
  926. [AS_HELP_STRING([--enable-werror],
  927. [Treat warnings as errors @<:@default=no@:>@])],
  928. [],
  929. [enable_werror=no])
  930. if test "x$enable_werror" = xyes; then
  931. AM_CFLAGS="$AM_CFLAGS -Werror"
  932. fi
  933. AC_ARG_ENABLE([debug],
  934. [AS_HELP_STRING([--enable-debug],
  935. [Enable compiling with maximum debug info, asserts and internal sanity checks @<:@default=no@:>@])],
  936. [],
  937. [enable_debug=no])
  938. if test "x$enable_debug" != xyes; then
  939. AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
  940. AC_COMPILE_IFELSE([
  941. AC_LANG_SOURCE([[
  942. #ifdef __SUPPORT_SNAN__
  943. #error "signaling NaN support not recommended"
  944. #endif
  945. ]])],
  946. :,
  947. [warning_msg="signaling NaN support is enabled; not recommended for htop"
  948. case "$CC" in
  949. *gcc*)
  950. warning_msg="$warning_msg (use '-fno-signaling-nans' compiler flag to disable)"
  951. ;;
  952. esac
  953. AC_MSG_WARN([$warning_msg])
  954. ])
  955. else
  956. AM_CPPFLAGS="$AM_CPPFLAGS -ggdb3"
  957. fi
  958. AC_SUBST([AM_CFLAGS])
  959. AC_SUBST([AM_CPPFLAGS])
  960. # ----------------------------------------------------------------------
  961. # ----------------------------------------------------------------------
  962. # We're done, let's go!
  963. # ----------------------------------------------------------------------
  964. AC_DEFINE_UNQUOTED([COPYRIGHT], ["(C) 2004-2019 Hisham Muhammad. (C) 2020-2025 htop dev team."], [Copyright message.])
  965. AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
  966. AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
  967. AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
  968. AM_CONDITIONAL([HTOP_NETBSD], [test "$my_htop_platform" = netbsd])
  969. AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
  970. AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
  971. AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
  972. AM_CONDITIONAL([HTOP_PCP], [test "$my_htop_platform" = pcp])
  973. AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
  974. AC_SUBST(my_htop_platform)
  975. AC_CONFIG_FILES([Makefile htop.1])
  976. AC_OUTPUT
  977. if test "$my_htop_platform" = unsupported; then
  978. echo ""
  979. echo "****************************************************************"
  980. echo "WARNING! This platform is not currently supported by htop."
  981. echo ""
  982. echo "The code will build, but it will produce a dummy version of htop"
  983. echo "which shows no processes, using the files from the unsupported/"
  984. echo "directory. This is meant to be a skeleton, to be used as a"
  985. echo "starting point if you are porting htop to a new platform."
  986. echo "****************************************************************"
  987. echo ""
  988. fi
  989. AC_MSG_RESULT([
  990. ${PACKAGE_NAME} ${VERSION}
  991. platform: $my_htop_platform ($host_os)
  992. os-release file: $with_os_release
  993. (Linux) proc directory: $with_proc
  994. (Linux) openvz: $enable_openvz
  995. (Linux) vserver: $enable_vserver
  996. (Linux) ancient vserver: $enable_ancient_vserver
  997. (Linux) delay accounting: $enable_delayacct
  998. (Linux) sensors: $enable_sensors
  999. (Linux) capabilities: $enable_capabilities
  1000. unicode: $enable_unicode
  1001. affinity: $enable_affinity
  1002. unwind: $enable_unwind
  1003. hwloc: $enable_hwloc
  1004. debug: $enable_debug
  1005. static: $enable_static
  1006. ])