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