aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: b0bc2b9d135ce21c0e5bad5e8236eebaefe83c1e (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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT([cifs-utils],[6.8],[linux-cifs@vger.kernel.org],[cifs-utils],[https://wiki.samba.org/index.php/LinuxCIFS_utils])
AC_CONFIG_SRCDIR([data_blob.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile contrib/Makefile contrib/request-key.d/Makefile])
AC_CONFIG_MACRO_DIR(aclocal)

AM_INIT_AUTOMAKE

# "enable" options
AC_ARG_ENABLE(pie,
	[AS_HELP_STRING([--enable-pie],[Produce position independent executables @<:@default=yes@:>@])],
	enable_pie=$enableval,
	enable_pie="maybe")

AC_ARG_ENABLE(relro,
	[AS_HELP_STRING([--enable-relro],[Enable relocations read-only support @<:@default=yes@:>@])],
	enable_relro=$enableval,
	enable_relro="maybe")

AC_ARG_ENABLE(cifsupcall,
	[AS_HELP_STRING([--enable-cifsupcall],[Create cifs.upcall binary @<:@default=yes@:>@])],
	enable_cifsupcall=$enableval,
	enable_cifsupcall="maybe")

AC_ARG_ENABLE(cifscreds,
	[AS_HELP_STRING([--enable-cifscreds],[Create cifscreds utility @<:@default=yes@:>@])],
	enable_cifscreds=$enableval,
	enable_cifscreds="maybe")

AC_ARG_ENABLE(cifsidmap,
	[AS_HELP_STRING([--enable-cifsidmap],[Create cifs.idmap binary @<:@default=yes@:>@])],
	enable_cifsidmap=$enableval,
	enable_cifsidmap="maybe")

AC_ARG_ENABLE(cifsacl,
	[AS_HELP_STRING([--enable-cifsacl],[Create get/set cifsacl binary @<:@default=yes@:>@])],
	enable_cifsacl=$enableval,
	enable_cifsacl="maybe")

AC_ARG_ENABLE(pam,
	[AS_HELP_STRING([--enable-pam],[Create cifscreds PAM module @<:@default=yes@:>@])],
	enable_pam=$enableval,
	enable_pam="maybe")

AC_ARG_ENABLE(systemd,
	[AS_HELP_STRING([--enable-systemd],[Enable systemd specific behavior for mount.cifs @<:@default=yes@:>@])],
	enable_systemd=$enableval,
	enable_systemd="maybe")

AC_ARG_ENABLE(man,
	[AS_HELP_STRING([--enable-man],[Enable generation and installation of man pages @<:@default=yes@:>@])],
	enable_man=$enableval,
	enable_man="maybe")

# "with" options
AC_ARG_WITH(idmap-plugin,
	[AS_HELP_STRING([--with-idmap-plugin=/path/to/plugin],[Define the path to the plugin that the idmapping infrastructure should use @<:@default=/etc/cifs-utils/idmap-plugin@:>@])],
	pluginpath=$withval,
	pluginpath="/etc/cifs-utils/idmap-plugin")
AC_DEFINE_UNQUOTED(IDMAP_PLUGIN_PATH, "$pluginpath", [Location of plugin that ID mapping infrastructure should use. (usually a symlink to real plugin)])
AC_SUBST([pluginpath])

AC_ARG_WITH(pamdir,
	[AC_HELP_STRING([--with-pamdir=DIR],[Where to install the PAM module @<:@default=$(libdir)/security@:>@])],
	pamdir=$withval,
	pamdir="\$(libdir)/security")
AC_SUBST([pamdir])

# check for ROOTSBINDIR environment var
if test -z $ROOTSBINDIR; then
	ROOTSBINDIR="/sbin"
	export ROOTSBINDIR
fi

AC_ARG_VAR(ROOTSBINDIR, [Location where files ordinarily under /sbin should be installed. Note: unaffected by --prefix. @<:@default=/sbin@:>@])

# Checks for programs.
AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
AM_PROG_CC_C_O

# AC_PROG_SED is only avaliable in recent autoconf versions.
# Use AC_CHECK_PROG instead if AC_PROG_SED is not present.
ifdef([AC_PROG_SED],
      [AC_PROG_SED],
      [AC_CHECK_PROG(SED, sed, sed)])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_UID_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_TYPES([ptrdiff_t, ssize_t, uint32_t, uint8_t])

# Checks for library functions.
AC_FUNC_GETMNTENT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRNLEN

# check for required functions
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])])

