blob: 72c7a60fdfbd2f3e2c1b4475f607654550e95aa2 [file] [log] [blame]
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
Hisham Muhammadec17b702011-09-24 00:30:47 +00004AC_PREREQ(2.65)
Daniel Lange58ce8872021-01-11 18:59:55 +01005AC_INIT([htop],[3.0.6-dev],[htop@groups.io])
Hisham Muhammad3383d8e2015-01-21 23:27:31 -02006
Explorer09b71b07f2016-03-12 12:02:06 +08007AC_CONFIG_SRCDIR([htop.c])
8AC_CONFIG_AUX_DIR([.])
9AC_CONFIG_HEADERS([config.h])
Explorer09b71b07f2016-03-12 12:02:06 +080010
11# Required by hwloc scripts
Hisham Muhammadec17b702011-09-24 00:30:47 +000012AC_CANONICAL_TARGET
13
14AM_INIT_AUTOMAKE([1.11])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000015
16# Checks for programs.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020017# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000018AC_PROG_CC
Hisham Muhammad4df76d12008-03-05 09:46:47 +000019AM_PROG_CC_C_O
20
Explorer09b71b07f2016-03-12 12:02:06 +080021# Required by hwloc scripts
22AC_USE_SYSTEM_EXTENSIONS
23
Hisham Muhammadeb229d92014-11-24 18:55:03 -020024# Checks for platform.
25# ----------------------------------------------------------------------
James Clarkea9508272016-04-18 23:55:55 +010026case "$target_os" in
James Clarke2de52862016-04-18 23:57:30 +010027linux*|gnu*)
Hisham Muhammadeb229d92014-11-24 18:55:03 -020028 my_htop_platform=linux
Christian Göttscheddbb0c22020-10-29 21:50:38 +010029 AC_DEFINE([HTOP_LINUX], [], [Building for Linux])
Hisham Muhammadeb229d92014-11-24 18:55:03 -020030 ;;
James Clarkea9508272016-04-18 23:55:55 +010031freebsd*|kfreebsd*)
Hisham Muhammad8915b292014-11-27 16:27:34 -020032 my_htop_platform=freebsd
Christian Göttscheddbb0c22020-10-29 21:50:38 +010033 AC_DEFINE([HTOP_FREEBSD], [], [Building for FreeBSD])
Hisham Muhammad8915b292014-11-27 16:27:34 -020034 ;;
James Clarkea9508272016-04-18 23:55:55 +010035openbsd*)
Michael McConvillea9a5a532015-09-18 00:46:48 -040036 my_htop_platform=openbsd
Christian Göttscheddbb0c22020-10-29 21:50:38 +010037 AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD])
Michael McConvillea9a5a532015-09-18 00:46:48 -040038 ;;
Diederik de Grootb258d6e2017-04-19 16:12:17 +020039dragonfly*)
40 my_htop_platform=dragonflybsd
Christian Göttscheddbb0c22020-10-29 21:50:38 +010041 AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD])
Diederik de Grootb258d6e2017-04-19 16:12:17 +020042 ;;
James Clarkea9508272016-04-18 23:55:55 +010043darwin*)
David Hunt70e7c8d2015-07-12 13:47:43 -050044 my_htop_platform=darwin
Christian Göttscheddbb0c22020-10-29 21:50:38 +010045 AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin])
David Hunt70e7c8d2015-07-12 13:47:43 -050046 ;;
gmbroome697f5bb2018-03-02 16:20:46 -050047solaris*)
48 my_htop_platform=solaris
Christian Göttscheddbb0c22020-10-29 21:50:38 +010049 AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris])
gmbroome697f5bb2018-03-02 16:20:46 -050050 ;;
Hisham Muhammadeb229d92014-11-24 18:55:03 -020051*)
52 my_htop_platform=unsupported
Christian Göttscheddbb0c22020-10-29 21:50:38 +010053 AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform])
Hisham Muhammadeb229d92014-11-24 18:55:03 -020054 ;;
55esac
Hisham Muhammadeb229d92014-11-24 18:55:03 -020056
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000057# Checks for libraries.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020058# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000059AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
60
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000061# Checks for header files.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020062# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000063AC_HEADER_DIRENT
64AC_HEADER_STDC
Hisham Muhammada0810562013-02-26 17:10:11 +000065AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
Hisham Muhammade46f1422006-07-12 01:15:14 +000066 missing_headers="$missing_headers $ac_header"
67])
Hisham Muhammad36ef1a92010-12-05 15:43:56 +000068AC_CHECK_HEADERS([execinfo.h],[:],[:])
Hisham Muhammade46f1422006-07-12 01:15:14 +000069
Kang-Che Sung (宋岡哲)c01f40e2018-02-26 21:15:05 +080070AC_HEADER_MAJOR
71dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
72dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
73dnl been updated in Autoconf 2.69, so use a workaround:
74m4_version_prereq([2.70], [],
Explorer0935129712018-12-30 12:18:27 +080075[if test "x$ac_cv_header_sys_mkdev_h" != xyes; then
Kang-Che Sung (宋岡哲)c01f40e2018-02-26 21:15:05 +080076 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>.])])
78fi])
79
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000080# Checks for typedefs, structures, and compiler characteristics.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020081# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000082AC_HEADER_STDBOOL
83AC_C_CONST
84AC_TYPE_PID_T
85AC_TYPE_UID_T
Christian Göttsche15fe8712020-11-26 20:28:38 +010086AC_TYPE_UINT8_T
87AC_TYPE_UINT16_T
88AC_TYPE_UINT32_T
89AC_TYPE_UINT64_T
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000090
Hisham Muhammad300af4b2014-11-19 23:17:16 -020091# Checks for library functions and compiler features.
92# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000093AC_FUNC_CLOSEDIR_VOID
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000094AC_FUNC_STAT
James Abbatiellob20bb542021-01-19 13:51:59 -050095
96AC_SEARCH_LIBS([dlopen], [dl dld])
97AC_SEARCH_LIBS([clock_gettime], [rt])
98
Christian Göttschea41e5c02020-11-22 16:29:18 +010099AC_CHECK_FUNCS([\
Christian Göttsche26993d22020-12-13 13:16:44 +0100100 clock_gettime\
Christian Göttschea41e5c02020-11-22 16:29:18 +0100101 faccessat\
102 fstatat\
Christian Göttsche26993d22020-12-13 13:16:44 +0100103 host_get_clock_service\
Christian Göttschea41e5c02020-11-22 16:29:18 +0100104 openat\
105 readlinkat\
106])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000107
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000108save_cflags="${CFLAGS}"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000109CFLAGS="${CFLAGS} -std=c99"
Christian Göttschef4602f72020-09-08 14:25:46 +0200110AC_MSG_CHECKING([whether cc -std=c99 option works])
Explorer09f0df28a2016-03-12 11:58:30 +0800111AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
112 [AC_INCLUDES_DEFAULT], [[char *a; a = strdup("foo"); int i = 0; i++; // C99]])],
113 [AC_MSG_RESULT([yes])],
Christian Göttschef4602f72020-09-08 14:25:46 +0200114 [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000115CFLAGS="$save_cflags"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000116
Christian Göttsche1d008932020-10-15 21:12:57 +0200117# Add -lexecinfo if needed
118AC_SEARCH_LIBS([backtrace], [execinfo])
119
Christian Goettschec2fdfd92020-10-21 17:06:32 +0200120# Add -ldevstat if needed
121AC_SEARCH_LIBS([devstat_checkversion], [devstat])
122
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200123# Checks for features and flags.
124# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000125PROCDIR=/proc
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200126
Explorer09f0df28a2016-03-12 11:58:30 +0800127AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])],
Christian Göttsche979d0042020-08-28 11:56:07 +0200128 if test -n "$withval"; then
129 AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
130 PROCDIR="$withval"
131 fi,
132 AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000133
Explorer09f0df28a2016-03-12 11:58:30 +0800134AC_ARG_ENABLE(openvz, [AS_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no")
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000135if test "x$enable_openvz" = xyes; then
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000136 AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
137fi
138
Explorer09f0df28a2016-03-12 11:58:30 +0800139AC_ARG_ENABLE(vserver, [AS_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no")
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000140if test "x$enable_vserver" = xyes; then
141 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
142fi
143
Explorer09f0df28a2016-03-12 11:58:30 +0800144AC_ARG_ENABLE(ancient_vserver, [AS_HELP_STRING([--enable-ancient-vserver], [enable ancient VServer support (implies --enable-vserver)])], ,enable_ancient_vserver="no")
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000145if test "x$enable_ancient_vserver" = xyes; then
146 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
147 AC_DEFINE(HAVE_ANCIENT_VSERVER, 1, [Define if ancient vserver support enabled.])
148fi
149
Hisham Muhammaddb682862015-12-09 17:17:30 -0200150# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
151m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200152[
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300153 if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
154 # to be used to set the path to ncurses*-config when cross-compiling
Michael Kleinbc5d4692018-02-26 14:19:01 +0100155 htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
156 htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300157 else
Michael Kleinbc5d4692018-02-26 14:19:01 +0100158 htop_config_script_libs=$([$4] --libs 2> /dev/null)
159 htop_config_script_cflags=$([$4] --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300160 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200161 htop_script_success=no
162 htop_save_LDFLAGS="$LDFLAGS"
Michael Kleinbc5d4692018-02-26 14:19:01 +0100163 htop_save_CFLAGS="$CFLAGS"
164 if test ! "x$htop_config_script_libs" = x; then
165 LDFLAGS="$htop_config_script_libs $LDFLAGS"
166 CFLAGS="$htop_config_script_cflags $CFLAGS"
Hisham Muhammaddb682862015-12-09 17:17:30 -0200167 AC_CHECK_LIB([$1], [$2], [
168 AC_DEFINE([$3], 1, [The library is present.])
Michael Kleinbc5d4692018-02-26 14:19:01 +0100169 LIBS="$htop_config_script_libs $LIBS "
Hisham Muhammaddb682862015-12-09 17:17:30 -0200170 htop_script_success=yes
Michael Kleinbc5d4692018-02-26 14:19:01 +0100171 ], [
Benny Baumann880eeca2020-12-12 19:49:52 +0100172 CFLAGS="$htop_save_CFLAGS"
Michael Kleinbc5d4692018-02-26 14:19:01 +0100173 ])
Hisham Muhammaddf9922a2018-02-17 14:50:55 -0200174 LDFLAGS="$htop_save_LDFLAGS"
Hisham Muhammadc2377022015-12-06 19:06:23 -0200175 fi
Hisham Muhammadcccc18d2015-12-09 17:34:57 -0200176 if test "x$htop_script_success" = xno; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200177 [$5]
178 fi
179])
180
181# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
182m4_define([HTOP_CHECK_LIB],
183[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200184 AC_CHECK_LIB([$1], [$2], [
185 AC_DEFINE([$3], 1, [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200186 LIBS="-l[$1] $LIBS "
187 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200188])
189
Benny Baumann2cde4a72020-09-18 19:32:41 +0200190dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
191AC_DEFUN([AX_CHECK_COMPILE_FLAG],
192[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
193AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
194AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
Benny Baumann880eeca2020-12-12 19:49:52 +0100195 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
196 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
197 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
198 [AS_VAR_SET(CACHEVAR,[yes])],
199 [AS_VAR_SET(CACHEVAR,[no])])
200 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
Benny Baumann2cde4a72020-09-18 19:32:41 +0200201AS_VAR_IF(CACHEVAR,yes,
Benny Baumann880eeca2020-12-12 19:49:52 +0100202 [m4_default([$2], :)],
203 [m4_default([$3], :)])
Benny Baumann2cde4a72020-09-18 19:32:41 +0200204AS_VAR_POPDEF([CACHEVAR])dnl
205])dnl AX_CHECK_COMPILE_FLAGS
206
Explorer09f0df28a2016-03-12 11:58:30 +0800207AC_ARG_ENABLE(unicode, [AS_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000208if test "x$enable_unicode" = xyes; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200209 HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200210 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
211 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw5-config",
212 HTOP_CHECK_SCRIPT([ncurses], [addnwstr], [HAVE_LIBNCURSESW], "ncurses5-config",
213 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
214 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
215 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
Benny Baumann880eeca2020-12-12 19:49:52 +0100216 missing_libraries="$missing_libraries libncursesw"
217 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200218 )))))))
Hisham Muhammaddb682862015-12-09 17:17:30 -0200219
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000220 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000221 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
222 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
223 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100224
225 # check if additional linker flags are needed for keypad(3)
226 # (at this point we already link against a working ncurses library with wide character support)
227 AC_SEARCH_LIBS([keypad], [tinfow tinfo])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000228else
Hisham Muhammaddb682862015-12-09 17:17:30 -0200229 HTOP_CHECK_SCRIPT([ncurses6], [refresh], [HAVE_LIBNCURSES], "ncurses6-config",
230 HTOP_CHECK_SCRIPT([ncurses], [refresh], [HAVE_LIBNCURSES], "ncurses5-config",
231 HTOP_CHECK_LIB([ncurses6], [refresh], [HAVE_LIBNCURSES],
232 HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES],
233 missing_libraries="$missing_libraries libncurses"
234 ))))
Christian Göttscheb92f62f2020-08-21 10:37:33 +0200235
Hisham Muhammada0810562013-02-26 17:10:11 +0000236 AC_CHECK_HEADERS([curses.h],[:],
237 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
238 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
239 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100240
241 # check if additional linker flags are needed for keypad(3)
242 # (at this point we already link against a working ncurses library)
243 AC_SEARCH_LIBS([keypad], [tinfo])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000244fi
245
Benny Baumannf32f0182020-12-12 20:43:08 +0100246if test "$my_htop_platform" = "darwin"; then
247 AC_CHECK_HEADERS([mach/mach_time.h])
248 AC_CHECK_FUNCS([mach_timebase_info])
249fi
250
Christian Göttsche8db8b9e2020-12-20 18:21:25 +0100251if test "$my_htop_platform" = "dragonflybsd"; then
252 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
253fi
254
Hisham Muhammad0aa485c2014-11-27 18:31:39 -0200255if test "$my_htop_platform" = "freebsd"; then
256 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
257fi
258
Michael McConvillea9a5a532015-09-18 00:46:48 -0400259if test "$my_htop_platform" = "openbsd"; then
260 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
261fi
262
gmbroome697f5bb2018-03-02 16:20:46 -0500263if test "$my_htop_platform" = "solaris"; then
264 AC_CHECK_LIB([kstat], [kstat_open], [], [missing_libraries="$missing_libraries libkstat"])
Guy M. Broome45fad052018-03-28 12:48:37 -0400265 AC_CHECK_LIB([proc], [Pgrab_error], [], [missing_libraries="$missing_libraries libproc"])
Guy M. Broome76ef3682018-03-05 12:02:07 -0500266 AC_CHECK_LIB([malloc], [free], [], [missing_libraries="$missing_libraries libmalloc"])
gmbroome697f5bb2018-03-02 16:20:46 -0500267fi
268
Christian Göttsche005c4d12020-09-08 16:25:22 +0200269AC_ARG_ENABLE(hwloc, [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity, disables Linux affinity])],, enable_hwloc="no")
Benny Baumann880eeca2020-12-12 19:49:52 +0100270if test "x$enable_hwloc" = xyes; then
Christian Göttsche005c4d12020-09-08 16:25:22 +0200271 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
272 AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
273fi
274
275AC_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")
276if test "x$enable_linux_affinity" = xcheck; then
277 if test "x$enable_hwloc" = xyes; then
278 enable_linux_affinity=no
279 else
280 AC_MSG_CHECKING([for usable sched_setaffinity])
281 AC_RUN_IFELSE([
282 AC_LANG_PROGRAM([[
283 #include <sched.h>
284 #include <errno.h>
285 static cpu_set_t cpuset;
286 ]], [[
287 CPU_ZERO(&cpuset);
288 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
289 if (errno == ENOSYS) return 1;
290 ]])],
291 [enable_linux_affinity=yes
Benny Baumann880eeca2020-12-12 19:49:52 +0100292 AC_MSG_RESULT([yes])],
Christian Göttsche005c4d12020-09-08 16:25:22 +0200293 [enable_linux_affinity=no
Benny Baumann880eeca2020-12-12 19:49:52 +0100294 AC_MSG_RESULT([no])],
Christian Göttsche005c4d12020-09-08 16:25:22 +0200295 [AC_MSG_RESULT([yes (assumed while cross compiling)])])
296 fi
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000297fi
Hisham474d26c2016-02-14 19:57:29 -0200298if test "x$enable_linux_affinity" = xyes; then
299 AC_DEFINE(HAVE_LINUX_AFFINITY, 1, [Define if Linux sched_setaffinity and sched_getaffinity are to be used.])
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000300fi
301
Benny Baumann880eeca2020-12-12 19:49:52 +0100302if test "x$enable_linux_affinity" = xyes -a "x$enable_hwloc" = xyes; then
Christian Göttsche005c4d12020-09-08 16:25:22 +0200303 AC_MSG_ERROR([--enable-hwloc and --enable-linux-affinity are mutual exclusive. Specify at most one of them.])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000304fi
305
Hisham Muhammad543d65c2017-07-26 15:40:55 -0300306AC_ARG_ENABLE(setuid, [AS_HELP_STRING([--enable-setuid], [enable setuid support for platforms that need it])],, enable_setuid="no")
Benny Baumann880eeca2020-12-12 19:49:52 +0100307if test "x$enable_setuid" = xyes; then
Hisham Muhammad543d65c2017-07-26 15:40:55 -0300308 AC_DEFINE(HAVE_SETUID_ENABLED, 1, [Define if setuid support should be enabled.])
309fi
310
Christian Göttschef4404ef2020-09-02 14:39:25 +0200311AC_ARG_WITH(capabilities, [AS_HELP_STRING([--with-capabilities], [Enable option to drop Linux capabilities via libcap])],, with_capabilities="no")
312if test "x$with_capabilities" = xyes
313then
314 AC_CHECK_LIB([cap], [cap_init], [], [missing_libraries="$missing_libraries libcap"])
315 AC_CHECK_HEADERS([sys/capability.h], [:], [missing_headers="$missing_headers $ac_header"])
316fi
317
Hisham Muhammade85b0722018-04-06 11:03:00 -0300318AC_ARG_ENABLE(delayacct, [AS_HELP_STRING([--enable-delayacct], [enable Linux delay accounting])],, enable_delayacct="no")
Benny Baumann880eeca2020-12-12 19:49:52 +0100319if test "x$enable_delayacct" = xyes; then
Hisham Muhammade85b0722018-04-06 11:03:00 -0300320 m4_ifdef([PKG_PROG_PKG_CONFIG], [
321 PKG_PROG_PKG_CONFIG()
322 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"])
323 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"])
324 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
325 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
326 AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.])
327 ], [
Explorer09103f1a42018-04-06 23:47:55 +0800328 pkg_m4_absent=1
329 m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.])
330 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 Muhammade85b0722018-04-06 11:03:00 -0300331 ])
André Carvalhob7b66b72017-12-04 00:15:29 -0200332fi
333
Christian Göttsche4f08d2d2020-12-03 16:42:38 +0100334AC_ARG_WITH(sensors, [AS_HELP_STRING([--with-sensors], [Compile with libsensors support for reading temperature data. Only requires libsensors headers at compile time, at runtime libsensors is loaded via dlopen.])],, with_sensors="check")
335if test "x$with_sensors" = xyes; then
Christian Göttsche1b225cd2020-09-10 19:56:33 +0200336 AC_CHECK_HEADERS([sensors/sensors.h], [], [missing_headers="$missing_headers $ac_header"])
Christian Göttsche4f08d2d2020-12-03 16:42:38 +0100337elif test "x$with_sensors" = xcheck; then
338 with_sensors=yes
339 AC_CHECK_HEADERS([sensors/sensors.h], [], [with_sensors=no])
Christian Göttsche1b225cd2020-09-10 19:56:33 +0200340fi
341
Christian Göttschef4602f72020-09-08 14:25:46 +0200342AM_CFLAGS="\
343 -Wall\
344 -Wcast-align\
Christian Göttschedb472072020-10-04 14:30:35 +0200345 -Wcast-qual\
Christian Göttschef4602f72020-09-08 14:25:46 +0200346 -Wextra\
Benny Baumannba0fca12020-09-18 16:58:03 +0200347 -Wfloat-equal\
Christian Göttschec150e4b2020-12-18 15:49:37 +0100348 -Wformat=2\
Christian Göttsche4dadbe32021-01-21 19:49:07 +0100349 -Winit-self\
Christian Göttschef4602f72020-09-08 14:25:46 +0200350 -Wmissing-format-attribute\
351 -Wmissing-noreturn\
Christian Göttsche4e282eb2020-09-25 14:03:55 +0200352 -Wmissing-prototypes\
Christian Göttschef4602f72020-09-08 14:25:46 +0200353 -Wpointer-arith\
354 -Wshadow\
355 -Wstrict-prototypes\
356 -Wundef\
357 -Wunused\
358 -Wwrite-strings"
359
Benny Baumann2cde4a72020-09-18 19:32:41 +0200360AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
361
Christian Göttsche57254cd2020-08-21 10:37:20 +0200362AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no])
363AS_IF([test "x$enable_werror" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -Werror"])
Christian Göttscheb7f63292020-09-17 22:23:05 +0200364
Christian Göttsche57254cd2020-08-21 10:37:20 +0200365AC_SUBST([AM_CFLAGS])
André Carvalhob7b66b72017-12-04 00:15:29 -0200366
Christian Göttscheb7f63292020-09-17 22:23:05 +0200367AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable asserts (default: asserts are disabled)])], [enable_debug="$enableval"], [enable_debug=no])
368AS_IF([test "x$enable_debug" = "xyes"], , [AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"])
369
370AC_SUBST([AM_CPPFLAGS])
371
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200372# Bail out on errors.
373# ----------------------------------------------------------------------
374if test ! -z "$missing_libraries"; then
Benny Baumann880eeca2020-12-12 19:49:52 +0100375 AC_MSG_ERROR([missing libraries: $missing_libraries])
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200376fi
377if test ! -z "$missing_headers"; then
Benny Baumann880eeca2020-12-12 19:49:52 +0100378 AC_MSG_ERROR([missing headers: $missing_headers])
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200379fi
380
Daniel Lange079c2ab2020-10-05 09:51:32 +0200381AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-2019 Hisham Muhammad. (C) 2020 htop dev team.", [Copyright message.])
Hisham Muhammad3383d8e2015-01-21 23:27:31 -0200382
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200383# We're done, let's go!
384# ----------------------------------------------------------------------
Hisham Muhammada75161f2014-11-24 20:11:33 -0200385AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200386AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200387AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400388AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500389AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
gmbroome697f5bb2018-03-02 16:20:46 -0500390AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200391AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200392AC_SUBST(my_htop_platform)
Daniel Langee1722822020-08-24 21:37:28 +0200393AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000394AC_OUTPUT
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300395
Benny Baumann880eeca2020-12-12 19:49:52 +0100396if test "$my_htop_platform" = "unsupported"; then
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300397 echo ""
398 echo "****************************************************************"
399 echo "WARNING! This platform is not currently supported by htop."
400 echo ""
401 echo "The code will build, but it will produce a dummy version of htop"
402 echo "which shows no processes, using the files from the unsupported/"
403 echo "directory. This is meant to be a skeleton, to be used as a"
404 echo "starting point if you are porting htop to a new platform."
405 echo "****************************************************************"
406 echo ""
407fi
Christian Göttsche3b084db2020-08-28 12:10:31 +0200408
409AC_MSG_RESULT([
410 ${PACKAGE_NAME} ${VERSION}
411
Christian Göttscheffd90c22020-10-05 12:29:31 +0200412 platform: $my_htop_platform
413 (Linux) proc directory: $PROCDIR
414 (Linux) openvz: $enable_openvz
Christian Göttscheffd90c22020-10-05 12:29:31 +0200415 (Linux) vserver: $enable_vserver
416 (Linux) ancient vserver: $enable_ancient_vserver
Christian Göttscheffd90c22020-10-05 12:29:31 +0200417 (Linux) affinity: $enable_linux_affinity
418 (Linux) delay accounting: $enable_delayacct
Christian Göttsche4f08d2d2020-12-03 16:42:38 +0100419 (Linux) sensors: $with_sensors
Christian Göttschef4404ef2020-09-02 14:39:25 +0200420 (Linux) capabilities: $with_capabilities
Christian Göttscheffd90c22020-10-05 12:29:31 +0200421 unicode: $enable_unicode
Daniel Lange309f1d72020-11-16 13:29:37 +0100422 hwloc: $enable_hwloc
Christian Göttscheffd90c22020-10-05 12:29:31 +0200423 setuid: $enable_setuid
Daniel Langea8a723f2020-11-16 17:01:51 +0100424 debug: $enable_debug
Christian Göttsche3b084db2020-08-28 12:10:31 +0200425])