Git init
[external/curl.git] / m4 / curl-system.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 #***************************************************************************
22
23 # File version for 'aclocal' use. Keep it a single number.
24 # serial 3
25
26
27 dnl CURL_CHECK_PATH_SEPARATOR
28 dnl -------------------------------------------------
29 dnl Check and compute the path separator for us. This
30 dnl path separator is the symbol used to diferentiate
31 dnl or separate paths inside the PATH environment var.
32
33 AC_DEFUN([CURL_CHECK_PATH_SEPARATOR], [
34   if test -z "$curl_cv_PATH_SEPARATOR"; then
35     if test -z "$PATH"; then
36       AC_MSG_ERROR([PATH not set. Cannot continue without PATH being set.])
37     fi
38     dnl Directory count in PATH when using a colon separator.
39     tst_dirs_col=0
40     tst_save_IFS=$IFS; IFS=':'
41     for tst_dir in $PATH; do
42       IFS=$tst_save_IFS
43       test -d "$tst_dir" && tst_dirs_col=`expr $tst_dirs_col + 1`
44     done
45     IFS=$tst_save_IFS
46     dnl Directory count in PATH when using a semicolon separator.
47     tst_dirs_sem=0
48     tst_save_IFS=$IFS; IFS=';'
49     for tst_dir in $PATH; do
50       IFS=$tst_save_IFS
51       test -d "$tst_dir" && tst_dirs_sem=`expr $tst_dirs_sem + 1`
52     done
53     IFS=$tst_save_IFS
54     if test $tst_dirs_sem -eq $tst_dirs_col; then
55       dnl When both counting methods give the same result we do not want to
56       dnl chose one over the other, and consider auto-detection not possible.
57       if test -z "$PATH_SEPARATOR"; then
58         dnl Stop dead until user provides PATH_SEPARATOR definition.
59         AC_MSG_ERROR([PATH_SEPARATOR not set. Cannot continue without it.])
60       fi
61     else
62       dnl Separator with the greater directory count is the auto-detected one.
63       if test $tst_dirs_sem -gt $tst_dirs_col; then
64         tst_auto_separator=';'
65       else
66         tst_auto_separator=':'
67       fi
68       if test -z "$PATH_SEPARATOR"; then
69         dnl Simply use the auto-detected one when not already set.
70         PATH_SEPARATOR="$tst_auto_separator"
71       fi
72     fi
73     curl_cv_PATH_SEPARATOR="$PATH_SEPARATOR"
74   fi
75   AC_SUBST([PATH_SEPARATOR])
76   AC_SUBST([PATH])
77 ])
78
79
80 dnl CURL_CHECK_PATH_SEPARATOR_REQUIRED
81 dnl -------------------------------------------------
82 dnl Use this to ensure that the path separator check
83 dnl macro is only expanded and included once.
84
85 AC_DEFUN([CURL_CHECK_PATH_SEPARATOR_REQUIRED], [
86   AC_REQUIRE([CURL_CHECK_PATH_SEPARATOR])dnl
87 ])
88