summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 4a159b4a54a4cc0f080b8c417daa6b997d805a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_CONFIG_MACRO_DIR([m4])
AC_INIT([psmisc],[22.21])
AC_CONFIG_SRCDIR([src/comm.h])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_AUX_DIR([config])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.10])
AC_LANG([C])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_LN_S

dnl checks for options
# SELinux support - off by default
AC_SUBST([WITH_SELINUX])
AC_ARG_ENABLE([selinux],
  [AS_HELP_STRING([--enable-selinux], [Enable Security-Enhanced Linux features])],
  [enable_selinux=$enableval],
  [enable_selinux="no"])
if test "$enable_selinux" = "yes"; then
  AC_DEFINE([WITH_SELINUX], [1], [Use Security-Enhanced Linux features])
  AC_CHECK_LIB([selinux], [getfilecon], [SELINUX_LIB=-lselinux], [
     AC_MSG_ERROR([Cannot find selinux static library]) ])
fi
AC_SUBST([SELINUX_LIB])

# Call fork before all stat calls to stop hanging on NFS mounts
AC_SUBST([WITH_TIMEOUT_STAT])
AC_ARG_ENABLE([timeout_stat],
  [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls (optional with argument "static" for a static background process)])],
  [enable_timeout_stat=$enableval],
  [enable_timeout_stat="no"])
if test "$enable_timeout_stat" = "yes"; then
  AC_DEFINE([WITH_TIMEOUT_STAT], [1], [Use timeout on stat calls])
fi
if test "$enable_timeout_stat" = "static"; then
  AC_DEFINE([WITH_TIMEOUT_STAT], [2], [Use timeout on stat calls])
fi
AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"])

# Use string search for network based file systems but only if the system
# has /proc/self/mountinfo
AC_SUBST([WITH_MOUNTINFO_LIST])
AC_ARG_ENABLE([mountinfo_list],
  [AS_HELP_STRING([--enable-mountinfo-list], [Use the list in /proc/self/mountinfo to replace stat(2) syscall on network file systems shares])],
  [enable_mountinfo_list="yes"],
  [enable_mountinfo_list="no"])
if test "$enable_mountinfo_list" = "yes" -a -e /proc/self/mountinfo ; then
  AC_DEFINE([WITH_MOUNTINFO_LIST], [1], [Use list in /proc/self/mountinfo to replace stat calls])
fi

# Enable hardened compile and link flags
AC_ARG_ENABLE([harden_flags],
  [AS_HELP_STRING([--disable-harden-flags], [disable hardened compilier and linker flags])],
  [enable_harden_flags=$enableval],
  [enable_harden_flags="yes"])

dnl ipv4 only option
AC_SUBST([WITH_IPV6])
AC_ARG_ENABLE([ipv6],
  [AS_HELP_STRING([--disable-ipv6], [Disable IPv6 checks (for uClibc)])],
  [enable_ipv6=$enableval],
  [enable_ipv6="yes"])
if test "$enable_ipv6" = "yes"; then
  AC_DEFINE([WITH_IPV6], [1], [Use IPv6 checks])
fi

dnl Checks for libraries.
AC_CHECK_LIB([tinfo], [tgetent], [TERMCAP_LIB=-ltinfo],
  [ AC_CHECK_LIB([ncurses], [tgetent], [TERMCAP_LIB=-lncurses],
    [ AC_CHECK_LIB([termcap], [tgetent], [TERMCAP_LIB=-ltermcap], 
      [ AC_MSG_ERROR([Cannot find tinfo, ncurses or termcap libraries])
	  ] )
	] )
  ] )
AC_SUBST([TERMCAP_LIB])

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h libintl.h limits.h locale.h mntent.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h termios.h unistd.h])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_TYPE_UID_T

# Check that harden CFLAGS will compile
AS_IF([test "$enable_harden_flags" = "yes"],
  HARDEN_CFLAGS="-fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security"
  [ AC_MSG_CHECKING([compiler supports harden flags])
  save_harden_cflags="$CFLAGS"
  CFLAGS="$CFLAGS $HARDEN_CFLAGS"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,,)],
      [AC_MSG_RESULT([yes])],
     [AC_MSG_RESULT([no]); HARDEN_CFLAGS='']
    )
  CFLAGS="$save_harden_cflags"],
  [HARDEN_CFLAGS=""])
