]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Fix for PR automake/337:
authorAlexandre Duret-Lutz <adl@gnu.org>
Thu, 11 Jul 2002 20:10:39 +0000 (20:10 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Thu, 11 Jul 2002 20:10:39 +0000 (20:10 +0000)
* automake.in: Redefine the `flags' attribute of each language
as a list.  List CPPFLAGS in `flags' when it is used.
(register_language): Set the default value of 'flags'.
(handle_single_transform_list): Adjust to treat `flags' as a list.
(handle_languages): Likewise.  Don't bother defining the
configure variable for `c', this is always done since we trace
configure.ac.
* automake.texi (etags): Use per-executable _CPPFLAGS.
(Program and Library Variables): Mention maude_CPPFLAGS.
(Program variables): Likewise.
* tests/specflags8.test: Use _CPPFLAGS instead of _CFLAGS.
* tests/specflags9.test: New file.
* tests/Makefile.am (TESTS): Add specflag9.test.

ChangeLog
NEWS
automake.in
automake.texi
stamp-vti
tests/Makefile.am
tests/Makefile.in
tests/specflags8.test
tests/specflags9.test [new file with mode: 0755]
version.texi

index 9f4b151c7dfec6eddffb06aa84f094db47ee2e0d..3f2fdc9d81134ea6e74314e696da38b932e02ef6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2002-07-11  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       Fix for PR automake/337:
+       * automake.in: Redefine the `flags' attribute of each language
+       as a list.  List CPPFLAGS in `flags' when it is used.
+       (register_language): Set the default value of 'flags'.
+       (handle_single_transform_list): Adjust to treat `flags' as a list.
+       (handle_languages): Likewise.  Don't bother defining the
+       configure variable for `c', this is always done since we trace
+       configure.ac.
+       * automake.texi (etags): Use per-executable _CPPFLAGS.
+       (Program and Library Variables): Mention maude_CPPFLAGS.
+       (Program variables): Likewise.
+       * tests/specflags8.test: Use _CPPFLAGS instead of _CFLAGS.
+       * tests/specflags9.test: New file.
+       * tests/Makefile.am (TESTS): Add specflag9.test.
+
 2002-07-10  Alexandre Duret-Lutz  <duret_g@epita.fr>
 
        * automake.texi: Use `variable' instead of `macro' everywhere it
diff --git a/NEWS b/NEWS
index bd9eebf9b22f57bfa06456525106aec179ac9b20..3542287e73096c49816659d6406dcc551757b536 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 New in 1.6a:
+* Support for per-program and per-library `_CPPFLAGS'.
+* New `ctags' target (builds CTAGS files).
 * Support for -Wmumble and -Wno-mumble, where mumble is a warning category
   (see `automake --help' or the manual for a list of them).
 * Honor the WARNINGS environment variable.
index 14957f60f460ff4aa970bf870fe211b3b98bdc49..76e56da8b81746a8d8de485c386aaaff5fcaad5c 100755 (executable)
@@ -64,7 +64,9 @@ struct (# Short name of the language (c, f77...).
        # the product given the input extensions.
        # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo'))
        'output_extensions' => "\$",
-        'flags' => "\$",
+       # A list of flag variables used in 'compile'.
+       # (defaults to [])
+        'flags' => "@",
 
        # The file to use when generating rules for this language.
        # The default is 'depend2'.
@@ -876,7 +878,7 @@ register_language ('name' => 'c',
                   'config_vars' => ['CC'],
                   'ansi' => 1,
                   'autodep' => '',
-                  'flags' => 'CFLAGS',
+                  'flags' => ['CFLAGS', 'CPPFLAGS'],
                   'compiler' => 'COMPILE',
                   'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
                   'lder' => 'CCLD',
@@ -894,7 +896,7 @@ register_language ('name' => 'cxx',
                   'linker' => 'CXXLINK',
                   'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
                   'autodep' => 'CXX',
-                  'flags' => 'CXXFLAGS',
+                  'flags' => ['CXXFLAGS', 'CPPFLAGS'],
                   'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
                   'compiler' => 'CXXCOMPILE',
                   'compile_flag' => '-c',
@@ -911,7 +913,7 @@ register_language ('name' => 'objc',
                   'linker' => 'OBJCLINK',,
                   'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
                   'autodep' => 'OBJC',
-                  'flags' => 'OBJCFLAGS',
+                  'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
                   'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
                   'compiler' => 'OBJCCOMPILE',
                   'compile_flag' => '-c',
@@ -935,7 +937,7 @@ register_language ('name' => 'header',
 register_language ('name' => 'yacc',
                   'Name' => 'Yacc',
                   'config_vars' => ['YACC'],
-                  'flags' => 'YFLAGS',
+                  'flags' => ['YFLAGS'],
                   'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
                   'compiler' => 'YACCCOMPILE',
                   'extensions' => ['.y'],
@@ -948,7 +950,7 @@ register_language ('name' => 'yaccxx',
                   'Name' => 'Yacc (C++)',
                   'config_vars' => ['YACC'],
                   'rule_file' => 'yacc',
-                  'flags' => 'YFLAGS',
+                  'flags' => ['YFLAGS'],
                   'compiler' => 'YACCCOMPILE',
                   'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
                   'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
@@ -962,7 +964,7 @@ register_language ('name' => 'lex',
                   'Name' => 'Lex',
                   'config_vars' => ['LEX'],
                   'rule_file' => 'lex',
-                  'flags' => 'LFLAGS',
+                  'flags' => ['LFLAGS'],
                   'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
                   'compiler' => 'LEXCOMPILE',
                   'extensions' => ['.l'],
@@ -974,7 +976,7 @@ register_language ('name' => 'lexxx',
                   'Name' => 'Lex (C++)',
                   'config_vars' => ['LEX'],
                   'rule_file' => 'lex',
-                  'flags' => 'LFLAGS',
+                  'flags' => ['LFLAGS'],
                   'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
                   'compiler' => 'LEXCOMPILE',
                   'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
@@ -988,7 +990,7 @@ register_language ('name' => 'asm',
                   'Name' => 'Assembler',
                   'config_vars' => ['CCAS', 'CCASFLAGS'],
 
-                  'flags' => 'CCASFLAGS',
+                  'flags' => ['CCASFLAGS'],
                   # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
                   # or anything else required.  They can also set AS.
                   'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
@@ -1004,7 +1006,7 @@ register_language ('name' => 'f77',
                   'Name' => 'Fortran 77',
                   'linker' => 'F77LINK',
                   'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
-                  'flags' => 'FFLAGS',
+                  'flags' => ['FFLAGS'],
                   'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
                   'compiler' => 'F77COMPILE',
                   'compile_flag' => '-c',
@@ -1036,7 +1038,7 @@ register_language ('name' => 'ppf77',
                   'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
                   'lder' => 'F77LD',
                   'ld' => '$(F77)',
-                  'flags' => 'FFLAGS',
+                  'flags' => ['FFLAGS', 'CPPFLAGS'],
                   'compiler' => 'PPF77COMPILE',
                   'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
                   'compile_flag' => '-c',
@@ -1052,7 +1054,7 @@ register_language ('name' => 'ratfor',
                   'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
                   'lder' => 'F77LD',
                   'ld' => '$(F77)',
-                  'flags' => 'RFLAGS',
+                  'flags' => ['RFLAGS', 'FFLAGS'],
                   # FIXME also FFLAGS.
                   'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
                   'compiler' => 'RCOMPILE',
@@ -1068,7 +1070,7 @@ register_language ('name' => 'java',
                   'linker' => 'GCJLINK',
                   'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
                   'autodep' => 'GCJ',
-                  'flags' => 'GCJFLAGS',
+                  'flags' => ['GCJFLAGS'],
                   'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
                   'compiler' => 'GCJCOMPILE',
                   'compile_flag' => '-c',
@@ -1974,7 +1976,7 @@ sub handle_languages
            my $output_flag = $lang->output_flag || '';
            $output_flag = '-o'
              if (! $output_flag
-                 && $lang->flags eq 'CFLAGS'
+                 && $lang->name eq 'c'
                  && defined $options{'subdir-objects'});
 
            # Compute a possible derived extension.
@@ -2024,14 +2026,21 @@ sub handle_languages
            next if defined $seen_files{$obj};
            $seen_files{$obj} = 1;
 
-           my $flags = $lang->flags || '';
-           my $val = "${derived}_${flags}";
-
            prog_error ("found " . $lang->name .
                        " in handle_languages, but compiler not defined")
              unless defined $lang->compile;
 
-           (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
+           my $obj_compile = $lang->compile;
+
+           # Rewrite each occurence of `AM_$flag' in the compile
+           # rule into `${derived}_$flag' if it exists.
+           for my $flag (@{$lang->flags})
+             {
+               my $val = "${derived}_$flag";
+               $obj_compile =~ s/\(AM_$flag\)/\($val\)/
+                 if variable_defined ($val);
+             }
+
            my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
 
            # We _need_ `-o' for per object rules.
@@ -2106,11 +2115,8 @@ sub handle_languages
 
     if ($needs_c)
       {
-       if (! defined $done{$languages{'c'}})
-         {
-           &define_configure_variable ($languages{'c'}->flags);
-           &define_compiler_variable ($languages{'c'});
-         }
+       &define_compiler_variable ($languages{'c'})
+         unless defined $done{$languages{'c'}};
        define_linker_variable ($languages{'c'});
       }
 }
@@ -2254,8 +2260,18 @@ sub handle_single_transform_list ($$$$@)
            }
            $object = $base . $this_obj_ext;
 