AC_CHECK_FUNCS(clock_gettime, [], [
  AC_CHECK_LIB(rt, clock_gettime, [
      AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
	AC_DEFINE(HAVE_CLOCK_GETTIME,1,
		[Whether the clock_gettime func is there])
      RT_LDADD="-lrt"
        ])
  ])
AC_SUBST(RT_LDADD)

# Checks for header files.
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])])

# do we have sys/fsuid.h and setfsuid()?
AC_CHECK_HEADERS([sys/fsuid.h])
AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])])

# FIXME: add test(s) to autodisable these flags when compiler/linker don't support it
if test $enable_pie != "no"; then
	PIE_CFLAGS="-fpie -pie"
else
	PIE_CFLAGS=""
fi
AC_SUBST([PIE_CFLAGS])

if test $enable_relro != "no"; then
	RELRO_CFLAGS="-Wl,-z,relro,-z,now"
else
	RELRO_CFLAGS=""
fi
AC_SUBST([RELRO_CFLAGS])

if test $enable_cifsupcall != "no"; then
	AC_CHECK_HEADERS([krb5.h krb5/krb5.h])
	if test x$ac_cv_header_krb5_krb5_h != xyes ; then
		if test x$ac_cv_header_krb5_h != xyes ; then
			if test "$enable_cifsupcall" = "yes"; then
				AC_MSG_ERROR([krb5.h not found, consider installing krb5-devel or krb5-libs-devel.])
			else
				AC_MSG_WARN([krb5.h not found, consider installing krb5-devel or krb5-libs-devel. Disabling cifs.upcall.])
				enable_cifsupcall="no"
			fi
		fi
	fi
fi
if test $enable_cifsupcall != "no"; then
	if test x$ac_cv_header_krb5_krb5_h = xyes ; then
		krb5_include="#include <krb5/krb5.h>"
	fi
	if test x$ac_cv_header_krb5_h = xyes ; then
		krb5_include="#include <krb5.h>"
	fi

	AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
		[ac_cv_have_krb5_keyblock_keyvalue],[
			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$krb5_include]], [[krb5_keyblock key; key.keyvalue.data = NULL;]])],[ac_cv_have_krb5_keyblock_keyvalue=yes],[ac_cv_have_krb5_keyblock_keyvalue=no])])
	if test x"$ac_cv_have_krb5_keyblock_keyvalue" = x"yes" ; then
		AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
			[Whether the krb5_keyblock struct has a keyvalue property])
	fi
fi
if test $enable_cifsupcall != "no"; then
	AC_CHECK_HEADERS([talloc.h], , [
				if test "$enable_cifsupcall" = "yes"; then
					AC_MSG_ERROR([talloc.h not found, consider installing libtalloc-devel.])
				else
					AC_MSG_WARN([talloc.h not found, consider installing libtalloc-devel. Disabling cifs.upcall.])
					enable_cifsupcall="no"
				fi
			])
fi
if test $enable_cifsupcall != "no" -o $enable_cifsidmap != "no"; then
	AC_CHECK_HEADERS([keyutils.h], , [
				if test "$enable_cifsupcall" = "yes"; then
					AC_MSG_ERROR([keyutils.h not found, consider installing keyutils-libs-devel.])
				else
					AC_MSG_WARN([keyutils.h not found, consider installing keyutils-libs-devel. Disabling cifs.upcall.])
					enable_cifsupcall="no"
				fi
				if test "$enable_cifsidmap" = "yes"; then
					AC_MSG_ERROR([keyutils.h not found, consider installing keyutils-libs-devel.])
				else
					AC_MSG_WARN([keyutils.h not found, consider installing keyutils-libs-devel. Disabling cifs.idmap.])
					enable_cifsidmap="no"
				fi
			])
