3 dnl $Id: as-arts.m4,v 1.5 2004/05/21 11:20:49 thomasvs Exp $
4 dnl if you copy this file to your cvs,
5 dnl add this file using cvs -ko add to retain this header
7 dnl This is an example arts .m4 adapted and scrubbed by thomasvs
9 # Configure paths for ARTS
10 # Philip Stadermann 2001-06-21
13 dnl AM_PATH_ARTS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
14 dnl Test for ARTS, and define ARTS_CXXFLAGS and ARTS_LIBS
16 AC_DEFUN([AM_PATH_ARTS],
18 dnl Get the cflags and libraries from the artsc-config script
20 AC_ARG_WITH(arts-prefix,
21 AC_HELP_STRING([--with-arts-prefix=PFX],
22 [prefix where ARTS is installed (optional)]),
23 arts_prefix="$withval", arts_prefix="")
25 AC_ARG_WITH(arts-exec-prefix,
26 AC_HELP_STRING([--with-arts-exec-prefix=PFX],
27 [exec prefix where ARTS is installed (optional)]),
28 arts_exec_prefix="$withval", arts_exec_prefix="")
30 AC_ARG_ENABLE(artstest,
31 AC_HELP_STRING([--disable-artstest],
32 [do not try to compile and run a test ARTS program]),
33 , enable_artstest=yes)
35 if test x$arts_exec_prefix != x ; then
36 arts_args="$arts_args --exec-prefix=$arts_exec_prefix"
37 if test x${ARTS_CONFIG+set} != xset ; then
38 ARTS_CONFIG=$arts_exec_prefix/bin/artsc-config
41 if test x$arts_prefix != x ; then
42 arts_args="$arts_args --prefix=$arts_prefix"
43 if test x${ARTS_CONFIG+set} != xset ; then
44 ARTS_CONFIG=$arts_prefix/bin/artsc-config
48 AC_PATH_PROG(ARTS_CONFIG, artsc-config, no)
49 min_arts_version=ifelse([$1], ,0.9.5,$1)
50 AC_MSG_CHECKING(for ARTS artsc - version >= $min_arts_version)
52 if test "$ARTS_CONFIG" = "no" ; then
55 # FIXME: thomas added this sed to get arts path instead of artsc
56 # replace -I.../artsc with -I.../arts
57 ARTS_CXXFLAGS=`$ARTS_CONFIG $artsconf_args --cflags | artsc-config --cflags | sed 's/\(-I.*\)artsc/\1arts/'`
58 ARTS_LIBS=`$ARTS_CONFIG $artsconf_args --libs | sed 's/artsc$/arts/'`
60 arts_major_version=`$ARTS_CONFIG $arts_args --version | \
61 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
62 arts_minor_version=`$ARTS_CONFIG $arts_args --version | \
63 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
64 arts_micro_version=`$ARTS_CONFIG $arts_config_args --version | \
65 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
66 if test "x$enable_artstest" = "xyes" ; then
67 dnl ac_save_CXXFLAGS="$CXXFLAGS"
68 dnl ac_save_LIBS="$LIBS"
69 dnl CFLAGS="$CFLAGS $ARTS_CXXFLAGS"
70 dnl LIBS="$LIBS $ARTS_LIBS"
72 dnl Now check if the installed ARTS is sufficiently new. (Also sanity
73 dnl checks the results of artsc-config to some extent)
76 dnl a*s: to successfully compile the C++ test app, we need to
77 dnl first make sure we're going to compile it as C++ (with AC_LANG_PUSH),
78 dnl then add the CFLAGS and CLIBS of arts which we just discovered to the
79 dnl C++ compilation and linking flags.
80 dnl We also need to clean up after the test; this means using AC_LANG_POP
81 dnl and restoring the CPPFLAGS and LDFLAGS from the saved values we take
84 dnl ask nicely for C++ compilation
87 dnl save compilation and link flags and make our own
88 ac_save_CPPFLAGS="$CPPFLAGS"
89 ac_save_LDFLAGS="$LDFLAGS"
90 AC_SUBST(CPPFLAGS,"$CPPFLAGS $ARTS_CXXFLAGS")
91 AC_SUBST(LDFLAGS,"$LDFLAGS $ARTS_CLIBS")
101 my_strdup (char *str)
107 // thomas: the original test did not have the typecast
108 new_str = (char *) malloc ((strlen (str) + 1) * sizeof(char));
109 strcpy (new_str, str);
119 int major, minor, micro;
122 system ("touch conf.artstest");
124 /* HP/UX 9 (%@#!) writes to sscanf strings */
125 tmp_version = my_strdup("$min_arts_version");
126 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
127 printf("%s, bad version string\n", "$min_arts_version");
131 if (($arts_major_version > major) ||
132 (($arts_major_version == major) && ($arts_minor_version > minor)) ||
133 (($arts_major_version == major) && ($arts_minor_version == minor) && ($arts_micro_version >= micro)))
139 printf("\n*** 'artsc-config --version' returned %d.%d.%d, but the minimum version\n", $arts_major_version, $arts_minor_version, $arts_micro_version);
140 printf("*** of ARTS required is %d.%d.%d. If artsc-config is correct, then it is\n", major, minor, micro);
141 printf("*** best to upgrade to the required version.\n");
142 printf("*** If artsc-config was wrong, set the environment variable ARTS_CONFIG\n");
143 printf("*** to point to the correct copy of artsc-config, and remove the file\n");
144 printf("*** config.cache before re-running configure\n");
149 ],, no_arts=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
150 dnl CFLAGS="$ac_save_CFLAGS"
151 dnl LIBS="$ac_save_LIBS"
152 dnl a*s this is were we clean up after the test
154 CXXFLAGS="$ac_save_CXXFLAGS"
155 LDFLAGS="$ac_save_LDFLAGS"
156 dnl a*s we are sure that these are right, so we make them active
157 AC_SUBST(CXXFLAGS,"$CXXFLAGS")
158 AC_SUBST(LDFLAGS,"$LDFLAGS")
161 if test "x$no_arts" = x ; then
163 ifelse([$2], , :, [$2])
166 if test "$ARTS_CONFIG" = "no" ; then
167 echo "*** The artsc-config script installed by ARTS could not be found"
168 echo "*** If ARTS was installed in PREFIX, make sure PREFIX/bin is in"
169 echo "*** your path, or set the ARTS_CONFIG environment variable to the"
170 echo "*** full path to artsc-config."
172 if test -f conf.artstest ; then
175 echo "*** Could not run ARTS test program, checking why..."
176 CFLAGS="$CFLAGS $ARTS_CXXFLAGS"
177 LIBS="$LIBS $ARTS_LIBS"
180 #include <artsflow.h>
182 [ echo "*** The test program compiled, but did not run. This usually means"
183 echo "*** that the run-time linker is not finding ARTS or finding the wrong"
184 echo "*** version of ARTS. If it is not finding ARTS, you'll need to set your"
185 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
186 echo "*** to the installed location Also, make sure you have run ldconfig if that"
187 echo "*** is required on your system"
189 echo "*** If you have an old version installed, it is best to remove it, although"
190 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
191 [ echo "*** The test program failed to compile or link. See the file config.log for the"
192 echo "*** exact error that occured. This usually means ARTS was incorrectly installed"
193 echo "*** or that you have moved ARTS since it was installed. In the latter case, you"
194 echo "*** may want to edit the artsc-config script: $ARTS_CONFIG" ])
195 CFLAGS="$ac_save_CFLAGS"
201 ifelse([$3], , :, [$3])
203 AC_SUBST(ARTS_CXXFLAGS)
208 dnl release C++ question