1dnl 2dnl AC_PROG_GPERF (MINIMUM-VERSION) 3dnl 4dnl Check for availability of gperf. 5dnl Abort if not found or if current version is not up to par. 6dnl 7 8AC_DEFUN([AC_PROG_GPERF],[ 9 AC_PATH_PROG(GPERF, gperf, no) 10 if test "$GPERF" = no; then 11 AC_MSG_ERROR(Could not find gperf) 12 fi 13 min_gperf_version=ifelse([$1], ,2.7,$1) 14 AC_MSG_CHECKING(for gperf - version >= $min_gperf_version) 15 gperf_major_version=`$GPERF --version | \ 16 sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\1/'` 17 gperf_minor_version=`$GPERF --version | \ 18 sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\2/'` 19 no_gperf="" 20dnl 21dnl Now check if the installed gperf is sufficiently new. 22dnl 23 AC_TRY_RUN([ 24#include <stdio.h> 25#include <stdlib.h> 26#include <string.h> 27 28static char* 29my_strdup (char *str) 30{ 31 char *new_str; 32 33 if (str) 34 { 35 new_str = malloc ((strlen (str) + 1) * sizeof(char)); 36 strcpy (new_str, str); 37 } 38 else 39 new_str = NULL; 40 41 return new_str; 42} 43 44int 45main () 46{ 47 char *tmp_version; 48 49 int major; 50 int minor; 51 52 /* HP/UX 9 (%@#!) writes to sscanf strings */ 53 tmp_version = my_strdup("$min_gperf_version"); 54 if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) { 55 printf ("%s, bad version string\n", "$min_gperf_version"); 56 exit (1); 57 } 58 59 if (($gperf_major_version > major) || 60 (($gperf_major_version == major) && ($gperf_minor_version >= minor))) { 61 return 0; 62 } else { 63 printf ("\n"); 64 printf ("*** An old version of gperf ($gperf_major_version.$gperf_minor_version) was found.\n"); 65 printf ("*** You need a version of gperf newer than %d.%d.%d. The latest version of\n", 66 major, minor); 67 printf ("*** gperf is always available from ftp://ftp.gnu.org.\n"); 68 printf ("***\n"); 69 return 1; 70 } 71} 72],,no_gperf=yes,[/bin/true]) 73 if test "x$no_gperf" = x ; then 74 AC_MSG_RESULT(yes) 75 else 76 AC_MSG_RESULT(no) 77 fi 78 79]) 80