Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.9KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_lib_gdal.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_LIB_GDAL([MINIMUM-VERSION])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro provides tests of availability of GDAL/OGR library of
  12. # particular version or newer.
  13. #
  14. # AX_LIB_GDAL macro takes only one argument which is optional. If there is
  15. # no required version passed, then macro does not run version test.
  16. #
  17. # The --with-gdal option takes complete path to gdal-config utility,
  18. #
  19. # This macro calls AC_SUBST for:
  20. #
  21. # GDAL_VERSION
  22. # GDAL_CFLAGS
  23. # GDAL_LDFLAGS
  24. # GDAL_DEP_LDFLAGS
  25. # GDAL_OGR_ENABLED
  26. #
  27. # and AC_DEFINE for:
  28. #
  29. # HAVE_GDAL
  30. # HAVE_GDAL_OGR
  31. #
  32. # LICENSE
  33. #
  34. # Copyright (c) 2011 Mateusz Loskot <mateusz@loskot.net>
  35. # Copyright (c) 2011 Alessandro Candini <candini@meeo.it>
  36. #
  37. # Copying and distribution of this file, with or without modification, are
  38. # permitted in any medium without royalty provided the copyright notice
  39. # and this notice are preserved. This file is offered as-is, without any
  40. # warranty.
  41. #serial 4
  42. AC_DEFUN([AX_LIB_GDAL],
  43. [
  44. dnl If gdal-config path is not given in ---with-gdal option,
  45. dnl check if it is present in the system anyway
  46. AC_ARG_WITH([gdal],
  47. AC_HELP_STRING([--with-gdal=@<:@ARG@:>@],
  48. [Specify full path to gdal-config script]),
  49. [ac_gdal_config_path=$withval],
  50. [gdal_config_system=check])
  51. dnl if gdal-config is present in the system, fill the ac_gdal_config_path variable with it full path
  52. AS_IF([test "x$gdal_config_system" = xcheck],
  53. [AC_PATH_PROG([GDAL_CONFIG], [gdal-config])],
  54. [AC_PATH_PROG([GDAL_CONFIG], [gdal-config],
  55. [no], [`dirname $ac_gdal_config_path 2> /dev/null`])]
  56. )
  57. if test ! -x "$GDAL_CONFIG"; then
  58. AC_MSG_ERROR([gdal-config does not exist or it is not an executable file])
  59. GDAL_CONFIG="no"
  60. found_gdal="no"
  61. fi
  62. GDAL_VERSION=""
  63. GDAL_CFLAGS=""
  64. GDAL_LDFLAGS=""
  65. GDAL_DEP_LDFLAGS=""
  66. GDAL_OGR_ENABLED=""
  67. dnl
  68. dnl Check GDAL library (libgdal)
  69. dnl
  70. if test "$GDAL_CONFIG" != "no"; then
  71. AC_MSG_CHECKING([for GDAL library])
  72. GDAL_VERSION="`$GDAL_CONFIG --version`"
  73. GDAL_CFLAGS="`$GDAL_CONFIG --cflags`"
  74. GDAL_LDFLAGS="`$GDAL_CONFIG --libs`"
  75. GDAL_DEP_LDFLAGS="`$GDAL_CONFIG --dep-libs`"
  76. AC_DEFINE([HAVE_GDAL], [1], [Define to 1 if GDAL library are available])
  77. found_gdal="yes"
  78. else
  79. found_gdal="no"
  80. fi
  81. AC_MSG_RESULT([$found_gdal])
  82. if test "$found_gdal" = "yes"; then
  83. AC_MSG_CHECKING([for OGR support in GDAL library])
  84. GDAL_OGR_ENABLED="`$GDAL_CONFIG --ogr-enabled`"
  85. AC_DEFINE([HAVE_GDAL_OGR], [1], [Define to 1 if GDAL library includes OGR support])
  86. AC_MSG_RESULT([$GDAL_OGR_ENABLED])
  87. fi
  88. dnl
  89. dnl Check if required version of GDAL is available
  90. dnl
  91. gdal_version_req=ifelse([$1], [], [], [$1])
  92. if test "$found_gdal" = "yes" -a -n "$gdal_version_req"; then
  93. AC_MSG_CHECKING([if GDAL version is >= $gdal_version_req])
  94. dnl Decompose required version string of GDAL
  95. dnl and calculate its number representation
  96. gdal_version_req_major=`expr $gdal_version_req : '\([[0-9]]*\)'`
  97. gdal_version_req_minor=`expr $gdal_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
  98. gdal_version_req_micro=`expr $gdal_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  99. if test "x$gdal_version_req_micro" = "x"; then
  100. gdal_version_req_micro="0"
  101. fi
  102. gdal_version_req_number=`expr $gdal_version_req_major \* 1000000 \
  103. \+ $gdal_version_req_minor \* 1000 \
  104. \+ $gdal_version_req_micro`
  105. dnl Decompose version string of installed GDAL
  106. dnl and calculate its number representation
  107. gdal_version_major=`expr $GDAL_VERSION : '\([[0-9]]*\)'`
  108. gdal_version_minor=`expr $GDAL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
  109. gdal_version_micro=`expr $GDAL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  110. if test "x$gdal_version_micro" = "x"; then
  111. gdal_version_micro="0"
  112. fi
  113. gdal_version_number=`expr $gdal_version_major \* 1000000 \
  114. \+ $gdal_version_minor \* 1000 \
  115. \+ $gdal_version_micro`
  116. gdal_version_check=`expr $gdal_version_number \>\= $gdal_version_req_number`
  117. if test "$gdal_version_check" = "1"; then
  118. AC_MSG_RESULT([yes])
  119. else
  120. AC_MSG_RESULT([no])
  121. AC_MSG_ERROR([GDAL $GDAL_VERSION found, but required version is $gdal_version_req])
  122. fi
  123. fi
  124. AC_SUBST(GDAL_VERSION)
  125. AC_SUBST(GDAL_CFLAGS)
  126. AC_SUBST(GDAL_LDFLAGS)
  127. AC_SUBST(GDAL_DEP_LDFLAGS)
  128. AC_SUBST(GDAL_OGR_ENABLED)
  129. ])