blob: f865cbf20ba08d4e6543a19934c4b789b5fd2ef3 [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
Hisham Muhammad3383d8e2015-01-21 23:27:31 -02007year=$(date +%Y)
8
Hisham Muhammadec17b702011-09-24 00:30:47 +00009# The following two lines are required by hwloc scripts
10AC_USE_SYSTEM_EXTENSIONS
11AC_CANONICAL_TARGET
12
13AM_INIT_AUTOMAKE([1.11])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000014AC_CONFIG_SRCDIR([htop.c])
15AC_CONFIG_HEADER([config.h])
Hisham Muhammad5fd14362010-11-20 18:54:39 +000016AC_CONFIG_MACRO_DIR([m4])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000017
18# Checks for programs.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020019# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000020AC_PROG_CC
Hisham Muhammad4df76d12008-03-05 09:46:47 +000021AM_PROG_CC_C_O
22
Hisham Muhammad5fd14362010-11-20 18:54:39 +000023AC_DISABLE_SHARED
24AC_ENABLE_STATIC
Hisham Muhammad4df76d12008-03-05 09:46:47 +000025AC_PROG_LIBTOOL
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000026
Hisham Muhammadeb229d92014-11-24 18:55:03 -020027# Checks for platform.
28# ----------------------------------------------------------------------
29case "$target" in
30*linux*)
31 my_htop_platform=linux
32 ;;
Hisham Muhammad8915b292014-11-27 16:27:34 -020033*freebsd*)
34 my_htop_platform=freebsd
35 ;;
Michael McConvillea9a5a532015-09-18 00:46:48 -040036*openbsd*)
37 my_htop_platform=openbsd
38 ;;
David Hunt70e7c8d2015-07-12 13:47:43 -050039*darwin*)
40 my_htop_platform=darwin
41 ;;
Hisham Muhammadeb229d92014-11-24 18:55:03 -020042*)
43 my_htop_platform=unsupported
44 ;;
45esac
Hisham Muhammadeb229d92014-11-24 18:55:03 -020046
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000047# Checks for libraries.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020048# ----------------------------------------------------------------------
Hisham Muhammade46f1422006-07-12 01:15:14 +000049AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
50
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000051# Checks for header files.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020052# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000053AC_HEADER_DIRENT
54AC_HEADER_STDC
Hisham Muhammada0810562013-02-26 17:10:11 +000055AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
Hisham Muhammade46f1422006-07-12 01:15:14 +000056 missing_headers="$missing_headers $ac_header"
57])
Hisham Muhammad36ef1a92010-12-05 15:43:56 +000058AC_CHECK_HEADERS([execinfo.h],[:],[:])
Hisham Muhammade46f1422006-07-12 01:15:14 +000059
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000060# Checks for typedefs, structures, and compiler characteristics.
Hisham Muhammad300af4b2014-11-19 23:17:16 -020061# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000062AC_HEADER_STDBOOL
63AC_C_CONST
64AC_TYPE_PID_T
65AC_TYPE_UID_T
66
Hisham Muhammad300af4b2014-11-19 23:17:16 -020067# Checks for library functions and compiler features.
68# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000069AC_FUNC_CLOSEDIR_VOID
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000070AC_TYPE_SIGNAL
71AC_FUNC_STAT
72AC_CHECK_FUNCS([memmove strncasecmp strstr strdup])
73
Hisham Muhammad4df76d12008-03-05 09:46:47 +000074save_cflags="${CFLAGS}"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000075CFLAGS="${CFLAGS} -std=c99"
76AC_MSG_CHECKING([whether gcc -std=c99 option works])
77AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [char *a; a = strdup("foo"); int i = 0; i++; // C99],
78 AC_MSG_RESULT([yes]),
79 AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.]))
Hisham Muhammad4df76d12008-03-05 09:46:47 +000080CFLAGS="$save_cflags"
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000081
Hisham Muhammadaed9b9d2015-02-04 12:19:04 -020082save_cflags="${CFLAGS}"
83CFLAGS="$CFLAGS -Wextra"
84AC_MSG_CHECKING([if compiler supports -Wextra])
85AC_TRY_COMPILE([], [], [
86 wextra_flag=-Wextra
87 AC_MSG_RESULT([yes])
88],[
89 wextra_flag=
90 AC_MSG_RESULT([no])
91])
92CFLAGS="$save_cflags"
93AC_SUBST(wextra_flag)
94
Hisham Muhammad300af4b2014-11-19 23:17:16 -020095# Checks for features and flags.
96# ----------------------------------------------------------------------
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000097PROCDIR=/proc
Hisham Muhammadeb229d92014-11-24 18:55:03 -020098
99AC_ARG_ENABLE(proc, [AC_HELP_STRING([--enable-proc], [use Linux-compatible proc filesystem])], enable_proc="yes", enable_proc="no")
100if test "x$enable_proc" = xyes; then
Hisham Muhammada75161f2014-11-24 20:11:33 -0200101 # An enabled proc assumes we're emulating Linux.
102 my_htop_platform=linux
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200103 AC_DEFINE(HAVE_PROC, 1, [Define if using a Linux-compatible proc filesystem.])
104fi
105
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000106AC_ARG_WITH(proc, [ --with-proc=DIR Location of a Linux-compatible proc filesystem (default=/proc).],
107
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200108if test -n "$withval"; then
109 AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
110 PROCDIR="$withval"
111fi,
112AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000113
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200114if test "x$cross_compiling" = xno; then
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200115 if test "x$enable_proc" = xyes; then
116 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.))
117 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.))
118 fi
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200119fi
120
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000121AC_ARG_ENABLE(openvz, [AC_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no")
122if test "x$enable_openvz" = xyes; then
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000123 AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
124fi
125
Hisham Muhammad84ed4c02010-10-30 19:24:07 +0000126AC_ARG_ENABLE(cgroup, [AC_HELP_STRING([--enable-cgroup], [enable cgroups support])], ,enable_cgroup="no")
127if test "x$enable_cgroup" = xyes; then
128 AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.])
129fi
130
Hisham Muhammada5dfaa22008-09-23 04:31:13 +0000131AC_ARG_ENABLE(vserver, [AC_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no")
132if test "x$enable_vserver" = xyes; then
133 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
134fi
135
136AC_ARG_ENABLE(ancient_vserver, [AC_HELP_STRING([--enable-ancient-vserver], [enable ancient VServer support (implies --enable-vserver)])], ,enable_ancient_vserver="no")
137if test "x$enable_ancient_vserver" = xyes; then
138 AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
139 AC_DEFINE(HAVE_ANCIENT_VSERVER, 1, [Define if ancient vserver support enabled.])
140fi
141
Hisham Muhammadb09339d2008-03-16 00:31:31 +0000142AC_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 +0000143if test "x$enable_taskstats" = xyes; then
144 AC_DEFINE(HAVE_TASKSTATS, 1, [Define if taskstats support enabled.])
145fi
146
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000147AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000148if test "x$enable_unicode" = xyes; then
Hisham Muhammad8bd603c2015-08-20 00:31:48 -0300149 AC_CHECK_LIB([ncursesw6], [refresh], [
150 AC_DEFINE(HAVE_LIBNCURSESW, 1, [])
151 LIBS="-lncursesw6 $LIBS "
152 ], [
Hisham Muhammadb0036362015-08-19 18:55:24 -0300153 AC_CHECK_LIB([ncursesw], [refresh], [], [
154 missing_libraries="$missing_libraries libncursesw"
155 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
156 ])
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000157 ])
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000158 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000159 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
160 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
161 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000162else
163 AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"])
Hisham Muhammada0810562013-02-26 17:10:11 +0000164 AC_CHECK_HEADERS([curses.h],[:],
165 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
166 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
167 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000168fi
169
Hisham Muhammad0aa485c2014-11-27 18:31:39 -0200170if test "$my_htop_platform" = "freebsd"; then
171 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
172fi
173
Michael McConvillea9a5a532015-09-18 00:46:48 -0400174if test "$my_htop_platform" = "openbsd"; then
175 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
176fi
177
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000178AC_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 +0000179if test "x$enable_native_affinity" = xyes -a "x$cross_compiling" = xno; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000180 AC_MSG_CHECKING([for usable sched_setaffinity])
181 AC_RUN_IFELSE([
182 AC_LANG_PROGRAM([[
183 #include <sched.h>
184 #include <errno.h>
185 static cpu_set_t cpuset;
186 ]], [[
187 CPU_ZERO(&cpuset);
188 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
189 if (errno == ENOSYS) return 1;
190 ]])],
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000191 [AC_MSG_RESULT([yes])],
192 [enable_native_affinity=no
193 AC_MSG_RESULT([no])])
194fi
195if test "x$enable_native_affinity" = xyes; then
196 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 +0000197fi
198
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000199AC_ARG_ENABLE(hwloc, [AC_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
Hisham Muhammadec17b702011-09-24 00:30:47 +0000200if test "x$enable_hwloc" = xyes
Hisham Muhammad9604e022010-11-22 12:24:46 +0000201then
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000202 AC_CHECK_LIB([hwloc], [hwloc_linux_get_tid_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
203 AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000204fi
205
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200206# Bail out on errors.
207# ----------------------------------------------------------------------
208if test ! -z "$missing_libraries"; then
209 AC_MSG_ERROR([missing libraries: $missing_libraries])
210fi
211if test ! -z "$missing_headers"; then
212 AC_MSG_ERROR([missing headers: $missing_headers])
213fi
214
Hisham Muhammad3383d8e2015-01-21 23:27:31 -0200215AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-$year Hisham Muhammad", [Copyright message.])
216
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200217# We're done, let's go!
218# ----------------------------------------------------------------------
Hisham Muhammada75161f2014-11-24 20:11:33 -0200219AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200220AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400221AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500222AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200223AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200224AC_SUBST(my_htop_platform)
Hisham Muhammaddd86b9b2009-06-23 14:02:14 +0000225AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000226AC_OUTPUT