blob: bc586d997b88e5fd161549561c9042dd0d74cd64 [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)
Hisham Muhammad43c3e4d2014-04-24 19:54:35 -03005AC_INIT([htop],[1.0.3],[hisham@gobolinux.org])
Hisham Muhammadec17b702011-09-24 00:30:47 +00006
7# The following two lines are required by hwloc scripts
8AC_USE_SYSTEM_EXTENSIONS
9AC_CANONICAL_TARGET
10
11AM_INIT_AUTOMAKE([1.11])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000012AC_CONFIG_SRCDIR([htop.c])
13AC_CONFIG_HEADER([config.h])
Hisham Muhammad5fd14362010-11-20 18:54:39 +000014AC_CONFIG_MACRO_DIR([m4])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000015
16# Checks for programs.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020017# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000018AC_PROG_CC
Hisham Muhammad4df76d12008-03-05 09:46:47 +000019AM_PROG_CC_C_O
20
Hisham Muhammad5fd14362010-11-20 18:54:39 +000021AC_DISABLE_SHARED
22AC_ENABLE_STATIC
Hisham Muhammad4df76d12008-03-05 09:46:47 +000023AC_PROG_LIBTOOL
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000024
Hisham Muhammadeb229d92014-11-24 18:55:03 -020025# Checks for platform.
26# ----------------------------------------------------------------------
27case "$target" in
28*linux*)
29 my_htop_platform=linux
30 ;;
31*)
32 my_htop_platform=unsupported
33 ;;
34esac
Hisham Muhammadeb229d92014-11-24 18:55:03 -020035
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000036# Checks for libraries.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020037# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000038AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
39
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000040# Checks for header files.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020041# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000042AC_HEADER_DIRENT
43AC_HEADER_STDC
Hisham Muhammada0810562013-02-26 17:10:11 +000044AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
Hisham Muhammade46f1422006-07-12 01:15:14 +000045 missing_headers="$missing_headers $ac_header"
46])
Hisham Muhammad36ef1a92010-12-05 15:43:56 +000047AC_CHECK_HEADERS([execinfo.h],[:],[:])
Hisham Muhammade46f1422006-07-12 01:15:14 +000048
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000049# Checks for typedefs, structures, and compiler characteristics.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020050# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000051AC_HEADER_STDBOOL
52AC_C_CONST
53AC_TYPE_PID_T
54AC_TYPE_UID_T
55
Hisham Muhammad300af4b2014-11-19 23:17:16 -020056# Checks for library functions and compiler features.
57# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000058AC_FUNC_CLOSEDIR_VOID
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000059AC_TYPE_SIGNAL
60AC_FUNC_STAT
61AC_CHECK_FUNCS([memmove strncasecmp strstr strdup])
62
Hisham Muhammad4df76d12008-03-05 09:46:47 +000063save_cflags="${CFLAGS}"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000064CFLAGS="${CFLAGS} -std=c99"
65AC_MSG_CHECKING([whether gcc -std=c99 option works])
66AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [char *a; a = strdup("foo"); int i = 0; i++; // C99],
67 AC_MSG_RESULT([yes]),
68 AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.]))
Hisham Muhammad4df76d12008-03-05 09:46:47 +000069CFLAGS="$save_cflags"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000070
Hisham Muhammad300af4b2014-11-19 23:17:16 -020071# Checks for features and flags.
72# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000073PROCDIR=/proc
Hisham Muhammadeb229d92014-11-24 18:55:03 -020074
75AC_ARG_ENABLE(proc, [AC_HELP_STRING([--enable-proc], [use Linux-compatible proc filesystem])], enable_proc="yes", enable_proc="no")
76if test "x$enable_proc" = xyes; then
Hisham Muhammada75161f2014-11-24 20:11:33 -020077 # An enabled proc assumes we're emulating Linux.
78 my_htop_platform=linux
Hisham Muhammadeb229d92014-11-24 18:55:03 -020079 AC_DEFINE(HAVE_PROC, 1, [Define if using a Linux-compatible proc filesystem.])
80fi
81
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000082AC_ARG_WITH(proc, [ --with-proc=DIR Location of a Linux-compatible proc filesystem (default=/proc).],
83
Hisham Muhammadeb229d92014-11-24 18:55:03 -020084if test -n "$withval"; then
85 AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
86 PROCDIR="$withval"
87fi,
88AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000089
Hisham Muhammad300af4b2014-11-19 23:17:16 -020090if test "x$cross_compiling" = xno; then
Hisham Muhammadeb229d92014-11-24 18:55:03 -020091 if test "x$enable_proc" = xyes; then
92 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.))
93 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.))
94 fi
Hisham Muhammad300af4b2014-11-19 23:17:16 -020095fi
96
Hisham Muhammad4c51ad02007-08-10 05:07:14 +000097AC_ARG_ENABLE(openvz, [AC_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no")
98if test "x$enable_openvz" = xyes; then
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +000099 AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
100fi
101
Hisham Muhammad84ed4c02010-10-30 19:24:07 +0000102AC_ARG_ENABLE(cgroup, [AC_HELP_STRING([--enable-cgroup], [enable cgroups support])], ,enable_cgroup="no")
103if test "x$enable_cgroup" = xyes; then
104 AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.])
105fi
106
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000107AC_ARG_ENABLE(vserver, [AC_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no")
108if test "x$enable_vserver" = xyes; then
109 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
110fi
111
112AC_ARG_ENABLE(ancient_vserver, [AC_HELP_STRING([--enable-ancient-vserver], [enable ancient VServer support (implies --enable-vserver)])], ,enable_ancient_vserver="no")
113if test "x$enable_ancient_vserver" = xyes; then
114 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
115 AC_DEFINE(HAVE_ANCIENT_VSERVER, 1, [Define if ancient vserver support enabled.])
116fi
117
Hisham Muhammadb09339d2008-03-16 00:31:31 +0000118AC_ARG_ENABLE(taskstats, [AC_HELP_STRING([--enable-taskstats], [enable per-task IO Stats (taskstats kernel sup required)])], ,enable_taskstats="yes")
Hisham Muhammad12f4f092008-03-09 08:02:22 +0000119if test "x$enable_taskstats" = xyes; then
120 AC_DEFINE(HAVE_TASKSTATS, 1, [Define if taskstats support enabled.])
121fi
122
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000123AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000124if test "x$enable_unicode" = xyes; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000125 AC_CHECK_LIB([ncursesw], [refresh], [], [
126 missing_libraries="$missing_libraries libncursesw"
127 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
128 ])
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000129 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000130 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
131 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
132 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000133else
134 AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"])
Hisham Muhammada0810562013-02-26 17:10:11 +0000135 AC_CHECK_HEADERS([curses.h],[:],
136 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
137 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
138 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000139fi
140
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000141AC_ARG_ENABLE(native_affinity, [AC_HELP_STRING([--enable-native-affinity], [enable native sched_setaffinity and sched_getaffinity for affinity support, disables hwloc])], ,enable_native_affinity="yes")
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000142if test "x$enable_native_affinity" = xyes -a "x$cross_compiling" = xno; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000143 AC_MSG_CHECKING([for usable sched_setaffinity])
144 AC_RUN_IFELSE([
145 AC_LANG_PROGRAM([[
146 #include <sched.h>
147 #include <errno.h>
148 static cpu_set_t cpuset;
149 ]], [[
150 CPU_ZERO(&cpuset);
151 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
152 if (errno == ENOSYS) return 1;
153 ]])],
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000154 [AC_MSG_RESULT([yes])],
155 [enable_native_affinity=no
156 AC_MSG_RESULT([no])])
157fi
158if test "x$enable_native_affinity" = xyes; then
159 AC_DEFINE(HAVE_NATIVE_AFFINITY, 1, [Define if native sched_setaffinity and sched_getaffinity are to be used.])
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000160fi
161
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000162AC_ARG_ENABLE(hwloc, [AC_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
Hisham Muhammadec17b702011-09-24 00:30:47 +0000163if test "x$enable_hwloc" = xyes
Hisham Muhammad9604e022010-11-22 12:24:46 +0000164then
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000165 AC_CHECK_LIB([hwloc], [hwloc_linux_get_tid_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
166 AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000167fi
168
Leigh Simpsonda236ca2014-01-29 22:41:55 +0000169AC_ARG_ENABLE(oom, [AC_HELP_STRING([--enable-oom], [enable OOM score reporting])], ,enable_oom="no")
170if test "x$enable_oom" = xyes; then
171 AC_DEFINE(HAVE_OOM, 1, [Define if OOM score support enabled.])
172fi
173
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200174# Bail out on errors.
175# ----------------------------------------------------------------------
176if test ! -z "$missing_libraries"; then
177 AC_MSG_ERROR([missing libraries: $missing_libraries])
178fi
179if test ! -z "$missing_headers"; then
180 AC_MSG_ERROR([missing headers: $missing_headers])
181fi
182
183# We're done, let's go!
184# ----------------------------------------------------------------------
Hisham Muhammada75161f2014-11-24 20:11:33 -0200185AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
186AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200187AC_SUBST(my_htop_platform)
Hisham Muhammaddd86b9b2009-06-23 14:02:14 +0000188AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000189AC_OUTPUT