1 # This is an example arts .m4 adapted and scrubbed by thomasvs
3 # Configure paths for ARTS
4 # Philip Stadermann 2001-06-21
7 dnl AM_PATH_ARTS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
8 dnl Test for ARTS, and define ARTS_CXXFLAGS and ARTS_LIBS
10 AC_DEFUN([AM_PATH_ARTS],
12 dnl Get the cflags and libraries from the artsc-config script
14 AC_ARG_WITH(arts-prefix,[ --with-arts-prefix=PFX Prefix where ARTS is installed (optional)],
15 arts_prefix="$withval", arts_prefix="")
16 AC_ARG_WITH(arts-exec-prefix,[ --with-arts-exec-prefix=PFX Exec prefix where ARTS is installed (optional)],
17 arts_exec_prefix="$withval", arts_exec_prefix="")
18 AC_ARG_ENABLE(artstest, [ --disable-artstest Do not try to compile and run a test ARTS program],
19 , enable_artstest=yes)
21 if test x$arts_exec_prefix != x ; then
22 arts_args="$arts_args --exec-prefix=$arts_exec_prefix"
23 if test x${ARTS_CONFIG+set} != xset ; then
24 ARTS_CONFIG=$arts_exec_prefix/bin/artsc-config
27 if test x$arts_prefix != x ; then
28 arts_args="$arts_args --prefix=$arts_prefix"
29 if test x${ARTS_CONFIG+set} != xset ; then
30 ARTS_CONFIG=$arts_prefix/bin/artsc-config
34 AC_PATH_PROG(ARTS_CONFIG, artsc-config, no)
35 min_arts_version=ifelse([$1], ,0.9.5,$1)
36 AC_MSG_CHECKING(for ARTS artsc - version >= $min_arts_version)
38 if test "$ARTS_CONFIG" = "no" ; then
41 # FIXME : thomas added this sed to get arts path instead of artsc
42 ARTS_CXXFLAGS=`$ARTS_CONFIG $artsconf_args --cflags | sed 's/artsc$/arts/'`
43 ARTS_LIBS=`$ARTS_CONFIG $artsconf_args --libs | sed 's/artsc$/arts/'`
45 arts_major_version=`$ARTS_CONFIG $arts_args --version | \
46 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
47 arts_minor_version=`$ARTS_CONFIG $arts_args --version | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
49 arts_micro_version=`$ARTS_CONFIG $arts_config_args --version | \
50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
51 if test "x$enable_artstest" = "xyes" ; then
52 dnl ac_save_CXXFLAGS="$CXXFLAGS"
53 dnl ac_save_LIBS="$LIBS"
54 dnl CFLAGS="$CFLAGS $ARTS_CXXFLAGS"
55 dnl LIBS="$LIBS $ARTS_LIBS"
57 dnl Now check if the installed ARTS is sufficiently new. (Also sanity
58 dnl checks the results of artsc-config to some extent)
61 dnl a*s: to successfully compile the C++ test app, we need to
62 dnl first make sure we're going to compile it as C++ (with AC_LANG_PUSH),
63 dnl then add the CFLAGS and CLIBS of arts which we just discovered to the
64 dnl C++ compilation and linking flags.
65 dnl We also need to clean up after the test; this means using AC_LANG_POP
66 dnl and restoring the CPPFLAGS and LDFLAGS from the saved values we take
69 dnl ask nicely for C++ compilation
72 dnl save compilation and link flags and make our own
73 ac_save_CPPFLAGS="$CPPFLAGS"
74 ac_save_LDFLAGS="$LDFLAGS"
75 AC_SUBST(CPPFLAGS,"$CPPFLAGS $ARTS_CXXFLAGS")
76 AC_SUBST(LDFLAGS,"$LDFLAGS $ARTS_CLIBS")
92 // thomas: the original test did not have the typecast
93 new_str = (char *) malloc ((strlen (str) + 1) * sizeof(char));
94 strcpy (new_str, str);
104 int major, minor, micro;
107 system ("touch conf.artstest");
109 /* HP/UX 9 (%@#!) writes to sscanf strings */
110 tmp_version = my_strdup("$min_arts_version");
111 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
112 printf("%s, bad version string\n", "$min_arts_version");
116 if (($arts_major_version > major) ||
117 (($arts_major_version == major) && ($arts_minor_version > minor)) ||
118 (($arts_major_version == major) && ($arts_minor_version == minor) && ($arts_micro_version >= micro)))
124 printf("\n*** 'artsc-config --version' returned %d.%d.%d, but the minimum version\n", $arts_major_version, $arts_minor_version, $arts_micro_version);
125 printf("*** of ARTS required is %d.%d.%d. If artsc-config is correct, then it is\n", major, minor, micro);
126 printf("*** best to upgrade to the required version.\n");
127 printf("*** If artsc-config was wrong, set the environment variable ARTS_CONFIG\n");
128 printf("*** to point to the correct copy of artsc-config, and remove the file\n");
129 printf("*** config.cache before re-running configure\n");
134 ],, no_arts=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
135 dnl CFLAGS="$ac_save_CFLAGS"
136 dnl LIBS="$ac_save_LIBS"
137 dnl a*s this is were we clean up after the test
139 CXXFLAGS="$ac_save_CXXFLAGS"
140 LDFLAGS="$ac_save_LDFLAGS"
141 dnl a*s we are sure that these are right, so we make them active
142 AC_SUBST(CXXFLAGS,"$CXXFLAGS")
143 AC_SUBST(LDFLAGS,"$LDFLAGS")
146 if test "x$no_arts" = x ; then
148 ifelse([$2], , :, [$2])
151 if test "$ARTS_CONFIG" = "no" ; then
152 echo "*** The artsc-config script installed by ARTS could not be found"
153 echo "*** If ARTS was installed in PREFIX, make sure PREFIX/bin is in"
154 echo "*** your path, or set the ARTS_CONFIG environment variable to the"
155 echo "*** full path to artsc-config."
157 if test -f conf.artstest ; then
160 echo "*** Could not run ARTS test program, checking why..."
161 CFLAGS="$CFLAGS $ARTS_CXXFLAGS"
162 LIBS="$LIBS $ARTS_LIBS"
165 #include <artsflow.h>
167 [ echo "*** The test program compiled, but did not run. This usually means"
168 echo "*** that the run-time linker is not finding ARTS or finding the wrong"
169 echo "*** version of ARTS. If it is not finding ARTS, you'll need to set your"
170 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
171 echo "*** to the installed location Also, make sure you have run ldconfig if that"
172 echo "*** is required on your system"
174 echo "*** If you have an old version installed, it is best to remove it, although"
175 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
176 [ echo "*** The test program failed to compile or link. See the file config.log for the"
177 echo "*** exact error that occured. This usually means ARTS was incorrectly installed"
178 echo "*** or that you have moved ARTS since it was installed. In the latter case, you"
179 echo "*** may want to edit the artsc-config script: $ARTS_CONFIG" ])
180 CFLAGS="$ac_save_CFLAGS"
186 ifelse([$3], , :, [$3])
188 AC_SUBST(ARTS_CXXFLAGS)
193 dnl release C++ question