fi
if test $enable_cifsupcall != "no"; then
	AC_CHECK_LIB([krb5], [krb5_init_context],
			[ KRB5_LDADD='-lkrb5' ],
			AC_MSG_ERROR([no functioning krb5 library found!]))
	AC_SUBST(KRB5_LDADD)
fi

# checks for wbclient.h and libwbclient.so library
AC_TEST_WBCHL

# test for presence of WBC_ID_TYPE_BOTH enum value
AC_TEST_WBC_IDMAP_BOTH

if test $enable_cifscreds != "no" -o $enable_pam != "no"; then
	AC_CHECK_HEADERS([keyutils.h], , [

				if test $enable_cifscreds = "yes" -o $enable_pam = "yes"; then
					AC_MSG_ERROR([keyutils.h not found, consider installing keyutils-libs-devel.])
				else
					AC_MSG_WARN([keyutils.h not found, consider installing keyutils-libs-devel. Disabling cifscreds and cifscreds PAM module.])
					enable_cifscreds="no"
					enable_pam="no"
				fi
			])
fi

if test $enable_pam != "no"; then
	AC_CHECK_HEADERS([security/pam_appl.h], , [

				if test $enable_pam = "yes"; then
					AC_MSG_ERROR([security/pam_appl.h not found, consider installing keyutils-libs-devel.])
				else
					AC_MSG_WARN([security/pam_appl.h not found, consider installing pam-devel. Disabling cifscreds PAM module.])
					enable_pam="no"
				fi
			])
fi

# ugly, but I'm not sure how to check for functions in a library that's not in $LIBS
cu_saved_libs=$LIBS
LIBS="$LIBS $KRB5_LDADD"

# determine whether we can use MIT's new 'krb5_auth_con_getsendsubkey' to extract the signing key
if test $enable_cifsupcall != "no"; then
	AC_CHECK_FUNCS([krb5_auth_con_getsendsubkey])
fi

# non-critical functions (we have workarounds for these)
if test $enable_cifsupcall != "no"; then
	AC_CHECK_FUNCS([krb5_principal_get_realm krb5_free_unparsed_name])
	AC_CHECK_FUNCS([krb5_auth_con_setaddrs krb5_auth_con_set_req_cksumtype])
fi

if test $enable_systemd != "no"; then
	AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd specific behavior for mount.cifs])
fi

# if docs are not disabled, check if rst2man is available
if test $enable_man != "no"; then
	AC_CHECK_PROG(have_rst2man, rst2man, yes, no)
	if test $have_rst2man = "no"; then
		if test $enable_man = "yes"; then
			AC_MSG_ERROR([rst2man not found: cannot generate man pages, consider installing perl.])
		else
			AC_MSG_WARN([rst2man not found: cannot generate man pages, consider installing perl. Disabling man page generation.])
			enable_man="no"
		fi
	else
		enable_man="yes"
	fi
fi

# MIT krb5 < 1.7 does not have this declaration but does have the symbol
AC_CHECK_DECLS(krb5_auth_con_set_req_cksumtype, [], [], [#include <krb5.h>])

LIBS=$cu_saved_libs

AM_CONDITIONAL(CONFIG_MAN, [test "$enable_man" != "no"])
AM_CONDITIONAL(CONFIG_CIFSUPCALL, [test "$enable_cifsupcall" != "no"])
AM_CONDITIONAL(CONFIG_CIFSCREDS, [test "$enable_cifscreds" != "no"])
AM_CONDITIONAL(CONFIG_CIFSIDMAP, [test "$enable_cifsidmap" != "no"])
AM_CONDITIONAL(CONFIG_CIFSACL, [test "$enable_cifsacl" != "no"])
AM_CONDITIONAL(CONFIG_PAM, [test "$enable_pam" != "no"])
AM_CONDITIONAL(CONFIG_PLUGIN, [test "$enable_cifsidmap" != "no" -o "$enable_cifsacl" != "no"])

LIBCAP_NG_PATH

if test "x$CAPNG_LDADD" = "x"; then
	AC_LIBCAP
fi
AC_OUTPUT