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.

110 lines
3.6KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_postgres_db.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_POSTGRES_DB([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro tries to find the headers and libraries for the PostgreSQL
  12. # database to build client applications.
  13. #
  14. # If includes are found, the variable PQINCPATH will be set, and
  15. # have_pqinc will be 'yes'. If libraries are found, the variable PQLIBPATH
  16. # will be set, and have_pqlib will be 'yes'. If both PQINCPATH and
  17. # PQLIBPATH are found, HAVE_LIBPQ will be set to 'yes' (and AC_DEFINEd),
  18. # and -lpq will be added to the beginning of LIBS. If their respective
  19. # conditions are not met, have_pqinc, have_pqlib, HAVE_LIBPQ, will be
  20. # 'no'.
  21. #
  22. # This macro does fails if either the headers or the library are not
  23. # found, unless ACTION-IF-NOT-FOUND is not empty. When both are found,
  24. # ACTION-IF-FOUND, if defined, is executed after the variables have been
  25. # defined. If --with-pgsql=no (or equivalents) is given, nothing happens.
  26. #
  27. # An automake conditional can be subsequently defined as
  28. #
  29. # AM_CONDITIONAL([HAVE_LIBPQ], [test x$HAVE_LIBPQ = x$yes])
  30. #
  31. # in configure.ac.
  32. #
  33. # LICENSE
  34. #
  35. # Copyright (c) 2008 Christian Toepp <c.toepp@gmail.com>
  36. # Copyright (c) 2012 Olivier Mehani <shtrom-ax@ssji.net>
  37. #
  38. # Copying and distribution of this file, with or without modification, are
  39. # permitted in any medium without royalty provided the copyright notice
  40. # and this notice are preserved. This file is offered as-is, without any
  41. # warranty.
  42. #serial 12
  43. AU_ALIAS([CT_CHECK_POSTGRES_DB], [AX_CHECK_POSTGRES_DB])
  44. AC_DEFUN([AX_CHECK_POSTGRES_DB], [
  45. pushdef([ACTION_IF_FOUND],$1)
  46. pushdef([ACTION_IF_NOT_FOUND],$2)
  47. AC_ARG_WITH(pgsql,
  48. [AS_HELP_STRING([--with-pgsql[[=PREFIX]]],
  49. [Prefix of your PostgreSQL installation @<:@PREFIX@:>@])],
  50. [pg_prefix=$withval], [pg_prefix=])
  51. AC_ARG_WITH(pgsql-inc,
  52. [AS_HELP_STRING([--with-pgsql-inc=[[PATH]]],
  53. [Path to the include directory of PostgreSQL @<:@INCLUDEDIR@:>@])],
  54. [pg_inc=$withval], [pg_inc=])
  55. AC_ARG_WITH(pgsql-lib,
  56. [AS_HELP_STRING([--with-pgsql-lib=[[PATH]]],
  57. [Path to the libraries of PostgreSQL @<:@LIBDIR@:>@])],
  58. [pg_lib=$withval], [pg_lib=])
  59. have_pqinc=no
  60. have_pqlib=no
  61. HAVE_LIBPQ=no
  62. AS_IF([test "$pg_prefix" != "no"],[
  63. AS_IF([test "$pg_prefix" != "yes" && test "$pg_prefix" != ""], [
  64. PQINCPATH="-I$pg_prefix/include $PQINCPATH"
  65. PQLIBPATH="-L$pg_prefix/lib $PQLIBPATH"
  66. ])
  67. AS_IF([test "$pg_inc" != ""], [PQINCPATH="-I$pg_inc $PQINCPATH"])
  68. AS_IF([test "$pg_lib" != ""], [PQLIBPATH="-L$pg_lib $PQLIBPATH"])
  69. oldCPPFLAGS=$CPPFLAGS
  70. oldLDFLAGS=$LDFLAGS
  71. CPPFLAGS="$PQINCPATH $CPPFLAGS"
  72. LDFLAGS="$PQLIBPATH $LDFLAGS"
  73. AC_CHECK_HEADER([libpq-fe.h], [have_pqinc=yes])
  74. AC_CHECK_LIB([pq], [PQconnectdb], [
  75. dnl We only search for libpq, so we know why we're here
  76. LIBPQ_LIBS=-lpq
  77. have_pqlib=yes
  78. ])
  79. HAVE_LIBPQ=`(test x$have_pqinc = xyes && test x$have_pqlib = xyes && echo yes) || echo no`
  80. CPPFLAGS=$oldCPPFLAGS
  81. LDFLAGS=$oldLDFLAGS
  82. AC_SUBST(PQINCPATH)
  83. AC_SUBST(PQLIBPATH)
  84. AC_SUBST(LIBPQ_LIBS)
  85. AS_IF([test x$HAVE_LIBPQ = xyes],[
  86. AC_DEFINE([HAVE_LIBPQ], [1], [Define if libpq is installed])
  87. ACTION_IF_FOUND
  88. ],
  89. [m4_ifset([ACTION_IF_NOT_FOUND],[ACTION_IF_NOT_FOUND],
  90. [AC_MSG_ERROR(some support files for PostgreSQL were missing)])])
  91. ])
  92. popdef([ACTION_IF_FOUND])
  93. popdef([ACTION_IF_NOT_FOUND])
  94. ])