This patch adds the ability to use partial $(wildcard *.h) (GNU?)
make-style syntax in automake variable declarations. It is useful for
projects where the files for each target are are organised in a single
directory.

Example -

        banana_SOURCES = fridge.app $(wildcard *.tree)

banana_SOURCES will be expanded in Makefile.in and banana_OBJECTS will
be generated as if every .tree file had been mentioned explicitly.

I don't know if using GNU Make function syntax is a good idea, because
to do it properly would be a bit of work.

The patch is against the CVS tree, but works without modification
(though GNU patch isn't smart enough to figure out where part of it
should go) in the 1.4 release.

--- automake.in.~1~	Sat Mar  4 08:55:19 2000
+++ automake.in	Fri Mar 10 17:36:25 2000
@@ -5552,6 +5552,54 @@
     return $val;
 }
 
+
+# Quick hack to (partially) implement $(wildcard *.c) globbing
+
+sub do_gnu_make_functions()
+  {
+    local $text = shift;
+    local $ret = undef;
+
+    while ( $text =~ /(.*?)[\s]*\$\(([a-zA-Z]+)[\s]+([^\)]+)\)(.*)/ )
+      {
+	local $before = $1;
+	local $name = $2;
+	local $arguments = $3;
+	local $after = $4;
+	
+	$ret .= $before . " ";
+
+	if ( $name eq "wildcard" )
+	  {
+	    local @list = glob($relative_dir);
+	    local $dir = $list[0];
+
+	    #should this be $am_relative_dir?
+
+	    local @globs = glob "$dir/$arguments";
+	    local @basenames;
+
+	    foreach $glob (@globs)
+	      {
+		$glob =~ s/^$dir[\/]*//;
+
+		push @basenames,$glob;
+	      }
+
+	    $ret .= join( " ", @basenames) . " ";
+	  }
+	else
+	  {
+	    &am_error( "warning: function call $name is unrecognised" );
+	    $ret .= "$\($name $arguments\) ";
+	  }
+	$text = $after;
+      }
+
+    return ($ret or $text);
+}
+
+
 # Return the set of conditions for which a variable is defined.
 
 # If the variable is not defined conditionally, and is not defined in
@@ -6307,6 +6355,8 @@
 		$value = $3;
 	    }
 	    local ($type) = $2;
+
+	    $value = &do_gnu_make_functions($value);
 
 	    if (! defined $contents{$last_var_name})
 	    {

-- 

        http://altern.org/vii

Reply via email to