ax_nagios_get_distrib 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # ===========================================================================
  2. # SYNOPSIS
  3. #
  4. # AX_NAGIOS_GET_DISTRIB_TYPE
  5. #
  6. # DESCRIPTION
  7. #
  8. # This macro determines the O/S distribution of the computer it is run on.
  9. # $dist_type will be set and will be one of:
  10. # unknown (could not be determined)
  11. # freebsd, netbsd, openbsd, dragonfly, etc (The BSDs)
  12. # suse, rh, debian, gentoo (and possibly their descendants)
  13. # Other major Linux distributions (and possibly their descendants)
  14. # The O/S name for the rest
  15. #
  16. # LICENSE
  17. #
  18. # Copyright (c) 2016 Nagios Core Development Team
  19. #
  20. # This program is free software; you can redistribute it and/or modify it
  21. # under the terms of the GNU General Public License as published by the
  22. # Free Software Foundation; either version 2 of the License, or (at your
  23. # option) any later version.
  24. #
  25. # This program is distributed in the hope that it will be useful, but
  26. # WITHOUT ANY WARRANTY; without even the implied warranty of
  27. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  28. # Public License for more details.
  29. #
  30. # You should have received a copy of the GNU General Public License along
  31. # with this program. If not, see <http://www.gnu.org/licenses/>.
  32. #
  33. # As a special exception, the respective Autoconf Macro's copyright owner
  34. # gives unlimited permission to copy, distribute and modify the configure
  35. # scripts that are the output of Autoconf when processing the Macro. You
  36. # need not follow the terms of the GNU General Public License when using
  37. # or distributing such scripts, even though portions of the text of the
  38. # Macro appear in them. The GNU General Public License (GPL) does govern
  39. # all other use of the material that constitutes the Autoconf Macro.
  40. #
  41. # This special exception to the GPL applies to versions of the Autoconf
  42. # Macro released by the Autoconf Archive. When you make and distribute a
  43. # modified version of the Autoconf Macro, you may extend this special
  44. # exception to the GPL to apply to your modified version as well.
  45. # ===========================================================================
  46. AU_ALIAS([AC_NAGIOS_GET_DISTRIB_TYPE], [AX_NAGIOS_GET_DISTRIB_TYPE])
  47. AC_DEFUN([AX_NAGIOS_GET_DISTRIB_TYPE],
  48. [
  49. #
  50. # Get user hints for possible cross-compile
  51. #
  52. AC_MSG_CHECKING(what the distribution type is )
  53. AC_ARG_WITH(dist-type, AC_HELP_STRING([--with-dist-type=type],
  54. [specify distribution type (suse, rh, debian, etc.)]),
  55. [
  56. #
  57. # Run this if --with was specified
  58. #
  59. if test "x$withval" = x -o x$withval = xno; then
  60. dist_type_wanted=yes
  61. else
  62. dist_type_wanted=no
  63. dist_type="$withval"
  64. dist_ver="unknown"
  65. AC_MSG_RESULT($dist_type)
  66. fi
  67. ], [
  68. #
  69. # Run this if --with was not specified
  70. #
  71. dist_type_wanted=yes
  72. ])
  73. if test x$dist_type = xno; then
  74. dist_type_wanted=yes
  75. elif test x$dist_type = xyes; then
  76. AC_MSG_ERROR([you must enter a distribution type if '--with-dist-type' is specified])
  77. fi
  78. #
  79. # Determine distribution type if it wasn't supplied
  80. #
  81. dist_ver="unknown"
  82. if test $dist_type_wanted=yes; then
  83. dist_type="unknown"
  84. if test "$opsys" != "linux"; then
  85. dist_type="$opsys"
  86. AS_CASE([$opsys],
  87. [bsd],
  88. dist_type=`uname -s | tr ["[A-Z]" "[a-z]"]`
  89. dist_ver=`uname -r`,
  90. [aix|hp-ux],
  91. dist_ver=$OSTYPE,
  92. [solaris],
  93. dist_ver=`echo $OSTYPE | cut -d'.' -f2`,
  94. [*],
  95. dist_ver=$OSTYPE
  96. )
  97. else
  98. if test -r "/etc/gentoo-release"; then
  99. dist_type="gentoo"
  100. dist_ver=`cat /etc/gentoo-release`
  101. elif test -r "/etc/os-release"; then
  102. . /etc/os-release
  103. if test x"$ID_LIKE" != x; then
  104. dist_type=`echo $ID_LIKE | cut -d' ' -f1 | tr ["[A-Z]" "[a-z]"]`
  105. elif test x"$ID" = xol; then
  106. dist_type=rh
  107. else
  108. dist_type=`echo $ID | tr ["[A-Z]" "[a-z]"]`
  109. fi
  110. if test x"$dist_type" = sles; then
  111. dist_type=suse
  112. fi
  113. if test x"$VERSION_ID" != x; then
  114. dist_ver=$VERSION_ID
  115. elif test x"$VERSION" != x; then
  116. dist_ver=`echo $VERSION | cut -d'.' -f1 | tr -d [:alpha:][:blank:][:punct:]`
  117. fi
  118. elif test -r "/etc/redhat-release"; then
  119. dist_type=rh
  120. dist_ver=`cat /etc/redhat-release`
  121. elif test -r "/etc/debian_version"; then
  122. dist_type="debian"
  123. if test -r "/etc/lsb-release"; then
  124. . /etc/lsb-release
  125. dist_ver=`echo "$DISTRIB_RELEASE"`
  126. else
  127. dist_ver=`cat /etc/debian_version`
  128. fi
  129. elif test -r "/etc/SuSE-release"; then
  130. dist_type=suse
  131. dist_ver=`grep VERSION /etc/SuSE-release`
  132. fi
  133. fi
  134. if test "$dist_ver" != "unknown"; then
  135. dist_ver=`echo "$dist_ver" | cut -d'.' -f1 | tr -d [:alpha:][:blank:][:punct:]`
  136. fi
  137. fi
  138. AC_MSG_RESULT($dist_type)
  139. ])