]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Move yet more functions to Utils.pm
authorMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 29 Jun 2018 09:07:04 +0000 (11:07 +0200)
committerMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 29 Jun 2018 09:20:32 +0000 (11:20 +0200)
backanme: get the back path to the Makefile directory.
locate_am: locate the *.am file for which a *.in file exists
get_number_of_threads: returns the number of threads on which Automake should
run.

* lib/Automake/Utils.pm: Add the backname, locate_am, get_number_of_threads
  functions to the Automake::Utils module.

bin/automake.in
lib/Automake/Utils.pm

index a74b7143d867b3c2fcbdedcf09cbb33c11fa8b60..b17ad7bd14809686ed8b86225644d52e646ebf45 100755 (executable)
@@ -87,7 +87,6 @@ use Carp;
 sub am_install_var;
 sub am_primary_prefixes;
 sub append_exeext (&$);
-sub backname;
 sub check_canonical_spelling;
 sub check_directories_in_var;
 sub check_directory;
@@ -102,7 +101,6 @@ sub define_objects_from_sources;
 sub define_per_target_linker_variable;
 sub do_check_merge_target ();
 sub generate_makefile;
-sub get_number_of_threads ();
 sub handle_ALLOCA;
 sub handle_LIBOBJS;
 sub handle_LIBOBJS_or_ALLOCA;
@@ -144,7 +142,6 @@ sub handle_tests_dejagnu ();
 sub handle_user_recursion ();
 sub initialize_per_input ();
 sub is_valid_test_extension;
-sub locate_am;
 sub parse_arguments ();
 sub prepend_srcdir;
 sub print_autodist_files;
@@ -588,39 +585,6 @@ register_language ('name' => 'java',
                   'pure' => 1,
                   'extensions' => ['.java', '.class', '.zip', '.jar']);
 
-################################################################
-
-
-
-################################################################
-
-
-# $BACKPATH
-# backname ($RELDIR)
-# -------------------
-# If I "cd $RELDIR", then to come back, I should "cd $BACKPATH".
-# For instance 'src/foo' => '../..'.
-# Works with non strictly increasing paths, i.e., 'src/../lib' => '..'.
-sub backname
-{
-    my ($file) = @_;
-    my @res;
-    foreach (split (/\//, $file))
-    {
-       next if $_ eq '.' || $_ eq '';
-       if ($_ eq '..')
-       {
-           pop @res
-             or prog_error ("trying to reverse path '$file' pointing outside tree");
-       }
-       else
-       {
-           push (@res, '..');
-       }
-    }
-    return join ('/', @res) || '.';
-}
-
 
 ################################################################
 
@@ -4003,27 +3967,6 @@ sub split_config_file_spec
   return ($output, @inputs);
 }
 
-# $input
-# locate_am (@POSSIBLE_SOURCES)
-# -----------------------------
-# AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in
-# This functions returns the first *.in file for which a *.am exists.
-# It returns undef otherwise.
-sub locate_am
-{
-  my (@rest) = @_;
-  my $input;
-  foreach my $file (@rest)
-    {
-      if (($file =~ /^(.*)\.in$/) && -f "$1.am")
-       {
-         $input = $file;
-         last;
-       }
-    }
-  return $input;
-}
-
 my %make_list;
 
 # scan_autoconf_config_files ($WHERE, $CONFIG-FILES)
@@ -5660,24 +5603,6 @@ sub handle_makefiles_serial ()
     }
 }
 
-# Logic for deciding how many worker threads to use.
-sub get_number_of_threads ()
-{
-  my $nthreads = $ENV{'AUTOMAKE_JOBS'} || 0;
-
-  $nthreads = 0
-    unless $nthreads =~ /^[0-9]+$/;
-
-  # It doesn't make sense to use more threads than makefiles,
-  my $max_threads = @input_files;
-
-  if ($nthreads > $max_threads)
-    {
-      $nthreads = $max_threads;
-    }
-  return $nthreads;
-}
-
 # handle_makefiles_threaded ($NTHREADS)
 # -------------------------------------
 # Deal with all makefiles, using threads.  The general strategy is to
index 08e91e5f564533a040c527e52bc8baaceaf44729..65364f8ce8b8a85ef4bee42c821dcee7cd3b755a 100644 (file)
@@ -34,7 +34,7 @@ use vars qw (@EXPORT);
     $config_aux_dir_set_in_configure_ac $seen_maint_mode $relative_dir
     $seen_canonical $am_file_cache &var_SUFFIXES_trigger &locate_aux_dir
     &subst &make_paragraphs &flatten &canonicalize &push_dist_common
-    &is_make_dir);
+    &is_make_dir &backname &get_number_of_threads &locate_am);
 
 # Directory to search for configure-required files.  This
 # will be computed by locate_aux_dir() and can be set using
@@ -343,4 +343,74 @@ sub is_make_dir
     return defined $make_dirs{$dir};
 }
 
+
+# $BACKPATH
+# backname ($RELDIR)
+# -------------------
+# If I "cd $RELDIR", then to come back, I should "cd $BACKPATH".
+# For instance 'src/foo' => '../..'.
+# Works with non strictly increasing paths, i.e., 'src/../lib' => '..'.
+sub backname
+{
+    my ($file) = @_;
+    my @res;
+    foreach (split (/\//, $file))
+    {
+       next if $_ eq '.' || $_ eq '';
+       if ($_ eq '..')
+       {
+           pop @res
+             or prog_error ("trying to reverse path '$file' pointing outside tree");
+       }
+       else
+       {
+           push (@res, '..');
+       }
+    }
+    return join ('/', @res) || '.';
+}
+
+
+# Logic for deciding how many worker threads to use.
+sub get_number_of_threads ()
+{
+  my $nthreads = $ENV{'AUTOMAKE_JOBS'} || 0;
+
+  $nthreads = 0
+    unless $nthreads =~ /^[0-9]+$/;
+
+  # It doesn't make sense to use more threads than makefiles,
+  my $max_threads = @input_files;
+
+  if ($nthreads > $max_threads)
+    {
+      $nthreads = $max_threads;
+    }
+  return $nthreads;
+}
+
+
+
+# $input
+# locate_am (@POSSIBLE_SOURCES)
+# -----------------------------
+# AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in
+# This functions returns the first *.in file for which a *.am exists.
+# It returns undef otherwise.
+sub locate_am
+{
+  my (@rest) = @_;
+  my $input;
+  foreach my $file (@rest)
+    {
+      if (($file =~ /^(.*)\.in$/) && -f "$1.am")
+       {
+         $input = $file;
+         last;
+       }
+    }
+  return $input;
+}
+
+
 1;