cares-system.m4 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #***************************************************************************
  2. # $Id$
  3. #
  4. # Copyright (C) 2008 by Daniel Stenberg et al
  5. #
  6. # Permission to use, copy, modify, and distribute this software and its
  7. # documentation for any purpose and without fee is hereby granted, provided
  8. # that the above copyright notice appear in all copies and that both that
  9. # copyright notice and this permission notice appear in supporting
  10. # documentation, and that the name of M.I.T. not be used in advertising or
  11. # publicity pertaining to distribution of the software without specific,
  12. # written prior permission. M.I.T. makes no representations about the
  13. # suitability of this software for any purpose. It is provided "as is"
  14. # without express or implied warranty.
  15. #
  16. #***************************************************************************
  17. # File version for 'aclocal' use. Keep it a single number.
  18. # serial 2
  19. dnl CARES_CHECK_PATH_SEPARATOR
  20. dnl -------------------------------------------------
  21. dnl Check and compute the path separator for us. This
  22. dnl path separator is the symbol used to diferentiate
  23. dnl or separate paths inside the PATH environment var.
  24. AC_DEFUN([CARES_CHECK_PATH_SEPARATOR], [
  25. if test -z "$cares_cv_PATH_SEPARATOR"; then
  26. if test -z "$PATH"; then
  27. AC_MSG_ERROR([PATH not set. Cannot continue without PATH being set.])
  28. fi
  29. dnl Directory count in PATH when using a colon separator.
  30. tst_dirs_col=0
  31. tst_save_IFS=$IFS; IFS=':'
  32. for tst_dir in $PATH; do
  33. IFS=$tst_save_IFS
  34. test -d "$tst_dir" && tst_dirs_col=`expr $tst_dirs_col + 1`
  35. done
  36. IFS=$tst_save_IFS
  37. dnl Directory count in PATH when using a semicolon separator.
  38. tst_dirs_sem=0
  39. tst_save_IFS=$IFS; IFS=';'
  40. for tst_dir in $PATH; do
  41. IFS=$tst_save_IFS
  42. test -d "$tst_dir" && tst_dirs_sem=`expr $tst_dirs_sem + 1`
  43. done
  44. IFS=$tst_save_IFS
  45. if test $tst_dirs_sem -eq $tst_dirs_col; then
  46. dnl When both counting methods give the same result we do not want to
  47. dnl chose one over the other, and consider auto-detection not possible.
  48. if test -z "$PATH_SEPARATOR"; then
  49. dnl Stop dead until user provides PATH_SEPARATOR definition.
  50. AC_MSG_ERROR([PATH_SEPARATOR not set. Cannot continue without it.])
  51. fi
  52. else
  53. dnl Separator with the greater directory count is the auto-detected one.
  54. if test $tst_dirs_sem -gt $tst_dirs_col; then
  55. tst_auto_separator=';'
  56. else
  57. tst_auto_separator=':'
  58. fi
  59. if test -z "$PATH_SEPARATOR"; then
  60. dnl Simply use the auto-detected one when not already set.
  61. PATH_SEPARATOR="$tst_auto_separator"
  62. fi
  63. fi
  64. cares_cv_PATH_SEPARATOR="$PATH_SEPARATOR"
  65. fi
  66. AC_SUBST([PATH_SEPARATOR])
  67. AC_SUBST([PATH])
  68. ])