summaryrefslogtreecommitdiff
path: root/configure.in
blob: 2bc92f4268d83a68098bf47549c15644a073e442 (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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(quota.c)
AC_CONFIG_HEADERS([config.h])

dnl Checks for programs.
AC_PROG_CC
AC_HEADER_STDC
AC_PROG_INSTALL

dnl Check for compiler options
AC_ARG_ENABLE(static-link, [  --enable-static-link=[yes/no]        Link all binaries statically [default=no].],
	,
	enable_static_link="no")
if test "x$enable_static_link" != "xyes"; then
	AC_MSG_CHECKING(whether compiler supports PIE)
	oldCFLAGS="$CFLAGS"
	CFLAGS="$CFLAGS -fPIE"
	oldLDFLAGS="$LDFLAGS"
	LDFLAGS="$LDFLAGS -pie"
	AC_LINK_IFELSE([AC_LANG_PROGRAM([[]])], compilepie="yes")
	if test "x$compilepie" != "xyes"; then
		CFLAGS="$oldCFLAGS"
		LDFLAGS="$oldLDFLAGS"
		AC_MSG_RESULT(no)
	else
		AC_MSG_RESULT(yes)
	fi
else
	CFLAGS="$CFLAGS -static"
	LDFLAGS="$LDFLAGS -static"
fi

dnl Strip binaries before installation
AC_ARG_ENABLE(strip-binaries, [  --enable-strip-binaries=[yes/no] Strip binaries while installing them [default=yes].],
	,
	enable_strip="yes")
if test "x$enable_strip" = "xyes"; then
	STRIP="-s"
else
	STRIP=""
fi

dnl Checks for libraries.
AC_ARG_ENABLE(ldapmail, [  --enable-ldapmail=[yes/no/try]       Enable ldap mail address lookups [default=no].],
	,
	enable_ldapmail="no")
if test "x$enable_ldapmail" != "xno"; then
	have_new_ldap="no"
	have_old_ldap="no"
	AC_CHECK_LIB(ldap, ldap_initialize, have_new_ldap="yes", AC_CHECK_LIB(ldap, ldap_init, have_old_ldap="yes"))
	if test "x$have_new_ldap" != "xno" -o "x$have_old_ldap" != "xno"; then
		LDAPLIBS="-L/usr/lib -lldap -llber"
		AC_DEFINE([USE_LDAP_MAIL_LOOKUP], 1, [Lookup email address using LDAP])
		COMPILE_OPTS="$COMPILE_OPTS USE_LDAP_MAIL_LOOKUP"
		if test "x$have_new_ldap" = "xyes"; then
			AC_DEFINE([USE_LDAP_23], 1, [LDAP 2.3 or newer installed])
			AC_CHECK_DECL(ldap_perror, ,
				      AC_DEFINE([NEED_LDAP_PERROR], 1, [ldap_perror function not declared]),
				      [#include <ldap.h>])
		fi
	else
		if test "x$enable_ldapmail" = "xyes"; then
			AC_MSG_ERROR([LDAP support required but library not found.]);
		fi
	fi
fi
AC_SUBST(LDAPLIBS)

	
AC_CHECK_HEADER(ext2fs/ext2fs.h,ext2fshead="yes")
if test "x$ext2fshead" = "xyes"; then
	AC_DEFINE([HAVE_EXT2_INCLUDE], 1, [Header files for e2fslib])
	AC_MSG_CHECKING([for ext2_ino_t])
	have_ext2_ino_t="no"
	AC_EGREP_HEADER(ext2_ino_t, ext2fs/ext2fs.h, have_ext2_ino_t="yes")
	if test "x$have_ext2_ino_t" != "xyes"; then
		AC_MSG_RESULT([not found])
	else
		AC_MSG_RESULT([found])
		AC_DEFINE([HAVE_EXT2_INO_T], 1, [ext2fs.h defines ext2_ino_t])
	fi
fi

AC_ARG_ENABLE(ext2direct,
	[  --enable-ext2direct=[yes/no/try]     Enable scanning of EXT2/EXT3 filesystem using e2fslib [default=try].],
	,
	enable_ext2direct="try")
if test "x$enable_ext2direct" != "xno"; then
	AC_CHECK_LIB(com_err, com_err, EXT2LIBS="-lcom_err $EXT2LIBS")
	AC_CHECK_LIB(ext2fs, ext2fs_initialize, EXT2LIBS="-lext2fs $EXT2LIBS",, "-lcom_err")
	if test "${ac_cv_lib_com_err_com_err}" != "yes" -o "${ac_cv_lib_ext2fs_ext2fs_initialize}" != "yes"; then
		if test "x$enable_ext2direct" = "xyes"; then
			AC_MSG_ERROR([Ext2 direct support required but libraries not found.])
		else
			AC_MSG_WARN([Ext2 direct support won't be compiled. Libraries not found.])
		fi
		enable_ext2direct="no"
		EXT2LIBS=""
	else
		if test "x$ext2fshead" != "xyes"; then
			if test "x$enable_ext2direct" = "xyes"; then
				AC_MSG_ERROR([Ext2 direct support required but header files not found.])
			else
				AC_MSG_WARN([Ext2 direct support won't be compiled. Header files not found.])
			fi
			enable_ext2direct="no"
			EXT2LIBS=""
		else
			enable_ext2direct="yes"
		fi
	fi
	if test "x$enable_ext2direct" = "xyes"; then
		AC_DEFINE([EXT2_DIRECT], 1, [Scanning of ext? filesystems using e2fslib])
		COMPILE_OPTS="$COMPILE_OPTS EXT2_DIRECT"
	fi
fi
AC_SUBST(EXT2LIBS)

AC_ARG_ENABLE(netlink,
	[  --enable-netlink=[yes/no/try]   Compile daemon receiving quota messages via netlink [default=no].],
	,
	enable_netlink="no")
if test "x$enable_netlink" != "xno"; then
	PKG_CHECK_MODULES([DBUS], [dbus-1])

	AC_CHECK_LIB(nl, genl_register, NETLINKLIBS="-lnl $DBUS_LIBS")
	if test -z "$NETLINKLIBS" -o -z "$DBUS_LIBS"; then
		if test "x$enable_netlink" = "xyes"; then
			AC_MSG_ERROR([Required libraries for quota netlink daemon not found.])
		else
			AC_MSG_WARN([Quota netlink daemon won't be compiled. Required libraries not found.])
		fi
		enable_netlink="no"
		NETLINKLIBS=""
	else
		CPPFLAGS="$DBUS_CFLAGS $CPPFLAGS"
		if test -z "$DBUS_LIBS"; then
			if test "x$enable_netlink" = "xyes"; then
				AC_MSG_ERROR([Required headers for quota netlink daemon not found.])
			else
				AC_MSG_WARN([Quota netlink daemon won't be compiled. Required headers not found.])
			fi
			NETLINKLIBS=""
			enable_netlink="no"
		else
			QUOTA_NETLINK_PROG=quota_nld
		fi
	fi
fi
AC_SUBST(QUOTA_NETLINK_PROG)
AC_SUBST(NETLINKLIBS)

AC_SEARCH_LIBS(gethostbyname, nsl)
AC_MSG_CHECKING(for host_access in -lwrap)
AC_CACHE_VAL(ac_cv_lib_wrap_main,
	saved_LIBS="$LIBS"
	LIBS="$LIBS -lwrap"
	[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
	#include <stdio.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <tcpd.h>
	struct request_info request;
	int deny_severity, allow_severity;]],[[hosts_access(&request);]])],
	dnl We always restore LIBS as we add -lwrap in the next check
	[ac_cv_lib_wrap_main=yes; LIBS="$saved_LIBS"; AC_MSG_RESULT(yes)],
	[ac_cv_lib_wrap_main=no; LIBS="$saved_LIBS"; AC_MSG_RESULT(no)])
	])

if test ${ac_cv_lib_wrap_main} = yes; then
	AC_CHECK_HEADER(tcpd.h,, [
		echo 'ERROR: could not find tcpd.h - missing TCP wrappers package'
		exit 1
	])
	LIBS="$LIBS -lwrap"
	AC_DEFINE([HOSTS_ACCESS], 1, [Use hosts.allow and hosts.deny for access checking of rpc.rquotad])
	COMPILE_OPTS="$COMPILE_OPTS HOSTS_ACCESS"
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE

AC_ARG_ENABLE(altformat,
	[  --enable-altformat=[yes/no]     Enable alternative format used by edquota [default=yes].],
	,
	enable_altformat="yes")
AC_ARG_ENABLE(rpc,
	[  --enable-rpc=[yes/no]           Enable RPC support [default=yes].],
	,
	enable_rpc="yes")
AC_ARG_ENABLE(rpcsetquota,
	[  --enable-rpcsetquota=[yes/no]   Use RPC for setting quotas [default=no].],
	,
	enable_rpcsetquota="no")
AC_ARG_ENABLE(xfs_roothack,
	[  --enable-xfs_roothack=[yes/no]  Support old XFS root filesystems [default=no].],
	,
	enable_xfs_roothack="no")
AC_ARG_ENABLE(bsd_behaviour,
	[  --enable-bsd_behaviour=[yes/no] Mimic BSD behaviour [default=yes].],
	,
	enable_bsd_behaviour="yes")
AC_ARG_ENABLE(libefence,
	[  --enable-libefence=[yes/no]     Use Electric Fence memory checks [default=no].],
	,
	enable_libefence="no")

AC_ARG_ENABLE(nls,
	[  --enable-nls=[yes/no]           Enable gettext [default=yes].],
	,
	enable_nls="yes")
AC_ARG_ENABLE(rootsbin,
	[  --enable-rootsbin=[yes/no]      Use /sbin for some important binaries regardless $prefix [default=no].],
	,
	enable_rootsbin="no")
AC_ARG_ENABLE(proc-mounts,
	[  --enable-proc-mounts=[path]   Use alternate file instead of /etc/mtab [default=/proc/mounts].],
	,
	enable_proc_mounts="/proc/mounts")

if test "$enable_altformat" = "yes" ; then
	AC_DEFINE([ALT_FORMAT], 1, [Alternative file format of edquota])
	COMPILE_OPTS="$COMPILE_OPTS ALT_FORMAT"
fi
if test "$enable_rpc" = "yes" ; then
	AC_DEFINE([RPC], 1, [Support for RPC])
	COMPILE_OPTS="$COMPILE_OPTS RPC"
fi
if test "$enable_rpcsetquota" = "yes" ; then
	AC_DEFINE([RPC_SETQUOTA], 1, [Allow setting of quotas over RPC])
	COMPILE_OPTS="$COMPILE_OPTS RPC_SETQUOTA"
fi
if test "$enable_xfs_roothack" = "yes" ; then
	AC_DEFINE([XFS_ROOTHACK], 1, [Assume quota mount options for root filesystem])
	COMPILE_OPTS="$COMPILE_OPTS XFS_ROOTHACK"
fi
if test "$enable_bsd_behaviour" = "yes" ; then
	AC_DEFINE([BSD_BEHAVIOUR], 1, [Check rights to query / set quotas before calling quotactl])
	COMPILE_OPTS="$COMPILE_OPTS BSD_BEHAVIOUR"
fi
if test "$enable_libefence" = "yes" ; then
	LIBMALLOC="/usr/lib/libefence.a"
fi
if test "$enable_nls" = "yes" ; then
	AC_DEFINE([USE_GETTEXT], 1, [Use gettext to translate messages])
	INSTMO="inst_mo"
fi
if test "$enable_proc_mounts" != "no"; then
	AC_DEFINE_UNQUOTED([ALT_MTAB], ["$enable_proc_mounts"], [File with mounted filesystems])
fi
if test "$enable_rootsbin" = "yes" ; then
	ROOTSBIN="/sbin"
else
	ROOTSBIN='$(prefix)/sbin'
fi

AC_DEFINE_UNQUOTED([COMPILE_OPTS], ["$COMPILE_OPTS"], [Configuration options])
AC_DEFINE([PACKAGE_VERSION], ["4.00"], [Version of quota tools])

AC_SUBST(LIBMALLOC)
AC_SUBST(INSTMO)
AC_SUBST(ROOTSBIN)
AC_SUBST(CPPFLAGS)
AC_SUBST(STRIP)

AC_OUTPUT(Makefile)