blob: 63d34842c5235771a9c7cf6bb48e3c04cd1b21d4 [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
25# Checks for libraries.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020026# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000027AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
28
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000029# Checks for header files.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020030# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000031AC_HEADER_DIRENT
32AC_HEADER_STDC
Hisham Muhammada0810562013-02-26 17:10:11 +000033AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
Hisham Muhammade46f1422006-07-12 01:15:14 +000034 missing_headers="$missing_headers $ac_header"
35])
Hisham Muhammad36ef1a92010-12-05 15:43:56 +000036AC_CHECK_HEADERS([execinfo.h],[:],[:])
Hisham Muhammade46f1422006-07-12 01:15:14 +000037
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000038# Checks for typedefs, structures, and compiler characteristics.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020039# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000040AC_HEADER_STDBOOL
41AC_C_CONST
42AC_TYPE_PID_T
43AC_TYPE_UID_T
44
Hisham Muhammad300af4b2014-11-19 23:17:16 -020045# Checks for library functions and compiler features.
46# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000047AC_FUNC_CLOSEDIR_VOID
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000048AC_TYPE_SIGNAL
49AC_FUNC_STAT
50AC_CHECK_FUNCS([memmove strncasecmp strstr strdup])
51
Hisham Muhammad4df76d12008-03-05 09:46:47 +000052save_cflags="${CFLAGS}"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000053CFLAGS="${CFLAGS} -std=c99"
54AC_MSG_CHECKING([whether gcc -std=c99 option works])
55AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [char *a; a = strdup("foo"); int i = 0; i++; // C99],
56 AC_MSG_RESULT([yes]),
57 AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.]))
Hisham Muhammad4df76d12008-03-05 09:46:47 +000058CFLAGS="$save_cflags"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000059
Hisham Muhammad300af4b2014-11-19 23:17:16 -020060# Checks for features and flags.
61# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000062PROCDIR=/proc
63AC_ARG_WITH(proc, [ --with-proc=DIR Location of a Linux-compatible proc filesystem (default=/proc).],
64
65 if test -n "$withval"; then
66 AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
Hisham Muhammadbd613882006-05-18 20:22:36 +000067 PROCDIR="$withval"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000068 fi,
69 AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
70
Hisham Muhammad300af4b2014-11-19 23:17:16 -020071if test "x$cross_compiling" = xno; then
72AC_CHECK_FILE($PROCDIR/stat,,AC_MSG_ERROR(Cannot find /proc/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))
73AC_CHECK_FILE($PROCDIR/meminfo,,AC_MSG_ERROR(Cannot find /proc/meminfo. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))
74fi
75
Hisham Muhammad4c51ad02007-08-10 05:07:14 +000076AC_ARG_ENABLE(openvz, [AC_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no")
77if test "x$enable_openvz" = xyes; then
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +000078 AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
79fi
80
Hisham Muhammad84ed4c02010-10-30 19:24:07 +000081AC_ARG_ENABLE(cgroup, [AC_HELP_STRING([--enable-cgroup], [enable cgroups support])], ,enable_cgroup="no")
82if test "x$enable_cgroup" = xyes; then
83 AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.])
84fi
85
Hisham Muhammada5dfaa22008-09-23 04:31:13 +000086AC_ARG_ENABLE(vserver, [AC_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no")
87if test "x$enable_vserver" = xyes; then
88 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
89fi
90
91AC_ARG_ENABLE(ancient_vserver, [AC_HELP_STRING([--enable-ancient-vserver], [enable ancient VServer support (implies --enable-vserver)])], ,enable_ancient_vserver="no")
92if test "x$enable_ancient_vserver" = xyes; then
93 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
94 AC_DEFINE(HAVE_ANCIENT_VSERVER, 1, [Define if ancient vserver support enabled.])
95fi
96
Hisham Muhammadb09339d2008-03-16 00:31:31 +000097AC_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 +000098if test "x$enable_taskstats" = xyes; then
99 AC_DEFINE(HAVE_TASKSTATS, 1, [Define if taskstats support enabled.])
100fi
101
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000102AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000103if test "x$enable_unicode" = xyes; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000104 AC_CHECK_LIB([ncursesw], [refresh], [], [
105 missing_libraries="$missing_libraries libncursesw"
106 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
107 ])
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000108 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000109 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
110 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
111 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000112else
113 AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"])
Hisham Muhammada0810562013-02-26 17:10:11 +0000114 AC_CHECK_HEADERS([curses.h],[:],
115 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
116 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
117 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000118fi
119
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000120AC_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 +0000121if test "x$enable_native_affinity" = xyes -a "x$cross_compiling" = xno; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000122 AC_MSG_CHECKING([for usable sched_setaffinity])
123 AC_RUN_IFELSE([
124 AC_LANG_PROGRAM([[
125 #include <sched.h>
126 #include <errno.h>
127 static cpu_set_t cpuset;
128 ]], [[
129 CPU_ZERO(&cpuset);
130 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
131 if (errno == ENOSYS) return 1;
132 ]])],
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000133 [AC_MSG_RESULT([yes])],
134 [enable_native_affinity=no
135 AC_MSG_RESULT([no])])
136fi
137if test "x$enable_native_affinity" = xyes; then
138 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 +0000139fi
140
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000141AC_ARG_ENABLE(hwloc, [AC_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
Hisham Muhammadec17b702011-09-24 00:30:47 +0000142if test "x$enable_hwloc" = xyes
Hisham Muhammad9604e022010-11-22 12:24:46 +0000143then
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000144 AC_CHECK_LIB([hwloc], [hwloc_linux_get_tid_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
145 AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000146fi
147
Leigh Simpsonda236ca2014-01-29 22:41:55 +0000148AC_ARG_ENABLE(oom, [AC_HELP_STRING([--enable-oom], [enable OOM score reporting])], ,enable_oom="no")
149if test "x$enable_oom" = xyes; then
150 AC_DEFINE(HAVE_OOM, 1, [Define if OOM score support enabled.])
151fi
152
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200153# Bail out on errors.
154# ----------------------------------------------------------------------
155if test ! -z "$missing_libraries"; then
156 AC_MSG_ERROR([missing libraries: $missing_libraries])
157fi
158if test ! -z "$missing_headers"; then
159 AC_MSG_ERROR([missing headers: $missing_headers])
160fi
161
162# We're done, let's go!
163# ----------------------------------------------------------------------
Hisham Muhammaddd86b9b2009-06-23 14:02:14 +0000164AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000165AC_OUTPUT