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