dnl Find a program via --with options, in the path, or well known places
dnl
dnl Parameters:
-dnl $1 - program name
+dnl $1 - program's executable name
dnl $2 - header file name to check (optional)
dnl $3 - library file name to check (optional)
+dnl $4 - alternate (long) name for the program
AC_DEFUN([FIND_STD_PROGRAM],
[m4_define([allcapsname],translit($1,a-z,A-Z))
-AC_MSG_CHECKING([for ]$1[ bin/lib/include locations])
+m4_define([stdprog_long_name],ifelse($4,,translit($1,[ !@#$%^&*()-+={}[]:;"',./?],[-]),translit($4,[ !@#$%^&*()-+={}[]:;"',./?],[-])))
+AC_MSG_CHECKING([for ]stdprog_long_name()[ bin/lib/include locations])
AC_ARG_WITH($1,
- AS_HELP_STRING([--with-]$1[=DIR],[Specify that ]$1['s install prefix is DIR]),
- $1[pfxdir=$withval],$1[pfxdir=nada])
+ AS_HELP_STRING([--with-]stdprog_long_name()[=DIR],
+ [Specify that the ]stdprog_long_name()[ install prefix is DIR]),
+ $1[pfxdir=$withval],$1[pfxdir=nada])
AC_ARG_WITH($1[-bin],
- AS_HELP_STRING([--with-]$1[-bin=DIR],[Specify that ]$1[ binary are in DIR]),
+ AS_HELP_STRING([--with-]stdprog_long_name()[-bin=DIR],
+ [Specify that the ]stdprog_long_name()[ binary is in DIR]),
$1[bindir=$withval],$1[bindir=nada])
AC_ARG_WITH($1[-lib],
- AS_HELP_STRING([--with-]$1[-lib=DIR],[Specify that ]$1[ libs are in DIR]),
+ AS_HELP_STRING([--with-]stdprog_long_name()[-lib=DIR],
+ [Specify that ]stdprog_long_name()[ libraries are in DIR]),
$1[libdir=$withval],$1[libdir=nada])
AC_ARG_WITH($1[-inc],
- AS_HELP_STRING([--with-]$1[-inc=DIR],[Specify that ]$1[ includes are in DIR]),
+ AS_HELP_STRING([--with-]stdprog_long_name()[-inc=DIR],
+ [Specify that the ]stdprog_long_name()[ includes are in DIR]),
$1[incdir=$withval],$1[incdir=nada])
-pfxvar=$1pfxdir
-binvar=$1bindir
-incvar=$1incdir
-libvar=$1libdir
-if test "${!pfxvar}" != "nada" ; then
- CHECK_STD_PROGRAM(${!pfxvar},$1,$2,$3)
-elif test "${!binvar}" != "nada" ; then
- if test "${!libvar}" != "nada" ; then
- if test "${!incvar}" != "nada" ; then
- if test -d "${!binvar}" ; then
- if test -d "${!incvar}" ; then
- if test -d "${!libvar}" ; then
- AC_SUBST(allcapsname(),${!binvar}/$1)
- AC_SUBST(allcapsname()[_BIN],${!binvar})
- AC_SUBST(allcapsname()[_INC],${!incvar})
- AC_SUBST(allcapsname()[_LIB],${!libvar})
- AC_SUBST([USE_]allcapsname(),[1])
+eval pfxval=\$\{$1pfxdir\}
+eval binval=\$\{$1bindir\}
+eval incval=\$\{$1incdir\}
+eval libval=\$\{$1libdir\}
+if test "${pfxval}" != "nada" ; then
+ CHECK_STD_PROGRAM(${pfxval},$1,$2,$3)
+elif test "${binval}" != "nada" ; then
+ if test "${libval}" != "nada" ; then
+ if test "${incval}" != "nada" ; then
+ if test -d "${binval}" ; then
+ if test -d "${incval}" ; then
+ if test -d "${libval}" ; then
+ AC_SUBST(allcapsname(),${binval}/$1)
+ AC_SUBST(allcapsname()[_BIN],${binval})
+ AC_SUBST(allcapsname()[_INC],${incval})
+ AC_SUBST(allcapsname()[_LIB],${libval})
+ AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"])
AC_MSG_RESULT([found via --with options])
else
AC_MSG_RESULT([failed])
AC_MSG_RESULT([found in PATH at ]$tmppfxdir)
else
checkresult="yes"
- checkvar="USE_"allcapsname()
+ eval checkval=\$\{"USE_"allcapsname()\}
CHECK_STD_PROGRAM([/usr],$1,$2,$3)
- if test -z "${!checkvar}" ; then
+ if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/usr/local],$1,$2,$3)
- if test -z "${!checkvar}" ; then
+ if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/sw],$1,$2,$3)
- if test -z "${!checkvar}" ; then
+ if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/opt],$1,$2,$3)
- if test -z "${!checkvar}" ; then
+ if test -z "${checkval}" ; then
CHECK_STD_PROGRAM([/],$1,$2,$3)
- if test -z "${!checkvar}" ; then
+ if test -z "${checkval}" ; then
checkresult="no"
fi
fi