[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/6] aclocal: diagnose non-existing directories in AC_CONFIG_MACR
From: |
Stefano Lattarini |
Subject: |
[PATCH 2/6] aclocal: diagnose non-existing directories in AC_CONFIG_MACRO_DIRS better |
Date: |
Sat, 3 Nov 2012 13:36:19 +0100 |
This new implementation ensures that any directory (possibly excluding
the first one, if the '--install' option is used) that is declared with
AC_CONFIG_MACRO_DIRS and that is non-existent will cause an error from
aclocal.
* aclocal.in (scan_m4_dirs): Add a new argument, telling whether it's OK
for the scanned directory to be non-existing. Adjust the implementation
accordingly.
($first_user_m4dir): Remove, no more needed.
(scan_m4_files): Update 'scan_m4_dirs' invocations so that aclocal will
not complain if the first user macro directory is non-existing and the
'--install' option is given: such directory will be created later by
aclocal itself.
* t/aclocal-macrodir.tap: Do not mark the last test as TODO anymore;
it now passes. Make stricter by ensuring a non-existing directory in
AC_CONFIG_MACRO_DIRS causes an hard error, not a warning.
Signed-off-by: Stefano Lattarini <address@hidden>
---
aclocal.in | 35 +++++++++++++++++------------------
t/aclocal-macrodir.tap | 3 +--
t/aclocal-macrodirs.tap | 5 ++---
3 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/aclocal.in b/aclocal.in
index ea96025..751ab49 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -164,7 +164,7 @@ sub check_acinclude ();
sub reset_maps ();
sub install_file ($$);
sub list_compare (address@hidden@);
-sub scan_m4_dirs ($@);
+sub scan_m4_dirs ($$@);
sub scan_m4_files ();
sub add_macro ($);
sub scan_configure_dep ($);
@@ -344,28 +344,20 @@ sub list_compare (address@hidden@)
################################################################
-# scan_m4_dirs($TYPE, @DIRS)
-# --------------------------
+# scan_m4_dirs($TYPE, $ERR_ON_NONEXISTING, @DIRS)
+# -----------------------------------------------
# Scan all M4 files installed in @DIRS for new macro definitions.
# Register each file as of type $TYPE (one of the FT_* constants).
-my $first_user_m4dir = 1;
-sub scan_m4_dirs ($@)
+sub scan_m4_dirs ($$@)
{
- my ($type, @dirlist) = @_;
+ my ($type, $err_on_nonexisting, @dirlist) = @_;
foreach my $m4dir (@dirlist)
{
if (! opendir (DIR, $m4dir))
{
- if ($install && $type == FT_USER && $first_user_m4dir)
- {
- # We will try to create this directory later, so don't
- # complain if it doesn't exist.
- # TODO: maybe we should avoid complaining only if errno
- # is ENONENT?
- $first_user_m4dir = 0;
- next;
- }
+ # TODO: maybe avoid complaining only if errno == ENONENT?
+ next unless $err_on_nonexisting;
fatal "couldn't open directory '$m4dir': $!";
}
@@ -400,9 +392,16 @@ sub scan_m4_files ()
}
# Finally, scan all files in our search paths.
- scan_m4_dirs (FT_USER, @user_includes);
- scan_m4_dirs (FT_AUTOMAKE, @automake_includes);
- scan_m4_dirs (FT_SYSTEM, @system_includes);
+
+ if (@user_includes)
+ {
+ # Don't complain if the first user directory doesn't exist, in case
+ # we need to create it later (can happen if '--install' was given).
+ scan_m4_dirs (FT_USER, !$install, $user_includes[0]);
+ scan_m4_dirs (FT_USER, 1, @user_includes[1..$#user_includes]);
+ }
+ scan_m4_dirs (FT_AUTOMAKE, 1, @automake_includes);
+ scan_m4_dirs (FT_SYSTEM, 1, @system_includes);
# Construct a new function that does the searching. We use a
# function (instead of just evaluating $search in the loop) so that
diff --git a/t/aclocal-macrodir.tap b/t/aclocal-macrodir.tap
index 5ef1ee4..4114edb 100755
--- a/t/aclocal-macrodir.tap
+++ b/t/aclocal-macrodir.tap
@@ -164,7 +164,7 @@ AC_INIT([oops], [1.0])
AC_CONFIG_MACRO_DIR([non-existent])
END
-not $ACLOCAL 2>stderr \
+not $ACLOCAL -Wnone 2>stderr \
&& cat stderr >&2 \
&& grep "couldn't open directory 'non-existent'" stderr \
|| r='not ok'
@@ -173,5 +173,4 @@ test_end
#---------------------------------------------------------------------------
-
:
diff --git a/t/aclocal-macrodirs.tap b/t/aclocal-macrodirs.tap
index aaac4b4..2440d8f 100755
--- a/t/aclocal-macrodirs.tap
+++ b/t/aclocal-macrodirs.tap
@@ -294,8 +294,7 @@ test_end
#---------------------------------------------------------------------------
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (tricky setup)" \
- TODO
+test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (tricky setup)"
cat > configure.ac << 'END'
AC_INIT([oops], [1.0])
@@ -305,7 +304,7 @@ END
mkdir dir-ok
-not $ACLOCAL --install 2>stderr \
+not $ACLOCAL -Wnone --install 2>stderr \
&& cat stderr >&2 \
&& grep "couldn't open directory 'dir-ko'" stderr \
&& test ! -e dir-ko \
--
1.8.0
- [PATCH 0/6] Support for AC_CONFIG_MACRO_DIRS in aclocal, Stefano Lattarini, 2012/11/03
- [PATCH 2/6] aclocal: diagnose non-existing directories in AC_CONFIG_MACRO_DIRS better,
Stefano Lattarini <=
- [PATCH 3/6] tests: better coverage for AC_CONFIG_MACRO_DIRS, Stefano Lattarini, 2012/11/03
- [PATCH 4/6] aclocal: smash newlines in arguments of traced macros, Stefano Lattarini, 2012/11/03
- [PATCH 1/6] aclocal: multiple local m4 macro dirs with AC_CONFIG_MACRO_DIRS, Stefano Lattarini, 2012/11/03
- [PATCH 5/6] coverage: expose a bug in aclocal (spurious warnings), Stefano Lattarini, 2012/11/03
- [PATCH 6/6] aclocal: avoid spurious warnings from autom4te with AC_CONFIG_MACRO_DIRS, Stefano Lattarini, 2012/11/03