blob: 752e8e9430b92e410e6f219a3edc0e6ca2e8044c [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 Muhammaddb682862015-12-09 17:17:30 -0200147# HTOP_CHECK_SCRIPT(LIBNAME, FUNCTION, DEFINE, CONFIG_SCRIPT, ELSE_PART)
148m4_define([HTOP_CHECK_SCRIPT],
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200149[
Hisham Muhammaddb682862015-12-09 17:17:30 -0200150 htop_config_script=$([$4] --libs 2> /dev/null)
151 htop_script_success=no
152 htop_save_LDFLAGS="$LDFLAGS"
153 if test ! "x$htop_config_script" = x; then
154 LDFLAGS="$htop_config_script $LDFLAGS"
155 AC_CHECK_LIB([$1], [$2], [
156 AC_DEFINE([$3], 1, [The library is present.])
157 LIBS="$htop_config_script $LIBS "
158 htop_script_success=yes
159 ], [])
160 LDFLAGS="$save_LDFLAGS"
Hisham Muhammadc2377022015-12-06 19:06:23 -0200161 fi
Hisham Muhammaddb682862015-12-09 17:17:30 -0200162 if test "x$htop_script_success" = no; then
163 [$5]
164 fi
165])
166
167# HTOP_CHECK_LIB(LIBNAME, FUNCTION, DEFINE, ELSE_PART)
168m4_define([HTOP_CHECK_LIB],
169[
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200170 AC_CHECK_LIB([$1], [$2], [
171 AC_DEFINE([$3], 1, [The library is present.])
Hisham Muhammaddb682862015-12-09 17:17:30 -0200172 LIBS="-l[$1] $LIBS "
173 ], [$4])
Hisham Muhammad96c929f2015-11-30 16:36:22 -0200174])
175
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000176AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000177if test "x$enable_unicode" = xyes; then
Hisham Muhammaddb682862015-12-09 17:17:30 -0200178 HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
179 HTOP_CHECK_SCRIPT([ncursesw], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw5-config",
180 HTOP_CHECK_SCRIPT([ncurses], [addnwstr], [HAVE_LIBNCURSESW], "ncurses5-config",
181 HTOP_CHECK_LIB([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW],
182 HTOP_CHECK_LIB([ncursesw], [addnwstr], [HAVE_LIBNCURSESW],
183 HTOP_CHECK_LIB([ncurses], [addnwstr], [HAVE_LIBNCURSESW],
184 missing_libraries="$missing_libraries libncursesw"
185 AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
186 ))))))
187
Hisham Muhammada7bcf1d2011-09-08 01:45:16 +0000188 AC_CHECK_HEADERS([ncursesw/curses.h],[:],
Hisham Muhammada0810562013-02-26 17:10:11 +0000189 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
190 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
191 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad8fa33dc2008-03-09 02:33:23 +0000192else
Hisham Muhammaddb682862015-12-09 17:17:30 -0200193 HTOP_CHECK_SCRIPT([ncurses6], [refresh], [HAVE_LIBNCURSES], "ncurses6-config",
194 HTOP_CHECK_SCRIPT([ncurses], [refresh], [HAVE_LIBNCURSES], "ncurses5-config",
195 HTOP_CHECK_LIB([ncurses6], [refresh], [HAVE_LIBNCURSES],
196 HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES],
197 missing_libraries="$missing_libraries libncurses"
198 ))))
199
Hisham Muhammada0810562013-02-26 17:10:11 +0000200 AC_CHECK_HEADERS([curses.h],[:],
201 [AC_CHECK_HEADERS([ncurses/curses.h],[:],
202 [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
203 [AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
Hisham Muhammad4c51ad02007-08-10 05:07:14 +0000204fi
205
Hisham Muhammad0aa485c2014-11-27 18:31:39 -0200206if test "$my_htop_platform" = "freebsd"; then
207 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
208fi
209
Michael McConvillea9a5a532015-09-18 00:46:48 -0400210if test "$my_htop_platform" = "openbsd"; then
211 AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
212fi
213
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000214AC_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 +0000215if test "x$enable_native_affinity" = xyes -a "x$cross_compiling" = xno; then
Hisham Muhammad7ca10812011-11-18 06:08:56 +0000216 AC_MSG_CHECKING([for usable sched_setaffinity])
217 AC_RUN_IFELSE([
218 AC_LANG_PROGRAM([[
219 #include <sched.h>
220 #include <errno.h>
221 static cpu_set_t cpuset;
222 ]], [[
223 CPU_ZERO(&cpuset);
224 sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
225 if (errno == ENOSYS) return 1;
226 ]])],
Hisham Muhammaddfad0af2011-11-23 18:43:35 +0000227 [AC_MSG_RESULT([yes])],
228 [enable_native_affinity=no
229 AC_MSG_RESULT([no])])
230fi
231if test "x$enable_native_affinity" = xyes; then
232 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 +0000233fi
234
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000235AC_ARG_ENABLE(hwloc, [AC_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
Hisham Muhammadec17b702011-09-24 00:30:47 +0000236if test "x$enable_hwloc" = xyes
Hisham Muhammad9604e022010-11-22 12:24:46 +0000237then
Hisham Muhammadbc87a8f2011-11-21 02:52:41 +0000238 AC_CHECK_LIB([hwloc], [hwloc_linux_get_tid_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
239 AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
Hisham Muhammad4df76d12008-03-05 09:46:47 +0000240fi
241
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200242# Bail out on errors.
243# ----------------------------------------------------------------------
244if test ! -z "$missing_libraries"; then
245 AC_MSG_ERROR([missing libraries: $missing_libraries])
246fi
247if test ! -z "$missing_headers"; then
248 AC_MSG_ERROR([missing headers: $missing_headers])
249fi
250
Hisham Muhammad3383d8e2015-01-21 23:27:31 -0200251AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-$year Hisham Muhammad", [Copyright message.])
252
Hisham Muhammad300af4b2014-11-19 23:17:16 -0200253# We're done, let's go!
254# ----------------------------------------------------------------------
Hisham Muhammada75161f2014-11-24 20:11:33 -0200255AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
Hisham Muhammad8915b292014-11-27 16:27:34 -0200256AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
Michael McConvillea9a5a532015-09-18 00:46:48 -0400257AM_CONDITIONAL([HTOP_OPENBSD], [test "$my_htop_platform" = openbsd])
David Hunt70e7c8d2015-07-12 13:47:43 -0500258AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
Hisham Muhammada75161f2014-11-24 20:11:33 -0200259AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
Hisham Muhammadeb229d92014-11-24 18:55:03 -0200260AC_SUBST(my_htop_platform)
Hisham Muhammaddd86b9b2009-06-23 14:02:14 +0000261AC_CONFIG_FILES([Makefile htop.1])
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000262AC_OUTPUT