Fixing invalid reads in find_elf_note due to setenv invocation
[platform/upstream/procps-ng.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.69])
5 AC_CONFIG_MACRO_DIR([m4])
6 AC_INIT([procps-ng],
7         m4_esyscmd([misc/git-version-gen .tarball-version]),
8         [procps@freelists.org],,[http://gitorious.org/procps])
9 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability tar-pax no-dist-gzip dist-xz])
10 AM_SILENT_RULES([yes])
11 AC_CONFIG_SRCDIR([free.c])
12 AC_CONFIG_HEADERS([config.h])
13
14 # Checks for programs.
15 AC_USE_SYSTEM_EXTENSIONS(_GNU_SOURCE)
16 AC_PROG_CXX
17 AC_PROG_AWK
18 AC_PROG_CC
19 AC_PROG_CC_STDC
20 if test "$cross_compiling" = no; then
21   if test "x$ac_cv_prog_cc_c99" = "xno" || test "x$ac_cv_prog_cc_c99" = "x"; then
22   # We might be on RHEL5 with a git checkout and so broken
23   # autoconf. Check if CC is gcc and if it bails when given -std=gnu99.
24   # If not, use that.  Yuck.
25     if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
26        CC="$CC -std=gnu99"
27        AC_RUN_IFELSE(
28           [AC_LANG_PROGRAM([],[[
29   return 0;
30       ]])],
31       [],
32       [AC_MSG_ERROR([Could not find a C99 compatible compiler])])
33     else
34       AC_MSG_ERROR([Could not find a C99 compatible compiler])
35     fi
36   fi
37 fi
38 AM_PROG_CC_C_O
39 AC_PROG_CPP
40 AC_PROG_INSTALL
41 AC_PROG_LN_S
42 PKG_PROG_PKG_CONFIG
43 AC_PROG_MAKE_SET
44 AC_PROG_RANLIB
45
46 # Checks for header files.
47 AC_HEADER_MAJOR
48 AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h libintl.h limits.h locale.h netinet/in.h stdint.h stdio_ext.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/time.h termios.h unistd.h utmp.h values.h wchar.h wctype.h])
49
50 # Checks for typedefs, structures, and compiler characteristics.
51 AC_CHECK_HEADER_STDBOOL
52 AC_TYPE_UID_T
53 AC_C_INLINE
54 AC_TYPE_INT32_T
55 AC_TYPE_PID_T
56 AC_C_RESTRICT
57 AC_TYPE_SIZE_T
58 AC_TYPE_SSIZE_T
59 AC_CHECK_MEMBERS([struct stat.st_rdev])
60
61 dnl libtool
62 LT_INIT
63
64 # Checks for library functions.
65 AC_FUNC_ERROR_AT_LINE
66 AC_FUNC_FORK
67 AC_FUNC_MALLOC
68 AC_FUNC_MBRTOWC
69 AC_FUNC_MMAP
70 AC_FUNC_REALLOC
71 AC_FUNC_STRTOD
72
73 usrbin_execdir='${exec_prefix}/usr/bin'
74 AC_SUBST([usrbin_execdir])
75
76 AM_GNU_GETTEXT_VERSION([0.14.1])
77 AM_GNU_GETTEXT([external])
78 dnl if test -d "$srcdir/po"
79 dnl then
80 dnl     ALL_LINGUAS=`cd $srcdir/po > /dev/null && echo *.po | sed 's/\.po//g'`
81 dnl else
82 dnl     ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq sr@Latn sr sv ta te th tr uk ur vi zh_CN zh_TW zu"
83 dnl fi
84
85 AC_CHECK_HEADERS(error.h, [], [], AC_INCLUDES_DEFAULT)
86
87 AC_CHECK_HEADERS(stdio_ext.h, [], [], AC_INCLUDES_DEFAULT)
88
89 AC_MSG_CHECKING(whether program_invocation_name is defined)
90 AC_TRY_COMPILE([#include <errno.h>],
91                 [program_invocation_name = "test";],
92                 AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME, 1,
93                         [Define if program_invocation_name is defined])
94                 AC_MSG_RESULT(yes),
95                 AC_MSG_RESULT(no))
96
97 AC_MSG_CHECKING(whether program_invocation_short_name is defined)
98 AC_TRY_COMPILE([#include <errno.h>],
99                 [program_invocation_short_name = "test";],
100                 AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME, 1,
101                         [Define if program_invocation_short_name is defined])
102                 AC_MSG_RESULT(yes),
103                 AC_MSG_RESULT(no))
104
105 dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses
106 AC_SUBST([WITH_WATCH8BIT])
107 AC_ARG_ENABLE([watch8bit],
108   AS_HELP_STRING([--enable-watch8bit], [enable watch to be 8bit clean (requires ncursesw)]),
109   [], [enable_watch8bit=no]
110 )
111 if test "$enable_watch8bit" = "yes"; then
112   AC_DEFINE([WITH_WATCH8BIT], [1], [Enable 8 bit clean watch])
113 fi
114
115 AC_ARG_ENABLE([libselinux],
116   AS_HELP_STRING([--enable-libselinux], [enable libselinux]),
117   [], [enable_libselinux=no]
118 )
119 if test "$enable_libselinux" = "yes"; then
120   AC_DEFINE([ENABLE_LIBSELINUX], [1], [Enable libselinux])
121 fi
122
123 # Optional packages - AC_ARG_WITH
124 AC_ARG_WITH([ncurses],
125   AS_HELP_STRING([--without-ncurses], [build only applications not needing ncurses]),
126   [], [with_ncurses=yes]
127 )
128 if test "x$with_ncurses" = xno; then
129   AM_CONDITIONAL(WITH_NCURSES, false)
130 else
131   PKG_CHECK_MODULES([NCURSES], [ncurses], [], [
132     AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
133     AC_CHECK_HEADERS(curses.h ncurses.h term.h, [], [have_ncurses=no], AC_INCLUDES_DEFAULT)
134     if test "x$have_ncurses" = xno; then
135       AC_MSG_ERROR([ncurses support missing/incomplete (for partial build use --without-ncurses)])
136     fi
137     NCURSES_LIBS="-lncurses"
138   ])
139   AM_CONDITIONAL(WITH_NCURSES, true)
140   if test "$enable_watch8bit" = yes; then
141     PKG_CHECK_MODULES([NCURSESW], [ncursesw], [WATCH_NCURSES_LIBS="$NCURSESW_LIBS"], [
142       AC_CHECK_LIB([ncursesw], [addwstr], [WATCH_NCURSES_LIBS=-lncursesw],
143                    [AC_MSG_ERROR([Cannot find ncurses wide library ncursesw with --enable-watch8bit])])
144     ])
145   else
146     WATCH_NCURSES_LIBS="$NCURSES_LIBS"
147   fi
148 fi
149 AC_SUBST([NCURSES_LIBS])
150 AC_SUBST([WATCH_NCURSES_LIBS])
151
152 AC_ARG_WITH([systemd],
153   [AS_HELP_STRING([--with-systemd], [enable systemd support])],
154   [], [with_systemd=no]
155 )
156 if test "x$with_systemd" != xno; then
157   PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login >= 206], [], [
158     AC_CHECK_LIB(systemd-login, sd_pid_get_slice, [have_systemd=yes], [have_systemd=no])
159     if test "x$have_systemd" = xno; then
160       AC_MSG_ERROR([systemd support missing/incomplete])
161     fi
162     SYSTEMD_LIBS="-lsystemd-login"
163   ])
164   AM_CONDITIONAL(WITH_SYSTEMD, true)
165   AC_DEFINE(WITH_SYSTEMD, 1, [enable systemd support])
166 else
167   AM_CONDITIONAL(WITH_SYSTEMD, false)
168 fi
169
170 # AC_ARG_ENABLEs
171 AC_ARG_ENABLE([pidof],
172   AS_HELP_STRING([--disable-pidof], [do not build pidof]),
173   [], [enable_pidof=yes]
174 )
175 AM_CONDITIONAL(BUILD_PIDOF, test "x$enable_pidof" = xyes)
176
177 AC_ARG_ENABLE([kill],
178   AS_HELP_STRING([--disable-kill], [do not build kill]),
179   [], [enable_kill=yes]
180 )
181 AM_CONDITIONAL(BUILD_KILL, test "x$enable_kill" = xyes)
182 AM_CONDITIONAL(LINUX, test "x$host_os" = xlinux-gnu)
183
184 AC_ARG_ENABLE([skill],
185   AS_HELP_STRING([--enable-skill], [build skill and snice]),
186   [], [enable_skill=no]
187 )
188 AM_CONDITIONAL(BUILD_SKILL, test "x$enable_skill" = xyes)
189
190 AC_ARG_ENABLE([examples],
191   AS_HELP_STRING([--enable-examples], [add example files to installation]),
192   [], [enable_examples=no]
193 )
194 AM_CONDITIONAL(EXAMPLE_FILES, test "x$enable_examples" = xyes)
195
196 AC_ARG_ENABLE([oomem],
197   AS_HELP_STRING([--enable-oomem], [add out-of-memory fields to the library and top]),
198   [], [enable_oomem=no]
199 )
200 if test "x$enable_oomem" = xyes; then
201   AC_DEFINE(OOMEM_ENABLE, 1, [add out-of-memory fields to the library and top])
202 fi
203
204 AC_ARG_ENABLE([sigwinch],
205   AS_HELP_STRING([--enable-sigwinch], [reduce impact of x-windows resize operations on top]),
206   [], [enable_sigwinch=no]
207 )
208 if test "x$enable_sigwinch" = xyes; then
209   AC_DEFINE(SIGNALS_LESS, 1, [reduce impact of x-windows resize operations on top])
210 fi
211
212 AC_ARG_ENABLE([wide-percent],
213   AS_HELP_STRING([--enable-wide-percent], [provide extra precision under %CPU and %MEM for top]),
214   [], [enable_wide_percent=no]
215 )
216 if test "x$enable_wide_percent" = xyes; then
217   AC_DEFINE(BOOST_PERCNT, 1, [provide extra precision under %CPU and %MEM for top])
218 fi
219
220 AC_ARG_ENABLE([wide-memory],
221   AS_HELP_STRING([--disable-wide-memory], [disable extra precision under memory fields for top]),
222   [], [enable_wide_memory=yes]
223 )
224 if test "x$enable_wide_memory" = xno; then
225   AC_DEFINE(NOBOOST_MEMS, 1, [disable extra precision under memory fields for top])
226 fi
227
228 DL_LIB=
229 AC_ARG_ENABLE([numa],
230   AS_HELP_STRING([--disable-numa], [disable NUMA/Node support in top]),
231   [], [enable_numa=yes]
232 )
233 if test "x$enable_numa" = xno; then
234   AC_DEFINE([NUMA_DISABLE], [1], [disable NUMA/Node support in top])
235 else
236     AC_CHECK_LIB(dl, dlopen, [have_dlopen=yes], [have_dlopen=no])
237     if test "x$have_dlopen" = xno; then
238       AC_MSG_ERROR([dynamic linking unavailable, circumvent with --disable-numa])
239     fi
240     DL_LIB="-ldl"
241 fi
242 AC_SUBST([DL_LIB])
243
244 AC_ARG_ENABLE([w-from],
245   AS_HELP_STRING([--enable-w-from], [enable w from field by default]),
246   [], [enable_w_from=no]
247 )
248 if test "x$enable_w_from" = xyes; then
249   AC_DEFINE(W_SHOWFROM, 1, [enable w from field by default])
250 fi
251
252 AC_ARG_ENABLE([whining],
253   AS_HELP_STRING([--disable-whining], [do not print unnecessary warnings (slackware-ism)]),
254   [], [enable_whining=yes]
255 )
256 if test "x$enable_whining" = xyes; then
257   AC_DEFINE(BUILD_WITH_WHINE, 1, [should extra warnings be printed (slackware-ism)])
258 fi
259
260 if test x"$DEJAGNU" = x
261 then
262   DEJAGNU="/dev/null"
263 fi
264 AC_SUBST(DEJAGNU)
265
266 AC_CHECK_FUNCS([__fpending alarm atexit dup2 getpagesize gettimeofday iswprint memchr memmove memset munmap nl_langinfo putenv regcomp rpmatch select setlocale strcasecmp strchr strcspn strdup strerror strncasecmp strpbrk strrchr strspn strstr strtol strtoul strtoull strverscmp uname utmpname wcwidth])
267
268 AC_CONFIG_FILES([Makefile
269                  include/Makefile
270                  lib/Makefile
271                  po/Makefile.in
272                  proc/Makefile
273                  proc/libprocps.pc
274                  ps/Makefile
275                  testsuite/Makefile
276                  top/Makefile])
277 AC_OUTPUT