summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2018-04-28 23:41:16 (GMT)
committerAlexey Neyman <stilor@att.net>2018-04-29 19:06:54 (GMT)
commit74979fb19b2c7220dab4196c0d34e0c29b341b09 (patch)
tree6ae4685ef53ec2b10593fe19fc1397bc8619f311 /m4
parent0f34b0ebf0651fd26fde1646ac1fb4031e0c57a2 (diff)
Add checking for *sum and unzip
Also improve logging (add an ability to log commands/files/environment variables to config.log) Signed-off-by: Alexey Neyman <stilor@att.net>
Diffstat (limited to 'm4')
-rw-r--r--m4/ctng_log.m429
-rw-r--r--m4/ctng_prog.m417
-rw-r--r--m4/ctng_prog_stat.m410
-rw-r--r--m4/ctng_version_check.m427
4 files changed, 67 insertions, 16 deletions
diff --git a/m4/ctng_log.m4 b/m4/ctng_log.m4
new file mode 100644
index 0000000..3f1428c
--- /dev/null
+++ b/m4/ctng_log.m4
@@ -0,0 +1,29 @@
+# CTNG_MSG_LOG(MSG)
+# Log the MSG message to config.log
+AC_DEFUN([CTNG_MSG_LOG],
+ [AS_ECHO(["$as_me:${as_lineno-$LINENO}: AS_ESCAPE([$1])"]) >&AS_MESSAGE_LOG_FD])
+
+# CTNG_MSG_LOG_CMD(CMD, [DESC])
+# Log the output of a command CMD to config.log, prepending the
+# description DESC.
+AC_DEFUN([CTNG_MSG_LOG_CMD],
+ [AS_IF([test -n "AS_ESCAPE([$2])"],
+ [AS_ECHO(["$as_me:${as_lineno-$LINENO}: AS_ESCAPE([$2]):"]) >&AS_MESSAGE_LOG_FD],
+ [AS_ECHO(["$as_me:${as_lineno-$LINENO}: output from command '$1':"]) >&AS_MESSAGE_LOG_FD])
+ $1 | sed 's/^/| /' >&AS_MESSAGE_LOG_FD])
+
+# CTNG_MSG_LOG_ENVVAR(VAR, [DESC])
+# Log the contents of an environment variable VAR to config.log, prepending the
+# description DESC.
+AC_DEFUN([CTNG_MSG_LOG_ENVVAR],
+ [AS_IF([test -n "AS_ESCAPE([$2])"],
+ [CTNG_MSG_LOG_CMD([AS_ECHO(["$$1"])], [$2])],
+ [CTNG_MSG_LOG_CMD([AS_ECHO(["$$1"])], [variable $1 is set to])])])
+
+# CTNG_MSG_LOG_FILE(FILE, [DESC])
+# Log the contents of a file FILE to config.log, prepending the
+# description DESC.
+AC_DEFUN([CTNG_MSG_LOG_FILE],
+ [AS_IF([test -n "AS_ESCAPE([$2])"],
+ [CTNG_MSG_LOG_CMD([cat $1], [$2])],
+ [CTNG_MSG_LOG_CMD([cat $1], [contents of $1])])])
diff --git a/m4/ctng_prog.m4 b/m4/ctng_prog.m4
index ebbe333..7ac9ef3 100644
--- a/m4/ctng_prog.m4
+++ b/m4/ctng_prog.m4
@@ -1,5 +1,15 @@
# Several convenience wrappers for checking the programs
+# Convert a pre-set tool variable to absolute path if it is not already.
+AC_DEFUN([CTNG_PATH_ABSNAME],
+ [CTNG_MSG_LOG_ENVVAR([$1], [must determine absolute path for '$$1'])
+ AS_CASE([$$1],
+ [/*],,
+ [*\ *],,
+ [?*],[AC_MSG_CHECKING([for absolute path to $$1])
+ $1=$(which $$1)
+ AC_MSG_RESULT([$$1])])])
+
# Check for required tool
AC_DEFUN([CTNG_CHECK_TOOL_REQ],
[AC_CHECK_TOOLS([$1], [$2])
@@ -12,12 +22,7 @@ AC_DEFUN([CTNG_CHECK_TOOL_REQ],
AC_DEFUN([CTNG_PATH_TOOL_REQ],
[AC_ARG_VAR([$1], [Specify the full path to GNU $3])
CTNG_CHECK_TOOL_REQ([$1], [$2])
- AS_CASE(
- [$$1],
- [/*],,
- [?*],[AC_MSG_CHECKING([for absolute path to $$1])
- $1=$(which $$1)
- AC_MSG_RESULT([$$1])])])
+ CTNG_PATH_ABSNAME([$1])])
# Check for required program
AC_DEFUN([CTNG_CHECK_PROGS_REQ],
diff --git a/m4/ctng_prog_stat.m4 b/m4/ctng_prog_stat.m4
index 6bee076..8a0b26a 100644
--- a/m4/ctng_prog_stat.m4
+++ b/m4/ctng_prog_stat.m4
@@ -7,9 +7,13 @@ AC_DEFUN([CTNG_PROG_STAT_FORMAT],
[ctng_cv_stat_flavor],
[touch conftest
chmod 642 conftest
- attr_bsd=$(stat -f '%Lp' conftest 2>/dev/null)
- attr_gnu=$(stat -c '%a' conftest 2>/dev/null)
- rm -f conftest
+ attr_bsd=$(stat -f '%Lp' conftest 2>conftest.stderr.bsd)
+ CTNG_MSG_LOG_ENVVAR([attr_bsd], [stat -f output])
+ CTNG_MSG_LOG_FILE([conftest.stderr.bsd])
+ attr_gnu=$(stat -c '%a' conftest 2>conftest.stderr.gnu)
+ CTNG_MSG_LOG_ENVVAR([attr_gnu], [stat -c output])
+ CTNG_MSG_LOG_FILE([conftest.stderr.gnu])
+ rm -f conftest conftest.stderr.*
AS_IF([test "$attr_bsd" = "642"],
[ctng_cv_stat_flavor=BSD],
[test "$attr_gnu" = "642"],
diff --git a/m4/ctng_version_check.m4 b/m4/ctng_version_check.m4
index 703661b..4518e0c 100644
--- a/m4/ctng_version_check.m4
+++ b/m4/ctng_version_check.m4
@@ -11,14 +11,27 @@ AC_DEFUN([CTNG_PROG_VERSION],
CTNG_WITH_DEPRECATED([$3], [$1])
AC_ARG_VAR([$1], [Specify the full path to $2])
ctng_version_$1_ok=false
- AC_CACHE_CHECK([for $3], [ac_cv_path_$1],
- [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4],
- [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5)
- test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1
- test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: ctng_version_$1_ok=:]])])
+ # If a variable is already set, check if it an absolute path and convert if not.
+ # Autoconf's AC_PATH_PROGS* macros just blindly trust $1 to be correct - but
+ # AWK is set to just the command name by AC_INIT.
AS_IF([test -n "$$1"],
- [[ver=$($ac_cv_path_$1 --version 2>/dev/null| $EGREP $5)
- test -n "$ver" && ctng_version_$1_ok=:]])
+ [ac_cv_path_$1="$$1"
+ CTNG_PATH_ABSNAME([ac_cv_path_$1])
+ CTNG_MSG_LOG_ENVVAR([ac_cv_path_$1])
+ ver=$($ac_cv_path_$1 --version 2>/dev/null)
+ CTNG_MSG_LOG([looking for '[$5]' regexp in])
+ CTNG_MSG_LOG_ENVVAR([ver], [version info for $ac_cv_path_$1])
+ ver=$(AS_ECHO(["$ver"]) | $EGREP '[$5]')
+ test -n "$ver" && ctng_version_$1_ok=:],
+ [AC_CACHE_CHECK([for $3], [ac_cv_path_$1],
+ [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4],
+ [CTNG_MSG_LOG_ENVVAR([ac_path_$1], [checking $1 at])
+ ver=$($ac_path_$1 --version 2>/dev/null)
+ CTNG_MSG_LOG([looking for '[$5]' regexp in])
+ CTNG_MSG_LOG_ENVVAR([ver], [version info])
+ ver=$(AS_ECHO(["$ver"]) | $EGREP '[$5]')
+ test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1
+ test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: ctng_version_$1_ok=:])])])
AC_MSG_CHECKING([for $2])
AS_IF([$ctng_version_$1_ok],
[AC_MSG_RESULT([yes])],