summaryrefslogtreecommitdiff
path: root/autoconf
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-07-17 00:50:40 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-07-17 00:50:40 +0000
commita5e26077edb9611a0ea366c9f098a6e080f6da6b (patch)
tree22dfbd952b3e98f714bf4014f53976d281688446 /autoconf
parent0589523525a156e096baf975c5e6e7e4112cb673 (diff)
downloadllvm-a5e26077edb9611a0ea366c9f098a6e080f6da6b.tar.gz
llvm-a5e26077edb9611a0ea366c9f098a6e080f6da6b.tar.bz2
llvm-a5e26077edb9611a0ea366c9f098a6e080f6da6b.tar.xz
Add two new checks for use in LLVM configuration files:
* FIND_STD_PROGRAM will find a program in the path or using --with options and verify that the path/bin/program is executable. Also allows checking for include files and libraries. If found, USE_PROGRAM is set, otherwise its not set. Also sets PROGRAM_BIN (bin directory), and PROGRAM_DIR (top level directory). If headers are found, sets PROGRAM_INC. If libraries are found, sets PROGRAM_LIB. * CHECK_PROGRAM_SANITY can be used to run a program with some option that only produces information output and requires no input. If the output matches a regular expression, the program passes the sanity check. Otherwise, an error occurs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'autoconf')
-rw-r--r--autoconf/m4/find_std_program.m4112
-rw-r--r--autoconf/m4/sanity_check.m422
2 files changed, 134 insertions, 0 deletions
diff --git a/autoconf/m4/find_std_program.m4 b/autoconf/m4/find_std_program.m4
new file mode 100644
index 0000000000..e0245df5cb
--- /dev/null
+++ b/autoconf/m4/find_std_program.m4
@@ -0,0 +1,112 @@
+dnl Check for a standard program that has a bin, include and lib directory
+dnl
+dnl Parameters:
+dnl $1 - prefix directory to check
+dnl $2 - program name to check
+dnl $3 - header file to check
+dnl $4 - library file to check
+AC_DEFUN([CHECK_STD_PROGRAM],
+[m4_define([allcapsname],translit($2,a-z,A-Z))
+if test -n "$1" -a -d "$1" -a -n "$2" -a -d "$1/bin" -a -x "$1/bin/$2" ; then
+ AC_SUBST([USE_]allcapsname(),["USE_]allcapsname()[ = 1"])
+ AC_SUBST(allcapsname(),[$1/bin/$2])
+ AC_SUBST(allcapsname()[_BIN],[$1/bin])
+ AC_SUBST(allcapsname()[_DIR],[$1])
+ if test -n "$3" -a -d "$1/include" -a -f "$1/include/$3" ; then
+ AC_SUBST(allcapsname()[_INC],[$1/include])
+ fi
+ if test -n "$4" -a -d "$1/lib" -a -f "$1/lib/$4" ; then
+ AC_SUBST(allcapsname()[_LIB],[$1/lib])
+ fi
+fi
+])
+
+dnl Find a program via --with options, in the path, or well known places
+dnl
+dnl Parameters:
+dnl $1 - program name
+dnl $2 - header file name to check (optional)
+dnl $3 - library file name to check (optional)
+AC_DEFUN([FIND_STD_PROGRAM],
+[m4_define([allcapsname],translit($1,a-z,A-Z))
+AC_MSG_CHECKING([for ]$1[ 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])
+AC_ARG_WITH($1[-bin],
+ AS_HELP_STRING([--with-]$1[-bin=DIR],[Specify that ]$1[ binary are 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]),
+ $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]),
+ $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])
+ AC_MSG_RESULT([found via --with options])
+ else
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([The --with-]$1[-libdir value must be a directory])
+ fi
+ else
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([The --with-]$1[-incdir value must be a directory])
+ fi
+ else
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([The --with-]$1[-bindir value must be a directory])
+ fi
+ else
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([The --with-]$1[-incdir option must be specified])
+ fi
+ else
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([The --with-]$1[-libdir option must be specified])
+ fi
+else
+ tmppfxdir=`which $1 2>&1`
+ if test -n "$tmppfxdir" -a -d "${tmppfxdir%*$1}" -a \
+ -d "${tmppfxdir%*$1}/.." ; then
+ tmppfxdir=`cd "${tmppfxdir%*$1}/.." ; pwd`
+ CHECK_STD_PROGRAM($tmppfxdir,$1,$2,$3)
+ AC_MSG_RESULT([found in PATH at ]$tmppfxdir)
+ else
+ checkresult="yes"
+ checkvar="USE_"allcapsname()
+ CHECK_STD_PROGRAM([/usr],$1,$2,$3)
+ if test -z "${!checkvar}" ; then
+ CHECK_STD_PROGRAM([/usr/local],$1,$2,$3)
+ if test -z "${!checkvar}" ; then
+ CHECK_STD_PROGRAM([/sw],$1,$2,$3)
+ if test -z "${!checkvar}" ; then
+ CHECK_STD_PROGRAM([/opt],$1,$2,$3)
+ if test -z "${!checkvar}" ; then
+ CHECK_STD_PROGRAM([/],$1,$2,$3)
+ if test -z "${!checkvar}" ; then
+ checkresult="no"
+ fi
+ fi
+ fi
+ fi
+ fi
+ AC_MSG_RESULT($checkresult)
+ fi
+fi
+])
diff --git a/autoconf/m4/sanity_check.m4 b/autoconf/m4/sanity_check.m4
new file mode 100644
index 0000000000..5c4d1904fc
--- /dev/null
+++ b/autoconf/m4/sanity_check.m4
@@ -0,0 +1,22 @@
+dnl Check a program for version sanity. The test runs a program, passes it an
+dnl argument to make it print out some identification string, and filters that
+dnl output with a regular expression. If the output is non-empty, the program
+dnl passes the sanity check.
+dnl $1 - Name or full path of the program to run
+dnl $2 - Argument to pass to print out identification string
+dnl $3 - grep RE to match identification string
+AC_DEFUN([CHECK_PROGRAM_SANITY],
+[
+AC_MSG_CHECKING([sanity for program ]$1)
+sanity_path=`which $1 2>/dev/null`
+if test "$?" -eq 0 -a -x "$sanity_path" ; then
+ sanity=`$1 $2 2>&1 | grep "$3"`
+ if test -z "$sanity" ; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Program ]$1[ failed to pass sanity check.])
+ fi
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([not found])
+fi
+])