Implemented the .INCLUDE_DIRS special variable. It expands to a list
authorBoris Kolpackov <boris@kolpackov.net>
Mon, 14 Nov 2005 15:31:13 +0000 (15:31 +0000)
committerBoris Kolpackov <boris@kolpackov.net>
Mon, 14 Nov 2005 15:31:13 +0000 (15:31 +0000)
of directories that make searches for included makefiles.

ChangeLog
NEWS
doc/make.texi
read.c
tests/ChangeLog
tests/scripts/variables/INCLUDE_DIRS [new file with mode: 0644]

index 7565fb0..6445cc2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-11-14  Boris Kolpackov  <boris@kolpackov.net>
+
+       * read.c (construct_include_path): Set the .INCLUDE_DIRS special
+       variable.
+       * doc/make.texi (Special Variables): Document .INCLUDE_DIRS.
+       * NEWS: Add .INCLUDE_DIRS to the list of new special variables.
+
 2005-10-26  Paul Smith  <psmith@gnu.org>
 
        * read.c (record_files): Don't set deps flags if there are no deps.
diff --git a/NEWS b/NEWS
index e6b3322..01e9016 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,8 @@ Version 3.81beta3
   load average accordingly.
 
 * New special variables available in this release:
+   - .INCLUDE_DIRS: Expands to a list of directories that make searches
+     for included makefiles.
    - .FEATURES: Contains a list of special features available in this
      version of GNU make.
    - .DEFAULT_GOAL: Set the name of the default goal make will
index cc5f061..62ad82e 100644 (file)
@@ -1390,6 +1390,11 @@ Supports the @code{-L} (@code{--check-symlink-times}) flag.
 
 @end table
 
+@vindex .INCLUDE_DIRS @r{(list of include directories)}
+@item .INCLUDE_DIRS
+Expands to a list of directories that @code{make} searches for
+included makefiles (@pxref{Include, , Including Other Makefiles}).
+
 @end table
 
 @node Remaking Makefiles, Overriding Makefiles, Special Variables, Makefiles
diff --git a/read.c b/read.c
index 9fbfd35..894bf6f 100644 (file)
--- a/read.c
+++ b/read.c
@@ -2917,7 +2917,8 @@ construct_include_path (char **arg_dirs)
 
   dirs[idx] = 0;
 
-  /* Now compute the maximum length of any name in it.  */
+  /* Now compute the maximum length of any name in it. Also add each
+     dir to the .INCLUDE_DIRS variable.  */
 
   max_incl_len = 0;
   for (i = 0; i < idx; ++i)
@@ -2930,6 +2931,10 @@ construct_include_path (char **arg_dirs)
        dirs[i] = savestring (dirs[i], len - 1);
       if (len > max_incl_len)
        max_incl_len = len;
+
+      /* Append to .INCLUDE_DIRS.   */
+      do_variable_definition (NILF, ".INCLUDE_DIRS", dirs[i],
+                              o_default, f_append, 0);
     }
 
   include_directories = dirs;
index c936301..d30f0c9 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-14  Boris Kolpackov  <boris@kolpackov.net>
+
+       * scripts/variables/INCLUDE_DIRS: Add a test for the .INCLUDE_DIRS
+       special variable.
+
 2005-10-24  Paul D. Smith  <psmith@gnu.org>
 
        * scripts/misc/general4: Test '$$' in prerequisites list.
diff --git a/tests/scripts/variables/INCLUDE_DIRS b/tests/scripts/variables/INCLUDE_DIRS
new file mode 100644 (file)
index 0000000..c9662e9
--- /dev/null
@@ -0,0 +1,46 @@
+#                                                                    -*-perl-*-
+$description = "Test the .INCLUDE_DIRS special variable.";
+
+$details = "";
+
+use Cwd;
+
+$dir = cwd;
+$dir =~ s,.*/([^/]+)$,../$1,;
+
+# Test #1: The content of .INCLUDE_DIRS depends on the platform for which
+#          make was built. What we know for sure is that it shouldn't be
+#          empty.
+#
+run_make_test('
+ifeq ($(.INCLUDE_DIRS),)
+$(warning .INCLUDE_DIRS is empty)
+endif
+
+.PHONY: all
+all:;@:
+',
+'',
+'');
+
+
+# Test #2: Make sure -I paths end up in .INCLUDE_DIRS.
+#
+run_make_test('
+ifeq ($(dir),)
+$(warning dir is empty)
+endif
+
+ifeq ($(filter $(dir),$(.INCLUDE_DIRS)),)
+$(warning .INCLUDE_DIRS does not contain $(dir))
+endif
+
+.PHONY: all
+all:;@:
+',
+"-I$dir dir=$dir",
+'');
+
+
+# This tells the test driver that the perl test script executed properly.
+1;