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