various AC_HELP_STRING changes
[platform/upstream/gst-plugins-good.git] / m4 / xmms.m4
1 # CFLAGS and library paths for XMMS
2 # written 15 December 1999 by Ben Gertzfield <che@debian.org>
3
4 dnl Usage:
5 dnl AM_PATH_XMMS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
6 dnl
7 dnl Example:
8 dnl AM_PATH_XMMS(0.9.5.1, , AC_MSG_ERROR([*** XMMS >= 0.9.5.1 not installed - please install first ***]))
9 dnl
10 dnl Defines XMMS_CFLAGS, XMMS_LIBS, XMMS_DATA_DIR, XMMS_PLUGIN_DIR, 
11 dnl XMMS_VISUALIZATION_PLUGIN_DIR, XMMS_INPUT_PLUGIN_DIR, 
12 dnl XMMS_OUTPUT_PLUGIN_DIR, XMMS_GENERAL_PLUGIN_DIR, XMMS_EFFECT_PLUGIN_DIR,
13 dnl and XMMS_VERSION for your plugin pleasure.
14 dnl
15
16 dnl XMMS_TEST_VERSION(AVAILABLE-VERSION, NEEDED-VERSION [, ACTION-IF-OKAY [, ACTION-IF-NOT-OKAY]])
17 AC_DEFUN(XMMS_TEST_VERSION, [
18
19 # Determine which version number is greater. Prints 2 to stdout if      
20 # the second number is greater, 1 if the first number is greater,       
21 # 0 if the numbers are equal.                                           
22                                                                         
23 # Written 15 December 1999 by Ben Gertzfield <che@debian.org>           
24 # Revised 15 December 1999 by Jim Monty <monty@primenet.com>            
25                                                                         
26     AC_PROG_AWK
27     xmms_got_version=[` $AWK '                                          \
28 BEGIN {                                                                 \
29     print vercmp(ARGV[1], ARGV[2]);                                     \
30 }                                                                       \
31                                                                         \
32 function vercmp(ver1, ver2,    ver1arr, ver2arr,                        \
33                                ver1len, ver2len,                        \
34                                ver1int, ver2int, len, i, p) {           \
35                                                                         \
36     ver1len = split(ver1, ver1arr, /\./);                               \
37     ver2len = split(ver2, ver2arr, /\./);                               \
38                                                                         \
39     len = ver1len > ver2len ? ver1len : ver2len;                        \
40                                                                         \
41     for (i = 1; i <= len; i++) {                                        \
42         p = 1000 ^ (len - i);                                           \
43         ver1int += ver1arr[i] * p;                                      \
44         ver2int += ver2arr[i] * p;                                      \
45     }                                                                   \
46                                                                         \
47     if (ver1int < ver2int)                                              \
48         return 2;                                                       \
49     else if (ver1int > ver2int)                                         \
50         return 1;                                                       \
51     else                                                                \
52         return 0;                                                       \
53 }' $1 $2`]                                                              
54
55     if test $xmms_got_version -eq 2; then       # failure
56         ifelse([$4], , :, $4)                   
57     else                                        # success!
58         ifelse([$3], , :, $3)
59     fi
60 ])
61
62 AC_DEFUN(AM_PATH_XMMS,
63 [
64 AC_ARG_WITH(xmms-prefix,
65   AC_HELP_STRING([--with-xmms-prefix=PFX],
66                  [prefix where XMMS is installed (optional)]),
67   xmms_config_prefix="$withval", xmms_config_prefix="")
68
69 AC_ARG_WITH(xmms-exec-prefix,
70   AC_HELP_STRING([--with-xmms-exec-prefix=PFX],
71                  [exec prefix where XMMS is installed (optional)]),
72   xmms_config_exec_prefix="$withval", xmms_config_exec_prefix="")
73
74 if test x$xmms_config_exec_prefix != x; then
75     xmms_config_args="$xmms_config_args --exec-prefix=$xmms_config_exec_prefix"
76     if test x${XMMS_CONFIG+set} != xset; then
77         XMMS_CONFIG=$xmms_config_exec_prefix/bin/xmms-config
78     fi
79 fi
80
81 if test x$xmms_config_prefix != x; then
82     xmms_config_args="$xmms_config_args --prefix=$xmms_config_prefix"
83     if test x${XMMS_CONFIG+set} != xset; then
84         XMMS_CONFIG=$xmms_config_prefix/bin/xmms-config
85     fi
86 fi
87
88 AC_PATH_PROG(XMMS_CONFIG, xmms-config, no)
89 min_xmms_version=ifelse([$1], ,0.9.5.1, $1)
90
91 if test "$XMMS_CONFIG" = "no"; then
92     no_xmms=yes
93 else
94     XMMS_CFLAGS=`$XMMS_CONFIG $xmms_config_args --cflags`
95     XMMS_LIBS=`$XMMS_CONFIG $xmms_config_args --libs`
96     XMMS_VERSION=`$XMMS_CONFIG $xmms_config_args --version`
97     XMMS_DATA_DIR=`$XMMS_CONFIG $xmms_config_args --data-dir`
98     XMMS_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --plugin-dir`
99     XMMS_VISUALIZATION_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args \
100                                         --visualization-plugin-dir`
101     XMMS_INPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --input-plugin-dir`
102     XMMS_OUTPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --output-plugin-dir`
103     XMMS_EFFECT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --effect-plugin-dir`
104     XMMS_GENERAL_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --general-plugin-dir`
105
106     XMMS_TEST_VERSION($XMMS_VERSION, $min_xmms_version, ,no_xmms=version)
107 fi
108
109 AC_MSG_CHECKING(for XMMS - version >= $min_xmms_version)
110
111 if test "x$no_xmms" = x; then
112     AC_MSG_RESULT(yes)
113     ifelse([$2], , :, [$2])
114 else
115     AC_MSG_RESULT(no)
116
117     if test "$XMMS_CONFIG" = "no" ; then
118         echo "*** The xmms-config script installed by XMMS could not be found."
119         echo "*** If XMMS was installed in PREFIX, make sure PREFIX/bin is in"
120         echo "*** your path, or set the XMMS_CONFIG environment variable to the"
121         echo "*** full path to xmms-config."
122     else
123         if test "$no_xmms" = "version"; then
124             echo "*** An old version of XMMS, $XMMS_VERSION, was found."
125             echo "*** You need a version of XMMS newer than $min_xmms_version."
126             echo "*** The latest version of XMMS is always available from"
127             echo "*** http://www.xmms.org/"
128             echo "***"
129
130             echo "*** If you have already installed a sufficiently new version, this error"
131             echo "*** probably means that the wrong copy of the xmms-config shell script is"
132             echo "*** being found. The easiest way to fix this is to remove the old version"
133             echo "*** of XMMS, but you can also set the XMMS_CONFIG environment to point to the"
134             echo "*** correct copy of xmms-config. (In this case, you will have to"
135             echo "*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf"
136             echo "*** so that the correct libraries are found at run-time)"
137         fi
138     fi
139     XMMS_CFLAGS=""
140     XMMS_LIBS=""
141     ifelse([$3], , :, [$3])
142 fi
143 AC_SUBST(XMMS_CFLAGS)
144 AC_SUBST(XMMS_LIBS)
145 AC_SUBST(XMMS_VERSION)
146 AC_SUBST(XMMS_DATA_DIR)
147 AC_SUBST(XMMS_PLUGIN_DIR)
148 AC_SUBST(XMMS_VISUALIZATION_PLUGIN_DIR)
149 AC_SUBST(XMMS_INPUT_PLUGIN_DIR)
150 AC_SUBST(XMMS_OUTPUT_PLUGIN_DIR)
151 AC_SUBST(XMMS_GENERAL_PLUGIN_DIR)
152 AC_SUBST(XMMS_EFFECT_PLUGIN_DIR)
153 ])