AC_SUBST([HARDEN_CFLAGS])

dnl Check for language stuff
AM_GNU_GETTEXT_VERSION([0.16.1])
AM_GNU_GETTEXT([external])

dnl Must be after the gettext stuff as it sets build_cpu
AC_CHECK_MEMBERS([struct user_regs_struct.orig_eax,
		struct user_regs_struct.eax,
		struct user_regs_struct.ebx,
		struct user_regs_struct.ecx,
		struct user_regs_struct.edx,
		struct user_regs_struct.orig_rax,
		struct user_regs_struct.rax,
		struct user_regs_struct.rdi,
		struct user_regs_struct.rsi,
		struct user_regs_struct.rdx], [],[],
    [#include <bits/types.h>
     #include <sys/user.h>])
AC_CHECK_MEMBERS([struct pt_regs.orig_gpr3,
		struct pt_regs.gpr], [],[], [#include <linux/ptrace.h>])
AC_CHECK_MEMBERS([struct pt_regs.uregs],[],[], [#include <asm/ptrace.h>])
AC_CHECK_MEMBERS([struct pt_regs.regs,
                  struct pt_regs.cp0_status],[],[], [#include <asm/ptrace.h>])
AC_CHECK_MEMBERS([struct pt_regs.orig_d0,
                  struct pt_regs.d0],[],[], [#include <asm/ptrace.h>])

case ${host_os} in
  gnu*)
    want_fuser=no
    ;;
  *)
    want_fuser=yes
	;;
esac
AM_CONDITIONAL(WANT_FUSER, test $want_fuser = yes)

AM_CONDITIONAL(WANT_PEEKFD_I386,
 test $ac_cv_member_struct_user_regs_struct_orig_eax = yes &&
   test $ac_cv_member_struct_user_regs_struct_eax = yes &&
   test $ac_cv_member_struct_user_regs_struct_ebx = yes &&
   test $ac_cv_member_struct_user_regs_struct_ecx = yes &&
   test $ac_cv_member_struct_user_regs_struct_edx = yes )
AM_CONDITIONAL(WANT_PEEKFD_X86_64,
 test $ac_cv_member_struct_user_regs_struct_orig_rax = yes &&
   test $ac_cv_member_struct_user_regs_struct_rax = yes &&
   test $ac_cv_member_struct_user_regs_struct_rdi = yes &&
   test $ac_cv_member_struct_user_regs_struct_rsi = yes &&
   test $ac_cv_member_struct_user_regs_struct_rdx = yes )
AM_CONDITIONAL(WANT_PEEKFD_PPC,
   test $ac_cv_member_struct_pt_regs_orig_gpr3 = yes &&
   test $ac_cv_member_struct_pt_regs_gpr = yes )
AM_CONDITIONAL(WANT_PEEKFD_ARM,
   test $ac_cv_member_struct_pt_regs_uregs = yes)
AM_CONDITIONAL(WANT_PEEKFD_MIPS,
   test $build_cpu = mipsel &&
   test $ac_cv_member_struct_pt_regs_regs = yes &&
   test $ac_cv_member_struct_pt_regs_cp0_status = yes)
AM_CONDITIONAL(WANT_PEEKFD_M68K,
   test $ac_cv_member_struct_pt_regs_orig_d0 = yes &&
   test $ac_cv_member_struct_pt_regs_d0 = yes)

dnl Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_GETMNTENT
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([atexit getmntent memset nl_langinfo rawmemchr regcomp rpmatch setlocale socket strcasecmp strchr strdup strerror strpbrk strrchr strtoul])

dnl Checks for Large File System
AC_SYS_LARGEFILE

if test x"$DEJAGNU" = x
then
  DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp"
fi
AC_SUBST(DEJAGNU)
	
AC_CONFIG_FILES([Makefile
		 doc/Makefile
		 src/Makefile
		 icons/Makefile
		 po/Makefile.in
		 testsuite/Makefile])
AC_OUTPUT