automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATCH: patsubst support


From: Alex Hornby
Subject: Re: PATCH: patsubst support
Date: Wed, 25 Oct 2000 17:26:35 +0100 (BST)

Akim,

Okay, here is patsubst patch v2. New since last time:

* ChangeLog entry formatting
* NEWS entry
* Documentation (first texinfo usage, please beware!)

The _PROGRAMS based example in the documentation needs a patsubst
supporting make (e.g. GNU and Solaris work). This is because the
program target writes prog_SOURCES to the Makefile.in without any
variable expansions.

The real reason I want patsubst (user specified dependency files)
doesn't impose any new make requirements when used, as the patsubst
expressions are expanded before being written to Makefile.in.

Until then, the PROGRAM targets are the only obvious route to
Automake's variable expansion, so thats what I used to give an
example.

Alex.


diff -r -P -u automake/ChangeLog.entry automake-patsubst/ChangeLog.entry
--- automake/ChangeLog.entry    Thu Jan  1 01:00:00 1970
+++ automake-patsubst/ChangeLog.entry   Wed Oct 25 15:41:28 2000
@@ -0,0 +1,5 @@
+2000-10-25  Alex Hornby <address@hidden>
+
+       * automake.in (value_to_list): Add support for patsubst
+       style variable substitution.
+
diff -r -P -u automake/NEWS.entry automake-patsubst/NEWS.entry
--- automake/NEWS.entry Thu Jan  1 01:00:00 1970
+++ automake-patsubst/NEWS.entry        Wed Oct 25 15:44:28 2000
@@ -0,0 +1 @@
+* Patsubst style variable expansion is now available.
diff -r -P -u automake/automake.in automake-patsubst/automake.in
--- automake/automake.in        Wed Oct 25 11:25:01 2000
+++ automake-patsubst/automake.in       Wed Oct 25 14:20:07 2000
@@ -5902,16 +5902,34 @@
            {
                $varname = $1;
                $to = $3;
-               ($from = $2) =~ s/(\W)/\\$1/g;
+               ($from = $2) =~ s/(\W)/$1/g;
            }
 
            # Find the value.
            @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
 
            # Now rewrite the value if appropriate.
-           if ($from)
+           if ($from =~ '^([^%]*)%([^%]*)')
            {
-               grep (s/$from$/$to/, @temp_list);
+               # patsubst style substitution
+               local ($prefrom, $suffrom, $preto, $sufto);
+               $prefrom = $1;
+               $suffrom = $2;
+
+               if ( $to =~  '^([^%]*)%([^%]*)')
+               {
+                   $preto = $1;
+                   $sufto = $2;
+               }
+               grep { 
+                   s/^$prefrom/$preto/;
+                   s/$suffrom$/$sufto/;
+               } @temp_list;
+           }
+           elsif ($from)
+           {
+               # standard substitution reference style
+               grep (s/$from$/$to/, @temp_list);
            }
 
            push (@result, @temp_list);
diff -r -P -u automake/automake.texi automake-patsubst/automake.texi
--- automake/automake.texi      Tue Oct 17 09:49:13 2000
+++ automake-patsubst/automake.texi     Wed Oct 25 16:42:13 2000
@@ -1605,6 +1605,23 @@
 cause an invalid value for @address@hidden to be
 generated.
 
address@hidden Variables, patsubst expansion
+
+Sometimes it can be useful to derive @address@hidden from
+another variable. This can be done using patsubst style expansion to
+rewrite a variable:
+
address@hidden
+MODULES = Account Bank Currency @dots{}
+bin_PROGRAMS = account_server
+account_server_SOURCES = address@hidden:address@hidden
address@hidden example
+
+Currently this feature requires the use of a @code{make} with patsubst
+support (such as GNU @code{make}). It may become possible in the future
+to expand all patsubst variable definitions before they are written to
address@hidden Makefile.in}. In the meantime if you use this feature you may get
+a error from non-GNU make.
 
 @node A Library, LIBOBJS, A Program, Programs
 @section Building a library
diff -r -P -u automake/tests/ChangeLog.entry 
automake-patsubst/tests/ChangeLog.entry
--- automake/tests/ChangeLog.entry      Thu Jan  1 01:00:00 1970
+++ automake-patsubst/tests/ChangeLog.entry     Wed Oct 25 15:41:59 2000
@@ -0,0 +1,5 @@
+2000-10-25  Alex Hornby <address@hidden>
+
+       * patsubst.test: Add test for patsubst variable expansion.
+
+       * Makefile.am: Reference patsubst.test.
Only in automake/tests: Makefile
diff -r -P -u automake/tests/Makefile.am automake-patsubst/tests/Makefile.am
--- automake/tests/Makefile.am  Wed Oct 25 11:25:02 2000
+++ automake-patsubst/tests/Makefile.am Wed Oct 25 14:13:05 2000
@@ -181,6 +181,7 @@
 output5.test \
 package.test \
 parse.test \
+patsubst.test \
 pluseq.test \
 pluseq2.test \
 pluseq3.test \
diff -r -P -u automake/tests/patsubst.test automake-patsubst/tests/patsubst.test
--- automake/tests/patsubst.test        Thu Jan  1 01:00:00 1970
+++ automake-patsubst/tests/patsubst.test       Wed Oct 25 14:13:01 2000
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+# Test `patsubst expansion' functionality.
+
+. $srcdir/defs || exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+BASENAMES = zar doz
+zardoz_SOURCES = ${BASENAMES:%=%.c}
+END
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+END
+
+: > zar.c
+: > doz.c
+
+$AUTOMAKE || exit 1
+fgrep 'zar.o doz.o' Makefile.in





reply via email to

[Prev in Thread] Current Thread [Next in Thread]