source: trunk/third/ORBit/ORBit.m4 @ 15271

Revision 15271, 8.6 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15270, which included commits to RCS files with non-trunk default branches.
Line 
1dnl AM_PATH_ORBIT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
2dnl Test for ORBit, and define ORBIT_CFLAGS and ORBIT_LIBS
3dnl
4AC_DEFUN(AM_PATH_ORBIT,
5[dnl
6dnl Get the cflags and libraries from the orbit-config script
7dnl
8AC_ARG_WITH(orbit-prefix,[  --with-orbit-prefix=PFX   Prefix where ORBIT is installed (optional)],
9            orbit_config_prefix="$withval", orbit_config_prefix="")
10AC_ARG_WITH(orbit-exec-prefix,[  --with-orbit-exec-prefix=PFX Exec prefix where ORBIT is installed (optional)],
11            orbit_config_exec_prefix="$withval", orbit_config_exec_prefix="")
12AC_ARG_ENABLE(orbittest, [  --disable-orbittest       Do not try to compile and run a test ORBIT program],
13                    , enable_orbittest=yes)
14
15  for module in . $4
16  do
17      case "$module" in
18         server)
19             orbit_config_args="$orbit_config_args server"
20         ;;
21         client)
22             orbit_config_args="$orbit_config_args client"
23         ;;
24      esac
25  done
26  if test x$orbit_config_args = x ; then
27        orbit_config_args=server
28  fi
29
30  if test x$orbit_config_exec_prefix != x ; then
31     orbit_config_args="$orbit_config_args --exec-prefix=$orbit_config_exec_prefix"
32     if test x${ORBIT_CONFIG+set} != xset ; then
33        ORBIT_CONFIG=$orbit_config_exec_prefix/bin/orbit-config
34     fi
35  fi
36  if test x$orbit_config_prefix != x ; then
37     orbit_config_args="$orbit_config_args --prefix=$orbit_config_prefix"
38     if test x${ORBIT_CONFIG+set} != xset ; then
39        ORBIT_CONFIG=$orbit_config_prefix/bin/orbit-config
40     fi
41  fi
42
43  AC_PATH_PROG(ORBIT_CONFIG, orbit-config, no)
44  min_orbit_version=ifelse([$1], , 0.5.1, $1)
45  AC_MSG_CHECKING(for ORBit - version >= $min_orbit_version)
46  no_orbit=""
47  if test "$ORBIT_CONFIG" = "no" ; then
48    no_orbit=yes
49  else
50    ORBIT_CFLAGS=`$ORBIT_CONFIG $orbit_config_args --cflags`
51    ORBIT_LIBS=`$ORBIT_CONFIG $orbit_config_args --libs`
52    orbit_config_major_version=`$ORBIT_CONFIG $orbit_config_args --version | \
53           sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
54    orbit_config_minor_version=`$ORBIT_CONFIG $orbit_config_args --version | \
55           sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
56    orbit_config_micro_version=`$ORBIT_CONFIG $orbit_config_args --version | \
57           sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
58    if test "x$enable_orbittest" = "xyes" ; then
59      ac_save_CFLAGS="$CFLAGS"
60      ac_save_LIBS="$LIBS"
61      CFLAGS="$CFLAGS $ORBIT_CFLAGS"
62      LIBS="$ORBIT_LIBS $LIBS"
63dnl
64dnl Now check if the installed ORBIT is sufficiently new. (Also sanity
65dnl checks the results of orbit-config to some extent
66dnl
67      rm -f conf.orbittest
68      AC_TRY_RUN([
69#include <orb/orbit.h>
70#include <stdio.h>
71#include <stdlib.h>
72
73int
74main ()
75{
76  int major, minor, micro;
77  char *tmp_version;
78
79  system ("touch conf.orbittest");
80
81  /* HP/UX 9 (%@#!) writes to sscanf strings */
82  tmp_version = g_strdup("$min_orbit_version");
83  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
84     printf("%s, bad version string\n", "$min_orbit_version");
85     exit(1);
86   }
87
88  if ((orbit_major_version != $orbit_config_major_version) ||
89      (orbit_minor_version != $orbit_config_minor_version) ||
90      (orbit_micro_version != $orbit_config_micro_version))
91    {
92      printf("\n*** 'orbit-config --version' returned %d.%d.%d, but ORBit (%d.%d.%d)\n",
93             $orbit_config_major_version, $orbit_config_minor_version, $orbit_config_micro_version,
94             orbit_major_version, orbit_minor_version, orbit_micro_version);
95      printf ("*** was found! If orbit-config was correct, then it is best\n");
96      printf ("*** to remove the old version of ORBit. You may also be able to fix the error\n");
97      printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
98      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
99      printf("*** required on your system.\n");
100      printf("*** If orbit-config was wrong, set the environment variable ORBIT_CONFIG\n");
101      printf("*** to point to the correct copy of orbit-config, and remove the file config.cache\n");
102      printf("*** before re-running configure\n");
103    }
104#if defined (ORBIT_MAJOR_VERSION) && defined (ORBIT_MINOR_VERSION) && defined (ORBIT_MICRO_VERSION)
105  else if ((orbit_major_version != ORBIT_MAJOR_VERSION) ||
106           (orbit_minor_version != ORBIT_MINOR_VERSION) ||
107           (orbit_micro_version != ORBIT_MICRO_VERSION))
108    {
109      printf("*** ORBit header files (version %d.%d.%d) do not match\n",
110             ORBIT_MAJOR_VERSION, ORBIT_MINOR_VERSION, ORBIT_MICRO_VERSION);
111      printf("*** library (version %d.%d.%d)\n",
112             orbit_major_version, orbit_minor_version, orbit_micro_version);
113    }
114#endif /* defined (ORBIT_MAJOR_VERSION) ... */
115  else
116    {
117      if ((orbit_major_version > major) ||
118        ((orbit_major_version == major) && (orbit_minor_version > minor)) ||
119        ((orbit_major_version == major) && (orbit_minor_version == minor) && (orbit_micro_version >= micro)))
120      {
121        return 0;
122       }
123     else
124      {
125        printf("\n*** An old version of ORBit (%d.%d.%d) was found.\n",
126               orbit_major_version, orbit_minor_version, orbit_micro_version);
127        printf("*** You need a version of ORBit newer than %d.%d.%d. The latest version of\n",
128               major, minor, micro);
129        printf("*** ORBit is always available from ftp://ftp.orbit.org.\n");
130        printf("***\n");
131        printf("*** If you have already installed a sufficiently new version, this error\n");
132        printf("*** probably means that the wrong copy of the orbit-config shell script is\n");
133        printf("*** being found. The easiest way to fix this is to remove the old version\n");
134        printf("*** of ORBit, but you can also set the ORBIT_CONFIG environment to point to the\n");
135        printf("*** correct copy of orbit-config. (In this case, you will have to\n");
136        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
137        printf("*** so that the correct libraries are found at run-time))\n");
138      }
139    }
140  return 1;
141}
142],, no_orbit=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
143       CFLAGS="$ac_save_CFLAGS"
144       LIBS="$ac_save_LIBS"
145     fi
146  fi
147  if test "x$no_orbit" = x ; then
148     AC_MSG_RESULT(yes)
149     ifelse([$2], , :, [$2])     
150  else
151     AC_MSG_RESULT(no)
152     if test "$ORBIT_CONFIG" = "no" ; then
153       echo "*** The orbit-config script installed by ORBIT could not be found"
154       echo "*** If ORBit was installed in PREFIX, make sure PREFIX/bin is in"
155       echo "*** your path, or set the ORBIT_CONFIG environment variable to the"
156       echo "*** full path to orbit-config."
157     else
158       if test -f conf.orbittest ; then
159        :
160       else
161          echo "*** Could not run ORBIT test program, checking why..."
162          CFLAGS="$CFLAGS $ORBIT_CFLAGS"
163          LIBS="$LIBS $ORBIT_LIBS"
164          AC_TRY_LINK([
165#include <orb/orbit.h>
166#include <stdio.h>
167],      [ return ((orbit_major_version) || (orbit_minor_version) || (orbit_micro_version)); ],
168        [ echo "*** The test program compiled, but did not run. This usually means"
169          echo "*** that the run-time linker is not finding ORBit or finding the wrong"
170          echo "*** version of ORBit. If it is not finding ORBit, you'll need to set your"
171          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
172          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
173          echo "*** is required on your system"
174          echo "***"
175          echo "*** If you have an old version installed, it is best to remove it, although"
176          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
177          echo "***"
178          echo "*** If you have a RedHat 5.0 system, you should remove the ORBit package that"
179          echo "*** came with the system with the command"
180          echo "***"
181          echo "***    rpm --erase --nodeps orbit orbit-devel" ],
182        [ echo "*** The test program failed to compile or link. See the file config.log for the"
183          echo "*** exact error that occured. This usually means ORBIT was incorrectly installed"
184          echo "*** or that you have moved ORBit since it was installed. In the latter case, you"
185          echo "*** may want to edit the orbit-config script: $ORBIT_CONFIG" ])
186          CFLAGS="$ac_save_CFLAGS"
187          LIBS="$ac_save_LIBS"
188       fi
189     fi
190     ORBIT_CFLAGS=""
191     ORBIT_LIBS=""
192     ifelse([$3], , :, [$3])
193  fi
194
195  AC_PATH_PROG(ORBIT_IDL, orbit-idl, ifelse([$3], , :, [$3]))
196  AC_SUBST(ORBIT_CFLAGS)
197  AC_SUBST(ORBIT_LIBS)
198  AC_SUBST(ORBIT_IDL)
199  rm -f conf.orbittest
200])
Note: See TracBrowser for help on using the repository browser.