blob: 8c9e484aa7681fd6c6558cf2d051a1a19d4900d2 [file] [log] [blame]
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
Christian Göttschef3623b72021-01-22 19:14:50 +01004# ----------------------------------------------------------------------
5# Autoconf initialization.
6# ----------------------------------------------------------------------
7
Christian Göttsche38b6a012021-01-22 19:14:53 +01008AC_PREREQ([2.69])
Daniel Lange2a58f5d2024-01-10 10:56:45 +01009AC_INIT([htop], [3.4.0-dev], [htop@groups.io], [], [https://htop.dev/])
Hisham Muhammad3383d8e2015-01-21 23:27:31 -020010
Explorer09b71b07f2016-03-12 12:02:06 +080011AC_CONFIG_SRCDIR([htop.c])
Christian Göttsche38b6a012021-01-22 19:14:53 +010012AC_CONFIG_AUX_DIR([build-aux])
Explorer09b71b07f2016-03-12 12:02:06 +080013AC_CONFIG_HEADERS([config.h])
Explorer09b71b07f2016-03-12 12:02:06 +080014
Sam James939685d2022-01-22 03:54:42 +000015AC_CANONICAL_HOST
Christian Göttsche38b6a012021-01-22 19:14:53 +010016AM_INIT_AUTOMAKE([-Wall std-options subdir-objects])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000017
Hisham Muhammad300af4b2014-11-19 23:17:16 -020018# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010019
20
21# ----------------------------------------------------------------------
22# Checks for platform.
23# ----------------------------------------------------------------------
24
Sam James939685d2022-01-22 03:54:42 +000025case "$host_os" in
Christian Göttschef3623b72021-01-22 19:14:50 +010026linux*|gnu*)
27 my_htop_platform=linux
28 AC_DEFINE([HTOP_LINUX], [], [Building for Linux.])
29 ;;
30freebsd*|kfreebsd*)
31 my_htop_platform=freebsd
32 AC_DEFINE([HTOP_FREEBSD], [], [Building for FreeBSD.])
33 ;;
fraggerfox4b49de42021-03-15 13:14:39 +053034netbsd*)
35 my_htop_platform=netbsd
36 AC_DEFINE([HTOP_NETBSD], [], [Building for NetBSD.])
37 ;;
Christian Göttschef3623b72021-01-22 19:14:50 +010038openbsd*)
39 my_htop_platform=openbsd
40 AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD.])
41 ;;
42dragonfly*)
43 my_htop_platform=dragonflybsd
44 AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD.])
45 ;;
46darwin*)
47 my_htop_platform=darwin
48 AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin.])
49 ;;
50solaris*)
51 my_htop_platform=solaris
52 AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris.])
53 ;;
54*)
55 my_htop_platform=unsupported
56 AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform.])
57 ;;
58esac
Hisham Muhammad4df76d12008-03-05 09:46:47 +000059
Christian Göttsche38b6a012021-01-22 19:14:53 +010060# Enable extensions, required by hwloc scripts
Explorer09b71b07f2016-03-12 12:02:06 +080061AC_USE_SYSTEM_EXTENSIONS
62
Benny Baumanna98fc472023-11-29 20:39:25 +010063# Activate some more of the missing global defines
64AC_SYS_LARGEFILE
65
Hisham Muhammadeb229d92014-11-24 18:55:03 -020066# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -020067
Christian Göttschef3623b72021-01-22 19:14:50 +010068
Hisham Muhammad300af4b2014-11-19 23:17:16 -020069# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010070# Checks for compiler.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020071# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000072
Christian Göttschef3623b72021-01-22 19:14:50 +010073AC_PROG_CC
74AM_PROG_CC_C_O
Christian Göttschea5e2eff2021-08-25 10:23:30 +020075m4_version_prereq([2.70], [], [AC_PROG_CC_C99])
Christian Göttsche38b6a012021-01-22 19:14:53 +010076AS_IF([test "x$ac_cv_prog_cc_c99" = xno], [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])])
Benny Baumann5c7cb912023-11-28 17:42:04 +010077AM_CFLAGS="-std=c99 -pedantic"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000078
Christian Göttschef3623b72021-01-22 19:14:50 +010079# ----------------------------------------------------------------------
80
81
82# ----------------------------------------------------------------------
Christian Göttsche575edff2021-01-22 19:14:59 +010083# Checks for static build.
84# ----------------------------------------------------------------------
85
86AC_ARG_ENABLE([static],
87 [AS_HELP_STRING([--enable-static],
88 [build a static htop binary @<:@default=no@:>@])],
89 [],
90 [enable_static=no])
91case "$enable_static" in
92 no)
93 ;;
94 yes)
95 AC_DEFINE([BUILD_STATIC], [1], [Define if building static binary.])
96 CFLAGS="$CFLAGS -static"
97 LDFLAGS="$LDFLAGS -static"
98 ;;
99 *)
100 AC_MSG_ERROR([bad value '$enable_static' for --enable-static option])
101 ;;
102esac
103
104# ----------------------------------------------------------------------
105
Nathan Scottc14a45b2021-02-17 14:43:56 +1100106# ----------------------------------------------------------------------
107# Checks for a PCP-based htop build. (https://pcp.io)
108# ----------------------------------------------------------------------
109
110AC_ARG_ENABLE([pcp],
111 [AS_HELP_STRING([--enable-pcp],
Nathan Scott9ce95572021-04-14 11:34:47 +1000112 [build a pcp-htop binary @<:@default=no@:>@])],
Nathan Scottc14a45b2021-02-17 14:43:56 +1100113 [],
114 [enable_pcp=no])
115case "$enable_pcp" in
116 no)
117 ;;
118 yes)
119 AC_CHECK_HEADERS([pcp/pmapi.h], [my_htop_platform=pcp],
Benny Baumann92324d32021-06-13 19:46:13 +0200120 [AC_MSG_ERROR([can not find PCP header file])])
Nathan Scott94d37982021-06-08 09:46:02 +1000121 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.])
Daniel Langefc2377f2021-08-14 10:35:11 +0200123 AC_CONFIG_FILES([pcp-htop.5])
Nathan Scottc14a45b2021-02-17 14:43:56 +1100124 ;;
125 *)
Nathan Scott6bb59f82021-02-19 14:13:27 +1100126 AC_MSG_ERROR([bad value '$enable_pcp' for --enable-pcp option])
Nathan Scottc14a45b2021-02-17 14:43:56 +1100127 ;;
128esac
129
130# ----------------------------------------------------------------------
131
Christian Göttsche575edff2021-01-22 19:14:59 +0100132
133# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100134# Checks for generic header files.
135# ----------------------------------------------------------------------
136
137AC_HEADER_DIRENT
Christian Göttschea5e2eff2021-08-25 10:23:30 +0200138m4_version_prereq([2.70], [AC_CHECK_INCLUDES_DEFAULT], [AC_HEADER_STDC])
Christian Göttschef3623b72021-01-22 19:14:50 +0100139AC_CHECK_HEADERS([ \
140 stdlib.h \
141 string.h \
142 strings.h \
143 sys/param.h \
144 sys/time.h \
Nathan Scott5b50ae32021-03-02 15:58:11 +1100145 sys/utsname.h \
Christian Göttschef3623b72021-01-22 19:14:50 +0100146 unistd.h
Christian Göttsche759a3402021-01-22 19:14:55 +0100147 ], [], [AC_MSG_ERROR([can not find required generic header files])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100148
149AC_HEADER_MAJOR
150dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
151dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
152dnl been updated in Autoconf 2.69, so use a workaround:
153m4_version_prereq([2.70], [],
154[if test "x$ac_cv_header_sys_mkdev_h" != xyes; then
155 AC_CHECK_HEADER([sys/sysmacros.h], [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
Explorer0947ae9662023-07-29 03:11:54 +0800156 [Define to 1 if 'major', 'minor', and 'makedev' are declared in <sys/sysmacros.h>.])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100157fi])
158
159# Optional Section
160
161AC_CHECK_HEADERS([execinfo.h])
162
163if test "$my_htop_platform" = darwin; then
164 AC_CHECK_HEADERS([mach/mach_time.h])
165fi
166
167# ----------------------------------------------------------------------
168
169
170# ----------------------------------------------------------------------
171# Checks for typedefs, structures, and compiler characteristics.
172# ----------------------------------------------------------------------
173
Benny Baumanna98fc472023-11-29 20:39:25 +0100174AC_TYPE_MBSTATE_T
175AC_TYPE_MODE_T
176AC_TYPE_OFF_T
Christian Göttschef3623b72021-01-22 19:14:50 +0100177AC_TYPE_PID_T
Benny Baumanna98fc472023-11-29 20:39:25 +0100178AC_TYPE_SIZE_T
179AC_TYPE_SSIZE_T
Christian Göttschef3623b72021-01-22 19:14:50 +0100180AC_TYPE_UID_T
181AC_TYPE_UINT8_T
182AC_TYPE_UINT16_T
183AC_TYPE_UINT32_T
184AC_TYPE_UINT64_T
185
Benny Baumann44d12002021-06-27 12:44:01 +0200186AC_MSG_CHECKING(for alloc_size)
187old_CFLAGS="$CFLAGS"
188CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
189AC_COMPILE_IFELSE([
190 AC_LANG_SOURCE(
191 [
192 __attribute__((alloc_size(1))) char* my_alloc(int size) { return 0; }
193 ],[]
194 )],
195 AC_DEFINE([HAVE_ATTR_ALLOC_SIZE], 1, [The alloc_size attribute is supported.])
196 AC_MSG_RESULT(yes),
197 AC_MSG_RESULT(no))
198CFLAGS="$old_CFLAGS"
199
Christian Göttsche8387df12023-02-04 17:34:08 +0100200AC_MSG_CHECKING(for access)
201old_CFLAGS="$CFLAGS"
202CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
203AC_COMPILE_IFELSE([
204 AC_LANG_SOURCE(
205 [
206 __attribute__((access(read_only, 1, 2))) extern int foo(const char* str, unsigned len);
207 ],[]
208 )],
209 AC_DEFINE([HAVE_ATTR_ACCESS], 1, [The access attribute is supported.])
210 AC_MSG_RESULT(yes),
211 AC_MSG_RESULT(no))
212CFLAGS="$old_CFLAGS"
213
Explorer09f541f702023-10-11 03:37:39 +0800214AC_MSG_CHECKING(for nonnull)
215old_CFLAGS="$CFLAGS"
216CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
217AC_COMPILE_IFELSE([
218 AC_LANG_SOURCE(
219 [[
220 /* Attribute supported in GCC 3.3 or later */
221 __attribute__((nonnull)) int my_strcmp(const char* a, const char* b);
222 __attribute__((nonnull(1))) long my_strtol(const char* str, char** endptr, int base);
223 ]]
224 )],
225 AC_DEFINE([HAVE_ATTR_NONNULL], 1, [The nonnull attribute is supported.])
226 AC_MSG_RESULT(yes),
227 AC_MSG_RESULT(no))
228CFLAGS="$old_CFLAGS"
229
Christian Göttscheaa0424a2021-08-08 16:54:20 +0200230AC_MSG_CHECKING(for NaN support)
Explorer09b4164332023-07-29 16:24:12 +0800231dnl Note: AC_RUN_IFELSE does not try compiling the program at all when
232dnl $cross_compiling is 'yes'.
233AC_LINK_IFELSE([
Christian Göttscheaa0424a2021-08-08 16:54:20 +0200234 AC_LANG_PROGRAM(
235 [[
Explorer09b4164332023-07-29 16:24:12 +0800236#include <math.h>
Christian Göttscheaa0424a2021-08-08 16:54:20 +0200237 ]],
238 [[
Explorer09b4164332023-07-29 16:24:12 +0800239 double x = NAN;
240 /* Both should evaluate to false -> 0 (exit success) */
241 return isgreater(x, x) || isgreaterequal(x, x);
Christian Göttscheaa0424a2021-08-08 16:54:20 +0200242 ]]
243 )],
Explorer09b4164332023-07-29 16:24:12 +0800244 [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)]),
Benny Baumann6aa9ef22023-11-23 12:22:02 +0100254 flag_finite_math_only=yes)
Explorer09b4164332023-07-29 16:24:12 +0800255 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
Christian Göttscheaa0424a2021-08-08 16:54:20 +0200262 AC_MSG_RESULT(no)
Explorer09b4164332023-07-29 16:24:12 +0800263 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()])])
Christian Göttscheaa0424a2021-08-08 16:54:20 +0200267
Christian Göttschef3623b72021-01-22 19:14:50 +0100268# ----------------------------------------------------------------------
269
270
271# ----------------------------------------------------------------------
272# Checks for generic library functions.
273# ----------------------------------------------------------------------
274
Christian Göttschee34c3872022-08-09 21:37:14 +0200275AC_SEARCH_LIBS([ceil], [m], [], [AC_MSG_ERROR([can not find required function ceil()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100276
277if test "$my_htop_platform" = dragonflybsd; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100278 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
Christian Göttsche2f67a2b2024-01-19 21:06:14 +0100279 AC_SEARCH_LIBS([getdevs], [devstat], [], [AC_MSG_ERROR([can not find required function getdevs()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100280fi
281
282if test "$my_htop_platform" = freebsd; then
Christian Göttschecae47bb2021-02-05 15:15:01 +0100283 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
Christian Göttsche759a3402021-01-22 19:14:55 +0100286 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()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100288fi
289
290if test "$my_htop_platform" = linux; then
Christian Göttsche575edff2021-01-22 19:14:59 +0100291 if test "$enable_static" != yes; then
292 AC_SEARCH_LIBS([dlopen], [dl dld], [], [AC_MSG_ERROR([can not find required function dlopen()])])
293 fi
Christian Göttschef3623b72021-01-22 19:14:50 +0100294fi
295
fraggerfox4b49de42021-03-15 13:14:39 +0530296if test "$my_htop_platform" = netbsd; then
297 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
niafdcdc542021-07-26 19:04:44 +0200298 AC_SEARCH_LIBS([prop_dictionary_get], [prop], [], [AC_MSG_ERROR([can not find required function prop_dictionary_get()])])
fraggerfox4b49de42021-03-15 13:14:39 +0530299fi
300
Christian Göttschef3623b72021-01-22 19:14:50 +0100301if test "$my_htop_platform" = openbsd; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100302 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100303fi
304
305if test "$my_htop_platform" = solaris; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100306 AC_SEARCH_LIBS([kstat_open], [kstat], [], [AC_MSG_ERROR([can not find required function kstat_open()])])
307 AC_SEARCH_LIBS([Pgrab_error], [proc], [], [AC_MSG_ERROR([can not find required function Pgrab_error()])])
308 AC_SEARCH_LIBS([free], [malloc], [], [AC_MSG_ERROR([can not find required function free()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100309fi
310
311# Optional Section
312
313AC_SEARCH_LIBS([clock_gettime], [rt])
314
315AC_CHECK_FUNCS([ \
316 clock_gettime \
Christian Göttsche29e1fcf2021-05-16 20:45:09 +0200317 dladdr \
Christian Göttschef3623b72021-01-22 19:14:50 +0100318 faccessat \
319 fstatat \
320 host_get_clock_service \
Christian Göttsche7b1fa1b2020-12-25 11:03:15 +0100321 memfd_create\
Christian Göttschef3623b72021-01-22 19:14:50 +0100322 openat \
323 readlinkat \
Christian Göttscheda494892023-01-10 19:40:04 +0100324 sched_getscheduler \
325 sched_setscheduler \
Nathan Scott4103c232023-10-09 10:48:38 +1100326 strchrnul \
Christian Göttschef3623b72021-01-22 19:14:50 +0100327 ])
328
Christian Göttschef3623b72021-01-22 19:14:50 +0100329if test "$my_htop_platform" = darwin; then
330 AC_CHECK_FUNCS([mach_timebase_info])
UeiWanged7eac52023-04-16 23:11:20 +0800331 AC_CHECK_DECLS([IOMainPort], [], [], [[#include <IOKit/IOKitLib.h>]])
332 AC_CHECK_DECLS([IOMasterPort], [], [], [[#include <IOKit/IOKitLib.h>]])
Christian Göttschef3623b72021-01-22 19:14:50 +0100333fi
Christian Goettschec2fdfd92020-10-21 17:06:32 +0200334
Nathan Scottd58180b2022-09-13 12:14:40 +1000335if test "$my_htop_platform" = pcp; then
336 AC_CHECK_FUNCS([pmLookupDescs])
337fi
338
Christian Göttsche575edff2021-01-22 19:14:59 +0100339if test "$my_htop_platform" = linux && test "x$enable_static" = xyes; then
Christian Göttschee59176f2024-01-10 17:12:18 +0100340 AC_CHECK_LIB([systemd], [sd_bus_open_system], [], [], [-lcap])
Christian Göttsche575edff2021-01-22 19:14:59 +0100341fi
342
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200343# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200344
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000345
Christian Göttschef3623b72021-01-22 19:14:50 +0100346# ----------------------------------------------------------------------
347# Checks for cross-platform features and flags.
348# ----------------------------------------------------------------------
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000349
Hisham Muhammaddb682862015-12-09 17:17:30 -0200350# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
351m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200352[
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300353 if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
354 # to be used to set the path to ncurses*-config when cross-compiling
Michael Kleinbc5d4692018-02-26 14:19:01 +0100355 htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
356 htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300357 else
Michael Kleinbc5d4692018-02-26 14:19:01 +0100358 htop_config_script_libs=$([$4] --libs 2> /dev/null)
359 htop_config_script_cflags=$([$4] --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300360 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200361 htop_script_success=no
Benny Baumann5c7cb912023-11-28 17:42:04 +0100362 htop_save_CFLAGS="$AM_CFLAGS"
Michael Kleinbc5d4692018-02-26 14:19:01 +0100363 if test ! "x$htop_config_script_libs" = x; then
Benny Baumann5c7cb912023-11-28 17:42:04 +0100364 AM_CFLAGS="$AM_CFLAGS $htop_config_script_cflags"
Hisham Muhammaddb682862015-12-09 17:17:30 -0200365 AC_CHECK_LIB([$1], [$2], [
366 AC_DEFINE([$3], 1, [The library is present.])
Michael Kleinbc5d4692018-02-26 14:19:01 +0100367 LIBS="$htop_config_script_libs $LIBS "
Hisham Muhammaddb682862015-12-09 17:17:30 -0200368 htop_script_success=yes
Michael Kleinbc5d4692018-02-26 14:19:01 +0100369 ], [
Benny Baumann5c7cb912023-11-28 17:42:04 +0100370 AM_CFLAGS="$htop_save_CFLAGS"
Christian Göttsche575edff2021-01-22 19:14:59 +0100371 ], [
372 $htop_config_script_libs
Michael Kleinbc5d4692018-02-26 14:19:01 +0100373 ])
Hisham Muhammadc2377022015-12-06 19:06:23 -0200374 fi
Hisham Muhammadcccc18d2015-12-09 17:34:57 -0200375 if test "x$htop_script_success" = xno; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200376 [$5]
377 fi
378])
379
380# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
381m4_define([HTOP_CHECK_LIB],
382[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200383 AC_CHECK_LIB([$1], [$2], [
Christian Göttsche575edff2021-01-22 19:14:59 +0100384 AC_DEFINE([$3], [1], [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200385 LIBS="-l[$1] $LIBS "
386 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200387])
388
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100389AC_ARG_ENABLE([unicode],
390 [AS_HELP_STRING([--enable-unicode],
391 [enable Unicode support @<:@default=yes@:>@])],
392 [],
393 [enable_unicode=yes])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000394if test "x$enable_unicode" = xyes; then
Christian Göttschefd8c0612021-01-28 17:40:33 +0100395 HTOP_CHECK_SCRIPT([ncursesw6], [waddwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
396 HTOP_CHECK_SCRIPT([ncursesw], [waddwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
397 HTOP_CHECK_SCRIPT([ncursesw], [wadd_wch], [HAVE_LIBNCURSESW], "ncursesw5-config",
398 HTOP_CHECK_SCRIPT([ncurses], [wadd_wch], [HAVE_LIBNCURSESW], "ncurses5-config",
399 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
400 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
401 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
Christian Göttsche759a3402021-01-22 19:14:55 +0100402 AC_MSG_ERROR([can not find required library libncursesw; you may want to use --disable-unicode])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200403 )))))))
Hisham Muhammaddb682862015-12-09 17:17:30 -0200404
Christian Göttsche759a3402021-01-22 19:14:55 +0100405 AC_CHECK_HEADERS([ncursesw/curses.h], [],
406 [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
407 [AC_CHECK_HEADERS([ncurses/curses.h], [],
408 [AC_CHECK_HEADERS([ncurses.h], [],
409 [AC_MSG_ERROR([can not find required ncurses header file])])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100410
Sahil Siddiq3fc28622023-02-07 22:56:57 +0530411 AC_CHECK_HEADERS([ncursesw/term.h], [],
412 [AC_CHECK_HEADERS([ncurses/term.h], [],
413 [AC_CHECK_HEADERS([term.h], [],
414 [AC_MSG_ERROR([can not find required term header file])])])])
415
Christian Göttscheead978b2020-12-07 15:30:56 +0100416 # check if additional linker flags are needed for keypad(3)
417 # (at this point we already link against a working ncurses library with wide character support)
418 AC_SEARCH_LIBS([keypad], [tinfow tinfo])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000419else
Christian Göttsche575edff2021-01-22 19:14:59 +0100420 HTOP_CHECK_SCRIPT([ncurses6], [wnoutrefresh], [HAVE_LIBNCURSES], [ncurses6-config],
421 HTOP_CHECK_SCRIPT([ncurses], [wnoutrefresh], [HAVE_LIBNCURSES], [ncurses5-config],
Christian Göttschefd8c0612021-01-28 17:40:33 +0100422 HTOP_CHECK_LIB([ncurses6], [doupdate], [HAVE_LIBNCURSES],
423 HTOP_CHECK_LIB([ncurses], [doupdate], [HAVE_LIBNCURSES],
nia09c7e3e2021-07-13 17:53:47 +0200424 HTOP_CHECK_LIB([curses], [doupdate], [HAVE_LIBNCURSES],
425 AC_MSG_ERROR([can not find required curses/ncurses library])
426 )))))
Christian Göttscheb92f62f2020-08-21 10:37:33 +0200427
Christian Göttsche759a3402021-01-22 19:14:55 +0100428 AC_CHECK_HEADERS([curses.h], [],
429 [AC_CHECK_HEADERS([ncurses/curses.h], [],
430 [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
Sahil Siddiq3fc28622023-02-07 22:56:57 +0530431 [AC_CHECK_HEADERS([ncurses.h], [],
Christian Göttsche759a3402021-01-22 19:14:55 +0100432 [AC_MSG_ERROR([can not find required ncurses header file])])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100433
Sahil Siddiq3fc28622023-02-07 22:56:57 +0530434 AC_CHECK_HEADERS([ncurses/term.h], [],
435 [AC_CHECK_HEADERS([term.h], [],
436 [AC_MSG_ERROR([can not find required term header file])])])
437
Christian Göttscheead978b2020-12-07 15:30:56 +0100438 # check if additional linker flags are needed for keypad(3)
439 # (at this point we already link against a working ncurses library)
440 AC_SEARCH_LIBS([keypad], [tinfo])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000441fi
Sahil Siddiq3fc28622023-02-07 22:56:57 +0530442
Christian Göttsche575edff2021-01-22 19:14:59 +0100443if test "$enable_static" = yes; then
444 AC_SEARCH_LIBS([Gpm_GetEvent], [gpm])
445fi
Christian Göttscheee9e7ed2021-05-20 18:27:10 +0200446if test "$my_htop_platform" = "solaris"; then
447 # On OmniOS /usr/include/sys/regset.h redefines ERR to 13 - \r, breaking the Enter key.
Nathan Scottca06e682021-09-08 12:11:51 +1000448 # Since ncurses macros use the ERR macro, we can not use another name.
Christian Göttscheee9e7ed2021-05-20 18:27:10 +0200449 AC_DEFINE([ERR], [(-1)], [Predefine ncurses macro.])
450fi
Benny Baumann18e3fd52021-07-04 16:50:41 +0200451AC_CHECK_FUNCS( [set_escdelay] )
nia2ab8fb82021-07-14 20:17:13 +0200452AC_CHECK_FUNCS( [getmouse] )
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000453
gmbroome697f5bb2018-03-02 16:20:46 -0500454
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200455AC_ARG_ENABLE([affinity],
456 [AS_HELP_STRING([--enable-affinity],
457 [enable sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
458 [],
459 [enable_affinity=check])
460if test "x$enable_affinity" = xcheck; then
461 if test "x$enable_hwloc" = xyes; then
462 enable_affinity=no
463 else
464 AC_MSG_CHECKING([for usable sched_setaffinity])
465 AC_RUN_IFELSE([
466 AC_LANG_PROGRAM([[
467 #include <sched.h>
468 #include <errno.h>
469 static cpu_set_t cpuset;
470 ]], [[
471 CPU_ZERO(&cpuset);
472 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
473 if (errno == ENOSYS) return 1;
474 ]])],
475 [enable_affinity=yes
476 AC_MSG_RESULT([yes])],
477 [enable_affinity=no
478 AC_MSG_RESULT([no])],
Explorer0947ae9662023-07-29 03:11:54 +0800479 [AC_MSG_RESULT([assume yes (cross compiling)])])
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200480 fi
481fi
482if test "x$enable_affinity" = xyes; then
483 if test "x$enable_hwloc" = xyes; then
484 AC_MSG_ERROR([--enable-hwloc and --enable-affinity are mutual exclusive. Specify at most one of them.])
485 fi
486 AC_DEFINE([HAVE_AFFINITY], [1], [Define if sched_setaffinity and sched_getaffinity are to be used.])
487fi
488
489
Christian Göttsche29e1fcf2021-05-16 20:45:09 +0200490AC_ARG_ENABLE([unwind],
491 [AS_HELP_STRING([--enable-unwind],
492 [enable unwind support for printing backtraces; requires libunwind @<:@default=check@:>@])],
493 [],
494 [enable_unwind=check])
495case "$enable_unwind" in
496 check)
497 enable_unwind=yes
498 if test "$enable_static" = yes; then
499 AC_CHECK_LIB([lzma], [lzma_index_buffer_decode])
500 fi
501 AC_CHECK_LIB([unwind], [backtrace], [], [enable_unwind=no])
Christian Göttsche63880332021-12-14 17:36:57 +0100502 AC_CHECK_HEADERS([libunwind.h], [], [
503 old_CFLAGS="$CFLAGS"
504 CFLAGS="$CFLAGS -I/usr/include/libunwind"
505 AC_CHECK_HEADERS([libunwind/libunwind.h], [], [
506 enable_unwind=no
507 CFLAGS="$old_CFLAGS"
508 ])
509 ])
Christian Göttsche29e1fcf2021-05-16 20:45:09 +0200510 ;;
511 no)
512 ;;
513 yes)
514 AC_CHECK_LIB([unwind], [backtrace], [], [AC_MSG_ERROR([can not find required library libunwind])])
Christian Göttsche63880332021-12-14 17:36:57 +0100515 AC_CHECK_HEADERS([libunwind.h], [], [
Benny Baumann5c7cb912023-11-28 17:42:04 +0100516 AM_CFLAGS="$AM_CFLAGS -I/usr/include/libunwind"
Christian Göttsche63880332021-12-14 17:36:57 +0100517 AC_CHECK_HEADERS([libunwind/libunwind.h], [], [AC_MSG_ERROR([can not find required header file libunwind.h])])
518 ])
Christian Göttsche29e1fcf2021-05-16 20:45:09 +0200519 ;;
520 *)
521 AC_MSG_ERROR([bad value '$enable_unwind' for --enable-unwind])
522 ;;
523esac
524if test "x$enable_unwind" = xno; then
525 # Fall back to backtrace(3) and add -lexecinfo if needed
526 AC_SEARCH_LIBS([backtrace], [execinfo])
527fi
528
529
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100530AC_ARG_ENABLE([hwloc],
531 [AS_HELP_STRING([--enable-hwloc],
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200532 [enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100533 [],
534 [enable_hwloc=no])
535case "$enable_hwloc" in
536 no)
537 ;;
538 yes)
Fabrice Fontaine4ccad462022-04-02 17:27:01 +0200539 m4_ifdef([PKG_PROG_PKG_CONFIG], [
540 PKG_PROG_PKG_CONFIG()
541 PKG_CHECK_MODULES(HWLOC, hwloc, [
Benny Baumann5c7cb912023-11-28 17:42:04 +0100542 AM_CFLAGS="$AM_CFLAGS $HWLOC_CFLAGS"
Christian Göttschec8a61852023-04-05 01:21:14 +0200543 LIBS="$LIBS $HWLOC_LIBS"
Explorer0947ae9662023-07-29 03:11:54 +0800544 AC_DEFINE([HAVE_LIBHWLOC], [1], [Define to 1 if you have the 'hwloc' library (-lhwloc).])
Fabrice Fontaine4ccad462022-04-02 17:27:01 +0200545 ], [
546 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
547 AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
548 ])
549 ], [
550 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
551 AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
552 ])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100553 ;;
554 *)
555 AC_MSG_ERROR([bad value '$enable_hwloc' for --enable-hwloc])
556 ;;
557esac
Christian Göttsche005c4d12020-09-08 16:25:22 +0200558
Christian Göttsche29e1fcf2021-05-16 20:45:09 +0200559
Nathan Scott5b50ae32021-03-02 15:58:11 +1100560AC_ARG_WITH([os-release],
561 [AS_HELP_STRING([--with-os-release=FILE],
Christian Göttsche8ba4ef32021-03-12 16:37:17 +0100562 [location of an os-release file @<:@default=/etc/os-release@:>@])],
Nathan Scott5b50ae32021-03-02 15:58:11 +1100563 [],
564 [with_os_release=/etc/os-release])
Christian Göttsche8ba4ef32021-03-12 16:37:17 +0100565if test -n "$with_os_release" && test ! -f "$with_os_release"; then
Nathan Scott5b50ae32021-03-02 15:58:11 +1100566 if test -f "/usr/lib/os-release"; then
567 with_os_release="/usr/lib/os-release"
568 fi
569fi
570AC_DEFINE_UNQUOTED([OSRELEASEFILE], ["$with_os_release"], [File with OS release details.])
571
Christian Göttschef3623b72021-01-22 19:14:50 +0100572# ----------------------------------------------------------------------
573
574
575# ----------------------------------------------------------------------
576# Checks for Linux features and flags.
577# ----------------------------------------------------------------------
578
579AC_ARG_WITH([proc],
580 [AS_HELP_STRING([--with-proc=DIR],
581 [location of a Linux-compatible proc filesystem @<:@default=/proc@:>@])],
582 [],
583 [with_proc=/proc])
584if test -z "$with_proc"; then
585 AC_MSG_ERROR([bad empty value for --with-proc option])
586fi
587AC_DEFINE_UNQUOTED([PROCDIR], ["$with_proc"], [Path of proc filesystem.])
588
589
590AC_ARG_ENABLE([openvz],
591 [AS_HELP_STRING([--enable-openvz],
592 [enable OpenVZ support @<:@default=no@:>@])],
593 [],
594 [enable_openvz=no])
595if test "x$enable_openvz" = xyes; then
596 AC_DEFINE([HAVE_OPENVZ], [1], [Define if openvz support enabled.])
597fi
598
599
600AC_ARG_ENABLE([vserver],
601 [AS_HELP_STRING([--enable-vserver],
602 [enable VServer support @<:@default=no@:>@])],
603 [],
604 [enable_vserver=no])
605if test "x$enable_vserver" = xyes; then
Christian Göttsche284f8c52021-09-02 22:32:46 +0200606 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
Christian Göttschef3623b72021-01-22 19:14:50 +0100607fi
608
609
610AC_ARG_ENABLE([ancient_vserver],
611 [AS_HELP_STRING([--enable-ancient-vserver],
612 [enable ancient VServer support (implies --enable-vserver) @<:@default=no@:>@])],
613 [],
614 [enable_ancient_vserver=no])
615if test "x$enable_ancient_vserver" = xyes; then
Christian Göttsche284f8c52021-09-02 22:32:46 +0200616 if test "x$enable_vserver" != xyes; then
617 enable_vserver=implied
618 fi
619 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
620 AC_DEFINE([HAVE_ANCIENT_VSERVER], [1], [Define if ancient vserver support enabled.])
Christian Göttschef3623b72021-01-22 19:14:50 +0100621fi
622
623
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100624AC_ARG_ENABLE([capabilities],
625 [AS_HELP_STRING([--enable-capabilities],
626 [enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
627 [],
628 [enable_capabilities=check])
629case "$enable_capabilities" in
630 no)
631 ;;
632 check)
633 enable_capabilities=yes
634 AC_CHECK_LIB([cap], [cap_init], [], [enable_capabilities=no])
635 AC_CHECK_HEADERS([sys/capability.h], [], [enable_capabilities=no])
636 ;;
637 yes)
Christian Göttsche759a3402021-01-22 19:14:55 +0100638 AC_CHECK_LIB([cap], [cap_init], [], [AC_MSG_ERROR([can not find required library libcap])])
639 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([can not find required header file sys/capability.h])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100640 ;;
641 *)
642 AC_MSG_ERROR([bad value '$enable_capabilities' for --enable-capabilities])
643 ;;
644esac
Christian Göttschef4404ef2020-09-02 14:39:25 +0200645
Christian Göttschef3623b72021-01-22 19:14:50 +0100646
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100647AC_ARG_ENABLE([delayacct],
648 [AS_HELP_STRING([--enable-delayacct],
649 [enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@default=check@:>@])],
650 [],
651 [enable_delayacct=check])
652case "$enable_delayacct" in
653 no)
654 ;;
655 check)
Christian Göttsche69cfaf22021-05-16 20:01:25 +0200656 if test "$my_htop_platform" != linux; then
657 enable_delayacct=no
658 elif test "$enable_static" = yes; then
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100659 enable_delayacct=no
Christian Göttsche575edff2021-01-22 19:14:59 +0100660 else
661 m4_ifdef([PKG_PROG_PKG_CONFIG], [
662 enable_delayacct=yes
663 PKG_PROG_PKG_CONFIG()
664 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [enable_delayacct=no])
665 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [enable_delayacct=no])
666 if test "$enable_delayacct" = yes; then
Benny Baumann5c7cb912023-11-28 17:42:04 +0100667 AM_CFLAGS="$AM_CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
Christian Göttsche575edff2021-01-22 19:14:59 +0100668 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
669 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
670 fi
671 ], [
672 enable_delayacct=no
673 AC_MSG_NOTICE([Linux delay accounting support can not be enabled, cause pkg-config is required for checking its availability])
674 ])
675 fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100676 ;;
677 yes)
678 m4_ifdef([PKG_PROG_PKG_CONFIG], [
679 PKG_PROG_PKG_CONFIG()
Christian Göttsche759a3402021-01-22 19:14:55 +0100680 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3])])
681 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3genl])])
Benny Baumann5c7cb912023-11-28 17:42:04 +0100682 AM_CFLAGS="$AM_CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100683 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
684 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
685 ], [
686 pkg_m4_absent=1
687 m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.])
688 AC_MSG_ERROR([htop on Linux requires pkg-config for checking delayacct requirements. Please install pkg-config and run ./autogen.sh to rebuild the configure script.])
689 ])
690 ;;
691 *)
692 AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct])
693 ;;
694esac
André Carvalhob7b66b72017-12-04 00:15:29 -0200695
Christian Göttschef3623b72021-01-22 19:14:50 +0100696
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100697AC_ARG_ENABLE([sensors],
698 [AS_HELP_STRING([--enable-sensors],
699 [enable libsensors support for reading temperature data; requires only libsensors headers at compile time, at runtime libsensors is loaded via dlopen @<:@default=check@:>@])],
700 [],
701 [enable_sensors=check])
702case "$enable_sensors" in
703 no)
704 ;;
705 check)
706 enable_sensors=yes
Christian Göttsche575edff2021-01-22 19:14:59 +0100707 if test "$enable_static" = yes; then
708 AC_CHECK_LIB([sensors], [sensors_init], [], [enable_sensors=no])
709 fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100710 AC_CHECK_HEADERS([sensors/sensors.h], [], [enable_sensors=no])
711 ;;
712 yes)
Christian Göttsche575edff2021-01-22 19:14:59 +0100713 if test "$enable_static" = yes; then
714 AC_CHECK_LIB([sensors], [sensors_init], [], [AC_MSG_ERROR([can not find required library libsensors])])
715 fi
716 AC_CHECK_HEADERS([sensors/sensors.h], [], [AC_MSG_ERROR([can not find required header file sensors/sensors.h])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100717 ;;
718 *)
719 AC_MSG_ERROR([bad value '$enable_sensors' for --enable-sensors])
720 ;;
721esac
Christian Göttschefd2a0cf2020-12-22 20:02:01 +0100722if test "$enable_sensors" = yes || test "$my_htop_platform" = freebsd; then
723 AC_DEFINE([BUILD_WITH_CPU_TEMP], [1], [Define if CPU temperature option should be enabled.])
724fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100725
Christian Göttschef3623b72021-01-22 19:14:50 +0100726# ----------------------------------------------------------------------
727
728
729# ----------------------------------------------------------------------
730# Checks for compiler warnings.
731# ----------------------------------------------------------------------
Christian Göttsche1b225cd2020-09-10 19:56:33 +0200732
Benny Baumann5c7cb912023-11-28 17:42:04 +0100733AM_CFLAGS="$AM_CFLAGS\
Christian Göttschef4602f72020-09-08 14:25:46 +0200734 -Wall\
735 -Wcast-align\
Christian Göttschedb472072020-10-04 14:30:35 +0200736 -Wcast-qual\
Christian Göttschef4602f72020-09-08 14:25:46 +0200737 -Wextra\
Benny Baumannba0fca12020-09-18 16:58:03 +0200738 -Wfloat-equal\
Christian Göttschec150e4b2020-12-18 15:49:37 +0100739 -Wformat=2\
Christian Göttsche4dadbe32021-01-21 19:49:07 +0100740 -Winit-self\
Christian Göttschef4602f72020-09-08 14:25:46 +0200741 -Wmissing-format-attribute\
742 -Wmissing-noreturn\
Christian Göttsche4e282eb2020-09-25 14:03:55 +0200743 -Wmissing-prototypes\
Christian Göttschef4602f72020-09-08 14:25:46 +0200744 -Wpointer-arith\
745 -Wshadow\
746 -Wstrict-prototypes\
747 -Wundef\
748 -Wunused\
749 -Wwrite-strings"
750
Christian Göttschef3623b72021-01-22 19:14:50 +0100751dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
752AC_DEFUN([AX_CHECK_COMPILE_FLAG],
Christian Göttsche38b6a012021-01-22 19:14:53 +0100753[
Christian Göttschef3623b72021-01-22 19:14:50 +0100754AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
755AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
756 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
757 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
758 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
759 [AS_VAR_SET(CACHEVAR,[yes])],
760 [AS_VAR_SET(CACHEVAR,[no])])
761 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
762AS_VAR_IF(CACHEVAR,yes,
763 [m4_default([$2], :)],
764 [m4_default([$3], :)])
765AS_VAR_POPDEF([CACHEVAR])dnl
766])dnl AX_CHECK_COMPILE_FLAGS
767
Christian Göttsche970885e2021-08-14 11:21:54 +0200768AX_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
Christian Göttsche53732ab2021-08-14 11:26:43 +0200769AX_CHECK_COMPILE_FLAG([-Wimplicit-int-conversion], [AM_CFLAGS="$AM_CFLAGS -Wimplicit-int-conversion"], , [-Werror])
770AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
Benny Baumann2cde4a72020-09-18 19:32:41 +0200771
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100772AC_ARG_ENABLE([werror],
773 [AS_HELP_STRING([--enable-werror],
774 [Treat warnings as errors @<:@default=no@:>@])],
775 [],
776 [enable_werror=no])
777if test "x$enable_werror" = xyes; then
778 AM_CFLAGS="$AM_CFLAGS -Werror"
779fi
780
781AC_ARG_ENABLE([debug],
782 [AS_HELP_STRING([--enable-debug],
Daniel Lange135efd52021-02-16 11:22:02 +0100783 [Enable compiling with maximum debug info, asserts and internal sanity checks @<:@default=no@:>@])],
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100784 [],
785 [enable_debug=no])
786if test "x$enable_debug" != xyes; then
787 AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
Explorer0993d76fd2023-07-31 05:05:43 +0800788
789 AC_COMPILE_IFELSE([
790 AC_LANG_SOURCE([[
791#ifdef __SUPPORT_SNAN__
792#error "signaling NaN support not recommended"
793#endif
794 ]])],
795 :,
796 [warning_msg="signaling NaN support is enabled; not recommended for htop"
797 case "$CC" in
798 *gcc*)
799 warning_msg="$warning_msg (use '-fno-signaling-nans' compiler flag to disable)"
800 ;;
801 esac
802 AC_MSG_WARN([$warning_msg])
803 ])
Daniel Lange135efd52021-02-16 11:22:02 +0100804else
805 AM_CPPFLAGS="$AM_CPPFLAGS -ggdb3"
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100806fi
Christian Göttscheb7f63292020-09-17 22:23:05 +0200807
Christian Göttschef3623b72021-01-22 19:14:50 +0100808
Christian Göttsche57254cd2020-08-21 10:37:20 +0200809AC_SUBST([AM_CFLAGS])
Christian Göttscheb7f63292020-09-17 22:23:05 +0200810AC_SUBST([AM_CPPFLAGS])
811
Christian Göttschef3623b72021-01-22 19:14:50 +0100812# ----------------------------------------------------------------------
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100813
Christian Göttschef3623b72021-01-22 19:14:50 +0100814
815# ----------------------------------------------------------------------
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200816# We're done, let's go!
817# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100818
Daniel Langec3b4a772024-01-01 02:12:06 +0100819AC_DEFINE_UNQUOTED([COPYRIGHT], ["(C) 2004-2019 Hisham Muhammad. (C) 2020-2024 htop dev team."], [Copyright message.])
Christian Göttschef3623b72021-01-22 19:14:50 +0100820
Hisham Muhammada75161f2014-11-24 20:11:33 -0200821AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200822AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200823AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
fraggerfox4b49de42021-03-15 13:14:39 +0530824AM_CONDITIONAL([HTOP_NETBSD], [test "$my_htop_platform" = netbsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400825AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500826AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
gmbroome697f5bb2018-03-02 16:20:46 -0500827AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
Nathan Scottc14a45b2021-02-17 14:43:56 +1100828AM_CONDITIONAL([HTOP_PCP], [test "$my_htop_platform" = pcp])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200829AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Christian Göttsche38b6a012021-01-22 19:14:53 +0100830
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200831AC_SUBST(my_htop_platform)
Daniel Langefc2377f2021-08-14 10:35:11 +0200832AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000833AC_OUTPUT
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300834
Christian Göttschef3623b72021-01-22 19:14:50 +0100835if test "$my_htop_platform" = unsupported; then
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300836 echo ""
837 echo "****************************************************************"
838 echo "WARNING! This platform is not currently supported by htop."
839 echo ""
840 echo "The code will build, but it will produce a dummy version of htop"
841 echo "which shows no processes, using the files from the unsupported/"
842 echo "directory. This is meant to be a skeleton, to be used as a"
843 echo "starting point if you are porting htop to a new platform."
844 echo "****************************************************************"
845 echo ""
846fi
Christian Göttsche3b084db2020-08-28 12:10:31 +0200847
848AC_MSG_RESULT([
849 ${PACKAGE_NAME} ${VERSION}
850
Christian Göttscheffd90c22020-10-05 12:29:31 +0200851 platform: $my_htop_platform
Nathan Scott5b50ae32021-03-02 15:58:11 +1100852 os-release file: $with_os_release
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100853 (Linux) proc directory: $with_proc
Christian Göttscheffd90c22020-10-05 12:29:31 +0200854 (Linux) openvz: $enable_openvz
Christian Göttscheffd90c22020-10-05 12:29:31 +0200855 (Linux) vserver: $enable_vserver
856 (Linux) ancient vserver: $enable_ancient_vserver
Christian Göttscheffd90c22020-10-05 12:29:31 +0200857 (Linux) delay accounting: $enable_delayacct
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100858 (Linux) sensors: $enable_sensors
859 (Linux) capabilities: $enable_capabilities
Christian Göttscheffd90c22020-10-05 12:29:31 +0200860 unicode: $enable_unicode
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200861 affinity: $enable_affinity
Christian Göttsche29e1fcf2021-05-16 20:45:09 +0200862 unwind: $enable_unwind
Daniel Lange309f1d72020-11-16 13:29:37 +0100863 hwloc: $enable_hwloc
Daniel Langea8a723f2020-11-16 17:01:51 +0100864 debug: $enable_debug
Christian Göttsche575edff2021-01-22 19:14:59 +0100865 static: $enable_static
Christian Göttsche3b084db2020-08-28 12:10:31 +0200866])