zsh-workers
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: "ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Cc: "Roland Jesse" <jesse@mail.CS.Uni-Magdeburg.De>,
	"Danek Duvall" <duvall@lorien.emufarm.org>
Subject: PATCH: test for network libraries (for test only)/problems with name resolution
Date: Tue, 22 Aug 2000 17:15:18 +0400	[thread overview]
Message-ID: <001501c00c3b$044cce00$21c9ca95@mow.siemens.ru> (raw)
In-Reply-To: <20000821092904.A32199@lorien.emufarm.org>

[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]

[ Moved to zsh-workers ]

This patch tries more intellegent test for needed network libraries. In my
case it correctly finds -lresolv and related functions. I'm a bit confused
about Solaris. Up to Solaris 7 there is no gethostbyname2; Solaris 7 has it as
LOCAL in -lresolv and Solaris 8 has it in -lnsl (actually Solaris 8 has
everything there, this is the reason why it builds smoothly). Roland, what
version was it that had problem? If it is Solaris 7, either it has some magic
or broken headers.

The patch is against current CVS; it should apply to 3.1.9 with some fuzz, if
not, I can send generated configure.

I do not commit it for two reasons:

 - I'd like to know, that it does not break some other system
 - I'm trapped on my own system. The problem is, now, when gethostbyname2 is
correctly found, name resolution goes via resolver library. But this is using
/etc/hosts only as fallback "if nameserver is not running" (at least in
original bind implemetation as found here). Due to our infrastructure, it is
unacceptable to me.

If I understand it correctly, gethostbyname2 and getipnodebyname are needed to
support IPv6. Which means, that as long as it is NOT supported, they are not
needed and we may fallback to good old gethostbyname. I can just hope that if
IPv6 will ever be suppored here, there will be some reasonable name-to-address
translation support as well.

Any ideas?

-andrej

[-- Attachment #2: zsh-netlibs.diff --]
[-- Type: application/octet-stream, Size: 4561 bytes --]

? .configure.in.swp
Index: aczsh.m4
===================================================================
RCS file: /cvsroot/zsh/zsh/aczsh.m4,v
retrieving revision 1.3
diff -u -r1.3 aczsh.m4
--- aczsh.m4	2000/08/14 04:46:29	1.3
+++ aczsh.m4	2000/08/22 12:58:35
@@ -646,3 +646,33 @@
 	then LIBS="$4"
 	else LIBS="$enable_libs"
 	fi)])
+
+# zsh_SEARCH_LIBS(FUNCTION, SEARCH-LIBS,
+#                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# This is derived from autoconf 2.49a AC_SEARCH_LIBS
+# with the following differences:
+#  - no extra libs argument
+#  - SEARCH-LIBS are taken literally - use -lfoo not foo. That
+#    makes it possible to pass several libs, e.g. "-lsocket -lnsl"
+# --------------------------------------------------------
+# Search for a library defining FUNC, if it's not already available.
+AC_DEFUN([zsh_SEARCH_LIBS],
+[AC_CACHE_CHECK([for library containing $1], [zsh_cv_search_$1],
+[zsh_func_search_save_LIBS="$LIBS"
+zsh_cv_search_$1=no
+AC_TRY_LINK_FUNC([$1], [zsh_cv_search_$1="none required"])
+test "$zsh_cv_search_$1" = no && for zsh_lib in $2; do
+LIBS="$zsh_lib $zsh_func_search_save_LIBS"
+AC_TRY_LINK_FUNC([$1],
+[zsh_cv_search_$1="$zsh_lib"
+break])
+done
+LIBS="$zsh_func_search_save_LIBS"])
+if test "$zsh_cv_search_$1" = no; then
+  ifelse([$4], , :, [$4])
+else
+  test "$zsh_cv_search_$1" = "none required" || LIBS="$zsh_cv_search_$1 $LIBS"
+  ifelse([$3], , , [$3])
+fi
+])
+
Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.26
diff -u -r1.26 configure.in
--- configure.in	2000/08/16 13:23:37	1.26
+++ configure.in	2000/08/22 12:58:37
@@ -512,7 +512,9 @@
 dnl On some systems, modules need to be linked against libc explicitly,
 dnl in case they require objects that exist only in the static version
 dnl and might not be compiled into the zsh executable.
