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.

170 lines
5.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_prog_apache.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_PROG_APACHE([version])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro searches for an installed apache server. If nothing was
  12. # specified when calling configure or just --with-apache, it searches in
  13. # /usr/local/apache/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
  14. # The argument of --with-apache specifies the full pathname of the httpd
  15. # argument. For instance --with-apache=/usr/sbin/httpd.
  16. #
  17. # If the version argument is given, AX_PROG_APACHE checks that the apache
  18. # server is this version number or higher.
  19. #
  20. # If the apache server is not found, abort configuration with error
  21. # message.
  22. #
  23. # It defines the symbol APACHE if the server is found.
  24. #
  25. # Files using apache should do the following:
  26. #
  27. # @APACHE@ -d /etc/httpd
  28. #
  29. # It defines the symbol APACHE_MODULES if a directory containing mod_env.*
  30. # is found in the default server root directory (obtained with httpd -V).
  31. #
  32. # The httpd.conf file listing modules to be loaded dynamically can use
  33. # @APACHE_MODULES@ to grab them in the appropriate sub directory. For
  34. # instance:
  35. #
  36. # ...
  37. # <IfModule mod_so.c>
  38. # LoadModule env_module @APACHE_MODULES@/mod_env.so
  39. # LoadModule config_log_module @APACHE_MODULES@/mod_log_config.so
  40. # ...
  41. #
  42. # LICENSE
  43. #
  44. # Copyright (c) 2008 Loic Dachary <loic@senga.org>
  45. #
  46. # This program is free software; you can redistribute it and/or modify it
  47. # under the terms of the GNU General Public License as published by the
  48. # Free Software Foundation; either version 2 of the License, or (at your
  49. # option) any later version.
  50. #
  51. # This program is distributed in the hope that it will be useful, but
  52. # WITHOUT ANY WARRANTY; without even the implied warranty of
  53. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  54. # Public License for more details.
  55. #
  56. # You should have received a copy of the GNU General Public License along
  57. # with this program. If not, see <https://www.gnu.org/licenses/>.
  58. #
  59. # As a special exception, the respective Autoconf Macro's copyright owner
  60. # gives unlimited permission to copy, distribute and modify the configure
  61. # scripts that are the output of Autoconf when processing the Macro. You
  62. # need not follow the terms of the GNU General Public License when using
  63. # or distributing such scripts, even though portions of the text of the
  64. # Macro appear in them. The GNU General Public License (GPL) does govern
  65. # all other use of the material that constitutes the Autoconf Macro.
  66. #
  67. # This special exception to the GPL applies to versions of the Autoconf
  68. # Macro released by the Autoconf Archive. When you make and distribute a
  69. # modified version of the Autoconf Macro, you may extend this special
  70. # exception to the GPL to apply to your modified version as well.
  71. #serial 7
  72. AU_ALIAS([AC_PROG_APACHE], [AX_PROG_APACHE])
  73. AC_DEFUN([AX_PROG_APACHE],
  74. #
  75. # Handle user hints
  76. #
  77. [
  78. AC_MSG_CHECKING(if apache is wanted)
  79. AC_ARG_WITH(apache,
  80. [ --with-apache=PATH absolute path name of apache server (default is to search httpd in
  81. /usr/local/apache/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin),
  82. --without-apache to disable apache detection],
  83. [
  84. #
  85. # Run this if -with or -without was specified
  86. #
  87. if test "$withval" != no ; then
  88. AC_MSG_RESULT(yes)
  89. APACHE_WANTED=yes
  90. if test "$withval" != yes ; then
  91. APACHE="$withval"
  92. fi
  93. else
  94. APACHE_WANTED=no
  95. AC_MSG_RESULT(no)
  96. fi
  97. ], [
  98. #
  99. # Run this if nothing was said
  100. #
  101. APACHE_WANTED=yes
  102. AC_MSG_RESULT(yes)
  103. ])
  104. #
  105. # Now we know if we want apache or not, only go further if
  106. # it's wanted.
  107. #
  108. if test $APACHE_WANTED = yes ; then
  109. #
  110. # If not specified by caller, search in standard places
  111. #
  112. if test -z "$APACHE" ; then
  113. AC_PATH_PROG(APACHE, httpd, , /usr/local/apache/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
  114. fi
  115. AC_SUBST(APACHE)
  116. if test -z "$APACHE" ; then
  117. AC_MSG_ERROR("apache server executable not found");
  118. fi
  119. #
  120. # Collect apache version number. If for nothing else, this
  121. # guaranties that httpd is a working apache executable.
  122. #
  123. changequote(<<, >>)dnl
  124. APACHE_READABLE_VERSION=`$APACHE -v | grep 'Server version' | sed -e 's;.*Apache/\([0-9\.][0-9\.]*\).*;\1;'`
  125. changequote([, ])dnl
  126. APACHE_VERSION=`echo $APACHE_READABLE_VERSION | sed -e 's/\.//g'`
  127. if test -z "$APACHE_VERSION" ; then
  128. AC_MSG_ERROR("could not determine apache version number");
  129. fi
  130. APACHE_MAJOR=`expr $APACHE_VERSION : '\(..\)'`
  131. APACHE_MINOR=`expr $APACHE_VERSION : '..\(.*\)'`
  132. #
  133. # Check that apache version matches requested version or above
  134. #
  135. if test -n "$1" ; then
  136. AC_MSG_CHECKING(apache version >= $1)
  137. APACHE_REQUEST=`echo $1 | sed -e 's/\.//g'`
  138. APACHE_REQUEST_MAJOR=`expr $APACHE_REQUEST : '\(..\)'`
  139. APACHE_REQUEST_MINOR=`expr $APACHE_REQUEST : '..\(.*\)'`
  140. if test "$APACHE_MAJOR" -lt "$APACHE_REQUEST_MAJOR" -o "$APACHE_MINOR" -lt "$APACHE_REQUEST_MINOR" ; then
  141. AC_MSG_RESULT(no)
  142. AC_MSG_ERROR(apache version is $APACHE_READABLE_VERSION)
  143. else
  144. AC_MSG_RESULT(yes)
  145. fi
  146. fi
  147. #
  148. # Find out if .so modules are in libexec/module.so or modules/module.so
  149. #
  150. HTTP_ROOT=`$APACHE -V | grep HTTPD_ROOT | sed -e 's/.*"\(.*\)"/\1/'`
  151. AC_MSG_CHECKING(apache modules)
  152. for dir in libexec modules
  153. do
  154. if test -f $HTTP_ROOT/$dir/mod_env.*
  155. then
  156. APACHE_MODULES=$dir
  157. fi
  158. done
  159. if test -z "$APACHE_MODULES"
  160. then
  161. AC_MSG_RESULT(not found)
  162. else
  163. AC_MSG_RESULT(in $HTTP_ROOT/$APACHE_MODULES)
  164. fi
  165. AC_SUBST(APACHE_MODULES)
  166. fi
  167. ])