]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
lib: Add Automake::Utils module
authorMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Mon, 4 Jun 2018 09:49:36 +0000 (11:49 +0200)
committerMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 22 Jun 2018 12:17:42 +0000 (14:17 +0200)
This module contains utility methods to be used in bin/automake.

* lib/Automake/Utils.pm: New utility module.
* var_SUFFIXES_trigger: Moved to the Automake::Utils module.
* locate_aux_dir: Moved to the Automake::Utils module.

bin/automake.in
lib/Automake/Utils.pm [new file with mode: 0644]

index ce2bc89199bff1df20445332857a2dae61ca14a5..480e69f0220064a5834d60e1c110de05866f35d6 100755 (executable)
@@ -67,6 +67,7 @@ use Automake::Rule;
 use Automake::RuleDef;
 use Automake::Wrap 'makefile_wrap';
 use Automake::Language;
+use Automake::Utils;
 use File::Basename;
 use File::Spec;
 use Carp;
@@ -120,7 +121,6 @@ sub lang_lex_finish ();
 sub lang_sub_obj ();
 sub lang_vala_finish ();
 sub lang_yacc_finish ();
-sub locate_aux_dir ();
 sub parse_arguments ();
 sub scan_aclocal_m4 ();
 sub scan_autoconf_files ();
@@ -150,19 +150,6 @@ my $gen_copyright = "\
 
 ################################################################
 
-# var_SUFFIXES_trigger ($TYPE, $VALUE)
-# ------------------------------------
-# This is called by Automake::Variable::define() when SUFFIXES
-# is defined ($TYPE eq '') or appended ($TYPE eq '+').
-# The work here needs to be performed as a side-effect of the
-# macro_define() call because SUFFIXES definitions impact
-# on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
-# the input am file.
-sub var_SUFFIXES_trigger
-{
-    my ($type, $value) = @_;
-    accept_extensions (split (' ', $value));
-}
 Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
 
 ################################################################
@@ -6981,33 +6968,6 @@ sub is_make_dir
 
 ################################################################
 
-# Find the aux dir.  This should match the algorithm used by
-# ./configure. (See the Autoconf documentation for for
-# AC_CONFIG_AUX_DIR.)
-sub locate_aux_dir ()
-{
-  if (! $config_aux_dir_set_in_configure_ac)
-    {
-      # The default auxiliary directory is the first
-      # of ., .., or ../.. that contains install-sh.
-      # Assume . if install-sh doesn't exist yet.
-      for my $dir (qw (. .. ../..))
-       {
-         if (-f "$dir/install-sh")
-           {
-             $config_aux_dir = $dir;
-             last;
-           }
-       }
-      $config_aux_dir = '.' unless $config_aux_dir;
-    }
-  # Avoid unsightly '/.'s.
-  $am_config_aux_dir =
-    '$(top_srcdir)' . ($config_aux_dir eq '.' ? "" : "/$config_aux_dir");
-  $am_config_aux_dir =~ s,/*$,,;
-}
-
-
 # push_required_file ($DIR, $FILE, $FULLFILE)
 # -------------------------------------------
 # Push the given file onto DIST_COMMON.
diff --git a/lib/Automake/Utils.pm b/lib/Automake/Utils.pm
new file mode 100644 (file)
index 0000000..e1cd463
--- /dev/null
@@ -0,0 +1,69 @@
+# Copyright (C) 2018  Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+package Automake::Utils;
+
+use 5.006;
+use strict;
+use Exporter;
+use Automake::Rule;
+use Automake::Global;
+
+use vars qw (@ISA @EXPORT);
+
+@ISA = qw (Exporter);
+@EXPORT = qw (&var_SUFFIXES_trigger &locate_aux_dir);
+
+# var_SUFFIXES_trigger ($TYPE, $VALUE)
+# ------------------------------------
+# This is called by Automake::Variable::define() when SUFFIXES
+# is defined ($TYPE eq '') or appended ($TYPE eq '+').
+# The work here needs to be performed as a side-effect of the
+# macro_define() call because SUFFIXES definitions impact
+# on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
+# the input am file.
+sub var_SUFFIXES_trigger
+{
+    my ($type, $value) = @_;
+    accept_extensions (split (' ', $value));
+}
+
+# Find the aux dir.  This should match the algorithm used by
+# ./configure. (See the Autoconf documentation for for
+# AC_CONFIG_AUX_DIR.)
+sub locate_aux_dir
+{
+  if (! $config_aux_dir_set_in_configure_ac)
+    {
+      # The default auxiliary directory is the first
+      # of ., .., or ../.. that contains install-sh.
+      # Assume . if install-sh doesn't exist yet.
+      for my $dir (qw (. .. ../..))
+       {
+         if (-f "$dir/install-sh")
+           {
+             $config_aux_dir = $dir;
+             last;
+           }
+       }
+      $config_aux_dir = '.' unless $config_aux_dir;
+    }
+  # Avoid unsightly '/.'s.
+  $am_config_aux_dir =
+    '$(top_srcdir)' . ($config_aux_dir eq '.' ? "" : "/$config_aux_dir");
+  $am_config_aux_dir =~ s,/*$,,;
+}
+
+1;