summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>2018-06-29 11:07:04 +0200
committerMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>2018-06-29 11:20:32 +0200
commitf8a9947d39b992633ec2201718daf0f14b692432 (patch)
treed450b7c4f7a5c7b7027577fe0341a4b0c5c9fb78
parentdb1d9cde803417425d6bfe33538e4c1b15017d01 (diff)
downloadautomake-f8a9947d39b992633ec2201718daf0f14b692432.tar.gz
Move yet more functions to Utils.pm
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.
-rwxr-xr-xbin/automake.in75
-rw-r--r--lib/Automake/Utils.pm72
2 files changed, 71 insertions, 76 deletions
diff --git a/bin/automake.in b/bin/automake.in
index a74b7143d..b17ad7bd1 100755
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -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
diff --git a/lib/Automake/Utils.pm b/lib/Automake/Utils.pm
index 08e91e5f5..65364f8ce 100644
--- a/lib/Automake/Utils.pm
+++ b/lib/Automake/Utils.pm
@@ -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;