blob: 225c6d856d6595307f5b803668d22000e10542a6 [file] [log] [blame]
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
Hisham Muhammadec17b702011-09-24 00:30:47 +00004AC_PREREQ(2.65)
Hisham96157872016-09-11 23:28:17 -03005LT_PREREQ([2.4.0])
Hisham81552d42016-07-21 16:54:41 -03006AC_INIT([htop],[2.0.2],[hisham@gobolinux.org])
Hisham Muhammadec17b702011-09-24 00:30:47 +00007
Hishamc37be402016-05-04 15:34:49 -03008SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
9year=$(date -u -d "@$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u "+%Y")
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])
14AC_CONFIG_MACRO_DIR([m4])
15
16# Required by hwloc scripts
Hisham Muhammadec17b702011-09-24 00:30:47 +000017AC_CANONICAL_TARGET
18
19AM_INIT_AUTOMAKE([1.11])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000020
21# Checks for programs.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020022# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000023AC_PROG_CC
Hisham Muhammad4df76d12008-03-05 09:46:47 +000024AM_PROG_CC_C_O
25
Explorer09b71b07f2016-03-12 12:02:06 +080026# Required by hwloc scripts
27AC_USE_SYSTEM_EXTENSIONS
28
Diederik de Grootb258d6e2017-04-19 16:12:17 +020029#LT_INIT([disable-shared static])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000030
Hisham Muhammadeb229d92014-11-24 18:55:03 -020031# Checks for platform.
32# ----------------------------------------------------------------------
James Clarkea9508272016-04-18 23:55:55 +010033case "$target_os" in
James Clarke2de52862016-04-18 23:57:30 +010034linux*|gnu*)
Hisham Muhammadeb229d92014-11-24 18:55:03 -020035 my_htop_platform=linux
36 ;;
James Clarkea9508272016-04-18 23:55:55 +010037freebsd*|kfreebsd*)
Hisham Muhammad8915b292014-11-27 16:27:34 -020038 my_htop_platform=freebsd
39 ;;
James Clarkea9508272016-04-18 23:55:55 +010040openbsd*)
Michael McConvillea9a5a532015-09-18 00:46:48 -040041 my_htop_platform=openbsd
42 ;;
Diederik de Grootb258d6e2017-04-19 16:12:17 +020043dragonfly*)
44 my_htop_platform=dragonflybsd
45 ;;
James Clarkea9508272016-04-18 23:55:55 +010046darwin*)
David Hunt70e7c8d2015-07-12 13:47:43 -050047 my_htop_platform=darwin
48 ;;
Hisham Muhammadeb229d92014-11-24 18:55:03 -020049*)
50 my_htop_platform=unsupported
51 ;;
52esac
Hisham Muhammadeb229d92014-11-24 18:55:03 -020053
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000054# Checks for libraries.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020055# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000056AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
57
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000058# Checks for header files.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020059# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000060AC_HEADER_DIRENT
61AC_HEADER_STDC
Hisham Muhammada0810562013-02-26 17:10:11 +000062AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
Hisham Muhammade46f1422006-07-12 01:15:14 +000063 missing_headers="$missing_headers $ac_header"
64])
Hisham Muhammad36ef1a92010-12-05 15:43:56 +000065AC_CHECK_HEADERS([execinfo.h],[:],[:])
Hisham Muhammade46f1422006-07-12 01:15:14 +000066
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000067# Checks for typedefs, structures, and compiler characteristics.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020068# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000069AC_HEADER_STDBOOL
70AC_C_CONST
71AC_TYPE_PID_T
72AC_TYPE_UID_T
73
Hisham Muhammad300af4b2014-11-19 23:17:16 -020074# Checks for library functions and compiler features.
75# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000076AC_FUNC_CLOSEDIR_VOID
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000077AC_TYPE_SIGNAL
78AC_FUNC_STAT
79AC_CHECK_FUNCS([memmove strncasecmp strstr strdup])
80
Hisham Muhammad4df76d12008-03-05 09:46:47 +000081save_cflags="${CFLAGS}"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000082CFLAGS="${CFLAGS} -std=c99"
83AC_MSG_CHECKING([whether gcc -std=c99 option works])
Explorer09f0df28a2016-03-12 11:58:30 +080084AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
85 [AC_INCLUDES_DEFAULT], [[char *a; a = strdup("foo"); int i = 0; i++; // C99]])],
86 [AC_MSG_RESULT([yes])],
87 [AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.])])
Hisham Muhammad4df76d12008-03-05 09:46:47 +000088CFLAGS="$save_cflags"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000089
Hisham Muhammadaed9b9d2015-02-04 12:19:04 -020090save_cflags="${CFLAGS}"
91CFLAGS="$CFLAGS -Wextra"
92AC_MSG_CHECKING([if compiler supports -Wextra])
Explorer09f0df28a2016-03-12 11:58:30 +080093AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],[
Hisham Muhammadaed9b9d2015-02-04 12:19:04 -020094 wextra_flag=-Wextra
95 AC_MSG_RESULT([yes])
96],[
97 wextra_flag=
98 AC_MSG_RESULT([no])
99])
100CFLAGS="$save_cflags"
101AC_SUBST(wextra_flag)
102
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200103# Checks for features and flags.
104# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000105PROCDIR=/proc
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200106
Explorer09f0df28a2016-03-12 11:58:30 +0800107AC_ARG_ENABLE(proc, [AS_HELP_STRING([--enable-proc], [use Linux-compatible proc filesystem])], enable_proc="yes", enable_proc="no")
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200108if test "x$enable_proc" = xyes; then
Hisham Muhammada75161f2014-11-24 20:11:33 -0200109 # An enabled proc assumes we're emulating Linux.
110 my_htop_platform=linux
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200111 AC_DEFINE(HAVE_PROC, 1, [Define if using a Linux-compatible proc filesystem.])
112fi
113
Explorer09f0df28a2016-03-12 11:58:30 +0800114AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])],
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000115
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200116if test -n "$withval"; then
117 AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
118 PROCDIR="$withval"
119fi,
120AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000121
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200122if test "x$cross_compiling" = xno; then
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200123 if test "x$enable_proc" = xyes; then
124 AC_CHECK_FILE($PROCDIR/stat,,AC_MSG_ERROR(Cannot find $PROCDIR/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))
125 AC_CHECK_FILE($PROCDIR/meminfo,,AC_MSG_ERROR(Cannot find $PROCDIR/meminfo. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))
126 fi
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200127fi
128
Explorer09f0df28a2016-03-12 11:58:30 +0800129AC_ARG_ENABLE(openvz, [AS_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no")
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000130if test "x$enable_openvz" = xyes; then
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000131 AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
132fi
133
Explorer09f0df28a2016-03-12 11:58:30 +0800134AC_ARG_ENABLE(cgroup, [AS_HELP_STRING([--enable-cgroup], [enable cgroups support])], ,enable_cgroup="no")
Hisham Muhammad84ed4c02010-10-30 19:24:07 +0000135if test "x$enable_cgroup" = xyes; then
136 AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.])
137fi
138
Explorer09f0df28a2016-03-12 11:58:30 +0800139AC_ARG_ENABLE(vserver, [AS_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no")
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000140if test "x$enable_vserver" = xyes; then
141 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
142fi
143
Explorer09f0df28a2016-03-12 11:58:30 +0800144AC_ARG_ENABLE(ancient_vserver, [AS_HELP_STRING([--enable-ancient-vserver], [enable ancient VServer support (implies --enable-vserver)])], ,enable_ancient_vserver="no")
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000145if test "x$enable_ancient_vserver" = xyes; then
146 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
147 AC_DEFINE(HAVE_ANCIENT_VSERVER, 1, [Define if ancient vserver support enabled.])
148fi
149
Explorer09f0df28a2016-03-12 11:58:30 +0800150AC_ARG_ENABLE(taskstats, [AS_HELP_STRING([--enable-taskstats], [enable per-task IO Stats (taskstats kernel sup required)])], ,enable_taskstats="yes")
Hisham Muhammad12f4f092008-03-09 08:02:22 +0000151if test "x$enable_taskstats" = xyes; then
152 AC_DEFINE(HAVE_TASKSTATS, 1, [Define if taskstats support enabled.])
153fi
154
Hisham Muhammaddb682862015-12-09 17:17:30 -0200155# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
156m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200157[
Ricardo Martincoski78b82d02016-07-11 20:12:07 -0300158 if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
159 # to be used to set the path to ncurses*-config when cross-compiling
160 htop_config_script=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
161 else
162 htop_config_script=$([$4] --libs 2> /dev/null)
163 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200164 htop_script_success=no
165 htop_save_LDFLAGS="$LDFLAGS"
166 if test ! "x$htop_config_script" = x; then
167 LDFLAGS="$htop_config_script $LDFLAGS"
168 AC_CHECK_LIB([$1], [$2], [
169 AC_DEFINE([$3], 1, [The library is present.])
170 LIBS="$htop_config_script $LIBS "
171 htop_script_success=yes
172 ], [])
173 LDFLAGS="$save_LDFLAGS"
Hisham Muhammadc2377022015-12-06 19:06:23 -0200174 fi
Hisham Muhammadcccc18d2015-12-09 17:34:57 -0200175 if test "x$htop_script_success" = xno; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200176 [$5]
177 fi
178])
179
180# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
181m4_define([HTOP_CHECK_LIB],
182[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200183 AC_CHECK_LIB([$1], [$2], [
184 AC_DEFINE([$3], 1, [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200185 LIBS="-l[$1] $LIBS "
186 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200187])
188
Explorer09f0df28a2016-03-12 11:58:30 +0800189AC_ARG_ENABLE(unicode, [AS_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000190if test "x$enable_unicode" = xyes; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200191 HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200192 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
193 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw5-config",
194 HTOP_CHECK_SCRIPT([ncurses], [addnwstr], [HAVE_LIBNCURSESW], "ncurses5-config",
195 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
196 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
197 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
198 missing_libraries="$missing_libraries libncursesw"
199 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
200 )))))))
Hisham Muhammaddb682862015-12-09 17:17:30 -0200201
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000202 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000203 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
204 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
205 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000206else
Hisham Muhammaddb682862015-12-09 17:17:30 -0200207 HTOP_CHECK_SCRIPT([ncurses6], [refresh], [HAVE_LIBNCURSES], "ncurses6-config",
208 HTOP_CHECK_SCRIPT([ncurses], [refresh], [HAVE_LIBNCURSES], "ncurses5-config",
209 HTOP_CHECK_LIB([ncurses6], [refresh], [HAVE_LIBNCURSES],
210 HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES],
211 missing_libraries="$missing_libraries libncurses"
212 ))))
213
Hisham Muhammada0810562013-02-26 17:10:11 +0000214 AC_CHECK_HEADERS([curses.h],[:],
215 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
216 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
217 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000218fi
219
Hisham Muhammad0aa485c2014-11-27 18:31:39 -0200220if test "$my_htop_platform" = "freebsd"; then
221 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
222fi
223
Michael McConvillea9a5a532015-09-18 00:46:48 -0400224if test "$my_htop_platform" = "openbsd"; then
225 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
226fi
227
Explorer09f0df28a2016-03-12 11:58:30 +0800228AC_ARG_ENABLE(linux_affinity, [AS_HELP_STRING([--enable-linux-affinity], [enable Linux sched_setaffinity and sched_getaffinity for affinity support, disables hwloc])], ,enable_linux_affinity="yes")
Hisham474d26c2016-02-14 19:57:29 -0200229if test "x$enable_linux_affinity" = xyes -a "x$cross_compiling" = xno; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000230 AC_MSG_CHECKING([for usable sched_setaffinity])
231 AC_RUN_IFELSE([
232 AC_LANG_PROGRAM([[
233 #include <sched.h>
234 #include <errno.h>
235 static cpu_set_t cpuset;
236 ]], [[
237 CPU_ZERO(&cpuset);
238 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
239 if (errno == ENOSYS) return 1;
240 ]])],
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000241 [AC_MSG_RESULT([yes])],
Hisham474d26c2016-02-14 19:57:29 -0200242 [enable_linux_affinity=no
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000243 AC_MSG_RESULT([no])])
244fi
Hisham474d26c2016-02-14 19:57:29 -0200245if test "x$enable_linux_affinity" = xyes; then
246 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 +0000247fi
248
Explorer09f0df28a2016-03-12 11:58:30 +0800249AC_ARG_ENABLE(hwloc, [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
Hisham Muhammadec17b702011-09-24 00:30:47 +0000250if test "x$enable_hwloc" = xyes
Hisham Muhammad9604e022010-11-22 12:24:46 +0000251then
Hisham474d26c2016-02-14 19:57:29 -0200252 AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000253 AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000254fi
255
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200256# Bail out on errors.
257# ----------------------------------------------------------------------
258if test ! -z "$missing_libraries"; then
259 AC_MSG_ERROR([missing libraries: $missing_libraries])
260fi
261if test ! -z "$missing_headers"; then
262 AC_MSG_ERROR([missing headers: $missing_headers])
263fi
264
Hisham Muhammad3383d8e2015-01-21 23:27:31 -0200265AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-$year Hisham Muhammad", [Copyright message.])
266
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200267# We're done, let's go!
268# ----------------------------------------------------------------------
Hisham Muhammada75161f2014-11-24 20:11:33 -0200269AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200270AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Diederik de Grootb258d6e2017-04-19 16:12:17 +0200271AM_CONDITIONAL([HTOP_DRAGONFLYBSD], [test "$my_htop_platform" = dragonflybsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400272AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500273AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200274AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200275AC_SUBST(my_htop_platform)
Hisham Muhammaddd86b9b2009-06-23 14:02:14 +0000276AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000277AC_OUTPUT
Hisham Muhammadc39f18a2017-07-10 20:14:25 -0300278
279if test "$my_htop_platform" = "unsupported"
280then
281 echo ""
282 echo "****************************************************************"
283 echo "WARNING! This platform is not currently supported by htop."
284 echo ""
285 echo "The code will build, but it will produce a dummy version of htop"
286 echo "which shows no processes, using the files from the unsupported/"
287 echo "directory. This is meant to be a skeleton, to be used as a"
288 echo "starting point if you are porting htop to a new platform."
289 echo "****************************************************************"
290 echo ""
291fi