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