blob: 99915ccedc355bb375b281a190fc57cf990ed9b1 [file] [log] [blame]
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
Christian Göttschef3623b72021-01-22 19:14:50 +01004# ----------------------------------------------------------------------
5# Autoconf initialization.
6# ----------------------------------------------------------------------
7
Christian Göttsche38b6a012021-01-22 19:14:53 +01008AC_PREREQ([2.69])
Daniel Lange8aca6fb2021-06-18 07:52:44 +02009AC_INIT([htop], [3.1.0-dev], [htop@groups.io], [], [https://htop.dev/])
Hisham Muhammad3383d8e2015-01-21 23:27:31 -020010
Explorer09b71b07f2016-03-12 12:02:06 +080011AC_CONFIG_SRCDIR([htop.c])
Christian Göttsche38b6a012021-01-22 19:14:53 +010012AC_CONFIG_AUX_DIR([build-aux])
Explorer09b71b07f2016-03-12 12:02:06 +080013AC_CONFIG_HEADERS([config.h])
Explorer09b71b07f2016-03-12 12:02:06 +080014
Hisham Muhammadec17b702011-09-24 00:30:47 +000015AC_CANONICAL_TARGET
Christian Göttsche38b6a012021-01-22 19:14:53 +010016AM_INIT_AUTOMAKE([-Wall std-options subdir-objects])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000017
Hisham Muhammad300af4b2014-11-19 23:17:16 -020018# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010019
20
21# ----------------------------------------------------------------------
22# Checks for platform.
23# ----------------------------------------------------------------------
24
25case "$target_os" in
26linux*|gnu*)
27 my_htop_platform=linux
28 AC_DEFINE([HTOP_LINUX], [], [Building for Linux.])
29 ;;
30freebsd*|kfreebsd*)
31 my_htop_platform=freebsd
32 AC_DEFINE([HTOP_FREEBSD], [], [Building for FreeBSD.])
33 ;;
fraggerfox4b49de42021-03-15 13:14:39 +053034netbsd*)
35 my_htop_platform=netbsd
36 AC_DEFINE([HTOP_NETBSD], [], [Building for NetBSD.])
37 ;;
Christian Göttschef3623b72021-01-22 19:14:50 +010038openbsd*)
39 my_htop_platform=openbsd
40 AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD.])
41 ;;
42dragonfly*)
43 my_htop_platform=dragonflybsd
44 AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD.])
45 ;;
46darwin*)
47 my_htop_platform=darwin
48 AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin.])
49 ;;
50solaris*)
51 my_htop_platform=solaris
52 AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris.])
53 ;;
54*)
55 my_htop_platform=unsupported
56 AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform.])
57 ;;
58esac
Hisham Muhammad4df76d12008-03-05 09:46:47 +000059
Christian Göttsche38b6a012021-01-22 19:14:53 +010060# Enable extensions, required by hwloc scripts
Explorer09b71b07f2016-03-12 12:02:06 +080061AC_USE_SYSTEM_EXTENSIONS
62
Hisham Muhammadeb229d92014-11-24 18:55:03 -020063# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -020064
Christian Göttschef3623b72021-01-22 19:14:50 +010065
Hisham Muhammad300af4b2014-11-19 23:17:16 -020066# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010067# Checks for compiler.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020068# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000069
Christian Göttschef3623b72021-01-22 19:14:50 +010070AC_PROG_CC
71AM_PROG_CC_C_O
Christian Göttsche38b6a012021-01-22 19:14:53 +010072AC_PROG_CC_C99
73AS_IF([test "x$ac_cv_prog_cc_c99" = xno], [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000074
Christian Göttschef3623b72021-01-22 19:14:50 +010075# ----------------------------------------------------------------------
76
77
78# ----------------------------------------------------------------------
Christian Göttsche575edff2021-01-22 19:14:59 +010079# Checks for static build.
80# ----------------------------------------------------------------------
81
82AC_ARG_ENABLE([static],
83 [AS_HELP_STRING([--enable-static],
84 [build a static htop binary @<:@default=no@:>@])],
85 [],
86 [enable_static=no])
87case "$enable_static" in
88 no)
89 ;;
90 yes)
91 AC_DEFINE([BUILD_STATIC], [1], [Define if building static binary.])
92 CFLAGS="$CFLAGS -static"
93 LDFLAGS="$LDFLAGS -static"
94 ;;
95 *)
96 AC_MSG_ERROR([bad value '$enable_static' for --enable-static option])
97 ;;
98esac
99
100# ----------------------------------------------------------------------
101
Nathan Scottc14a45b2021-02-17 14:43:56 +1100102# ----------------------------------------------------------------------
103# Checks for a PCP-based htop build. (https://pcp.io)
104# ----------------------------------------------------------------------
105
106AC_ARG_ENABLE([pcp],
107 [AS_HELP_STRING([--enable-pcp],
Nathan Scott9ce95572021-04-14 11:34:47 +1000108 [build a pcp-htop binary @<:@default=no@:>@])],
Nathan Scottc14a45b2021-02-17 14:43:56 +1100109 [],
110 [enable_pcp=no])
111case "$enable_pcp" in
112 no)
113 ;;
114 yes)
115 AC_CHECK_HEADERS([pcp/pmapi.h], [my_htop_platform=pcp],
Benny Baumann92324d32021-06-13 19:46:13 +0200116 [AC_MSG_ERROR([can not find PCP header file])])
Nathan Scott94d37982021-06-08 09:46:02 +1000117 AC_SEARCH_LIBS([pmNewContext], [pcp], [], [AC_MSG_ERROR([can not find PCP library])])
118 AC_DEFINE([HTOP_PCP], [1], [Define if building pcp-htop binary.])
Nathan Scottc14a45b2021-02-17 14:43:56 +1100119 ;;
120 *)
Nathan Scott6bb59f82021-02-19 14:13:27 +1100121 AC_MSG_ERROR([bad value '$enable_pcp' for --enable-pcp option])
Nathan Scottc14a45b2021-02-17 14:43:56 +1100122 ;;
123esac
124
125# ----------------------------------------------------------------------
126
Christian Göttsche575edff2021-01-22 19:14:59 +0100127
128# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100129# Checks for generic header files.
130# ----------------------------------------------------------------------
131
132AC_HEADER_DIRENT
133AC_HEADER_STDC
134AC_CHECK_HEADERS([ \
135 stdlib.h \
136 string.h \
137 strings.h \
138 sys/param.h \
139 sys/time.h \
Nathan Scott5b50ae32021-03-02 15:58:11 +1100140 sys/utsname.h \
Christian Göttschef3623b72021-01-22 19:14:50 +0100141 unistd.h
Christian Göttsche759a3402021-01-22 19:14:55 +0100142 ], [], [AC_MSG_ERROR([can not find required generic header files])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100143
144AC_HEADER_MAJOR
145dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
146dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
147dnl been updated in Autoconf 2.69, so use a workaround:
148m4_version_prereq([2.70], [],
149[if test "x$ac_cv_header_sys_mkdev_h" != xyes; then
150 AC_CHECK_HEADER([sys/sysmacros.h], [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
151 [Define to 1 if `major', `minor', and `makedev' are declared in <sys/sysmacros.h>.])])
152fi])
153
154# Optional Section
155
156AC_CHECK_HEADERS([execinfo.h])
157
158if test "$my_htop_platform" = darwin; then
159 AC_CHECK_HEADERS([mach/mach_time.h])
160fi
161
162# ----------------------------------------------------------------------
163
164
165# ----------------------------------------------------------------------
166# Checks for typedefs, structures, and compiler characteristics.
167# ----------------------------------------------------------------------
168
Christian Göttschef3623b72021-01-22 19:14:50 +0100169AC_TYPE_PID_T
170AC_TYPE_UID_T
171AC_TYPE_UINT8_T
172AC_TYPE_UINT16_T
173AC_TYPE_UINT32_T
174AC_TYPE_UINT64_T
175
Benny Baumann44d12002021-06-27 12:44:01 +0200176AC_MSG_CHECKING(for alloc_size)
177old_CFLAGS="$CFLAGS"
178CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
179AC_COMPILE_IFELSE([
180 AC_LANG_SOURCE(
181 [
182 __attribute__((alloc_size(1))) char* my_alloc(int size) { return 0; }
183 ],[]
184 )],
185 AC_DEFINE([HAVE_ATTR_ALLOC_SIZE], 1, [The alloc_size attribute is supported.])
186 AC_MSG_RESULT(yes),
187 AC_MSG_RESULT(no))
188CFLAGS="$old_CFLAGS"
189
Christian Göttschef3623b72021-01-22 19:14:50 +0100190# ----------------------------------------------------------------------
191
192
193# ----------------------------------------------------------------------
194# Checks for generic library functions.
195# ----------------------------------------------------------------------
196
Christian Göttsche759a3402021-01-22 19:14:55 +0100197AC_CHECK_LIB([m], [ceil], [], [AC_MSG_ERROR([can not find required function ceil()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100198
199if test "$my_htop_platform" = dragonflybsd; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100200 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100201fi
202
203if test "$my_htop_platform" = freebsd; then
Christian Göttschecae47bb2021-02-05 15:15:01 +0100204 if test "$enable_static" = yes; then
205 AC_SEARCH_LIBS([elf_version], [elf], [], [AC_MSG_ERROR([can not find required function elf_version()])])
206 fi
Christian Göttsche759a3402021-01-22 19:14:55 +0100207 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
208 AC_SEARCH_LIBS([devstat_checkversion], [devstat], [], [AC_MSG_ERROR([can not find required function devstat_checkversion()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100209fi
210
211if test "$my_htop_platform" = linux; then
Christian Göttsche575edff2021-01-22 19:14:59 +0100212 if test "$enable_static" != yes; then
213 AC_SEARCH_LIBS([dlopen], [dl dld], [], [AC_MSG_ERROR([can not find required function dlopen()])])
214 fi
Christian Göttschef3623b72021-01-22 19:14:50 +0100215fi
216
fraggerfox4b49de42021-03-15 13:14:39 +0530217if test "$my_htop_platform" = netbsd; then
218 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
niafdcdc542021-07-26 19:04:44 +0200219 AC_SEARCH_LIBS([prop_dictionary_get], [prop], [], [AC_MSG_ERROR([can not find required function prop_dictionary_get()])])
fraggerfox4b49de42021-03-15 13:14:39 +0530220fi
221
Christian Göttschef3623b72021-01-22 19:14:50 +0100222if test "$my_htop_platform" = openbsd; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100223 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100224fi
225
226if test "$my_htop_platform" = solaris; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100227 AC_SEARCH_LIBS([kstat_open], [kstat], [], [AC_MSG_ERROR([can not find required function kstat_open()])])
228 AC_SEARCH_LIBS([Pgrab_error], [proc], [], [AC_MSG_ERROR([can not find required function Pgrab_error()])])
229 AC_SEARCH_LIBS([free], [malloc], [], [AC_MSG_ERROR([can not find required function free()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100230fi
231
232# Optional Section
233
234AC_SEARCH_LIBS([clock_gettime], [rt])
235
236AC_CHECK_FUNCS([ \
237 clock_gettime \
238 faccessat \
239 fstatat \
240 host_get_clock_service \
Christian Göttsche7b1fa1b2020-12-25 11:03:15 +0100241 memfd_create\
Christian Göttschef3623b72021-01-22 19:14:50 +0100242 openat \
243 readlinkat \
244 ])
245
Christian Göttsche1d008932020-10-15 21:12:57 +0200246# Add -lexecinfo if needed
247AC_SEARCH_LIBS([backtrace], [execinfo])
248
Christian Göttschef3623b72021-01-22 19:14:50 +0100249if test "$my_htop_platform" = darwin; then
250 AC_CHECK_FUNCS([mach_timebase_info])
251fi
Christian Goettschec2fdfd92020-10-21 17:06:32 +0200252
Christian Göttsche575edff2021-01-22 19:14:59 +0100253if test "$my_htop_platform" = linux && test "x$enable_static" = xyes; then
254 AC_CHECK_LIB([systemd], [sd_bus_open_system])
255fi
256
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200257# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200258
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000259
Christian Göttschef3623b72021-01-22 19:14:50 +0100260# ----------------------------------------------------------------------
261# Checks for cross-platform features and flags.
262# ----------------------------------------------------------------------
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000263
Hisham Muhammaddb682862015-12-09 17:17:30 -0200264# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
265m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200266[
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300267 if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
268 # to be used to set the path to ncurses*-config when cross-compiling
Michael Kleinbc5d4692018-02-26 14:19:01 +0100269 htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
270 htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300271 else
Michael Kleinbc5d4692018-02-26 14:19:01 +0100272 htop_config_script_libs=$([$4] --libs 2> /dev/null)
273 htop_config_script_cflags=$([$4] --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300274 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200275 htop_script_success=no
Michael Kleinbc5d4692018-02-26 14:19:01 +0100276 htop_save_CFLAGS="$CFLAGS"
277 if test ! "x$htop_config_script_libs" = x; then
Michael Kleinbc5d4692018-02-26 14:19:01 +0100278 CFLAGS="$htop_config_script_cflags $CFLAGS"
Hisham Muhammaddb682862015-12-09 17:17:30 -0200279 AC_CHECK_LIB([$1], [$2], [
280 AC_DEFINE([$3], 1, [The library is present.])
Michael Kleinbc5d4692018-02-26 14:19:01 +0100281 LIBS="$htop_config_script_libs $LIBS "
Hisham Muhammaddb682862015-12-09 17:17:30 -0200282 htop_script_success=yes
Michael Kleinbc5d4692018-02-26 14:19:01 +0100283 ], [
Benny Baumann880eeca2020-12-12 19:49:52 +0100284 CFLAGS="$htop_save_CFLAGS"
Christian Göttsche575edff2021-01-22 19:14:59 +0100285 ], [
286 $htop_config_script_libs
Michael Kleinbc5d4692018-02-26 14:19:01 +0100287 ])
Hisham Muhammadc2377022015-12-06 19:06:23 -0200288 fi
Hisham Muhammadcccc18d2015-12-09 17:34:57 -0200289 if test "x$htop_script_success" = xno; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200290 [$5]
291 fi
292])
293
294# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
295m4_define([HTOP_CHECK_LIB],
296[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200297 AC_CHECK_LIB([$1], [$2], [
Christian Göttsche575edff2021-01-22 19:14:59 +0100298 AC_DEFINE([$3], [1], [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200299 LIBS="-l[$1] $LIBS "
300 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200301])
302
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100303AC_ARG_ENABLE([unicode],
304 [AS_HELP_STRING([--enable-unicode],
305 [enable Unicode support @<:@default=yes@:>@])],
306 [],
307 [enable_unicode=yes])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000308if test "x$enable_unicode" = xyes; then
Christian Göttschefd8c0612021-01-28 17:40:33 +0100309 HTOP_CHECK_SCRIPT([ncursesw6], [waddwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
310 HTOP_CHECK_SCRIPT([ncursesw], [waddwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
311 HTOP_CHECK_SCRIPT([ncursesw], [wadd_wch], [HAVE_LIBNCURSESW], "ncursesw5-config",
312 HTOP_CHECK_SCRIPT([ncurses], [wadd_wch], [HAVE_LIBNCURSESW], "ncurses5-config",
313 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
314 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
315 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
Christian Göttsche759a3402021-01-22 19:14:55 +0100316 AC_MSG_ERROR([can not find required library libncursesw; you may want to use --disable-unicode])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200317 )))))))
Hisham Muhammaddb682862015-12-09 17:17:30 -0200318
Christian Göttsche759a3402021-01-22 19:14:55 +0100319 AC_CHECK_HEADERS([ncursesw/curses.h], [],
320 [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
321 [AC_CHECK_HEADERS([ncurses/curses.h], [],
322 [AC_CHECK_HEADERS([ncurses.h], [],
323 [AC_MSG_ERROR([can not find required ncurses header file])])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100324
325 # check if additional linker flags are needed for keypad(3)
326 # (at this point we already link against a working ncurses library with wide character support)
327 AC_SEARCH_LIBS([keypad], [tinfow tinfo])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000328else
Christian Göttsche575edff2021-01-22 19:14:59 +0100329 HTOP_CHECK_SCRIPT([ncurses6], [wnoutrefresh], [HAVE_LIBNCURSES], [ncurses6-config],
330 HTOP_CHECK_SCRIPT([ncurses], [wnoutrefresh], [HAVE_LIBNCURSES], [ncurses5-config],
Christian Göttschefd8c0612021-01-28 17:40:33 +0100331 HTOP_CHECK_LIB([ncurses6], [doupdate], [HAVE_LIBNCURSES],
332 HTOP_CHECK_LIB([ncurses], [doupdate], [HAVE_LIBNCURSES],
nia09c7e3e2021-07-13 17:53:47 +0200333 HTOP_CHECK_LIB([curses], [doupdate], [HAVE_LIBNCURSES],
334 AC_MSG_ERROR([can not find required curses/ncurses library])
335 )))))
Christian Göttscheb92f62f2020-08-21 10:37:33 +0200336
Christian Göttsche759a3402021-01-22 19:14:55 +0100337 AC_CHECK_HEADERS([curses.h], [],
338 [AC_CHECK_HEADERS([ncurses/curses.h], [],
339 [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
340 [AC_CHECK_HEADERS([ncurses.h] ,[],
341 [AC_MSG_ERROR([can not find required ncurses header file])])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100342
343 # check if additional linker flags are needed for keypad(3)
344 # (at this point we already link against a working ncurses library)
345 AC_SEARCH_LIBS([keypad], [tinfo])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000346fi
Christian Göttsche575edff2021-01-22 19:14:59 +0100347if test "$enable_static" = yes; then
348 AC_SEARCH_LIBS([Gpm_GetEvent], [gpm])
349fi
Christian Göttscheee9e7ed2021-05-20 18:27:10 +0200350if test "$my_htop_platform" = "solaris"; then
351 # On OmniOS /usr/include/sys/regset.h redefines ERR to 13 - \r, breaking the Enter key.
352 # Since ncruses macros use the ERR macro, we can not use another name.
353 AC_DEFINE([ERR], [(-1)], [Predefine ncurses macro.])
354fi
Benny Baumann18e3fd52021-07-04 16:50:41 +0200355AC_CHECK_FUNCS( [set_escdelay] )
nia2ab8fb82021-07-14 20:17:13 +0200356AC_CHECK_FUNCS( [getmouse] )
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000357
gmbroome697f5bb2018-03-02 16:20:46 -0500358
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200359AC_ARG_ENABLE([affinity],
360 [AS_HELP_STRING([--enable-affinity],
361 [enable sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
362 [],
363 [enable_affinity=check])
364if test "x$enable_affinity" = xcheck; then
365 if test "x$enable_hwloc" = xyes; then
366 enable_affinity=no
367 else
368 AC_MSG_CHECKING([for usable sched_setaffinity])
369 AC_RUN_IFELSE([
370 AC_LANG_PROGRAM([[
371 #include <sched.h>
372 #include <errno.h>
373 static cpu_set_t cpuset;
374 ]], [[
375 CPU_ZERO(&cpuset);
376 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
377 if (errno == ENOSYS) return 1;
378 ]])],
379 [enable_affinity=yes
380 AC_MSG_RESULT([yes])],
381 [enable_affinity=no
382 AC_MSG_RESULT([no])],
383 [AC_MSG_RESULT([yes (assumed while cross compiling)])])
384 fi
385fi
386if test "x$enable_affinity" = xyes; then
387 if test "x$enable_hwloc" = xyes; then
388 AC_MSG_ERROR([--enable-hwloc and --enable-affinity are mutual exclusive. Specify at most one of them.])
389 fi
390 AC_DEFINE([HAVE_AFFINITY], [1], [Define if sched_setaffinity and sched_getaffinity are to be used.])
391fi
392
393
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100394AC_ARG_ENABLE([hwloc],
395 [AS_HELP_STRING([--enable-hwloc],
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200396 [enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100397 [],
398 [enable_hwloc=no])
399case "$enable_hwloc" in
400 no)
401 ;;
402 yes)
Christian Göttsche759a3402021-01-22 19:14:55 +0100403 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
404 AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100405 ;;
406 *)
407 AC_MSG_ERROR([bad value '$enable_hwloc' for --enable-hwloc])
408 ;;
409esac
Christian Göttsche005c4d12020-09-08 16:25:22 +0200410
Nathan Scott5b50ae32021-03-02 15:58:11 +1100411AC_ARG_WITH([os-release],
412 [AS_HELP_STRING([--with-os-release=FILE],
Christian Göttsche8ba4ef32021-03-12 16:37:17 +0100413 [location of an os-release file @<:@default=/etc/os-release@:>@])],
Nathan Scott5b50ae32021-03-02 15:58:11 +1100414 [],
415 [with_os_release=/etc/os-release])
Christian Göttsche8ba4ef32021-03-12 16:37:17 +0100416if test -n "$with_os_release" && test ! -f "$with_os_release"; then
Nathan Scott5b50ae32021-03-02 15:58:11 +1100417 if test -f "/usr/lib/os-release"; then
418 with_os_release="/usr/lib/os-release"
419 fi
420fi
421AC_DEFINE_UNQUOTED([OSRELEASEFILE], ["$with_os_release"], [File with OS release details.])
422
Christian Göttschef3623b72021-01-22 19:14:50 +0100423# ----------------------------------------------------------------------
424
425
426# ----------------------------------------------------------------------
427# Checks for Linux features and flags.
428# ----------------------------------------------------------------------
429
430AC_ARG_WITH([proc],
431 [AS_HELP_STRING([--with-proc=DIR],
432 [location of a Linux-compatible proc filesystem @<:@default=/proc@:>@])],
433 [],
434 [with_proc=/proc])
435if test -z "$with_proc"; then
436 AC_MSG_ERROR([bad empty value for --with-proc option])
437fi
438AC_DEFINE_UNQUOTED([PROCDIR], ["$with_proc"], [Path of proc filesystem.])
439
440
441AC_ARG_ENABLE([openvz],
442 [AS_HELP_STRING([--enable-openvz],
443 [enable OpenVZ support @<:@default=no@:>@])],
444 [],
445 [enable_openvz=no])
446if test "x$enable_openvz" = xyes; then
447 AC_DEFINE([HAVE_OPENVZ], [1], [Define if openvz support enabled.])
448fi
449
450
451AC_ARG_ENABLE([vserver],
452 [AS_HELP_STRING([--enable-vserver],
453 [enable VServer support @<:@default=no@:>@])],
454 [],
455 [enable_vserver=no])
456if test "x$enable_vserver" = xyes; then
457 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
458fi
459
460
461AC_ARG_ENABLE([ancient_vserver],
462 [AS_HELP_STRING([--enable-ancient-vserver],
463 [enable ancient VServer support (implies --enable-vserver) @<:@default=no@:>@])],
464 [],
465 [enable_ancient_vserver=no])
466if test "x$enable_ancient_vserver" = xyes; then
467 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
468 AC_DEFINE([HAVE_ANCIENT_VSERVER], [1], [Define if ancient vserver support enabled.])
469fi
470
471
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100472AC_ARG_ENABLE([capabilities],
473 [AS_HELP_STRING([--enable-capabilities],
474 [enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
475 [],
476 [enable_capabilities=check])
477case "$enable_capabilities" in
478 no)
479 ;;
480 check)
481 enable_capabilities=yes
482 AC_CHECK_LIB([cap], [cap_init], [], [enable_capabilities=no])
483 AC_CHECK_HEADERS([sys/capability.h], [], [enable_capabilities=no])
484 ;;
485 yes)
Christian Göttsche759a3402021-01-22 19:14:55 +0100486 AC_CHECK_LIB([cap], [cap_init], [], [AC_MSG_ERROR([can not find required library libcap])])
487 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([can not find required header file sys/capability.h])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100488 ;;
489 *)
490 AC_MSG_ERROR([bad value '$enable_capabilities' for --enable-capabilities])
491 ;;
492esac
Christian Göttschef4404ef2020-09-02 14:39:25 +0200493
Christian Göttschef3623b72021-01-22 19:14:50 +0100494
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100495AC_ARG_ENABLE([delayacct],
496 [AS_HELP_STRING([--enable-delayacct],
497 [enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@default=check@:>@])],
498 [],
499 [enable_delayacct=check])
500case "$enable_delayacct" in
501 no)
502 ;;
503 check)
Christian Göttsche69cfaf22021-05-16 20:01:25 +0200504 if test "$my_htop_platform" != linux; then
505 enable_delayacct=no
506 elif test "$enable_static" = yes; then
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100507 enable_delayacct=no
Christian Göttsche575edff2021-01-22 19:14:59 +0100508 else
509 m4_ifdef([PKG_PROG_PKG_CONFIG], [
510 enable_delayacct=yes
511 PKG_PROG_PKG_CONFIG()
512 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [enable_delayacct=no])
513 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [enable_delayacct=no])
514 if test "$enable_delayacct" = yes; then
515 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
516 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
517 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
518 fi
519 ], [
520 enable_delayacct=no
521 AC_MSG_NOTICE([Linux delay accounting support can not be enabled, cause pkg-config is required for checking its availability])
522 ])
523 fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100524 ;;
525 yes)
526 m4_ifdef([PKG_PROG_PKG_CONFIG], [
527 PKG_PROG_PKG_CONFIG()
Christian Göttsche759a3402021-01-22 19:14:55 +0100528 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3])])
529 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3genl])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100530 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
531 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
532 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
533 ], [
534 pkg_m4_absent=1
535 m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.])
536 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.])
537 ])
538 ;;
539 *)
540 AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct])
541 ;;
542esac
André Carvalhob7b66b72017-12-04 00:15:29 -0200543
Christian Göttschef3623b72021-01-22 19:14:50 +0100544
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100545AC_ARG_ENABLE([sensors],
546 [AS_HELP_STRING([--enable-sensors],
547 [enable libsensors support for reading temperature data; requires only libsensors headers at compile time, at runtime libsensors is loaded via dlopen @<:@default=check@:>@])],
548 [],
549 [enable_sensors=check])
550case "$enable_sensors" in
551 no)
552 ;;
553 check)
554 enable_sensors=yes
Christian Göttsche575edff2021-01-22 19:14:59 +0100555 if test "$enable_static" = yes; then
556 AC_CHECK_LIB([sensors], [sensors_init], [], [enable_sensors=no])
557 fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100558 AC_CHECK_HEADERS([sensors/sensors.h], [], [enable_sensors=no])
559 ;;
560 yes)
Christian Göttsche575edff2021-01-22 19:14:59 +0100561 if test "$enable_static" = yes; then
562 AC_CHECK_LIB([sensors], [sensors_init], [], [AC_MSG_ERROR([can not find required library libsensors])])
563 fi
564 AC_CHECK_HEADERS([sensors/sensors.h], [], [AC_MSG_ERROR([can not find required header file sensors/sensors.h])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100565 ;;
566 *)
567 AC_MSG_ERROR([bad value '$enable_sensors' for --enable-sensors])
568 ;;
569esac
Christian Göttschefd2a0cf2020-12-22 20:02:01 +0100570if test "$enable_sensors" = yes || test "$my_htop_platform" = freebsd; then
571 AC_DEFINE([BUILD_WITH_CPU_TEMP], [1], [Define if CPU temperature option should be enabled.])
572fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100573
Christian Göttschef3623b72021-01-22 19:14:50 +0100574# ----------------------------------------------------------------------
575
576
577# ----------------------------------------------------------------------
578# Checks for compiler warnings.
579# ----------------------------------------------------------------------
Christian Göttsche1b225cd2020-09-10 19:56:33 +0200580
Christian Göttschef4602f72020-09-08 14:25:46 +0200581AM_CFLAGS="\
582 -Wall\
583 -Wcast-align\
Christian Göttschedb472072020-10-04 14:30:35 +0200584 -Wcast-qual\
Christian Göttschef4602f72020-09-08 14:25:46 +0200585 -Wextra\
Benny Baumannba0fca12020-09-18 16:58:03 +0200586 -Wfloat-equal\
Christian Göttschec150e4b2020-12-18 15:49:37 +0100587 -Wformat=2\
Christian Göttsche4dadbe32021-01-21 19:49:07 +0100588 -Winit-self\
Christian Göttschef4602f72020-09-08 14:25:46 +0200589 -Wmissing-format-attribute\
590 -Wmissing-noreturn\
Christian Göttsche4e282eb2020-09-25 14:03:55 +0200591 -Wmissing-prototypes\
Christian Göttschef4602f72020-09-08 14:25:46 +0200592 -Wpointer-arith\
593 -Wshadow\
594 -Wstrict-prototypes\
595 -Wundef\
596 -Wunused\
597 -Wwrite-strings"
598
Christian Göttsche64a1ab82021-02-05 15:20:00 +0100599# FreeBSD uses C11 _Generic in its isnan implementation, even with -std=c99
600if test "$my_htop_platform" = freebsd; then
601 AM_CFLAGS="$AM_CFLAGS -Wno-c11-extensions"
602fi
603
Christian Göttschef3623b72021-01-22 19:14:50 +0100604dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
605AC_DEFUN([AX_CHECK_COMPILE_FLAG],
Christian Göttsche38b6a012021-01-22 19:14:53 +0100606[
Christian Göttschef3623b72021-01-22 19:14:50 +0100607AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
608AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
609 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
610 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
611 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
612 [AS_VAR_SET(CACHEVAR,[yes])],
613 [AS_VAR_SET(CACHEVAR,[no])])
614 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
615AS_VAR_IF(CACHEVAR,yes,
616 [m4_default([$2], :)],
617 [m4_default([$3], :)])
618AS_VAR_POPDEF([CACHEVAR])dnl
619])dnl AX_CHECK_COMPILE_FLAGS
620
Benny Baumann2cde4a72020-09-18 19:32:41 +0200621AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
622
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100623AC_ARG_ENABLE([werror],
624 [AS_HELP_STRING([--enable-werror],
625 [Treat warnings as errors @<:@default=no@:>@])],
626 [],
627 [enable_werror=no])
628if test "x$enable_werror" = xyes; then
629 AM_CFLAGS="$AM_CFLAGS -Werror"
630fi
631
632AC_ARG_ENABLE([debug],
633 [AS_HELP_STRING([--enable-debug],
Daniel Lange135efd52021-02-16 11:22:02 +0100634 [Enable compiling with maximum debug info, asserts and internal sanity checks @<:@default=no@:>@])],
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100635 [],
636 [enable_debug=no])
637if test "x$enable_debug" != xyes; then
638 AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
Daniel Lange135efd52021-02-16 11:22:02 +0100639else
640 AM_CPPFLAGS="$AM_CPPFLAGS -ggdb3"
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100641fi
Christian Göttscheb7f63292020-09-17 22:23:05 +0200642
Christian Göttschef3623b72021-01-22 19:14:50 +0100643
Christian Göttsche57254cd2020-08-21 10:37:20 +0200644AC_SUBST([AM_CFLAGS])
Christian Göttscheb7f63292020-09-17 22:23:05 +0200645AC_SUBST([AM_CPPFLAGS])
646
Christian Göttschef3623b72021-01-22 19:14:50 +0100647# ----------------------------------------------------------------------
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100648
Christian Göttschef3623b72021-01-22 19:14:50 +0100649
650# ----------------------------------------------------------------------
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200651# We're done, let's go!
652# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100653
654AC_DEFINE_UNQUOTED([COPYRIGHT], ["(C) 2004-2019 Hisham Muhammad. (C) 2020-2021 htop dev team."], [Copyright message.])
655
Hisham Muhammada75161f2014-11-24 20:11:33 -0200656AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200657AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200658AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
fraggerfox4b49de42021-03-15 13:14:39 +0530659AM_CONDITIONAL([HTOP_NETBSD], [test "$my_htop_platform" = netbsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400660AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500661AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
gmbroome697f5bb2018-03-02 16:20:46 -0500662AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
Nathan Scottc14a45b2021-02-17 14:43:56 +1100663AM_CONDITIONAL([HTOP_PCP], [test "$my_htop_platform" = pcp])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200664AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Christian Göttsche38b6a012021-01-22 19:14:53 +0100665
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200666AC_SUBST(my_htop_platform)
Daniel Langee1722822020-08-24 21:37:28 +0200667AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000668AC_OUTPUT
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300669
Christian Göttschef3623b72021-01-22 19:14:50 +0100670if test "$my_htop_platform" = unsupported; then
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300671 echo ""
672 echo "****************************************************************"
673 echo "WARNING! This platform is not currently supported by htop."
674 echo ""
675 echo "The code will build, but it will produce a dummy version of htop"
676 echo "which shows no processes, using the files from the unsupported/"
677 echo "directory. This is meant to be a skeleton, to be used as a"
678 echo "starting point if you are porting htop to a new platform."
679 echo "****************************************************************"
680 echo ""
681fi
Christian Göttsche3b084db2020-08-28 12:10:31 +0200682
683AC_MSG_RESULT([
684 ${PACKAGE_NAME} ${VERSION}
685
Christian Göttscheffd90c22020-10-05 12:29:31 +0200686 platform: $my_htop_platform
Nathan Scott5b50ae32021-03-02 15:58:11 +1100687 os-release file: $with_os_release
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100688 (Linux) proc directory: $with_proc
Christian Göttscheffd90c22020-10-05 12:29:31 +0200689 (Linux) openvz: $enable_openvz
Christian Göttscheffd90c22020-10-05 12:29:31 +0200690 (Linux) vserver: $enable_vserver
691 (Linux) ancient vserver: $enable_ancient_vserver
Christian Göttscheffd90c22020-10-05 12:29:31 +0200692 (Linux) delay accounting: $enable_delayacct
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100693 (Linux) sensors: $enable_sensors
694 (Linux) capabilities: $enable_capabilities
Christian Göttscheffd90c22020-10-05 12:29:31 +0200695 unicode: $enable_unicode
Christian Göttsche1fb0c722021-06-13 11:29:39 +0200696 affinity: $enable_affinity
Daniel Lange309f1d72020-11-16 13:29:37 +0100697 hwloc: $enable_hwloc
Daniel Langea8a723f2020-11-16 17:01:51 +0100698 debug: $enable_debug
Christian Göttsche575edff2021-01-22 19:14:59 +0100699 static: $enable_static
Christian Göttsche3b084db2020-08-28 12:10:31 +0200700])