]> granicus.if.org Git - shadow/blob - configure.in
Split check_perms() out of main().
[shadow] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AM_INIT_AUTOMAKE(shadow, 4.1.0)
4 AC_CONFIG_HEADERS([config.h])
5
6 dnl Some hacks...
7 test "$prefix" = "NONE" && prefix="/usr"
8 test "$prefix" = "/usr" && exec_prefix=""
9
10 AC_GNU_SOURCE
11
12 AM_DISABLE_SHARED
13 AM_ENABLE_STATIC
14
15 AM_MAINTAINER_MODE
16
17 dnl Checks for programs.
18 AC_PROG_CC
19 AC_ISC_POSIX
20 AC_PROG_LN_S
21 AC_PROG_YACC
22 AM_C_PROTOTYPES
23 AM_PROG_LIBTOOL
24
25 dnl Checks for libraries.
26
27 dnl Checks for header files.
28 AC_HEADER_DIRENT
29 AC_HEADER_STDC
30 AC_HEADER_SYS_WAIT
31
32 AC_CHECK_HEADERS(errno.h fcntl.h limits.h unistd.h sys/time.h utmp.h \
33         utmpx.h termios.h termio.h sgtty.h sys/ioctl.h syslog.h paths.h \
34         utime.h ulimit.h sys/resource.h gshadow.h shadow.h lastlog.h \
35         locale.h rpc/key_prot.h netdb.h)
36
37 AC_CHECK_FUNCS(l64a fchmod fchown fsync getgroups gethostname getspnam \
38         gettimeofday getusershell getutent initgroups lchown lckpwdf lstat \
39         memcpy memset setgroups sigaction strchr updwtmp updwtmpx innetgr \
40         getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r)
41 AC_SYS_LARGEFILE
42
43 dnl Checks for typedefs, structures, and compiler characteristics.
44 AC_C_CONST
45 AC_TYPE_UID_T
46 AC_TYPE_OFF_T
47 AC_TYPE_PID_T
48 AC_TYPE_MODE_T
49 AC_HEADER_STAT
50 AC_CHECK_MEMBERS([struct stat.st_rdev])
51 AC_HEADER_TIME
52 AC_STRUCT_TM
53
54 if test "$ac_cv_header_utmp_h" = "yes"; then
55         AC_CACHE_CHECK(for ut_host in struct utmp,
56                 ac_cv_struct_utmp_ut_host,
57                 AC_COMPILE_IFELSE(
58                         [AC_LANG_PROGRAM([#include <utmp.h>],
59                                 [struct utmp ut; char *cp = ut.ut_host;]
60                         )],
61                         [ac_cv_struct_utmp_ut_host=yes],
62                         [ac_cv_struct_utmp_ut_host=no]
63                 )
64         )
65
66         if test "$ac_cv_struct_utmp_ut_host" = "yes"; then
67                 AC_DEFINE(UT_HOST, 1, [Define if you have ut_host in struct utmp.])
68         fi
69
70         AC_CACHE_CHECK(for ut_user in struct utmp,
71                 ac_cv_struct_utmp_ut_user,
72                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <utmp.h>],
73                                 [struct utmp ut; char *cp = ut.ut_user;]
74                         )],
75                         [ac_cv_struct_utmp_ut_user=yes],
76                         [ac_cv_struct_utmp_ut_user=no]
77                 )
78         )
79
80         if test "$ac_cv_struct_utmp_ut_user" = "no"; then
81                 AC_DEFINE(ut_user, ut_name,
82                         [Define to ut_name if struct utmp has ut_name (not ut_user).])
83         fi
84 fi
85
86 if test "$ac_cv_header_lastlog_h" = "yes"; then
87         AC_CACHE_CHECK(for ll_host in struct lastlog,
88                 ac_cv_struct_lastlog_ll_host,
89                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <lastlog.h>],
90                                         [struct lastlog ll; char *cp = ll.ll_host;]
91                                 )],
92                         [ac_cv_struct_lastlog_ll_host=yes],
93                         [ac_cv_struct_lastlog_ll_host=no]
94                 )
95         )
96
97         if test "$ac_cv_struct_lastlog_ll_host" = "yes"; then
98                 AC_DEFINE(HAVE_LL_HOST, 1,
99                         [Define if struct lastlog has ll_host])
100         fi
101 fi
102
103 dnl Checks for library functions.
104 AC_TYPE_GETGROUPS
105 AC_TYPE_SIGNAL
106 AC_FUNC_UTIME_NULL
107 AC_FUNC_STRFTIME
108 AC_REPLACE_FUNCS(mkdir putgrent putpwent putspent rename rmdir)
109 AC_REPLACE_FUNCS(sgetgrent sgetpwent sgetspent)
110 AC_REPLACE_FUNCS(snprintf strcasecmp strdup strerror strstr)
111
112 AC_CHECK_FUNC(setpgrp)
113 AC_FUNC_SETPGRP
114
115 if test "$ac_cv_header_shadow_h" = "yes"; then
116         AC_CACHE_CHECK(for working shadow group support,
117                 ac_cv_libc_shadowgrp,
118                 AC_RUN_IFELSE([AC_LANG_SOURCE([
119                                 #include <shadow.h>
120                                 main()
121                                 {
122                                         struct sgrp *sg = sgetsgent("test:x::");
123                                         /* NYS libc on Red Hat 3.0.3 has broken shadow group support */
124                                         return !sg || !sg->sg_adm || !sg->sg_mem;
125                                 }]
126                         )],
127                         [ac_cv_libc_shadowgrp=yes],
128                         [ac_cv_libc_shadowgrp=no],
129                         [ac_cv_libc_shadowgrp=no]
130                 )
131         )
132
133         if test "$ac_cv_libc_shadowgrp" = "yes"; then
134                 AC_DEFINE(HAVE_SHADOWGRP, 1, [Have working shadow group support in libc])
135         fi
136 fi
137
138 AC_CACHE_CHECK([location of shared mail directory], shadow_cv_maildir,
139 [for shadow_cv_maildir in /var/mail /var/spool/mail /usr/spool/mail /usr/mail none; do
140         if test -d $shadow_cv_maildir; then
141                 break
142         fi
143 done])
144 if test $shadow_cv_maildir != none; then
145         AC_DEFINE_UNQUOTED(MAIL_SPOOL_DIR, "$shadow_cv_maildir",
146                 [Location of system mail spool directory.])
147 fi
148
149 AC_CACHE_CHECK([location of user mail file], shadow_cv_mailfile,
150 [for shadow_cv_mailfile in Mailbox mailbox Mail mail .mail none; do
151         if test -f $HOME/$shadow_cv_mailfile; then
152                 break
153         fi
154 done])
155 if test $shadow_cv_mailfile != none; then
156         AC_DEFINE_UNQUOTED(MAIL_SPOOL_FILE, "$shadow_cv_mailfile",
157                 [Name of user's mail spool file if stored in user's home directory.])
158 fi
159
160 AC_CACHE_CHECK([location of utmp], shadow_cv_utmpdir,
161 [for shadow_cv_utmpdir in /var/run /var/adm /usr/adm /etc none; do
162         if test -f $shadow_cv_utmpdir/utmp; then
163                 break
164         fi
165 done])
166 if test "$shadow_cv_utmpdir" = "none"; then
167         AC_MSG_WARN(utmp file not found)
168 fi
169 AC_DEFINE_UNQUOTED(_UTMP_FILE, "$shadow_cv_utmpdir/utmp",
170         [Path for utmp file.])
171
172 AC_CACHE_CHECK([location of faillog/lastlog/wtmp], shadow_cv_logdir,
173 [for shadow_cv_logdir in /var/log /var/adm /usr/adm /etc; do
174         if test -d $shadow_cv_logdir; then
175                 break
176         fi
177 done])
178 AC_DEFINE_UNQUOTED(_WTMP_FILE, "$shadow_cv_logdir/wtmp",
179         [Path for wtmp file.])
180 AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$shadow_cv_logdir/lastlog",
181         [Path for lastlog file.])
182 AC_DEFINE_UNQUOTED(FAILLOG_FILE, "$shadow_cv_logdir/faillog",
183         [Path for faillog file.])
184
185 AC_CACHE_CHECK([location of the passwd program], shadow_cv_passwd_dir,
186 [if test -f /usr/bin/passwd; then
187         shadow_cv_passwd_dir=/usr/bin
188 else
189         shadow_cv_passwd_dir=/bin
190 fi])
191 AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$shadow_cv_passwd_dir/passwd",
192         [Path to passwd program.])
193
194 dnl XXX - quick hack, should disappear before anyone notices :).
195 AC_DEFINE(USE_SYSLOG, 1, [Define to use syslog().])
196 AC_DEFINE(RLOGIN, 1, [Define if login should support the -r flag for rlogind.])
197 AC_DEFINE(RUSEROK, 0, [Define to the ruserok() "success" return value (0 or 1).])
198
199 AC_ARG_ENABLE(shadowgrp,
200         [AC_HELP_STRING([--enable-shadowgrp], [enable shadow group support @<:@default=yes@:>@])],
201         [case "${enableval}" in
202          yes) enable_shadowgrp="yes" ;;
203           no) enable_shadowgrp="no" ;;
204            *) AC_MSG_ERROR(bad value ${enableval} for --enable-shadowgrp) ;;
205          esac],
206         [enable_shadowgrp="yes"]
207 )
208
209 AC_ARG_ENABLE(man,
210         [AC_HELP_STRING([--enable-man],
211                 [regenerate roff man pages from Docbook @<:@default=no@:>@])],
212         [enable_man=yes],
213         [enable_man=no]
214 )
215
216 AC_ARG_WITH(audit, 
217         [AC_HELP_STRING([--with-audit], [use auditing support @<:@default=yes if found@:>@])],
218         [with_audit=$withval], [with_audit=yes])
219 AC_ARG_WITH(libpam,
220         [AC_HELP_STRING([--with-libpam], [use libpam for PAM support @<:@default=yes if found@:>@])],
221         [with_libpam=$withval], [with_libpam=yes])
222 AC_ARG_WITH(selinux,
223         [AC_HELP_STRING([--with-selinux], [use SELinux support @<:@default=autodetect@:>@])],
224         [with_selinux=$withval], [with_selinux=yes])
225 AC_ARG_WITH(skey,
226         [AC_HELP_STRING([--with-skey], [use S/Key support @<:@default=no@:>@])],
227         [with_skey=$withval], [with_skey=no])
228 AC_ARG_WITH(libcrack,
229         [AC_HELP_STRING([--with-libcrack], [use libcrack @<:@default=yes if found and if PAM not enabled@:>@])],
230         [with_libcrack=$withval], [with_libcrack=no])
231 AC_ARG_WITH(sha-crypt,
232         [AC_HELP_STRING([--with-sha-crypt], [allow the SHA256 and SHA512 password encryption algorithms @<:@default=yes@:>@])],
233         [with_sha_crypt=$withval], [with_sha_crypt=yes])
234
235 AM_CONDITIONAL(USE_SHA_CRYPT, test "x$with_sha_crypt" = "xyes")
236 if test "$with_sha_crypt" = "yes"; then
237                 AC_DEFINE(USE_SHA_CRYPT, 1, [Define to allow the SHA256 and SHA512 password encryption algorithms])
238 fi
239
240 dnl Check for some functions in libc first, only if not found check for
241 dnl other libraries.  This should prevent linking libnsl if not really
242 dnl needed (Linux glibc, Irix), but still link it if needed (Solaris).
243
244 AC_SEARCH_LIBS(inet_ntoa, inet)
245 AC_SEARCH_LIBS(socket, socket)
246 AC_SEARCH_LIBS(gethostbyname, nsl)
247
248 if test "$enable_shadowgrp" = "yes"; then
249         AC_DEFINE(SHADOWGRP, 1, [Define to support the shadow group file.])
250 fi
251 AM_CONDITIONAL(SHADOWGRP, test "x$enable_shadowgrp" = "xyes")
252
253 if test "$enable_man" = "yes"; then
254         dnl
255         dnl Check for xsltproc
256         dnl
257         AC_PATH_PROG([XSLTPROC], [xsltproc])
258         if test -z "$XSLTPROC"; then
259                 enable_man=no
260         fi
261
262         dnl check for DocBook DTD and stylesheets in the local catalog.
263         JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
264                 [DocBook XML DTD V4.1.2], [], enable_man=no)
265         JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
266                 [DocBook XSL Stylesheets >= 1.70.1], [], enable_man=no)
267 fi
268 AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test x$enable_man != xno)
269
270 AC_SUBST(LIBCRYPT)
271 AC_CHECK_LIB(crypt, crypt, [LIBCRYPT=-lcrypt],
272         [AC_MSG_ERROR([crypt() not found])])
273
274 AC_SUBST(LIBAUDIT)
275 if test "$with_audit" = "yes"; then
276         AC_CHECK_HEADER(libaudit.h, [audit_header="yes"], [audit_header="no"])
277         if test "$audit_header" = "yes"; then
278                 AC_CHECK_LIB(audit, audit_log_acct_message,
279                         [AC_DEFINE(WITH_AUDIT, 1, [Define if you want to enable Audit messages])
280                         LIBAUDIT="-laudit"])
281         fi
282 fi
283
284 AC_SUBST(LIBCRACK)
285 if test "$with_libcrack" = "yes"; then
286         echo "checking cracklib flavour, don't be surprised by the results"
287         AC_CHECK_LIB(crack, FascistCheck,
288                 [LIBCRACK=-lcrack AC_DEFINE(HAVE_LIBCRACK, 1, [Defined if you have libcrack.])])
289         AC_CHECK_LIB(crack, FascistHistory,
290                 AC_DEFINE(HAVE_LIBCRACK_HIST, 1, [Defined if you have the ts&szs cracklib.]))
291         AC_CHECK_LIB(crack, FascistHistoryPw,
292                 AC_DEFINE(HAVE_LIBCRACK_PW, 1, [Defined if it includes *Pw functions.]))
293 fi
294
295 if test "$with_selinux" = "yes"; then
296         AC_CHECK_LIB(selinux, is_selinux_enabled,
297                 [LIBSELINUX="-lselinux"
298                 AC_SUBST(LIBSELINUX)
299                 AC_CHECK_HEADERS(selinux/selinux.h, [],
300                         [AC_MSG_ERROR([selinux/selinux.h is missing])])
301                 AC_DEFINE(WITH_SELINUX, 1, [Build shadow with SELinux support])
302                 ],
303                 [AC_MSG_ERROR([libselinux not found])])
304 fi
305
306 AC_SUBST(LIBPAM)
307 if test "$with_libpam" = "yes"; then
308         AC_CHECK_LIB(pam, pam_start,
309                 [AC_DEFINE(USE_PAM, 1, [Define to support Pluggable Authentication Modules])
310                 AM_CONDITIONAL(USE_PAM, [true])
311                 LIBPAM="-lpam"
312                 AC_CHECK_LIB(pam_misc, main,
313                         [LIBPAM="$LIBPAM -lpam_misc"],
314                         AC_MSG_ERROR(libpam_misc is missing for enable PAM support)
315                 )],
316                 [AC_MSG_CHECKING(use login access checking if PAM not used)
317                 AM_CONDITIONAL(USE_PAM, [false])
318                 AC_MSG_RESULT(yes)]
319         )
320         AC_MSG_CHECKING(use login and su access checking if PAM not used)
321         AC_MSG_RESULT(no)
322 else
323         AC_MSG_CHECKING(use login and su access checking if PAM not used)
324         AC_DEFINE(SU_ACCESS, 1, [Define to support /etc/suauth su access control.])
325         AC_MSG_RESULT(yes)
326         AM_CONDITIONAL(USE_PAM, [false])
327 fi
328
329 AC_SUBST(LIBSKEY)
330 AC_SUBST(LIBMD)
331 if test "$with_skey" = "yes"; then
332         AC_CHECK_LIB(md, MD5Init, [LIBMD=-lmd])
333         AC_CHECK_LIB(skey, skeychallenge, [LIBSKEY=-lskey],
334                 [AC_MSG_ERROR([liskey missing. You can download S/Key source code from http://rsync1.it.gentoo.org/gentoo/distfiles/skey-1.1.5.tar.bz2])])
335         AC_DEFINE(SKEY, 1, [Define to support S/Key logins.])
336         AC_TRY_COMPILE([
337                 #include <stdio.h>
338                 #include <skey.h>
339         ],[
340                 skeychallenge((void*)0, (void*)0, (void*)0, 0);
341         ],[AC_DEFINE(SKEY_BSD_STYLE, 1, [Define to support newer BSD S/Key API])])
342 fi
343
344 AM_GNU_GETTEXT_VERSION(0.16)
345 AM_GNU_GETTEXT([external], [need-ngettext])
346 AM_CONDITIONAL(USE_NLS, test "x$USE_NLS" = "xyes")
347
348 AC_CONFIG_FILES([
349         Makefile
350         po/Makefile.in
351         doc/Makefile
352         man/Makefile
353         man/po/Makefile.in
354         man/cs/Makefile
355         man/de/Makefile
356         man/es/Makefile
357         man/fi/Makefile
358         man/fr/Makefile
359         man/hu/Makefile
360         man/id/Makefile
361         man/it/Makefile
362         man/ja/Makefile
363         man/ko/Makefile
364         man/pl/Makefile
365         man/pt_BR/Makefile
366         man/ru/Makefile
367         man/sv/Makefile
368         man/tr/Makefile
369         man/zh_CN/Makefile
370         man/zh_TW/Makefile
371         libmisc/Makefile
372         lib/Makefile
373         src/Makefile
374         contrib/Makefile
375         etc/Makefile
376         etc/pam.d/Makefile
377         shadow.spec
378 ])
379 AC_OUTPUT
380
381 echo
382 echo "shadow will be compiled with the following features:"
383 echo
384 echo "  auditing support:               $with_audit"
385 echo "  CrackLib support:               $with_libcrack"
386 echo "  PAM support:                    $with_libpam"
387 echo "  SELinux support:                $with_selinux"
388 echo "  shadow group support:           $enable_shadowgrp"
389 echo "  S/Key support:                  $with_skey"
390 echo "  SHA passwords encryption:       $with_sha_crypt"
391 echo