[GRASS5] Re: [GRASS-CVS] glynn: grass51 configure,1.73,1.74 configure.in,1.63,1.64

Hi list,

I found that AC_CHECK_FUNC(gdal) doesn't work in cygwin.

gcc -o conftest -g -O2 -Wl,--export-dynamic \
  -L/usr/local/lib -L/usr/X11R6/lib -L/usr/local/lib -lgdal conftest.c

doesn't compile, but the following is fine when I changed AC_CHECK_FUNC to
AC_CHECK_LIB:

gcc -o conftest -g -O2 -Wl,--export-dynamic \
  -L/usr/local/lib -L/usr/X11R6/lib conftest.c -L/usr/local/lib -lgdal

If there is no reason to keep AC_CHECK_FUNC, I think AC_CHECK_LIB would be
better.
---<diff>---
-ac_save_ldflags="$LDFLAGS"
-LDFLAGS="$LDFLAGS $GDAL_LIBS"
-AC_CHECK_FUNC(GDALOpen,,[
-LDFLAGS="$LDFLAGS $GDAL_DEP_LIBS"
-AC_CHECK_FUNC(GDALOpen,[GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS"],[
+AC_CHECK_LIB(gdal,GDALOpen,[
+AC_CHECK_LIB(gdal,GDALOpen,GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS",[
     AC_MSG_ERROR([*** Unable to locate GDAL library.])
])
])
-LDFLAGS=${ac_save_ldflags}
------------

This is another issue. My autoconf doesn't include the following code snippet
in configure. Do we need this? If so, for what?
---<cut>----
-for ac_declaration in \
- ''\
- '#include <stdlib.h>' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat > conftest.$ac_ext <<EOF
-#line 12132 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-$ac_declaration
-int main() {
-exit (42);
-; return 0; }
-EOF
-if { (eval echo configure:12140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- :
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- continue
-fi
-rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#line 12150 "configure"
-#include "confdefs.h"
-$ac_declaration
-int main() {
-exit (42);
-; return 0; }
-EOF
-if { (eval echo configure:12157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- break
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
-fi
-rm -f conftest*
-done
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-
------------

Thank you.
Huidae Cho

On Fri, Nov 26, 2004 at 10:52:29PM +0100, grass@intevation.de wrote:

Author: glynn

Update of /grassrepository/grass51
In directory doto:/tmp/cvs-serv26674

Modified Files:
  configure configure.in
Log Message:
Check whether GDAL needs --dep-libs

Index: configure

RCS file: /grassrepository/grass51/configure,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- configure 25 Nov 2004 10:21:43 -0000 1.73
+++ configure 26 Nov 2004 21:52:27 -0000 1.74
@@ -7145,6 +7145,7 @@

if test "$GDAL_CONFIG" != "" ; then
   GDAL_LIBS=`"$GDAL_CONFIG" --libs`
+ GDAL_DEP_LIBS=`"$GDAL_CONFIG" --dep-libs`
   GDAL_CFLAGS=`"$GDAL_CONFIG" --cflags`
   USE_GDAL=1
   if test `"$GDAL_CONFIG" --ogr-enabled` = "yes" ; then
@@ -7156,6 +7157,106 @@
   fi
fi

[...2500 lines suppressed...]
-#line 12164 "configure"
+#line 12214 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:12169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:12219: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
   rm -rf conftest*
@@ -12199,7 +12249,7 @@

echo $ac_n "checking for location of openDWG library""... $ac_c" 1>&6
-echo "configure:12203: checking for location of openDWG library" >&5
+echo "configure:12253: checking for location of openDWG library" >&5
case "$with_opendwg_libs" in
y | ye | yes | n | no)
   { echo "configure: error: *** You must supply a directory to --with-opendwg-libs." 1>&2; exit 1; }

Index: configure.in

RCS file: /grassrepository/grass51/configure.in,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- configure.in 25 Nov 2004 10:21:43 -0000 1.63
+++ configure.in 26 Nov 2004 21:52:27 -0000 1.64
@@ -614,6 +614,7 @@

if test "$GDAL_CONFIG" != "" ; then
   GDAL_LIBS=`"$GDAL_CONFIG" --libs`
+ GDAL_DEP_LIBS=`"$GDAL_CONFIG" --dep-libs`
   GDAL_CFLAGS=`"$GDAL_CONFIG" --cflags`
   USE_GDAL=1
   if test `"$GDAL_CONFIG" --ogr-enabled` = "yes" ; then
@@ -621,6 +622,16 @@
     USE_OGR=1
   fi
fi
+
+ac_save_ldflags="$LDFLAGS"
+LDFLAGS="$LDFLAGS $GDAL_LIBS"
+AC_CHECK_FUNC(GDALOpen,,[
+LDFLAGS="$LDFLAGS $GDAL_DEP_LIBS"
+AC_CHECK_FUNC(GDALOpen,[GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS"],[
+ AC_MSG_ERROR([*** Unable to locate GDAL library.])
+])
+])
+LDFLAGS=${ac_save_ldflags}

AC_SUBST(GDAL_LIBS)
AC_SUBST(GDAL_CFLAGS)

_______________________________________________
grass-commit mailing list
grass-commit@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-commit

On Fri, 10 Dec 2004, Huidae Cho wrote:

Hi list,

I found that AC_CHECK_FUNC(gdal) doesn't work in cygwin.

Doesn't work on IRIX either; I haven't had time to investigate more and comment to the list. I thought the point of the gdal-config command is that you can just use the output of it and assume GDAL is installed properly,
without having to test for the libraries in the usual way.

Paul

Huidae Cho wrote:

I found that AC_CHECK_FUNC(gdal) doesn't work in cygwin.

gcc -o conftest -g -O2 -Wl,--export-dynamic \
  -L/usr/local/lib -L/usr/X11R6/lib -L/usr/local/lib -lgdal conftest.c

doesn't compile, but the following is fine when I changed AC_CHECK_FUNC to
AC_CHECK_LIB:

gcc -o conftest -g -O2 -Wl,--export-dynamic \
  -L/usr/local/lib -L/usr/X11R6/lib conftest.c -L/usr/local/lib -lgdal

If there is no reason to keep AC_CHECK_FUNC, I think AC_CHECK_LIB would be
better.

We don't have the name of a specific library, only a list of switches.

---<diff>---
-ac_save_ldflags="$LDFLAGS"
-LDFLAGS="$LDFLAGS $GDAL_LIBS"
-AC_CHECK_FUNC(GDALOpen,,[
-LDFLAGS="$LDFLAGS $GDAL_DEP_LIBS"
-AC_CHECK_FUNC(GDALOpen,[GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS"],[
+AC_CHECK_LIB(gdal,GDALOpen,[
+AC_CHECK_LIB(gdal,GDALOpen,GDAL_LIBS="$GDAL_LIBS $GDAL_DEP_LIBS",[
     AC_MSG_ERROR([*** Unable to locate GDAL library.])
])
])
-LDFLAGS=${ac_save_ldflags}
------------

According to the autoconf Info file:

-- Variable: LDFLAGS
     Stripping (`-s') and any other miscellaneous options for the
     linker. If it is not set in the environment when `configure' runs,
     the default value is empty. `configure' uses this variable when
     linking programs to test for C features.

-- Variable: LIBS
     `-l' and `-L' options to pass to the linker.

So, we should probably be using LIBS rather than LDFLAGS. I suspect
that $LIBS will go at the end of the link command, which is required
for static libraries to work.

Using AC_CHECK_LIB(gdal,...) is wrong; we should be using whatever
"gdal-config --libs" says, in case the library isn't called "gdal"
(the GDAL bridge code suggests that the name might include the
version, requiring e.g. -lgdal11 or -lgdal.1.1).

This is another issue. My autoconf doesn't include the following code snippet
in configure. Do we need this? If so, for what?

[snip]

None of the configure scripts which I have here include that code. I
suspect that code is due to someone recently committing a version
generated using a later version of autoconf (all of the versions I
have here used 2.13; most modern systems have a newer version).

As the old versions have worked fine for years, I don't think that we
need that code.

--
Glynn Clements <glynn@gclements.plus.com>