-            if (defined $lang->flags
-                && variable_defined ($derived . '_' . $lang->flags))
+           # Do we have per-executable flags for this executable?
+           my $have_per_exec_flags = 0;
+           foreach my $flag (@{$lang->flags})
+             {
+               if (variable_defined ("${derived}_$flag"))
+                 {
+                   $have_per_exec_flags = 1;
+                   last;
+                 }
+             }
+
+            if ($have_per_exec_flags)
             {
                 # We have a per-executable flag in effect for this
                 # object.  In this case we rewrite the object's
@@ -5508,6 +5524,8 @@ sub register_language (%)
     unless defined $option{'autodep'};
   $option{'linker'} = ''
     unless defined $option{'linker'};
+  $option{'flags'} = []
+    unless defined $option{'flags'};
   $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
     unless defined $option{'output_extensions'};
 
index 23a0291f88170a1fbfdd9c9f0d4aac3847978ef6..1caa5c2bf645d42bea1c48d24c247d93a2dfe762 100644 (file)
@@ -868,10 +868,10 @@ compilation flags, like so:
 bin_PROGRAMS = ctags etags
 
 ctags_SOURCES = etags.c
-ctags_CFLAGS = -DCTAGS
+ctags_CPPFLAGS = -DCTAGS
 
 etags_SOURCES = etags.c
-etags_CFLAGS = -DETAGS_REGEXPS
+etags_CPPFLAGS = -DETAGS_REGEXPS
 @end example
 
 In this case Automake will cause @file{etags.c} to be compiled twice,
@@ -2320,14 +2320,31 @@ Note that the name of the underlying program is @emph{not} passed to
 maude_LINK = $(CCLD) -magic -o $@@
 @end example
 
-@item maude_CFLAGS
+@item maude_CCASFLAGS
+@itemx maude_CFLAGS
+@itemx maude_CPPFLAGS
+@itemx maude_CXXFLAGS
+@itemx maude_FFLAGS
+@itemx maude_GCJFLAGS
+@itemx maude_LFLAGS
+@itemx maude_OBJCFLAGS
+@itemx maude_RFLAGS
+@itemx maude_YFLAGS
 Automake allows you to set compilation flags on a per-program (or
 per-library) basis.  A single source file can be included in several
 programs, and it will potentially be compiled with different flags for
 each program.  This works for any language directly supported by
-Automake.  The flags are @samp{_CFLAGS}, @samp{_CXXFLAGS},
-@samp{_OBJCFLAGS}, @samp{_LFLAGS}, @samp{_YFLAGS}, @samp{_CCASFLAGS},
-@samp{_FFLAGS}, @samp{_RFLAGS}, and @samp{_GCJFLAGS}.
+Automake.  The flags are
+@samp{_CCASFLAGS},
+@samp{_CFLAGS},
+@samp{_CPPFLAGS},
+@samp{_CXXFLAGS},
+@samp{_FFLAGS},
+@samp{_GCJFLAGS},
+@samp{_LFLAGS},
+@samp{_OBJCFLAGS},
+@samp{_RFLAGS}, and
+@samp{_YFLAGS}.
 
 When using a per-program compilation flag, Automake will choose a
 different name for the intermediate object files.  Ordinarily a file
@@ -2345,6 +2362,7 @@ to also use the value of @samp{AM_CFLAGS}, you would need to write:
 maude_CFLAGS = @dots{} your flags @dots{} $(AM_CFLAGS)
 @end example
 
+
 @item maude_DEPENDENCIES
 It is also occasionally useful to have a program depend on some other
 target which is not actually part of that program.  This can be done
@@ -2420,6 +2438,9 @@ pointing to the directory holding @file{config.h} (if you've used
 @code{AC_CONFIG_HEADERS} or @code{AM_CONFIG_HEADER}).  You can disable
 the default @samp{-I} options using the @samp{nostdinc} option.
 
+@code{AM_CPPFLAGS} is ignored in preference to a per-executable (or
+per-library) @code{_CPPFLAGS} variable if it is defined.
+
 @item INCLUDES
 This does the same job as @samp{AM_CPPFLAGS}.  It is an older name for
 the same functionality.  This variable is deprecated; we suggest using
index 832b35e66dc64c56840a5fdb24801c8b0564a1cf..dd8d9a137278af9f153f0c90ba528ac0f324b206 100644 (file)
--- a/stamp-vti
+++ b/stamp-vti
@@ -1,4 +1,4 @@
-@set UPDATED 10 July 2002
+@set UPDATED 11 July 2002
 @set UPDATED-MONTH July 2002
 @set EDITION 1.6a
 @set VERSION 1.6a
index 367c39bf144e02d02b667569f3c315ab800e87b4..2705db56f277a7a9a54ab59d02127381811eb756 100644 (file)
@@ -320,6 +320,7 @@ specflags3.test     \
 specflags6.test        \
 specflags7.test        \
 specflags8.test        \
+specflags9.test        \
 spell.test \
 spell2.test \
 spell3.test \
index 719f6e24960e949e4151830953de334022a8f482..f396c434a3f78351ec4a8303e463d009576e914a 100644 (file)
@@ -407,6 +407,7 @@ specflags3.test     \
 specflags6.test        \
 specflags7.test        \
 specflags8.test        \
+specflags9.test        \
 spell.test \
 spell2.test \
 spell3.test \
index b9566d52676e66d8ed12c23514c594fc016271b6..93e5420d4f5f5c335b544f232b7fa70ea8ac990b 100755 (executable)
@@ -1,8 +1,8 @@
 #! /bin/sh
 
 # Like the ctags/etags example from the manual,
-# with one extra indirection in the sources.
-# PR 315.
+# with one extra indirection in the sources (PR/315), and
+# use of _CPPFLAGS (PR/337).
 
 required=gcc
 . $srcdir/defs || exit 1
@@ -22,9 +22,9 @@ cat > Makefile.am << 'END'
 ETAGSSOURCE = etags.c
 bin_PROGRAMS = etags ctags
 ctags_SOURCES = $(ETAGSSOURCE)
-ctags_CFLAGS = -DCTAGS
+ctags_CPPFLAGS = -DCTAGS
 etags_SOURCES = $(ETAGSSOURCE)
-etags_CFLAGS = -DETAGS
+etags_CPPFLAGS = -DETAGS
 END
 
 cat > etags.c << 'END'
diff --git a/tests/specflags9.test b/tests/specflags9.test
new file mode 100755 (executable)
index 0000000..a1566a6
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+# Another check for per-target flag substitutions.
+
+. $srcdir/defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zzfoo zzbar
+zzfoo_SOURCES = sub/foo.c
+zzbar_SOURCES = bar.c
+zzbar_CPPFLAGS = -Dfoo
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+$FGREP '$(AM_CFLAGS)' Makefile.in
+
+$FGREP '$(zzfoo_CFLAGS)' Makefile.in && exit 1
+$FGREP '$(zzfoo_CPPFLAGS)' Makefile.in && exit 1
+
+$FGREP '$(zzbar_CFLAGS)' Makefile.in && exit 1
+$FGREP '$(zzbar_CPPFLAGS)' Makefile.in
+
+:
index 832b35e66dc64c56840a5fdb24801c8b0564a1cf..dd8d9a137278af9f153f0c90ba528ac0f324b206 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 10 July 2002
+@set UPDATED 11 July 2002
 @set UPDATED-MONTH July 2002
 @set EDITION 1.6a
 @set VERSION 1.6a