blob: 95b011435cc2ec3146e9b14c31f4d0144c0c061b [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])
9AC_INIT([htop], [3.0.6-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 ;;
34openbsd*)
35 my_htop_platform=openbsd
36 AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD.])
37 ;;
38dragonfly*)
39 my_htop_platform=dragonflybsd
40 AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD.])
41 ;;
42darwin*)
43 my_htop_platform=darwin
44 AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin.])
45 ;;
46solaris*)
47 my_htop_platform=solaris
48 AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris.])
49 ;;
50*)
51 my_htop_platform=unsupported
52 AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform.])
53 ;;
54esac
Hisham Muhammad4df76d12008-03-05 09:46:47 +000055
Christian Göttsche38b6a012021-01-22 19:14:53 +010056# Enable extensions, required by hwloc scripts
Explorer09b71b07f2016-03-12 12:02:06 +080057AC_USE_SYSTEM_EXTENSIONS
58
Hisham Muhammadeb229d92014-11-24 18:55:03 -020059# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -020060
Christian Göttschef3623b72021-01-22 19:14:50 +010061
Hisham Muhammad300af4b2014-11-19 23:17:16 -020062# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010063# Checks for compiler.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020064# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000065
Christian Göttschef3623b72021-01-22 19:14:50 +010066AC_PROG_CC
67AM_PROG_CC_C_O
Christian Göttsche38b6a012021-01-22 19:14:53 +010068AC_PROG_CC_C99
69AS_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 +000070
Christian Göttschef3623b72021-01-22 19:14:50 +010071# ----------------------------------------------------------------------
72
73
74# ----------------------------------------------------------------------
Christian Göttsche575edff2021-01-22 19:14:59 +010075# Checks for static build.
76# ----------------------------------------------------------------------
77
78AC_ARG_ENABLE([static],
79 [AS_HELP_STRING([--enable-static],
80 [build a static htop binary @<:@default=no@:>@])],
81 [],
82 [enable_static=no])
83case "$enable_static" in
84 no)
85 ;;
86 yes)
87 AC_DEFINE([BUILD_STATIC], [1], [Define if building static binary.])
88 CFLAGS="$CFLAGS -static"
89 LDFLAGS="$LDFLAGS -static"
90 ;;
91 *)
92 AC_MSG_ERROR([bad value '$enable_static' for --enable-static option])
93 ;;
94esac
95
96# ----------------------------------------------------------------------
97
98
99# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100100# Checks for generic header files.
101# ----------------------------------------------------------------------
102
103AC_HEADER_DIRENT
104AC_HEADER_STDC
105AC_CHECK_HEADERS([ \
106 stdlib.h \
107 string.h \
108 strings.h \
109 sys/param.h \
110 sys/time.h \
Nathan Scott5b50ae32021-03-02 15:58:11 +1100111 sys/utsname.h \
Christian Göttschef3623b72021-01-22 19:14:50 +0100112 unistd.h
Christian Göttsche759a3402021-01-22 19:14:55 +0100113 ], [], [AC_MSG_ERROR([can not find required generic header files])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100114
115AC_HEADER_MAJOR
116dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
117dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
118dnl been updated in Autoconf 2.69, so use a workaround:
119m4_version_prereq([2.70], [],
120[if test "x$ac_cv_header_sys_mkdev_h" != xyes; then
121 AC_CHECK_HEADER([sys/sysmacros.h], [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
122 [Define to 1 if `major', `minor', and `makedev' are declared in <sys/sysmacros.h>.])])
123fi])
124
125# Optional Section
126
127AC_CHECK_HEADERS([execinfo.h])
128
129if test "$my_htop_platform" = darwin; then
130 AC_CHECK_HEADERS([mach/mach_time.h])
131fi
132
133# ----------------------------------------------------------------------
134
135
136# ----------------------------------------------------------------------
137# Checks for typedefs, structures, and compiler characteristics.
138# ----------------------------------------------------------------------
139
Christian Göttschef3623b72021-01-22 19:14:50 +0100140AC_TYPE_PID_T
141AC_TYPE_UID_T
142AC_TYPE_UINT8_T
143AC_TYPE_UINT16_T
144AC_TYPE_UINT32_T
145AC_TYPE_UINT64_T
146
147# ----------------------------------------------------------------------
148
149
150# ----------------------------------------------------------------------
151# Checks for generic library functions.
152# ----------------------------------------------------------------------
153
Christian Göttsche759a3402021-01-22 19:14:55 +0100154AC_CHECK_LIB([m], [ceil], [], [AC_MSG_ERROR([can not find required function ceil()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100155
156if test "$my_htop_platform" = dragonflybsd; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100157 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100158fi
159
160if test "$my_htop_platform" = freebsd; then
Christian Göttschecae47bb2021-02-05 15:15:01 +0100161 if test "$enable_static" = yes; then
162 AC_SEARCH_LIBS([elf_version], [elf], [], [AC_MSG_ERROR([can not find required function elf_version()])])
163 fi
Christian Göttsche759a3402021-01-22 19:14:55 +0100164 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
165 AC_SEARCH_LIBS([devstat_checkversion], [devstat], [], [AC_MSG_ERROR([can not find required function devstat_checkversion()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100166fi
167
168if test "$my_htop_platform" = linux; then
Christian Göttsche575edff2021-01-22 19:14:59 +0100169 if test "$enable_static" != yes; then
170 AC_SEARCH_LIBS([dlopen], [dl dld], [], [AC_MSG_ERROR([can not find required function dlopen()])])
171 fi
Christian Göttschef3623b72021-01-22 19:14:50 +0100172fi
173
174if test "$my_htop_platform" = openbsd; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100175 AC_SEARCH_LIBS([kvm_open], [kvm], [], [AC_MSG_ERROR([can not find required function kvm_open()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100176fi
177
178if test "$my_htop_platform" = solaris; then
Christian Göttsche759a3402021-01-22 19:14:55 +0100179 AC_SEARCH_LIBS([kstat_open], [kstat], [], [AC_MSG_ERROR([can not find required function kstat_open()])])
180 AC_SEARCH_LIBS([Pgrab_error], [proc], [], [AC_MSG_ERROR([can not find required function Pgrab_error()])])
181 AC_SEARCH_LIBS([free], [malloc], [], [AC_MSG_ERROR([can not find required function free()])])
Christian Göttschef3623b72021-01-22 19:14:50 +0100182fi
183
184# Optional Section
185
186AC_SEARCH_LIBS([clock_gettime], [rt])
187
188AC_CHECK_FUNCS([ \
189 clock_gettime \
190 faccessat \
191 fstatat \
192 host_get_clock_service \
Christian Göttsche7b1fa1b2020-12-25 11:03:15 +0100193 memfd_create\
Christian Göttschef3623b72021-01-22 19:14:50 +0100194 openat \
195 readlinkat \
196 ])
197
Christian Göttsche1d008932020-10-15 21:12:57 +0200198# Add -lexecinfo if needed
199AC_SEARCH_LIBS([backtrace], [execinfo])
200
Christian Göttschef3623b72021-01-22 19:14:50 +0100201if test "$my_htop_platform" = darwin; then
202 AC_CHECK_FUNCS([mach_timebase_info])
203fi
Christian Goettschec2fdfd92020-10-21 17:06:32 +0200204
Christian Göttsche575edff2021-01-22 19:14:59 +0100205if test "$my_htop_platform" = linux && test "x$enable_static" = xyes; then
206 AC_CHECK_LIB([systemd], [sd_bus_open_system])
207fi
208
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200209# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200210
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000211
Christian Göttschef3623b72021-01-22 19:14:50 +0100212# ----------------------------------------------------------------------
213# Checks for cross-platform features and flags.
214# ----------------------------------------------------------------------
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000215
Hisham Muhammaddb682862015-12-09 17:17:30 -0200216# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
217m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200218[
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300219 if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
220 # to be used to set the path to ncurses*-config when cross-compiling
Michael Kleinbc5d4692018-02-26 14:19:01 +0100221 htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
222 htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300223 else
Michael Kleinbc5d4692018-02-26 14:19:01 +0100224 htop_config_script_libs=$([$4] --libs 2> /dev/null)
225 htop_config_script_cflags=$([$4] --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300226 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200227 htop_script_success=no
Michael Kleinbc5d4692018-02-26 14:19:01 +0100228 htop_save_CFLAGS="$CFLAGS"
229 if test ! "x$htop_config_script_libs" = x; then
Michael Kleinbc5d4692018-02-26 14:19:01 +0100230 CFLAGS="$htop_config_script_cflags $CFLAGS"
Hisham Muhammaddb682862015-12-09 17:17:30 -0200231 AC_CHECK_LIB([$1], [$2], [
232 AC_DEFINE([$3], 1, [The library is present.])
Michael Kleinbc5d4692018-02-26 14:19:01 +0100233 LIBS="$htop_config_script_libs $LIBS "
Hisham Muhammaddb682862015-12-09 17:17:30 -0200234 htop_script_success=yes
Michael Kleinbc5d4692018-02-26 14:19:01 +0100235 ], [
Benny Baumann880eeca2020-12-12 19:49:52 +0100236 CFLAGS="$htop_save_CFLAGS"
Christian Göttsche575edff2021-01-22 19:14:59 +0100237 ], [
238 $htop_config_script_libs
Michael Kleinbc5d4692018-02-26 14:19:01 +0100239 ])
Hisham Muhammadc2377022015-12-06 19:06:23 -0200240 fi
Hisham Muhammadcccc18d2015-12-09 17:34:57 -0200241 if test "x$htop_script_success" = xno; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200242 [$5]
243 fi
244])
245
246# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
247m4_define([HTOP_CHECK_LIB],
248[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200249 AC_CHECK_LIB([$1], [$2], [
Christian Göttsche575edff2021-01-22 19:14:59 +0100250 AC_DEFINE([$3], [1], [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200251 LIBS="-l[$1] $LIBS "
252 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200253])
254
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100255AC_ARG_ENABLE([unicode],
256 [AS_HELP_STRING([--enable-unicode],
257 [enable Unicode support @<:@default=yes@:>@])],
258 [],
259 [enable_unicode=yes])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000260if test "x$enable_unicode" = xyes; then
Christian Göttschefd8c0612021-01-28 17:40:33 +0100261 HTOP_CHECK_SCRIPT([ncursesw6], [waddwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
262 HTOP_CHECK_SCRIPT([ncursesw], [waddwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
263 HTOP_CHECK_SCRIPT([ncursesw], [wadd_wch], [HAVE_LIBNCURSESW], "ncursesw5-config",
264 HTOP_CHECK_SCRIPT([ncurses], [wadd_wch], [HAVE_LIBNCURSESW], "ncurses5-config",
265 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
266 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
267 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
Christian Göttsche759a3402021-01-22 19:14:55 +0100268 AC_MSG_ERROR([can not find required library libncursesw; you may want to use --disable-unicode])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200269 )))))))
Hisham Muhammaddb682862015-12-09 17:17:30 -0200270
Christian Göttsche759a3402021-01-22 19:14:55 +0100271 AC_CHECK_HEADERS([ncursesw/curses.h], [],
272 [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
273 [AC_CHECK_HEADERS([ncurses/curses.h], [],
274 [AC_CHECK_HEADERS([ncurses.h], [],
275 [AC_MSG_ERROR([can not find required ncurses header file])])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100276
277 # check if additional linker flags are needed for keypad(3)
278 # (at this point we already link against a working ncurses library with wide character support)
279 AC_SEARCH_LIBS([keypad], [tinfow tinfo])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000280else
Christian Göttsche575edff2021-01-22 19:14:59 +0100281 HTOP_CHECK_SCRIPT([ncurses6], [wnoutrefresh], [HAVE_LIBNCURSES], [ncurses6-config],
282 HTOP_CHECK_SCRIPT([ncurses], [wnoutrefresh], [HAVE_LIBNCURSES], [ncurses5-config],
Christian Göttschefd8c0612021-01-28 17:40:33 +0100283 HTOP_CHECK_LIB([ncurses6], [doupdate], [HAVE_LIBNCURSES],
284 HTOP_CHECK_LIB([ncurses], [doupdate], [HAVE_LIBNCURSES],
Christian Göttsche759a3402021-01-22 19:14:55 +0100285 AC_MSG_ERROR([can not find required library libncurses])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200286 ))))
Christian Göttscheb92f62f2020-08-21 10:37:33 +0200287
Christian Göttsche759a3402021-01-22 19:14:55 +0100288 AC_CHECK_HEADERS([curses.h], [],
289 [AC_CHECK_HEADERS([ncurses/curses.h], [],
290 [AC_CHECK_HEADERS([ncurses/ncurses.h], [],
291 [AC_CHECK_HEADERS([ncurses.h] ,[],
292 [AC_MSG_ERROR([can not find required ncurses header file])])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100293
294 # check if additional linker flags are needed for keypad(3)
295 # (at this point we already link against a working ncurses library)
296 AC_SEARCH_LIBS([keypad], [tinfo])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000297fi
Christian Göttsche575edff2021-01-22 19:14:59 +0100298if test "$enable_static" = yes; then
299 AC_SEARCH_LIBS([Gpm_GetEvent], [gpm])
300fi
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000301
gmbroome697f5bb2018-03-02 16:20:46 -0500302
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100303AC_ARG_ENABLE([hwloc],
304 [AS_HELP_STRING([--enable-hwloc],
305 [enable hwloc support for CPU affinity; disables Linux affinity; requires libhwloc @<:@default=no@:>@])],
306 [],
307 [enable_hwloc=no])
308case "$enable_hwloc" in
309 no)
310 ;;
311 yes)
Christian Göttsche759a3402021-01-22 19:14:55 +0100312 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [AC_MSG_ERROR([can not find required library libhwloc])])
313 AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([can not find require header file hwloc.h])])
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100314 ;;
315 *)
316 AC_MSG_ERROR([bad value '$enable_hwloc' for --enable-hwloc])
317 ;;
318esac
Christian Göttsche005c4d12020-09-08 16:25:22 +0200319
Nathan Scott5b50ae32021-03-02 15:58:11 +1100320AC_ARG_WITH([os-release],
321 [AS_HELP_STRING([--with-os-release=FILE],
322 [location of an os-release file @<:@default=/etc/os-release@:>@])],
323 [],
324 [with_os_release=/etc/os-release])
325if test -n "$with_os_release" -a ! -f "$with_os_release"; then
326 if test -f "/usr/lib/os-release"; then
327 with_os_release="/usr/lib/os-release"
328 fi
329fi
330AC_DEFINE_UNQUOTED([OSRELEASEFILE], ["$with_os_release"], [File with OS release details.])
331
Christian Göttschef3623b72021-01-22 19:14:50 +0100332# ----------------------------------------------------------------------
333
334
335# ----------------------------------------------------------------------
336# Checks for Linux features and flags.
337# ----------------------------------------------------------------------
338
339AC_ARG_WITH([proc],
340 [AS_HELP_STRING([--with-proc=DIR],
341 [location of a Linux-compatible proc filesystem @<:@default=/proc@:>@])],
342 [],
343 [with_proc=/proc])
344if test -z "$with_proc"; then
345 AC_MSG_ERROR([bad empty value for --with-proc option])
346fi
347AC_DEFINE_UNQUOTED([PROCDIR], ["$with_proc"], [Path of proc filesystem.])
348
349
350AC_ARG_ENABLE([openvz],
351 [AS_HELP_STRING([--enable-openvz],
352 [enable OpenVZ support @<:@default=no@:>@])],
353 [],
354 [enable_openvz=no])
355if test "x$enable_openvz" = xyes; then
356 AC_DEFINE([HAVE_OPENVZ], [1], [Define if openvz support enabled.])
357fi
358
359
360AC_ARG_ENABLE([vserver],
361 [AS_HELP_STRING([--enable-vserver],
362 [enable VServer support @<:@default=no@:>@])],
363 [],
364 [enable_vserver=no])
365if test "x$enable_vserver" = xyes; then
366 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
367fi
368
369
370AC_ARG_ENABLE([ancient_vserver],
371 [AS_HELP_STRING([--enable-ancient-vserver],
372 [enable ancient VServer support (implies --enable-vserver) @<:@default=no@:>@])],
373 [],
374 [enable_ancient_vserver=no])
375if test "x$enable_ancient_vserver" = xyes; then
376 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
377 AC_DEFINE([HAVE_ANCIENT_VSERVER], [1], [Define if ancient vserver support enabled.])
378fi
379
380
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100381AC_ARG_ENABLE([linux_affinity],
382 [AS_HELP_STRING([--enable-linux-affinity],
383 [enable Linux sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
384 [],
385 [enable_linux_affinity=check])
Christian Göttsche005c4d12020-09-08 16:25:22 +0200386if test "x$enable_linux_affinity" = xcheck; then
387 if test "x$enable_hwloc" = xyes; then
388 enable_linux_affinity=no
389 else
390 AC_MSG_CHECKING([for usable sched_setaffinity])
391 AC_RUN_IFELSE([
392 AC_LANG_PROGRAM([[
393 #include <sched.h>
394 #include <errno.h>
395 static cpu_set_t cpuset;
396 ]], [[
397 CPU_ZERO(&cpuset);
398 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
399 if (errno == ENOSYS) return 1;
400 ]])],
401 [enable_linux_affinity=yes
Benny Baumann880eeca2020-12-12 19:49:52 +0100402 AC_MSG_RESULT([yes])],
Christian Göttsche005c4d12020-09-08 16:25:22 +0200403 [enable_linux_affinity=no
Benny Baumann880eeca2020-12-12 19:49:52 +0100404 AC_MSG_RESULT([no])],
Christian Göttsche005c4d12020-09-08 16:25:22 +0200405 [AC_MSG_RESULT([yes (assumed while cross compiling)])])
406 fi
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000407fi
Hisham474d26c2016-02-14 19:57:29 -0200408if test "x$enable_linux_affinity" = xyes; then
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100409 if test "x$enable_hwloc" = xyes; then
410 AC_MSG_ERROR([--enable-hwloc and --enable-linux-affinity are mutual exclusive. Specify at most one of them.])
411 fi
412 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 +0000413fi
414
Hisham Muhammad543d65c2017-07-26 15:40:55 -0300415
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100416AC_ARG_ENABLE([capabilities],
417 [AS_HELP_STRING([--enable-capabilities],
418 [enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
419 [],
420 [enable_capabilities=check])
421case "$enable_capabilities" in
422 no)
423 ;;
424 check)
425 enable_capabilities=yes
426 AC_CHECK_LIB([cap], [cap_init], [], [enable_capabilities=no])
427 AC_CHECK_HEADERS([sys/capability.h], [], [enable_capabilities=no])
428 ;;
429 yes)
Christian Göttsche759a3402021-01-22 19:14:55 +0100430 AC_CHECK_LIB([cap], [cap_init], [], [AC_MSG_ERROR([can not find required library libcap])])
431 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 +0100432 ;;
433 *)
434 AC_MSG_ERROR([bad value '$enable_capabilities' for --enable-capabilities])
435 ;;
436esac
Christian Göttschef4404ef2020-09-02 14:39:25 +0200437
Christian Göttschef3623b72021-01-22 19:14:50 +0100438
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100439AC_ARG_ENABLE([delayacct],
440 [AS_HELP_STRING([--enable-delayacct],
441 [enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@default=check@:>@])],
442 [],
443 [enable_delayacct=check])
444case "$enable_delayacct" in
445 no)
446 ;;
447 check)
Christian Göttsche575edff2021-01-22 19:14:59 +0100448 if test "$enable_static" = yes; then
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100449 enable_delayacct=no
Christian Göttsche575edff2021-01-22 19:14:59 +0100450 else
451 m4_ifdef([PKG_PROG_PKG_CONFIG], [
452 enable_delayacct=yes
453 PKG_PROG_PKG_CONFIG()
454 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [enable_delayacct=no])
455 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [enable_delayacct=no])
456 if test "$enable_delayacct" = yes; then
457 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
458 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
459 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
460 fi
461 ], [
462 enable_delayacct=no
463 AC_MSG_NOTICE([Linux delay accounting support can not be enabled, cause pkg-config is required for checking its availability])
464 ])
465 fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100466 ;;
467 yes)
468 m4_ifdef([PKG_PROG_PKG_CONFIG], [
469 PKG_PROG_PKG_CONFIG()
Christian Göttsche759a3402021-01-22 19:14:55 +0100470 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [AC_MSG_ERROR([can not find required library libnl3])])
471 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 +0100472 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
473 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
474 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
475 ], [
476 pkg_m4_absent=1
477 m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.])
478 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.])
479 ])
480 ;;
481 *)
482 AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct])
483 ;;
484esac
André Carvalhob7b66b72017-12-04 00:15:29 -0200485
Christian Göttschef3623b72021-01-22 19:14:50 +0100486
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100487AC_ARG_ENABLE([sensors],
488 [AS_HELP_STRING([--enable-sensors],
489 [enable libsensors support for reading temperature data; requires only libsensors headers at compile time, at runtime libsensors is loaded via dlopen @<:@default=check@:>@])],
490 [],
491 [enable_sensors=check])
492case "$enable_sensors" in
493 no)
494 ;;
495 check)
496 enable_sensors=yes
Christian Göttsche575edff2021-01-22 19:14:59 +0100497 if test "$enable_static" = yes; then
498 AC_CHECK_LIB([sensors], [sensors_init], [], [enable_sensors=no])
499 fi
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100500 AC_CHECK_HEADERS([sensors/sensors.h], [], [enable_sensors=no])
501 ;;
502 yes)
Christian Göttsche575edff2021-01-22 19:14:59 +0100503 if test "$enable_static" = yes; then
504 AC_CHECK_LIB([sensors], [sensors_init], [], [AC_MSG_ERROR([can not find required library libsensors])])
505 fi
506 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 +0100507 ;;
508 *)
509 AC_MSG_ERROR([bad value '$enable_sensors' for --enable-sensors])
510 ;;
511esac
512
Christian Göttschef3623b72021-01-22 19:14:50 +0100513# ----------------------------------------------------------------------
514
515
516# ----------------------------------------------------------------------
517# Checks for compiler warnings.
518# ----------------------------------------------------------------------
Christian Göttsche1b225cd2020-09-10 19:56:33 +0200519
Christian Göttschef4602f72020-09-08 14:25:46 +0200520AM_CFLAGS="\
521 -Wall\
522 -Wcast-align\
Christian Göttschedb472072020-10-04 14:30:35 +0200523 -Wcast-qual\
Christian Göttschef4602f72020-09-08 14:25:46 +0200524 -Wextra\
Benny Baumannba0fca12020-09-18 16:58:03 +0200525 -Wfloat-equal\
Christian Göttschec150e4b2020-12-18 15:49:37 +0100526 -Wformat=2\
Christian Göttsche4dadbe32021-01-21 19:49:07 +0100527 -Winit-self\
Christian Göttschef4602f72020-09-08 14:25:46 +0200528 -Wmissing-format-attribute\
529 -Wmissing-noreturn\
Christian Göttsche4e282eb2020-09-25 14:03:55 +0200530 -Wmissing-prototypes\
Christian Göttschef4602f72020-09-08 14:25:46 +0200531 -Wpointer-arith\
532 -Wshadow\
533 -Wstrict-prototypes\
534 -Wundef\
535 -Wunused\
536 -Wwrite-strings"
537
Christian Göttsche64a1ab82021-02-05 15:20:00 +0100538# FreeBSD uses C11 _Generic in its isnan implementation, even with -std=c99
539if test "$my_htop_platform" = freebsd; then
540 AM_CFLAGS="$AM_CFLAGS -Wno-c11-extensions"
541fi
542
Christian Göttschef3623b72021-01-22 19:14:50 +0100543dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
544AC_DEFUN([AX_CHECK_COMPILE_FLAG],
Christian Göttsche38b6a012021-01-22 19:14:53 +0100545[
Christian Göttschef3623b72021-01-22 19:14:50 +0100546AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
547AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
548 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
549 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
550 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
551 [AS_VAR_SET(CACHEVAR,[yes])],
552 [AS_VAR_SET(CACHEVAR,[no])])
553 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
554AS_VAR_IF(CACHEVAR,yes,
555 [m4_default([$2], :)],
556 [m4_default([$3], :)])
557AS_VAR_POPDEF([CACHEVAR])dnl
558])dnl AX_CHECK_COMPILE_FLAGS
559
Benny Baumann2cde4a72020-09-18 19:32:41 +0200560AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
561
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100562AC_ARG_ENABLE([werror],
563 [AS_HELP_STRING([--enable-werror],
564 [Treat warnings as errors @<:@default=no@:>@])],
565 [],
566 [enable_werror=no])
567if test "x$enable_werror" = xyes; then
568 AM_CFLAGS="$AM_CFLAGS -Werror"
569fi
570
571AC_ARG_ENABLE([debug],
572 [AS_HELP_STRING([--enable-debug],
Daniel Lange135efd52021-02-16 11:22:02 +0100573 [Enable compiling with maximum debug info, asserts and internal sanity checks @<:@default=no@:>@])],
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100574 [],
575 [enable_debug=no])
576if test "x$enable_debug" != xyes; then
577 AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
Daniel Lange135efd52021-02-16 11:22:02 +0100578else
579 AM_CPPFLAGS="$AM_CPPFLAGS -ggdb3"
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100580fi
Christian Göttscheb7f63292020-09-17 22:23:05 +0200581
Christian Göttschef3623b72021-01-22 19:14:50 +0100582
Christian Göttsche57254cd2020-08-21 10:37:20 +0200583AC_SUBST([AM_CFLAGS])
Christian Göttscheb7f63292020-09-17 22:23:05 +0200584AC_SUBST([AM_CPPFLAGS])
585
Christian Göttschef3623b72021-01-22 19:14:50 +0100586# ----------------------------------------------------------------------
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100587
Christian Göttschef3623b72021-01-22 19:14:50 +0100588
589# ----------------------------------------------------------------------
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200590# We're done, let's go!
591# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100592
593AC_DEFINE_UNQUOTED([COPYRIGHT], ["(C) 2004-2019 Hisham Muhammad. (C) 2020-2021 htop dev team."], [Copyright message.])
594
Hisham Muhammada75161f2014-11-24 20:11:33 -0200595AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200596AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200597AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400598AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500599AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
gmbroome697f5bb2018-03-02 16:20:46 -0500600AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200601AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Christian Göttsche38b6a012021-01-22 19:14:53 +0100602
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200603AC_SUBST(my_htop_platform)
Daniel Langee1722822020-08-24 21:37:28 +0200604AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000605AC_OUTPUT
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300606
Christian Göttschef3623b72021-01-22 19:14:50 +0100607if test "$my_htop_platform" = unsupported; then
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300608 echo ""
609 echo "****************************************************************"
610 echo "WARNING! This platform is not currently supported by htop."
611 echo ""
612 echo "The code will build, but it will produce a dummy version of htop"
613 echo "which shows no processes, using the files from the unsupported/"
614 echo "directory. This is meant to be a skeleton, to be used as a"
615 echo "starting point if you are porting htop to a new platform."
616 echo "****************************************************************"
617 echo ""
618fi
Christian Göttsche3b084db2020-08-28 12:10:31 +0200619
620AC_MSG_RESULT([
621 ${PACKAGE_NAME} ${VERSION}
622
Christian Göttscheffd90c22020-10-05 12:29:31 +0200623 platform: $my_htop_platform
Nathan Scott5b50ae32021-03-02 15:58:11 +1100624 os-release file: $with_os_release
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100625 (Linux) proc directory: $with_proc
Christian Göttscheffd90c22020-10-05 12:29:31 +0200626 (Linux) openvz: $enable_openvz
Christian Göttscheffd90c22020-10-05 12:29:31 +0200627 (Linux) vserver: $enable_vserver
628 (Linux) ancient vserver: $enable_ancient_vserver
Christian Göttscheffd90c22020-10-05 12:29:31 +0200629 (Linux) affinity: $enable_linux_affinity
630 (Linux) delay accounting: $enable_delayacct
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100631 (Linux) sensors: $enable_sensors
632 (Linux) capabilities: $enable_capabilities
Christian Göttscheffd90c22020-10-05 12:29:31 +0200633 unicode: $enable_unicode
Daniel Lange309f1d72020-11-16 13:29:37 +0100634 hwloc: $enable_hwloc
Daniel Langea8a723f2020-11-16 17:01:51 +0100635 debug: $enable_debug
Christian Göttsche575edff2021-01-22 19:14:59 +0100636 static: $enable_static
Christian Göttsche3b084db2020-08-28 12:10:31 +0200637])