-AC_CHECK_LIB(c, printf)
+dnl Also, on SINIX -lc MUST BE after -lsocket, so this test
+dnl adds -lc as the last library
+AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"])
 
 AC_CHECK_LIB(m, pow)
 
@@ -528,12 +530,43 @@
   AC_CHECK_LIB(${lib}, tgetent, [LIBS="-l$lib $LIBS"; break])
 done
 
-dnl Some systems (Solaris 2.x, Linux Redhat 5.x) require
-dnl libnsl (Network Services Library) to find yp_all
-AC_CHECK_FUNCS(yp_all)
-if test $ac_cv_func_yp_all = no; then
-  AC_CHECK_LIB(nsl, yp_all)
-fi
+dnl Check for network libraries.
+dnl This is really sad and messy story
+dnl Zsh needs three groups of functions:
+dnl   NIS (a.k.a. Yellow Pages)
+dnl   socket
+dnl   resolver
+dnl Depending on particlular OS (or even on particular OS version)
+dnl these function may be found in -lc, -lnsl, -lresolv, -lsocket.
+dnl Sometimes libraries depend on other (notorious -lnsl that is needed
+dnl on SVR4-derived systems to get any network functionality at all)
+dnl or must follow particular order (SINIX, that has two incompatible
+dnl versions of gethostbyname() in -lsocket and -lresolv).
+dnl So, this test tries to find minimal set of needed libraries;
+dnl it tries to preserve user settings (if needed libs were explcitly
+dnl specified) and -lresolv after -lsocket order.
+
+#
+# First check for -lnsl. Good chances, that if it exists, it
+# will be neeeded anyway.
+#
+zsh_SEARCH_LIBS(yp_all, -lnsl)
+
+#
+# Check for resolver functions to make sure, that 
+# -lresolv will be after -lsocket on SINIX
+#
+
+zsh_SEARCH_LIBS(inet_aton, -lnsl -lresolv "-lresolv -lnsl")
+zsh_SEARCH_LIBS(inet_pton, -lnsl -lresolv "-lresolv -lnsl")
+zsh_SEARCH_LIBS(inet_ntop, -lnsl -lresolv "-lresolv -lnsl")
+zsh_SEARCH_LIBS(gethostbyname2, -lnsl -lresolv "-lresolv -lnsl")
+
+#
+# ... and check for socket support
+#
+
+zsh_SEARCH_LIBS(socket, -lnsl -lsocket "-lsocket -lnsl")
 
 dnl I am told that told that unicos reqire these for nis_list
 if test `echo $host_os | sed 's/^\(unicos\).*/\1/'` = unicos; then
@@ -546,8 +579,6 @@
 
 AC_CHECK_LIB(cap, cap_get_proc)
 
-AC_CHECK_LIB(socket, socket)
-
 dnl ---------------------
 dnl CHECK TERMCAP LIBRARY
 dnl ---------------------
@@ -857,7 +888,7 @@
 	       gethostname gethostbyname2 getipnodebyname \
 	       inet_aton inet_pton inet_ntop \
 	       getlogin getpwent getpwnam getpwuid getgrgid getgrnam \
-	       initgroups nis_list \
+	       initgroups yp_all nis_list \
 	       setuid seteuid setreuid setresuid setsid \
 	       memcpy memmove strstr strerror \
 	       cap_get_proc \

       reply	other threads:[~2000-08-22 13:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20000821092904.A32199@lorien.emufarm.org>
2000-08-22 13:15 ` Andrej Borsenkow [this message]
2000-08-22 13:43   ` Roland Jesse
2000-08-22 17:02   ` Bart Schaefer
2000-08-23  6:55     ` Andrej Borsenkow
2000-09-04 13:39     ` Andrej Borsenkow
2000-09-06 15:52       ` Removed " Andrej Borsenkow
2000-09-07 22:16       ` Will Day
2000-09-08  4:14         ` Bart Schaefer
2000-09-08  6:05           ` Andrej Borsenkow
2000-09-08  6:39             ` Will Day
2000-09-08  7:28             ` OT: " Andrej Borsenkow
2000-09-08 20:31             ` Zefram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001501c00c3b$044cce00$21c9ca95@mow.siemens.ru' \
    --to=andrej.borsenkow@mow.siemens.ru \
    --cc=duvall@lorien.emufarm.org \
    --cc=jesse@mail.CS.Uni-Magdeburg.De \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).