diff options
author | Matthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr> | 2018-06-04 17:29:26 +0200 |
---|---|---|
committer | Matthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr> | 2018-06-22 14:18:25 +0200 |
commit | 9a93513b42a698ba9ac46a88ccb5fbcceea4daac (patch) | |
tree | 873cf47a3fc6cfb474652428ac3aabd197c94987 /bin/automake.in | |
parent | 69dd1687944916e21fa520b4b87061a5dbeceab2 (diff) | |
download | automake-9a93513b42a698ba9ac46a88ccb5fbcceea4daac.tar.gz |
lib: Move methods to Automake::Variable
Some subs in bin/automake are still moveable to this file but require to move
other subs before.
* verbose_var: adds a prefix to a variable name.
* verbose_private_var: same as verbose_var but for private vars. This method
is now private in this module since it is only used once in the.
define_verbose_var which has been moved here took.
* define_verbose_var: defines verbose variables for silent rules in the
generated makefile.
* define_verbose_tagvar: calls define_verbose_var with $name as argument
* define_variable: define a new Makefile variable.
* define_pretty_variable: same as above but for printing in an input file.
* define_files_variables: define a variable containing a list of files
composed of a specified basename and extension.
* define_configure_variable: define a variable and substitute its name by a
configure-style text.
Diffstat (limited to 'bin/automake.in')
-rwxr-xr-x | bin/automake.in | 330 |
1 files changed, 2 insertions, 328 deletions
diff --git a/bin/automake.in b/bin/automake.in index e119d9ca1..fb9779882 100755 --- a/bin/automake.in +++ b/bin/automake.in @@ -81,8 +81,6 @@ sub check_gnits_standards (); sub check_gnu_standards (); sub check_trailing_slash ($\$); sub check_typos (); -sub define_files_variable ($\@$$); -sub define_standard_variables (); sub define_verbose_libtool (); sub define_verbose_texinfo (); sub do_check_merge_target (); @@ -643,52 +641,6 @@ sub backname # Silent rules handling functions. -# verbose_var (NAME) -# ------------------ -# The public variable stem used to implement silent rules. -sub verbose_var -{ - my ($name) = @_; - return 'AM_V_' . $name; -} - -# verbose_private_var (NAME) -# -------------------------- -# The naming policy for the private variables for silent rules. -sub verbose_private_var -{ - my ($name) = @_; - return 'am__v_' . $name; -} - -# define_verbose_var (NAME, VAL-IF-SILENT, [VAL-IF-VERBOSE]) -# ---------------------------------------------------------- -# For silent rules, setup VAR and dispatcher, to expand to -# VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to -# empty) if not. -sub define_verbose_var -{ - my ($name, $silent_val, $verbose_val) = @_; - $verbose_val = '' unless defined $verbose_val; - my $var = verbose_var ($name); - my $pvar = verbose_private_var ($name); - my $silent_var = $pvar . '_0'; - my $verbose_var = $pvar . '_1'; - # For typical 'make's, 'configure' replaces AM_V (inside @@) with $(V) - # and AM_DEFAULT_V (inside @@) with $(AM_DEFAULT_VERBOSITY). - # For strict POSIX 2008 'make's, it replaces them with 0 or 1 instead. - # See AM_SILENT_RULES in m4/silent.m4. - define_variable ($var, '$(' . $pvar . '_@'.'AM_V'.'@)', INTERNAL); - define_variable ($pvar . '_', '$(' . $pvar . '_@'.'AM_DEFAULT_V'.'@)', - INTERNAL); - Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE, - $silent_val, '', INTERNAL, VAR_ASIS) - if (! vardef ($silent_var, TRUE)); - Automake::Variable::define ($verbose_var, VAR_AUTOMAKE, '', TRUE, - $verbose_val, '', INTERNAL, VAR_ASIS) - if (! vardef ($verbose_var, TRUE)); -} - # verbose_flag (NAME) # ------------------- # Contents of '%VERBOSE%' variable to expand before rule command. @@ -712,15 +664,6 @@ sub silent_flag () return verbose_flag ('at'); } -# define_verbose_tagvar (NAME) -# ---------------------------- -# Engage the needed silent rules machinery for tag NAME. -sub define_verbose_tagvar -{ - my ($name) = @_; - define_verbose_var ($name, '@echo " '. $name . ' ' x (8 - length ($name)) . '" $@;'); -} - # Engage the needed silent rules machinery for assorted texinfo commands. sub define_verbose_texinfo () { @@ -5716,65 +5659,8 @@ sub cond_stack_endif ## ------------------------ ## -# define_pretty_variable ($VAR, $COND, $WHERE, @VALUE) -# ---------------------------------------------------- -# Like define_variable, but the value is a list, and the variable may -# be defined conditionally. The second argument is the condition -# under which the value should be defined; this should be the empty -# string to define the variable unconditionally. The third argument -# is a list holding the values to use for the variable. The value is -# pretty printed in the output file. -sub define_pretty_variable -{ - my ($var, $cond, $where, @value) = @_; - - if (! vardef ($var, $cond)) - { - Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value", - '', $where, VAR_PRETTY); - rvar ($var)->rdef ($cond)->set_seen; - } -} - - -# define_variable ($VAR, $VALUE, $WHERE) -# -------------------------------------- -# Define a new Automake Makefile variable VAR to VALUE, but only if -# not already defined. -sub define_variable -{ - my ($var, $value, $where) = @_; - define_pretty_variable ($var, TRUE, $where, $value); -} - - -# define_files_variable ($VAR, \@BASENAME, $EXTENSION, $WHERE) -# ------------------------------------------------------------ -# Define the $VAR which content is the list of file names composed of -# a @BASENAME and the $EXTENSION. -sub define_files_variable ($\@$$) -{ - my ($var, $basename, $extension, $where) = @_; - define_variable ($var, - join (' ', map { "$_.$extension" } @$basename), - $where); -} - - -# Like define_variable, but define a variable to be the configure -# substitution by the same name. -sub define_configure_variable -{ - my ($var) = @_; - # Some variables we do not want to output. For instance it - # would be a bad idea to output `U = @U@` when `@U@` can be - # substituted as `\`. - my $pretty = exists $ignored_configure_vars{$var} ? VAR_SILENT : VAR_ASIS; - Automake::Variable::define ($var, VAR_CONFIGURE, '', TRUE, subst ($var), - '', $configure_vars{$var}, $pretty); -} - - +# TODO: Look for a better file for `define_verbose_libtool' to move these to +# Automake::Variable # define_compiler_variable ($LANG) # -------------------------------- # Define a compiler variable. We also handle defining the 'LT' @@ -6196,24 +6082,6 @@ sub read_am_file } -# A helper for read_main_am_file which initializes configure variables -# and variables from header-vars.am. -sub define_standard_variables () -{ - my $saved_output_vars = $output_vars; - my ($comments, undef, $rules) = - file_contents_internal (1, "$libdir/am/header-vars.am", - new Automake::Location); - - foreach my $var (sort keys %configure_vars) - { - define_configure_variable ($var); - } - - $output_vars .= $comments . $rules; -} - - # read_main_am_file ($MAKEFILE_AM, $MAKEFILE_IN) # ---------------------------------------------- sub read_main_am_file @@ -6420,200 +6288,6 @@ sub make_paragraphs } - -# ($COMMENT, $VARIABLES, $RULES) -# file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM]) -# ------------------------------------------------------------ -# Return contents of a file from $libdir/am, automatically skipping -# macros or rules which are already known. $IS_AM iff the caller is -# reading an Automake file (as opposed to the user's Makefile.am). -sub file_contents_internal -{ - my ($is_am, $file, $where, %transform) = @_; - - $where->set ($file); - - my $result_vars = ''; - my $result_rules = ''; - my $comment = ''; - my $spacing = ''; - - # The following flags are used to track rules spanning across - # multiple paragraphs. - my $is_rule = 0; # 1 if we are processing a rule. - my $discard_rule = 0; # 1 if the current rule should not be output. - - # We save the conditional stack on entry, and then check to make - # sure it is the same on exit. This lets us conditionally include - # other files. - my @saved_cond_stack = @cond_stack; - my $cond = new Automake::Condition (@cond_stack); - - foreach (make_paragraphs ($file, %transform)) - { - # FIXME: no line number available. - $where->set ($file); - - # Sanity checks. - error $where, "blank line following trailing backslash:\n$_" - if /\\$/; - error $where, "comment following trailing backslash:\n$_" - if /\\#/; - - if (/^$/) - { - $is_rule = 0; - # Stick empty line before the incoming macro or rule. - $spacing = "\n"; - } - elsif (/$COMMENT_PATTERN/mso) - { - $is_rule = 0; - # Stick comments before the incoming macro or rule. - $comment = "$_\n"; - } - - # Handle inclusion of other files. - elsif (/$INCLUDE_PATTERN/o) - { - if ($cond != FALSE) - { - my $file = ($is_am ? "$libdir/am/" : '') . $1; - $where->push_context ("'$file' included from here"); - # N-ary '.=' fails. - my ($com, $vars, $rules) - = file_contents_internal ($is_am, $file, $where, %transform); - $where->pop_context; - $comment .= $com; - $result_vars .= $vars; - $result_rules .= $rules; - } - } - - # Handling the conditionals. - elsif (/$IF_PATTERN/o) - { - $cond = cond_stack_if ($1, $2, $file); - } - elsif (/$ELSE_PATTERN/o) - { - $cond = cond_stack_else ($1, $2, $file); - } - elsif (/$ENDIF_PATTERN/o) - { - $cond = cond_stack_endif ($1, $2, $file); - } - - # Handling rules. - elsif (/$RULE_PATTERN/mso) - { - $is_rule = 1; - $discard_rule = 0; - # Separate relationship from optional actions: the first - # `new-line tab" not preceded by backslash (continuation - # line). - my $paragraph = $_; - /^(.*?)(?:(?<!\\)\n(\t.*))?$/s; - my ($relationship, $actions) = ($1, $2 || ''); - - # Separate targets from dependencies: the first colon. - $relationship =~ /^([^:]+\S+) *: *(.*)$/som; - my ($targets, $dependencies) = ($1, $2); - # Remove the escaped new lines. - # I don't know why, but I have to use a tmp $flat_deps. - my $flat_deps = flatten ($dependencies); - my @deps = split (' ', $flat_deps); - - foreach (split (' ', $targets)) - { - # FIXME: 1. We are not robust to people defining several targets - # at once, only some of them being in %dependencies. The - # actions from the targets in %dependencies are usually generated - # from the content of %actions, but if some targets in $targets - # are not in %dependencies the ELSE branch will output - # a rule for all $targets (i.e. the targets which are both - # in %dependencies and $targets will have two rules). - - # FIXME: 2. The logic here is not able to output a - # multi-paragraph rule several time (e.g. for each condition - # it is defined for) because it only knows the first paragraph. - - # FIXME: 3. We are not robust to people defining a subset - # of a previously defined "multiple-target" rule. E.g. - # 'foo:' after 'foo bar:'. - - # Output only if not in FALSE. - if (defined $dependencies{$_} && $cond != FALSE) - { - depend ($_, @deps); - register_action ($_, $actions); - } - else - { - # Free-lance dependency. Output the rule for all the - # targets instead of one by one. - my @undefined_conds = - Automake::Rule::define ($targets, $file, - $is_am ? RULE_AUTOMAKE : RULE_USER, - $cond, $where); - for my $undefined_cond (@undefined_conds) - { - my $condparagraph = $paragraph; - $condparagraph =~ s/^/$undefined_cond->subst_string/gme; - $result_rules .= "$spacing$comment$condparagraph\n"; - } - if (scalar @undefined_conds == 0) - { - # Remember to discard next paragraphs - # if they belong to this rule. - # (but see also FIXME: #2 above.) - $discard_rule = 1; - } - $comment = $spacing = ''; - last; - } - } - } - - elsif (/$ASSIGNMENT_PATTERN/mso) - { - my ($var, $type, $val) = ($1, $2, $3); - error $where, "variable '$var' with trailing backslash" - if /\\$/; - - $is_rule = 0; - - Automake::Variable::define ($var, - $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE, - $type, $cond, $val, $comment, $where, - VAR_ASIS) - if $cond != FALSE; - - $comment = $spacing = ''; - } - else - { - # This isn't an error; it is probably some tokens which - # configure is supposed to replace, such as '@SET-MAKE@', - # or some part of a rule cut by an if/endif. - if (! $cond->false && ! ($is_rule && $discard_rule)) - { - s/^/$cond->subst_string/gme; - $result_rules .= "$spacing$comment$_\n"; - } - $comment = $spacing = ''; - } - } - - error ($where, @cond_stack ? - "unterminated conditionals: @cond_stack" : - "too many conditionals closed in include file") - if "@saved_cond_stack" ne "@cond_stack"; - - return ($comment, $result_vars, $result_rules); -} - - # $CONTENTS # file_contents ($BASENAME, $WHERE, [%TRANSFORM]) # ----------------------------------------------- |