1dnl Check for a standard program that has a bin, include and lib directory 2dnl 3dnl Parameters: 4dnl $1 - prefix directory to check 5dnl $2 - program name to check 6dnl $3 - header file to check 7dnl $4 - library file to check 8AC_DEFUN([CHECK_STD_PROGRAM], 9[m4_define([allcapsname],translit($2,a-z,A-Z)) 10if test -n "$1" -a -d "$1" -a -n "$2" -a -d "$1/bin" -a -x "$1/bin/$2" ; then 11 AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"]) 12 AC_SUBST(allcapsname(),[$1/bin/$2]) 13 AC_SUBST(allcapsname()[_BIN],[$1/bin]) 14 AC_SUBST(allcapsname()[_DIR],[$1]) 15 if test -n "$3" -a -d "$1/include" -a -f "$1/include/$3" ; then 16 AC_SUBST(allcapsname()[_INC],[$1/include]) 17 fi 18 if test -n "$4" -a -d "$1/lib" -a -f "$1/lib/$4" ; then 19 AC_SUBST(allcapsname()[_LIB],[$1/lib]) 20 fi 21fi 22]) 23 24dnl Find a program via --with options, in the path, or well known places 25dnl 26dnl Parameters: 27dnl $1 - program's executable name 28dnl $2 - header file name to check (optional) 29dnl $3 - library file name to check (optional) 30dnl $4 - alternate (long) name for the program 31AC_DEFUN([FIND_STD_PROGRAM], 32[m4_define([allcapsname],translit($1,a-z,A-Z)) 33m4_define([stdprog_long_name],ifelse($4,,translit($1,[ !@#$%^&*()-+={}[]:;"',./?],[-]),translit($4,[ !@#$%^&*()-+={}[]:;"',./?],[-]))) 34AC_MSG_CHECKING([for ]stdprog_long_name()[ bin/lib/include locations]) 35AC_ARG_WITH($1, 36 AS_HELP_STRING([--with-]stdprog_long_name()[=DIR], 37 [Specify that the ]stdprog_long_name()[ install prefix is DIR]), 38 $1[pfxdir=$withval],$1[pfxdir=nada]) 39AC_ARG_WITH($1[-bin], 40 AS_HELP_STRING([--with-]stdprog_long_name()[-bin=DIR], 41 [Specify that the ]stdprog_long_name()[ binary is in DIR]), 42 $1[bindir=$withval],$1[bindir=nada]) 43AC_ARG_WITH($1[-lib], 44 AS_HELP_STRING([--with-]stdprog_long_name()[-lib=DIR], 45 [Specify that ]stdprog_long_name()[ libraries are in DIR]), 46 $1[libdir=$withval],$1[libdir=nada]) 47AC_ARG_WITH($1[-inc], 48 AS_HELP_STRING([--with-]stdprog_long_name()[-inc=DIR], 49 [Specify that the ]stdprog_long_name()[ includes are in DIR]), 50 $1[incdir=$withval],$1[incdir=nada]) 51eval pfxval=\$\{$1pfxdir\} 52eval binval=\$\{$1bindir\} 53eval incval=\$\{$1incdir\} 54eval libval=\$\{$1libdir\} 55if test "${pfxval}" != "nada" ; then 56 CHECK_STD_PROGRAM(${pfxval},$1,$2,$3) 57elif test "${binval}" != "nada" ; then 58 if test "${libval}" != "nada" ; then 59 if test "${incval}" != "nada" ; then 60 if test -d "${binval}" ; then 61 if test -d "${incval}" ; then 62 if test -d "${libval}" ; then 63 AC_SUBST(allcapsname(),${binval}/$1) 64 AC_SUBST(allcapsname()[_BIN],${binval}) 65 AC_SUBST(allcapsname()[_INC],${incval}) 66 AC_SUBST(allcapsname()[_LIB],${libval}) 67 AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"]) 68 AC_MSG_RESULT([found via --with options]) 69 else 70 AC_MSG_RESULT([failed]) 71 AC_MSG_ERROR([The --with-]$1[-libdir value must be a directory]) 72 fi 73 else 74 AC_MSG_RESULT([failed]) 75 AC_MSG_ERROR([The --with-]$1[-incdir value must be a directory]) 76 fi 77 else 78 AC_MSG_RESULT([failed]) 79 AC_MSG_ERROR([The --with-]$1[-bindir value must be a directory]) 80 fi 81 else 82 AC_MSG_RESULT([failed]) 83 AC_MSG_ERROR([The --with-]$1[-incdir option must be specified]) 84 fi 85 else 86 AC_MSG_RESULT([failed]) 87 AC_MSG_ERROR([The --with-]$1[-libdir option must be specified]) 88 fi 89else 90 tmppfxdir=`which $1 2>&1` 91 if test -n "$tmppfxdir" -a -d "${tmppfxdir%*$1}" -a \ 92 -d "${tmppfxdir%*$1}/.." ; then 93 tmppfxdir=`cd "${tmppfxdir%*$1}/.." ; pwd` 94 CHECK_STD_PROGRAM($tmppfxdir,$1,$2,$3) 95 AC_MSG_RESULT([found in PATH at ]$tmppfxdir) 96 else 97 checkresult="yes" 98 eval checkval=\$\{"USE_"allcapsname()\} 99 CHECK_STD_PROGRAM([/usr],$1,$2,$3) 100 if test -z "${checkval}" ; then 101 CHECK_STD_PROGRAM([/usr/local],$1,$2,$3) 102 if test -z "${checkval}" ; then 103 CHECK_STD_PROGRAM([/sw],$1,$2,$3) 104 if test -z "${checkval}" ; then 105 CHECK_STD_PROGRAM([/opt],$1,$2,$3) 106 if test -z "${checkval}" ; then 107 CHECK_STD_PROGRAM([/],$1,$2,$3) 108 if test -z "${checkval}" ; then 109 checkresult="no" 110 fi 111 fi 112 fi 113 fi 114 fi 115 AC_MSG_RESULT($checkresult) 116 fi 117fi 118]) 119