configure.ac 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  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.0-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([mach_timebase_info])
  323. AC_CHECK_DECLS([IOMainPort], [], [], [[#include <IOKit/IOKitLib.h>]])
  324. AC_CHECK_DECLS([IOMasterPort], [], [], [[#include <IOKit/IOKitLib.h>]])
  325. AC_CHECK_FUNCS([host_statistics64], [
  326. AC_CHECK_TYPES([struct vm_statistics64], [], [], [[#include <mach/vm_statistics.h>]])
  327. ], [])
  328. fi
  329. if test "$my_htop_platform" = pcp; then
  330. AC_CHECK_FUNCS([pmLookupDescs])
  331. fi
  332. if test "$my_htop_platform" = linux && test "x$enable_static" = xyes; then
  333. AC_CHECK_LIB([systemd], [sd_bus_open_system], [], [], [-lcap])
  334. fi
  335. # ----------------------------------------------------------------------
  336. # ----------------------------------------------------------------------
  337. # Checks for cross-platform features and flags.
  338. # ----------------------------------------------------------------------
  339. dnl PKG_PROG_PKG_CONFIG initializes $PKG_CONFIG and related variables.
  340. dnl If the macro is not called, some pkg-config checks might be skipped
  341. dnl and $PKG_CONFIG might be unset.
  342. m4_ifdef([PKG_PROG_PKG_CONFIG], [
  343. PKG_PROG_PKG_CONFIG()
  344. pkg_m4_included=1 # Makefile might grep this keyword. Don't remove.
  345. ], [
  346. m4_warn(
  347. [syntax],
  348. [pkg.m4 is absent or older than version 0.16; this 'configure' would have incomplete pkg-config support])
  349. ])
  350. AC_ARG_ENABLE([unicode],
  351. [AS_HELP_STRING([--enable-unicode],
  352. [enable Unicode support @<:@default=yes@:>@])],
  353. [],
  354. [enable_unicode=yes])
  355. AC_ARG_VAR([CURSES_CFLAGS], [C compiler flags for curses; this overrides auto detected values])
  356. AC_ARG_VAR([CURSES_LIBS], [linker flags for curses; this overrides auto detected values])
  357. curses_pkg_names="ncurses6 ncurses5 ncurses ncursest6 ncursest5 \
  358. ncursest curses"
  359. if test "x$enable_unicode" = xyes; then
  360. curses_pkg_names="ncursesw6 ncursesw5 ncursesw ncursestw6 ncursestw5 \
  361. ncursestw $curses_pkg_names"
  362. fi
  363. AC_ARG_WITH([curses],
  364. [AS_HELP_STRING([--with-curses=NAME],
  365. [select curses package NAME to link with; e.g. ncursesw6])],
  366. [],
  367. [with_curses=check])
  368. case $with_curses in
  369. check|yes)
  370. : # No-op. Use default list.
  371. ;;
  372. no)
  373. AC_MSG_ERROR([bad value '$with_curses' for --with-curses option])
  374. ;;
  375. *)
  376. if test "x${CURSES_CFLAGS+y}${CURSES_LIBS+y}" = xyy; then
  377. AC_MSG_WARN([ignoring --with-curses value due to override])
  378. fi
  379. curses_pkg_names=`echo "x$with_curses" | sed 's/^x\(lib\)\{0,1\}//'`
  380. ;;
  381. esac
  382. # $1: C preprocessor and compiler flags for curses library
  383. # $2: linker flags for curses library
  384. htop_check_curses_capability () {
  385. htop_curses_cflags=${CURSES_CFLAGS-"$1"}
  386. htop_curses_libs=${CURSES_LIBS-"$2"}
  387. echo "curses cflags${CURSES_CFLAGS+ (override)}: $htop_curses_cflags" >&AS_MESSAGE_LOG_FD
  388. echo "curses libs${CURSES_LIBS+ (override)}: $htop_curses_libs" >&AS_MESSAGE_LOG_FD
  389. htop_msg_linker_flags=$htop_curses_libs
  390. if test "`echo x $htop_msg_linker_flags`" = x; then
  391. htop_msg_linker_flags="(no linker flags)"
  392. fi
  393. htop_curses_status=0 # 0 for success; nonzero for failure
  394. htop_save_CFLAGS=$CFLAGS
  395. htop_save_LIBS=$LIBS
  396. CFLAGS="$AM_CFLAGS $htop_curses_cflags $CFLAGS"
  397. LIBS="$htop_curses_libs $LIBS"
  398. # At this point we have not checked the name of curses header, so
  399. # use forward declaration for the linking tests below.
  400. # htop uses keypad(), but for ncurses implementation, the symbol is
  401. # in "-ltinfo" and not "-lncurses".
  402. # Check "-ltinfo" symbols first, as libncurses might require
  403. # explicit "-ltinfo" to link (for internal dependency).
  404. AC_MSG_CHECKING([for keypad in $htop_msg_linker_flags])
  405. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  406. /* int keypad(WINDOW* win, bool enable); */
  407. int keypad(void* win, int enable);
  408. ]], [[
  409. static char dummy;
  410. keypad((void*)&dummy, 0);
  411. ]])],
  412. [AC_MSG_RESULT(yes)],
  413. [AC_MSG_RESULT(no)
  414. htop_curses_status=1])
  415. # htop calls refresh(), which might be implemented as a macro.
  416. # It is more reliable to test linking with doupdate(), which
  417. # refresh() would call internally.
  418. if test "$htop_curses_status" -eq 0; then
  419. AC_MSG_CHECKING([for doupdate in $htop_msg_linker_flags])
  420. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  421. int doupdate(void);
  422. ]], [[
  423. doupdate();
  424. ]])],
  425. [AC_MSG_RESULT(yes)
  426. htop_curses_capability=nonwide],
  427. [AC_MSG_RESULT(no)
  428. htop_curses_status=1])
  429. fi
  430. # htop calls mvadd_wchnstr(), which might be implemented as a macro.
  431. # It is more reliable to test linking with wadd_wchnstr().
  432. if test "x$htop_curses_status$enable_unicode" = x0yes; then
  433. AC_MSG_CHECKING([for wadd_wchnstr in $htop_msg_linker_flags])
  434. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  435. /* int wadd_wchnstr(WINDOW* win, const cchar_t* wchstr, int n); */
  436. int wadd_wchnstr(void* win, const void* wchstr, int n);
  437. ]], [[
  438. static char dummy1;
  439. static char dummy2;
  440. wadd_wchnstr((void*)&dummy1, (void*)&dummy2, 0);
  441. ]])],
  442. [AC_MSG_RESULT(yes)
  443. htop_curses_capability=wide],
  444. [AC_MSG_RESULT(no)
  445. htop_curses_status=1])
  446. fi
  447. if test "$htop_curses_status" -eq 0; then
  448. AM_CFLAGS="$AM_CFLAGS $htop_curses_cflags"
  449. if test "$htop_curses_capability" = wide; then
  450. AC_DEFINE([HAVE_LIBNCURSESW], 1, [libncursesw is present])
  451. else
  452. AC_DEFINE([HAVE_LIBNCURSES], 1, [libcurses is present])
  453. fi
  454. else
  455. LIBS=$htop_save_LIBS
  456. fi
  457. CFLAGS=$htop_save_CFLAGS
  458. return "$htop_curses_status"
  459. } # htop_check_curses_capability
  460. htop_curses_capability=none
  461. if test "x${CURSES_CFLAGS+y}${CURSES_LIBS+y}" = xyy; then
  462. curses_pkg_names=""
  463. htop_check_curses_capability "$CURSES_CFLAGS" "$CURSES_LIBS"
  464. fi
  465. # Prioritize $PKG_CONFIG over ncurses*-config, as users might need to
  466. # cross-compile htop.
  467. if test "x$PKG_CONFIG" != x; then
  468. pkg_config_static_flag=""
  469. if test "$enable_static" = yes; then
  470. pkg_config_static_flag=--static
  471. fi
  472. for curses_name in $curses_pkg_names; do
  473. echo retrieving $curses_name information through $PKG_CONFIG >&AS_MESSAGE_LOG_FD
  474. $PKG_CONFIG --exists --print-errors $curses_name >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD || continue
  475. : # Resets "$?" to 0
  476. htop_config_cflags=`$PKG_CONFIG --cflags $pkg_config_static_flag $curses_name 2>/dev/null` || continue
  477. : # Resets "$?" to 0
  478. htop_config_libs=`$PKG_CONFIG --libs $pkg_config_static_flag $curses_name 2>/dev/null` || continue
  479. AC_MSG_RESULT([found $curses_name information through $PKG_CONFIG])
  480. if htop_check_curses_capability "$htop_config_cflags" "$htop_config_libs"; then
  481. break
  482. fi
  483. done
  484. fi
  485. case ${htop_curses_capability}-$enable_unicode in
  486. none-*|nonwide-yes)
  487. for curses_name in $curses_pkg_names; do
  488. echo retrieving $curses_name information through ${curses_name}-config >&AS_MESSAGE_LOG_FD
  489. ${curses_name}-config --cflags >/dev/null 2>&AS_MESSAGE_LOG_FD || continue
  490. : # Resets "$?" to 0
  491. htop_config_cflags=`${curses_name}-config --cflags 2>/dev/null` || continue
  492. : # Resets "$?" to 0
  493. htop_config_libs=`${curses_name}-config --libs 2>/dev/null` || continue
  494. AC_MSG_RESULT([found $curses_name information through ${curses_name}-config])
  495. if htop_check_curses_capability "$htop_config_cflags" "$htop_config_libs"; then
  496. break
  497. fi
  498. done
  499. ;;
  500. esac
  501. case ${htop_curses_capability}-$enable_unicode in
  502. none-*|nonwide-yes)
  503. if test "x$PKG_CONFIG" = x; then (
  504. # Friendly warning to advise user to install pkg-config.
  505. # The local variables get discarded when done.
  506. list=""
  507. echo "" >conftest.c
  508. if test "$cross_compiling" != yes; then
  509. # "-print-multi-directory" supported in GCC 3.0 or later
  510. name=""
  511. if $CC $CPPFLAGS $CFLAGS -print-multi-directory -E conftest.c >/dev/null 2>&1; then
  512. name=`$CC $CPPFLAGS $CFLAGS -print-multi-directory -E conftest.c 2>/dev/null |
  513. sed '/^ *#/ d; s/^\.$//; q'`
  514. fi
  515. list="/usr/lib${name}/pkgconfig $list"
  516. case $host_os in
  517. darwin*)
  518. list="/opt/homebrew/Library/Homebrew/os/mac/pkgconfig $list"
  519. ;;
  520. freebsd*)
  521. list="/usr/libdata/pkgconfig $list"
  522. ;;
  523. netbsd*)
  524. list="/usr/pkg/lib/pkgconfig $list"
  525. ;;
  526. esac
  527. fi
  528. if test "x$host_alias" != x; then
  529. list="/usr/lib/${host_alias}/pkgconfig $list"
  530. fi
  531. # "-print-multiarch" supported in GCC 4.6 or later
  532. if $CC $CPPFLAGS $CFLAGS -print-multiarch -E conftest.c >/dev/null 2>&1; then
  533. name=`$CC $CPPFLAGS $CFLAGS -print-multiarch -E conftest.c 2>/dev/null |
  534. sed '/^ *#/ d; q'`
  535. if test "x$name" != x; then
  536. list="/usr/lib/${name}/pkgconfig $list"
  537. fi
  538. fi
  539. rm -f conftest.*
  540. for d in $list; do
  541. result=`find "$d" -name '*curses*.pc' 2>/dev/null | sed '1 q'`
  542. if test "x$result" != x; then
  543. echo detected a .pc file: "$result" >&AS_MESSAGE_LOG_FD
  544. AC_MSG_WARN([your system supports pkg-config; installing pkg-config is recommended before configuring htop])
  545. m4_ifdef([PKG_PROG_PKG_CONFIG], [], [
  546. AC_MSG_WARN([this configure script would also need to be regenerated])
  547. ])
  548. break
  549. fi
  550. done
  551. ) fi
  552. # OpenBSD and Solaris are known to not provide '*curses*.pc' files.
  553. AC_MSG_RESULT([no curses information found through '*-config' utilities; will guess the linker flags])
  554. for curses_name in $curses_pkg_names; do
  555. if htop_check_curses_capability "" "-l$curses_name"; then
  556. break
  557. fi
  558. # For ncurses implementation, an extra terminfo library might be
  559. # needed. Guess the terminfo library name based on the ncurses
  560. # library file name (e.g. "-ltinfow" for "-lncursesw"), before
  561. # trying the "-ltinfo" name.
  562. tinfo_name=`echo x$curses_name | sed 's/^xncurses/tinfo/p; d'`
  563. case x$tinfo_name in
  564. x|xtinfo)
  565. ;;
  566. *)
  567. if htop_check_curses_capability "" "-l$curses_name -l$tinfo_name"; then
  568. break
  569. fi
  570. ;;
  571. esac
  572. if htop_check_curses_capability "" "-l$curses_name -ltinfo"; then
  573. break
  574. fi
  575. done
  576. ;;
  577. esac
  578. case ${htop_curses_capability}-$enable_unicode in
  579. nonwide-yes)
  580. AC_MSG_ERROR([cannot find required ncursesw library; you may want to use --disable-unicode])
  581. ;;
  582. none-*)
  583. AC_MSG_ERROR([cannot find required curses/ncurses library])
  584. ;;
  585. esac
  586. htop_save_CFLAGS=$CFLAGS
  587. CFLAGS="$AM_CFLAGS $CFLAGS"
  588. if test "x$enable_unicode" = xyes; then
  589. AC_CHECK_HEADERS([ncursesw/curses.h], [],
  590. [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
  591. [AC_CHECK_HEADERS([ncurses/curses.h], [],
  592. [AC_CHECK_HEADERS([ncurses.h], [],
  593. [AC_MSG_ERROR([can not find required ncurses header file])])])])])
  594. AC_CHECK_HEADERS([ncursesw/term.h], [],
  595. [AC_CHECK_HEADERS([ncurses/term.h], [],
  596. [AC_CHECK_HEADERS([term.h], [],
  597. [AC_MSG_ERROR([can not find required term header file])])])])
  598. else
  599. AC_CHECK_HEADERS([curses.h], [],
  600. [AC_CHECK_HEADERS([ncurses/curses.h], [],
  601. [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
  602. [AC_CHECK_HEADERS([ncurses.h], [],
  603. [AC_MSG_ERROR([can not find required ncurses header file])])])])])
  604. AC_CHECK_HEADERS([ncurses/term.h], [],
  605. [AC_CHECK_HEADERS([term.h], [],
  606. [AC_MSG_ERROR([can not find required term header file])])])
  607. fi
  608. CFLAGS="-I$srcdir $CFLAGS"
  609. # Check for things that might be macros.
  610. # "stdscr" is a macro in ncursest (reentrant version of ncurses).
  611. AC_MSG_CHECKING([whether the curses header works])
  612. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  613. /* Checks if the "bool" definition in curses is ISO C compatible */
  614. #include <stdbool.h>
  615. #include "ProvideCurses.h"
  616. ]], [[
  617. keypad(stdscr, false);
  618. refresh();
  619. #if defined(HAVE_LIBNCURSESW)
  620. {
  621. static cchar_t dummy;
  622. mvadd_wchnstr(0, 0, &dummy, 0);
  623. }
  624. #endif
  625. ]])],
  626. [AC_MSG_RESULT(yes)],
  627. [AC_MSG_RESULT(no)
  628. AC_MSG_FAILURE([there are problems with the curses header])]
  629. )
  630. CFLAGS=$htop_save_CFLAGS
  631. if test "$enable_static" = yes; then
  632. AC_SEARCH_LIBS([Gpm_GetEvent], [gpm])
  633. fi
  634. if test "$my_htop_platform" = "solaris"; then
  635. # On OmniOS /usr/include/sys/regset.h redefines ERR to 13 - \r, breaking the Enter key.
  636. # Since ncurses macros use the ERR macro, we can not use another name.
  637. AC_DEFINE([ERR], [(-1)], [Predefine ncurses macro.])
  638. fi
  639. AC_CHECK_FUNCS( [set_escdelay] )
  640. AC_CHECK_FUNCS( [getmouse] )
  641. AC_DEFINE([NCURSES_ENABLE_STDBOOL_H], [1], [Define to enable stdbool.h in ncurses])
  642. AC_ARG_ENABLE([affinity],
  643. [AS_HELP_STRING([--enable-affinity],
  644. [enable sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
  645. [],
  646. [enable_affinity=check])
  647. if test "x$enable_affinity" = xcheck; then
  648. if test "x$enable_hwloc" = xyes; then
  649. enable_affinity=no
  650. else
  651. AC_MSG_CHECKING([for usable sched_setaffinity])
  652. AC_RUN_IFELSE([
  653. AC_LANG_PROGRAM([[
  654. #include <sched.h>
  655. #include <errno.h>
  656. static cpu_set_t cpuset;
  657. ]], [[
  658. CPU_ZERO(&cpuset);
  659. sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
  660. if (errno == ENOSYS) return 1;
  661. ]])],
  662. [enable_affinity=yes
  663. AC_MSG_RESULT([yes])],
  664. [enable_affinity=no
  665. AC_MSG_RESULT([no])],
  666. [AC_MSG_RESULT([assume yes (cross compiling)])])
  667. fi
  668. fi
  669. if test "x$enable_affinity" = xyes; then
  670. if test "x$enable_hwloc" = xyes; then
  671. AC_MSG_ERROR([--enable-hwloc and --enable-affinity are mutual exclusive. Specify at most one of them.])
  672. fi
  673. AC_DEFINE([HAVE_AFFINITY], [1], [Define if sched_setaffinity and sched_getaffinity are to be used.])
  674. fi
  675. AC_ARG_ENABLE([unwind],
  676. [AS_HELP_STRING([--enable-unwind],
  677. [enable unwind support for printing backtraces; requires libunwind @<:@default=check@:>@])],
  678. [],
  679. [enable_unwind=check])
  680. case "$enable_unwind" in
  681. check)
  682. enable_unwind=yes
  683. if test "$enable_static" = yes; then
  684. AC_CHECK_LIB([lzma], [lzma_index_buffer_decode])
  685. fi
  686. AC_CHECK_LIB([unwind], [backtrace], [], [enable_unwind=no])
  687. AC_CHECK_HEADERS([libunwind.h], [], [
  688. old_CFLAGS="$CFLAGS"
  689. CFLAGS="$CFLAGS -I/usr/include/libunwind"
  690. AC_CHECK_HEADERS([libunwind/libunwind.h], [], [
  691. enable_unwind=no
  692. CFLAGS="$old_CFLAGS"
  693. ])
  694. ])
  695. ;;
  696. no)
  697. ;;
  698. yes)
  699. AC_CHECK_LIB([unwind], [backtrace], [], [AC_MSG_ERROR([can not find required library libunwind])])
  700. AC_CHECK_HEADERS([libunwind.h], [], [
  701. AM_CFLAGS="$AM_CFLAGS -I/usr/include/libunwind"
  702. AC_CHECK_HEADERS([libunwind/libunwind.h], [], [AC_MSG_ERROR([can not find required header file libunwind.h])])
  703. ])
  704. ;;
  705. *)
  706. AC_MSG_ERROR([bad value '$enable_unwind' for --enable-unwind])
  707. ;;
  708. esac
  709. if test "x$enable_unwind" = xno; then
  710. # Fall back to backtrace(3) and add -lexecinfo if needed
  711. AC_SEARCH_LIBS([backtrace], [execinfo])
  712. fi
  713. AC_ARG_ENABLE([hwloc],
  714. [AS_HELP_STRING([--enable-hwloc],
  715. [enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
  716. [],
  717. [enable_hwloc=no])
  718. case "$enable_hwloc" in
  719. no)
  720. ;;
  721. yes)
  722. m4_ifdef([PKG_PROG_PKG_CONFIG], [
  723. PKG_CHECK_MODULES(HWLOC, hwloc, [
  724. AM_CFLAGS="$AM_CFLAGS $HWLOC_CFLAGS"
  725. LIBS="$LIBS $HWLOC_LIBS"
  726. AC_DEFINE([HAVE_LIBHWLOC], [1], [Define to 1 if you have the 'hwloc' library (-lhwloc).])
  727. ], [
  728. AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
  729. AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
  730. ])
  731. ], [
  732. AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
  733. AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
  734. ])
  735. ;;
  736. *)
  737. AC_MSG_ERROR([bad value '$enable_hwloc' for --enable-hwloc])
  738. ;;
  739. esac
  740. AC_ARG_WITH([os-release],
  741. [AS_HELP_STRING([--with-os-release=FILE],
  742. [location of an os-release file @<:@default=/etc/os-release@:>@])],
  743. [],
  744. [with_os_release=/etc/os-release])
  745. if test -n "$with_os_release" && test ! -f "$with_os_release"; then
  746. if test -f "/usr/lib/os-release"; then
  747. with_os_release="/usr/lib/os-release"
  748. fi
  749. fi
  750. AC_DEFINE_UNQUOTED([OSRELEASEFILE], ["$with_os_release"], [File with OS release details.])
  751. AC_ARG_WITH([config],
  752. [AS_HELP_STRING([--with-config=DIR],
  753. [configuration path @<:@default=/.config@:>@])],
  754. [],
  755. [with_config="/.config"])
  756. dnl Performance Co-Pilot configuration location to prevent overwrite
  757. if test "$my_htop_platform" = pcp -a "$with_config" = /.config; then
  758. with_config="/.pcp"
  759. elif test -z "$with_config"; then
  760. AC_MSG_ERROR([bad empty value for --with-config option])
  761. fi
  762. AC_DEFINE_UNQUOTED([CONFIGDIR], ["$with_config"], [Configuration path.])
  763. # ----------------------------------------------------------------------
  764. # ----------------------------------------------------------------------
  765. # Checks for Linux features and flags.
  766. # ----------------------------------------------------------------------
  767. AC_ARG_WITH([proc],
  768. [AS_HELP_STRING([--with-proc=DIR],
  769. [location of a Linux-compatible proc filesystem @<:@default=/proc@:>@])],
  770. [],
  771. [with_proc=/proc])
  772. if test -z "$with_proc"; then
  773. AC_MSG_ERROR([bad empty value for --with-proc option])
  774. fi
  775. AC_DEFINE_UNQUOTED([PROCDIR], ["$with_proc"], [Path of proc filesystem.])
  776. AC_ARG_ENABLE([openvz],
  777. [AS_HELP_STRING([--enable-openvz],
  778. [enable OpenVZ support @<:@default=no@:>@])],
  779. [],
  780. [enable_openvz=no])
  781. if test "x$enable_openvz" = xyes; then
  782. AC_DEFINE([HAVE_OPENVZ], [1], [Define if openvz support enabled.])
  783. fi
  784. AC_ARG_ENABLE([vserver],
  785. [AS_HELP_STRING([--enable-vserver],
  786. [enable VServer support @<:@default=no@:>@])],
  787. [],
  788. [enable_vserver=no])
  789. if test "x$enable_vserver" = xyes; then
  790. AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
  791. fi
  792. AC_ARG_ENABLE([ancient_vserver],
  793. [AS_HELP_STRING([--enable-ancient-vserver],
  794. [enable ancient VServer support (implies --enable-vserver) @<:@default=no@:>@])],
  795. [],
  796. [enable_ancient_vserver=no])
  797. if test "x$enable_ancient_vserver" = xyes; then
  798. if test "x$enable_vserver" != xyes; then
  799. enable_vserver=implied
  800. fi
  801. AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
  802. AC_DEFINE([HAVE_ANCIENT_VSERVER], [1], [Define if ancient vserver support enabled.])
  803. fi
  804. AC_ARG_ENABLE([capabilities],
  805. [AS_HELP_STRING([--enable-capabilities],
  806. [enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
  807. [],
  808. [enable_capabilities=check])
  809. case "$enable_capabilities" in
  810. no)
  811. ;;
  812. check)
  813. enable_capabilities=yes
  814. AC_CHECK_LIB([cap], [cap_init], [], [enable_capabilities=no])
  815. AC_CHECK_HEADERS([sys/capability.h], [], [enable_capabilities=no])
  816. ;;
  817. yes)
  818. AC_CHECK_LIB([cap], [cap_init], [], [AC_MSG_ERROR([can not find required library libcap])])
  819. AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([can not find required header file sys/capability.h])])
  820. ;;
  821. *)
  822. AC_MSG_ERROR([bad value '$enable_capabilities' for --enable-capabilities])
  823. ;;
  824. esac
  825. AC_ARG_ENABLE([delayacct],
  826. [AS_HELP_STRING([--enable-delayacct],
  827. [enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@default=check@:>@])],
  828. [],
  829. [enable_delayacct=check])
  830. case "$enable_delayacct" in
  831. no)
  832. ;;
  833. check)
  834. if test "$my_htop_platform" != linux; then
  835. enable_delayacct=no
  836. elif test "$enable_static" = yes; then
  837. enable_delayacct=no
  838. else
  839. old_CFLAGS="$CFLAGS"
  840. CFLAGS="$CFLAGS -I/usr/include/libnl3"
  841. AC_CHECK_HEADERS([netlink/attr.h netlink/handlers.h netlink/msg.h], [enable_delayacct=yes], [enable_delayacct=no])
  842. CFLAGS="$old_CFLAGS"
  843. fi
  844. ;;
  845. yes)
  846. old_CFLAGS="$CFLAGS"
  847. CFLAGS="$CFLAGS -I/usr/include/libnl3"
  848. 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])])
  849. CFLAGS="$old_CFLAGS"
  850. ;;
  851. *)
  852. AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct])
  853. ;;
  854. esac
  855. if test "$enable_delayacct" = yes; then
  856. AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
  857. AM_CFLAGS="$AM_CFLAGS -I/usr/include/libnl3"
  858. fi
  859. AM_CONDITIONAL([HAVE_DELAYACCT], [test "$enable_delayacct" = yes])
  860. AC_ARG_ENABLE([sensors],
  861. [AS_HELP_STRING([--enable-sensors],
  862. [enable libsensors support for reading temperature data; requires only libsensors headers at compile time, at runtime libsensors is loaded via dlopen @<:@default=check@:>@])],
  863. [],
  864. [enable_sensors=check])
  865. case "$enable_sensors" in
  866. no)
  867. ;;
  868. check)
  869. enable_sensors=yes
  870. if test "$enable_static" = yes; then
  871. AC_CHECK_LIB([sensors], [sensors_init], [], [enable_sensors=no])
  872. fi
  873. AC_CHECK_HEADERS([sensors/sensors.h], [], [enable_sensors=no])
  874. ;;
  875. yes)
  876. if test "$enable_static" = yes; then
  877. AC_CHECK_LIB([sensors], [sensors_init], [], [AC_MSG_ERROR([can not find required library libsensors])])
  878. fi
  879. AC_CHECK_HEADERS([sensors/sensors.h], [], [AC_MSG_ERROR([can not find required header file sensors/sensors.h])])
  880. ;;
  881. *)
  882. AC_MSG_ERROR([bad value '$enable_sensors' for --enable-sensors])
  883. ;;
  884. esac
  885. if test "$enable_sensors" = yes || test "$my_htop_platform" = freebsd; then
  886. AC_DEFINE([BUILD_WITH_CPU_TEMP], [1], [Define if CPU temperature option should be enabled.])
  887. fi
  888. # ----------------------------------------------------------------------
  889. # ----------------------------------------------------------------------
  890. # Checks for compiler warnings.
  891. # ----------------------------------------------------------------------
  892. AM_CFLAGS="$AM_CFLAGS\
  893. -Wall\
  894. -Wcast-align\
  895. -Wcast-qual\
  896. -Wextra\
  897. -Wfloat-equal\
  898. -Wformat=2\
  899. -Winit-self\
  900. -Wmissing-format-attribute\
  901. -Wmissing-noreturn\
  902. -Wmissing-prototypes\
  903. -Wpointer-arith\
  904. -Wshadow\
  905. -Wstrict-prototypes\
  906. -Wundef\
  907. -Wunused\
  908. -Wwrite-strings"
  909. dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
  910. AC_DEFUN([AX_CHECK_COMPILE_FLAG],
  911. [
  912. AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
  913. AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
  914. ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
  915. _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
  916. AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
  917. [AS_VAR_SET(CACHEVAR,[yes])],
  918. [AS_VAR_SET(CACHEVAR,[no])])
  919. _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
  920. AS_VAR_IF(CACHEVAR,yes,
  921. [m4_default([$2], :)],
  922. [m4_default([$3], :)])
  923. AS_VAR_POPDEF([CACHEVAR])dnl
  924. ])dnl AX_CHECK_COMPILE_FLAGS
  925. 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
  926. AX_CHECK_COMPILE_FLAG([-Wimplicit-int-conversion], [AM_CFLAGS="$AM_CFLAGS -Wimplicit-int-conversion"], , [-Werror])
  927. AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
  928. AC_ARG_ENABLE([werror],
  929. [AS_HELP_STRING([--enable-werror],
  930. [Treat warnings as errors @<:@default=no@:>@])],
  931. [],
  932. [enable_werror=no])
  933. if test "x$enable_werror" = xyes; then
  934. AM_CFLAGS="$AM_CFLAGS -Werror"
  935. fi
  936. AC_ARG_ENABLE([debug],
  937. [AS_HELP_STRING([--enable-debug],
  938. [Enable compiling with maximum debug info, asserts and internal sanity checks @<:@default=no@:>@])],
  939. [],
  940. [enable_debug=no])
  941. if test "x$enable_debug" != xyes; then
  942. AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
  943. AC_COMPILE_IFELSE([
  944. AC_LANG_SOURCE([[
  945. #ifdef __SUPPORT_SNAN__
  946. #error "signaling NaN support not recommended"
  947. #endif
  948. ]])],
  949. :,
  950. [warning_msg="signaling NaN support is enabled; not recommended for htop"
  951. case "$CC" in
  952. *gcc*)
  953. warning_msg="$warning_msg (use '-fno-signaling-nans' compiler flag to disable)"
  954. ;;
  955. esac
  956. AC_MSG_WARN([$warning_msg])
  957. ])
  958. else
  959. AM_CPPFLAGS="$AM_CPPFLAGS -ggdb3"
  960. fi
  961. AC_SUBST([AM_CFLAGS])
  962. AC_SUBST([AM_CPPFLAGS])
  963. # ----------------------------------------------------------------------
  964. # ----------------------------------------------------------------------
  965. # We're done, let's go!
  966. # ----------------------------------------------------------------------
  967. AC_DEFINE_UNQUOTED([COPYRIGHT], ["(C) 2004-2019 Hisham Muhammad. (C) 2020-2025 htop dev team."], [Copyright message.])
  968. AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
  969. AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
  970. AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
  971. AM_CONDITIONAL([HTOP_NETBSD], [test "$my_htop_platform" = netbsd])
  972. AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
  973. AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
  974. AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
  975. AM_CONDITIONAL([HTOP_PCP], [test "$my_htop_platform" = pcp])
  976. AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
  977. AC_SUBST(my_htop_platform)
  978. AC_CONFIG_FILES([Makefile htop.1])
  979. AC_OUTPUT
  980. if test "$my_htop_platform" = unsupported; then
  981. echo ""
  982. echo "****************************************************************"
  983. echo "WARNING! This platform is not currently supported by htop."
  984. echo ""
  985. echo "The code will build, but it will produce a dummy version of htop"
  986. echo "which shows no processes, using the files from the unsupported/"
  987. echo "directory. This is meant to be a skeleton, to be used as a"
  988. echo "starting point if you are porting htop to a new platform."
  989. echo "****************************************************************"
  990. echo ""
  991. fi
  992. AC_MSG_RESULT([
  993. ${PACKAGE_NAME} ${VERSION}
  994. platform: $my_htop_platform
  995. os-release file: $with_os_release
  996. (Linux) proc directory: $with_proc
  997. (Linux) openvz: $enable_openvz
  998. (Linux) vserver: $enable_vserver
  999. (Linux) ancient vserver: $enable_ancient_vserver
  1000. (Linux) delay accounting: $enable_delayacct
  1001. (Linux) sensors: $enable_sensors
  1002. (Linux) capabilities: $enable_capabilities
  1003. unicode: $enable_unicode
  1004. affinity: $enable_affinity
  1005. unwind: $enable_unwind
  1006. hwloc: $enable_hwloc
  1007. debug: $enable_debug
  1008. static: $enable_static
  1009. ])