| 1 | # Copyright (c) 2005-2008 David Carter <dcarter@arm4.org> and others. |
|---|
| 2 | # All rights reserved. This program and the accompanying materials |
|---|
| 3 | # are made available under the terms of the Eclipse Public License v1.0 |
|---|
| 4 | # which accompanies this distribution, and is available at |
|---|
| 5 | # http://www.eclipse.org/legal/epl-v10.html |
|---|
| 6 | |
|---|
| 7 | # Macros to check the version for the ant java build system |
|---|
| 8 | AC_DEFUN([ARM4_VERSION_ANT], |
|---|
| 9 | [ |
|---|
| 10 | min_ant_version=ifelse([$1], ,1.6,$1) |
|---|
| 11 | ANT="" |
|---|
| 12 | AC_ARG_WITH(ant, |
|---|
| 13 | [ --with-ant=PATH prefix for installed ant build manager], |
|---|
| 14 | [ |
|---|
| 15 | ant_found="no" |
|---|
| 16 | ant_root="" |
|---|
| 17 | if test "$withval" = "no" || test "$withval" = "yes"; then |
|---|
| 18 | AC_MSG_ERROR([--with-ant requires the full path to the ant program]) |
|---|
| 19 | fi |
|---|
| 20 | |
|---|
| 21 | if test "$ant_found" != "yes" && test -x "$withval" > /dev/null 2>&1 ; then |
|---|
| 22 | ant_found="yes" |
|---|
| 23 | ANT="$withval" |
|---|
| 24 | fi |
|---|
| 25 | |
|---|
| 26 | dnl if --with-ant is used, it is a fatal error for its argument |
|---|
| 27 | dnl to be invalid |
|---|
| 28 | if test "$ant_found" != "yes"; then |
|---|
| 29 | AC_MSG_ERROR([the --with-ant parameter is incorrect. It must specify the location of the ant executable.]) |
|---|
| 30 | fi |
|---|
| 31 | ],[ |
|---|
| 32 | AC_PATH_PROG(ANT, ant, no) |
|---|
| 33 | AC_MSG_CHECKING(for ant - version >= $min_ant_version) |
|---|
| 34 | no_ant="" |
|---|
| 35 | if test "$ANT" = "no" ; then |
|---|
| 36 | no_ant=yes |
|---|
| 37 | else |
|---|
| 38 | ant_major_version=`$ANT -version | \ |
|---|
| 39 | grep Ant | \ |
|---|
| 40 | awk '{print \[$]4}' | cut -d . -f 1` |
|---|
| 41 | if test "x${ant_major_version}" = "x" ; then |
|---|
| 42 | ant_major_version=0 |
|---|
| 43 | fi |
|---|
| 44 | |
|---|
| 45 | ant_minor_version=`$ANT -version | \ |
|---|
| 46 | grep Ant | \ |
|---|
| 47 | awk '{print \[$]4}' | cut -d . -f 2` |
|---|
| 48 | if test "x${ant_minor_version}" = "x" ; then |
|---|
| 49 | ant_minor_version=0 |
|---|
| 50 | fi |
|---|
| 51 | |
|---|
| 52 | ant_micro_version=`$ANT -version | \ |
|---|
| 53 | grep Ant | \ |
|---|
| 54 | awk '{print \[$]4}' | cut -d . -f 3` |
|---|
| 55 | if test "x${ant_micro_version}" = "x" ; then |
|---|
| 56 | ant_micro_version=0 |
|---|
| 57 | fi |
|---|
| 58 | |
|---|
| 59 | enable_anttest=yes |
|---|
| 60 | if test "x$enable_anttest" = "xyes" ; then |
|---|
| 61 | rm -f conf.anttest |
|---|
| 62 | AC_RUN_IFELSE([ |
|---|
| 63 | #include <stdio.h> |
|---|
| 64 | #include <stdlib.h> |
|---|
| 65 | #include <string.h> |
|---|
| 66 | |
|---|
| 67 | char* my_strdup (const char *str); |
|---|
| 68 | |
|---|
| 69 | char* |
|---|
| 70 | my_strdup (const char *str) |
|---|
| 71 | { |
|---|
| 72 | char *new_str; |
|---|
| 73 | |
|---|
| 74 | if (str) |
|---|
| 75 | { |
|---|
| 76 | new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); |
|---|
| 77 | strcpy (new_str, str); |
|---|
| 78 | } |
|---|
| 79 | else |
|---|
| 80 | new_str = NULL; |
|---|
| 81 | |
|---|
| 82 | return new_str; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | int main (void) |
|---|
| 86 | { |
|---|
| 87 | int major = 0, minor = 0, micro = 0; |
|---|
| 88 | int n; |
|---|
| 89 | char *tmp_version; |
|---|
| 90 | |
|---|
| 91 | system ("touch conf.anttest"); |
|---|
| 92 | |
|---|
| 93 | /* HP/UX 9 (%@#!) writes to sscanf strings */ |
|---|
| 94 | tmp_version = my_strdup("$min_ant_version"); |
|---|
| 95 | |
|---|
| 96 | n = sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) ; |
|---|
| 97 | |
|---|
| 98 | if (n != 2 && n != 3) { |
|---|
| 99 | printf("%s, bad version string\n", "$min_ant_version"); |
|---|
| 100 | exit(1); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | if (($ant_major_version > major) || |
|---|
| 104 | (($ant_major_version == major) && ($ant_minor_version > minor)) || |
|---|
| 105 | (($ant_major_version == major) && ($ant_minor_version == minor) && ($ant_micro_version >= micro))) |
|---|
| 106 | { |
|---|
| 107 | exit(0); |
|---|
| 108 | } |
|---|
| 109 | else |
|---|
| 110 | { |
|---|
| 111 | printf("\n*** 'ant -version' returned %d.%d.%d, but the minimum version\n", $ant_major_version, $ant_minor_version, $ant_micro_version); |
|---|
| 112 | printf("*** of ant required is %d.%d.%d. If ant is correct, then it is\n", major, minor, micro); |
|---|
| 113 | printf("*** best to upgrade to the required version.\n"); |
|---|
| 114 | exit(1); |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | ],, no_ant=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
|---|
| 119 | fi |
|---|
| 120 | fi |
|---|
| 121 | if test "x$no_ant" = x ; then |
|---|
| 122 | AC_MSG_RESULT(yes) |
|---|
| 123 | ifelse([$2], , :, [$2]) |
|---|
| 124 | else |
|---|
| 125 | AC_MSG_RESULT(no) |
|---|
| 126 | if test "$ant" = "no" ; then |
|---|
| 127 | echo "*** The ant program could not be found" |
|---|
| 128 | echo "*** If ant was installed in PREFIX, make sure PREFIX/bin is in" |
|---|
| 129 | echo "*** your path." |
|---|
| 130 | fi |
|---|
| 131 | ifelse([$3], , :, [$3]) |
|---|
| 132 | fi |
|---|
| 133 | rm -f conf.anttest |
|---|
| 134 | ]) |
|---|
| 135 | AC_SUBST(ANT) |
|---|
| 136 | ]) |
|---|
| 137 | |
|---|
| 138 | |
|---|