# 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'.
'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',
'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',
'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',
register_language ('name' => 'yacc',
'Name' => 'Yacc',
'config_vars' => ['YACC'],
- 'flags' => 'YFLAGS',
+ 'flags' => ['YFLAGS'],
'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
'compiler' => 'YACCCOMPILE',
'extensions' => ['.y'],
'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'],
'Name' => 'Lex',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
- 'flags' => 'LFLAGS',
+ 'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l'],
'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'],
'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)',
'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',
'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',
'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',
'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',
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.
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.
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'});
}
}
}
$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
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'};
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,
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
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
@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