From: Tom Tromey Date: Tue, 27 Apr 1999 13:57:07 +0000 (+0000) Subject: * automake.in (handle_lib_objects_cond): Prefer `$1' over `\1'. X-Git-Tag: v1.10.2~2604 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=546c5271c94fbee9735e1770b0b6328a6bf4e1fd;p=platform%2Fupstream%2Fautomake.git * automake.in (handle_lib_objects_cond): Prefer `$1' over `\1'. Minor rewrite for clarity. (check_canonical_spelling): Prefer `$1' over `\1'. * depend2.am (@OBJ@): Renamed. Use @SOURCE@, @COMPILE@. Always use `-o $@'. (@LTOBJ@): Likewise. * automake.in (handle_single_transform_list): Don't print rule if doing dependency tracking and the file's language supports it. (initialize_per_input): Initialize lang_specific_files. (add_depend2): New function. (handle_dependencies): Use it. * automake.in (lang_ppf77_finish): Use lang_f77_finish. ratfor compiler name is `RCOMPILE'. ppf77 compiler name changed to `PPF77COMPILE' to allow use of f77 and ppf77 in the same directory. (lang_ratfor_finish): Use lang_f77_finish. * compile.am (NOTDEPEND.c.o): Removed. (OBJEXT.c.obj): Likewise. * automake.in: Added `flags' attribute to all relevant languages. (handle_single_transform_list): Handle per-derived-object flags. Changed interface and all callers. (handle_built_sources): Don't call handle_single_transform_list. Added `compile' and `compiler-name' attribute to all relevant languages. (finish_languages): Define compiler variables here. (lang_cxx_finish): Don't call define_compiler_variable. Don't define flag variable or .o rules. Don't add to @suffixes. (lang_f77_finish): Likewise. (lang_ppf77_finish): Likewise. (lang_objc_finish): Likewise. (lang_java_finish): Likewise. (finish_languages): Define flag variable here. Added `output-arg' attribute to all relevant languages. (finish_languages): Define `.o' rules here. (finish_languages): Put extension on @suffixes. (get_object_extension): Don't transform NOTDEPEND or MINUSO. --- diff --git a/ChangeLog b/ChangeLog index 6fc9109..8c60081 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,45 @@ +1999-04-27 Tom Tromey + + * automake.in (handle_lib_objects_cond): Prefer `$1' over `\1'. + Minor rewrite for clarity. + (check_canonical_spelling): Prefer `$1' over `\1'. + + * depend2.am (@OBJ@): Renamed. Use @SOURCE@, @COMPILE@. Always + use `-o $@'. + (@LTOBJ@): Likewise. + * automake.in (handle_single_transform_list): Don't print rule if + doing dependency tracking and the file's language supports it. + (initialize_per_input): Initialize lang_specific_files. + (add_depend2): New function. + (handle_dependencies): Use it. + + * automake.in (lang_ppf77_finish): Use lang_f77_finish. + ratfor compiler name is `RCOMPILE'. ppf77 compiler name changed + to `PPF77COMPILE' to allow use of f77 and ppf77 in the same + directory. + (lang_ratfor_finish): Use lang_f77_finish. + + * compile.am (NOTDEPEND.c.o): Removed. + (OBJEXT.c.obj): Likewise. + * automake.in: Added `flags' attribute to all relevant languages. + (handle_single_transform_list): Handle per-derived-object flags. + Changed interface and all callers. + (handle_built_sources): Don't call handle_single_transform_list. + Added `compile' and `compiler-name' attribute to all relevant + languages. + (finish_languages): Define compiler variables here. + (lang_cxx_finish): Don't call define_compiler_variable. Don't + define flag variable or .o rules. Don't add to @suffixes. + (lang_f77_finish): Likewise. + (lang_ppf77_finish): Likewise. + (lang_objc_finish): Likewise. + (lang_java_finish): Likewise. + (finish_languages): Define flag variable here. + Added `output-arg' attribute to all relevant languages. + (finish_languages): Define `.o' rules here. + (finish_languages): Put extension on @suffixes. + (get_object_extension): Don't transform NOTDEPEND or MINUSO. + 1999-04-27 Alexandre Oliva * automake.in (initialize_global_constants): Invoke gzip for diff --git a/Makefile.in b/Makefile.in index edd91ef..36223bf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -263,8 +263,9 @@ uninstall-info: @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ - echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file"; \ - install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \ + d=$(srcdir); \ + echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $$d/$$file"; \ + install-info --info-dir=$(DESTDIR)$(infodir) --remove $$d/$$file; \ done; \ else :; fi @$(NORMAL_UNINSTALL) diff --git a/NEWS b/NEWS index 2d3b540..ef17825 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ New in 1.4a: * GNU tar is no longer required for `make dist' * Added support for `dist_' and `nodist_' prefixes * Compiled Java support +* Support for per-executable and per-library compilation flags * The usual bug fixes New in 1.4: diff --git a/TODO b/TODO index 4f1210b..cab6406 100644 --- a/TODO +++ b/TODO @@ -7,6 +7,10 @@ try to find a losing compiler and see if it really works. (actually: hack config.cache and do it) +* We're using `$<' in explicit rules when using per-exe flags + per-exe flags don't work for CPPFLAGS/YFLAGS/LFLAGS. Fix. + LIBOBJS shouldn't be used when there are per-exe flags (?) + * test `make clean' with subdir-objects * Test nodist_SOURCES with lex, yacc, etc. @@ -61,7 +65,7 @@ That's because DEFS is defined in header-vars.am, which is read after the user's Makefile.am. This will be a problem for any macro defined internally - [ fixing this will probabl fix the nasty `exeext redefines + [ fixing this will probably fix the nasty `exeext redefines foo_PROGRAMS' hack that is in there right now ] In some cases this is unfixable. In these cases we should give an error. This can be done by keeping track of whether a macro @@ -104,6 +108,8 @@ * Allow per-object cflags: bin_PROGRAMS = foo foo_CFLAGS = -DFOO +* per-object compiler flags do not apply to libobjs + -> give error in this case * At the same time, allow sources in subdirs: foo_SOURCES = x/y.c This requires `mkdir x' at build time diff --git a/automake.in b/automake.in index c71113f..a00c493 100755 --- a/automake.in +++ b/automake.in @@ -318,14 +318,26 @@ $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')'; # internally supported. &initialize_global_constants; -®ister_language ('c', 'ansi-p=1', 'autodep=', +®ister_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS', + 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', + 'compiler-name=COMPILE', + 'output-arg=-c', 'c'); -®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', +®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS', + 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)', + 'compiler-name=CXXCOMPILE', + 'output-arg=-c -o $@', 'c++', 'cc', 'cpp', 'cxx', 'C'); ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC', + 'flags=OBJCFLAGS', + 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)', + 'compiler-name=OBJCCOMPILE', + 'output-arg=-c -o $@', 'm'); ®ister_language ('header', 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'); + +# For now, yacc and lex can't be handled on a per-exe basis. ®ister_language ('yacc', 'ansi-p=1', 'y'); ®ister_language ('yaccxx', 'linker=CXXLINK', @@ -334,15 +346,34 @@ $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')'; 'l'); ®ister_language ('lexxx', 'linker=CXXLINK', 'l++', 'll', 'lxx', 'lpp'); + ®ister_language ('asm', + 'flags=CFLAGS', # FIXME: asmflags? + 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler? + 'compiler-name=COMPILE', + 'output-arg=-c', 's', 'S'); -®ister_language ('f77', 'linker=F77LINK', + +®ister_language ('f77', 'linker=F77LINK', 'flags=FFLAGS', + 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)', + 'compiler-name=F77COMPILE', + 'output-arg=-c -o $@', 'f', 'for', 'f90'); -®ister_language ('ppf77', 'linker=F77LINK', +®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS', + 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)', + 'compiler-name=PPF77COMPILE', + 'output-arg=-c -o $@', 'F'); ®ister_language ('ratfor', 'linker=F77LINK', + 'flags=RFLAGS', # FIXME also FFLAGS. + 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)', + 'compiler-name=RCOMPILE', + 'output-arg=-c -o $@', 'r'); -®ister_language ('java', 'linker=GCJLINK', 'autodep=GCJ', +®ister_language ('java', 'linker=GCJLINK', 'autodep=GCJ', 'flags=GCJFLAGS', + 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)', + 'compiler-name=GCJCOMPILE', + 'output-arg=-c -o $@', 'java', 'class', 'zip', 'jar'); @@ -818,13 +849,7 @@ sub get_object_extension $output_vars .= &file_contents_with_transform ($xform, 'comp-vars'); - $xform = (($use_dependencies - ? 's/^NOTDEPEND.*$//;' - : 's/^NOTDEPEND//;') - . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;') - . 's/\@MINUSO\@/' - . (defined $options{'subdir-objects'} ? '-o \$\@' : '') - . '/;'); + $xform = $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;'; $output_rules .= &file_contents_with_transform ($xform, 'compile'); &push_phony_cleaners ('compile'); @@ -951,10 +976,63 @@ sub finish_languages foreach $ext (sort keys %extension_seen) { $lang = $extension_map{$ext}; + + # Generate the appropriate rules for this extension. + local ($comp) = ''; + if (defined $language_map{$lang . '-compile'}) + { + $comp = $language_map{$lang . '-compile'}; + + local ($outarg) = $language_map{$lang . '-output-arg'}; + if ($language_map{$lang . '-flags'} eq 'CFLAGS') + { + # C compilers don't always support -c -o. + if (defined $options{'subdir-objects'}) + { + $outarg .= ' -o $@'; + } + } + + local ($full) = ("\t\$(" + . $language_map{$lang . '-compiler-name'} + . ") " + . $outarg); + $output_rules .= (".$ext.o:\n" + . $full + . " \$<\n"); + # FIXME: Using cygpath should be somehow conditional. + $output_rules .= ("$ext.obj:\n" + . $full + . " \`cygpath -w \$<\`\n") + if $seen_objext; + $output_rules .= ("$ext.lo:\n" + . "\t\$(LT" + . $language_map{$lang . '-compiler-name'} + . ") " + . $outarg + . " \$<\n") + if $seen_libtool; + } + + push (@suffixes, $ext); + + # The rest of the loop is done once per language. next if defined $done{$lang}; $done{$lang} = 1; + $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/; + if ($comp ne '') + { + &define_compiler_variable ($language_map{$lang . '-compiler-name'}, + $ltcompile, $comp); + } + # The compiler's flag must be a configure variable. + if (defined $language_map{$lang . '-flag'}) + { + &define_configure_variable ($language_map{$lang . '-flag'}); + } + # Compute the function name of the finisher and then call it. $name = 'lang_' . $lang . '_finish'; & $name (); @@ -965,11 +1043,15 @@ sub finish_languages # it. if (! $non_c || scalar keys %suffix_rules > 0) { - local ($ltcompile, $ltlink) = &libtool_compiler; + if (! defined $done{'c'}) + { + local ($ltcompile, $ltlink) = &libtool_compiler; - &define_configure_variable ('CFLAGS'); - &define_compiler_variable ('COMPILE', $ltcompile, - '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)'); + &define_configure_variable ($language_map{'c-flag'}); + &define_compiler_variable ($language_map{'c-compiler-name'}, + $ltcompile, + $language_map{'c-compile'}); + } &define_variable ('CCLD', '$(CC)'); &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); } @@ -1071,6 +1153,7 @@ sub check_libobjs_sources # Does much of the actual work for handle_source_transform. # Arguments are: +# name of resulting executable or library ("derived") # object extension (e.g., `$U.lo') # list of source files to transform # Result is a list @@ -1078,7 +1161,7 @@ sub check_libobjs_sources # remaining elements are names of objects sub handle_single_transform_list { - local ($obj, @files) = @_; + local ($derived, $obj, @files) = @_; local (@result) = (); local ($nonansi_obj) = $obj; $nonansi_obj =~ s/_//g; @@ -1104,6 +1187,11 @@ sub handle_single_transform_list local ($xbase) = $base; + # We must generate a rule for the object if it requires + # its own flags. + local ($rule) = ''; + local ($renamed) = 0; + local ($lang) = $extension_map{$extension}; if ($lang) { @@ -1127,6 +1215,59 @@ sub handle_single_transform_list $object = $base . $nonansi_obj; } + if ($language_map{$lang . '-flags'} ne '' + && &variable_defined ($derived . '_' + . $language_map{$lang . '-flags'})) + { + # We have a per-executable flag in effect for this + # object. In this case we rewrite the object's + # name to ensure it is unique. We also require + # the `compile' program to deal with compilers + # where `-c -o' does not work. + + # We choose the name `DERIVED-OBJECT' to ensure + # (1) uniqueness, and (2) continuity between + # invocations. However, this will result in a + # name that is too long for losing systems, in + # some situations. So we provide _SHORTNAME to + # override. + + local ($dname) = $derived; + if (&variable_defined ($derived . '_SHORTNAME')) + { + # FIXME: should use the same conditional as + # the _SOURCES variable. But this is really + # silly overkill -- nobody should have + # conditional shortnames. + $dname = &variable_value ($derived . '_SHORTNAME'); + } + $object = $dname . '-' . $object; + + &require_file ($FOREIGN, 'compile') + if $lang eq 'c'; + + if (! defined $language_map{$lang . '-compile'}) + { + print STDERR "automake: programming error: $lang flags defined without compiler\n"; + exit 1; + } + # Compute the rule to compile this object. + local ($flag) = $language_map{$lang . '-flags'}; + local ($val) = "(${derived}_${flag}"; + ($rule = $language_map{$lang . '-compile'}) =~ + s/\($flag/$val/; + + $rule .= $language_map{$lang . '-output-arg'}; + # For C we have to add the -o, because the + # standard rule doesn't include it. + if ($language_map{$lang . '-flags'} eq 'CFLAGS') + { + $rule .= ' -o $@'; + } + + $renamed = 1; + } + # If rewrite said it was ok, put the object into a # subdir. if ($r == $LANG_SUBDIR && $directory ne '') @@ -1134,6 +1275,18 @@ sub handle_single_transform_list $object = $directory . '/' . $object; $xbase = $directory . '/' . $base; } + + # If doing dependency tracking, then we can't print + # the rule. + if ($use_dependencies + && $rule ne '' + && $language_map{$lang . '-autodep'} ne 'no') + { + $rule = ''; + $lang_specific_files{$lang} .= (' ' . $derived + . ' ' . $full + . ' ' . $object); + } } elsif ($extension =~ /^$source_suffix_pattern$/) { @@ -1167,7 +1320,7 @@ sub handle_single_transform_list # If file is in subdirectory, we need explicit # dependency. - if ($directory ne '') + if ($directory ne '' || $renamed) { push (@dep_list, $full); } @@ -1215,7 +1368,23 @@ sub handle_single_transform_list } } - &pretty_print_rule ($object . ':', "\t", @dep_list); + &pretty_print_rule ($object . ':', "\t", @dep_list) + if scalar @dep_list > 0 || $rule ne ''; + + # Print the rule if we have one. + if ($rule ne '') + { + # Turn `$@' into name of our object file. + local ($xform); + ($xform = $object) =~ s,/,\\/,g; + $rule =~ s/\$\@/$xform/; + # FIXME: we use $< in an explicit rule here. + # We can't use $(srcdir)/ because we don't + # actually know it is in srcdir. + $rule .= ' $<'; + # FIXME: handle .lo and .obj as well. + $output_rules .= "\t" . $rule . "\n"; + } } # Transform .o or $o file into .P file (for automatic @@ -1280,8 +1449,9 @@ sub handle_source_transform foreach $cond (@conds) { @files = &variable_value_as_list ($var, $cond); - ($temp, @result) = &handle_single_transform_list ($obj, - @files); + ($temp, @result) = + &handle_single_transform_list ($one_file, $obj, + @files); $linker = $temp if $linker eq ''; # Define _OBJECTS conditionally. @@ -1305,7 +1475,8 @@ sub handle_source_transform $used_pfx{$xpfx} = 1 unless $prefix =~ /EXTRA_/; - ($temp, @result) = &handle_single_transform_list ($obj, @files); + ($temp, @result) = &handle_single_transform_list ($one_file, $obj, + @files); $linker = $temp if $linker eq ''; &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result) unless $prefix =~ /EXTRA_/; @@ -1320,7 +1491,8 @@ sub handle_source_transform push (@objects, $unxformed . $obj); push (@files, $unxformed . '.c'); - ($temp, @result) = &handle_single_transform_list ($obj, @files); + ($temp, @result) = &handle_single_transform_list ($one_file, $obj, + @files); $linker = $temp if $linker eq ''; &define_pretty_variable ($one_file . "_OBJECTS", '', @result) } @@ -1350,11 +1522,6 @@ sub handle_built_sources last; } } - - # We don't care about the return value of this function. We just - # want to make sure to update %dep_files with the contents of - # BUILT_SOURCES. - &handle_single_transform_list (".o", @sources); } # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables. @@ -1467,10 +1634,16 @@ sub handle_lib_objects_cond { ($rewrite = $iter) =~ s/\.c$/.P/; $dep_files{'.deps/' . $rewrite} = 1; - &require_file_with_line ($var, $FOREIGN, $iter) - unless &variable_defined ('BUILT_SOURCES') - && grep ('^' . (($rewrite = $iter) =~ s/(\W)/\\\1/g) . '$', - &variable_value_as_list ('BUILT_SOURCES', 'all')); + ($rewrite = $iter) =~ s/(\W)/\\$1/g; + $rewrite = "^" . $rewrite . "\$"; + # Only require the file if it is not a built source. + if (! &variable_defined ('BUILT_SOURCES') + || ! grep (/$rewrite/, + &variable_value_as_list ('BUILT_SOURCES', + 'all'))) + { + &require_file_with_line ($var, $FOREIGN, $iter); + } } } } @@ -1503,7 +1676,7 @@ sub check_canonical_spelling local ($xname, $xt); ($xname = $name) =~ tr/A-Za-z0-9_/_/c; - $xname =~ s/^([0-9_])/AM\1/; + $xname =~ s/^([0-9_])/AM$1/; if ($xname ne $name) { local ($xt); @@ -2835,6 +3008,57 @@ sub scan_dependency_file close (DEP_FILE); } +# A subroutine of handle_dependencies. This function includes +# `depend2' with appropriate transformations. +sub add_depend2 +{ + local ($lang) = @_; + + # First include code for ordinary objects. + local ($key) = $lang . '-autodep'; + local ($xform, $ext); + $xform = ('s/\@COMPILE\@/\$(' . $language_map{$key} . 'COMPILE)/g;' + . 's/\@LTCOMPILE\@/\$(LT' . $language_map{$key} . 'COMPILE)/g;' + . 's/\@OBJ\@/%.o/g;' + . 's/\@LTOBJ\@/%.lo/g;'); + foreach $ext (&lang_extensions ($lang)) + { + $output_rules .= &file_contents_with_transform ('s/\@SOURCE\@/%' + . $ext . '/g;' + . $xform, + 'depend2'); + } + + # Now include code for each specially handled object with this + # language. + local (@list) = grep ($_ ne '', split (' ', $lang_specific_files{$lang})); + local ($max) = scalar @list; + local ($i) = 0; + local ($derived, $source, $obj); + while ($i < $max) + { + $derived = $list[$i]; + ($source = $list[$i + 1]) =~ s,([/\$]),\\$1,g; + ($obj = $list[$i + 2]) =~ s,([/\$]),\\$1,g; + $i += 3; + + local ($flag) = $language_map{$lang . '-flags'}; + local ($val) = "(${derived}_${flag}"; + ($rule = $language_map{$lang . '-compile'}) =~ + s/\($flag/$val/; + + $rule =~ s,([/\$]),\\$1,g; + + $xform = ('s/\@COMPILE\@/' . $rule . '/g;' + . 's/\@LTCOMPILE\@/\$(LIBTOOL) --mode=compile ' . $rule + . '/g;' + . 's/\@OBJ\@/' . $obj . '.o/g;' + . 's/\@LTOBJ\@/' . $obj . '.lo/g;' + . 's/\@SOURCE\@/' . $source . '/g;'); + $output_rules .= &file_contents_with_transform ($xform, 'depend2'); + } +} + # Handle auto-dependency code. sub handle_dependencies { @@ -2855,18 +3079,10 @@ sub handle_dependencies local ($key, $lang, $ext, $xform); foreach $key (sort keys %language_map) { - next unless $key =~ /^(.*)-autodep$/; - next if $language_map{$key} eq 'no'; - $lang = $1; - - $xform = 's/\@PFX\@/' . $language_map{$key} . '/g;'; - foreach $ext (&lang_extensions ($lang)) + if ($key =~ /^(.*)-autodep$/ + && $language_map{$key} ne 'no') { - $output_rules .= - &file_contents_with_transform ('s/\@EXT\@/' - . $ext . '/g;' - . $xform, - 'depend2'); + &add_depend2 ($1); } } } @@ -4833,39 +5049,14 @@ sub lang_c_finish sub lang_cxx_finish { - local (@cxx_list) = &lang_extensions ('cxx'); - local ($cxx_count) = scalar @cxx_list; - if ($cxx_count) - { - push (@suffixes, @cxx_list); - - local ($ltcompile, $ltlink) = &libtool_compiler; - - &define_configure_variable ("CXXFLAGS"); - &define_compiler_variable ('CXXCOMPILE', $ltcompile, '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)'); - - &define_variable ('CXXLD', '$(CXX)'); - &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); + local ($ltcompile, $ltlink) = &libtool_compiler; - local ($ext); - foreach $ext (@cxx_list) - { - # Every known C++ compiler supports both -c and -o. - $output_rules .= ("$ext.o:\n" - . "\t\$(CXXCOMPILE) -c -o \$\@ \$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= ("$ext.obj:\n" - . "\t\$(CXXCOMPILE) -c -o \$\@ `cygpath -w \$<`\n") - if ($seen_objext); - $output_rules .= ("$ext.lo:\n" - . "\t\$(LTCXXCOMPILE) -c -o \$\@ \$<\n") - if ($seen_libtool); - } + &define_variable ('CXXLD', '$(CXX)'); + &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - if (! defined $configure_vars{'CXX'}) - { - &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'"); - } + if (! defined $configure_vars{'CXX'}) + { + &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'"); } } @@ -5009,67 +5200,21 @@ sub lang_asm_finish { # We need the C code for assembly. &lang_c_finish; - - # We also need our own rules. - local ($minuso) = ''; - if (defined $options{'subdir-objects'}) - { - $minuso = '-o $@ '; - } - local (@asm_list) = &lang_extensions ('am'); - local ($ext); - foreach $ext (@asm_list) - { - $output_rules .= ("$ext.o:\n" - . "\t\$(COMPILE) -c " . $minuso . "\$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= ("$ext.obj:\n" - . "\t\$(COMPILE) -c " . $minuso - . "`cygpath -w \$<`\n") - if $seen_objext; - $output_rules .= ("$ext.lo:\n" - . "\t\$(LTCOMPILE) -c -o \$\@ \$<\n") - if $seen_libtool; - } - - push (@suffixes, @asm_list); } sub lang_f77_finish { - local (@f77_list) = &lang_extensions ('f77'); - local ($f77_count) = scalar @f77_list; - if ($f77_count) - { - push (@suffixes, @f77_list); - - local ($ltcompile, $ltlink) = &libtool_compiler; + # FIXME: this function can be called more than once. We should + # arrange for it to only do anything the first time through. - &define_configure_variable ('FFLAGS'); - &define_compiler_variable ('F77COMPILE', $ltcompile, - '$(F77) $(AM_FFLAGS) $(FFLAGS)'); - - &define_variable ('F77LD', '$(F77)'); - &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); + local ($ltcompile, $ltlink) = &libtool_compiler; - local ($ext); - foreach $ext (@f77_list) - { - $output_rules .= ("$ext.o:\n" - . "\t\$(F77COMPILE) -c \$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= ("$ext.obj:\n" - . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n") - if ($seen_objext); - $output_rules .= ("$ext.lo:\n" - . "\t\$(LTF77COMPILE) -c \$<\n") - if ($seen_libtool); - } + &define_variable ('F77LD', '$(F77)'); + &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - if (! defined $configure_vars{'F77'}) - { - &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'"); - } + if (! defined $configure_vars{'F77'}) + { + &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'"); } } @@ -5089,104 +5234,31 @@ sub lang_f77_finish # available). sub lang_ppf77_finish { - local ($ext) = 'F'; - last unless $extension_seen{$ext}; - - $ext = '.' . $ext; - push (@suffixes, $ext); - - local ($ltcompile, $ltlink) = &libtool_compiler; - - &define_configure_variable ('FFLAGS'); - &define_compiler_variable ('F77COMPILE', $ltcompile, - '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)'); - - &define_variable ('F77LD', '$(F77)'); - &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - - $output_rules .= ("$ext.o:\n" - . "\t\$(F77COMPILE) -c \$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= ("$ext.obj:\n" - . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n") - if ($seen_objext); - $output_rules .= ("$ext.lo:\n" - . "\t\$(LTF77COMPILE) -c \$<\n") - if ($seen_libtool); + &lang_f77_finish; # We also handle the case of preprocessing `.F' files into `.f' # files. - $output_rules .= ("$ext.f:\n" + $output_rules .= (".F.f:\n" . "\t\$(F77COMPILE) -F \$<\n"); - - if (! defined $configure_vars{'F77'}) - { - &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'"); - } } sub lang_ratfor_finish { - local ($ext) = 'r'; - last unless $extension_seen{$ext}; - $ext = '.' . $ext; - push (@suffixes, $ext); - - local ($ltcompile, $ltlink) = &libtool_compiler; - - &define_configure_variable ('FFLAGS'); - &define_configure_variable ('RFLAGS'); - &define_variable ('RCOMPILE', $ltcompile, - '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)'); - - &define_variable ('F77LD', '$(F77)'); - &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - - $output_rules .= ("$ext.o:\n" - . "\t\$(RCOMPILE) -c \$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= ("$ext.obj:\n" - . "\t\$(RCOMPILE) -c `cygpath -w \$<`\n") - if ($seen_objext); - $output_rules .= ("$ext.lo:\n" - . "\t\$(LTRCOMPILE) -c \$<\n") - if ($seen_libtool); + &lang_f77_finish; # We also handle the case of preprocessing `.r' files into `.f' # files. - $output_rules .= ("$ext.f:\n" + $output_rules .= (".r.f:\n" . "\t\$(RCOMPILE) -F \$<\n"); - - if (! defined $configure_vars{'F77'}) - { - &am_error ("Ratfor source seen but \`F77' not defined in \`configure.in'"); - } } sub lang_objc_finish { - push (@suffixes, '.m'); - local ($ltcompile, $ltlink) = &libtool_compiler; - &define_configure_variable ("OBJCFLAGS"); - &define_compiler_variable ('OBJCCOMPILE', $ltcompile, - '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)'); - &define_variable ('OBJCLD', '$(OBJC)'); &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - # All known ObjC compilers support -c and -o together. - $output_rules .= (".m.o:\n" - . "\t\$(OBJCCOMPILE) -c -o \$\@ \$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= (".m.obj:\n" - . "\t\$(OBJCCOMPILE) -c -o \$\@ `cygpath -w \$<`\n") - if ($seen_objext); - $output_rules .= (".m.lo:\n" - . "\t\$(LTOBJCCOMPILE) -c -o \$\@ \$<\n") - if ($seen_libtool); - if (! defined $configure_vars{'OBJC'}) { &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'"); @@ -5195,33 +5267,11 @@ sub lang_objc_finish sub lang_java_finish { - local (@java_list) = &lang_extensions ('java'); - push (@suffixes, @java_list); - local ($ltcompile, $ltlink) = &libtool_compiler; - &define_configure_variable ("GCJFLAGS"); - &define_compiler_variable ('GCJCOMPILE', $ltcompile, - '$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)'); - &define_variable ('GCJLD', '$(GCJ)'); &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'); - local ($ext); - foreach $ext (@java_list) - { - # All known Java compilers support -c and -o together. - $output_rules .= (".${ext}.o:\n" - . "\t\$(GCJCOMPILE) -c -o \$\@ \$<\n"); - # FIXME: Using cygpath should be somehow conditional. - $output_rules .= (".${ext}.obj:\n" - . "\t\$(GCJCOMPILE) -c -o \$\@ `cygpath -w \$<`\n") - if $seen_objext; - $output_rules .= (".${ext}.lo:\n" - . "\t\$(LTGCJCOMPILE) -c -o \$\@ \$<\n") - if $seen_libtool; - } - if (! defined $configure_vars{'GCJ'}) { &am_error ("Java source seen but \`GCJ' not defined in \`configure.in'"); @@ -6806,6 +6856,10 @@ sub initialize_per_input # This is random scratch space for the language finish functions. # Don't randomly overwrite it; examine other uses of keys first. %language_scratch = (); + + # We keep track of which objects need special (per-executable) + # handling on a per-language basis. + %lang_specific_files = (); } diff --git a/compile.am b/compile.am index e0a6eb1..8fac893 100644 --- a/compile.am +++ b/compile.am @@ -15,14 +15,6 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -NOTDEPEND.c.o: -NOTDEPEND $(COMPILE) -c@MINUSO@ $< - -OBJEXT# FIXME: We should only use cygpath when building on Windows, -OBJEXT# and only if it is available. -OBJEXT.c.obj: -OBJEXT $(COMPILE) -c@MINUSO@ `cygpath -w $<` - mostlyclean-compile: ## Don't remove 'core.*' because some distributions have eg "core.c". ## 4.4BSD systems use `PROG.core'. diff --git a/depend2.am b/depend2.am index be93a8b..7d68dbf 100644 --- a/depend2.am +++ b/depend2.am @@ -15,8 +15,8 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -%.o: %@EXT@ - @echo '$(@PFX@COMPILE) -c $<'; \ +@OBJ@: @SOURCE@ + @echo '@COMPILE@ -c -o $@ $<'; \ ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end @@ -26,7 +26,7 @@ ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). - $(@PFX@COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c $< + @COMPILE@ -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $< ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is @@ -42,10 +42,10 @@ >> .deps/$(*D)/$(*F).P; \ rm .deps/$(*D)/$(*F).pp -%.lo: %@EXT@ - @echo '$(LT@PFX@COMPILE) -c $<'; \ +@LTOBJ@: @SOURCE@ + @echo '@LTCOMPILE@ -c -o $@ $<'; \ ## See above to understand implementation weirdness. - $(LT@PFX@COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c $< + @LTCOMPILE@ -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $< ## Account for versions of gcc that put a space before the `:'. @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ < .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \ diff --git a/lib/am/compile.am b/lib/am/compile.am index e0a6eb1..8fac893 100644 --- a/lib/am/compile.am +++ b/lib/am/compile.am @@ -15,14 +15,6 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -NOTDEPEND.c.o: -NOTDEPEND $(COMPILE) -c@MINUSO@ $< - -OBJEXT# FIXME: We should only use cygpath when building on Windows, -OBJEXT# and only if it is available. -OBJEXT.c.obj: -OBJEXT $(COMPILE) -c@MINUSO@ `cygpath -w $<` - mostlyclean-compile: ## Don't remove 'core.*' because some distributions have eg "core.c". ## 4.4BSD systems use `PROG.core'. diff --git a/lib/am/depend2.am b/lib/am/depend2.am index be93a8b..7d68dbf 100644 --- a/lib/am/depend2.am +++ b/lib/am/depend2.am @@ -15,8 +15,8 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -%.o: %@EXT@ - @echo '$(@PFX@COMPILE) -c $<'; \ +@OBJ@: @SOURCE@ + @echo '@COMPILE@ -c -o $@ $<'; \ ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end @@ -26,7 +26,7 @@ ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). - $(@PFX@COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c $< + @COMPILE@ -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $< ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is @@ -42,10 +42,10 @@ >> .deps/$(*D)/$(*F).P; \ rm .deps/$(*D)/$(*F).pp -%.lo: %@EXT@ - @echo '$(LT@PFX@COMPILE) -c $<'; \ +@LTOBJ@: @SOURCE@ + @echo '@LTCOMPILE@ -c -o $@ $<'; \ ## See above to understand implementation weirdness. - $(LT@PFX@COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c $< + @LTCOMPILE@ -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $< ## Account for versions of gcc that put a space before the `:'. @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ < .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \