]> err.no Git - util-linux/commitdiff
build-sys: improve check for crypt
authorFabian Groffen <grobian@gentoo.org>
Wed, 12 Jan 2011 20:01:07 +0000 (21:01 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Jan 2011 15:32:39 +0000 (16:32 +0100)
Check for crypt.h existence, and use it if available over using unistd.h
for which a certain feature level has to be set to export a definition
for crypt.  On Solaris this set causes a standards conflict in the
headers, because at the time of this check C99 mode is already enabled,
which implies certain standards non-compatible with _XOPEN_SOURCE.

 92  #define _XOPEN_SOURCE
 93  #include <unistd.h>

configure:16259: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/unistd.h:18,
                 from conftest.c:93:
/prefix/gentoo/usr/lib/gcc/i386-pc-solaris2.10/4.4.5/include-fixed/sys/feature_tests.h:341:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"

configure.ac: improve crypt check
login-utils/my_crypt.h: replace old GNU_LIBRARY check with autoconf
define for crypt.h

[kzak@redhat.com: - remove my_crypt.h]

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
login-utils/Makefile.am
login-utils/chfn.c
login-utils/chsh.c
login-utils/login.c
login-utils/my_crypt.h [deleted file]
login-utils/newgrp.c
simpleinit/simpleinit.c

index f68d79073d582131729ca340e85d0c87d3c0d2bf..8922d1f68e23dfd2e6e3a6336b4e73d614a9c332 100644 (file)
@@ -520,17 +520,28 @@ else
   AM_CONDITIONAL(HAVE_UTEMPTER, false)
 fi
 
-
+# on Solaris, you can't mix and match standards, since we use c99
+# aparently at this stage, XOPEN_SOURCE will conflict.  As workaround,
+# check for crypt.h and use that without XOPEN_SOURCE.
+AC_CHECK_HEADERS([crypt.h])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#else
 #define _XOPEN_SOURCE
 #include <unistd.h>
+#endif
 ]], [[
 char *c = crypt("abc","pw");
 ]])],[],[
   LIBS="$LIBS -lcrypt"
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+  #ifdef HAVE_CRYPT_H
+  #include <crypt.h>
+  #else
   #define _XOPEN_SOURCE
   #include <unistd.h>
+  #endif
   ]], [[
   char *c = crypt("abc","pw");
   ]])],[
index c490999d9525525f4be6871a976fbac12c56cf01..9c64149f1ac0eaa018e3e91284cc73c599a35798 100644 (file)
@@ -34,10 +34,9 @@ login_ldadd_common =
 
 chfn_SOURCES = chfn.c $(chfn_chsh_common)
 chsh_SOURCES = chsh.c $(chfn_chsh_common)
-chfn_chsh_common = islocal.c setpwnam.c islocal.h my_crypt.h setpwnam.h \
+chfn_chsh_common = islocal.c setpwnam.c islocal.h setpwnam.h \
        $(top_srcdir)/lib/env.c
-login_SOURCES = login.c login.h my_crypt.h $(top_srcdir)/lib/setproctitle.c
-newgrp_SOURCES = newgrp.c my_crypt.h
+login_SOURCES = login.c login.h $(top_srcdir)/lib/setproctitle.c
 vipw_SOURCES = vipw.c setpwnam.h
 
 chfn_LDADD = $(login_ldadd_common)
index 2e0c82b1594c2bca8f57efc6e3e87c0bba436773..64f4ac4298f327829d7081c72d4d5d2b897cf80b 100644 (file)
 #include <ctype.h>
 #include <getopt.h>
 
-#include "my_crypt.h"
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
 #include "islocal.h"
 #include "setpwnam.h"
 #include "strutils.h"
index 22b3350638cf3954032511aa80d7582c38d02f6f..778c4578b8e66cf8b4733c267fabd92f78c0c362 100644 (file)
 #include <ctype.h>
 #include <getopt.h>
 
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
 #include "c.h"
-#include "my_crypt.h"
 #include "islocal.h"
 #include "setpwnam.h"
 #include "nls.h"
index ad2932d0b14fdc7a4c87ecba901ab94901370637..5584c320267c87c8743029c81356771ba5bcb30d 100644 (file)
 # include <libaudit.h>
 #endif
 
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
 #include "pathnames.h"
-#include "my_crypt.h"
 #include "login.h"
 #include "strutils.h"
 #include "nls.h"
diff --git a/login-utils/my_crypt.h b/login-utils/my_crypt.h
deleted file mode 100644 (file)
index efb1a66..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#if defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
-#include <crypt.h>
-#endif
index 6323af19838d3b1081de39491e654ba109083244..2ffe3873445f24cec7ca5f76aa99bb07537933fb 100644 (file)
 #include <errno.h>
 #include <err.h>
 
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
 #include "c.h"
 #include "pathnames.h"
-#include "my_crypt.h"
 #include "nls.h"
 
 /* try to read password from gshadow */
index 5d627c0dae2f6553c4e17ec71a8dd8aad48356aa..d7f9655e9719c53a33cabdd2c3d745fe197b4f3d 100644 (file)
@@ -43,7 +43,7 @@
 #  include <shadow.h>
 #endif
 
-#if defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
+#ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif