| 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 | |
| Hisham Muhammad | ec17b70 | 2011-09-24 00:30:47 +0000 | [diff] [blame] | 4 | AC_PREREQ(2.65) |
| Daniel Lange | 769df60 | 2020-10-07 10:35:06 +0200 | [diff] [blame] | 5 | AC_INIT([htop],[3.0.3-dev],[htop@groups.io]) |
| Hisham Muhammad | 3383d8e | 2015-01-21 23:27:31 -0200 | [diff] [blame] | 6 | |
| Explorer09 | b71b07f | 2016-03-12 12:02:06 +0800 | [diff] [blame] | 7 | AC_CONFIG_SRCDIR([htop.c]) |
| 8 | AC_CONFIG_AUX_DIR([.]) |
| 9 | AC_CONFIG_HEADERS([config.h]) |
| Explorer09 | b71b07f | 2016-03-12 12:02:06 +0800 | [diff] [blame] | 10 | |
| 11 | # Required by hwloc scripts |
| Hisham Muhammad | ec17b70 | 2011-09-24 00:30:47 +0000 | [diff] [blame] | 12 | AC_CANONICAL_TARGET |
| 13 | |
| 14 | AM_INIT_AUTOMAKE([1.11]) |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 15 | |
| 16 | # Checks for programs. |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 17 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 18 | AC_PROG_CC |
| Hisham Muhammad | 4df76d1 | 2008-03-05 09:46:47 +0000 | [diff] [blame] | 19 | AM_PROG_CC_C_O |
| 20 | |
| Explorer09 | b71b07f | 2016-03-12 12:02:06 +0800 | [diff] [blame] | 21 | # Required by hwloc scripts |
| 22 | AC_USE_SYSTEM_EXTENSIONS |
| 23 | |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 24 | # Checks for platform. |
| 25 | # ---------------------------------------------------------------------- |
| James Clarke | a950827 | 2016-04-18 23:55:55 +0100 | [diff] [blame] | 26 | case "$target_os" in |
| James Clarke | 2de5286 | 2016-04-18 23:57:30 +0100 | [diff] [blame] | 27 | linux*|gnu*) |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 28 | my_htop_platform=linux |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 29 | AC_DEFINE([HTOP_LINUX], [], [Building for Linux]) |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 30 | ;; |
| James Clarke | a950827 | 2016-04-18 23:55:55 +0100 | [diff] [blame] | 31 | freebsd*|kfreebsd*) |
| Hisham Muhammad | 8915b29 | 2014-11-27 16:27:34 -0200 | [diff] [blame] | 32 | my_htop_platform=freebsd |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 33 | AC_DEFINE([HTOP_FREEBSD], [], [Building for FreeBSD]) |
| Hisham Muhammad | 8915b29 | 2014-11-27 16:27:34 -0200 | [diff] [blame] | 34 | ;; |
| James Clarke | a950827 | 2016-04-18 23:55:55 +0100 | [diff] [blame] | 35 | openbsd*) |
| Michael McConville | a9a5a53 | 2015-09-18 00:46:48 -0400 | [diff] [blame] | 36 | my_htop_platform=openbsd |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 37 | AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD]) |
| Michael McConville | a9a5a53 | 2015-09-18 00:46:48 -0400 | [diff] [blame] | 38 | ;; |
| Diederik de Groot | b258d6e | 2017-04-19 16:12:17 +0200 | [diff] [blame] | 39 | dragonfly*) |
| 40 | my_htop_platform=dragonflybsd |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 41 | AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD]) |
| Diederik de Groot | b258d6e | 2017-04-19 16:12:17 +0200 | [diff] [blame] | 42 | ;; |
| James Clarke | a950827 | 2016-04-18 23:55:55 +0100 | [diff] [blame] | 43 | darwin*) |
| David Hunt | 70e7c8d | 2015-07-12 13:47:43 -0500 | [diff] [blame] | 44 | my_htop_platform=darwin |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 45 | AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin]) |
| David Hunt | 70e7c8d | 2015-07-12 13:47:43 -0500 | [diff] [blame] | 46 | ;; |
| gmbroome | 697f5bb | 2018-03-02 16:20:46 -0500 | [diff] [blame] | 47 | solaris*) |
| 48 | my_htop_platform=solaris |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 49 | AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris]) |
| gmbroome | 697f5bb | 2018-03-02 16:20:46 -0500 | [diff] [blame] | 50 | ;; |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 51 | *) |
| 52 | my_htop_platform=unsupported |
| Christian Göttsche | ddbb0c2 | 2020-10-29 21:50:38 +0100 | [diff] [blame] | 53 | AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform]) |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 54 | ;; |
| 55 | esac |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 56 | |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 57 | # Checks for libraries. |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 58 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | e46f142 | 2006-07-12 01:15:14 +0000 | [diff] [blame] | 59 | AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"]) |
| 60 | |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 61 | # Checks for header files. |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 62 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 63 | AC_HEADER_DIRENT |
| 64 | AC_HEADER_STDC |
| Hisham Muhammad | a081056 | 2013-02-26 17:10:11 +0000 | [diff] [blame] | 65 | AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[ |
| Hisham Muhammad | e46f142 | 2006-07-12 01:15:14 +0000 | [diff] [blame] | 66 | missing_headers="$missing_headers $ac_header" |
| 67 | ]) |
| Hisham Muhammad | 36ef1a9 | 2010-12-05 15:43:56 +0000 | [diff] [blame] | 68 | AC_CHECK_HEADERS([execinfo.h],[:],[:]) |
| Hisham Muhammad | e46f142 | 2006-07-12 01:15:14 +0000 | [diff] [blame] | 69 | |
| Kang-Che Sung (宋岡哲) | c01f40e | 2018-02-26 21:15:05 +0800 | [diff] [blame] | 70 | AC_HEADER_MAJOR |
| 71 | dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to |
| 72 | dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet |
| 73 | dnl been updated in Autoconf 2.69, so use a workaround: |
| 74 | m4_version_prereq([2.70], [], |
| Explorer09 | 3512971 | 2018-12-30 12:18:27 +0800 | [diff] [blame] | 75 | [if test "x$ac_cv_header_sys_mkdev_h" != xyes; then |
| Kang-Che Sung (宋岡哲) | c01f40e | 2018-02-26 21:15:05 +0800 | [diff] [blame] | 76 | AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS, 1, |
| 77 | [Define to 1 if `major', `minor', and `makedev' are declared in <sys/sysmacros.h>.])]) |
| 78 | fi]) |
| 79 | |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 80 | # Checks for typedefs, structures, and compiler characteristics. |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 81 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 82 | AC_HEADER_STDBOOL |
| 83 | AC_C_CONST |
| 84 | AC_TYPE_PID_T |
| 85 | AC_TYPE_UID_T |
| 86 | |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 87 | # Checks for library functions and compiler features. |
| 88 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 89 | AC_FUNC_CLOSEDIR_VOID |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 90 | AC_FUNC_STAT |
| Fynn Wulf | 84dad4c | 2020-10-09 21:02:27 +0200 | [diff] [blame] | 91 | AC_CHECK_FUNCS([fstatat memmove readlinkat strdup strncasecmp strstr]) |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 92 | |
| Christian Göttsche | 2a9e8ca | 2020-10-07 15:42:13 +0200 | [diff] [blame] | 93 | AC_SEARCH_LIBS([dlopen], [dl dld]) |
| 94 | |
| Hisham Muhammad | 4df76d1 | 2008-03-05 09:46:47 +0000 | [diff] [blame] | 95 | save_cflags="${CFLAGS}" |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 96 | CFLAGS="${CFLAGS} -std=c99" |
| Christian Göttsche | f4602f7 | 2020-09-08 14:25:46 +0200 | [diff] [blame] | 97 | AC_MSG_CHECKING([whether cc -std=c99 option works]) |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 98 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 99 | [AC_INCLUDES_DEFAULT], [[char *a; a = strdup("foo"); int i = 0; i++; // C99]])], |
| 100 | [AC_MSG_RESULT([yes])], |
| Christian Göttsche | f4602f7 | 2020-09-08 14:25:46 +0200 | [diff] [blame] | 101 | [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])]) |
| Hisham Muhammad | 4df76d1 | 2008-03-05 09:46:47 +0000 | [diff] [blame] | 102 | CFLAGS="$save_cflags" |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 103 | |
| Christian Göttsche | 1d00893 | 2020-10-15 21:12:57 +0200 | [diff] [blame] | 104 | # Add -lexecinfo if needed |
| 105 | AC_SEARCH_LIBS([backtrace], [execinfo]) |
| 106 | |
| Christian Goettsche | c2fdfd9 | 2020-10-21 17:06:32 +0200 | [diff] [blame] | 107 | # Add -ldevstat if needed |
| 108 | AC_SEARCH_LIBS([devstat_checkversion], [devstat]) |
| 109 | |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 110 | # Checks for features and flags. |
| 111 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 112 | PROCDIR=/proc |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 113 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 114 | AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])], |
| Christian Göttsche | 979d004 | 2020-08-28 11:56:07 +0200 | [diff] [blame] | 115 | if test -n "$withval"; then |
| 116 | AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem]) |
| 117 | PROCDIR="$withval" |
| 118 | fi, |
| 119 | AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem])) |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 120 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 121 | AC_ARG_ENABLE(openvz, [AS_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no") |
| Hisham Muhammad | 4c51ad0 | 2007-08-10 05:07:14 +0000 | [diff] [blame] | 122 | if test "x$enable_openvz" = xyes; then |
| Hisham Muhammad | 8fa33dc | 2008-03-09 02:33:23 +0000 | [diff] [blame] | 123 | AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.]) |
| 124 | fi |
| 125 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 126 | AC_ARG_ENABLE(cgroup, [AS_HELP_STRING([--enable-cgroup], [enable cgroups support])], ,enable_cgroup="no") |
| Hisham Muhammad | 84ed4c0 | 2010-10-30 19:24:07 +0000 | [diff] [blame] | 127 | if test "x$enable_cgroup" = xyes; then |
| 128 | AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.]) |
| 129 | fi |
| 130 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 131 | AC_ARG_ENABLE(vserver, [AS_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no") |
| Hisham Muhammad | a5dfaa2 | 2008-09-23 04:31:13 +0000 | [diff] [blame] | 132 | if test "x$enable_vserver" = xyes; then |
| 133 | AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.]) |
| 134 | fi |
| 135 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 136 | AC_ARG_ENABLE(ancient_vserver, [AS_HELP_STRING([--enable-ancient-vserver], [enable ancient VServer support (implies --enable-vserver)])], ,enable_ancient_vserver="no") |
| Hisham Muhammad | a5dfaa2 | 2008-09-23 04:31:13 +0000 | [diff] [blame] | 137 | if test "x$enable_ancient_vserver" = xyes; then |
| 138 | AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.]) |
| 139 | AC_DEFINE(HAVE_ANCIENT_VSERVER, 1, [Define if ancient vserver support enabled.]) |
| 140 | fi |
| 141 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 142 | AC_ARG_ENABLE(taskstats, [AS_HELP_STRING([--enable-taskstats], [enable per-task IO Stats (taskstats kernel sup required)])], ,enable_taskstats="yes") |
| Hisham Muhammad | 12f4f09 | 2008-03-09 08:02:22 +0000 | [diff] [blame] | 143 | if test "x$enable_taskstats" = xyes; then |
| 144 | AC_DEFINE(HAVE_TASKSTATS, 1, [Define if taskstats support enabled.]) |
| 145 | fi |
| 146 | |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 147 | # HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART) |
| 148 | m4_define([HTOP_CHECK_SCRIPT], |
| Hisham Muhammad | 96c929f | 2015-11-30 16:36:22 -0200 | [diff] [blame] | 149 | [ |
| Ricardo Martincoski | 78b82d0 | 2016-07-11 20:12:07 -0300 | [diff] [blame] | 150 | if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then |
| 151 | # to be used to set the path to ncurses*-config when cross-compiling |
| Michael Klein | bc5d469 | 2018-02-26 14:19:01 +0100 | [diff] [blame] | 152 | htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null) |
| 153 | htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null) |
| Ricardo Martincoski | 78b82d0 | 2016-07-11 20:12:07 -0300 | [diff] [blame] | 154 | else |
| Michael Klein | bc5d469 | 2018-02-26 14:19:01 +0100 | [diff] [blame] | 155 | htop_config_script_libs=$([$4] --libs 2> /dev/null) |
| 156 | htop_config_script_cflags=$([$4] --cflags 2> /dev/null) |
| Ricardo Martincoski | 78b82d0 | 2016-07-11 20:12:07 -0300 | [diff] [blame] | 157 | fi |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 158 | htop_script_success=no |
| 159 | htop_save_LDFLAGS="$LDFLAGS" |
| Michael Klein | bc5d469 | 2018-02-26 14:19:01 +0100 | [diff] [blame] | 160 | htop_save_CFLAGS="$CFLAGS" |
| 161 | if test ! "x$htop_config_script_libs" = x; then |
| 162 | LDFLAGS="$htop_config_script_libs $LDFLAGS" |
| 163 | CFLAGS="$htop_config_script_cflags $CFLAGS" |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 164 | AC_CHECK_LIB([$1], [$2], [ |
| 165 | AC_DEFINE([$3], 1, [The library is present.]) |
| Michael Klein | bc5d469 | 2018-02-26 14:19:01 +0100 | [diff] [blame] | 166 | LIBS="$htop_config_script_libs $LIBS " |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 167 | htop_script_success=yes |
| Michael Klein | bc5d469 | 2018-02-26 14:19:01 +0100 | [diff] [blame] | 168 | ], [ |
| 169 | CFLAGS="$htop_save_CFLAGS" |
| 170 | ]) |
| Hisham Muhammad | df9922a | 2018-02-17 14:50:55 -0200 | [diff] [blame] | 171 | LDFLAGS="$htop_save_LDFLAGS" |
| Hisham Muhammad | c237702 | 2015-12-06 19:06:23 -0200 | [diff] [blame] | 172 | fi |
| Hisham Muhammad | cccc18d | 2015-12-09 17:34:57 -0200 | [diff] [blame] | 173 | if test "x$htop_script_success" = xno; then |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 174 | [$5] |
| 175 | fi |
| 176 | ]) |
| 177 | |
| 178 | # HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART) |
| 179 | m4_define([HTOP_CHECK_LIB], |
| 180 | [ |
| Hisham Muhammad | 96c929f | 2015-11-30 16:36:22 -0200 | [diff] [blame] | 181 | AC_CHECK_LIB([$1], [$2], [ |
| 182 | AC_DEFINE([$3], 1, [The library is present.]) |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 183 | LIBS="-l[$1] $LIBS " |
| 184 | ], [$4]) |
| Hisham Muhammad | 96c929f | 2015-11-30 16:36:22 -0200 | [diff] [blame] | 185 | ]) |
| 186 | |
| Benny Baumann | 2cde4a7 | 2020-09-18 19:32:41 +0200 | [diff] [blame] | 187 | dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html |
| 188 | AC_DEFUN([AX_CHECK_COMPILE_FLAG], |
| 189 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF |
| 190 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl |
| 191 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ |
| 192 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS |
| 193 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" |
| 194 | AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], |
| 195 | [AS_VAR_SET(CACHEVAR,[yes])], |
| 196 | [AS_VAR_SET(CACHEVAR,[no])]) |
| 197 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) |
| 198 | AS_VAR_IF(CACHEVAR,yes, |
| 199 | [m4_default([$2], :)], |
| 200 | [m4_default([$3], :)]) |
| 201 | AS_VAR_POPDEF([CACHEVAR])dnl |
| 202 | ])dnl AX_CHECK_COMPILE_FLAGS |
| 203 | |
| Explorer09 | f0df28a | 2016-03-12 11:58:30 +0800 | [diff] [blame] | 204 | AC_ARG_ENABLE(unicode, [AS_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes") |
| Hisham Muhammad | 8fa33dc | 2008-03-09 02:33:23 +0000 | [diff] [blame] | 205 | if test "x$enable_unicode" = xyes; then |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 206 | HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config", |
| Diederik de Groot | b258d6e | 2017-04-19 16:12:17 +0200 | [diff] [blame] | 207 | HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config", |
| 208 | HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw5-config", |
| 209 | HTOP_CHECK_SCRIPT([ncurses], [addnwstr], [HAVE_LIBNCURSESW], "ncurses5-config", |
| 210 | HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], |
| 211 | HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], |
| 212 | HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW], |
| 213 | missing_libraries="$missing_libraries libncursesw" |
| 214 | AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.]) |
| 215 | ))))))) |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 216 | |
| Hisham Muhammad | a7bcf1d | 2011-09-08 01:45:16 +0000 | [diff] [blame] | 217 | AC_CHECK_HEADERS([ncursesw/curses.h],[:], |
| Hisham Muhammad | a081056 | 2013-02-26 17:10:11 +0000 | [diff] [blame] | 218 | [AC_CHECK_HEADERS([ncurses/ncurses.h],[:], |
| 219 | [AC_CHECK_HEADERS([ncurses/curses.h],[:], |
| 220 | [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])]) |
| Hisham Muhammad | 8fa33dc | 2008-03-09 02:33:23 +0000 | [diff] [blame] | 221 | else |
| Hisham Muhammad | db68286 | 2015-12-09 17:17:30 -0200 | [diff] [blame] | 222 | HTOP_CHECK_SCRIPT([ncurses6], [refresh], [HAVE_LIBNCURSES], "ncurses6-config", |
| 223 | HTOP_CHECK_SCRIPT([ncurses], [refresh], [HAVE_LIBNCURSES], "ncurses5-config", |
| 224 | HTOP_CHECK_LIB([ncurses6], [refresh], [HAVE_LIBNCURSES], |
| 225 | HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES], |
| 226 | missing_libraries="$missing_libraries libncurses" |
| 227 | )))) |
| Christian Göttsche | b92f62f | 2020-08-21 10:37:33 +0200 | [diff] [blame] | 228 | |
| Hisham Muhammad | a081056 | 2013-02-26 17:10:11 +0000 | [diff] [blame] | 229 | AC_CHECK_HEADERS([curses.h],[:], |
| 230 | [AC_CHECK_HEADERS([ncurses/curses.h],[:], |
| 231 | [AC_CHECK_HEADERS([ncurses/ncurses.h],[:], |
| 232 | [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])]) |
| Hisham Muhammad | 4c51ad0 | 2007-08-10 05:07:14 +0000 | [diff] [blame] | 233 | fi |
| 234 | |
| Hisham Muhammad | 0aa485c | 2014-11-27 18:31:39 -0200 | [diff] [blame] | 235 | if test "$my_htop_platform" = "freebsd"; then |
| 236 | AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"]) |
| 237 | fi |
| 238 | |
| Michael McConville | a9a5a53 | 2015-09-18 00:46:48 -0400 | [diff] [blame] | 239 | if test "$my_htop_platform" = "openbsd"; then |
| 240 | AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"]) |
| 241 | fi |
| 242 | |
| gmbroome | 697f5bb | 2018-03-02 16:20:46 -0500 | [diff] [blame] | 243 | if test "$my_htop_platform" = "solaris"; then |
| 244 | AC_CHECK_LIB([kstat], [kstat_open], [], [missing_libraries="$missing_libraries libkstat"]) |
| Guy M. Broome | 45fad05 | 2018-03-28 12:48:37 -0400 | [diff] [blame] | 245 | AC_CHECK_LIB([proc], [Pgrab_error], [], [missing_libraries="$missing_libraries libproc"]) |
| Guy M. Broome | 76ef368 | 2018-03-05 12:02:07 -0500 | [diff] [blame] | 246 | AC_CHECK_LIB([malloc], [free], [], [missing_libraries="$missing_libraries libmalloc"]) |
| gmbroome | 697f5bb | 2018-03-02 16:20:46 -0500 | [diff] [blame] | 247 | fi |
| 248 | |
| Christian Göttsche | 005c4d1 | 2020-09-08 16:25:22 +0200 | [diff] [blame] | 249 | AC_ARG_ENABLE(hwloc, [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity, disables Linux affinity])],, enable_hwloc="no") |
| 250 | if test "x$enable_hwloc" = xyes |
| 251 | then |
| 252 | AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"]) |
| 253 | AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"]) |
| 254 | fi |
| 255 | |
| 256 | AC_ARG_ENABLE(linux_affinity, [AS_HELP_STRING([--enable-linux-affinity], [enable Linux sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc])], ,enable_linux_affinity="check") |
| 257 | if test "x$enable_linux_affinity" = xcheck; then |
| 258 | if test "x$enable_hwloc" = xyes; then |
| 259 | enable_linux_affinity=no |
| 260 | else |
| 261 | AC_MSG_CHECKING([for usable sched_setaffinity]) |
| 262 | AC_RUN_IFELSE([ |
| 263 | AC_LANG_PROGRAM([[ |
| 264 | #include <sched.h> |
| 265 | #include <errno.h> |
| 266 | static cpu_set_t cpuset; |
| 267 | ]], [[ |
| 268 | CPU_ZERO(&cpuset); |
| 269 | sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); |
| 270 | if (errno == ENOSYS) return 1; |
| 271 | ]])], |
| 272 | [enable_linux_affinity=yes |
| 273 | AC_MSG_RESULT([yes])], |
| 274 | [enable_linux_affinity=no |
| 275 | AC_MSG_RESULT([no])], |
| 276 | [AC_MSG_RESULT([yes (assumed while cross compiling)])]) |
| 277 | fi |
| Hisham Muhammad | dfad0af | 2011-11-23 18:43:35 +0000 | [diff] [blame] | 278 | fi |
| Hisham | 474d26c | 2016-02-14 19:57:29 -0200 | [diff] [blame] | 279 | if test "x$enable_linux_affinity" = xyes; then |
| 280 | AC_DEFINE(HAVE_LINUX_AFFINITY, 1, [Define if Linux sched_setaffinity and sched_getaffinity are to be used.]) |
| Hisham Muhammad | 7ca1081 | 2011-11-18 06:08:56 +0000 | [diff] [blame] | 281 | fi |
| 282 | |
| Christian Göttsche | 005c4d1 | 2020-09-08 16:25:22 +0200 | [diff] [blame] | 283 | if test "x$enable_linux_affinity" = xyes -a "x$enable_hwloc" = xyes |
| Hisham Muhammad | 9604e02 | 2010-11-22 12:24:46 +0000 | [diff] [blame] | 284 | then |
| Christian Göttsche | 005c4d1 | 2020-09-08 16:25:22 +0200 | [diff] [blame] | 285 | AC_MSG_ERROR([--enable-hwloc and --enable-linux-affinity are mutual exclusive. Specify at most one of them.]) |
| Hisham Muhammad | 4df76d1 | 2008-03-05 09:46:47 +0000 | [diff] [blame] | 286 | fi |
| 287 | |
| Hisham Muhammad | 543d65c | 2017-07-26 15:40:55 -0300 | [diff] [blame] | 288 | AC_ARG_ENABLE(setuid, [AS_HELP_STRING([--enable-setuid], [enable setuid support for platforms that need it])],, enable_setuid="no") |
| 289 | if test "x$enable_setuid" = xyes |
| 290 | then |
| 291 | AC_DEFINE(HAVE_SETUID_ENABLED, 1, [Define if setuid support should be enabled.]) |
| 292 | fi |
| 293 | |
| Hisham Muhammad | e85b072 | 2018-04-06 11:03:00 -0300 | [diff] [blame] | 294 | AC_ARG_ENABLE(delayacct, [AS_HELP_STRING([--enable-delayacct], [enable Linux delay accounting])],, enable_delayacct="no") |
| André Carvalho | b7b66b7 | 2017-12-04 00:15:29 -0200 | [diff] [blame] | 295 | if test "x$enable_delayacct" = xyes |
| 296 | then |
| Hisham Muhammad | e85b072 | 2018-04-06 11:03:00 -0300 | [diff] [blame] | 297 | m4_ifdef([PKG_PROG_PKG_CONFIG], [ |
| 298 | PKG_PROG_PKG_CONFIG() |
| 299 | PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"]) |
| 300 | PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"]) |
| 301 | CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS" |
| 302 | LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS" |
| 303 | AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.]) |
| 304 | ], [ |
| Explorer09 | 103f1a4 | 2018-04-06 23:47:55 +0800 | [diff] [blame] | 305 | pkg_m4_absent=1 |
| 306 | m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.]) |
| 307 | AC_MSG_ERROR([htop on Linux requires pkg-config for checking delayacct requirements. Please install pkg-config and run ./autogen.sh to rebuild the configure script.]) |
| Hisham Muhammad | e85b072 | 2018-04-06 11:03:00 -0300 | [diff] [blame] | 308 | ]) |
| André Carvalho | b7b66b7 | 2017-12-04 00:15:29 -0200 | [diff] [blame] | 309 | fi |
| 310 | |
| Christian Göttsche | f4602f7 | 2020-09-08 14:25:46 +0200 | [diff] [blame] | 311 | AM_CFLAGS="\ |
| 312 | -Wall\ |
| 313 | -Wcast-align\ |
| Christian Göttsche | db47207 | 2020-10-04 14:30:35 +0200 | [diff] [blame] | 314 | -Wcast-qual\ |
| Christian Göttsche | f4602f7 | 2020-09-08 14:25:46 +0200 | [diff] [blame] | 315 | -Wextra\ |
| Benny Baumann | ba0fca1 | 2020-09-18 16:58:03 +0200 | [diff] [blame] | 316 | -Wfloat-equal\ |
| Christian Göttsche | f4602f7 | 2020-09-08 14:25:46 +0200 | [diff] [blame] | 317 | -Wmissing-format-attribute\ |
| 318 | -Wmissing-noreturn\ |
| Christian Göttsche | 4e282eb | 2020-09-25 14:03:55 +0200 | [diff] [blame] | 319 | -Wmissing-prototypes\ |
| Christian Göttsche | f4602f7 | 2020-09-08 14:25:46 +0200 | [diff] [blame] | 320 | -Wpointer-arith\ |
| 321 | -Wshadow\ |
| 322 | -Wstrict-prototypes\ |
| 323 | -Wundef\ |
| 324 | -Wunused\ |
| 325 | -Wwrite-strings" |
| 326 | |
| Benny Baumann | 2cde4a7 | 2020-09-18 19:32:41 +0200 | [diff] [blame] | 327 | AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror]) |
| 328 | |
| Christian Göttsche | 57254cd | 2020-08-21 10:37:20 +0200 | [diff] [blame] | 329 | AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no]) |
| 330 | AS_IF([test "x$enable_werror" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -Werror"]) |
| Christian Göttsche | b7f6329 | 2020-09-17 22:23:05 +0200 | [diff] [blame] | 331 | |
| Christian Göttsche | 57254cd | 2020-08-21 10:37:20 +0200 | [diff] [blame] | 332 | AC_SUBST([AM_CFLAGS]) |
| André Carvalho | b7b66b7 | 2017-12-04 00:15:29 -0200 | [diff] [blame] | 333 | |
| Christian Göttsche | b7f6329 | 2020-09-17 22:23:05 +0200 | [diff] [blame] | 334 | AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable asserts (default: asserts are disabled)])], [enable_debug="$enableval"], [enable_debug=no]) |
| 335 | AS_IF([test "x$enable_debug" = "xyes"], , [AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"]) |
| 336 | |
| 337 | AC_SUBST([AM_CPPFLAGS]) |
| 338 | |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 339 | # Bail out on errors. |
| 340 | # ---------------------------------------------------------------------- |
| 341 | if test ! -z "$missing_libraries"; then |
| 342 | AC_MSG_ERROR([missing libraries: $missing_libraries]) |
| 343 | fi |
| 344 | if test ! -z "$missing_headers"; then |
| 345 | AC_MSG_ERROR([missing headers: $missing_headers]) |
| 346 | fi |
| 347 | |
| Daniel Lange | 079c2ab | 2020-10-05 09:51:32 +0200 | [diff] [blame] | 348 | AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-2019 Hisham Muhammad. (C) 2020 htop dev team.", [Copyright message.]) |
| Hisham Muhammad | 3383d8e | 2015-01-21 23:27:31 -0200 | [diff] [blame] | 349 | |
| Hisham Muhammad | 300af4b | 2014-11-19 23:17:16 -0200 | [diff] [blame] | 350 | # We're done, let's go! |
| 351 | # ---------------------------------------------------------------------- |
| Hisham Muhammad | a75161f | 2014-11-24 20:11:33 -0200 | [diff] [blame] | 352 | AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux]) |
| Hisham Muhammad | 8915b29 | 2014-11-27 16:27:34 -0200 | [diff] [blame] | 353 | AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd]) |
| Diederik de Groot | b258d6e | 2017-04-19 16:12:17 +0200 | [diff] [blame] | 354 | AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd]) |
| Michael McConville | a9a5a53 | 2015-09-18 00:46:48 -0400 | [diff] [blame] | 355 | AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd]) |
| David Hunt | 70e7c8d | 2015-07-12 13:47:43 -0500 | [diff] [blame] | 356 | AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin]) |
| gmbroome | 697f5bb | 2018-03-02 16:20:46 -0500 | [diff] [blame] | 357 | AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris]) |
| Hisham Muhammad | a75161f | 2014-11-24 20:11:33 -0200 | [diff] [blame] | 358 | AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported]) |
| Hisham Muhammad | eb229d9 | 2014-11-24 18:55:03 -0200 | [diff] [blame] | 359 | AC_SUBST(my_htop_platform) |
| Daniel Lange | e172282 | 2020-08-24 21:37:28 +0200 | [diff] [blame] | 360 | AC_CONFIG_FILES([Makefile htop.1]) |
| Hisham Muhammad | d6231ba | 2006-03-04 18:16:49 +0000 | [diff] [blame] | 361 | AC_OUTPUT |
| Hisham Muhammad | c39f18a | 2017-07-10 20:14:25 -0300 | [diff] [blame] | 362 | |
| 363 | if test "$my_htop_platform" = "unsupported" |
| 364 | then |
| 365 | echo "" |
| 366 | echo "****************************************************************" |
| 367 | echo "WARNING! This platform is not currently supported by htop." |
| 368 | echo "" |
| 369 | echo "The code will build, but it will produce a dummy version of htop" |
| 370 | echo "which shows no processes, using the files from the unsupported/" |
| 371 | echo "directory. This is meant to be a skeleton, to be used as a" |
| 372 | echo "starting point if you are porting htop to a new platform." |
| 373 | echo "****************************************************************" |
| 374 | echo "" |
| 375 | fi |
| Christian Göttsche | 3b084db | 2020-08-28 12:10:31 +0200 | [diff] [blame] | 376 | |
| 377 | AC_MSG_RESULT([ |
| 378 | ${PACKAGE_NAME} ${VERSION} |
| 379 | |
| Christian Göttsche | ffd90c2 | 2020-10-05 12:29:31 +0200 | [diff] [blame] | 380 | platform: $my_htop_platform |
| 381 | (Linux) proc directory: $PROCDIR |
| 382 | (Linux) openvz: $enable_openvz |
| 383 | (Linux) cgroup: $enable_cgroup |
| 384 | (Linux) vserver: $enable_vserver |
| 385 | (Linux) ancient vserver: $enable_ancient_vserver |
| 386 | (Linux) taskstats: $enable_taskstats |
| 387 | (Linux) affinity: $enable_linux_affinity |
| 388 | (Linux) delay accounting: $enable_delayacct |
| 389 | unicode: $enable_unicode |
| Daniel Lange | 309f1d7 | 2020-11-16 13:29:37 +0100 | [diff] [blame^] | 390 | hwloc: $enable_hwloc |
| Christian Göttsche | ffd90c2 | 2020-10-05 12:29:31 +0200 | [diff] [blame] | 391 | setuid: $enable_setuid |
| Christian Göttsche | 3b084db | 2020-08-28 12:10:31 +0200 | [diff] [blame] | 392 | ]) |