libgcrypt configure fixes

Albert Chin gcrypt-devel at mlists.thewrittenword.com
Sat Jan 22 21:16:27 CET 2005


1. Don't use $(CMD) as it's not portable. Use `CMD` instead.
2. Simpler -lnsl/-lsocket test.
3. Test to replace socklen_t on systems without it (TYPE_SOCKLEN_T).
   This test comes from curl but we wrote it so we own the Copyright.
4. No default for random_modules if --enable-random specified.

Patch tested on Solaris 2.5.1-9/SPARC, HP-UX 10.20-11i, AIX 4.3.3-5.2,
IRIX 6.5, Tru64 UNIX 4.0D, 5.1, Redhat Linux 7.1, 9, RHEL 2.0,
3.0/x86, 3.0/amd64.

-- 
albert chin (china at thewrittenword.com)

--snip snip
--- configure.ac.orig	Thu Jan 20 21:21:02 2005
+++ configure.ac	Sat Jan 22 14:10:48 2005
@@ -250,7 +226,7 @@
 AC_ARG_ENABLE(ciphers,
 	      AC_HELP_STRING([--enable-ciphers=ciphers],
 			     [select the symmetric ciphers to include]),
-	      [enabled_ciphers=$(echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]')],
+	      [enabled_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
 	      [enabled_ciphers=""])
 if test "x$enabled_ciphers" = "x" \
    -o "$enabled_ciphers" = "yes"  \
@@ -270,7 +246,7 @@
 AC_ARG_ENABLE(pubkey-ciphers,
 	      AC_HELP_STRING([--enable-pubkey-ciphers=ciphers],
 			     [select the public-key ciphers to include]),
-	      [enabled_pubkey_ciphers=$(echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]')],
+	      [enabled_pubkey_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
 	      [enabled_pubkey_ciphers=""])
 if test "x$enabled_pubkey_ciphers" = "x" \
    -o "$enabled_pubkey_ciphers" = "yes"  \
@@ -290,7 +266,7 @@
 AC_ARG_ENABLE(digests,
 	      AC_HELP_STRING([--enable-digests=digests],
 			     [select the message digests to include]),
-	      [enabled_digests=$(echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]')],
+	      [enabled_digests=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
 	      [enabled_digests=""])
 if test "x$enabled_digests" = "x" \
    -o "$enabled_digests" = "yes"  \
@@ -310,7 +286,7 @@
 AC_ARG_ENABLE(random,
 	      AC_HELP_STRING([--enable-random=name],
 	                     [select which random number generator to use]),
-	      [random=$(echo $enableval | tr '[A-Z]' '[a-z]')],
+	      [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
 	      [])
 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
     random=default
@@ -428,18 +407,9 @@
 
 # Solaris needs -lsocket and -lnsl. Unisys system includes
 # gethostbyname in libsocket but needs libnsl for socket.
-AC_CHECK_LIB(nsl, gethostbyname)
-AC_CHECK_LIB(socket, socket, ac_need_libsocket=1, ac_try_nsl=1)
-if test x$ac_need_libsocket = x1; then
-    LIBS="$LIBS -lsocket"
-fi
-if test x$ac_try_nsl = x1; then
-    AC_CHECK_LIB(nsl, gethostbyname, ac_need_libnsl=1)
-    if test x$ac_need_libnsl = x1
-    then
-        LIBS="$LIBS -lnsl"
-    fi
-fi
+AC_SEARCH_LIBS(setsockopt, [socket], ,
+	[AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
+AC_SEARCH_LIBS(setsockopt, [nsl])
 
 ##################################
 #### Checks for header files. ####
@@ -474,6 +444,8 @@
 #include <sys/socket.h>
               ])
 
+TYPE_SOCKLEN_T
+
 #######################################
 #### Checks for library functions. ####
 #######################################
@@ -554,6 +526,8 @@
     if test "$random" = "auto"; then
         # Build everything, allow to select at runtime.
         random_modules="$auto_random_modules"
+    else
+        random_modules="$random"
     fi
 fi
 
--- acinclude.m4.orig	2005-01-20 23:22:38.000000000 -0600
+++ acinclude.m4	2005-01-21 10:57:15.000000000 -0600
@@ -727,3 +728,43 @@
 fi
 ])
 
+dnl Check for socklen_t: historically on BSD it is an int, and in
+dnl POSIX 1g it is a type of its own, but some platforms use different
+dnl types for the argument to getsockopt, getpeername, etc.  So we
+dnl have to test to find something that will work.
+AC_DEFUN([TYPE_SOCKLEN_T],
+[
+   AC_CHECK_TYPE([socklen_t], ,[
+      AC_MSG_CHECKING([for socklen_t equivalent])
+      AC_CACHE_VAL([socklen_t_equiv],
+      [
+         # Systems have either "struct sockaddr *" or
+         # "void *" as the second argument to getpeername
+         socklen_t_equiv=
+         for arg2 in "struct sockaddr" void; do
+            for t in int size_t unsigned long "unsigned long"; do
+               AC_TRY_COMPILE([
+                  #include <sys/types.h>
+                  #include <sys/socket.h>
+
+                  int getpeername (int, $arg2 *, $t *);
+               ],[
+                  $t len;
+                  getpeername(0,0,&len);
+               ],[
+                  socklen_t_equiv="$t"
+                  break
+               ])
+            done
+         done
+
+         if test "x$socklen_t_equiv" = x; then
+            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+         fi
+      ])
+      AC_MSG_RESULT($socklen_t_equiv)
+      AC_DEFINE_UNQUOTED(socklen_t, $socklen_t_equiv,
+			[type to use in place of socklen_t if not defined])],
+      [#include <sys/types.h>
+#include <sys/socket.h>])
+])



More information about the Gcrypt-devel mailing list