Little cleanup for -lz

Michael Tokarev mjt at tls.msk.ru
Sat Mar 9 11:54:14 EST 2002


Here is a first patch in a series of similar ones (I hope).
This patch is to make -lz used for only those programs that
*really* need zlib (namely, ssh and sshd for now).  There
is no need to load libz.so for ssh-keygen, sftp and others.

Related question.  It seems ssh's configure script pickups
-lnsl on linux -- what for?  It is required on solaris, but
not on linux.  But on solaris, one need to use -lsocket -lnsl
in order to do any network code (i.e. BOTH libs are for
BSD socket operations).  Are there other platforms exists
where ssh uses OTHER features/symbols from -lnsl?  And from
-lutil (EXCEPT login()/logwtmp()/whatether needed for sshd
only)?

Regards,
 Michael.

BTW, please don't blame me: I NOT tested this patch AT ALL
(but it is very trivial): right now I have no working
autoconf-2.  It is a big trouble -- dealing with incompatibility
in autoconf.  I'll have it soon.
-------------- next part --------------
--- openssh-3.1p1/configure.ac.zlib	Wed Feb 27 09:12:35 2002
+++ openssh-3.1p1/configure.ac	Sat Mar  9 03:35:52 2002
@@ -359,6 +359,7 @@
 )
 
 dnl zlib is required
+ZLIB_LDFLAGS=
 AC_ARG_WITH(zlib,
 	[  --with-zlib=PATH        Use zlib in PATH],
 	[
@@ -367,15 +368,15 @@
 		fi
 		if test -d "$withval/lib"; then
 			if test -n "${need_dash_r}"; then
-				LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
+				ZLIB_LDFLAGS="-L${withval}/lib -R${withval}/lib"
 			else
-				LDFLAGS="-L${withval}/lib ${LDFLAGS}"
+				ZLIB_LDFLAGS="-L${withval}/lib"
 			fi
 		else
 			if test -n "${need_dash_r}"; then
-				LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
+				ZLIB_LDFLAGS="-L${withval} -R${withval}"
 			else
-				LDFLAGS="-L${withval} ${LDFLAGS}"
+				ZLIB_LDFLAGS="-L${withval}"
 			fi
 		fi
 		if test -d "$withval/include"; then
@@ -386,7 +387,9 @@
 	]
 )
 
-AC_CHECK_LIB(z, deflate, ,AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***]))
+AC_CHECK_LIB(z, deflate, ZLIB_LDFLAGS="$ZLIB_LDFLAGS -lz"; AC_SUBST(ZLIB_LDFLAGS),
+	AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***]),
+	$ZLIB_LDFLAGS)
 
 dnl UnixWare 2.x
 AC_CHECK_FUNC(strcasecmp, 
--- openssh-3.1p1/Makefile.in.zlib	Tue Feb 26 22:24:22 2002
+++ openssh-3.1p1/Makefile.in	Sat Mar  9 03:41:32 2002
@@ -31,6 +31,7 @@
 CFLAGS=@CFLAGS@
 CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
 LIBS=@LIBS@
+ZLIB_LDFLAGS=@ZLIB_LDFLAGS@
 LIBPAM=@LIBPAM@
 LIBWRAP=@LIBWRAP@
 AR=@AR@
@@ -99,10 +100,10 @@
 	$(RANLIB) $@
 
 ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
-	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(ZLIB_LDFLAGS) $(LIBS)
 
 sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
-	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBWRAP) $(LIBPAM) $(LIBS)
+	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(ZLIB_LDFLAGS) $(LIBWRAP) $(LIBPAM) $(LIBS)
 
 scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o
 	$(LD) -o $@ scp.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)


More information about the openssh-unix-dev mailing list