Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 1 | dnl Check for a standard program that has a bin, include and lib directory |
| 2 | dnl |
| 3 | dnl Parameters: |
| 4 | dnl $1 - prefix directory to check |
| 5 | dnl $2 - program name to check |
| 6 | dnl $3 - header file to check |
| 7 | dnl $4 - library file to check |
| 8 | AC_DEFUN([CHECK_STD_PROGRAM], |
| 9 | [m4_define([allcapsname],translit($2,a-z,A-Z)) |
| 10 | if 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 |
| 21 | fi |
| 22 | ]) |
| 23 | |
| 24 | dnl Find a program via --with options, in the path, or well known places |
| 25 | dnl |
| 26 | dnl Parameters: |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 27 | dnl $1 - program's executable name |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 28 | dnl $2 - header file name to check (optional) |
| 29 | dnl $3 - library file name to check (optional) |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 30 | dnl $4 - alternate (long) name for the program |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 31 | AC_DEFUN([FIND_STD_PROGRAM], |
| 32 | [m4_define([allcapsname],translit($1,a-z,A-Z)) |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 33 | m4_define([stdprog_long_name],ifelse($4,,translit($1,[ !@#$%^&*()-+={}[]:;"',./?],[-]),translit($4,[ !@#$%^&*()-+={}[]:;"',./?],[-]))) |
| 34 | AC_MSG_CHECKING([for ]stdprog_long_name()[ bin/lib/include locations]) |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 35 | AC_ARG_WITH($1, |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 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]) |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 39 | AC_ARG_WITH($1[-bin], |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 40 | AS_HELP_STRING([--with-]stdprog_long_name()[-bin=DIR], |
| 41 | [Specify that the ]stdprog_long_name()[ binary is in DIR]), |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 42 | $1[bindir=$withval],$1[bindir=nada]) |
| 43 | AC_ARG_WITH($1[-lib], |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 44 | AS_HELP_STRING([--with-]stdprog_long_name()[-lib=DIR], |
| 45 | [Specify that ]stdprog_long_name()[ libraries are in DIR]), |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 46 | $1[libdir=$withval],$1[libdir=nada]) |
| 47 | AC_ARG_WITH($1[-inc], |
Reid Spencer | 72f71e1 | 2005-07-17 05:30:33 +0000 | [diff] [blame] | 48 | AS_HELP_STRING([--with-]stdprog_long_name()[-inc=DIR], |
| 49 | [Specify that the ]stdprog_long_name()[ includes are in DIR]), |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 50 | $1[incdir=$withval],$1[incdir=nada]) |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 51 | eval pfxval=\$\{$1pfxdir\} |
| 52 | eval binval=\$\{$1bindir\} |
| 53 | eval incval=\$\{$1incdir\} |
Reid Spencer | cc2665d | 2006-08-14 23:15:03 +0000 | [diff] [blame] | 54 | eval libval=\$\{$1libdir\} |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 55 | if test "${pfxval}" != "nada" ; then |
| 56 | CHECK_STD_PROGRAM(${pfxval},$1,$2,$3) |
| 57 | elif 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}) |
Reid Spencer | 9977ea6 | 2006-08-14 23:19:57 +0000 | [diff] [blame] | 67 | AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"]) |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 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 |
| 89 | else |
| 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" |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 98 | eval checkval=\$\{"USE_"allcapsname()\} |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 99 | CHECK_STD_PROGRAM([/usr],$1,$2,$3) |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 100 | if test -z "${checkval}" ; then |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 101 | CHECK_STD_PROGRAM([/usr/local],$1,$2,$3) |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 102 | if test -z "${checkval}" ; then |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 103 | CHECK_STD_PROGRAM([/sw],$1,$2,$3) |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 104 | if test -z "${checkval}" ; then |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 105 | CHECK_STD_PROGRAM([/opt],$1,$2,$3) |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 106 | if test -z "${checkval}" ; then |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 107 | CHECK_STD_PROGRAM([/],$1,$2,$3) |
Reid Spencer | 675267e | 2005-07-25 20:25:08 +0000 | [diff] [blame] | 108 | if test -z "${checkval}" ; then |
Reid Spencer | a5e2607 | 2005-07-17 00:50:40 +0000 | [diff] [blame] | 109 | checkresult="no" |
| 110 | fi |
| 111 | fi |
| 112 | fi |
| 113 | fi |
| 114 | fi |
| 115 | AC_MSG_RESULT($checkresult) |
| 116 | fi |
| 117 | fi |
| 118 | ]) |