Writing a Module for Hyrax: Difference between revisions

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽
No edit summary
Line 15: Line 15:


=== Here's how ===
=== Here's how ===
First, look to see if the ''configure'' was run with the ''--with-API'' option, then test for the ''--enable...'' option, and then test for a copy of the API library on the host. The first of those found is used; if none are found/given, it's a configuration error.


<source lang="sh">
<source lang="sh">
GDAL_FOUND=
GDAL_FOUND=


AC_ARG_WITH(gdal,[ AS_HELP_STRING ([--with-gdal], [Use the copy of GDAL at this location]) ])
AC_ARG_WITH(gdal,[ AS_HELP_STRING ([--with-gdal], [Use the copy of GDAL at this location]) ],
#            with_gdal_prefix="$withval", with_gdal_prefix="")
                      with_gdal_prefix="$withval", with_gdal_prefix="")


if test -n "$with_gdal_prefix" -a -x $with_gdal_prefix/bin/gdal-config
if test -n "$with_gdal_prefix" -a -x $with_gdal_prefix/bin/gdal-config
Line 58: Line 59:
then
then
     AX_LIB_GDAL([1.7.2])
     AX_LIB_GDAL([1.7.2])
     if test ! -z "$GDAL_CFLAGS" -a ! -z "$GDAL_LDFLAGS"; then
     if test ! -z "$GDAL_CFLAGS" -a ! -z "$GDAL_LDFLAGS"
    then
         GDAL_FOUND="yes"
         GDAL_FOUND="yes"
     fi
     fi

Revision as of 16:36, 25 September 2012

Other guides:

Autoconf documentation: http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/index.html#Top

Including the library ...

It's often easiest for people building from source code if the data access API used by the handler is included in the source.

Support three options:

  1. using --enable-local-API
  2. using --with-API-prefix
  3. finding a copy installed on the build OS

Here's how

First, look to see if the configure was run with the --with-API option, then test for the --enable... option, and then test for a copy of the API library on the host. The first of those found is used; if none are found/given, it's a configuration error.

GDAL_FOUND=

AC_ARG_WITH(gdal,[ AS_HELP_STRING ([--with-gdal], [Use the copy of GDAL at this location]) ],
                       with_gdal_prefix="$withval", with_gdal_prefix="")

if test -n "$with_gdal_prefix" -a -x $with_gdal_prefix/bin/gdal-config
then
    AC_MSG_NOTICE([Using $with_gdal_prefix as the GDAL prefix directory.])
    GDAL_LDFLAGS="`$with_gdal_prefix/bin/gdal-config --libs`"
    GDAL_CFLAGS="`$with_gdal_prefix/bin/gdal-config --cflags`"
    GDAL_FOUND="yes"
elif test -n "$with_gdal_prefix"
then
    AC_MSG_ERROR([You set the gdal-prefix directory to $with_gdal_prefix, but gdal-config is not there.])
fi

AC_ARG_ENABLE(local-gdal, [ AS_HELP_STRING ([--enable_local-gdal], [Build and use the local copy of GDAL]) ])

AC_MSG_NOTICE([enable_local_gdal: >$enable_local_gdal<])
if test -n "$enable_local_gdal" -a "$enable_local_gdal" = "yes"
then
    AC_MSG_NOTICE([Building the local GDAL library.])
    gdal_prx=`pwd`/gdal-1.9.1/build
    if (cd gdal-1.9.1 && ./configure --prefix=$gdal_prx --disable-shared && make -j9 && make install)
    then
        GDAL_LDFLAGS="`$gdal_prx/bin/gdal-config --libs`"
        GDAL_CFLAGS="`$gdal_prx/bin/gdal-config --cflags`"
        AC_SUBST([GDAL_LDFLAGS])
        AC_SUBST([GDAL_CFLAGS])
        GDAL_FOUND="yes"
    
        # AC_MSG_NOTICE(["GDAL_LDFLAGS status >$GDAL_LDFLAGS<"])
        # AC_MSG_NOTICE(["GDAL_CFLAGS status >$GDAL_CFLAGS<"])
    else
        AC_MSG_ERROR([I could not build GDAL.])
    fi
fi

if test -z "$GDAL_FOUND"
then
    AX_LIB_GDAL([1.7.2])
    if test ! -z "$GDAL_CFLAGS" -a ! -z "$GDAL_LDFLAGS"
    then
        GDAL_FOUND="yes"
    fi
fi

if test -z "$GDAL_FOUND"
then
    AC_MSG_ERROR([I could not find GDAL.])
fi