Update to 4.01.
[profile/ivi/quota.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(quota.c)
3 AC_CONFIG_HEADERS([config.h])
4
5 dnl Checks for programs.
6 AC_PROG_CC
7 AC_HEADER_STDC
8 AC_PROG_INSTALL
9
10 dnl Check for compiler options
11 AC_ARG_ENABLE(static-link, [  --enable-static-link=[yes/no]        Link all binaries statically [default=no].],
12         ,
13         enable_static_link="no")
14 if test "x$enable_static_link" != "xyes"; then
15         AC_MSG_CHECKING(whether compiler supports PIE)
16         oldCFLAGS="$CFLAGS"
17         CFLAGS="$CFLAGS -fPIE"
18         oldLDFLAGS="$LDFLAGS"
19         LDFLAGS="$LDFLAGS -pie"
20         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]])], compilepie="yes")
21         if test "x$compilepie" != "xyes"; then
22                 CFLAGS="$oldCFLAGS"
23                 LDFLAGS="$oldLDFLAGS"
24                 AC_MSG_RESULT(no)
25         else
26                 AC_MSG_RESULT(yes)
27         fi
28 else
29         CFLAGS="$CFLAGS -static"
30         LDFLAGS="$LDFLAGS -static"
31 fi
32
33 dnl Strip binaries before installation
34 AC_ARG_ENABLE(strip-binaries, [  --enable-strip-binaries=[yes/no] Strip binaries while installing them [default=yes].],
35         ,
36         enable_strip="yes")
37 if test "x$enable_strip" = "xyes"; then
38         STRIP="-s"
39 else
40         STRIP=""
41 fi
42
43 dnl Checks for libraries.
44 AC_ARG_ENABLE(ldapmail, [  --enable-ldapmail=[yes/no/try]       Enable ldap mail address lookups [default=no].],
45         ,
46         enable_ldapmail="no")
47 if test "x$enable_ldapmail" != "xno"; then
48         have_new_ldap="no"
49         have_old_ldap="no"
50         AC_CHECK_LIB(ldap, ldap_initialize, have_new_ldap="yes", AC_CHECK_LIB(ldap, ldap_init, have_old_ldap="yes"))
51         if test "x$have_new_ldap" != "xno" -o "x$have_old_ldap" != "xno"; then
52                 LDAPLIBS="-L/usr/lib -lldap -llber"
53                 AC_DEFINE([USE_LDAP_MAIL_LOOKUP], 1, [Lookup email address using LDAP])
54                 COMPILE_OPTS="$COMPILE_OPTS USE_LDAP_MAIL_LOOKUP"
55                 if test "x$have_new_ldap" = "xyes"; then
56                         AC_DEFINE([USE_LDAP_23], 1, [LDAP 2.3 or newer installed])
57                         AC_CHECK_DECL(ldap_perror, ,
58                                       AC_DEFINE([NEED_LDAP_PERROR], 1, [ldap_perror function not declared]),
59                                       [#include <ldap.h>])
60                 fi
61         else
62                 if test "x$enable_ldapmail" = "xyes"; then
63                         AC_MSG_ERROR([LDAP support required but library not found.]);
64                 fi
65         fi
66 fi
67 AC_SUBST(LDAPLIBS)
68
69         
70 AC_CHECK_HEADER(ext2fs/ext2fs.h,ext2fshead="yes")
71 if test "x$ext2fshead" = "xyes"; then
72         AC_DEFINE([HAVE_EXT2_INCLUDE], 1, [Header files for e2fslib])
73         AC_MSG_CHECKING([for ext2_ino_t])
74         have_ext2_ino_t="no"
75         AC_EGREP_HEADER(ext2_ino_t, ext2fs/ext2fs.h, have_ext2_ino_t="yes")
76         if test "x$have_ext2_ino_t" != "xyes"; then
77                 AC_MSG_RESULT([not found])
78         else
79                 AC_MSG_RESULT([found])
80                 AC_DEFINE([HAVE_EXT2_INO_T], 1, [ext2fs.h defines ext2_ino_t])
81         fi
82 fi
83
84 AC_ARG_ENABLE(ext2direct,
85         [  --enable-ext2direct=[yes/no/try]     Enable scanning of EXT2/EXT3 filesystem using e2fslib [default=try].],
86         ,
87         enable_ext2direct="try")
88 if test "x$enable_ext2direct" != "xno"; then
89         AC_CHECK_LIB(com_err, com_err, EXT2LIBS="-lcom_err $EXT2LIBS")
90         AC_CHECK_LIB(ext2fs, ext2fs_initialize, EXT2LIBS="-lext2fs $EXT2LIBS",, "-lcom_err")
91         if test "${ac_cv_lib_com_err_com_err}" != "yes" -o "${ac_cv_lib_ext2fs_ext2fs_initialize}" != "yes"; then
92                 if test "x$enable_ext2direct" = "xyes"; then
93                         AC_MSG_ERROR([Ext2 direct support required but libraries not found.])
94                 else
95                         AC_MSG_WARN([Ext2 direct support won't be compiled. Libraries not found.])
96                 fi
97                 enable_ext2direct="no"
98                 EXT2LIBS=""
99         else
100                 if test "x$ext2fshead" != "xyes"; then
101                         if test "x$enable_ext2direct" = "xyes"; then
102                                 AC_MSG_ERROR([Ext2 direct support required but header files not found.])
103                         else
104                                 AC_MSG_WARN([Ext2 direct support won't be compiled. Header files not found.])
105                         fi
106                         enable_ext2direct="no"
107                         EXT2LIBS=""
108                 else
109                         enable_ext2direct="yes"
110                 fi
111         fi
112         if test "x$enable_ext2direct" = "xyes"; then
113                 AC_DEFINE([EXT2_DIRECT], 1, [Scanning of ext? filesystems using e2fslib])
114                 COMPILE_OPTS="$COMPILE_OPTS EXT2_DIRECT"
115         fi
116 fi
117 AC_SUBST(EXT2LIBS)
118
119 AC_ARG_ENABLE(netlink,
120         [  --enable-netlink=[yes/no/try]   Compile daemon receiving quota messages via netlink [default=no].],
121         ,
122         enable_netlink="no")
123 if test "x$enable_netlink" != "xno"; then
124         PKG_CHECK_MODULES([DBUS], [dbus-1])
125
126         AC_CHECK_LIB(nl, genl_register, NETLINKLIBS="-lnl $DBUS_LIBS")
127         if test -z "$NETLINKLIBS" -o -z "$DBUS_LIBS"; then
128                 if test "x$enable_netlink" = "xyes"; then
129                         AC_MSG_ERROR([Required libraries for quota netlink daemon not found.])
130                 else
131                         AC_MSG_WARN([Quota netlink daemon won't be compiled. Required libraries not found.])
132                 fi
133                 enable_netlink="no"
134                 NETLINKLIBS=""
135         else
136                 CPPFLAGS="$DBUS_CFLAGS $CPPFLAGS"
137                 if test -z "$DBUS_LIBS"; then
138                         if test "x$enable_netlink" = "xyes"; then
139                                 AC_MSG_ERROR([Required headers for quota netlink daemon not found.])
140                         else
141                                 AC_MSG_WARN([Quota netlink daemon won't be compiled. Required headers not found.])
142                         fi
143                         NETLINKLIBS=""
144                         enable_netlink="no"
145                 else
146                         QUOTA_NETLINK_PROG=quota_nld
147                 fi
148         fi
149 fi
150 AC_SUBST(QUOTA_NETLINK_PROG)
151 AC_SUBST(NETLINKLIBS)
152
153 AC_SEARCH_LIBS(gethostbyname, nsl)
154 AC_MSG_CHECKING(for host_access in -lwrap)
155 AC_CACHE_VAL(ac_cv_lib_wrap_main,
156         saved_LIBS="$LIBS"
157         LIBS="$LIBS -lwrap"
158         [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
159         #include <stdio.h>
160         #include <sys/types.h>
161         #include <sys/socket.h>
162         #include <netinet/in.h>
163         #include <tcpd.h>
164         struct request_info request;
165         int deny_severity, allow_severity;]],[[hosts_access(&request);]])],
166         dnl We always restore LIBS as we add -lwrap in the next check
167         [ac_cv_lib_wrap_main=yes; LIBS="$saved_LIBS"; AC_MSG_RESULT(yes)],
168         [ac_cv_lib_wrap_main=no; LIBS="$saved_LIBS"; AC_MSG_RESULT(no)])
169         ])
170
171 if test ${ac_cv_lib_wrap_main} = yes; then
172         AC_CHECK_HEADER(tcpd.h,, [
173                 echo 'ERROR: could not find tcpd.h - missing TCP wrappers package'
174                 exit 1
175         ])
176         LIBS="$LIBS -lwrap"
177         AC_DEFINE([HOSTS_ACCESS], 1, [Use hosts.allow and hosts.deny for access checking of rpc.rquotad])
178         COMPILE_OPTS="$COMPILE_OPTS HOSTS_ACCESS"
179 fi
180
181 dnl Checks for typedefs, structures, and compiler characteristics.
182 AC_C_CONST
183 AC_C_INLINE
184
185 AC_ARG_ENABLE(rpc,
186         [  --enable-rpc=[yes/no]           Enable RPC support [default=yes].],
187         ,
188         enable_rpc="yes")
189 AC_ARG_ENABLE(rpcsetquota,
190         [  --enable-rpcsetquota=[yes/no]   Use RPC for setting quotas [default=no].],
191         ,
192         enable_rpcsetquota="no")
193 AC_ARG_ENABLE(xfs_roothack,
194         [  --enable-xfs_roothack=[yes/no]  Support old XFS root filesystems [default=no].],
195         ,
196         enable_xfs_roothack="no")
197 AC_ARG_ENABLE(bsd_behaviour,
198         [  --enable-bsd_behaviour=[yes/no] Mimic BSD behaviour [default=yes].],
199         ,
200         enable_bsd_behaviour="yes")
201 AC_ARG_ENABLE(libefence,
202         [  --enable-libefence=[yes/no]     Use Electric Fence memory checks [default=no].],
203         ,
204         enable_libefence="no")
205
206 AC_ARG_ENABLE(nls,
207         [  --enable-nls=[yes/no]           Enable gettext [default=yes].],
208         ,
209         enable_nls="yes")
210 AC_ARG_ENABLE(rootsbin,
211         [  --enable-rootsbin=[yes/no]      Use /sbin for some important binaries regardless $prefix [default=no].],
212         ,
213         enable_rootsbin="no")
214 AC_ARG_ENABLE(proc-mounts,
215         [  --enable-proc-mounts=[path]   Use alternate file instead of /etc/mtab [default=/proc/mounts].],
216         ,
217         enable_proc_mounts="/proc/mounts")
218
219 if test "$enable_rpc" = "yes" ; then
220         AC_DEFINE([RPC], 1, [Support for RPC])
221         COMPILE_OPTS="$COMPILE_OPTS RPC"
222 fi
223 if test "$enable_rpcsetquota" = "yes" ; then
224         AC_DEFINE([RPC_SETQUOTA], 1, [Allow setting of quotas over RPC])
225         COMPILE_OPTS="$COMPILE_OPTS RPC_SETQUOTA"
226 fi
227 if test "$enable_xfs_roothack" = "yes" ; then
228         AC_DEFINE([XFS_ROOTHACK], 1, [Assume quota mount options for root filesystem])
229         COMPILE_OPTS="$COMPILE_OPTS XFS_ROOTHACK"
230 fi
231 if test "$enable_bsd_behaviour" = "yes" ; then
232         AC_DEFINE([BSD_BEHAVIOUR], 1, [Check rights to query / set quotas before calling quotactl])
233         COMPILE_OPTS="$COMPILE_OPTS BSD_BEHAVIOUR"
234 fi
235 if test "$enable_libefence" = "yes" ; then
236         LIBMALLOC="/usr/lib/libefence.a"
237 fi
238 if test "$enable_nls" = "yes" ; then
239         AC_DEFINE([USE_GETTEXT], 1, [Use gettext to translate messages])
240         INSTMO="inst_mo"
241 fi
242 if test "$enable_proc_mounts" != "no"; then
243         AC_DEFINE_UNQUOTED([ALT_MTAB], ["$enable_proc_mounts"], [File with mounted filesystems])
244 fi
245 if test "$enable_rootsbin" = "yes" ; then
246         ROOTSBIN="/sbin"
247 else
248         ROOTSBIN='$(prefix)/sbin'
249 fi
250
251 AC_DEFINE_UNQUOTED([COMPILE_OPTS], ["$COMPILE_OPTS"], [Configuration options])
252 AC_DEFINE([PACKAGE_VERSION], ["4.01"], [Version of quota tools])
253
254 AC_SUBST(LIBMALLOC)
255 AC_SUBST(INSTMO)
256 AC_SUBST(ROOTSBIN)
257 AC_SUBST(CPPFLAGS)
258 AC_SUBST(STRIP)
259
260 AC_OUTPUT(Makefile)