[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check directory arguments for consistency
From: |
Christian Rössel |
Subject: |
Re: Check directory arguments for consistency |
Date: |
Mon, 18 May 2009 16:17:22 +0200 |
User-agent: |
Thunderbird 1.5.0.14 (X11/20060911) |
Ralf Wildenhues wrote:
> Hello Christian,
>
> * Christian Rössel wrote on Wed, May 13, 2009 at 05:50:43PM CEST:
>> configure checks it's standard directory arguments for consistency, e.g.
>> exec_prefix prefix bindir sbindir libexecdir etc.
>>
>> Is there a way to check my own directory argument in the same way, e.g.
>> by adding my directory variable to the list of standard directory
>> variables. Or is there a ready to use macro?
>
> Not yet, AFAICS it's all hardcoded in the autoconf/general.m4 macro
> _AC_INIT_PARSE_ARGS but you should be able to copy the code quite
> straightforwardly. Bonus points for producing a patch to factor it
> out and making it usable for third-party code. ;-)
Hi Ralf,
I pulled the code out of general.m4 and defined the following macro:
# AC_DIR_ARG_CONSISTENT(DIR_ARG [, FAILED_OPTION])
# ------------------------------
# Check directory argument DIR_ARG for consistency, i.e. remove trailing
# slashes and abort if argument is not an absolute directory name. Use
# FAILED_OPTION to show the user which option caused an error, e.g.
# AC_DIR_ARG_CONSISTENT([doxygen_output_dir], [--with-doxygen-output-dir])
#
AC_DEFUN([AC_DIR_ARG_CONSISTENT],
[
for ac_var in $1
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[[^/]]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[[\\/$]]* | ?:[[\\/]]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
if test $# -gt 1; then
AC_MSG_ERROR([expected an absolute directory name for $2: $ac_val])
else
AC_MSG_ERROR([expected an absolute directory name for --$ac_var:
$ac_val])
fi
done
])
You can also use this as a replacement for the hard coded consistency
check in general.m4, just call it in this way
AC_DIR_ARG_CONSISTENT([exec_prefix prefix bindir ...])
without the second parameter. If you consider this useful and meeting
the autoconf stnadards, please give me some hint for creating a patch.
Which autoconf should I use as base? Currently I'm working with a 2.63
tarball, not with git. Should the new macro placed in general.m4?
Thanks,
Christian