automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] new option: object-shortname


From: Thomas Martitz
Subject: Re: [PATCH] new option: object-shortname
Date: Mon, 25 Jul 2016 21:19:26 +0200

Am 27.01.2016 um 09:50 schrieb Thomas Martitz:
This option is intended to be used in conjunction with subdir-objects and
Automake-time substitutions for included makefile fragments (%C%, %D%). It
suppresses the generation path components in object filenames.


Ping. Can anyone please review this patch? It's totally useful for my use cases.

Best regards.



It should equivalent to setting %C%_foo_SHORTNAME=foo, except it can work if the makefile fragment is conditionally included, which improves the modularity
of Automake-using projects.

Example:
without object-shortname
  root/path/to/Makefile.am:
  bin_PROGRAMS += foo
  %C%_foo_CFLAGS = $(CFLAGS)

results in objects:
  root/path/to/root_path_to_foo-foo.o

with object-shortname the object filename is:
  root/path/to/foo-foo.o

And it allows the following in root/Makefile.am (not possible with foo_SHORTNAME=foo)
  if ENABLE_FOO
  include path/too/Makefile.am
  endif

* bin/automake.in: Handle new object-shortname option
* lib/Automake/Options.pm: Add the option

---
 bin/automake.in         | 13 +++++++++++++
 lib/Automake/Options.pm |  1 +
 2 files changed, 14 insertions(+)

diff --git a/bin/automake.in b/bin/automake.in
index eedc8bc..cea04c6 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1691,6 +1691,19 @@ sub handle_single_transform
         # override.

         my $dname = $derived;
+        if (option 'object-shortname') {
+ # If object-shortname is enabled the object's filename shall not contain the parts + # derived from its path (e.g. if %C% is used), but just the name of the object's target
+            # e.g. instead of path_to_binary-object.o just binary-object
+            my $dirname = dirname ($_file);
+            if ($dirname ne ".") {
+                my $canon_dirname = canonicalize ($dirname) . "_";
+ # paranoid check: should never fail but ensure path prefix is part of the filename
+                if (index ($derived, $canon_dirname) == 0) {
+                    $dname = substr ($derived, length ($canon_dirname));
+                }
+            }
+        }
         my $var = var ($derived . '_SHORTNAME');
         if ($var)
         {
diff --git a/lib/Automake/Options.pm b/lib/Automake/Options.pm
index 7d782c3..819c5ff 100644
--- a/lib/Automake/Options.pm
+++ b/lib/Automake/Options.pm
@@ -293,6 +293,7 @@ sub _is_valid_easy_option ($)
     silent-rules
     std-options
     subdir-objects
+    object-shortname
   );
 }





reply via email to

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