blob: 7735c019eb2f70671e086d4589eb41f745306cee [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
8AC_PREREQ([2.65])
9AC_INIT([htop], [3.0.6-dev], [htop@groups.io])
Hisham Muhammad3383d8e2015-01-21 23:27:31 -020010
Explorer09b71b07f2016-03-12 12:02:06 +080011AC_CONFIG_SRCDIR([htop.c])
12AC_CONFIG_AUX_DIR([.])
13AC_CONFIG_HEADERS([config.h])
Explorer09b71b07f2016-03-12 12:02:06 +080014
15# Required by hwloc scripts
Hisham Muhammadec17b702011-09-24 00:30:47 +000016AC_CANONICAL_TARGET
17
18AM_INIT_AUTOMAKE([1.11])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000019
Hisham Muhammad300af4b2014-11-19 23:17:16 -020020# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010021
22
23# ----------------------------------------------------------------------
24# Checks for platform.
25# ----------------------------------------------------------------------
26
27case "$target_os" in
28linux*|gnu*)
29 my_htop_platform=linux
30 AC_DEFINE([HTOP_LINUX], [], [Building for Linux.])
31 ;;
32freebsd*|kfreebsd*)
33 my_htop_platform=freebsd
34 AC_DEFINE([HTOP_FREEBSD], [], [Building for FreeBSD.])
35 ;;
36openbsd*)
37 my_htop_platform=openbsd
38 AC_DEFINE([HTOP_OPENBSD], [], [Building for OpenBSD.])
39 ;;
40dragonfly*)
41 my_htop_platform=dragonflybsd
42 AC_DEFINE([HTOP_DRAGONFLYBSD], [], [Building for DragonFlyBSD.])
43 ;;
44darwin*)
45 my_htop_platform=darwin
46 AC_DEFINE([HTOP_DARWIN], [], [Building for Darwin.])
47 ;;
48solaris*)
49 my_htop_platform=solaris
50 AC_DEFINE([HTOP_SOLARIS], [], [Building for Solaris.])
51 ;;
52*)
53 my_htop_platform=unsupported
54 AC_DEFINE([HTOP_UNSUPPORTED], [], [Building for an unsupported platform.])
55 ;;
56esac
Hisham Muhammad4df76d12008-03-05 09:46:47 +000057
Explorer09b71b07f2016-03-12 12:02:06 +080058# Required by hwloc scripts
59AC_USE_SYSTEM_EXTENSIONS
60
Hisham Muhammadeb229d92014-11-24 18:55:03 -020061# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -020062
Christian Göttschef3623b72021-01-22 19:14:50 +010063
Hisham Muhammad300af4b2014-11-19 23:17:16 -020064# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +010065# Checks for compiler.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020066# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000067
Christian Göttschef3623b72021-01-22 19:14:50 +010068AC_PROG_CC
69AM_PROG_CC_C_O
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000070
Hisham Muhammad4df76d12008-03-05 09:46:47 +000071save_cflags="${CFLAGS}"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000072CFLAGS="${CFLAGS} -std=c99"
Christian Göttschef4602f72020-09-08 14:25:46 +020073AC_MSG_CHECKING([whether cc -std=c99 option works])
Explorer09f0df28a2016-03-12 11:58:30 +080074AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
75 [AC_INCLUDES_DEFAULT], [[char *a; a = strdup("foo"); int i = 0; i++; // C99]])],
76 [AC_MSG_RESULT([yes])],
Christian Göttschef4602f72020-09-08 14:25:46 +020077 [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])])
Hisham Muhammad4df76d12008-03-05 09:46:47 +000078CFLAGS="$save_cflags"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000079
Christian Göttschef3623b72021-01-22 19:14:50 +010080# ----------------------------------------------------------------------
81
82
83# ----------------------------------------------------------------------
84# Checks for generic header files.
85# ----------------------------------------------------------------------
86
87AC_HEADER_DIRENT
88AC_HEADER_STDC
89AC_CHECK_HEADERS([ \
90 stdlib.h \
91 string.h \
92 strings.h \
93 sys/param.h \
94 sys/time.h \
95 unistd.h
96 ], [], [missing_headers="$missing_headers $ac_header"])
97
98AC_HEADER_MAJOR
99dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
100dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
101dnl been updated in Autoconf 2.69, so use a workaround:
102m4_version_prereq([2.70], [],
103[if test "x$ac_cv_header_sys_mkdev_h" != xyes; then
104 AC_CHECK_HEADER([sys/sysmacros.h], [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
105 [Define to 1 if `major', `minor', and `makedev' are declared in <sys/sysmacros.h>.])])
106fi])
107
108# Optional Section
109
110AC_CHECK_HEADERS([execinfo.h])
111
112if test "$my_htop_platform" = darwin; then
113 AC_CHECK_HEADERS([mach/mach_time.h])
114fi
115
116# ----------------------------------------------------------------------
117
118
119# ----------------------------------------------------------------------
120# Checks for typedefs, structures, and compiler characteristics.
121# ----------------------------------------------------------------------
122
123AC_HEADER_STDBOOL
124AC_C_CONST
125AC_TYPE_PID_T
126AC_TYPE_UID_T
127AC_TYPE_UINT8_T
128AC_TYPE_UINT16_T
129AC_TYPE_UINT32_T
130AC_TYPE_UINT64_T
131
132# ----------------------------------------------------------------------
133
134
135# ----------------------------------------------------------------------
136# Checks for generic library functions.
137# ----------------------------------------------------------------------
138
139AC_FUNC_CLOSEDIR_VOID
140AC_FUNC_STAT
141
142AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
143
144if test "$my_htop_platform" = dragonflybsd; then
145 AC_SEARCH_LIBS([kvm_open], [kvm], [], [missing_libraries="$missing_libraries libkvm"])
146fi
147
148if test "$my_htop_platform" = freebsd; then
149 AC_SEARCH_LIBS([kvm_open], [kvm], [], [missing_libraries="$missing_libraries libkvm"])
150 AC_SEARCH_LIBS([devstat_checkversion], [devstat], [], [missing_libraries="$missing_libraries libdevstat"])
151fi
152
153if test "$my_htop_platform" = linux; then
154 AC_SEARCH_LIBS([dlopen], [dl dld], [], [missing_libraries="$missing_libraries libdl/libdld"])
155fi
156
157if test "$my_htop_platform" = openbsd; then
158 AC_SEARCH_LIBS([kvm_open], [kvm], [], [missing_libraries="$missing_libraries libkvm"])
159fi
160
161if test "$my_htop_platform" = solaris; then
162 AC_SEARCH_LIBS([kstat_open], [kstat], [], [missing_libraries="$missing_libraries libkstat"])
163 AC_SEARCH_LIBS([Pgrab_error], [proc], [], [missing_libraries="$missing_libraries libproc"])
164 AC_SEARCH_LIBS([free], [malloc], [], [missing_libraries="$missing_libraries libmalloc"])
165fi
166
167# Optional Section
168
169AC_SEARCH_LIBS([clock_gettime], [rt])
170
171AC_CHECK_FUNCS([ \
172 clock_gettime \
173 faccessat \
174 fstatat \
175 host_get_clock_service \
176 openat \
177 readlinkat \
178 ])
179
Christian Göttsche1d008932020-10-15 21:12:57 +0200180# Add -lexecinfo if needed
181AC_SEARCH_LIBS([backtrace], [execinfo])
182
Christian Göttschef3623b72021-01-22 19:14:50 +0100183if test "$my_htop_platform" = darwin; then
184 AC_CHECK_FUNCS([mach_timebase_info])
185fi
Christian Goettschec2fdfd92020-10-21 17:06:32 +0200186
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200187# ----------------------------------------------------------------------
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200188
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000189
Christian Göttschef3623b72021-01-22 19:14:50 +0100190# ----------------------------------------------------------------------
191# Checks for cross-platform features and flags.
192# ----------------------------------------------------------------------
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000193
Hisham Muhammaddb682862015-12-09 17:17:30 -0200194# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
195m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200196[
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300197 if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
198 # to be used to set the path to ncurses*-config when cross-compiling
Michael Kleinbc5d4692018-02-26 14:19:01 +0100199 htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
200 htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300201 else
Michael Kleinbc5d4692018-02-26 14:19:01 +0100202 htop_config_script_libs=$([$4] --libs 2> /dev/null)
203 htop_config_script_cflags=$([$4] --cflags 2> /dev/null)
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300204 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200205 htop_script_success=no
206 htop_save_LDFLAGS="$LDFLAGS"
Michael Kleinbc5d4692018-02-26 14:19:01 +0100207 htop_save_CFLAGS="$CFLAGS"
208 if test ! "x$htop_config_script_libs" = x; then
209 LDFLAGS="$htop_config_script_libs $LDFLAGS"
210 CFLAGS="$htop_config_script_cflags $CFLAGS"
Hisham Muhammaddb682862015-12-09 17:17:30 -0200211 AC_CHECK_LIB([$1], [$2], [
212 AC_DEFINE([$3], 1, [The library is present.])
Michael Kleinbc5d4692018-02-26 14:19:01 +0100213 LIBS="$htop_config_script_libs $LIBS "
Hisham Muhammaddb682862015-12-09 17:17:30 -0200214 htop_script_success=yes
Michael Kleinbc5d4692018-02-26 14:19:01 +0100215 ], [
Benny Baumann880eeca2020-12-12 19:49:52 +0100216 CFLAGS="$htop_save_CFLAGS"
Michael Kleinbc5d4692018-02-26 14:19:01 +0100217 ])
Hisham Muhammaddf9922a2018-02-17 14:50:55 -0200218 LDFLAGS="$htop_save_LDFLAGS"
Hisham Muhammadc2377022015-12-06 19:06:23 -0200219 fi
Hisham Muhammadcccc18d2015-12-09 17:34:57 -0200220 if test "x$htop_script_success" = xno; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200221 [$5]
222 fi
223])
224
225# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
226m4_define([HTOP_CHECK_LIB],
227[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200228 AC_CHECK_LIB([$1], [$2], [
229 AC_DEFINE([$3], 1, [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200230 LIBS="-l[$1] $LIBS "
231 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200232])
233
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100234AC_ARG_ENABLE([unicode],
235 [AS_HELP_STRING([--enable-unicode],
236 [enable Unicode support @<:@default=yes@:>@])],
237 [],
238 [enable_unicode=yes])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000239if test "x$enable_unicode" = xyes; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200240 HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200241 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
242 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw5-config",
243 HTOP_CHECK_SCRIPT([ncurses], [addnwstr], [HAVE_LIBNCURSESW], "ncurses5-config",
244 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
245 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
246 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
Benny Baumann880eeca2020-12-12 19:49:52 +0100247 missing_libraries="$missing_libraries libncursesw"
248 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200249 )))))))
Hisham Muhammaddb682862015-12-09 17:17:30 -0200250
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000251 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000252 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
253 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
254 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100255
256 # check if additional linker flags are needed for keypad(3)
257 # (at this point we already link against a working ncurses library with wide character support)
258 AC_SEARCH_LIBS([keypad], [tinfow tinfo])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000259else
Hisham Muhammaddb682862015-12-09 17:17:30 -0200260 HTOP_CHECK_SCRIPT([ncurses6], [refresh], [HAVE_LIBNCURSES], "ncurses6-config",
261 HTOP_CHECK_SCRIPT([ncurses], [refresh], [HAVE_LIBNCURSES], "ncurses5-config",
262 HTOP_CHECK_LIB([ncurses6], [refresh], [HAVE_LIBNCURSES],
263 HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES],
264 missing_libraries="$missing_libraries libncurses"
265 ))))
Christian Göttscheb92f62f2020-08-21 10:37:33 +0200266
Hisham Muhammada0810562013-02-26 17:10:11 +0000267 AC_CHECK_HEADERS([curses.h],[:],
268 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
269 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
270 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Christian Göttscheead978b2020-12-07 15:30:56 +0100271
272 # check if additional linker flags are needed for keypad(3)
273 # (at this point we already link against a working ncurses library)
274 AC_SEARCH_LIBS([keypad], [tinfo])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000275fi
276
gmbroome697f5bb2018-03-02 16:20:46 -0500277
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100278AC_ARG_ENABLE([hwloc],
279 [AS_HELP_STRING([--enable-hwloc],
280 [enable hwloc support for CPU affinity; disables Linux affinity; requires libhwloc @<:@default=no@:>@])],
281 [],
282 [enable_hwloc=no])
283case "$enable_hwloc" in
284 no)
285 ;;
286 yes)
287 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
288 AC_CHECK_HEADERS([hwloc.h], [], [missing_headers="$missing_headers $ac_header"])
289 ;;
290 *)
291 AC_MSG_ERROR([bad value '$enable_hwloc' for --enable-hwloc])
292 ;;
293esac
Christian Göttsche005c4d12020-09-08 16:25:22 +0200294
Christian Göttschef3623b72021-01-22 19:14:50 +0100295
296AC_ARG_ENABLE([setuid],
297 [AS_HELP_STRING([--enable-setuid],
298 [enable setuid support for privilege dropping @<:@default=no@:>@])],
299 [],
300 [enable_setuid=no])
301if test "x$enable_setuid" = xyes; then
302 AC_DEFINE([HAVE_SETUID_ENABLED], [1], [Define if setuid support should be enabled.])
303fi
304
305# ----------------------------------------------------------------------
306
307
308# ----------------------------------------------------------------------
309# Checks for Linux features and flags.
310# ----------------------------------------------------------------------
311
312AC_ARG_WITH([proc],
313 [AS_HELP_STRING([--with-proc=DIR],
314 [location of a Linux-compatible proc filesystem @<:@default=/proc@:>@])],
315 [],
316 [with_proc=/proc])
317if test -z "$with_proc"; then
318 AC_MSG_ERROR([bad empty value for --with-proc option])
319fi
320AC_DEFINE_UNQUOTED([PROCDIR], ["$with_proc"], [Path of proc filesystem.])
321
322
323AC_ARG_ENABLE([openvz],
324 [AS_HELP_STRING([--enable-openvz],
325 [enable OpenVZ support @<:@default=no@:>@])],
326 [],
327 [enable_openvz=no])
328if test "x$enable_openvz" = xyes; then
329 AC_DEFINE([HAVE_OPENVZ], [1], [Define if openvz support enabled.])
330fi
331
332
333AC_ARG_ENABLE([vserver],
334 [AS_HELP_STRING([--enable-vserver],
335 [enable VServer support @<:@default=no@:>@])],
336 [],
337 [enable_vserver=no])
338if test "x$enable_vserver" = xyes; then
339 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
340fi
341
342
343AC_ARG_ENABLE([ancient_vserver],
344 [AS_HELP_STRING([--enable-ancient-vserver],
345 [enable ancient VServer support (implies --enable-vserver) @<:@default=no@:>@])],
346 [],
347 [enable_ancient_vserver=no])
348if test "x$enable_ancient_vserver" = xyes; then
349 AC_DEFINE([HAVE_VSERVER], [1], [Define if VServer support enabled.])
350 AC_DEFINE([HAVE_ANCIENT_VSERVER], [1], [Define if ancient vserver support enabled.])
351fi
352
353
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100354AC_ARG_ENABLE([linux_affinity],
355 [AS_HELP_STRING([--enable-linux-affinity],
356 [enable Linux sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
357 [],
358 [enable_linux_affinity=check])
Christian Göttsche005c4d12020-09-08 16:25:22 +0200359if test "x$enable_linux_affinity" = xcheck; then
360 if test "x$enable_hwloc" = xyes; then
361 enable_linux_affinity=no
362 else
363 AC_MSG_CHECKING([for usable sched_setaffinity])
364 AC_RUN_IFELSE([
365 AC_LANG_PROGRAM([[
366 #include <sched.h>
367 #include <errno.h>
368 static cpu_set_t cpuset;
369 ]], [[
370 CPU_ZERO(&cpuset);
371 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
372 if (errno == ENOSYS) return 1;
373 ]])],
374 [enable_linux_affinity=yes
Benny Baumann880eeca2020-12-12 19:49:52 +0100375 AC_MSG_RESULT([yes])],
Christian Göttsche005c4d12020-09-08 16:25:22 +0200376 [enable_linux_affinity=no
Benny Baumann880eeca2020-12-12 19:49:52 +0100377 AC_MSG_RESULT([no])],
Christian Göttsche005c4d12020-09-08 16:25:22 +0200378 [AC_MSG_RESULT([yes (assumed while cross compiling)])])
379 fi
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000380fi
Hisham474d26c2016-02-14 19:57:29 -0200381if test "x$enable_linux_affinity" = xyes; then
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100382 if test "x$enable_hwloc" = xyes; then
383 AC_MSG_ERROR([--enable-hwloc and --enable-linux-affinity are mutual exclusive. Specify at most one of them.])
384 fi
385 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 +0000386fi
387
Hisham Muhammad543d65c2017-07-26 15:40:55 -0300388
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100389AC_ARG_ENABLE([capabilities],
390 [AS_HELP_STRING([--enable-capabilities],
391 [enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
392 [],
393 [enable_capabilities=check])
394case "$enable_capabilities" in
395 no)
396 ;;
397 check)
398 enable_capabilities=yes
399 AC_CHECK_LIB([cap], [cap_init], [], [enable_capabilities=no])
400 AC_CHECK_HEADERS([sys/capability.h], [], [enable_capabilities=no])
401 ;;
402 yes)
403 AC_CHECK_LIB([cap], [cap_init], [], [missing_libraries="$missing_libraries libcap"])
404 AC_CHECK_HEADERS([sys/capability.h], [], [missing_headers="$missing_headers $ac_header"])
405 ;;
406 *)
407 AC_MSG_ERROR([bad value '$enable_capabilities' for --enable-capabilities])
408 ;;
409esac
Christian Göttschef4404ef2020-09-02 14:39:25 +0200410
Christian Göttschef3623b72021-01-22 19:14:50 +0100411
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100412AC_ARG_ENABLE([delayacct],
413 [AS_HELP_STRING([--enable-delayacct],
414 [enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@default=check@:>@])],
415 [],
416 [enable_delayacct=check])
417case "$enable_delayacct" in
418 no)
419 ;;
420 check)
421 m4_ifdef([PKG_PROG_PKG_CONFIG], [
422 enable_delayacct=yes
423 PKG_PROG_PKG_CONFIG()
424 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [enable_delayacct=no])
425 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [enable_delayacct=no])
426 if test "$enable_delayacct" = yes; then
427 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
428 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
429 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
430 fi
431 ], [
432 enable_delayacct=no
433 AC_MSG_NOTICE([Linux delay accounting support can not be enabled, cause pkg-config is required for checking its availability])
434 ])
435 ;;
436 yes)
437 m4_ifdef([PKG_PROG_PKG_CONFIG], [
438 PKG_PROG_PKG_CONFIG()
439 PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"])
440 PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"])
441 CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
442 LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
443 AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.])
444 ], [
445 pkg_m4_absent=1
446 m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.])
447 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.])
448 ])
449 ;;
450 *)
451 AC_MSG_ERROR([bad value '$enable_delayacct' for --enable-delayacct])
452 ;;
453esac
André Carvalhob7b66b72017-12-04 00:15:29 -0200454
Christian Göttschef3623b72021-01-22 19:14:50 +0100455
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100456AC_ARG_ENABLE([sensors],
457 [AS_HELP_STRING([--enable-sensors],
458 [enable libsensors support for reading temperature data; requires only libsensors headers at compile time, at runtime libsensors is loaded via dlopen @<:@default=check@:>@])],
459 [],
460 [enable_sensors=check])
461case "$enable_sensors" in
462 no)
463 ;;
464 check)
465 enable_sensors=yes
466 AC_CHECK_HEADERS([sensors/sensors.h], [], [enable_sensors=no])
467 ;;
468 yes)
469 AC_CHECK_HEADERS([sensors/sensors.h], [], [missing_headers="$missing_headers $ac_header"])
470 ;;
471 *)
472 AC_MSG_ERROR([bad value '$enable_sensors' for --enable-sensors])
473 ;;
474esac
475
Christian Göttschef3623b72021-01-22 19:14:50 +0100476# ----------------------------------------------------------------------
477
478
479# ----------------------------------------------------------------------
480# Checks for compiler warnings.
481# ----------------------------------------------------------------------
Christian Göttsche1b225cd2020-09-10 19:56:33 +0200482
Christian Göttschef4602f72020-09-08 14:25:46 +0200483AM_CFLAGS="\
484 -Wall\
485 -Wcast-align\
Christian Göttschedb472072020-10-04 14:30:35 +0200486 -Wcast-qual\
Christian Göttschef4602f72020-09-08 14:25:46 +0200487 -Wextra\
Benny Baumannba0fca12020-09-18 16:58:03 +0200488 -Wfloat-equal\
Christian Göttschec150e4b2020-12-18 15:49:37 +0100489 -Wformat=2\
Christian Göttsche4dadbe32021-01-21 19:49:07 +0100490 -Winit-self\
Christian Göttschef4602f72020-09-08 14:25:46 +0200491 -Wmissing-format-attribute\
492 -Wmissing-noreturn\
Christian Göttsche4e282eb2020-09-25 14:03:55 +0200493 -Wmissing-prototypes\
Christian Göttschef4602f72020-09-08 14:25:46 +0200494 -Wpointer-arith\
495 -Wshadow\
496 -Wstrict-prototypes\
497 -Wundef\
498 -Wunused\
499 -Wwrite-strings"
500
Christian Göttschef3623b72021-01-22 19:14:50 +0100501dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
502AC_DEFUN([AX_CHECK_COMPILE_FLAG],
503[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
504AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
505AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
506 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
507 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
508 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
509 [AS_VAR_SET(CACHEVAR,[yes])],
510 [AS_VAR_SET(CACHEVAR,[no])])
511 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
512AS_VAR_IF(CACHEVAR,yes,
513 [m4_default([$2], :)],
514 [m4_default([$3], :)])
515AS_VAR_POPDEF([CACHEVAR])dnl
516])dnl AX_CHECK_COMPILE_FLAGS
517
Benny Baumann2cde4a72020-09-18 19:32:41 +0200518AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
519
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100520AC_ARG_ENABLE([werror],
521 [AS_HELP_STRING([--enable-werror],
522 [Treat warnings as errors @<:@default=no@:>@])],
523 [],
524 [enable_werror=no])
525if test "x$enable_werror" = xyes; then
526 AM_CFLAGS="$AM_CFLAGS -Werror"
527fi
528
529AC_ARG_ENABLE([debug],
530 [AS_HELP_STRING([--enable-debug],
531 [Enable asserts and internal sanity checks @<:@default=no@:>@])],
532 [],
533 [enable_debug=no])
534if test "x$enable_debug" != xyes; then
535 AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
536fi
Christian Göttscheb7f63292020-09-17 22:23:05 +0200537
Christian Göttschef3623b72021-01-22 19:14:50 +0100538
Christian Göttsche57254cd2020-08-21 10:37:20 +0200539AC_SUBST([AM_CFLAGS])
Christian Göttscheb7f63292020-09-17 22:23:05 +0200540AC_SUBST([AM_CPPFLAGS])
541
Christian Göttschef3623b72021-01-22 19:14:50 +0100542# ----------------------------------------------------------------------
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100543
Christian Göttschef3623b72021-01-22 19:14:50 +0100544
545# ----------------------------------------------------------------------
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200546# Bail out on errors.
547# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100548
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200549if test ! -z "$missing_libraries"; then
Benny Baumann880eeca2020-12-12 19:49:52 +0100550 AC_MSG_ERROR([missing libraries: $missing_libraries])
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200551fi
552if test ! -z "$missing_headers"; then
Benny Baumann880eeca2020-12-12 19:49:52 +0100553 AC_MSG_ERROR([missing headers: $missing_headers])
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200554fi
555
Christian Göttschef3623b72021-01-22 19:14:50 +0100556# ----------------------------------------------------------------------
Hisham Muhammad3383d8e2015-01-21 23:27:31 -0200557
Christian Göttschef3623b72021-01-22 19:14:50 +0100558
559# ----------------------------------------------------------------------
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200560# We're done, let's go!
561# ----------------------------------------------------------------------
Christian Göttschef3623b72021-01-22 19:14:50 +0100562
563AC_DEFINE_UNQUOTED([COPYRIGHT], ["(C) 2004-2019 Hisham Muhammad. (C) 2020-2021 htop dev team."], [Copyright message.])
564
Hisham Muhammada75161f2014-11-24 20:11:33 -0200565AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200566AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200567AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400568AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500569AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
gmbroome697f5bb2018-03-02 16:20:46 -0500570AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200571AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200572AC_SUBST(my_htop_platform)
Daniel Langee1722822020-08-24 21:37:28 +0200573AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000574AC_OUTPUT
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300575
Christian Göttschef3623b72021-01-22 19:14:50 +0100576if test "$my_htop_platform" = unsupported; then
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300577 echo ""
578 echo "****************************************************************"
579 echo "WARNING! This platform is not currently supported by htop."
580 echo ""
581 echo "The code will build, but it will produce a dummy version of htop"
582 echo "which shows no processes, using the files from the unsupported/"
583 echo "directory. This is meant to be a skeleton, to be used as a"
584 echo "starting point if you are porting htop to a new platform."
585 echo "****************************************************************"
586 echo ""
587fi
Christian Göttsche3b084db2020-08-28 12:10:31 +0200588
589AC_MSG_RESULT([
590 ${PACKAGE_NAME} ${VERSION}
591
Christian Göttscheffd90c22020-10-05 12:29:31 +0200592 platform: $my_htop_platform
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100593 (Linux) proc directory: $with_proc
Christian Göttscheffd90c22020-10-05 12:29:31 +0200594 (Linux) openvz: $enable_openvz
Christian Göttscheffd90c22020-10-05 12:29:31 +0200595 (Linux) vserver: $enable_vserver
596 (Linux) ancient vserver: $enable_ancient_vserver
Christian Göttscheffd90c22020-10-05 12:29:31 +0200597 (Linux) affinity: $enable_linux_affinity
598 (Linux) delay accounting: $enable_delayacct
Christian Göttsche5e103ff2021-01-22 19:14:46 +0100599 (Linux) sensors: $enable_sensors
600 (Linux) capabilities: $enable_capabilities
Christian Göttscheffd90c22020-10-05 12:29:31 +0200601 unicode: $enable_unicode
Daniel Lange309f1d72020-11-16 13:29:37 +0100602 hwloc: $enable_hwloc
Christian Göttscheffd90c22020-10-05 12:29:31 +0200603 setuid: $enable_setuid
Daniel Langea8a723f2020-11-16 17:01:51 +0100604 debug: $enable_debug
Christian Göttsche3b084db2020-08-28 12:10:31 +0200605])