release c++ checking comment out test
[platform/upstream/gstreamer.git] / m4 / gst-arts.m4
1 # Configure paths for ARTS
2 # Philip Stadermann   2001-06-21
3 # stolen from esd.m4
4 # adapted and scrubbed by thomas
5
6 dnl AM_PATH_ARTS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
7 dnl Test for ARTS, and define ARTS_CFLAGS and ARTS_LIBS
8 dnl
9 AC_DEFUN([AM_PATH_ARTS],
10 [dnl 
11 dnl Get the cflags and libraries from the artsc-config script
12 dnl
13 AC_ARG_WITH(arts-prefix,[  --with-arts-prefix=PFX  Prefix where ARTS is installed (optional)],
14             arts_prefix="$withval", arts_prefix="")
15 AC_ARG_WITH(arts-exec-prefix,[  --with-arts-exec-prefix=PFX                                                                             Exec prefix where ARTS is installed (optional)],
16             arts_exec_prefix="$withval", arts_exec_prefix="")
17 AC_ARG_ENABLE(artstest, [  --disable-artstest      Do not try to compile and run a test ARTS program],
18                     , enable_artstest=yes)
19
20   if test x$arts_exec_prefix != x ; then
21      arts_args="$arts_args --exec-prefix=$arts_exec_prefix"
22      if test x${ARTS_CONFIG+set} != xset ; then
23         ARTS_CONFIG=$arts_exec_prefix/bin/artsc-config
24      fi
25   fi
26   if test x$arts_prefix != x ; then
27      arts_args="$arts_args --prefix=$arts_prefix"
28      if test x${ARTS_CONFIG+set} != xset ; then
29         ARTS_CONFIG=$arts_prefix/bin/artsc-config
30      fi
31   fi
32
33   AC_PATH_PROG(ARTS_CONFIG, artsc-config, no)
34   min_arts_version=ifelse([$1], ,0.9.5,$1)
35   AC_MSG_CHECKING(for ARTS artsc - version >= $min_arts_version)
36   no_arts=""
37   if test "$ARTS_CONFIG" = "no" ; then
38     no_arts=yes
39   else
40     # FIXME : thomas added this sed to get arts path instead of artsc
41     ARTS_CFLAGS=`$ARTS_CONFIG $artsconf_args --cflags | sed 's/artsc$/arts/'`
42     ARTS_LIBS=`$ARTS_CONFIG $artsconf_args --libs | sed 's/artsc$/arts/'`
43
44     arts_major_version=`$ARTS_CONFIG $arts_args --version | \
45            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
46     arts_minor_version=`$ARTS_CONFIG $arts_args --version | \
47            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
48     arts_micro_version=`$ARTS_CONFIG $arts_config_args --version | \
49            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
50     if test "x$enable_artstest" = "xyes" ; then
51       ac_save_CFLAGS="$CFLAGS"
52       ac_save_LIBS="$LIBS"
53       CFLAGS="$CFLAGS $ARTS_CFLAGS"
54       LIBS="$LIBS $ARTS_LIBS"
55 dnl
56 dnl Now check if the installed ARTS is sufficiently new. (Also sanity
57 dnl checks the results of artsc-config to some extent)
58 dnl
59 dnl thomas: ask nicely for C++ compilation
60 AC_LANG_PUSH(C++)
61 AC_SUBST(CPPFLAGS,"$CPPFLAGS $ARTS_CFLAGS")
62 AC_SUBST(LDFLAGS,"$LDFLAGS $ARTS_CLIBS") 
63      rm -f conf.artstest
64       AC_TRY_RUN([
65 #include <stdio.h>
66 #include <stdlib.h>
67 #include <string.h>
68 #include <artsflow.h>
69
70 char*
71 my_strdup (char *str)
72 {
73   char *new_str;
74   
75   if (str)
76     {
77       // thomas: the original test did not have the typecast
78       new_str = (char *) malloc ((strlen (str) + 1) * sizeof(char));
79       strcpy (new_str, str);
80     }
81   else
82     new_str = NULL;
83   
84   return new_str;
85 }
86
87 int main ()
88 {
89   int major, minor, micro;
90   char *tmp_version;
91
92   system ("touch conf.artstest");
93
94   /* HP/UX 9 (%@#!) writes to sscanf strings */
95   tmp_version = my_strdup("$min_arts_version");
96   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
97      printf("%s, bad version string\n", "$min_arts_version");
98      exit(1);
99    }
100
101    if (($arts_major_version > major) ||
102       (($arts_major_version == major) && ($arts_minor_version > minor)) ||
103       (($arts_major_version == major) && ($arts_minor_version == minor) && ($arts_micro_version >= micro)))
104     {
105       return 0;
106     }
107   else
108     {
109       printf("\n*** 'artsc-config --version' returned %d.%d.%d, but the minimum version\n", $arts_major_version, $arts_minor_version, $arts_micro_version);
110       printf("*** of ARTS required is %d.%d.%d. If artsc-config is correct, then it is\n", major, minor, micro);
111       printf("*** best to upgrade to the required version.\n");
112       printf("*** If artsc-config was wrong, set the environment variable ARTS_CONFIG\n");
113       printf("*** to point to the correct copy of artsc-config, and remove the file\n");
114       printf("*** config.cache before re-running configure\n");
115       return 1;
116     }
117 }
118
119 ],, no_arts=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
120        CFLAGS="$ac_save_CFLAGS"
121        LIBS="$ac_save_LIBS"
122      fi
123   fi
124   if test "x$no_arts" = x ; then
125      AC_MSG_RESULT(yes)
126      ifelse([$2], , :, [$2])     
127   else
128      AC_MSG_RESULT(no)
129      if test "$ARTS_CONFIG" = "no" ; then
130        echo "*** The artsc-config script installed by ARTS could not be found"
131        echo "*** If ARTS was installed in PREFIX, make sure PREFIX/bin is in"
132        echo "*** your path, or set the ARTS_CONFIG environment variable to the"
133        echo "*** full path to artsc-config."
134      else
135        if test -f conf.artstest ; then
136         :
137        else
138           echo "*** Could not run ARTS test program, checking why..."
139           CFLAGS="$CFLAGS $ARTS_CFLAGS"
140           LIBS="$LIBS $ARTS_LIBS"
141           AC_TRY_LINK([
142 #include <stdio.h>
143 #include <artsflow.h>
144 ],      [ return 0; ],
145         [ echo "*** The test program compiled, but did not run. This usually means"
146           echo "*** that the run-time linker is not finding ARTS or finding the wrong"
147           echo "*** version of ARTS. If it is not finding ARTS, you'll need to set your"
148           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
149           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
150           echo "*** is required on your system"
151           echo "***"
152           echo "*** If you have an old version installed, it is best to remove it, although"
153           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
154         [ echo "*** The test program failed to compile or link. See the file config.log for the"
155           echo "*** exact error that occured. This usually means ARTS was incorrectly installed"
156           echo "*** or that you have moved ARTS since it was installed. In the latter case, you"
157           echo "*** may want to edit the artsc-config script: $ARTS_CONFIG" ])
158           CFLAGS="$ac_save_CFLAGS"
159           LIBS="$ac_save_LIBS"
160        fi
161      fi
162      ARTS_CFLAGS=""
163      ARTS_LIBS=""
164      ifelse([$3], , :, [$3])
165   fi
166   AC_SUBST(ARTS_CFLAGS)
167   AC_SUBST(ARTS_LIBS)
168   rm -f conf.artstest
169 ])
170 dnl release C++ question
171 AC_LANG_POP(C++)
172