From: Akim Demaille Date: Mon, 7 May 2001 17:39:09 +0000 (+0000) Subject: * automake.in (&handle_languages): Merge the two loops over X-Git-Tag: Release-1-4-p1~35 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=9248d0e61da2191bd39dd5e6eea6eeb86f506df1;p=automake.git * automake.in (&handle_languages): Merge the two loops over %extension_seen/%languages into one and group code to be run once per language together. --- diff --git a/ChangeLog b/ChangeLog index ca0602a7..ee7d5c3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-05-07 Akim Demaille + + * automake.in (&handle_languages): Merge the two loops over + %extension_seen/%languages into one and group code to be run once + per language together. + 2001-05-07 Akim Demaille * automake.in (&handle_languages): Move the `if diff --git a/automake.in b/automake.in index 1484c849..57bbe139 100755 --- a/automake.in +++ b/automake.in @@ -1375,50 +1375,118 @@ sub handle_languages # Is the c linker needed? my $needs_c = 0; foreach my $ext (sort keys %extension_seen) - { + { my $lang = $languages{$extension_map{$ext}}; + # Get information on $LANG. + my $pfx = $lang->autodep; + my $fpfx = ($pfx eq '') ? 'CC' : $pfx; + my $flag = $lang->flags || ''; + + # First include code for ordinary objects. + my %transform = ('PFX' => $pfx, + 'FPFX' => $fpfx, + 'LIBTOOL' => $seen_libtool, + 'AMDEP' => $use_dependencies ? 'AMDEP' : 'FALSE'); + # Generate the appropriate rules for this extension. If # dependency tracking was requested, and this extension # supports it, then we don't generate the rule here. my $comp = ''; if ($use_dependencies && $lang->autodep ne 'no') - { + { # Don't generate the rule, but still generate the variables. if (defined $lang->compile) - { + { $comp = $lang->compile - } - } + } + + my $compile = '$(' . $pfx . 'COMPILE)'; + my $ltcompile = '$(LT' . $pfx . 'COMPILE)'; + my %transform = (%transform, + 'GENERIC' => 1, + 'BASE' => '$*', + 'SOURCE' => '$<', + 'OBJ' => '$@', + 'LTOBJ' => '$@', + 'OBJOBJ' => '$@', + 'COMPILE' => $compile, + 'LTCOMPILE' => $ltcompile); + + foreach my $ext (grep ($extension_seen{$_}, + @{$lang->extensions})) + { + $output_rules .= (&file_contents ('depend2', + (%transform, + 'EXT' => $ext)) + . "\n"); + } + } elsif (defined $lang->compile) - { + { $comp = $lang->compile; my $outarg = $lang->output_arg; my $ltoutarg = ''; if ($lang->flags eq 'CFLAGS') - { + { # C compilers don't always support -c -o. if (defined $options{'subdir-objects'}) - { + { $outarg .= ' -o $@'; - } + } # We can always use -c -o with libtool. $ltoutarg = ' -o $@'; - } + } $output_rules .= file_contents ('ext-compile', ('EXT' => $ext, 'COMPILER' => $lang->compiler, 'OUTARG' => $outarg, 'LTOUTARG' => $ltoutarg)); - } + } + + if ($lang->autodep ne 'no') + { + # Now include code for each specially handled object with this + # language. + my %seen_files = (); + foreach my $file (@{$lang_specific_files{$lang->name}}) + { + my ($derived, $source, $obj) = split (' ', $file); + + # We might see a given object twice, for instance if it is + # used under different conditions. + next if defined $seen_files{$obj}; + $seen_files{$obj} = 1; + + my $val = "${derived}_${flag}"; + + (my $obj_compile = $lang->compile) =~ s/\(AM_$flag/\($val/; + my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile; + + # Generate a transform which will turn suffix targets in + # depend2.am into real targets for the particular objects we + # are building. + $output_rules .= &file_contents ('depend2', + (%transform, + 'GENERIC' => 0, + 'BASE' => $obj, + 'SOURCE' => $source, + 'OBJ' => "$obj.o", + 'OBJOBJ' => "$obj.obj", + 'LTOBJ' => "$obj.lo", + 'COMPILE' => $obj_compile, + 'LTCOMPILE' => $obj_ltcompile)) + } + } # The rest of the loop is done once per language. next if defined $done{$lang}; $done{$lang} = 1; + # If the source to a program consists entirely of code from a # `pure' language, for instance C++ for Fortran 77, then we # don't need the C compiler code. However if we run into @@ -1428,18 +1496,20 @@ sub handle_languages $needs_c ||= ! $lang->pure; if ($comp ne '') - { + { &define_compiler_variable ($lang->compiler, $ltcompile, $comp); - } + } # The compiler's flag must be a configure variable. if (defined $lang->flags) - { + { &define_configure_variable ($lang->flags); - } + } # Call the finisher. $lang->finish; - } + + + } # If the project is entirely C++ or entirely Fortran 77 (i.e., 1 # suffix rule was learned), don't bother with the C stuff. But if @@ -1448,92 +1518,17 @@ sub handle_languages if $need_link || scalar keys %suffix_rules > 1; if ($needs_c) - { + { if (! defined $done{$languages{'c'}}) - { + { &define_configure_variable ($languages{'c'}->flags); &define_compiler_variable ($languages{'c'}->compiler, $ltcompile, $languages{'c'}->compile); - } + } &define_variable ('CCLD', '$(CC)'); &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - } - - foreach my $lang (values %languages) - { - if ($lang->autodep ne 'no') - { - # Get information on $LANG. - my $pfx = $lang->autodep; - my $fpfx = ($pfx eq '') ? 'CC' : $pfx; - my $flag = $lang->flags || ''; - - # First include code for ordinary objects. - my %transform = ('PFX' => $pfx, - 'FPFX' => $fpfx, - 'LIBTOOL' => $seen_libtool, - 'AMDEP' => $use_dependencies ? 'AMDEP' : 'FALSE'); - - # This function can be called even when we don't want dependency - # tracking. This happens when we need an explicit rule for some - # target. In this case we don't want to include the generic code. - if ($use_dependencies) - { - my $compile = '$(' . $pfx . 'COMPILE)'; - my $ltcompile = '$(LT' . $pfx . 'COMPILE)'; - my %transform = (%transform, - 'GENERIC' => 1, - 'BASE' => '$*', - 'SOURCE' => '$<', - 'OBJ' => '$@', - 'LTOBJ' => '$@', - 'OBJOBJ' => '$@', - 'COMPILE' => $compile, - 'LTCOMPILE' => $ltcompile); - - foreach my $ext (grep ($extension_seen{$_}, @{$lang->extensions})) - { - $output_rules .= (&file_contents ('depend2', - (%transform, - 'EXT' => $ext)) - . "\n"); - } - } - - # Now include code for each specially handled object with this - # language. - my %seen_files = (); - foreach my $file (@{$lang_specific_files{$lang->name}}) - { - my ($derived, $source, $obj) = split (' ', $file); - - # We might see a given object twice, for instance if it is - # used under different conditions. - next if defined $seen_files{$obj}; - $seen_files{$obj} = 1; - - my $val = "${derived}_${flag}"; - - (my $obj_compile = $lang->compile) =~ s/\(AM_$flag/\($val/; - my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile; - - # Generate a transform which will turn suffix targets in - # depend2.am into real targets for the particular objects we - # are building. - $output_rules .= &file_contents ('depend2', - (%transform, - 'GENERIC' => 0, - 'BASE' => $obj, - 'SOURCE' => $source, - 'OBJ' => "$obj.o", - 'OBJOBJ' => "$obj.obj", - 'LTOBJ' => "$obj.lo", - 'COMPILE' => $obj_compile, - 'LTCOMPILE' => $obj_ltcompile)) - } - } } }