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.

107 lines
3.9KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_pgsql_db.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_PGSQL_DB([DB], [USER], [HOST], [PASSWORD], [ACTION_IF_FAILED], [ACTION_IF_OK])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro checks wether we can connect to a PostgreSQL server with the
  12. # given data. The macro AX_PROG_PGCLIENT is required by this one. The
  13. # variable $pgclient_call is set for later use in Makefiles, if you'd like
  14. # to make use of this, you must do
  15. #
  16. # AC_SUBST(pgclient_call)
  17. #
  18. # after having called AX_CHECK_PGSQL_DB. You can then do something like
  19. # the following in your Makefile.am:
  20. #
  21. # @pgclient_call@ -f file.sql
  22. #
  23. # If you want the user to set the data, you should support something like
  24. # these configure options:
  25. #
  26. # AC_ARG_WITH(pgsql-host,
  27. # [ --with-pgsql-host=HOST server is running on HOST @<:@local socket@:>@],
  28. # [pg_host=$withval], [pg_host=])
  29. #
  30. # AC_ARG_WITH(pgsql-db,
  31. # [ --with-pgsql-db=DATABASE use DATABASE @<:@tarantoola@:>@],
  32. # [pg_db=$withval], [pg_db=tarantoola])
  33. #
  34. # AC_ARG_WITH(pgsql-user,
  35. # [ --with-pgsql-user=USER use USER @<:@postgres@:>@],
  36. # [pg_user=$withval], [pg_user=postgres])
  37. #
  38. # AC_ARG_WITH(pgsql-password,
  39. # [ --with-pgsql-password=PASSWORD use PASSWORD @<:@none@:>@],
  40. # [pg_password=$withval], [pg_password=""])
  41. #
  42. # You can then call the macro like this:
  43. #
  44. # AX_CHECK_PGSQL_DB([$pg_db], [$pg_user], [$pg_host], [$pg_password], [AC_MSG_ERROR([We need a database connection!])])
  45. #
  46. # LICENSE
  47. #
  48. # Copyright (c) 2008 Moritz Sinn <moritz@freesources.org>
  49. #
  50. # This program is free software; you can redistribute it and/or modify it
  51. # under the terms of the GNU General Public License as published by the
  52. # Free Software Foundation; either version 2 of the License, or (at your
  53. # option) any later version.
  54. #
  55. # This program is distributed in the hope that it will be useful, but
  56. # WITHOUT ANY WARRANTY; without even the implied warranty of
  57. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  58. # Public License for more details.
  59. #
  60. # You should have received a copy of the GNU General Public License along
  61. # with this program. If not, see <https://www.gnu.org/licenses/>.
  62. #
  63. # As a special exception, the respective Autoconf Macro's copyright owner
  64. # gives unlimited permission to copy, distribute and modify the configure
  65. # scripts that are the output of Autoconf when processing the Macro. You
  66. # need not follow the terms of the GNU General Public License when using
  67. # or distributing such scripts, even though portions of the text of the
  68. # Macro appear in them. The GNU General Public License (GPL) does govern
  69. # all other use of the material that constitutes the Autoconf Macro.
  70. #
  71. # This special exception to the GPL applies to versions of the Autoconf
  72. # Macro released by the Autoconf Archive. When you make and distribute a
  73. # modified version of the Autoconf Macro, you may extend this special
  74. # exception to the GPL to apply to your modified version as well.
  75. #serial 6
  76. AU_ALIAS([MS_CHECK_PGSQL_DB], [AX_CHECK_PGSQL_DB])
  77. AC_DEFUN([AX_CHECK_PGSQL_DB], [
  78. AC_REQUIRE([AX_PROG_PGCLIENT])
  79. AC_MSG_CHECKING([for PostgreSQL db $1 (user: $2, host: $3)])
  80. pgclient_call="$pgclient"
  81. if test "x$1" != "x"; then
  82. pgclient_call="$pgclient_call dbname=$1";
  83. fi
  84. if test "x$2" != "x"; then
  85. pgclient_call="$pgclient_call user=$2";
  86. fi
  87. if test "x$3" != "x"; then
  88. pgclient_call="$pgclient_call host=$3";
  89. fi
  90. if test "x$4" != "x"; then
  91. pgclient_call="$pgclient_call password=$4";
  92. fi
  93. $pgclient_call -c 'SELECT 1' > /dev/null 2>&1
  94. if test "x$?" = "x0"; then
  95. AC_MSG_RESULT([yes])
  96. $6
  97. else
  98. AC_MSG_RESULT([no])
  99. $5
  100. fi;
  101. ])dnl