cifs.upcall: the exit code should be 0 when print version
[jlayton/cifs-utils.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_INIT([cifs-utils], [6.0.1], [linux-cifs@vger.kernel.org], [cifs-utils], [https://wiki.samba.org/index.php/LinuxCIFS_utils])
5 AC_CONFIG_SRCDIR([replace.h])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_FILES([Makefile contrib/Makefile contrib/request-key.d/Makefile])
8 AC_CONFIG_MACRO_DIR(aclocal)
9
10 AM_INIT_AUTOMAKE
11
12 # "enable" options
13 AC_ARG_ENABLE(pie,
14         [AC_HELP_STRING([--enable-pie],
15                         [Produce position independent executables @<:@default=yes@:>@])],
16         enable_pie=$enableval,
17         enable_pie="maybe")
18
19 AC_ARG_ENABLE(relro,
20         [AC_HELP_STRING([--enable-relro],
21                         [Enable relocations read-only support @<:@default=yes@:>@])],
22         enable_relro=$enableval,
23         enable_relro="maybe")
24
25 AC_ARG_ENABLE(cifsupcall,
26         [AC_HELP_STRING([--enable-cifsupcall],
27                         [Create cifs.upcall binary @<:@default=yes@:>@])],
28         enable_cifsupcall=$enableval,
29         enable_cifsupcall="maybe")
30
31 AC_ARG_ENABLE(cifscreds,
32         [AC_HELP_STRING([--enable-cifscreds],
33                         [Create cifscreds utility @<:@default=yes@:>@])],
34         enable_cifscreds=$enableval,
35         enable_cifscreds="maybe")
36
37 AC_ARG_ENABLE(cifsidmap,
38         [AC_HELP_STRING([--enable-cifsidmap],
39                         [Create cifs.idmap binary @<:@default=yes@:>@])],
40         enable_cifsidmap=$enableval,
41         enable_cifsidmap="maybe")
42
43 AC_ARG_ENABLE(cifsacl,
44         [AC_HELP_STRING([--enable-cifsacl],
45                         [Create get/set cifsacl binary @<:@default=yes@:>@])],
46         enable_cifsacl=$enableval,
47         enable_cifsacl="maybe")
48
49 AC_ARG_ENABLE(systemd,
50         [AC_HELP_STRING([--enable-systemd],
51                         [Enable systemd specific behavior for mount.cifs @<:@default=yes@:>@])],
52         enable_systemd=$enableval,
53         enable_systemd="maybe")
54
55 # "with" options
56 AC_ARG_WITH(idmap-plugin,
57         [AC_HELP_STRING([--with-idmap-plugin=/path/to/plugin],
58                         [Define the path to the plugin that the idmapping infrastructure should use @<:@default=/etc/cifs-utils/idmap-plugin@:>@])],
59         pluginpath=$withval,
60         pluginpath="/etc/cifs-utils/idmap-plugin")
61 AC_DEFINE_UNQUOTED(IDMAP_PLUGIN_PATH, "$pluginpath", [Location of plugin that ID mapping infrastructure should use. (usually a symlink to real plugin)])
62 AC_SUBST([pluginpath])
63
64 # check for ROOTSBINDIR environment var
65 if test -z $ROOTSBINDIR; then
66         ROOTSBINDIR="/sbin"
67         export ROOTSBINDIR
68 fi
69
70 AC_ARG_VAR(ROOTSBINDIR, [Location where files ordinarily under /sbin should be installed. Note: unaffected by --prefix. @<:@default=/sbin@:>@])
71
72 # Checks for programs.
73 AC_PROG_CC
74 AC_GNU_SOURCE
75 AM_PROG_CC_C_O
76
77 # AC_PROG_SED is only avaliable in recent autoconf versions.
78 # Use AC_CHECK_PROG instead if AC_PROG_SED is not present.
79 ifdef([AC_PROG_SED],
80       [AC_PROG_SED],
81       [AC_CHECK_PROG(SED, sed, sed)])
82
83 # Checks for typedefs, structures, and compiler characteristics.
84 AC_HEADER_STDBOOL
85 AC_TYPE_UID_T
86 AC_TYPE_OFF_T
87 AC_TYPE_PID_T
88 AC_TYPE_SIZE_T
89 AC_CHECK_TYPES([ptrdiff_t, ssize_t, uint32_t, uint8_t])
90
91 # Checks for library functions.
92 AC_FUNC_GETMNTENT
93 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
94 AC_FUNC_MALLOC
95 AC_FUNC_REALLOC
96 AC_FUNC_STRNLEN
97
98 # check for required functions
99 AC_CHECK_FUNCS([alarm atexit endpwent getmntent getpass gettimeofday inet_ntop memset realpath setenv strchr strcmp strdup strerror strncasecmp strndup strpbrk strrchr strstr strtol strtoul tolower uname], , [AC_MSG_ERROR([necessary functions(s) not found])])
100
101 AC_CHECK_FUNCS(clock_gettime, [], [
102   AC_CHECK_LIB(rt, clock_gettime, [
103       AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
104         AC_DEFINE(HAVE_CLOCK_GETTIME,1,
105                 [Whether the clock_gettime func is there])
106       RT_LDADD="-lrt"
107         ])
108   ])
109 AC_SUBST(RT_LDADD)
110
111 # Checks for header files.
112 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h inttypes.h limits.h mntent.h netdb.h stddef.h stdint.h stdbool.h stdlib.h stdio.h errno.h string.h strings.h sys/mount.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h], , [AC_MSG_ERROR([necessary header(s) not found])])
113
114 # do we have sys/fsuid.h and setfsuid()?
115 AC_CHECK_HEADERS([sys/fsuid.h])
116 AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])])
117
118 # FIXME: add test(s) to autodisable these flags when compiler/linker don't support it
119 if test $enable_pie != "no"; then
120         PIE_CFLAGS="-fpie -pie"
121 else
122         PIE_CFLAGS=""
123 fi
124 AC_SUBST([PIE_CFLAGS])
125
126 if test $enable_relro != "no"; then
127         RELRO_CFLAGS="-Wl,-z,relro,-z,now"
128 else
129         RELRO_CFLAGS=""
130 fi
131 AC_SUBST([RELRO_CFLAGS])
132
133 if test $enable_cifsupcall != "no"; then
134         AC_CHECK_HEADERS([krb5.h krb5/krb5.h])
135         if test x$ac_cv_header_krb5_krb5_h != xyes ; then
136                 if test x$ac_cv_header_krb5_h != xyes ; then
137                         if test "$enable_cifsupcall" = "yes"; then
138                                 AC_MSG_ERROR([krb5.h not found, consider installing krb5-libs-devel.])
139                         else
140                                 AC_MSG_WARN([krb5.h not found, consider installing krb5-libs-devel. Disabling cifs.upcall.])
141                                 enable_cifsupcall="no"
142                         fi
143                 fi
144         fi
145 fi
146 if test $enable_cifsupcall != "no"; then
147         if test x$ac_cv_header_krb5_krb5_h = xyes ; then
148                 krb5_include="#include <krb5/krb5.h>"
149         fi
150         if test x$ac_cv_header_krb5_h = xyes ; then
151                 krb5_include="#include <krb5.h>"
152         fi
153
154         AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
155                 [ac_cv_have_krb5_keyblock_keyvalue],[
156                         AC_TRY_COMPILE([$krb5_include],
157                         [krb5_keyblock key; key.keyvalue.data = NULL;],
158                         ac_cv_have_krb5_keyblock_keyvalue=yes,
159                         ac_cv_have_krb5_keyblock_keyvalue=no)])
160         if test x"$ac_cv_have_krb5_keyblock_keyvalue" = x"yes" ; then
161                 AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
162                         [Whether the krb5_keyblock struct has a keyvalue property])
163         fi
164 fi
165 if test $enable_cifsupcall != "no"; then
166         AC_CHECK_HEADERS([talloc.h], , [
167                                 if test "$enable_cifsupcall" = "yes"; then
168                                         AC_MSG_ERROR([talloc.h not found, consider installing libtalloc-devel.])
169                                 else
170                                         AC_MSG_WARN([talloc.h not found, consider installing libtalloc-devel. Disabling cifs.upcall.])
171                                         enable_cifsupcall="no"
172                                 fi
173                         ])
174 fi
175 if test $enable_cifsupcall != "no" -o $enable_cifsidmap != "no"; then
176         AC_CHECK_HEADERS([keyutils.h], , [
177                                 if test "$enable_cifsupcall" = "yes"; then
178                                         AC_MSG_ERROR([keyutils.h not found, consider installing keyutils-libs-devel.])
179                                 else
180                                         AC_MSG_WARN([keyutils.h not found, consider installing keyutils-libs-devel. Disabling cifs.upcall.])
181                                         enable_cifsupcall="no"
182                                 fi
183                                 if test "$enable_cifsidmap" = "yes"; then
184                                         AC_MSG_ERROR([keyutils.h not found, consider installing keyutils-libs-devel.])
185                                 else
186                                         AC_MSG_WARN([keyutils.h not found, consider installing keyutils-libs-devel. Disabling cifs.idmap.])
187                                         enable_cifsidmap="no"
188                                 fi
189                         ])
190 fi
191 if test $enable_cifsupcall != "no"; then
192         AC_CHECK_LIB([krb5], [krb5_init_context],
193                         [ KRB5_LDADD='-lkrb5' ],
194                         AC_MSG_ERROR([no functioning krb5 library found!]))
195         AC_SUBST(KRB5_LDADD)
196 fi
197
198 # checks for wbclient.h and libwbclient.so library
199 AC_TEST_WBCHL
200
201 # test for presence of WBC_ID_TYPE_BOTH enum value
202 AC_TEST_WBC_IDMAP_BOTH
203
204 if test $enable_cifscreds != "no"; then
205         AC_CHECK_HEADERS([keyutils.h], , [
206
207                                 if test $enable_cifscreds = "yes"; then
208                                         AC_MSG_ERROR([keyutils.h not found, consider installing keyutils-libs-devel.])
209                                 else
210                                         AC_MSG_WARN([keyutils.h not found, consider installing keyutils-libs-devel. Disabling cifscreds.])
211                                         enable_cifscreds="no"
212                                 fi
213                         ])
214 fi
215
216
217 # ugly, but I'm not sure how to check for functions in a library that's not in $LIBS
218 cu_saved_libs=$LIBS
219 LIBS="$LIBS $KRB5_LDADD"
220
221 # determine whether we can use MIT's new 'krb5_auth_con_getsendsubkey' to extract the signing key
222 if test $enable_cifsupcall != "no"; then
223         AC_CHECK_FUNCS([krb5_auth_con_getsendsubkey])
224 fi
225
226 # non-critical functions (we have workarounds for these)
227 if test $enable_cifsupcall != "no"; then
228         AC_CHECK_FUNCS([krb5_principal_get_realm krb5_free_unparsed_name])
229         AC_CHECK_FUNCS([krb5_auth_con_setaddrs krb5_auth_con_set_req_cksumtype])
230 fi
231
232 if test $enable_systemd != "no"; then
233         AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd specific behavior for mount.cifs])
234 fi
235
236 # MIT krb5 < 1.7 does not have this declaration but does have the symbol
237 AC_CHECK_DECLS(krb5_auth_con_set_req_cksumtype, [], [], [#include <krb5.h>])
238
239 LIBS=$cu_saved_libs
240
241 AM_CONDITIONAL(CONFIG_CIFSUPCALL, [test "$enable_cifsupcall" != "no"])
242 AM_CONDITIONAL(CONFIG_CIFSCREDS, [test "$enable_cifscreds" != "no"])
243 AM_CONDITIONAL(CONFIG_CIFSIDMAP, [test "$enable_cifsidmap" != "no"])
244 AM_CONDITIONAL(CONFIG_CIFSACL, [test "$enable_cifsacl" != "no"])
245 AM_CONDITIONAL(CONFIG_PLUGIN, [test "$enable_cifsidmap" != "no" -o "$enable_cifsacl" != "no"])
246
247 LIBCAP_NG_PATH
248
249 if test "x$CAPNG_LDADD" = "x"; then
250         AC_LIBCAP
251 fi
252 AC_OUTPUT