autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autoconf 2.50: Libdnet may be linked in unnecessarily with libX11


From: Maciej W. Rozycki
Subject: Re: autoconf 2.50: Libdnet may be linked in unnecessarily with libX11
Date: Tue, 12 Jun 2001 03:59:37 +0200 (MET DST)

Hi Pavel,

> There is still on detail that I don't like. I tried your patch and I'm
> getting a warning in config.log:
> 
> configure:10028: warning: implicit declaration of function `XOpenDisplay'

 I missed it, sorry.

> Maybe it's better to use AC_CHECK_LIB or AC_TRY_LINK_FUNC instead of

 AC_TRY_LINK_FUNC would be the best bet, I think, as we do only want to
pull a symbol out of a library, regardless of its semantics
(AC_TRY_LINK_FUNC declares functions as "char func()").

> AC_TRY_LINK? Or add the headers? I did it and now I'm getting "too few
> arguments to function `XOpenDisplay'". Not good!
> 
> For some reason AC_CHECK_LIB allows us to ommit the trailing semicolon,
> but we shouldn't be so sloppy in the Autoconf code.

 AC_LANG_PROGRAM adds semicolon itself for some reason.

> With all the changes we get the following patch (ChangeLog is the same):
> 
> __________________________________
> --- acspecific.m4
> +++ acspecific.m4
> @@ -810,11 +810,14 @@
>      # Martyn Johnson says this is needed for Ultrix, if the X
>      # libraries were built with DECnet support.  And Karl Berry says
>      # the Alpha needs dnet_stub (dnet does not exist).
> -    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
> +    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
> +    AC_TRY_LINK(address@hidden:@include <X11/Intrinsic.h>], 
> [XOpenDisplay("");], ,

 This is not the right header -- <X11/Xlib.h> is.  Then again, I'd vote
for AC_TRY_LINK_FUNC.

> +    [AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
>      if test $ac_cv_lib_dnet_dnet_ntoa = no; then
>        AC_CHECK_LIB(dnet_stub, dnet_ntoa,
>       [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
> -    fi
> +    fi])
> +    LIBS="$ac_xsave_LIBS"
> 
>      # address@hidden says -lnsl (and -lsocket) are needed for his 386/AT,
>      # to get the SysV transport functions.
> __________________________________

 The following patch should be fine.  It seems to work for me.  ChangeLog
unchanged.

 An example output for a static-link configuration on an
alphaev5-dec-osf4.0e (that might be among more interesting): 

$ CFLAGS=-non_shared ./configure --x-includes=/usr/include/X11
--x-libraries=/usr/lib/X11
checking for gcc... no
checking for cc... cc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for executable suffix...
checking for object suffix... o
checking whether we are using the GNU C compiler... no
checking whether cc accepts -g... yes
checking how to run the C preprocessor... cc -E
checking for X... libraries /usr/lib/X11, headers /usr/include/X11
checking for dnet_ntoa in -ldnet... no
checking for dnet_ntoa in -ldnet_stub... yes
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
configure: creating ./config.status
config.status: creating Makefile

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: address@hidden, PGP key available        +

autoconf-2.50-X-dnet.patch
diff -up --recursive --new-file autoconf-2.50.macro/acspecific.m4 
autoconf-2.50/acspecific.m4
--- autoconf-2.50.macro/acspecific.m4   Tue Apr 17 13:12:03 2001
+++ autoconf-2.50/acspecific.m4 Mon Jun 11 23:27:00 2001
@@ -810,11 +810,14 @@ dnl FIXME: banish uname from this macro!
     # Martyn Johnson says this is needed for Ultrix, if the X
     # libraries were built with DECnet support.  And Karl Berry says
     # the Alpha needs dnet_stub (dnet does not exist).
-    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
+    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
+    AC_TRY_LINK_FUNC(XOpenDisplay, ,
+    [AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
        [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
-    fi
+    fi])
+    LIBS="$ac_xsave_LIBS"
 
     # address@hidden says -lnsl (and -lsocket) are needed for his 386/AT,
     # to get the SysV transport functions.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]