| 1 | #!@PERL@ -w | 
|---|
| 2 | # -*- perl -*- | 
|---|
| 3 | # @configure_input@ | 
|---|
| 4 |  | 
|---|
| 5 | eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | 
|---|
| 6 | if 0; | 
|---|
| 7 |  | 
|---|
| 8 | # automake - create Makefile.in from Makefile.am | 
|---|
| 9 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, | 
|---|
| 10 | # 2003, 2004  Free Software Foundation, Inc. | 
|---|
| 11 |  | 
|---|
| 12 | # This program is free software; you can redistribute it and/or modify | 
|---|
| 13 | # it under the terms of the GNU General Public License as published by | 
|---|
| 14 | # the Free Software Foundation; either version 2, or (at your option) | 
|---|
| 15 | # any later version. | 
|---|
| 16 |  | 
|---|
| 17 | # This program is distributed in the hope that it will be useful, | 
|---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 20 | # GNU General Public License for more details. | 
|---|
| 21 |  | 
|---|
| 22 | # You should have received a copy of the GNU General Public License | 
|---|
| 23 | # along with this program; if not, write to the Free Software | 
|---|
| 24 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 
|---|
| 25 | # 02111-1307, USA. | 
|---|
| 26 |  | 
|---|
| 27 | # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>. | 
|---|
| 28 | # Perl reimplementation by Tom Tromey <tromey@redhat.com>. | 
|---|
| 29 |  | 
|---|
| 30 | package Language; | 
|---|
| 31 |  | 
|---|
| 32 | BEGIN | 
|---|
| 33 | { | 
|---|
| 34 | my $perllibdir = $ENV{'perllibdir'} || $ENV{'UNIXROOT'}.'@datadir@/@PACKAGE@-@APIVERSION@'; | 
|---|
| 35 | $perllibdir =~ s/$ENV{'UNIXROOT'}\/\@unixroot/$ENV{'UNIXROOT'}/; # The EMX built perl doesn't know @unixroot. | 
|---|
| 36 | $perllibdir =~ s/\/\@unixroot/$ENV{'UNIXROOT'}/; # The EMX built perl doesn't know @unixroot. | 
|---|
| 37 | unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir); | 
|---|
| 38 |  | 
|---|
| 39 | # Override SHELL.  This is required on DJGPP so that system() uses | 
|---|
| 40 | # bash, not COMMAND.COM which doesn't quote arguments properly. | 
|---|
| 41 | # Other systems aren't expected to use $SHELL when Automake | 
|---|
| 42 | # runs, but it should be safe to drop the `if DJGPP' guard if | 
|---|
| 43 | # it turns up other systems need the same thing.  After all, | 
|---|
| 44 | # if SHELL is used, ./configure's SHELL is always better than | 
|---|
| 45 | # the user's SHELL (which may be something like tcsh). | 
|---|
| 46 | $ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJGPP'}; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | use Automake::Struct; | 
|---|
| 50 | struct (# Short name of the language (c, f77...). | 
|---|
| 51 | 'name' => "\$", | 
|---|
| 52 | # Nice name of the language (C, Fortran 77...). | 
|---|
| 53 | 'Name' => "\$", | 
|---|
| 54 |  | 
|---|
| 55 | # List of configure variables which must be defined. | 
|---|
| 56 | 'config_vars' => '@', | 
|---|
| 57 |  | 
|---|
| 58 | 'ansi'    => "\$", | 
|---|
| 59 | # `pure' is `1' or `'.  A `pure' language is one where, if | 
|---|
| 60 | # all the files in a directory are of that language, then we | 
|---|
| 61 | # do not require the C compiler or any code to call it. | 
|---|
| 62 | 'pure'   => "\$", | 
|---|
| 63 |  | 
|---|
| 64 | 'autodep' => "\$", | 
|---|
| 65 |  | 
|---|
| 66 | # Name of the compiling variable (COMPILE). | 
|---|
| 67 | 'compiler'  => "\$", | 
|---|
| 68 | # Content of the compiling variable. | 
|---|
| 69 | 'compile'  => "\$", | 
|---|
| 70 | # Flag to require compilation without linking (-c). | 
|---|
| 71 | 'compile_flag' => "\$", | 
|---|
| 72 | 'extensions' => '@', | 
|---|
| 73 | # A subroutine to compute a list of possible extensions of | 
|---|
| 74 | # the product given the input extensions. | 
|---|
| 75 | # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo')) | 
|---|
| 76 | 'output_extensions' => "\$", | 
|---|
| 77 | # A list of flag variables used in 'compile'. | 
|---|
| 78 | # (defaults to []) | 
|---|
| 79 | 'flags' => "@", | 
|---|
| 80 |  | 
|---|
| 81 | # The file to use when generating rules for this language. | 
|---|
| 82 | # The default is 'depend2'. | 
|---|
| 83 | 'rule_file' => "\$", | 
|---|
| 84 |  | 
|---|
| 85 | # Name of the linking variable (LINK). | 
|---|
| 86 | 'linker' => "\$", | 
|---|
| 87 | # Content of the linking variable. | 
|---|
| 88 | 'link' => "\$", | 
|---|
| 89 |  | 
|---|
| 90 | # Name of the linker variable (LD). | 
|---|
| 91 | 'lder' => "\$", | 
|---|
| 92 | # Content of the linker variable ($(CC)). | 
|---|
| 93 | 'ld' => "\$", | 
|---|
| 94 |  | 
|---|
| 95 | # Flag to specify the output file (-o). | 
|---|
| 96 | 'output_flag' => "\$", | 
|---|
| 97 | '_finish' => "\$", | 
|---|
| 98 |  | 
|---|
| 99 | # This is a subroutine which is called whenever we finally | 
|---|
| 100 | # determine the context in which a source file will be | 
|---|
| 101 | # compiled. | 
|---|
| 102 | '_target_hook' => "\$"); | 
|---|
| 103 |  | 
|---|
| 104 |  | 
|---|
| 105 | sub finish ($) | 
|---|
| 106 | { | 
|---|
| 107 | my ($self) = @_; | 
|---|
| 108 | if (defined $self->_finish) | 
|---|
| 109 | { | 
|---|
| 110 | &{$self->_finish} (); | 
|---|
| 111 | } | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | sub target_hook ($$$$) | 
|---|
| 115 | { | 
|---|
| 116 | my ($self) = @_; | 
|---|
| 117 | if (defined $self->_target_hook) | 
|---|
| 118 | { | 
|---|
| 119 | &{$self->_target_hook} (@_); | 
|---|
| 120 | } | 
|---|
| 121 | } | 
|---|
| 122 |  | 
|---|
| 123 | package Automake; | 
|---|
| 124 |  | 
|---|
| 125 | use strict; | 
|---|
| 126 | use Automake::Config; | 
|---|
| 127 | use Automake::General; | 
|---|
| 128 | use Automake::XFile; | 
|---|
| 129 | use Automake::Channels; | 
|---|
| 130 | use Automake::ChannelDefs; | 
|---|
| 131 | use Automake::Configure_ac; | 
|---|
| 132 | use Automake::FileUtils; | 
|---|
| 133 | use Automake::Location; | 
|---|
| 134 | use Automake::Condition qw/TRUE FALSE/; | 
|---|
| 135 | use Automake::DisjConditions; | 
|---|
| 136 | use Automake::Options; | 
|---|
| 137 | use Automake::Version; | 
|---|
| 138 | use Automake::Variable; | 
|---|
| 139 | use Automake::VarDef; | 
|---|
| 140 | use Automake::Rule; | 
|---|
| 141 | use Automake::RuleDef; | 
|---|
| 142 | use Automake::Wrap 'makefile_wrap'; | 
|---|
| 143 | use File::Basename; | 
|---|
| 144 | use Carp; | 
|---|
| 145 |  | 
|---|
| 146 | ## ----------- ## | 
|---|
| 147 | ## Constants.  ## | 
|---|
| 148 | ## ----------- ## | 
|---|
| 149 |  | 
|---|
| 150 | # Some regular expressions.  One reason to put them here is that it | 
|---|
| 151 | # makes indentation work better in Emacs. | 
|---|
| 152 |  | 
|---|
| 153 | # Writing singled-quoted-$-terminated regexes is a pain because | 
|---|
| 154 | # perl-mode thinks of $' as the ${'} variable (instead of a $ followed | 
|---|
| 155 | # by a closing quote.  Letting perl-mode think the quote is not closed | 
|---|
| 156 | # leads to all sort of misindentations.  On the other hand, defining | 
|---|
| 157 | # regexes as double-quoted strings is far less readable.  So usually | 
|---|
| 158 | # we will write: | 
|---|
| 159 | # | 
|---|
| 160 | #  $REGEX = '^regex_value' . "\$"; | 
|---|
| 161 |  | 
|---|
| 162 | my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n'; | 
|---|
| 163 | my $WHITE_PATTERN = '^\s*' . "\$"; | 
|---|
| 164 | my $COMMENT_PATTERN = '^#'; | 
|---|
| 165 | my $TARGET_PATTERN='[$a-zA-Z_.@%][-.a-zA-Z0-9_(){}/$+@%]*'; | 
|---|
| 166 | # A rule has three parts: a list of targets, a list of dependencies, | 
|---|
| 167 | # and optionally actions. | 
|---|
| 168 | my $RULE_PATTERN = | 
|---|
| 169 | "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$"; | 
|---|
| 170 |  | 
|---|
| 171 | # Only recognize leading spaces, not leading tabs.  If we recognize | 
|---|
| 172 | # leading tabs here then we need to make the reader smarter, because | 
|---|
| 173 | # otherwise it will think rules like `foo=bar; \' are errors. | 
|---|
| 174 | my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$"; | 
|---|
| 175 | # This pattern recognizes a Gnits version id and sets $1 if the | 
|---|
| 176 | # release is an alpha release.  We also allow a suffix which can be | 
|---|
| 177 | # used to extend the version number with a "fork" identifier. | 
|---|
| 178 | my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?'; | 
|---|
| 179 |  | 
|---|
| 180 | my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$"; | 
|---|
| 181 | my $ELSE_PATTERN = | 
|---|
| 182 | '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$"; | 
|---|
| 183 | my $ENDIF_PATTERN = | 
|---|
| 184 | '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$"; | 
|---|
| 185 | my $PATH_PATTERN = '(\w|[/.-])+'; | 
|---|
| 186 | # This will pass through anything not of the prescribed form. | 
|---|
| 187 | my $INCLUDE_PATTERN = ('^include\s+' | 
|---|
| 188 | . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')' | 
|---|
| 189 | . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')' | 
|---|
| 190 | . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$"); | 
|---|
| 191 |  | 
|---|
| 192 | # Match `-d' as a command-line argument in a string. | 
|---|
| 193 | my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)"; | 
|---|
| 194 | # Directories installed during 'install-exec' phase. | 
|---|
| 195 | my $EXEC_DIR_PATTERN = | 
|---|
| 196 | '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$"; | 
|---|
| 197 |  | 
|---|
| 198 | # Values for AC_CANONICAL_* | 
|---|
| 199 | use constant AC_CANONICAL_HOST   => 1; | 
|---|
| 200 | use constant AC_CANONICAL_SYSTEM => 2; | 
|---|
| 201 |  | 
|---|
| 202 | # Values indicating when something should be cleaned. | 
|---|
| 203 | use constant MOSTLY_CLEAN     => 0; | 
|---|
| 204 | use constant CLEAN            => 1; | 
|---|
| 205 | use constant DIST_CLEAN       => 2; | 
|---|
| 206 | use constant MAINTAINER_CLEAN => 3; | 
|---|
| 207 |  | 
|---|
| 208 | # Libtool files. | 
|---|
| 209 | my @libtool_files = qw(ltmain.sh config.guess config.sub); | 
|---|
| 210 | # ltconfig appears here for compatibility with old versions of libtool. | 
|---|
| 211 | my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh); | 
|---|
| 212 |  | 
|---|
| 213 | # Commonly found files we look for and automatically include in | 
|---|
| 214 | # DISTFILES. | 
|---|
| 215 | my @common_files = | 
|---|
| 216 | (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB | 
|---|
| 217 | COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO | 
|---|
| 218 | ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub | 
|---|
| 219 | depcomp elisp-comp install-sh libversion.in mdate-sh missing | 
|---|
| 220 | mkinstalldirs py-compile texinfo.tex ylwrap), | 
|---|
| 221 | @libtool_files, @libtool_sometimes); | 
|---|
| 222 |  | 
|---|
| 223 | # Commonly used files we auto-include, but only sometimes.  This list | 
|---|
| 224 | # is used for the --help output only. | 
|---|
| 225 | my @common_sometimes = | 
|---|
| 226 | qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure | 
|---|
| 227 | configure.ac configure.in stamp-vti); | 
|---|
| 228 |  | 
|---|
| 229 | # Standard directories from the GNU Coding Standards, and additional | 
|---|
| 230 | # pkg* directories from Automake.  Stored in a hash for fast member check. | 
|---|
| 231 | my %standard_prefix = | 
|---|
| 232 | map { $_ => 1 } (qw(bin data exec include info lib libexec lisp | 
|---|
| 233 | localstate man man1 man2 man3 man4 man5 man6 | 
|---|
| 234 | man7 man8 man9 oldinclude pkgdatadir | 
|---|
| 235 | pkgincludedir pkglibdir sbin sharedstate | 
|---|
| 236 | sysconf)); | 
|---|
| 237 |  | 
|---|
| 238 | # Copyright on generated Makefile.ins. | 
|---|
| 239 | my $gen_copyright = "\ | 
|---|
| 240 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, | 
|---|
| 241 | # 2003, 2004  Free Software Foundation, Inc. | 
|---|
| 242 | # This Makefile.in is free software; the Free Software Foundation | 
|---|
| 243 | # gives unlimited permission to copy and/or distribute it, | 
|---|
| 244 | # with or without modifications, as long as this notice is preserved. | 
|---|
| 245 |  | 
|---|
| 246 | # This program is distributed in the hope that it will be useful, | 
|---|
| 247 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | 
|---|
| 248 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 
|---|
| 249 | # PARTICULAR PURPOSE. | 
|---|
| 250 | "; | 
|---|
| 251 |  | 
|---|
| 252 | # These constants are returned by lang_*_rewrite functions. | 
|---|
| 253 | # LANG_SUBDIR means that the resulting object file should be in a | 
|---|
| 254 | # subdir if the source file is.  In this case the file name cannot | 
|---|
| 255 | # have `..' components. | 
|---|
| 256 | use constant LANG_IGNORE  => 0; | 
|---|
| 257 | use constant LANG_PROCESS => 1; | 
|---|
| 258 | use constant LANG_SUBDIR  => 2; | 
|---|
| 259 |  | 
|---|
| 260 | # These are used when keeping track of whether an object can be built | 
|---|
| 261 | # by two different paths. | 
|---|
| 262 | use constant COMPILE_LIBTOOL  => 1; | 
|---|
| 263 | use constant COMPILE_ORDINARY => 2; | 
|---|
| 264 |  | 
|---|
| 265 | # We can't always associate a location to a variable or a rule, | 
|---|
| 266 | # when its defined by Automake.  We use INTERNAL in this case. | 
|---|
| 267 | use constant INTERNAL => new Automake::Location; | 
|---|
| 268 |  | 
|---|
| 269 |  | 
|---|
| 270 |  | 
|---|
| 271 | ## ---------------------------------- ## | 
|---|
| 272 | ## Variables related to the options.  ## | 
|---|
| 273 | ## ---------------------------------- ## | 
|---|
| 274 |  | 
|---|
| 275 | # TRUE if we should always generate Makefile.in. | 
|---|
| 276 | my $force_generation = 1; | 
|---|
| 277 |  | 
|---|
| 278 | # From the Perl manual. | 
|---|
| 279 | my $symlink_exists = (eval 'symlink ("", "");', $@ eq ''); | 
|---|
| 280 |  | 
|---|
| 281 | # TRUE if missing standard files should be installed. | 
|---|
| 282 | my $add_missing = 0; | 
|---|
| 283 |  | 
|---|
| 284 | # TRUE if we should copy missing files; otherwise symlink if possible. | 
|---|
| 285 | my $copy_missing = 0; | 
|---|
| 286 |  | 
|---|
| 287 | # TRUE if we should always update files that we know about. | 
|---|
| 288 | my $force_missing = 0; | 
|---|
| 289 |  | 
|---|
| 290 |  | 
|---|
| 291 | ## ---------------------------------------- ## | 
|---|
| 292 | ## Variables filled during files scanning.  ## | 
|---|
| 293 | ## ---------------------------------------- ## | 
|---|
| 294 |  | 
|---|
| 295 | # Name of the configure.ac file. | 
|---|
| 296 | my $configure_ac; | 
|---|
| 297 |  | 
|---|
| 298 | # Files found by scanning configure.ac for LIBOBJS. | 
|---|
| 299 | my %libsources = (); | 
|---|
| 300 |  | 
|---|
| 301 | # Names used in AC_CONFIG_HEADER call. | 
|---|
| 302 | my @config_headers = (); | 
|---|
| 303 |  | 
|---|
| 304 | # Names used in AC_CONFIG_LINKS call. | 
|---|
| 305 | my @config_links = (); | 
|---|
| 306 |  | 
|---|
| 307 | # Directory where output files go.  Actually, output files are | 
|---|
| 308 | # relative to this directory. | 
|---|
| 309 | my $output_directory; | 
|---|
| 310 |  | 
|---|
| 311 | # List of Makefile.am's to process, and their corresponding outputs. | 
|---|
| 312 | my @input_files = (); | 
|---|
| 313 | my %output_files = (); | 
|---|
| 314 |  | 
|---|
| 315 | # Complete list of Makefile.am's that exist. | 
|---|
| 316 | my @configure_input_files = (); | 
|---|
| 317 |  | 
|---|
| 318 | # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's, | 
|---|
| 319 | # and their outputs. | 
|---|
| 320 | my @other_input_files = (); | 
|---|
| 321 | # Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears. | 
|---|
| 322 | # The keys are the files created by these macros. | 
|---|
| 323 | my %ac_config_files_location = (); | 
|---|
| 324 |  | 
|---|
| 325 | # List of directories to search for configure-required files.  This | 
|---|
| 326 | # can be set by AC_CONFIG_AUX_DIR. | 
|---|
| 327 | my @config_aux_path = qw(. .. ../..); | 
|---|
| 328 | my $config_aux_dir = ''; | 
|---|
| 329 | my $config_aux_dir_set_in_configure_in = 0; | 
|---|
| 330 |  | 
|---|
| 331 | # Whether AM_GNU_GETTEXT has been seen in configure.ac. | 
|---|
| 332 | my $seen_gettext = 0; | 
|---|
| 333 | # Whether AM_GNU_GETTEXT([external]) is used. | 
|---|
| 334 | my $seen_gettext_external = 0; | 
|---|
| 335 | # Where AM_GNU_GETTEXT appears. | 
|---|
| 336 | my $ac_gettext_location; | 
|---|
| 337 |  | 
|---|
| 338 | # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). | 
|---|
| 339 | my $seen_canonical = 0; | 
|---|
| 340 | my $canonical_location; | 
|---|
| 341 |  | 
|---|
| 342 | # Where AM_MAINTAINER_MODE appears. | 
|---|
| 343 | my $seen_maint_mode; | 
|---|
| 344 |  | 
|---|
| 345 | # Actual version we've seen. | 
|---|
| 346 | my $package_version = ''; | 
|---|
| 347 |  | 
|---|
| 348 | # Where version is defined. | 
|---|
| 349 | my $package_version_location; | 
|---|
| 350 |  | 
|---|
| 351 | # TRUE if we've seen AC_ENABLE_MULTILIB. | 
|---|
| 352 | my $seen_multilib = 0; | 
|---|
| 353 |  | 
|---|
| 354 | # TRUE if we've seen AM_PROG_CC_C_O | 
|---|
| 355 | my $seen_cc_c_o = 0; | 
|---|
| 356 |  | 
|---|
| 357 | # Where AM_INIT_AUTOMAKE is called; | 
|---|
| 358 | my $seen_init_automake = 0; | 
|---|
| 359 |  | 
|---|
| 360 | # TRUE if we've seen AM_AUTOMAKE_VERSION. | 
|---|
| 361 | my $seen_automake_version = 0; | 
|---|
| 362 |  | 
|---|
| 363 | # Hash table of discovered configure substitutions.  Keys are names, | 
|---|
| 364 | # values are `FILE:LINE' strings which are used by error message | 
|---|
| 365 | # generation. | 
|---|
| 366 | my %configure_vars = (); | 
|---|
| 367 |  | 
|---|
| 368 | # Files included by $configure_ac. | 
|---|
| 369 | my @configure_deps = (); | 
|---|
| 370 |  | 
|---|
| 371 | # Greatest timestamp of configure's dependencies. | 
|---|
| 372 | my $configure_deps_greatest_timestamp = 0; | 
|---|
| 373 |  | 
|---|
| 374 | # Hash table of AM_CONDITIONAL variables seen in configure. | 
|---|
| 375 | my %configure_cond = (); | 
|---|
| 376 |  | 
|---|
| 377 | # This maps extensions onto language names. | 
|---|
| 378 | my %extension_map = (); | 
|---|
| 379 |  | 
|---|
| 380 | # List of the DIST_COMMON files we discovered while reading | 
|---|
| 381 | # configure.in | 
|---|
| 382 | my $configure_dist_common = ''; | 
|---|
| 383 |  | 
|---|
| 384 | # This maps languages names onto objects. | 
|---|
| 385 | my %languages = (); | 
|---|
| 386 |  | 
|---|
| 387 | # List of targets we must always output. | 
|---|
| 388 | # FIXME: Complete, and remove falsely required targets. | 
|---|
| 389 | my %required_targets = | 
|---|
| 390 | ( | 
|---|
| 391 | 'all'          => 1, | 
|---|
| 392 | 'dvi'          => 1, | 
|---|
| 393 | 'pdf'          => 1, | 
|---|
| 394 | 'ps'           => 1, | 
|---|
| 395 | 'info'         => 1, | 
|---|
| 396 | 'install-info' => 1, | 
|---|
| 397 | 'install'      => 1, | 
|---|
| 398 | 'install-data' => 1, | 
|---|
| 399 | 'install-exec' => 1, | 
|---|
| 400 | 'uninstall'    => 1, | 
|---|
| 401 |  | 
|---|
| 402 | # FIXME: Not required, temporary hacks. | 
|---|
| 403 | # Well, actually they are sort of required: the -recursive | 
|---|
| 404 | # targets will run them anyway... | 
|---|
| 405 | 'dvi-am'          => 1, | 
|---|
| 406 | 'pdf-am'          => 1, | 
|---|
| 407 | 'ps-am'           => 1, | 
|---|
| 408 | 'info-am'         => 1, | 
|---|
| 409 | 'install-data-am' => 1, | 
|---|
| 410 | 'install-exec-am' => 1, | 
|---|
| 411 | 'installcheck-am' => 1, | 
|---|
| 412 | 'uninstall-am' => 1, | 
|---|
| 413 |  | 
|---|
| 414 | 'install-man' => 1, | 
|---|
| 415 | ); | 
|---|
| 416 |  | 
|---|
| 417 | # This is set to 1 when Automake needs to be run again. | 
|---|
| 418 | # (For instance, this happens when an auxiliary file such as | 
|---|
| 419 | # depcomp is added after the toplevel Makefile.in -- which | 
|---|
| 420 | # should distribute depcomp -- has been generated.) | 
|---|
| 421 | my $automake_needs_to_reprocess_all_files = 0; | 
|---|
| 422 |  | 
|---|
| 423 | # If a file name appears as a key in this hash, then it has already | 
|---|
| 424 | # been checked for.  This variable is local to the "require file" | 
|---|
| 425 | # functions. | 
|---|
| 426 | my %require_file_found = (); | 
|---|
| 427 |  | 
|---|
| 428 | # The name of the Makefile currently being processed. | 
|---|
| 429 | my $am_file = 'BUG'; | 
|---|
| 430 |  | 
|---|
| 431 |  | 
|---|
| 432 |  | 
|---|
| 433 | ################################################################ | 
|---|
| 434 |  | 
|---|
| 435 | ## ------------------------------------------ ## | 
|---|
| 436 | ## Variables reset by &initialize_per_input.  ## | 
|---|
| 437 | ## ------------------------------------------ ## | 
|---|
| 438 |  | 
|---|
| 439 | # Basename and relative dir of the input file. | 
|---|
| 440 | my $am_file_name; | 
|---|
| 441 | my $am_relative_dir; | 
|---|
| 442 |  | 
|---|
| 443 | # Same but wrt Makefile.in. | 
|---|
| 444 | my $in_file_name; | 
|---|
| 445 | my $relative_dir; | 
|---|
| 446 |  | 
|---|
| 447 | # Greatest timestamp of the output's dependencies (excluding | 
|---|
| 448 | # configure's dependencies). | 
|---|
| 449 | my $output_deps_greatest_timestamp; | 
|---|
| 450 |  | 
|---|
| 451 | # These two variables are used when generating each Makefile.in. | 
|---|
| 452 | # They hold the Makefile.in until it is ready to be printed. | 
|---|
| 453 | my $output_rules; | 
|---|
| 454 | my $output_vars; | 
|---|
| 455 | my $output_trailer; | 
|---|
| 456 | my $output_all; | 
|---|
| 457 | my $output_header; | 
|---|
| 458 |  | 
|---|
| 459 | # This is the conditional stack, updated on if/else/endif, and | 
|---|
| 460 | # used to build Condition objects. | 
|---|
| 461 | my @cond_stack; | 
|---|
| 462 |  | 
|---|
| 463 | # This holds the set of included files. | 
|---|
| 464 | my @include_stack; | 
|---|
| 465 |  | 
|---|
| 466 | # This holds a list of directories which we must create at `dist' | 
|---|
| 467 | # time.  This is used in some strange scenarios involving weird | 
|---|
| 468 | # AC_OUTPUT commands. | 
|---|
| 469 | my %dist_dirs; | 
|---|
| 470 |  | 
|---|
| 471 | # List of dependencies for the obvious targets. | 
|---|
| 472 | my @all; | 
|---|
| 473 | my @check; | 
|---|
| 474 | my @check_tests; | 
|---|
| 475 |  | 
|---|
| 476 | # Keys in this hash table are files to delete.  The associated | 
|---|
| 477 | # value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.) | 
|---|
| 478 | my %clean_files; | 
|---|
| 479 |  | 
|---|
| 480 | # Keys in this hash table are object files or other files in | 
|---|
| 481 | # subdirectories which need to be removed.  This only holds files | 
|---|
| 482 | # which are created by compilations.  The value in the hash indicates | 
|---|
| 483 | # when the file should be removed. | 
|---|
| 484 | my %compile_clean_files; | 
|---|
| 485 |  | 
|---|
| 486 | # Keys in this hash table are directories where we expect to build a | 
|---|
| 487 | # libtool object.  We use this information to decide what directories | 
|---|
| 488 | # to delete. | 
|---|
| 489 | my %libtool_clean_directories; | 
|---|
| 490 |  | 
|---|
| 491 | # Value of `$(SOURCES)', used by tags.am. | 
|---|
| 492 | my @sources; | 
|---|
| 493 | # Sources which go in the distribution. | 
|---|
| 494 | my @dist_sources; | 
|---|
| 495 |  | 
|---|
| 496 | # This hash maps object file names onto their corresponding source | 
|---|
| 497 | # file names.  This is used to ensure that each object is created | 
|---|
| 498 | # by a single source file. | 
|---|
| 499 | my %object_map; | 
|---|
| 500 |  | 
|---|
| 501 | # This hash maps object file names onto an integer value representing | 
|---|
| 502 | # whether this object has been built via ordinary compilation or | 
|---|
| 503 | # libtool compilation (the COMPILE_* constants). | 
|---|
| 504 | my %object_compilation_map; | 
|---|
| 505 |  | 
|---|
| 506 |  | 
|---|
| 507 | # This keeps track of the directories for which we've already | 
|---|
| 508 | # created dirstamp code. | 
|---|
| 509 | my %directory_map; | 
|---|
| 510 |  | 
|---|
| 511 | # All .P files. | 
|---|
| 512 | my %dep_files; | 
|---|
| 513 |  | 
|---|
| 514 | # This is a list of all targets to run during "make dist". | 
|---|
| 515 | my @dist_targets; | 
|---|
| 516 |  | 
|---|
| 517 | # Keys in this hash are the basenames of files which must depend on | 
|---|
| 518 | # ansi2knr.  Values are either the empty string, or the directory in | 
|---|
| 519 | # which the ANSI source file appears; the directory must have a | 
|---|
| 520 | # trailing `/'. | 
|---|
| 521 | my %de_ansi_files; | 
|---|
| 522 |  | 
|---|
| 523 | # This is the name of the redirect `all' target to use. | 
|---|
| 524 | my $all_target; | 
|---|
| 525 |  | 
|---|
| 526 | # This keeps track of which extensions we've seen (that we care | 
|---|
| 527 | # about). | 
|---|
| 528 | my %extension_seen; | 
|---|
| 529 |  | 
|---|
| 530 | # This is random scratch space for the language finish functions. | 
|---|
| 531 | # Don't randomly overwrite it; examine other uses of keys first. | 
|---|
| 532 | my %language_scratch; | 
|---|
| 533 |  | 
|---|
| 534 | # We keep track of which objects need special (per-executable) | 
|---|
| 535 | # handling on a per-language basis. | 
|---|
| 536 | my %lang_specific_files; | 
|---|
| 537 |  | 
|---|
| 538 | # This is set when `handle_dist' has finished.  Once this happens, | 
|---|
| 539 | # we should no longer push on dist_common. | 
|---|
| 540 | my $handle_dist_run; | 
|---|
| 541 |  | 
|---|
| 542 | # Used to store a set of linkers needed to generate the sources currently | 
|---|
| 543 | # under consideration. | 
|---|
| 544 | my %linkers_used; | 
|---|
| 545 |  | 
|---|
| 546 | # True if we need `LINK' defined.  This is a hack. | 
|---|
| 547 | my $need_link; | 
|---|
| 548 |  | 
|---|
| 549 | # Was get_object_extension run? | 
|---|
| 550 | # FIXME: This is a hack. a better switch should be found. | 
|---|
| 551 | my $get_object_extension_was_run; | 
|---|
| 552 |  | 
|---|
| 553 | ################################################################ | 
|---|
| 554 |  | 
|---|
| 555 | # var_SUFFIXES_trigger ($TYPE, $VALUE) | 
|---|
| 556 | # ------------------------------------ | 
|---|
| 557 | # This is called by Automake::Variable::define() when SUFFIXES | 
|---|
| 558 | # is defined ($TYPE eq '') or appended ($TYPE eq '+'). | 
|---|
| 559 | # The work here needs to be performed as a side-effect of the | 
|---|
| 560 | # macro_define() call because SUFFIXES definitions impact | 
|---|
| 561 | # on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing | 
|---|
| 562 | # the input am file. | 
|---|
| 563 | sub var_SUFFIXES_trigger ($$) | 
|---|
| 564 | { | 
|---|
| 565 | my ($type, $value) = @_; | 
|---|
| 566 | accept_extensions (split (' ', $value)); | 
|---|
| 567 | } | 
|---|
| 568 | Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger); | 
|---|
| 569 |  | 
|---|
| 570 | ################################################################ | 
|---|
| 571 |  | 
|---|
| 572 | ## --------------------------------- ## | 
|---|
| 573 | ## Forward subroutine declarations.  ## | 
|---|
| 574 | ## --------------------------------- ## | 
|---|
| 575 | sub register_language (%); | 
|---|
| 576 | sub file_contents_internal ($$$%); | 
|---|
| 577 | sub define_files_variable ($\@$$); | 
|---|
| 578 |  | 
|---|
| 579 |  | 
|---|
| 580 | # &initialize_per_input () | 
|---|
| 581 | # ------------------------ | 
|---|
| 582 | # (Re)-Initialize per-Makefile.am variables. | 
|---|
| 583 | sub initialize_per_input () | 
|---|
| 584 | { | 
|---|
| 585 | reset_local_duplicates (); | 
|---|
| 586 |  | 
|---|
| 587 | $am_file_name = ''; | 
|---|
| 588 | $am_relative_dir = ''; | 
|---|
| 589 |  | 
|---|
| 590 | $in_file_name = ''; | 
|---|
| 591 | $relative_dir = ''; | 
|---|
| 592 |  | 
|---|
| 593 | $output_deps_greatest_timestamp = 0; | 
|---|
| 594 |  | 
|---|
| 595 | $output_rules = ''; | 
|---|
| 596 | $output_vars = ''; | 
|---|
| 597 | $output_trailer = ''; | 
|---|
| 598 | $output_all = ''; | 
|---|
| 599 | $output_header = ''; | 
|---|
| 600 |  | 
|---|
| 601 | Automake::Options::reset; | 
|---|
| 602 | Automake::Variable::reset; | 
|---|
| 603 | Automake::Rule::reset; | 
|---|
| 604 |  | 
|---|
| 605 | @cond_stack = (); | 
|---|
| 606 |  | 
|---|
| 607 | @include_stack = (); | 
|---|
| 608 |  | 
|---|
| 609 | %dist_dirs = (); | 
|---|
| 610 |  | 
|---|
| 611 | @all = (); | 
|---|
| 612 | @check = (); | 
|---|
| 613 | @check_tests = (); | 
|---|
| 614 |  | 
|---|
| 615 | %clean_files = (); | 
|---|
| 616 |  | 
|---|
| 617 | @sources = (); | 
|---|
| 618 | @dist_sources = (); | 
|---|
| 619 |  | 
|---|
| 620 | %object_map = (); | 
|---|
| 621 | %object_compilation_map = (); | 
|---|
| 622 |  | 
|---|
| 623 | %directory_map = (); | 
|---|
| 624 |  | 
|---|
| 625 | %dep_files = (); | 
|---|
| 626 |  | 
|---|
| 627 | @dist_targets = (); | 
|---|
| 628 |  | 
|---|
| 629 | %de_ansi_files = (); | 
|---|
| 630 |  | 
|---|
| 631 | $all_target = ''; | 
|---|
| 632 |  | 
|---|
| 633 | %extension_seen = (); | 
|---|
| 634 |  | 
|---|
| 635 | %language_scratch = (); | 
|---|
| 636 |  | 
|---|
| 637 | %lang_specific_files = (); | 
|---|
| 638 |  | 
|---|
| 639 | $handle_dist_run = 0; | 
|---|
| 640 |  | 
|---|
| 641 | $need_link = 0; | 
|---|
| 642 |  | 
|---|
| 643 | $get_object_extension_was_run = 0; | 
|---|
| 644 |  | 
|---|
| 645 | %compile_clean_files = (); | 
|---|
| 646 |  | 
|---|
| 647 | # We always include `.'.  This isn't strictly correct. | 
|---|
| 648 | %libtool_clean_directories = ('.' => 1); | 
|---|
| 649 | } | 
|---|
| 650 |  | 
|---|
| 651 |  | 
|---|
| 652 | ################################################################ | 
|---|
| 653 |  | 
|---|
| 654 | # Initialize our list of languages that are internally supported. | 
|---|
| 655 |  | 
|---|
| 656 | # C. | 
|---|
| 657 | register_language ('name' => 'c', | 
|---|
| 658 | 'Name' => 'C', | 
|---|
| 659 | 'config_vars' => ['CC'], | 
|---|
| 660 | 'ansi' => 1, | 
|---|
| 661 | 'autodep' => '', | 
|---|
| 662 | 'flags' => ['CFLAGS', 'CPPFLAGS'], | 
|---|
| 663 | 'compiler' => 'COMPILE', | 
|---|
| 664 | 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', | 
|---|
| 665 | 'lder' => 'CCLD', | 
|---|
| 666 | 'ld' => '$(CC)', | 
|---|
| 667 | 'linker' => 'LINK', | 
|---|
| 668 | 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 669 | 'compile_flag' => '-c', | 
|---|
| 670 | 'extensions' => ['.c'], | 
|---|
| 671 | '_finish' => \&lang_c_finish); | 
|---|
| 672 |  | 
|---|
| 673 | # C++. | 
|---|
| 674 | register_language ('name' => 'cxx', | 
|---|
| 675 | 'Name' => 'C++', | 
|---|
| 676 | 'config_vars' => ['CXX'], | 
|---|
| 677 | 'linker' => 'CXXLINK', | 
|---|
| 678 | 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 679 | 'autodep' => 'CXX', | 
|---|
| 680 | 'flags' => ['CXXFLAGS', 'CPPFLAGS'], | 
|---|
| 681 | 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)', | 
|---|
| 682 | 'compiler' => 'CXXCOMPILE', | 
|---|
| 683 | 'compile_flag' => '-c', | 
|---|
| 684 | 'output_flag' => '-o', | 
|---|
| 685 | 'lder' => 'CXXLD', | 
|---|
| 686 | 'ld' => '$(CXX)', | 
|---|
| 687 | 'pure' => 1, | 
|---|
| 688 | 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']); | 
|---|
| 689 |  | 
|---|
| 690 | # Objective C. | 
|---|
| 691 | register_language ('name' => 'objc', | 
|---|
| 692 | 'Name' => 'Objective C', | 
|---|
| 693 | 'config_vars' => ['OBJC'], | 
|---|
| 694 | 'linker' => 'OBJCLINK',, | 
|---|
| 695 | 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 696 | 'autodep' => 'OBJC', | 
|---|
| 697 | 'flags' => ['OBJCFLAGS', 'CPPFLAGS'], | 
|---|
| 698 | 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)', | 
|---|
| 699 | 'compiler' => 'OBJCCOMPILE', | 
|---|
| 700 | 'compile_flag' => '-c', | 
|---|
| 701 | 'output_flag' => '-o', | 
|---|
| 702 | 'lder' => 'OBJCLD', | 
|---|
| 703 | 'ld' => '$(OBJC)', | 
|---|
| 704 | 'pure' => 1, | 
|---|
| 705 | 'extensions' => ['.m']); | 
|---|
| 706 |  | 
|---|
| 707 | # Headers. | 
|---|
| 708 | register_language ('name' => 'header', | 
|---|
| 709 | 'Name' => 'Header', | 
|---|
| 710 | 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh', | 
|---|
| 711 | '.hpp', '.inc'], | 
|---|
| 712 | # No output. | 
|---|
| 713 | 'output_extensions' => sub { return () }, | 
|---|
| 714 | # Nothing to do. | 
|---|
| 715 | '_finish' => sub { }); | 
|---|
| 716 |  | 
|---|
| 717 | # Yacc (C & C++). | 
|---|
| 718 | register_language ('name' => 'yacc', | 
|---|
| 719 | 'Name' => 'Yacc', | 
|---|
| 720 | 'config_vars' => ['YACC'], | 
|---|
| 721 | 'flags' => ['YFLAGS'], | 
|---|
| 722 | 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)', | 
|---|
| 723 | 'compiler' => 'YACCCOMPILE', | 
|---|
| 724 | 'extensions' => ['.y'], | 
|---|
| 725 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/; | 
|---|
| 726 | return ($ext,) }, | 
|---|
| 727 | 'rule_file' => 'yacc', | 
|---|
| 728 | '_finish' => \&lang_yacc_finish, | 
|---|
| 729 | '_target_hook' => \&lang_yacc_target_hook); | 
|---|
| 730 | register_language ('name' => 'yaccxx', | 
|---|
| 731 | 'Name' => 'Yacc (C++)', | 
|---|
| 732 | 'config_vars' => ['YACC'], | 
|---|
| 733 | 'rule_file' => 'yacc', | 
|---|
| 734 | 'flags' => ['YFLAGS'], | 
|---|
| 735 | 'compiler' => 'YACCCOMPILE', | 
|---|
| 736 | 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)', | 
|---|
| 737 | 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'], | 
|---|
| 738 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/; | 
|---|
| 739 | return ($ext,) }, | 
|---|
| 740 | '_finish' => \&lang_yacc_finish, | 
|---|
| 741 | '_target_hook' => \&lang_yacc_target_hook); | 
|---|
| 742 |  | 
|---|
| 743 | # Lex (C & C++). | 
|---|
| 744 | register_language ('name' => 'lex', | 
|---|
| 745 | 'Name' => 'Lex', | 
|---|
| 746 | 'config_vars' => ['LEX'], | 
|---|
| 747 | 'rule_file' => 'lex', | 
|---|
| 748 | 'flags' => ['LFLAGS'], | 
|---|
| 749 | 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)', | 
|---|
| 750 | 'compiler' => 'LEXCOMPILE', | 
|---|
| 751 | 'extensions' => ['.l'], | 
|---|
| 752 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/; | 
|---|
| 753 | return ($ext,) }, | 
|---|
| 754 | '_finish' => \&lang_lex_finish, | 
|---|
| 755 | '_target_hook' => \&lang_lex_target_hook); | 
|---|
| 756 | register_language ('name' => 'lexxx', | 
|---|
| 757 | 'Name' => 'Lex (C++)', | 
|---|
| 758 | 'config_vars' => ['LEX'], | 
|---|
| 759 | 'rule_file' => 'lex', | 
|---|
| 760 | 'flags' => ['LFLAGS'], | 
|---|
| 761 | 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)', | 
|---|
| 762 | 'compiler' => 'LEXCOMPILE', | 
|---|
| 763 | 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'], | 
|---|
| 764 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/; | 
|---|
| 765 | return ($ext,) }, | 
|---|
| 766 | '_finish' => \&lang_lex_finish, | 
|---|
| 767 | '_target_hook' => \&lang_lex_target_hook); | 
|---|
| 768 |  | 
|---|
| 769 | # Assembler. | 
|---|
| 770 | register_language ('name' => 'asm', | 
|---|
| 771 | 'Name' => 'Assembler', | 
|---|
| 772 | 'config_vars' => ['CCAS', 'CCASFLAGS'], | 
|---|
| 773 |  | 
|---|
| 774 | 'flags' => ['CCASFLAGS'], | 
|---|
| 775 | # Users can set AM_ASFLAGS to includes DEFS, INCLUDES, | 
|---|
| 776 | # or anything else required.  They can also set AS. | 
|---|
| 777 | 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)', | 
|---|
| 778 | 'compiler' => 'CCASCOMPILE', | 
|---|
| 779 | 'compile_flag' => '-c', | 
|---|
| 780 | 'extensions' => ['.s', '.S'], | 
|---|
| 781 |  | 
|---|
| 782 | # With assembly we still use the C linker. | 
|---|
| 783 | '_finish' => \&lang_c_finish); | 
|---|
| 784 |  | 
|---|
| 785 | # Fortran 77 | 
|---|
| 786 | register_language ('name' => 'f77', | 
|---|
| 787 | 'Name' => 'Fortran 77', | 
|---|
| 788 | 'linker' => 'F77LINK', | 
|---|
| 789 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 790 | 'flags' => ['FFLAGS'], | 
|---|
| 791 | 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)', | 
|---|
| 792 | 'compiler' => 'F77COMPILE', | 
|---|
| 793 | 'compile_flag' => '-c', | 
|---|
| 794 | 'output_flag' => '-o', | 
|---|
| 795 | 'lder' => 'F77LD', | 
|---|
| 796 | 'ld' => '$(F77)', | 
|---|
| 797 | 'pure' => 1, | 
|---|
| 798 | 'extensions' => ['.f', '.for', '.f90']); | 
|---|
| 799 |  | 
|---|
| 800 | # Preprocessed Fortran 77 | 
|---|
| 801 | # | 
|---|
| 802 | # The current support for preprocessing Fortran 77 just involves | 
|---|
| 803 | # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) | 
|---|
| 804 | # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since | 
|---|
| 805 | # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51 | 
|---|
| 806 | # for `make' Version 3.76 Beta' (specifically, from info file | 
|---|
| 807 | # `(make)Catalogue of Rules'). | 
|---|
| 808 | # | 
|---|
| 809 | # A better approach would be to write an Autoconf test | 
|---|
| 810 | # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all | 
|---|
| 811 | # Fortran 77 compilers know how to do preprocessing.  The Autoconf | 
|---|
| 812 | # macro AC_PROG_FPP should test the Fortran 77 compiler first for | 
|---|
| 813 | # preprocessing capabilities, and then fall back on cpp (if cpp were | 
|---|
| 814 | # available). | 
|---|
| 815 | register_language ('name' => 'ppf77', | 
|---|
| 816 | 'Name' => 'Preprocessed Fortran 77', | 
|---|
| 817 | 'config_vars' => ['F77'], | 
|---|
| 818 | 'linker' => 'F77LINK', | 
|---|
| 819 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 820 | 'lder' => 'F77LD', | 
|---|
| 821 | 'ld' => '$(F77)', | 
|---|
| 822 | 'flags' => ['FFLAGS', 'CPPFLAGS'], | 
|---|
| 823 | 'compiler' => 'PPF77COMPILE', | 
|---|
| 824 | 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)', | 
|---|
| 825 | 'compile_flag' => '-c', | 
|---|
| 826 | 'output_flag' => '-o', | 
|---|
| 827 | 'pure' => 1, | 
|---|
| 828 | 'extensions' => ['.F']); | 
|---|
| 829 |  | 
|---|
| 830 | # Ratfor. | 
|---|
| 831 | register_language ('name' => 'ratfor', | 
|---|
| 832 | 'Name' => 'Ratfor', | 
|---|
| 833 | 'config_vars' => ['F77'], | 
|---|
| 834 | 'linker' => 'F77LINK', | 
|---|
| 835 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 836 | 'lder' => 'F77LD', | 
|---|
| 837 | 'ld' => '$(F77)', | 
|---|
| 838 | 'flags' => ['RFLAGS', 'FFLAGS'], | 
|---|
| 839 | # FIXME also FFLAGS. | 
|---|
| 840 | 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)', | 
|---|
| 841 | 'compiler' => 'RCOMPILE', | 
|---|
| 842 | 'compile_flag' => '-c', | 
|---|
| 843 | 'output_flag' => '-o', | 
|---|
| 844 | 'pure' => 1, | 
|---|
| 845 | 'extensions' => ['.r']); | 
|---|
| 846 |  | 
|---|
| 847 | # Java via gcj. | 
|---|
| 848 | register_language ('name' => 'java', | 
|---|
| 849 | 'Name' => 'Java', | 
|---|
| 850 | 'config_vars' => ['GCJ'], | 
|---|
| 851 | 'linker' => 'GCJLINK', | 
|---|
| 852 | 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | 
|---|
| 853 | 'autodep' => 'GCJ', | 
|---|
| 854 | 'flags' => ['GCJFLAGS'], | 
|---|
| 855 | 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)', | 
|---|
| 856 | 'compiler' => 'GCJCOMPILE', | 
|---|
| 857 | 'compile_flag' => '-c', | 
|---|
| 858 | 'output_flag' => '-o', | 
|---|
| 859 | 'lder' => 'GCJLD', | 
|---|
| 860 | 'ld' => '$(GCJ)', | 
|---|
| 861 | 'pure' => 1, | 
|---|
| 862 | 'extensions' => ['.java', '.class', '.zip', '.jar']); | 
|---|
| 863 |  | 
|---|
| 864 | ################################################################ | 
|---|
| 865 |  | 
|---|
| 866 | # Error reporting functions. | 
|---|
| 867 |  | 
|---|
| 868 | # err_am ($MESSAGE, [%OPTIONS]) | 
|---|
| 869 | # ----------------------------- | 
|---|
| 870 | # Uncategorized errors about the current Makefile.am. | 
|---|
| 871 | sub err_am ($;%) | 
|---|
| 872 | { | 
|---|
| 873 | msg_am ('error', @_); | 
|---|
| 874 | } | 
|---|
| 875 |  | 
|---|
| 876 | # err_ac ($MESSAGE, [%OPTIONS]) | 
|---|
| 877 | # ----------------------------- | 
|---|
| 878 | # Uncategorized errors about configure.ac. | 
|---|
| 879 | sub err_ac ($;%) | 
|---|
| 880 | { | 
|---|
| 881 | msg_ac ('error', @_); | 
|---|
| 882 | } | 
|---|
| 883 |  | 
|---|
| 884 | # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS]) | 
|---|
| 885 | # --------------------------------------- | 
|---|
| 886 | # Messages about about the current Makefile.am. | 
|---|
| 887 | sub msg_am ($$;%) | 
|---|
| 888 | { | 
|---|
| 889 | my ($channel, $msg, %opts) = @_; | 
|---|
| 890 | msg $channel, "${am_file}.am", $msg, %opts; | 
|---|
| 891 | } | 
|---|
| 892 |  | 
|---|
| 893 | # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS]) | 
|---|
| 894 | # --------------------------------------- | 
|---|
| 895 | # Messages about about configure.ac. | 
|---|
| 896 | sub msg_ac ($$;%) | 
|---|
| 897 | { | 
|---|
| 898 | my ($channel, $msg, %opts) = @_; | 
|---|
| 899 | msg $channel, $configure_ac, $msg, %opts; | 
|---|
| 900 | } | 
|---|
| 901 |  | 
|---|
| 902 | ################################################################ | 
|---|
| 903 |  | 
|---|
| 904 | # subst ($TEXT) | 
|---|
| 905 | # ------------- | 
|---|
| 906 | # Return a configure-style substitution using the indicated text. | 
|---|
| 907 | # We do this to avoid having the substitutions directly in automake.in; | 
|---|
| 908 | # when we do that they are sometimes removed and this causes confusion | 
|---|
| 909 | # and bugs. | 
|---|
| 910 | sub subst ($) | 
|---|
| 911 | { | 
|---|
| 912 | my ($text) = @_; | 
|---|
| 913 | return '@' . $text . '@'; | 
|---|
| 914 | } | 
|---|
| 915 |  | 
|---|
| 916 | ################################################################ | 
|---|
| 917 |  | 
|---|
| 918 |  | 
|---|
| 919 | # $BACKPATH | 
|---|
| 920 | # &backname ($REL-DIR) | 
|---|
| 921 | # -------------------- | 
|---|
| 922 | # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'. | 
|---|
| 923 | # For instance `src/foo' => `../..'. | 
|---|
| 924 | # Works with non strictly increasing paths, i.e., `src/../lib' => `..'. | 
|---|
| 925 | sub backname ($) | 
|---|
| 926 | { | 
|---|
| 927 | my ($file) = @_; | 
|---|
| 928 | my @res; | 
|---|
| 929 | foreach (split (/\//, $file)) | 
|---|
| 930 | { | 
|---|
| 931 | next if $_ eq '.' || $_ eq ''; | 
|---|
| 932 | if ($_ eq '..') | 
|---|
| 933 | { | 
|---|
| 934 | pop @res; | 
|---|
| 935 | } | 
|---|
| 936 | else | 
|---|
| 937 | { | 
|---|
| 938 | push (@res, '..'); | 
|---|
| 939 | } | 
|---|
| 940 | } | 
|---|
| 941 | return join ('/', @res) || '.'; | 
|---|
| 942 | } | 
|---|
| 943 |  | 
|---|
| 944 | ################################################################ | 
|---|
| 945 |  | 
|---|
| 946 |  | 
|---|
| 947 | # Handle AUTOMAKE_OPTIONS variable.  Return 1 on error, 0 otherwise. | 
|---|
| 948 | sub handle_options | 
|---|
| 949 | { | 
|---|
| 950 | my $var = var ('AUTOMAKE_OPTIONS'); | 
|---|
| 951 | if ($var) | 
|---|
| 952 | { | 
|---|
| 953 | # FIXME: We should disallow conditional definitions of AUTOMAKE_OPTIONS. | 
|---|
| 954 | if (process_option_list ($var->rdef (TRUE)->location, | 
|---|
| 955 | $var->value_as_list_recursive (cond_filter => | 
|---|
| 956 | TRUE))) | 
|---|
| 957 | { | 
|---|
| 958 | return 1; | 
|---|
| 959 | } | 
|---|
| 960 | } | 
|---|
| 961 |  | 
|---|
| 962 | if ($strictness == GNITS) | 
|---|
| 963 | { | 
|---|
| 964 | set_option ('readme-alpha', INTERNAL); | 
|---|
| 965 | set_option ('std-options', INTERNAL); | 
|---|
| 966 | set_option ('check-news', INTERNAL); | 
|---|
| 967 | } | 
|---|
| 968 |  | 
|---|
| 969 | return 0; | 
|---|
| 970 | } | 
|---|
| 971 |  | 
|---|
| 972 | # shadow_unconditionally ($varname, $where) | 
|---|
| 973 | # ----------------------------------------- | 
|---|
| 974 | # Return a $(variable) that contains all possible values | 
|---|
| 975 | # $varname can take. | 
|---|
| 976 | # If the VAR wasn't defined conditionally, return $(VAR). | 
|---|
| 977 | # Otherwise we create a am__VAR_DIST variable which contains | 
|---|
| 978 | # all possible values, and return $(am__VAR_DIST). | 
|---|
| 979 | sub shadow_unconditionally ($$) | 
|---|
| 980 | { | 
|---|
| 981 | my ($varname, $where) = @_; | 
|---|
| 982 | my $var = var $varname; | 
|---|
| 983 | if ($var->has_conditional_contents) | 
|---|
| 984 | { | 
|---|
| 985 | $varname = "am__${varname}_DIST"; | 
|---|
| 986 | my @files = uniq ($var->value_as_list_recursive); | 
|---|
| 987 | define_pretty_variable ($varname, TRUE, $where, @files); | 
|---|
| 988 | } | 
|---|
| 989 | return "\$($varname)" | 
|---|
| 990 | } | 
|---|
| 991 |  | 
|---|
| 992 | # get_object_extension ($OUT) | 
|---|
| 993 | # --------------------------- | 
|---|
| 994 | # Return object extension.  Just once, put some code into the output. | 
|---|
| 995 | # OUT is the name of the output file | 
|---|
| 996 | sub get_object_extension | 
|---|
| 997 | { | 
|---|
| 998 | my ($out) = @_; | 
|---|
| 999 |  | 
|---|
| 1000 | # Maybe require libtool library object files. | 
|---|
| 1001 | my $extension = '.$(OBJEXT)'; | 
|---|
| 1002 | $extension = '.lo' if ($out =~ /\.la$/); | 
|---|
| 1003 |  | 
|---|
| 1004 | # Check for automatic de-ANSI-fication. | 
|---|
| 1005 | $extension = '$U' . $extension | 
|---|
| 1006 | if option 'ansi2knr'; | 
|---|
| 1007 |  | 
|---|
| 1008 | $get_object_extension_was_run = 1; | 
|---|
| 1009 |  | 
|---|
| 1010 | return $extension; | 
|---|
| 1011 | } | 
|---|
| 1012 |  | 
|---|
| 1013 |  | 
|---|
| 1014 | # Call finish function for each language that was used. | 
|---|
| 1015 | sub handle_languages | 
|---|
| 1016 | { | 
|---|
| 1017 | if (! option 'no-dependencies') | 
|---|
| 1018 | { | 
|---|
| 1019 | # Include auto-dep code.  Don't include it if DEP_FILES would | 
|---|
| 1020 | # be empty. | 
|---|
| 1021 | if (&saw_sources_p (0) && keys %dep_files) | 
|---|
| 1022 | { | 
|---|
| 1023 | # Set location of depcomp. | 
|---|
| 1024 | &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp", | 
|---|
| 1025 | INTERNAL); | 
|---|
| 1026 | &define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL); | 
|---|
| 1027 |  | 
|---|
| 1028 | require_conf_file ("$am_file.am", FOREIGN, 'depcomp'); | 
|---|
| 1029 |  | 
|---|
| 1030 | my @deplist = sort keys %dep_files; | 
|---|
| 1031 |  | 
|---|
| 1032 | # We define this as a conditional variable because BSD | 
|---|
| 1033 | # make can't handle backslashes for continuing comments on | 
|---|
| 1034 | # the following line. | 
|---|
| 1035 | define_pretty_variable ('DEP_FILES', | 
|---|
| 1036 | new Automake::Condition ('AMDEP_TRUE'), | 
|---|
| 1037 | INTERNAL, @deplist); | 
|---|
| 1038 |  | 
|---|
| 1039 | # Generate each `include' individually.  Irix 6 make will | 
|---|
| 1040 | # not properly include several files resulting from a | 
|---|
| 1041 | # variable expansion; generating many separate includes | 
|---|
| 1042 | # seems safest. | 
|---|
| 1043 | $output_rules .= "\n"; | 
|---|
| 1044 | foreach my $iter (@deplist) | 
|---|
| 1045 | { | 
|---|
| 1046 | $output_rules .= (subst ('AMDEP_TRUE') | 
|---|
| 1047 | . subst ('am__include') | 
|---|
| 1048 | . ' ' | 
|---|
| 1049 | . subst ('am__quote') | 
|---|
| 1050 | . $iter | 
|---|
| 1051 | . subst ('am__quote') | 
|---|
| 1052 | . "\n"); | 
|---|
| 1053 | } | 
|---|
| 1054 |  | 
|---|
| 1055 | # Compute the set of directories to remove in distclean-depend. | 
|---|
| 1056 | my @depdirs = uniq (map { dirname ($_) } @deplist); | 
|---|
| 1057 | $output_rules .= &file_contents ('depend', | 
|---|
| 1058 | new Automake::Location, | 
|---|
| 1059 | DEPDIRS => "@depdirs"); | 
|---|
| 1060 | } | 
|---|
| 1061 | } | 
|---|
| 1062 | else | 
|---|
| 1063 | { | 
|---|
| 1064 | &define_variable ('depcomp', '', INTERNAL); | 
|---|
| 1065 | &define_variable ('am__depfiles_maybe', '', INTERNAL); | 
|---|
| 1066 | } | 
|---|
| 1067 |  | 
|---|
| 1068 | my %done; | 
|---|
| 1069 |  | 
|---|
| 1070 | # Is the c linker needed? | 
|---|
| 1071 | my $needs_c = 0; | 
|---|
| 1072 | foreach my $ext (sort keys %extension_seen) | 
|---|
| 1073 | { | 
|---|
| 1074 | next unless $extension_map{$ext}; | 
|---|
| 1075 |  | 
|---|
| 1076 | my $lang = $languages{$extension_map{$ext}}; | 
|---|
| 1077 |  | 
|---|
| 1078 | my $rule_file = $lang->rule_file || 'depend2'; | 
|---|
| 1079 |  | 
|---|
| 1080 | # Get information on $LANG. | 
|---|
| 1081 | my $pfx = $lang->autodep; | 
|---|
| 1082 | my $fpfx = ($pfx eq '') ? 'CC' : $pfx; | 
|---|
| 1083 |  | 
|---|
| 1084 | my ($AMDEP, $FASTDEP) = | 
|---|
| 1085 | (option 'no-dependencies' || $lang->autodep eq 'no') | 
|---|
| 1086 | ? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx"); | 
|---|
| 1087 |  | 
|---|
| 1088 | my %transform = ('EXT'     => $ext, | 
|---|
| 1089 | 'PFX'     => $pfx, | 
|---|
| 1090 | 'FPFX'    => $fpfx, | 
|---|
| 1091 | 'AMDEP'   => $AMDEP, | 
|---|
| 1092 | 'FASTDEP' => $FASTDEP, | 
|---|
| 1093 | '-c'      => $lang->compile_flag || '', | 
|---|
| 1094 | 'MORE-THAN-ONE' | 
|---|
| 1095 | => (count_files_for_language ($lang->name) > 1)); | 
|---|
| 1096 |  | 
|---|
| 1097 | # Generate the appropriate rules for this extension. | 
|---|
| 1098 | if (((! option 'no-dependencies') && $lang->autodep ne 'no') | 
|---|
| 1099 | || defined $lang->compile) | 
|---|
| 1100 | { | 
|---|
| 1101 | # Some C compilers don't support -c -o.  Use it only if really | 
|---|
| 1102 | # needed. | 
|---|
| 1103 | my $output_flag = $lang->output_flag || ''; | 
|---|
| 1104 | $output_flag = '-o' | 
|---|
| 1105 | if (! $output_flag | 
|---|
| 1106 | && $lang->name eq 'c' | 
|---|
| 1107 | && option 'subdir-objects'); | 
|---|
| 1108 |  | 
|---|
| 1109 | # Compute a possible derived extension. | 
|---|
| 1110 | # This is not used by depend2.am. | 
|---|
| 1111 | my $der_ext = (&{$lang->output_extensions} ($ext))[0]; | 
|---|
| 1112 |  | 
|---|
| 1113 | $output_rules .= | 
|---|
| 1114 | file_contents ($rule_file, | 
|---|
| 1115 | new Automake::Location, | 
|---|
| 1116 | %transform, | 
|---|
| 1117 | GENERIC   => 1, | 
|---|
| 1118 |  | 
|---|
| 1119 | 'DERIVED-EXT' => $der_ext, | 
|---|
| 1120 |  | 
|---|
| 1121 | # In this situation we know that the | 
|---|
| 1122 | # object is in this directory, so | 
|---|
| 1123 | # $(DEPDIR) is the correct location for | 
|---|
| 1124 | # dependencies. | 
|---|
| 1125 | DEPBASE   => '$(DEPDIR)/$*', | 
|---|
| 1126 | BASE      => '$*', | 
|---|
| 1127 | SOURCE    => '$<', | 
|---|
| 1128 | OBJ       => '$@', | 
|---|
| 1129 | OBJOBJ    => '$@', | 
|---|
| 1130 | LTOBJ     => '$@', | 
|---|
| 1131 |  | 
|---|
| 1132 | COMPILE   => '$(' . $lang->compiler . ')', | 
|---|
| 1133 | LTCOMPILE => '$(LT' . $lang->compiler . ')', | 
|---|
| 1134 | -o        => $output_flag); | 
|---|
| 1135 | } | 
|---|
| 1136 |  | 
|---|
| 1137 | # Now include code for each specially handled object with this | 
|---|
| 1138 | # language. | 
|---|
| 1139 | my %seen_files = (); | 
|---|
| 1140 | foreach my $file (@{$lang_specific_files{$lang->name}}) | 
|---|
| 1141 | { | 
|---|
| 1142 | my ($derived, $source, $obj, $myext) = split (' ', $file); | 
|---|
| 1143 |  | 
|---|
| 1144 | # We might see a given object twice, for instance if it is | 
|---|
| 1145 | # used under different conditions. | 
|---|
| 1146 | next if defined $seen_files{$obj}; | 
|---|
| 1147 | $seen_files{$obj} = 1; | 
|---|
| 1148 |  | 
|---|
| 1149 | prog_error ("found " . $lang->name . | 
|---|
| 1150 | " in handle_languages, but compiler not defined") | 
|---|
| 1151 | unless defined $lang->compile; | 
|---|
| 1152 |  | 
|---|
| 1153 | my $obj_compile = $lang->compile; | 
|---|
| 1154 |  | 
|---|
| 1155 | # Rewrite each occurrence of `AM_$flag' in the compile | 
|---|
| 1156 | # rule into `${derived}_$flag' if it exists. | 
|---|
| 1157 | for my $flag (@{$lang->flags}) | 
|---|
| 1158 | { | 
|---|
| 1159 | my $val = "${derived}_$flag"; | 
|---|
| 1160 | $obj_compile =~ s/\(AM_$flag\)/\($val\)/ | 
|---|
| 1161 | if set_seen ($val); | 
|---|
| 1162 | } | 
|---|
| 1163 |  | 
|---|
| 1164 | my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile; | 
|---|
| 1165 |  | 
|---|
| 1166 | # We _need_ `-o' for per object rules. | 
|---|
| 1167 | my $output_flag = $lang->output_flag || '-o'; | 
|---|
| 1168 |  | 
|---|
| 1169 | my $depbase = dirname ($obj); | 
|---|
| 1170 | $depbase = '' | 
|---|
| 1171 | if $depbase eq '.'; | 
|---|
| 1172 | $depbase .= '/' | 
|---|
| 1173 | unless $depbase eq ''; | 
|---|
| 1174 | $depbase .= '$(DEPDIR)/' . basename ($obj); | 
|---|
| 1175 |  | 
|---|
| 1176 | # Support for deansified files in subdirectories is ugly | 
|---|
| 1177 | # enough to deserve an explanation. | 
|---|
| 1178 | # | 
|---|
| 1179 | # A Note about normal ansi2knr processing first.  On | 
|---|
| 1180 | # | 
|---|
| 1181 | #   AUTOMAKE_OPTIONS = ansi2knr | 
|---|
| 1182 | #   bin_PROGRAMS = foo | 
|---|
| 1183 | #   foo_SOURCES = foo.c | 
|---|
| 1184 | # | 
|---|
| 1185 | # we generate rules similar to: | 
|---|
| 1186 | # | 
|---|
| 1187 | #   foo: foo$U.o; link ... | 
|---|
| 1188 | #   foo$U.o: foo$U.c; compile ... | 
|---|
| 1189 | #   foo_.c: foo.c; ansi2knr ... | 
|---|
| 1190 | # | 
|---|
| 1191 | # this is fairly compact, and will call ansi2knr depending | 
|---|
| 1192 | # on the value of $U (`' or `_'). | 
|---|
| 1193 | # | 
|---|
| 1194 | # It's harder with subdir sources. On | 
|---|
| 1195 | # | 
|---|
| 1196 | #   AUTOMAKE_OPTIONS = ansi2knr | 
|---|
| 1197 | #   bin_PROGRAMS = foo | 
|---|
| 1198 | #   foo_SOURCES = sub/foo.c | 
|---|
| 1199 | # | 
|---|
| 1200 | # we have to create foo_.c in the current directory. | 
|---|
| 1201 | # (Unless the user asks 'subdir-objects'.)  This is important | 
|---|
| 1202 | # in case the same file (`foo.c') is compiled from other | 
|---|
| 1203 | # directories with different cpp options: foo_.c would | 
|---|
| 1204 | # be preprocessed for only one set of options if it were | 
|---|
| 1205 | # put in the subdirectory. | 
|---|
| 1206 | # | 
|---|
| 1207 | # Because foo$U.o must be built from either foo_.c or | 
|---|
| 1208 | # sub/foo.c we can't be as concise as in the first example. | 
|---|
| 1209 | # Instead we output | 
|---|
| 1210 | # | 
|---|
| 1211 | #   foo: foo$U.o; link ... | 
|---|
| 1212 | #   foo_.o: foo_.c; compile ... | 
|---|
| 1213 | #   foo.o: sub/foo.c; compile ... | 
|---|
| 1214 | #   foo_.c: foo.c; ansi2knr ... | 
|---|
| 1215 | # | 
|---|
| 1216 | # This is why we'll now transform $rule_file twice | 
|---|
| 1217 | # if we detect this case. | 
|---|
| 1218 | # A first time we output the compile rule with `$U' | 
|---|
| 1219 | # replaced by `_' and the source directory removed, | 
|---|
| 1220 | # and another time we simply remove `$U'. | 
|---|
| 1221 | # | 
|---|
| 1222 | # Note that at this point $source (as computed by | 
|---|
| 1223 | # &handle_single_transform_list) is `sub/foo$U.c'. | 
|---|
| 1224 | # This can be confusing: it can be used as-is when | 
|---|
| 1225 | # subdir-objects is set, otherwise you have to know | 
|---|
| 1226 | # it really means `foo_.c' or `sub/foo.c'. | 
|---|
| 1227 | my $objdir = dirname ($obj); | 
|---|
| 1228 | my $srcdir = dirname ($source); | 
|---|
| 1229 | if ($lang->ansi && $obj =~ /\$U/) | 
|---|
| 1230 | { | 
|---|
| 1231 | prog_error "`$obj' contains \$U, but `$source' doesn't." | 
|---|
| 1232 | if $source !~ /\$U/; | 
|---|
| 1233 |  | 
|---|
| 1234 | (my $source_ = $source) =~ s/\$U/_/g; | 
|---|
| 1235 | # Explicitly clean the _.c files if they are in | 
|---|
| 1236 | # a subdirectory. (In the current directory they get | 
|---|
| 1237 | # erased by a `rm -f *_.c' rule.) | 
|---|
| 1238 | $clean_files{$source_} = MOSTLY_CLEAN | 
|---|
| 1239 | if $objdir ne '.'; | 
|---|
| 1240 | # Output an additional rule if _.c and .c are not in | 
|---|
| 1241 | # the same directory.  (_.c is always in $objdir.) | 
|---|
| 1242 | if ($objdir ne $srcdir) | 
|---|
| 1243 | { | 
|---|
| 1244 | (my $obj_ = $obj) =~ s/\$U/_/g; | 
|---|
| 1245 | (my $depbase_ = $depbase) =~ s/\$U/_/g; | 
|---|
| 1246 | $source_ = basename ($source_); | 
|---|
| 1247 |  | 
|---|
| 1248 | $output_rules .= | 
|---|
| 1249 | file_contents ($rule_file, | 
|---|
| 1250 | new Automake::Location, | 
|---|
| 1251 | %transform, | 
|---|
| 1252 | GENERIC   => 0, | 
|---|
| 1253 |  | 
|---|
| 1254 | DEPBASE   => $depbase_, | 
|---|
| 1255 | BASE      => $obj_, | 
|---|
| 1256 | SOURCE    => $source_, | 
|---|
| 1257 | OBJ       => "$obj_$myext", | 
|---|
| 1258 | OBJOBJ    => "$obj_.obj", | 
|---|
| 1259 | LTOBJ     => "$obj_.lo", | 
|---|
| 1260 |  | 
|---|
| 1261 | COMPILE   => $obj_compile, | 
|---|
| 1262 | LTCOMPILE => $obj_ltcompile, | 
|---|
| 1263 | -o        => $output_flag); | 
|---|
| 1264 | $obj =~ s/\$U//g; | 
|---|
| 1265 | $depbase =~ s/\$U//g; | 
|---|
| 1266 | $source =~ s/\$U//g; | 
|---|
| 1267 | } | 
|---|
| 1268 | } | 
|---|
| 1269 |  | 
|---|
| 1270 | $output_rules .= | 
|---|
| 1271 | file_contents ($rule_file, | 
|---|
| 1272 | new Automake::Location, | 
|---|
| 1273 | %transform, | 
|---|
| 1274 | GENERIC   => 0, | 
|---|
| 1275 |  | 
|---|
| 1276 | DEPBASE   => $depbase, | 
|---|
| 1277 | BASE      => $obj, | 
|---|
| 1278 | SOURCE    => $source, | 
|---|
| 1279 | # Use $myext and not `.o' here, in case | 
|---|
| 1280 | # we are actually building a new source | 
|---|
| 1281 | # file -- e.g. via yacc. | 
|---|
| 1282 | OBJ       => "$obj$myext", | 
|---|
| 1283 | OBJOBJ    => "$obj.obj", | 
|---|
| 1284 | LTOBJ     => "$obj.lo", | 
|---|
| 1285 |  | 
|---|
| 1286 | COMPILE   => $obj_compile, | 
|---|
| 1287 | LTCOMPILE => $obj_ltcompile, | 
|---|
| 1288 | -o        => $output_flag); | 
|---|
| 1289 | } | 
|---|
| 1290 |  | 
|---|
| 1291 | # The rest of the loop is done once per language. | 
|---|
| 1292 | next if defined $done{$lang}; | 
|---|
| 1293 | $done{$lang} = 1; | 
|---|
| 1294 |  | 
|---|
| 1295 | # Load the language dependent Makefile chunks. | 
|---|
| 1296 | my %lang = map { uc ($_) => 0 } keys %languages; | 
|---|
| 1297 | $lang{uc ($lang->name)} = 1; | 
|---|
| 1298 | $output_rules .= file_contents ('lang-compile', | 
|---|
| 1299 | new Automake::Location, | 
|---|
| 1300 | %transform, %lang); | 
|---|
| 1301 |  | 
|---|
| 1302 | # If the source to a program consists entirely of code from a | 
|---|
| 1303 | # `pure' language, for instance C++ for Fortran 77, then we | 
|---|
| 1304 | # don't need the C compiler code.  However if we run into | 
|---|
| 1305 | # something unusual then we do generate the C code.  There are | 
|---|
| 1306 | # probably corner cases here that do not work properly. | 
|---|
| 1307 | # People linking Java code to Fortran code deserve pain. | 
|---|
| 1308 | $needs_c ||= ! $lang->pure; | 
|---|
| 1309 |  | 
|---|
| 1310 | define_compiler_variable ($lang) | 
|---|
| 1311 | if ($lang->compile); | 
|---|
| 1312 |  | 
|---|
| 1313 | define_linker_variable ($lang) | 
|---|
| 1314 | if ($lang->link); | 
|---|
| 1315 |  | 
|---|
| 1316 | require_variables ("$am_file.am", $lang->Name . " source seen", | 
|---|
| 1317 | TRUE, @{$lang->config_vars}); | 
|---|
| 1318 |  | 
|---|
| 1319 | # Call the finisher. | 
|---|
| 1320 | $lang->finish; | 
|---|
| 1321 |  | 
|---|
| 1322 | # Flags listed in `->flags' are user variables (per GNU Standards), | 
|---|
| 1323 | # they should not be overridden in the Makefile... | 
|---|
| 1324 | my @dont_override = @{$lang->flags}; | 
|---|
| 1325 | # ... and so is LDFLAGS. | 
|---|
| 1326 | push @dont_override, 'LDFLAGS' if $lang->link; | 
|---|
| 1327 |  | 
|---|
| 1328 | foreach my $flag (@dont_override) | 
|---|
| 1329 | { | 
|---|
| 1330 | my $var = var $flag; | 
|---|
| 1331 | if ($var) | 
|---|
| 1332 | { | 
|---|
| 1333 | for my $cond ($var->conditions->conds) | 
|---|
| 1334 | { | 
|---|
| 1335 | if ($var->rdef ($cond)->owner == VAR_MAKEFILE) | 
|---|
| 1336 | { | 
|---|
| 1337 | msg_cond_var ('gnu', $cond, $flag, | 
|---|
| 1338 | "`$flag' is a user variable, " | 
|---|
| 1339 | . "you should not override it;\n" | 
|---|
| 1340 | . "use `AM_$flag' instead."); | 
|---|
| 1341 | } | 
|---|
| 1342 | } | 
|---|
| 1343 | } | 
|---|
| 1344 | } | 
|---|
| 1345 | } | 
|---|
| 1346 |  | 
|---|
| 1347 | # If the project is entirely C++ or entirely Fortran 77 (i.e., 1 | 
|---|
| 1348 | # suffix rule was learned), don't bother with the C stuff.  But if | 
|---|
| 1349 | # anything else creeps in, then use it. | 
|---|
| 1350 | $needs_c = 1 | 
|---|
| 1351 | if $need_link || suffix_rules_count > 1; | 
|---|
| 1352 |  | 
|---|
| 1353 | if ($needs_c) | 
|---|
| 1354 | { | 
|---|
| 1355 | &define_compiler_variable ($languages{'c'}) | 
|---|
| 1356 | unless defined $done{$languages{'c'}}; | 
|---|
| 1357 | define_linker_variable ($languages{'c'}); | 
|---|
| 1358 | } | 
|---|
| 1359 | } | 
|---|
| 1360 |  | 
|---|
| 1361 | # Check to make sure a source defined in LIBOBJS is not explicitly | 
|---|
| 1362 | # mentioned.  This is a separate function (as opposed to being inlined | 
|---|
| 1363 | # in handle_source_transform) because it isn't always appropriate to | 
|---|
| 1364 | # do this check. | 
|---|
| 1365 | sub check_libobjs_sources | 
|---|
| 1366 | { | 
|---|
| 1367 | my ($one_file, $unxformed) = @_; | 
|---|
| 1368 |  | 
|---|
| 1369 | foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_', | 
|---|
| 1370 | 'dist_EXTRA_', 'nodist_EXTRA_') | 
|---|
| 1371 | { | 
|---|
| 1372 | my @files; | 
|---|
| 1373 | my $varname = $prefix . $one_file . '_SOURCES'; | 
|---|
| 1374 | my $var = var ($varname); | 
|---|
| 1375 | if ($var) | 
|---|
| 1376 | { | 
|---|
| 1377 | @files = $var->value_as_list_recursive; | 
|---|
| 1378 | } | 
|---|
| 1379 | elsif ($prefix eq '') | 
|---|
| 1380 | { | 
|---|
| 1381 | @files = ($unxformed . '.c'); | 
|---|
| 1382 | } | 
|---|
| 1383 | else | 
|---|
| 1384 | { | 
|---|
| 1385 | next; | 
|---|
| 1386 | } | 
|---|
| 1387 |  | 
|---|
| 1388 | foreach my $file (@files) | 
|---|
| 1389 | { | 
|---|
| 1390 | err_var ($prefix . $one_file . '_SOURCES', | 
|---|
| 1391 | "automatically discovered file `$file' should not" . | 
|---|
| 1392 | " be explicitly mentioned") | 
|---|
| 1393 | if defined $libsources{$file}; | 
|---|
| 1394 | } | 
|---|
| 1395 | } | 
|---|
| 1396 | } | 
|---|
| 1397 |  | 
|---|
| 1398 |  | 
|---|
| 1399 | # @OBJECTS | 
|---|
| 1400 | # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES) | 
|---|
| 1401 | # ----------------------------------------------------------------------- | 
|---|
| 1402 | # Does much of the actual work for handle_source_transform. | 
|---|
| 1403 | # Arguments are: | 
|---|
| 1404 | #   $VAR is the name of the variable that the source filenames come from | 
|---|
| 1405 | #   $TOPPARENT is the name of the _SOURCES variable which is being processed | 
|---|
| 1406 | #   $DERIVED is the name of resulting executable or library | 
|---|
| 1407 | #   $OBJ is the object extension (e.g., `$U.lo') | 
|---|
| 1408 | #   @FILES is the list of source files to transform | 
|---|
| 1409 | # Result is a list of the names of objects | 
|---|
| 1410 | # %linkers_used will be updated with any linkers needed | 
|---|
| 1411 | sub handle_single_transform_list ($$$$@) | 
|---|
| 1412 | { | 
|---|
| 1413 | my ($var, $topparent, $derived, $obj, @files) = @_; | 
|---|
| 1414 | my @result = (); | 
|---|
| 1415 | my $nonansi_obj = $obj; | 
|---|
| 1416 | $nonansi_obj =~ s/\$U//g; | 
|---|
| 1417 |  | 
|---|
| 1418 | # Turn sources into objects.  We use a while loop like this | 
|---|
| 1419 | # because we might add to @files in the loop. | 
|---|
| 1420 | while (scalar @files > 0) | 
|---|
| 1421 | { | 
|---|
| 1422 | $_ = shift @files; | 
|---|
| 1423 |  | 
|---|
| 1424 | # Configure substitutions in _SOURCES variables are errors. | 
|---|
| 1425 | if (/^\@.*\@$/) | 
|---|
| 1426 | { | 
|---|
| 1427 | my $parent_msg = ''; | 
|---|
| 1428 | $parent_msg = "\nand is referred to from `$topparent'" | 
|---|
| 1429 | if $topparent ne $var->name; | 
|---|
| 1430 | err_var ($var, | 
|---|
| 1431 | "`" . $var->name . "' includes configure substitution `$_'" | 
|---|
| 1432 | . $parent_msg . ";\nconfigure " . | 
|---|
| 1433 | "substitutions are not allowed in _SOURCES variables"); | 
|---|
| 1434 | next; | 
|---|
| 1435 | } | 
|---|
| 1436 |  | 
|---|
| 1437 | # If the source file is in a subdirectory then the `.o' is put | 
|---|
| 1438 | # into the current directory, unless the subdir-objects option | 
|---|
| 1439 | # is in effect. | 
|---|
| 1440 |  | 
|---|
| 1441 | # Split file name into base and extension. | 
|---|
| 1442 | next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/; | 
|---|
| 1443 | my $full = $_; | 
|---|
| 1444 | my $directory = $1 || ''; | 
|---|
| 1445 | my $base = $2; | 
|---|
| 1446 | my $extension = $3; | 
|---|
| 1447 |  | 
|---|
| 1448 | # We must generate a rule for the object if it requires its own flags. | 
|---|
| 1449 | my $renamed = 0; | 
|---|
| 1450 | my ($linker, $object); | 
|---|
| 1451 |  | 
|---|
| 1452 | # This records whether we've seen a derived source file (e.g. | 
|---|
| 1453 | # yacc output). | 
|---|
| 1454 | my $derived_source = 0; | 
|---|
| 1455 |  | 
|---|
| 1456 | # This holds the `aggregate context' of the file we are | 
|---|
| 1457 | # currently examining.  If the file is compiled with | 
|---|
| 1458 | # per-object flags, then it will be the name of the object. | 
|---|
| 1459 | # Otherwise it will be `AM'.  This is used by the target hook | 
|---|
| 1460 | # language function. | 
|---|
| 1461 | my $aggregate = 'AM'; | 
|---|
| 1462 |  | 
|---|
| 1463 | $extension = &derive_suffix ($extension, $nonansi_obj); | 
|---|
| 1464 | my $lang; | 
|---|
| 1465 | if ($extension_map{$extension} && | 
|---|
| 1466 | ($lang = $languages{$extension_map{$extension}})) | 
|---|
| 1467 | { | 
|---|
| 1468 | # Found the language, so see what it says. | 
|---|
| 1469 | &saw_extension ($extension); | 
|---|
| 1470 |  | 
|---|
| 1471 | # Note: computed subr call.  The language rewrite function | 
|---|
| 1472 | # should return one of the LANG_* constants.  It could | 
|---|
| 1473 | # also return a list whose first value is such a constant | 
|---|
| 1474 | # and whose second value is a new source extension which | 
|---|
| 1475 | # should be applied.  This means this particular language | 
|---|
| 1476 | # generates another source file which we must then process | 
|---|
| 1477 | # further. | 
|---|
| 1478 | my $subr = \&{'lang_' . $lang->name . '_rewrite'}; | 
|---|
| 1479 | my ($r, $source_extension) | 
|---|
| 1480 | = &$subr ($directory, $base, $extension); | 
|---|
| 1481 | # Skip this entry if we were asked not to process it. | 
|---|
| 1482 | next if $r == LANG_IGNORE; | 
|---|
| 1483 |  | 
|---|
| 1484 | # Now extract linker and other info. | 
|---|
| 1485 | $linker = $lang->linker; | 
|---|
| 1486 |  | 
|---|
| 1487 | my $this_obj_ext; | 
|---|
| 1488 | if (defined $source_extension) | 
|---|
| 1489 | { | 
|---|
| 1490 | $this_obj_ext = $source_extension; | 
|---|
| 1491 | $derived_source = 1; | 
|---|
| 1492 | } | 
|---|
| 1493 | elsif ($lang->ansi) | 
|---|
| 1494 | { | 
|---|
| 1495 | $this_obj_ext = $obj; | 
|---|
| 1496 | } | 
|---|
| 1497 | else | 
|---|
| 1498 | { | 
|---|
| 1499 | $this_obj_ext = $nonansi_obj; | 
|---|
| 1500 | } | 
|---|
| 1501 | $object = $base . $this_obj_ext; | 
|---|
| 1502 |  | 
|---|
| 1503 | # Do we have per-executable flags for this executable? | 
|---|
| 1504 | my $have_per_exec_flags = 0; | 
|---|
| 1505 | foreach my $flag (@{$lang->flags}) | 
|---|
| 1506 | { | 
|---|
| 1507 | if (set_seen ("${derived}_$flag")) | 
|---|
| 1508 | { | 
|---|
| 1509 | $have_per_exec_flags = 1; | 
|---|
| 1510 | last; | 
|---|
| 1511 | } | 
|---|
| 1512 | } | 
|---|
| 1513 |  | 
|---|
| 1514 | if ($have_per_exec_flags) | 
|---|
| 1515 | { | 
|---|
| 1516 | # We have a per-executable flag in effect for this | 
|---|
| 1517 | # object.  In this case we rewrite the object's | 
|---|
| 1518 | # name to ensure it is unique.  We also require | 
|---|
| 1519 | # the `compile' program to deal with compilers | 
|---|
| 1520 | # where `-c -o' does not work. | 
|---|
| 1521 |  | 
|---|
| 1522 | # We choose the name `DERIVED_OBJECT' to ensure | 
|---|
| 1523 | # (1) uniqueness, and (2) continuity between | 
|---|
| 1524 | # invocations.  However, this will result in a | 
|---|
| 1525 | # name that is too long for losing systems, in | 
|---|
| 1526 | # some situations.  So we provide _SHORTNAME to | 
|---|
| 1527 | # override. | 
|---|
| 1528 |  | 
|---|
| 1529 | my $dname = $derived; | 
|---|
| 1530 | my $var = var ($derived . '_SHORTNAME'); | 
|---|
| 1531 | if ($var) | 
|---|
| 1532 | { | 
|---|
| 1533 | # FIXME: should use the same Condition as | 
|---|
| 1534 | # the _SOURCES variable.  But this is really | 
|---|
| 1535 | # silly overkill -- nobody should have | 
|---|
| 1536 | # conditional shortnames. | 
|---|
| 1537 | $dname = $var->variable_value; | 
|---|
| 1538 | } | 
|---|
| 1539 | $object = $dname . '-' . $object; | 
|---|
| 1540 |  | 
|---|
| 1541 | require_conf_file ("$am_file.am", FOREIGN, 'compile') | 
|---|
| 1542 | if $lang->name eq 'c'; | 
|---|
| 1543 |  | 
|---|
| 1544 | prog_error ($lang->name . " flags defined without compiler") | 
|---|
| 1545 | if ! defined $lang->compile; | 
|---|
| 1546 |  | 
|---|
| 1547 | $renamed = 1; | 
|---|
| 1548 | } | 
|---|
| 1549 |  | 
|---|
| 1550 | # If rewrite said it was ok, put the object into a | 
|---|
| 1551 | # subdir. | 
|---|
| 1552 | if ($r == LANG_SUBDIR && $directory ne '') | 
|---|
| 1553 | { | 
|---|
| 1554 | $object = $directory . '/' . $object; | 
|---|
| 1555 | } | 
|---|
| 1556 |  | 
|---|
| 1557 | # If doing dependency tracking, then we can't print | 
|---|
| 1558 | # the rule.  If we have a subdir object, we need to | 
|---|
| 1559 | # generate an explicit rule.  Actually, in any case | 
|---|
| 1560 | # where the object is not in `.' we need a special | 
|---|
| 1561 | # rule.  The per-object rules in this case are | 
|---|
| 1562 | # generated later, by handle_languages. | 
|---|
| 1563 | if ($renamed || $directory ne '') | 
|---|
| 1564 | { | 
|---|
| 1565 | my $obj_sans_ext = substr ($object, 0, | 
|---|
| 1566 | - length ($this_obj_ext)); | 
|---|
| 1567 | my $full_ansi = $full; | 
|---|
| 1568 | if ($lang->ansi && option 'ansi2knr') | 
|---|
| 1569 | { | 
|---|
| 1570 | $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/; | 
|---|
| 1571 | $obj_sans_ext .= '$U'; | 
|---|
| 1572 | } | 
|---|
| 1573 |  | 
|---|
| 1574 | my $val = ("$full_ansi $obj_sans_ext " | 
|---|
| 1575 | # Only use $this_obj_ext in the derived | 
|---|
| 1576 | # source case because in the other case we | 
|---|
| 1577 | # *don't* want $(OBJEXT) to appear here. | 
|---|
| 1578 | . ($derived_source ? $this_obj_ext : '.o')); | 
|---|
| 1579 |  | 
|---|
| 1580 | # If we renamed the object then we want to use the | 
|---|
| 1581 | # per-executable flag name.  But if this is simply a | 
|---|
| 1582 | # subdir build then we still want to use the AM_ flag | 
|---|
| 1583 | # name. | 
|---|
| 1584 | if ($renamed) | 
|---|
| 1585 | { | 
|---|
| 1586 | $val = "$derived $val"; | 
|---|
| 1587 | $aggregate = $derived; | 
|---|
| 1588 | } | 
|---|
| 1589 | else | 
|---|
| 1590 | { | 
|---|
| 1591 | $val = "AM $val"; | 
|---|
| 1592 | } | 
|---|
| 1593 |  | 
|---|
| 1594 | # Each item on this list is a string consisting of | 
|---|
| 1595 | # four space-separated values: the derived flag prefix | 
|---|
| 1596 | # (e.g. for `foo_CFLAGS', it is `foo'), the name of the | 
|---|
| 1597 | # source file, the base name of the output file, and | 
|---|
| 1598 | # the extension for the object file. | 
|---|
| 1599 | push (@{$lang_specific_files{$lang->name}}, $val); | 
|---|
| 1600 | } | 
|---|
| 1601 | } | 
|---|
| 1602 | elsif ($extension eq $nonansi_obj) | 
|---|
| 1603 | { | 
|---|
| 1604 | # This is probably the result of a direct suffix rule. | 
|---|
| 1605 | # In this case we just accept the rewrite. | 
|---|
| 1606 | $object = "$base$extension"; | 
|---|
| 1607 | $linker = ''; | 
|---|
| 1608 | } | 
|---|
| 1609 | else | 
|---|
| 1610 | { | 
|---|
| 1611 | # No error message here.  Used to have one, but it was | 
|---|
| 1612 | # very unpopular. | 
|---|
| 1613 | # FIXME: we could potentially do more processing here, | 
|---|
| 1614 | # perhaps treating the new extension as though it were a | 
|---|
| 1615 | # new source extension (as above).  This would require | 
|---|
| 1616 | # more restructuring than is appropriate right now. | 
|---|
| 1617 | next; | 
|---|
| 1618 | } | 
|---|
| 1619 |  | 
|---|
| 1620 | err_am "object `$object' created by `$full' and `$object_map{$object}'" | 
|---|
| 1621 | if (defined $object_map{$object} | 
|---|
| 1622 | && $object_map{$object} ne $full); | 
|---|
| 1623 |  | 
|---|
| 1624 | my $comp_val = (($object =~ /\.lo$/) | 
|---|
| 1625 | ? COMPILE_LIBTOOL : COMPILE_ORDINARY); | 
|---|
| 1626 | (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/; | 
|---|
| 1627 | if (defined $object_compilation_map{$comp_obj} | 
|---|
| 1628 | && $object_compilation_map{$comp_obj} != 0 | 
|---|
| 1629 | # Only see the error once. | 
|---|
| 1630 | && ($object_compilation_map{$comp_obj} | 
|---|
| 1631 | != (COMPILE_LIBTOOL | COMPILE_ORDINARY)) | 
|---|
| 1632 | && $object_compilation_map{$comp_obj} != $comp_val) | 
|---|
| 1633 | { | 
|---|
| 1634 | err_am "object `$comp_obj' created both with libtool and without"; | 
|---|
| 1635 | } | 
|---|
| 1636 | $object_compilation_map{$comp_obj} |= $comp_val; | 
|---|
| 1637 |  | 
|---|
| 1638 | if (defined $lang) | 
|---|
| 1639 | { | 
|---|
| 1640 | # Let the language do some special magic if required. | 
|---|
| 1641 | $lang->target_hook ($aggregate, $object, $full); | 
|---|
| 1642 | } | 
|---|
| 1643 |  | 
|---|
| 1644 | if ($derived_source) | 
|---|
| 1645 | { | 
|---|
| 1646 | prog_error ($lang->name . " has automatic dependency tracking") | 
|---|
| 1647 | if $lang->autodep ne 'no'; | 
|---|
| 1648 | # Make sure this new source file is handled next.  That will | 
|---|
| 1649 | # make it appear to be at the right place in the list. | 
|---|
| 1650 | unshift (@files, $object); | 
|---|
| 1651 | # Distribute derived sources unless the source they are | 
|---|
| 1652 | # derived from is not. | 
|---|
| 1653 | &push_dist_common ($object) | 
|---|
| 1654 | unless ($topparent =~ /^(?:nobase_)?nodist_/); | 
|---|
| 1655 | next; | 
|---|
| 1656 | } | 
|---|
| 1657 |  | 
|---|
| 1658 | $linkers_used{$linker} = 1; | 
|---|
| 1659 |  | 
|---|
| 1660 | push (@result, $object); | 
|---|
| 1661 |  | 
|---|
| 1662 | if (! defined $object_map{$object}) | 
|---|
| 1663 | { | 
|---|
| 1664 | my @dep_list = (); | 
|---|
| 1665 | $object_map{$object} = $full; | 
|---|
| 1666 |  | 
|---|
| 1667 | # If resulting object is in subdir, we need to make | 
|---|
| 1668 | # sure the subdir exists at build time. | 
|---|
| 1669 | if ($object =~ /\//) | 
|---|
| 1670 | { | 
|---|
| 1671 | # FIXME: check that $DIRECTORY is somewhere in the | 
|---|
| 1672 | # project | 
|---|
| 1673 |  | 
|---|
| 1674 | # For Java, the way we're handling it right now, a | 
|---|
| 1675 | # `..' component doesn't make sense. | 
|---|
| 1676 | if ($lang->name eq 'java' && $object =~ /(\/|^)\.\.\//) | 
|---|
| 1677 | { | 
|---|
| 1678 | err_am "`$full' should not contain a `..' component"; | 
|---|
| 1679 | } | 
|---|
| 1680 |  | 
|---|
| 1681 | # Make sure object is removed by `make mostlyclean'. | 
|---|
| 1682 | $compile_clean_files{$object} = MOSTLY_CLEAN; | 
|---|
| 1683 | # If we have a libtool object then we also must remove | 
|---|
| 1684 | # the ordinary .o. | 
|---|
| 1685 | if ($object =~ /\.lo$/) | 
|---|
| 1686 | { | 
|---|
| 1687 | (my $xobj = $object) =~ s,lo$,\$(OBJEXT),; | 
|---|
| 1688 | $compile_clean_files{$xobj} = MOSTLY_CLEAN; | 
|---|
| 1689 |  | 
|---|
| 1690 | # Remove any libtool object in this directory. | 
|---|
| 1691 | $libtool_clean_directories{$directory} = 1; | 
|---|
| 1692 | } | 
|---|
| 1693 |  | 
|---|
| 1694 | push (@dep_list, require_build_directory ($directory)); | 
|---|
| 1695 |  | 
|---|
| 1696 | # If we're generating dependencies, we also want | 
|---|
| 1697 | # to make sure that the appropriate subdir of the | 
|---|
| 1698 | # .deps directory is created. | 
|---|
| 1699 | push (@dep_list, | 
|---|
| 1700 | require_build_directory ($directory . '/$(DEPDIR)')) | 
|---|
| 1701 | unless option 'no-dependencies'; | 
|---|
| 1702 | } | 
|---|
| 1703 |  | 
|---|
| 1704 | &pretty_print_rule ($object . ':', "\t", @dep_list) | 
|---|
| 1705 | if scalar @dep_list > 0; | 
|---|
| 1706 | } | 
|---|
| 1707 |  | 
|---|
| 1708 | # Transform .o or $o file into .P file (for automatic | 
|---|
| 1709 | # dependency code). | 
|---|
| 1710 | if ($lang && $lang->autodep ne 'no') | 
|---|
| 1711 | { | 
|---|
| 1712 | my $depfile = $object; | 
|---|
| 1713 | $depfile =~ s/\.([^.]*)$/.P$1/; | 
|---|
| 1714 | $depfile =~ s/\$\(OBJEXT\)$/o/; | 
|---|
| 1715 | $dep_files{dirname ($depfile) . '/$(DEPDIR)/' | 
|---|
| 1716 | . basename ($depfile)} = 1; | 
|---|
| 1717 | } | 
|---|
| 1718 | } | 
|---|
| 1719 |  | 
|---|
| 1720 | return @result; | 
|---|
| 1721 | } | 
|---|
| 1722 |  | 
|---|
| 1723 |  | 
|---|
| 1724 | # $LINKER | 
|---|
| 1725 | # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE, | 
|---|
| 1726 | #                              $OBJ, $PARENT, $TOPPARENT, $WHERE) | 
|---|
| 1727 | # --------------------------------------------------------------------- | 
|---|
| 1728 | # Define an _OBJECTS variable for a _SOURCES variable (or subvariable) | 
|---|
| 1729 | # | 
|---|
| 1730 | # Arguments are: | 
|---|
| 1731 | #   $VAR is the name of the _SOURCES variable | 
|---|
| 1732 | #   $OBJVAR is the name of the _OBJECTS variable if known (otherwise | 
|---|
| 1733 | #     it will be generated and returned). | 
|---|
| 1734 | #   $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but | 
|---|
| 1735 | #     work done to determine the linker will be). | 
|---|
| 1736 | #   $ONE_FILE is the canonical (transformed) name of object to build | 
|---|
| 1737 | #   $OBJ is the object extension (i.e. either `.o' or `.lo'). | 
|---|
| 1738 | #   $TOPPARENT is the _SOURCES variable being processed. | 
|---|
| 1739 | #   $WHERE context into which this definition is done | 
|---|
| 1740 | # | 
|---|
| 1741 | # Result is a pair ($LINKER, $OBJVAR): | 
|---|
| 1742 | #    $LINKER is a boolean, true if a linker is needed to deal with the objects | 
|---|
| 1743 | sub define_objects_from_sources ($$$$$$$) | 
|---|
| 1744 | { | 
|---|
| 1745 | my ($var, $objvar, $nodefine, $one_file, $obj, $topparent, $where) = @_; | 
|---|
| 1746 |  | 
|---|
| 1747 | my $needlinker = ""; | 
|---|
| 1748 |  | 
|---|
| 1749 | transform_variable_recursively | 
|---|
| 1750 | ($var, $objvar, 'am__objects', $nodefine, $where, | 
|---|
| 1751 | # The transform code to run on each filename. | 
|---|
| 1752 | sub { | 
|---|
| 1753 | my ($subvar, $val, $cond, $full_cond) = @_; | 
|---|
| 1754 | my @trans = &handle_single_transform_list ($subvar, $topparent, | 
|---|
| 1755 | $one_file, $obj, $val); | 
|---|
| 1756 | $needlinker = "true" if @trans; | 
|---|
| 1757 | return @trans; | 
|---|
| 1758 | }); | 
|---|
| 1759 |  | 
|---|
| 1760 | return $needlinker; | 
|---|
| 1761 | } | 
|---|
| 1762 |  | 
|---|
| 1763 |  | 
|---|
| 1764 | # Handle SOURCE->OBJECT transform for one program or library. | 
|---|
| 1765 | # Arguments are: | 
|---|
| 1766 | #   canonical (transformed) name of object to build | 
|---|
| 1767 | #   actual name of object to build | 
|---|
| 1768 | #   object extension (i.e. either `.o' or `$o'. | 
|---|
| 1769 | # Return result is name of linker variable that must be used. | 
|---|
| 1770 | # Empty return means just use `LINK'. | 
|---|
| 1771 | sub handle_source_transform | 
|---|
| 1772 | { | 
|---|
| 1773 | # one_file is canonical name.  unxformed is given name.  obj is | 
|---|
| 1774 | # object extension. | 
|---|
| 1775 | my ($one_file, $unxformed, $obj, $where) = @_; | 
|---|
| 1776 |  | 
|---|
| 1777 | my ($linker) = ''; | 
|---|
| 1778 |  | 
|---|
| 1779 | # No point in continuing if _OBJECTS is defined. | 
|---|
| 1780 | return if reject_var ($one_file . '_OBJECTS', | 
|---|
| 1781 | $one_file . '_OBJECTS should not be defined'); | 
|---|
| 1782 |  | 
|---|
| 1783 | my %used_pfx = (); | 
|---|
| 1784 | my $needlinker; | 
|---|
| 1785 | %linkers_used = (); | 
|---|
| 1786 | foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_', | 
|---|
| 1787 | 'dist_EXTRA_', 'nodist_EXTRA_') | 
|---|
| 1788 | { | 
|---|
| 1789 | my $varname = $prefix . $one_file . "_SOURCES"; | 
|---|
| 1790 | my $var = var $varname; | 
|---|
| 1791 | next unless $var; | 
|---|
| 1792 |  | 
|---|
| 1793 | # We are going to define _OBJECTS variables using the prefix. | 
|---|
| 1794 | # Then we glom them all together.  So we can't use the null | 
|---|
| 1795 | # prefix here as we need it later. | 
|---|
| 1796 | my $xpfx = ($prefix eq '') ? 'am_' : $prefix; | 
|---|
| 1797 |  | 
|---|
| 1798 | # Keep track of which prefixes we saw. | 
|---|
| 1799 | $used_pfx{$xpfx} = 1 | 
|---|
| 1800 | unless $prefix =~ /EXTRA_/; | 
|---|
| 1801 |  | 
|---|
| 1802 | push @sources, "\$($varname)"; | 
|---|
| 1803 | push @dist_sources, shadow_unconditionally ($varname, $where) | 
|---|
| 1804 | unless ($prefix =~ /^nodist_/); | 
|---|
| 1805 |  | 
|---|
| 1806 | $needlinker |= | 
|---|
| 1807 | define_objects_from_sources ($varname, | 
|---|
| 1808 | $xpfx . $one_file . '_OBJECTS', | 
|---|
| 1809 | $prefix =~ /EXTRA_/, | 
|---|
| 1810 | $one_file, $obj, $varname, $where); | 
|---|
| 1811 | } | 
|---|
| 1812 | if ($needlinker) | 
|---|
| 1813 | { | 
|---|
| 1814 | $linker ||= &resolve_linker (%linkers_used); | 
|---|
| 1815 | } | 
|---|
| 1816 |  | 
|---|
| 1817 | my @keys = sort keys %used_pfx; | 
|---|
| 1818 | if (scalar @keys == 0) | 
|---|
| 1819 | { | 
|---|
| 1820 | # The default source for libfoo.la is libfoo.c, but for | 
|---|
| 1821 | # backward compatibility we first look at libfoo_la.c | 
|---|
| 1822 | my $old_default_source = "$one_file.c"; | 
|---|
| 1823 | (my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,.c,; | 
|---|
| 1824 | if ($old_default_source ne $default_source | 
|---|
| 1825 | && (rule $old_default_source | 
|---|
| 1826 | || rule '$(srcdir)/' . $old_default_source | 
|---|
| 1827 | || rule '${srcdir}/' . $old_default_source | 
|---|
| 1828 | || -f $old_default_source)) | 
|---|
| 1829 | { | 
|---|
| 1830 | my $loc = $where->clone; | 
|---|
| 1831 | $loc->pop_context; | 
|---|
| 1832 | msg ('obsolete', $loc, | 
|---|
| 1833 | "the default source for `$unxformed' has been changed " | 
|---|
| 1834 | . "to `$default_source'.\n(Using `$old_default_source' for " | 
|---|
| 1835 | . "backward compatibility.)"); | 
|---|
| 1836 | $default_source = $old_default_source; | 
|---|
| 1837 | } | 
|---|
| 1838 | # If a rule exists to build this source with a $(srcdir) | 
|---|
| 1839 | # prefix, use that prefix in our variables too.  This is for | 
|---|
| 1840 | # the sake of BSD Make. | 
|---|
| 1841 | if (rule '$(srcdir)/' . $default_source | 
|---|
| 1842 | || rule '${srcdir}/' . $default_source) | 
|---|
| 1843 | { | 
|---|
| 1844 | $default_source = '$(srcdir)/' . $default_source; | 
|---|
| 1845 | } | 
|---|
| 1846 |  | 
|---|
| 1847 | &define_variable ($one_file . "_SOURCES", $default_source, $where); | 
|---|
| 1848 | push (@sources, $default_source); | 
|---|
| 1849 | push (@dist_sources, $default_source); | 
|---|
| 1850 |  | 
|---|
| 1851 | %linkers_used = (); | 
|---|
| 1852 | my (@result) = | 
|---|
| 1853 | &handle_single_transform_list ($one_file . '_SOURCES', | 
|---|
| 1854 | $one_file . '_SOURCES', | 
|---|
| 1855 | $one_file, $obj, | 
|---|
| 1856 | $default_source); | 
|---|
| 1857 | $linker ||= &resolve_linker (%linkers_used); | 
|---|
| 1858 | define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result); | 
|---|
| 1859 | } | 
|---|
| 1860 | else | 
|---|
| 1861 | { | 
|---|
| 1862 | @keys = map { '$(' . $_ . $one_file . '_OBJECTS)' } @keys; | 
|---|
| 1863 | define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @keys); | 
|---|
| 1864 | } | 
|---|
| 1865 |  | 
|---|
| 1866 | # If we want to use `LINK' we must make sure it is defined. | 
|---|
| 1867 | if ($linker eq '') | 
|---|
| 1868 | { | 
|---|
| 1869 | $need_link = 1; | 
|---|
| 1870 | } | 
|---|
| 1871 |  | 
|---|
| 1872 | return $linker; | 
|---|
| 1873 | } | 
|---|
| 1874 |  | 
|---|
| 1875 |  | 
|---|
| 1876 | # handle_lib_objects ($XNAME, $VAR) | 
|---|
| 1877 | # --------------------------------- | 
|---|
| 1878 | # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables. | 
|---|
| 1879 | # Also, generate _DEPENDENCIES variable if appropriate. | 
|---|
| 1880 | # Arguments are: | 
|---|
| 1881 | #   transformed name of object being built, or empty string if no object | 
|---|
| 1882 | #   name of _LDADD/_LIBADD-type variable to examine | 
|---|
| 1883 | # Returns 1 if LIBOBJS seen, 0 otherwise. | 
|---|
| 1884 | sub handle_lib_objects | 
|---|
| 1885 | { | 
|---|
| 1886 | my ($xname, $varname) = @_; | 
|---|
| 1887 |  | 
|---|
| 1888 | my $var = var ($varname); | 
|---|
| 1889 | prog_error "handle_lib_objects: `$varname' undefined" | 
|---|
| 1890 | unless $var; | 
|---|
| 1891 | prog_error "handle_lib_objects: unexpected variable name `$varname'" | 
|---|
| 1892 | unless $varname =~ /^(.*)(?:LIB|LD)ADD$/; | 
|---|
| 1893 | my $prefix = $1 || 'AM_'; | 
|---|
| 1894 |  | 
|---|
| 1895 | my $seen_libobjs = 0; | 
|---|
| 1896 | my $flagvar = 0; | 
|---|
| 1897 |  | 
|---|
| 1898 | transform_variable_recursively | 
|---|
| 1899 | ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES', | 
|---|
| 1900 | ! $xname, INTERNAL, | 
|---|
| 1901 | # Transformation function, run on each filename. | 
|---|
| 1902 | sub { | 
|---|
| 1903 | my ($subvar, $val, $cond, $full_cond) = @_; | 
|---|
| 1904 |  | 
|---|
| 1905 | if ($val =~ /^-/) | 
|---|
| 1906 | { | 
|---|
| 1907 | # Skip -lfoo and -Ldir silently; these are explicitly allowed. | 
|---|
| 1908 | if ($val !~ /^-[lL]/ && | 
|---|
| 1909 | # Skip -dlopen and -dlpreopen; these are explicitly allowed | 
|---|
| 1910 | # for Libtool libraries or programs.  (Actually we are a bit | 
|---|
| 1911 | # laxest here since this code also applies to non-libtool | 
|---|
| 1912 | # libraries or programs, for which -dlopen and -dlopreopen | 
|---|
| 1913 | # are pure non-sence.  Diagnosting this doesn't seems very | 
|---|
| 1914 | # important: the developer will quickly get complaints from | 
|---|
| 1915 | # the linker.) | 
|---|
| 1916 | $val !~ /^-dl(?:pre)?open$/ && | 
|---|
| 1917 | # Only get this error once. | 
|---|
| 1918 | ! $flagvar) | 
|---|
| 1919 | { | 
|---|
| 1920 | $flagvar = 1; | 
|---|
| 1921 | # FIXME: should display a stack of nested variables | 
|---|
| 1922 | # as context when $var != $subvar. | 
|---|
| 1923 | err_var ($var, "linker flags such as `$val' belong in " | 
|---|
| 1924 | . "`${prefix}LDFLAGS"); | 
|---|
| 1925 | } | 
|---|
| 1926 | return (); | 
|---|
| 1927 | } | 
|---|
| 1928 | elsif ($val !~ /^\@.*\@$/) | 
|---|
| 1929 | { | 
|---|
| 1930 | # Assume we have a file of some sort, and output it into the | 
|---|
| 1931 | # dependency variable.  Autoconf substitutions are not output; | 
|---|
| 1932 | # rarely is a new dependency substituted into e.g. foo_LDADD | 
|---|
| 1933 | # -- but bad things (e.g. -lX11) are routinely substituted. | 
|---|
| 1934 | # Note that LIBOBJS and ALLOCA are exceptions to this rule, | 
|---|
| 1935 | # and handled specially below. | 
|---|
| 1936 | return $val; | 
|---|
| 1937 | } | 
|---|
| 1938 | elsif ($val =~ /^\@(LT)?LIBOBJS\@$/) | 
|---|
| 1939 | { | 
|---|
| 1940 | handle_LIBOBJS ($subvar, $cond, $1); | 
|---|
| 1941 | $seen_libobjs = 1; | 
|---|
| 1942 | return $val; | 
|---|
| 1943 | } | 
|---|
| 1944 | elsif ($val =~ /^\@(LT)?ALLOCA\@$/) | 
|---|
| 1945 | { | 
|---|
| 1946 | handle_ALLOCA ($subvar, $cond, $1); | 
|---|
| 1947 | return $val; | 
|---|
| 1948 | } | 
|---|
| 1949 | else | 
|---|
| 1950 | { | 
|---|
| 1951 | return (); | 
|---|
| 1952 | } | 
|---|
| 1953 | }); | 
|---|
| 1954 |  | 
|---|
| 1955 | return $seen_libobjs; | 
|---|
| 1956 | } | 
|---|
| 1957 |  | 
|---|
| 1958 | sub handle_LIBOBJS ($$$) | 
|---|
| 1959 | { | 
|---|
| 1960 | my ($var, $cond, $lt) = @_; | 
|---|
| 1961 | $lt ||= ''; | 
|---|
| 1962 | my $myobjext = ($1 ? 'l' : '') . 'o'; | 
|---|
| 1963 |  | 
|---|
| 1964 | $var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS') | 
|---|
| 1965 | if ! keys %libsources; | 
|---|
| 1966 |  | 
|---|
| 1967 | foreach my $iter (keys %libsources) | 
|---|
| 1968 | { | 
|---|
| 1969 | if ($iter =~ /\.[cly]$/) | 
|---|
| 1970 | { | 
|---|
| 1971 | &saw_extension ($&); | 
|---|
| 1972 | &saw_extension ('.c'); | 
|---|
| 1973 | } | 
|---|
| 1974 |  | 
|---|
| 1975 | if ($iter =~ /\.h$/) | 
|---|
| 1976 | { | 
|---|
| 1977 | require_file_with_macro ($cond, $var, FOREIGN, $iter); | 
|---|
| 1978 | } | 
|---|
| 1979 | elsif ($iter ne 'alloca.c') | 
|---|
| 1980 | { | 
|---|
| 1981 | my $rewrite = $iter; | 
|---|
| 1982 | $rewrite =~ s/\.c$/.P$myobjext/; | 
|---|
| 1983 | $dep_files{'$(DEPDIR)/' . $rewrite} = 1; | 
|---|
| 1984 | $rewrite = "^" . quotemeta ($iter) . "\$"; | 
|---|
| 1985 | # Only require the file if it is not a built source. | 
|---|
| 1986 | my $bs = var ('BUILT_SOURCES'); | 
|---|
| 1987 | if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive)) | 
|---|
| 1988 | { | 
|---|
| 1989 | require_file_with_macro ($cond, $var, FOREIGN, $iter); | 
|---|
| 1990 | } | 
|---|
| 1991 | } | 
|---|
| 1992 | } | 
|---|
| 1993 | } | 
|---|
| 1994 |  | 
|---|
| 1995 | sub handle_ALLOCA ($$$) | 
|---|
| 1996 | { | 
|---|
| 1997 | my ($var, $cond, $lt) = @_; | 
|---|
| 1998 | my $myobjext = ($lt ? 'l' : '') . 'o'; | 
|---|
| 1999 | $lt ||= ''; | 
|---|
| 2000 | $var->requires_variables ("\@${lt}ALLOCA\@ used", $lt . 'ALLOCA'); | 
|---|
| 2001 | $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1; | 
|---|
| 2002 | require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c'); | 
|---|
| 2003 | &saw_extension ('c'); | 
|---|
| 2004 | } | 
|---|
| 2005 |  | 
|---|
| 2006 | # Canonicalize the input parameter | 
|---|
| 2007 | sub canonicalize | 
|---|
| 2008 | { | 
|---|
| 2009 | my ($string) = @_; | 
|---|
| 2010 | $string =~ tr/A-Za-z0-9_\@/_/c; | 
|---|
| 2011 | return $string; | 
|---|
| 2012 | } | 
|---|
| 2013 |  | 
|---|
| 2014 | # Canonicalize a name, and check to make sure the non-canonical name | 
|---|
| 2015 | # is never used.  Returns canonical name.  Arguments are name and a | 
|---|
| 2016 | # list of suffixes to check for. | 
|---|
| 2017 | sub check_canonical_spelling | 
|---|
| 2018 | { | 
|---|
| 2019 | my ($name, @suffixes) = @_; | 
|---|
| 2020 |  | 
|---|
| 2021 | my $xname = &canonicalize ($name); | 
|---|
| 2022 | if ($xname ne $name) | 
|---|
| 2023 | { | 
|---|
| 2024 | foreach my $xt (@suffixes) | 
|---|
| 2025 | { | 
|---|
| 2026 | reject_var ("$name$xt", "use `$xname$xt', not `$name$xt'"); | 
|---|
| 2027 | } | 
|---|
| 2028 | } | 
|---|
| 2029 |  | 
|---|
| 2030 | return $xname; | 
|---|
| 2031 | } | 
|---|
| 2032 |  | 
|---|
| 2033 |  | 
|---|
| 2034 | # handle_compile () | 
|---|
| 2035 | # ----------------- | 
|---|
| 2036 | # Set up the compile suite. | 
|---|
| 2037 | sub handle_compile () | 
|---|
| 2038 | { | 
|---|
| 2039 | return | 
|---|
| 2040 | unless $get_object_extension_was_run; | 
|---|
| 2041 |  | 
|---|
| 2042 | # Boilerplate. | 
|---|
| 2043 | my $default_includes = ''; | 
|---|
| 2044 | if (! option 'nostdinc') | 
|---|
| 2045 | { | 
|---|
| 2046 | $default_includes = ' -I. -I$(srcdir)'; | 
|---|
| 2047 |  | 
|---|
| 2048 | my $var = var 'CONFIG_HEADER'; | 
|---|
| 2049 | if ($var) | 
|---|
| 2050 | { | 
|---|
| 2051 | foreach my $hdr (split (' ', $var->variable_value)) | 
|---|
| 2052 | { | 
|---|
| 2053 | $default_includes .= ' -I' . dirname ($hdr); | 
|---|
| 2054 | } | 
|---|
| 2055 | } | 
|---|
| 2056 | } | 
|---|
| 2057 |  | 
|---|
| 2058 | my (@mostly_rms, @dist_rms); | 
|---|
| 2059 | foreach my $item (sort keys %compile_clean_files) | 
|---|
| 2060 | { | 
|---|
| 2061 | if ($compile_clean_files{$item} == MOSTLY_CLEAN) | 
|---|
| 2062 | { | 
|---|
| 2063 | push (@mostly_rms, "\t-rm -f $item"); | 
|---|
| 2064 | } | 
|---|
| 2065 | elsif ($compile_clean_files{$item} == DIST_CLEAN) | 
|---|
| 2066 | { | 
|---|
| 2067 | push (@dist_rms, "\t-rm -f $item"); | 
|---|
| 2068 | } | 
|---|
| 2069 | else | 
|---|
| 2070 | { | 
|---|
| 2071 | prog_error 'invalid entry in %compile_clean_files'; | 
|---|
| 2072 | } | 
|---|
| 2073 | } | 
|---|
| 2074 |  | 
|---|
| 2075 | my ($coms, $vars, $rules) = | 
|---|
| 2076 | &file_contents_internal (1, "$libdir/am/compile.am", | 
|---|
| 2077 | new Automake::Location, | 
|---|
| 2078 | ('DEFAULT_INCLUDES' => $default_includes, | 
|---|
| 2079 | 'MOSTLYRMS' => join ("\n", @mostly_rms), | 
|---|
| 2080 | 'DISTRMS' => join ("\n", @dist_rms))); | 
|---|
| 2081 | $output_vars .= $vars; | 
|---|
| 2082 | $output_rules .= "$coms$rules"; | 
|---|
| 2083 |  | 
|---|
| 2084 | # Check for automatic de-ANSI-fication. | 
|---|
| 2085 | if (option 'ansi2knr') | 
|---|
| 2086 | { | 
|---|
| 2087 | my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'}; | 
|---|
| 2088 | my $ansi2knr_dir = ''; | 
|---|
| 2089 |  | 
|---|
| 2090 | require_variables ($ansi2knr_where, "option `ansi2knr' is used", | 
|---|
| 2091 | TRUE, "ANSI2KNR", "U"); | 
|---|
| 2092 |  | 
|---|
| 2093 | # topdir is where ansi2knr should be. | 
|---|
| 2094 | if ($ansi2knr_filename eq 'ansi2knr') | 
|---|
| 2095 | { | 
|---|
| 2096 | # Only require ansi2knr files if they should appear in | 
|---|
| 2097 | # this directory. | 
|---|
| 2098 | require_file ($ansi2knr_where, FOREIGN, | 
|---|
| 2099 | 'ansi2knr.c', 'ansi2knr.1'); | 
|---|
| 2100 |  | 
|---|
| 2101 | # ansi2knr needs to be built before subdirs, so unshift it. | 
|---|
| 2102 | unshift (@all, '$(ANSI2KNR)'); | 
|---|
| 2103 | } | 
|---|
| 2104 | else | 
|---|
| 2105 | { | 
|---|
| 2106 | $ansi2knr_dir = dirname ($ansi2knr_filename); | 
|---|
| 2107 | } | 
|---|
| 2108 |  | 
|---|
| 2109 | $output_rules .= &file_contents ('ansi2knr', | 
|---|
| 2110 | new Automake::Location, | 
|---|
| 2111 | 'ANSI2KNR-DIR' => $ansi2knr_dir); | 
|---|
| 2112 |  | 
|---|
| 2113 | } | 
|---|
| 2114 | } | 
|---|
| 2115 |  | 
|---|
| 2116 | # handle_libtool () | 
|---|
| 2117 | # ----------------- | 
|---|
| 2118 | # Handle libtool rules. | 
|---|
| 2119 | sub handle_libtool | 
|---|
| 2120 | { | 
|---|
| 2121 | return unless var ('LIBTOOL'); | 
|---|
| 2122 |  | 
|---|
| 2123 | # Libtool requires some files, but only at top level. | 
|---|
| 2124 | require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files) | 
|---|
| 2125 | if $relative_dir eq '.'; | 
|---|
| 2126 |  | 
|---|
| 2127 | my @libtool_rms; | 
|---|
| 2128 | foreach my $item (sort keys %libtool_clean_directories) | 
|---|
| 2129 | { | 
|---|
| 2130 | my $dir = ($item eq '.') ? '' : "$item/"; | 
|---|
| 2131 | # .libs is for Unix, _libs for DOS. | 
|---|
| 2132 | push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs"); | 
|---|
| 2133 | } | 
|---|
| 2134 |  | 
|---|
| 2135 | # Output the libtool compilation rules. | 
|---|
| 2136 | $output_rules .= &file_contents ('libtool', | 
|---|
| 2137 | new Automake::Location, | 
|---|
| 2138 | LTRMS => join ("\n", @libtool_rms)); | 
|---|
| 2139 | } | 
|---|
| 2140 |  | 
|---|
| 2141 | # handle_programs () | 
|---|
| 2142 | # ------------------ | 
|---|
| 2143 | # Handle C programs. | 
|---|
| 2144 | sub handle_programs | 
|---|
| 2145 | { | 
|---|
| 2146 | my @proglist = &am_install_var ('progs', 'PROGRAMS', | 
|---|
| 2147 | 'bin', 'sbin', 'libexec', 'pkglib', | 
|---|
| 2148 | 'noinst', 'check'); | 
|---|
| 2149 | return if ! @proglist; | 
|---|
| 2150 |  | 
|---|
| 2151 | my $seen_global_libobjs = | 
|---|
| 2152 | var ('LDADD') && &handle_lib_objects ('', 'LDADD'); | 
|---|
| 2153 |  | 
|---|
| 2154 | foreach my $pair (@proglist) | 
|---|
| 2155 | { | 
|---|
| 2156 | my ($where, $one_file) = @$pair; | 
|---|
| 2157 |  | 
|---|
| 2158 | my $seen_libobjs = 0; | 
|---|
| 2159 | my $obj = &get_object_extension ($one_file); | 
|---|
| 2160 |  | 
|---|
| 2161 | # Strip any $(EXEEXT) suffix the user might have added, or this | 
|---|
| 2162 | # will confuse &handle_source_transform and &check_canonical_spelling. | 
|---|
| 2163 | # We'll add $(EXEEXT) back later anyway. | 
|---|
| 2164 | $one_file =~ s/\$\(EXEEXT\)$//; | 
|---|
| 2165 |  | 
|---|
| 2166 | # Canonicalize names and check for misspellings. | 
|---|
| 2167 | my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS', | 
|---|
| 2168 | '_SOURCES', '_OBJECTS', | 
|---|
| 2169 | '_DEPENDENCIES'); | 
|---|
| 2170 |  | 
|---|
| 2171 | $where->push_context ("while processing program `$one_file'"); | 
|---|
| 2172 | $where->set (INTERNAL->get); | 
|---|
| 2173 |  | 
|---|
| 2174 | my $linker = &handle_source_transform ($xname, $one_file, $obj, $where); | 
|---|
| 2175 |  | 
|---|
| 2176 | if (var ($xname . "_LDADD")) | 
|---|
| 2177 | { | 
|---|
| 2178 | $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD'); | 
|---|
| 2179 | } | 
|---|
| 2180 | else | 
|---|
| 2181 | { | 
|---|
| 2182 | # User didn't define prog_LDADD override.  So do it. | 
|---|
| 2183 | &define_variable ($xname . '_LDADD', '$(LDADD)', $where); | 
|---|
| 2184 |  | 
|---|
| 2185 | # This does a bit too much work.  But we need it to | 
|---|
| 2186 | # generate _DEPENDENCIES when appropriate. | 
|---|
| 2187 | if (var ('LDADD')) | 
|---|
| 2188 | { | 
|---|
| 2189 | $seen_libobjs = &handle_lib_objects ($xname, 'LDADD'); | 
|---|
| 2190 | } | 
|---|
| 2191 | } | 
|---|
| 2192 |  | 
|---|
| 2193 | reject_var ($xname . '_LIBADD', | 
|---|
| 2194 | "use `${xname}_LDADD', not `${xname}_LIBADD'"); | 
|---|
| 2195 |  | 
|---|
| 2196 | set_seen ($xname . '_DEPENDENCIES'); | 
|---|
| 2197 | set_seen ($xname . '_LDFLAGS'); | 
|---|
| 2198 |  | 
|---|
| 2199 | # Determine program to use for link. | 
|---|
| 2200 | my $xlink; | 
|---|
| 2201 | if (var ($xname . '_LINK')) | 
|---|
| 2202 | { | 
|---|
| 2203 | $xlink = $xname . '_LINK'; | 
|---|
| 2204 | } | 
|---|
| 2205 | else | 
|---|
| 2206 | { | 
|---|
| 2207 | $xlink = $linker ? $linker : 'LINK'; | 
|---|
| 2208 | } | 
|---|
| 2209 |  | 
|---|
| 2210 | # If the resulting program lies into a subdirectory, | 
|---|
| 2211 | # make sure this directory will exist. | 
|---|
| 2212 | my $dirstamp = require_build_directory_maybe ($one_file); | 
|---|
| 2213 |  | 
|---|
| 2214 | $output_rules .= &file_contents ('program', | 
|---|
| 2215 | $where, | 
|---|
| 2216 | PROGRAM  => $one_file, | 
|---|
| 2217 | XPROGRAM => $xname, | 
|---|
| 2218 | XLINK    => $xlink, | 
|---|
| 2219 | DIRSTAMP => $dirstamp, | 
|---|
| 2220 | EXEEXT   => '$(EXEEXT)'); | 
|---|
| 2221 |  | 
|---|
| 2222 | if ($seen_libobjs || $seen_global_libobjs) | 
|---|
| 2223 | { | 
|---|
| 2224 | if (var ($xname . '_LDADD')) | 
|---|
| 2225 | { | 
|---|
| 2226 | &check_libobjs_sources ($xname, $xname . '_LDADD'); | 
|---|
| 2227 | } | 
|---|
| 2228 | elsif (var ('LDADD')) | 
|---|
| 2229 | { | 
|---|
| 2230 | &check_libobjs_sources ($xname, 'LDADD'); | 
|---|
| 2231 | } | 
|---|
| 2232 | } | 
|---|
| 2233 | } | 
|---|
| 2234 | } | 
|---|
| 2235 |  | 
|---|
| 2236 |  | 
|---|
| 2237 | # handle_libraries () | 
|---|
| 2238 | # ------------------- | 
|---|
| 2239 | # Handle libraries. | 
|---|
| 2240 | sub handle_libraries | 
|---|
| 2241 | { | 
|---|
| 2242 | my @liblist = &am_install_var ('libs', 'LIBRARIES', | 
|---|
| 2243 | 'lib', 'pkglib', 'noinst', 'check'); | 
|---|
| 2244 | return if ! @liblist; | 
|---|
| 2245 |  | 
|---|
| 2246 | my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib', | 
|---|
| 2247 | 'noinst', 'check'); | 
|---|
| 2248 |  | 
|---|
| 2249 | if (@prefix) | 
|---|
| 2250 | { | 
|---|
| 2251 | my $var = rvar ($prefix[0] . '_LIBRARIES'); | 
|---|
| 2252 | $var->requires_variables ('library used', 'RANLIB'); | 
|---|
| 2253 | } | 
|---|
| 2254 |  | 
|---|
| 2255 | &define_variable ('AR', 'ar', INTERNAL); | 
|---|
| 2256 | &define_variable ('ARFLAGS', 'cru', INTERNAL); | 
|---|
| 2257 |  | 
|---|
| 2258 | foreach my $pair (@liblist) | 
|---|
| 2259 | { | 
|---|
| 2260 | my ($where, $onelib) = @$pair; | 
|---|
| 2261 |  | 
|---|
| 2262 | my $seen_libobjs = 0; | 
|---|
| 2263 | # Check that the library fits the standard naming convention. | 
|---|
| 2264 | if (basename ($onelib) !~ /^lib.*\.a/) | 
|---|
| 2265 | { | 
|---|
| 2266 | error $where, "`$onelib' is not a standard library name"; | 
|---|
| 2267 | } | 
|---|
| 2268 |  | 
|---|
| 2269 | $where->push_context ("while processing library `$onelib'"); | 
|---|
| 2270 | $where->set (INTERNAL->get); | 
|---|
| 2271 |  | 
|---|
| 2272 | my $obj = &get_object_extension ($onelib); | 
|---|
| 2273 |  | 
|---|
| 2274 | # Canonicalize names and check for misspellings. | 
|---|
| 2275 | my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES', | 
|---|
| 2276 | '_OBJECTS', '_DEPENDENCIES', | 
|---|
| 2277 | '_AR'); | 
|---|
| 2278 |  | 
|---|
| 2279 | if (! var ($xlib . '_AR')) | 
|---|
| 2280 | { | 
|---|
| 2281 | &define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where); | 
|---|
| 2282 | } | 
|---|
| 2283 |  | 
|---|
| 2284 | # Generate support for conditional object inclusion in | 
|---|
| 2285 | # libraries. | 
|---|
| 2286 | if (var ($xlib . '_LIBADD')) | 
|---|
| 2287 | { | 
|---|
| 2288 | if (&handle_lib_objects ($xlib, $xlib . '_LIBADD')) | 
|---|
| 2289 | { | 
|---|
| 2290 | $seen_libobjs = 1; | 
|---|
| 2291 | } | 
|---|
| 2292 | } | 
|---|
| 2293 | else | 
|---|
| 2294 | { | 
|---|
| 2295 | &define_variable ($xlib . "_LIBADD", '', $where); | 
|---|
| 2296 | } | 
|---|
| 2297 |  | 
|---|
| 2298 | reject_var ($xlib . '_LDADD', | 
|---|
| 2299 | "use `${xlib}_LIBADD', not `${xlib}_LDADD'"); | 
|---|
| 2300 |  | 
|---|
| 2301 | # Make sure we at look at this. | 
|---|
| 2302 | set_seen ($xlib . '_DEPENDENCIES'); | 
|---|
| 2303 |  | 
|---|
| 2304 | &handle_source_transform ($xlib, $onelib, $obj, $where); | 
|---|
| 2305 |  | 
|---|
| 2306 | # If the resulting library lies into a subdirectory, | 
|---|
| 2307 | # make sure this directory will exist. | 
|---|
| 2308 | my $dirstamp = require_build_directory_maybe ($onelib); | 
|---|
| 2309 |  | 
|---|
| 2310 | $output_rules .= &file_contents ('library', | 
|---|
| 2311 | $where, | 
|---|
| 2312 | LIBRARY  => $onelib, | 
|---|
| 2313 | XLIBRARY => $xlib, | 
|---|
| 2314 | DIRSTAMP => $dirstamp); | 
|---|
| 2315 |  | 
|---|
| 2316 | if ($seen_libobjs) | 
|---|
| 2317 | { | 
|---|
| 2318 | if (var ($xlib . '_LIBADD')) | 
|---|
| 2319 | { | 
|---|
| 2320 | &check_libobjs_sources ($xlib, $xlib . '_LIBADD'); | 
|---|
| 2321 | } | 
|---|
| 2322 | } | 
|---|
| 2323 | } | 
|---|
| 2324 | } | 
|---|
| 2325 |  | 
|---|
| 2326 |  | 
|---|
| 2327 | # handle_ltlibraries () | 
|---|
| 2328 | # --------------------- | 
|---|
| 2329 | # Handle shared libraries. | 
|---|
| 2330 | sub handle_ltlibraries | 
|---|
| 2331 | { | 
|---|
| 2332 | my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES', | 
|---|
| 2333 | 'noinst', 'lib', 'pkglib', 'check'); | 
|---|
| 2334 | return if ! @liblist; | 
|---|
| 2335 |  | 
|---|
| 2336 | my %instdirs; | 
|---|
| 2337 | my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib', | 
|---|
| 2338 | 'noinst', 'check'); | 
|---|
| 2339 |  | 
|---|
| 2340 | if (@prefix) | 
|---|
| 2341 | { | 
|---|
| 2342 | my $var = rvar ($prefix[0] . '_LTLIBRARIES'); | 
|---|
| 2343 | $var->requires_variables ('Libtool library used', 'LIBTOOL'); | 
|---|
| 2344 | } | 
|---|
| 2345 |  | 
|---|
| 2346 | my %liblocations = ();        # Location (in Makefile.am) of each library. | 
|---|
| 2347 |  | 
|---|
| 2348 | foreach my $key (@prefix) | 
|---|
| 2349 | { | 
|---|
| 2350 | # Get the installation directory of each library. | 
|---|
| 2351 | (my $dir = $key) =~ s/^nobase_//; | 
|---|
| 2352 | my $var = rvar ($key . '_LTLIBRARIES'); | 
|---|
| 2353 | for my $pair ($var->value_as_list_recursive (location => 1)) | 
|---|
| 2354 | { | 
|---|
| 2355 | my ($where, $lib) = @$pair; | 
|---|
| 2356 | # We reject libraries which are installed in several places, | 
|---|
| 2357 | # because we don't handle this in the rules (think `-rpath'). | 
|---|
| 2358 | # | 
|---|
| 2359 | # However, we allow the same library to be listed many times | 
|---|
| 2360 | # for the same directory.  This is for users who need setups | 
|---|
| 2361 | # like | 
|---|
| 2362 | #   if COND1 | 
|---|
| 2363 | #     lib_LTLIBRARIES = libfoo.la | 
|---|
| 2364 | #   endif | 
|---|
| 2365 | #   if COND2 | 
|---|
| 2366 | #     lib_LTLIBRARIES = libfoo.la | 
|---|
| 2367 | #   endif | 
|---|
| 2368 | # | 
|---|
| 2369 | # Actually this will also allow | 
|---|
| 2370 | #   lib_LTLIBRARIES = libfoo.la libfoo.la | 
|---|
| 2371 | # Diagnosing this case doesn't seem worth the plain (we'd | 
|---|
| 2372 | # have to fill $instdirs on a per-condition basis, check | 
|---|
| 2373 | # implied conditions, etc.) | 
|---|
| 2374 | if (defined $instdirs{$lib} && $instdirs{$lib} ne $dir) | 
|---|
| 2375 | { | 
|---|
| 2376 | error ($where, "`$lib' is already going to be installed in " | 
|---|
| 2377 | . "`$instdirs{$lib}'", partial => 1); | 
|---|
| 2378 | error ($liblocations{$lib}, "`$lib' previously declared here"); | 
|---|
| 2379 | } | 
|---|
| 2380 | else | 
|---|
| 2381 | { | 
|---|
| 2382 | $instdirs{$lib} = $dir; | 
|---|
| 2383 | $liblocations{$lib} = $where->clone; | 
|---|
| 2384 | } | 
|---|
| 2385 | } | 
|---|
| 2386 | } | 
|---|
| 2387 |  | 
|---|
| 2388 | foreach my $pair (@liblist) | 
|---|
| 2389 | { | 
|---|
| 2390 | my ($where, $onelib) = @$pair; | 
|---|
| 2391 |  | 
|---|
| 2392 | my $seen_libobjs = 0; | 
|---|
| 2393 | my $obj = &get_object_extension ($onelib); | 
|---|
| 2394 |  | 
|---|
| 2395 | # Canonicalize names and check for misspellings. | 
|---|
| 2396 | my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS', | 
|---|
| 2397 | '_SOURCES', '_OBJECTS', | 
|---|
| 2398 | '_DEPENDENCIES'); | 
|---|
| 2399 |  | 
|---|
| 2400 | # Check that the library fits the standard naming convention. | 
|---|
| 2401 | my $libname_rx = "^lib.*\.la"; | 
|---|
| 2402 | my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS'); | 
|---|
| 2403 | my $ldvar2 = var ('LDFLAGS'); | 
|---|
| 2404 | if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive)) | 
|---|
| 2405 | || ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive))) | 
|---|
| 2406 | { | 
|---|
| 2407 | # Relax name checking for libtool modules. | 
|---|
| 2408 | $libname_rx = "\.la"; | 
|---|
| 2409 | } | 
|---|
| 2410 | if (basename ($onelib) !~ /$libname_rx$/) | 
|---|
| 2411 | { | 
|---|
| 2412 | msg ('error-gnu/warn', $where, | 
|---|
| 2413 | "`$onelib' is not a standard libtool library name"); | 
|---|
| 2414 | } | 
|---|
| 2415 |  | 
|---|
| 2416 | $where->push_context ("while processing Libtool library `$onelib'"); | 
|---|
| 2417 | $where->set (INTERNAL->get); | 
|---|
| 2418 |  | 
|---|
| 2419 | # Make sure we at look at these. | 
|---|
| 2420 | set_seen ($xlib . '_LDFLAGS'); | 
|---|
| 2421 | set_seen ($xlib . '_DEPENDENCIES'); | 
|---|
| 2422 |  | 
|---|
| 2423 | # Generate support for conditional object inclusion in | 
|---|
| 2424 | # libraries. | 
|---|
| 2425 | if (var ($xlib . '_LIBADD')) | 
|---|
| 2426 | { | 
|---|
| 2427 | if (&handle_lib_objects ($xlib, $xlib . '_LIBADD')) | 
|---|
| 2428 | { | 
|---|
| 2429 | $seen_libobjs = 1; | 
|---|
| 2430 | } | 
|---|
| 2431 | } | 
|---|
| 2432 | else | 
|---|
| 2433 | { | 
|---|
| 2434 | &define_variable ($xlib . "_LIBADD", '', $where); | 
|---|
| 2435 | } | 
|---|
| 2436 |  | 
|---|
| 2437 | reject_var ("${xlib}_LDADD", | 
|---|
| 2438 | "use `${xlib}_LIBADD', not `${xlib}_LDADD'"); | 
|---|
| 2439 |  | 
|---|
| 2440 |  | 
|---|
| 2441 | my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where); | 
|---|
| 2442 |  | 
|---|
| 2443 | # Determine program to use for link. | 
|---|
| 2444 | my $xlink; | 
|---|
| 2445 | if (var ($xlib . '_LINK')) | 
|---|
| 2446 | { | 
|---|
| 2447 | $xlink = $xlib . '_LINK'; | 
|---|
| 2448 | } | 
|---|
| 2449 | else | 
|---|
| 2450 | { | 
|---|
| 2451 | $xlink = $linker ? $linker : 'LINK'; | 
|---|
| 2452 | } | 
|---|
| 2453 |  | 
|---|
| 2454 | my $rpath; | 
|---|
| 2455 | if ($instdirs{$onelib} eq 'EXTRA' | 
|---|
| 2456 | || $instdirs{$onelib} eq 'noinst' | 
|---|
| 2457 | || $instdirs{$onelib} eq 'check') | 
|---|
| 2458 | { | 
|---|
| 2459 | # It's an EXTRA_ library, so we can't specify -rpath, | 
|---|
| 2460 | # because we don't know where the library will end up. | 
|---|
| 2461 | # The user probably knows, but generally speaking automake | 
|---|
| 2462 | # doesn't -- and in fact configure could decide | 
|---|
| 2463 | # dynamically between two different locations. | 
|---|
| 2464 | $rpath = ''; | 
|---|
| 2465 | } | 
|---|
| 2466 | else | 
|---|
| 2467 | { | 
|---|
| 2468 | $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)'); | 
|---|
| 2469 | } | 
|---|
| 2470 |  | 
|---|
| 2471 | # If the resulting library lies into a subdirectory, | 
|---|
| 2472 | # make sure this directory will exist. | 
|---|
| 2473 | my $dirstamp = require_build_directory_maybe ($onelib); | 
|---|
| 2474 |  | 
|---|
| 2475 | # Remember to cleanup .libs/ in this directory. | 
|---|
| 2476 | my $dirname = dirname $onelib; | 
|---|
| 2477 | $libtool_clean_directories{$dirname} = 1; | 
|---|
| 2478 |  | 
|---|
| 2479 | $output_rules .= &file_contents ('ltlibrary', | 
|---|
| 2480 | $where, | 
|---|
| 2481 | LTLIBRARY  => $onelib, | 
|---|
| 2482 | XLTLIBRARY => $xlib, | 
|---|
| 2483 | RPATH      => $rpath, | 
|---|
| 2484 | XLINK      => $xlink, | 
|---|
| 2485 | DIRSTAMP   => $dirstamp); | 
|---|
| 2486 | if ($seen_libobjs) | 
|---|
| 2487 | { | 
|---|
| 2488 | if (var ($xlib . '_LIBADD')) | 
|---|
| 2489 | { | 
|---|
| 2490 | &check_libobjs_sources ($xlib, $xlib . '_LIBADD'); | 
|---|
| 2491 | } | 
|---|
| 2492 | } | 
|---|
| 2493 | } | 
|---|
| 2494 | } | 
|---|
| 2495 |  | 
|---|
| 2496 | # See if any _SOURCES variable were misspelled. | 
|---|
| 2497 | sub check_typos () | 
|---|
| 2498 | { | 
|---|
| 2499 | # It is ok if the user sets this particular variable. | 
|---|
| 2500 | set_seen 'AM_LDFLAGS'; | 
|---|
| 2501 |  | 
|---|
| 2502 | foreach my $var (variables) | 
|---|
| 2503 | { | 
|---|
| 2504 | my $varname = $var->name; | 
|---|
| 2505 | # A configure variable is always legitimate. | 
|---|
| 2506 | next if exists $configure_vars{$varname}; | 
|---|
| 2507 |  | 
|---|
| 2508 | my $check = 0; | 
|---|
| 2509 | foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', | 
|---|
| 2510 | '_DEPENDENCIES') | 
|---|
| 2511 | { | 
|---|
| 2512 | if ($varname =~ /$primary$/) | 
|---|
| 2513 | { | 
|---|
| 2514 | $check = 1; | 
|---|
| 2515 | last; | 
|---|
| 2516 | } | 
|---|
| 2517 | } | 
|---|
| 2518 | next unless $check; | 
|---|
| 2519 |  | 
|---|
| 2520 | for my $cond ($var->conditions->conds) | 
|---|
| 2521 | { | 
|---|
| 2522 | msg_var 'syntax', $var, "unused variable: `$varname'" | 
|---|
| 2523 | unless $var->rdef ($cond)->seen; | 
|---|
| 2524 | } | 
|---|
| 2525 | } | 
|---|
| 2526 | } | 
|---|
| 2527 |  | 
|---|
| 2528 |  | 
|---|
| 2529 | # Handle scripts. | 
|---|
| 2530 | sub handle_scripts | 
|---|
| 2531 | { | 
|---|
| 2532 | # NOTE we no longer automatically clean SCRIPTS, because it is | 
|---|
| 2533 | # useful to sometimes distribute scripts verbatim.  This happens | 
|---|
| 2534 | # e.g. in Automake itself. | 
|---|
| 2535 | &am_install_var ('-candist', 'scripts', 'SCRIPTS', | 
|---|
| 2536 | 'bin', 'sbin', 'libexec', 'pkgdata', | 
|---|
| 2537 | 'noinst', 'check'); | 
|---|
| 2538 | } | 
|---|
| 2539 |  | 
|---|
| 2540 |  | 
|---|
| 2541 |  | 
|---|
| 2542 |  | 
|---|
| 2543 | ## ------------------------ ## | 
|---|
| 2544 | ## Handling Texinfo files.  ## | 
|---|
| 2545 | ## ------------------------ ## | 
|---|
| 2546 |  | 
|---|
| 2547 | # ($OUTFILE, $VFILE, @CLEAN_FILES) | 
|---|
| 2548 | # &scan_texinfo_file ($FILENAME) | 
|---|
| 2549 | # ------------------------------ | 
|---|
| 2550 | # $OUTFILE     - name of the info file produced by $FILENAME. | 
|---|
| 2551 | # $VFILE       - name of the version.texi file used (undef if none). | 
|---|
| 2552 | # @CLEAN_FILES - list of byproducts (indexes etc.) | 
|---|
| 2553 | sub scan_texinfo_file ($) | 
|---|
| 2554 | { | 
|---|
| 2555 | my ($filename) = @_; | 
|---|
| 2556 |  | 
|---|
| 2557 | # Some of the following extensions are always created, no matter | 
|---|
| 2558 | # whether indexes are used or not.  Other (like cps, fns, ... pgs) | 
|---|
| 2559 | # are only created when they are used.  We used to scan $FILENAME | 
|---|
| 2560 | # for their use, but that is not enough: they could be used in | 
|---|
| 2561 | # included files.  We can't scan included files because we don't | 
|---|
| 2562 | # know the include path.  Therefore we always erase these files, no | 
|---|
| 2563 | # matter whether they are used or not. | 
|---|
| 2564 | # | 
|---|
| 2565 | # (tmp is only created if an @macro is used and a certain e-TeX | 
|---|
| 2566 | # feature is not available.) | 
|---|
| 2567 | my %clean_suffixes = | 
|---|
| 2568 | map { $_ => 1 } (qw(aux log toc tmp | 
|---|
| 2569 | cp cps | 
|---|
| 2570 | fn fns | 
|---|
| 2571 | ky kys | 
|---|
| 2572 | vr vrs | 
|---|
| 2573 | tp tps | 
|---|
| 2574 | pg pgs)); # grep 'new.*index' texinfo.tex | 
|---|
| 2575 |  | 
|---|
| 2576 | my $texi = new Automake::XFile "< $filename"; | 
|---|
| 2577 | verb "reading $filename"; | 
|---|
| 2578 |  | 
|---|
| 2579 | my ($outfile, $vfile); | 
|---|
| 2580 | while ($_ = $texi->getline) | 
|---|
| 2581 | { | 
|---|
| 2582 | if (/^\@setfilename +(\S+)/) | 
|---|
| 2583 | { | 
|---|
| 2584 | # Honor only the first @setfilename.  (It's possible to have | 
|---|
| 2585 | # more occurrences later if the manual shows examples of how | 
|---|
| 2586 | # to use @setfilename...) | 
|---|
| 2587 | next if $outfile; | 
|---|
| 2588 |  | 
|---|
| 2589 | $outfile = $1; | 
|---|
| 2590 | if ($outfile =~ /\.(.+)$/ && $1 ne 'info') | 
|---|
| 2591 | { | 
|---|
| 2592 | error ("$filename:$.", | 
|---|
| 2593 | "output `$outfile' has unrecognized extension"); | 
|---|
| 2594 | return; | 
|---|
| 2595 | } | 
|---|
| 2596 | } | 
|---|
| 2597 | # A "version.texi" file is actually any file whose name matches | 
|---|
| 2598 | # "vers*.texi". | 
|---|
| 2599 | elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/) | 
|---|
| 2600 | { | 
|---|
| 2601 | $vfile = $1; | 
|---|
| 2602 | } | 
|---|
| 2603 |  | 
|---|
| 2604 | # Try to find new or unused indexes. | 
|---|
| 2605 |  | 
|---|
| 2606 | # Creating a new category of index. | 
|---|
| 2607 | elsif (/^\@def(code)?index (\w+)/) | 
|---|
| 2608 | { | 
|---|
| 2609 | $clean_suffixes{$2} = 1; | 
|---|
| 2610 | $clean_suffixes{"$2s"} = 1; | 
|---|
| 2611 | } | 
|---|
| 2612 |  | 
|---|
| 2613 | # Merging an index into an another. | 
|---|
| 2614 | elsif (/^\@syn(code)?index (\w+) (\w+)/) | 
|---|
| 2615 | { | 
|---|
| 2616 | delete $clean_suffixes{"$2s"}; | 
|---|
| 2617 | $clean_suffixes{"$3s"} = 1; | 
|---|
| 2618 | } | 
|---|
| 2619 |  | 
|---|
| 2620 | } | 
|---|
| 2621 |  | 
|---|
| 2622 | if (! $outfile) | 
|---|
| 2623 | { | 
|---|
| 2624 | err_am "`$filename' missing \@setfilename"; | 
|---|
| 2625 | return; | 
|---|
| 2626 | } | 
|---|
| 2627 |  | 
|---|
| 2628 | my $infobase = basename ($filename); | 
|---|
| 2629 | $infobase =~ s/\.te?xi(nfo)?$//; | 
|---|
| 2630 | return ($outfile, $vfile, | 
|---|
| 2631 | map { "$infobase.$_" } (sort keys %clean_suffixes)); | 
|---|
| 2632 | } | 
|---|
| 2633 |  | 
|---|
| 2634 |  | 
|---|
| 2635 | # ($DIRSTAMP, @CLEAN_FILES) | 
|---|
| 2636 | # output_texinfo_build_rules ($SOURCE, $DEST, $INSRC, @DEPENDENCIES) | 
|---|
| 2637 | # ------------------------------------------------------------------ | 
|---|
| 2638 | # SOURCE - the source Texinfo file | 
|---|
| 2639 | # DEST - the destination Info file | 
|---|
| 2640 | # INSRC - wether DEST should be built in the source tree | 
|---|
| 2641 | # DEPENDENCIES - known dependencies | 
|---|
| 2642 | sub output_texinfo_build_rules ($$$@) | 
|---|
| 2643 | { | 
|---|
| 2644 | my ($source, $dest, $insrc, @deps) = @_; | 
|---|
| 2645 |  | 
|---|
| 2646 | # Split `a.texi' into `a' and `.texi'. | 
|---|
| 2647 | my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/); | 
|---|
| 2648 | my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/); | 
|---|
| 2649 |  | 
|---|
| 2650 | $ssfx ||= ""; | 
|---|
| 2651 | $dsfx ||= ""; | 
|---|
| 2652 |  | 
|---|
| 2653 | # We can output two kinds of rules: the "generic" rules use Make | 
|---|
| 2654 | # suffix rules and are appropriate when $source and $dest do not lie | 
|---|
| 2655 | # in a sub-directory; the "specific" rules are needed in the other | 
|---|
| 2656 | # case. | 
|---|
| 2657 | # | 
|---|
| 2658 | # The former are output only once (this is not really apparent here, | 
|---|
| 2659 | # but just remember that some logic deeper in Automake will not | 
|---|
| 2660 | # output the same rule twice); while the later need to be output for | 
|---|
| 2661 | # each Texinfo source. | 
|---|
| 2662 | my $generic; | 
|---|
| 2663 | my $makeinfoflags; | 
|---|
| 2664 | my $sdir = dirname $source; | 
|---|
| 2665 | if ($sdir eq '.' && dirname ($dest) eq '.') | 
|---|
| 2666 | { | 
|---|
| 2667 | $generic = 1; | 
|---|
| 2668 | $makeinfoflags = '-I $(srcdir)'; | 
|---|
| 2669 | } | 
|---|
| 2670 | else | 
|---|
| 2671 | { | 
|---|
| 2672 | $generic = 0; | 
|---|
| 2673 | $makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir"; | 
|---|
| 2674 | } | 
|---|
| 2675 |  | 
|---|
| 2676 | # A directory can contain two kinds of info files: some built in the | 
|---|
| 2677 | # source tree, and some built in the build tree.  The rules are | 
|---|
| 2678 | # different in each case.  However we cannot output two different | 
|---|
| 2679 | # set of generic rules.  Because in-source builds are more usual, we | 
|---|
| 2680 | # use generic rules in this case and fall back to "specific" rules | 
|---|
| 2681 | # for build-dir builds.  (It should not be a problem to invert this | 
|---|
| 2682 | # if needed.) | 
|---|
| 2683 | $generic = 0 unless $insrc; | 
|---|
| 2684 |  | 
|---|
| 2685 | # We cannot use a suffix rule to build info files with an empty | 
|---|
| 2686 | # extension.  Otherwise we would output a single suffix inference | 
|---|
| 2687 | # rule, with separate dependencies, as in | 
|---|
| 2688 | # | 
|---|
| 2689 | #    .texi: | 
|---|
| 2690 | #             $(MAKEINFO) ... | 
|---|
| 2691 | #    foo.info: foo.texi | 
|---|
| 2692 | # | 
|---|
| 2693 | # which confuse Solaris make.  (See the Autoconf manual for | 
|---|
| 2694 | # details.)  Therefore we use a specific rule in this case.  This | 
|---|
| 2695 | # applies to info files only (dvi and pdf files always have an | 
|---|
| 2696 | # extension). | 
|---|
| 2697 | my $generic_info = ($generic && $dsfx) ? 1 : 0; | 
|---|
| 2698 |  | 
|---|
| 2699 | # If the resulting file lie into a subdirectory, | 
|---|
| 2700 | # make sure this directory will exist. | 
|---|
| 2701 | my $dirstamp = require_build_directory_maybe ($dest); | 
|---|
| 2702 |  | 
|---|
| 2703 | my $dipfx = ($insrc ? '$(srcdir)/' : '') . $dpfx; | 
|---|
| 2704 |  | 
|---|
| 2705 | $output_rules .= file_contents ('texibuild', | 
|---|
| 2706 | new Automake::Location, | 
|---|
| 2707 | DEPS             => "@deps", | 
|---|
| 2708 | DEST_PREFIX      => $dpfx, | 
|---|
| 2709 | DEST_INFO_PREFIX => $dipfx, | 
|---|
| 2710 | DEST_SUFFIX      => $dsfx, | 
|---|
| 2711 | DIRSTAMP         => $dirstamp, | 
|---|
| 2712 | GENERIC          => $generic, | 
|---|
| 2713 | GENERIC_INFO     => $generic_info, | 
|---|
| 2714 | INSRC            => $insrc, | 
|---|
| 2715 | MAKEINFOFLAGS    => $makeinfoflags, | 
|---|
| 2716 | SOURCE           => ($generic | 
|---|
| 2717 | ? '$<' : $source), | 
|---|
| 2718 | SOURCE_INFO      => ($generic_info | 
|---|
| 2719 | ? '$<' : $source), | 
|---|
| 2720 | SOURCE_REAL      => $source, | 
|---|
| 2721 | SOURCE_SUFFIX    => $ssfx, | 
|---|
| 2722 | ); | 
|---|
| 2723 | return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html"); | 
|---|
| 2724 | } | 
|---|
| 2725 |  | 
|---|
| 2726 |  | 
|---|
| 2727 | # $TEXICLEANS | 
|---|
| 2728 | # handle_texinfo_helper ($info_texinfos) | 
|---|
| 2729 | # -------------------------------------- | 
|---|
| 2730 | # Handle all Texinfo source; helper for handle_texinfo. | 
|---|
| 2731 | sub handle_texinfo_helper ($) | 
|---|
| 2732 | { | 
|---|
| 2733 | my ($info_texinfos) = @_; | 
|---|
| 2734 | my (@infobase, @info_deps_list, @texi_deps); | 
|---|
| 2735 | my %versions; | 
|---|
| 2736 | my $done = 0; | 
|---|
| 2737 | my @texi_cleans; | 
|---|
| 2738 |  | 
|---|
| 2739 | # Build a regex matching user-cleaned files. | 
|---|
| 2740 | my $d = var 'DISTCLEANFILES'; | 
|---|
| 2741 | my $c = var 'CLEANFILES'; | 
|---|
| 2742 | my @f = (); | 
|---|
| 2743 | push @f, $d->value_as_list_recursive (inner_expand => 1) if $d; | 
|---|
| 2744 | push @f, $c->value_as_list_recursive (inner_expand => 1) if $c; | 
|---|
| 2745 | @f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f; | 
|---|
| 2746 | my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$'; | 
|---|
| 2747 |  | 
|---|
| 2748 | foreach my $texi | 
|---|
| 2749 | ($info_texinfos->value_as_list_recursive (inner_expand => 1)) | 
|---|
| 2750 | { | 
|---|
| 2751 | my $infobase = $texi; | 
|---|
| 2752 | $infobase =~ s/\.(txi|texinfo|texi)$//; | 
|---|
| 2753 |  | 
|---|
| 2754 | if ($infobase eq $texi) | 
|---|
| 2755 | { | 
|---|
| 2756 | # FIXME: report line number. | 
|---|
| 2757 | err_am "texinfo file `$texi' has unrecognized extension"; | 
|---|
| 2758 | next; | 
|---|
| 2759 | } | 
|---|
| 2760 |  | 
|---|
| 2761 | push @infobase, $infobase; | 
|---|
| 2762 |  | 
|---|
| 2763 | # If 'version.texi' is referenced by input file, then include | 
|---|
| 2764 | # automatic versioning capability. | 
|---|
| 2765 | my ($out_file, $vtexi, @clean_files) = | 
|---|
| 2766 | scan_texinfo_file ("$relative_dir/$texi") | 
|---|
| 2767 | or next; | 
|---|
| 2768 | push (@texi_cleans, @clean_files); | 
|---|
| 2769 |  | 
|---|
| 2770 | # If the Texinfo source is in a subdirectory, create the | 
|---|
| 2771 | # resulting info in this subdirectory.  If it is in the current | 
|---|
| 2772 | # directory, try hard to not prefix "./" because it breaks the | 
|---|
| 2773 | # generic rules. | 
|---|
| 2774 | my $outdir = dirname ($texi) . '/'; | 
|---|
| 2775 | $outdir = "" if $outdir eq './'; | 
|---|
| 2776 | $out_file =  $outdir . $out_file; | 
|---|
| 2777 |  | 
|---|
| 2778 | # Until Automake 1.6.3, .info files were built in the | 
|---|
| 2779 | # source tree.  This was an obstacle to the support of | 
|---|
| 2780 | # non-distributed .info files, and non-distributed .texi | 
|---|
| 2781 | # files. | 
|---|
| 2782 | # | 
|---|
| 2783 | # * Non-distributed .texi files is important in some packages | 
|---|
| 2784 | #   where .texi files are built at make time, probably using | 
|---|
| 2785 | #   other binaries built in the package itself, maybe using | 
|---|
| 2786 | #   tools or information found on the build host.  Because | 
|---|
| 2787 | #   these files are not distributed they are always rebuilt | 
|---|
| 2788 | #   at make time; they should therefore not lie in the source | 
|---|
| 2789 | #   directory.  One plan was to support this using | 
|---|
| 2790 | #   nodist_info_TEXINFOS or something similar.  (Doing this | 
|---|
| 2791 | #   requires some sanity checks.  For instance Automake should | 
|---|
| 2792 | #   not allow: | 
|---|
| 2793 | #      dist_info_TEXINFO = foo.texi | 
|---|
| 2794 | #      nodist_foo_TEXINFO = included.texi | 
|---|
| 2795 | #   because a distributed file should never depend on a | 
|---|
| 2796 | #   non-distributed file.) | 
|---|
| 2797 | # | 
|---|
| 2798 | # * If .texi files are not distributed, then .info files should | 
|---|
| 2799 | #   not be distributed either.  There are also cases where one | 
|---|
| 2800 | #   want to distribute .texi files, but do not want to | 
|---|
| 2801 | #   distribute the .info files.  For instance the Texinfo package | 
|---|
| 2802 | #   distributes the tool used to build these files; it would | 
|---|
| 2803 | #   be a waste of space to distribute them.  It's not clear | 
|---|
| 2804 | #   which syntax we should use to indicate that .info files should | 
|---|
| 2805 | #   not be distributed.  Akim Demaille suggested that eventually | 
|---|
| 2806 | #   we switch to a new syntax: | 
|---|
| 2807 | #   |  Maybe we should take some inspiration from what's already | 
|---|
| 2808 | #   |  done in the rest of Automake.  Maybe there is too much | 
|---|
| 2809 | #   |  syntactic sugar here, and you want | 
|---|
| 2810 | #   |     nodist_INFO = bar.info | 
|---|
| 2811 | #   |     dist_bar_info_SOURCES = bar.texi | 
|---|
| 2812 | #   |     bar_texi_DEPENDENCIES = foo.texi | 
|---|
| 2813 | #   |  with a bit of magic to have bar.info represent the whole | 
|---|
| 2814 | #   |  bar*info set.  That's a lot more verbose that the current | 
|---|
| 2815 | #   |  situation, but it is # not new, hence the user has less | 
|---|
| 2816 | #   |  to learn. | 
|---|
| 2817 | #   | | 
|---|
| 2818 | #   |  But there is still too much room for meaningless specs: | 
|---|
| 2819 | #   |     nodist_INFO = bar.info | 
|---|
| 2820 | #   |     dist_bar_info_SOURCES = bar.texi | 
|---|
| 2821 | #   |     dist_PS = bar.ps something-written-by-hand.ps | 
|---|
| 2822 | #   |     nodist_bar_ps_SOURCES = bar.texi | 
|---|
| 2823 | #   |     bar_texi_DEPENDENCIES = foo.texi | 
|---|
| 2824 | #   |  here bar.texi is dist_ in line 2, and nodist_ in 4. | 
|---|
| 2825 | # | 
|---|
| 2826 | # Back to the point, it should be clear that in order to support | 
|---|
| 2827 | # non-distributed .info files, we need to build them in the | 
|---|
| 2828 | # build tree, not in the source tree (non-distributed .texi | 
|---|
| 2829 | # files are less of a problem, because we do not output build | 
|---|
| 2830 | # rules for them).  In Automake 1.7 .info build rules have been | 
|---|
| 2831 | # largely cleaned up so that .info files get always build in the | 
|---|
| 2832 | # build tree, even when distributed.  The idea was that | 
|---|
| 2833 | #   (1) if during a VPATH build the .info file was found to be | 
|---|
| 2834 | #       absent or out-of-date (in the source tree or in the | 
|---|
| 2835 | #       build tree), Make would rebuild it in the build tree. | 
|---|
| 2836 | #       If an up-to-date source-tree of the .info file existed, | 
|---|
| 2837 | #       make would not rebuild it in the build tree. | 
|---|
| 2838 | #   (2) having two copies of .info files, one in the source tree | 
|---|
| 2839 | #       and one (newer) in the build tree is not a problem | 
|---|
| 2840 | #       because `make dist' always pick files in the build tree | 
|---|
| 2841 | #       first. | 
|---|
| 2842 | # However it turned out the be a bad idea for several reasons: | 
|---|
| 2843 | #   * Tru64, OpenBSD, and FreeBSD (not NetBSD) Make do not behave | 
|---|
| 2844 | #     like GNU Make on point (1) above.  These implementations | 
|---|
| 2845 | #     of Make would always rebuild .info files in the build | 
|---|
| 2846 | #     tree, even if such files were up to date in the source | 
|---|
| 2847 | #     tree.  Consequently, it was impossible to perform a VPATH | 
|---|
| 2848 | #     build of a package containing Texinfo files using these | 
|---|
| 2849 | #     Make implementations. | 
|---|
| 2850 | #     (Refer to the Autoconf Manual, section "Limitation of | 
|---|
| 2851 | #     Make", paragraph "VPATH", item "target lookup", for | 
|---|
| 2852 | #     an account of the differences between these | 
|---|
| 2853 | #     implementations.) | 
|---|
| 2854 | #   * The GNU Coding Standards require these files to be built | 
|---|
| 2855 | #     in the source-tree (when they are distributed, that is). | 
|---|
| 2856 | #   * Keeping a fresher copy of distributed files in the | 
|---|
| 2857 | #     build tree can be annoying during development because | 
|---|
| 2858 | #     - if the files is kept under CVS, you really want it | 
|---|
| 2859 | #       to be updated in the source tree | 
|---|
| 2860 | #     - it is confusing that `make distclean' does not erase | 
|---|
| 2861 | #       all files in the build tree. | 
|---|
| 2862 | # | 
|---|
| 2863 | # Consequently, starting with Automake 1.8, .info files are | 
|---|
| 2864 | # built in the source tree again.  Because we still plan to | 
|---|
| 2865 | # support non-distributed .info files at some point, we | 
|---|
| 2866 | # have a single variable ($INSRC) that controls whether | 
|---|
| 2867 | # the current .info file must be built in the source tree | 
|---|
| 2868 | # or in the build tree.  Actually this variable is switched | 
|---|
| 2869 | # off for .info files that appear to be cleaned; this is | 
|---|
| 2870 | # for backward compatibility with package such as Texinfo, | 
|---|
| 2871 | # which do things like | 
|---|
| 2872 | #   info_TEXINFOS = texinfo.txi info-stnd.texi info.texi | 
|---|
| 2873 | #   DISTCLEANFILES = texinfo texinfo-* info*.info* | 
|---|
| 2874 | #   # Do not create info files for distribution. | 
|---|
| 2875 | #   dist-info: | 
|---|
| 2876 | # in order not to distribute .info files. | 
|---|
| 2877 | my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1; | 
|---|
| 2878 |  | 
|---|
| 2879 | my $soutdir = '$(srcdir)/' . $outdir; | 
|---|
| 2880 | $outdir = $soutdir if $insrc; | 
|---|
| 2881 |  | 
|---|
| 2882 | # If user specified file_TEXINFOS, then use that as explicit | 
|---|
| 2883 | # dependency list. | 
|---|
| 2884 | @texi_deps = (); | 
|---|
| 2885 | push (@texi_deps, "$soutdir$vtexi") if $vtexi; | 
|---|
| 2886 |  | 
|---|
| 2887 | my $canonical = canonicalize ($infobase); | 
|---|
| 2888 | if (var ($canonical . "_TEXINFOS")) | 
|---|
| 2889 | { | 
|---|
| 2890 | push (@texi_deps, '$(' . $canonical . '_TEXINFOS)'); | 
|---|
| 2891 | push_dist_common ('$(' . $canonical . '_TEXINFOS)'); | 
|---|
| 2892 | } | 
|---|
| 2893 |  | 
|---|
| 2894 | my ($dirstamp, @cfiles) = | 
|---|
| 2895 | output_texinfo_build_rules ($texi, $out_file, $insrc, @texi_deps); | 
|---|
| 2896 | push (@texi_cleans, @cfiles); | 
|---|
| 2897 |  | 
|---|
| 2898 | push (@info_deps_list, $out_file); | 
|---|
| 2899 |  | 
|---|
| 2900 | # If a vers*.texi file is needed, emit the rule. | 
|---|
| 2901 | if ($vtexi) | 
|---|
| 2902 | { | 
|---|
| 2903 | err_am ("`$vtexi', included in `$texi', " | 
|---|
| 2904 | . "also included in `$versions{$vtexi}'") | 
|---|
| 2905 | if defined $versions{$vtexi}; | 
|---|
| 2906 | $versions{$vtexi} = $texi; | 
|---|
| 2907 |  | 
|---|
| 2908 | # We number the stamp-vti files.  This is doable since the | 
|---|
| 2909 | # actual names don't matter much.  We only number starting | 
|---|
| 2910 | # with the second one, so that the common case looks nice. | 
|---|
| 2911 | my $vti = ($done ? $done : 'vti'); | 
|---|
| 2912 | ++$done; | 
|---|
| 2913 |  | 
|---|
| 2914 | # This is ugly, but it is our historical practice. | 
|---|
| 2915 | if ($config_aux_dir_set_in_configure_in) | 
|---|
| 2916 | { | 
|---|
| 2917 | require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, | 
|---|
| 2918 | 'mdate-sh'); | 
|---|
| 2919 | } | 
|---|
| 2920 | else | 
|---|
| 2921 | { | 
|---|
| 2922 | require_file_with_macro (TRUE, 'info_TEXINFOS', | 
|---|
| 2923 | FOREIGN, 'mdate-sh'); | 
|---|
| 2924 | } | 
|---|
| 2925 |  | 
|---|
| 2926 | my $conf_dir; | 
|---|
| 2927 | if ($config_aux_dir_set_in_configure_in) | 
|---|
| 2928 | { | 
|---|
| 2929 | $conf_dir = $config_aux_dir; | 
|---|
| 2930 | $conf_dir .= '/' unless $conf_dir =~ /\/$/; | 
|---|
| 2931 | } | 
|---|
| 2932 | else | 
|---|
| 2933 | { | 
|---|
| 2934 | $conf_dir = '$(srcdir)/'; | 
|---|
| 2935 | } | 
|---|
| 2936 | $output_rules .= file_contents ('texi-vers', | 
|---|
| 2937 | new Automake::Location, | 
|---|
| 2938 | TEXI     => $texi, | 
|---|
| 2939 | VTI      => $vti, | 
|---|
| 2940 | STAMPVTI => "${soutdir}stamp-$vti", | 
|---|
| 2941 | VTEXI    => "$soutdir$vtexi", | 
|---|
| 2942 | MDDIR    => $conf_dir, | 
|---|
| 2943 | DIRSTAMP => $dirstamp); | 
|---|
| 2944 | } | 
|---|
| 2945 | } | 
|---|
| 2946 |  | 
|---|
| 2947 | # Handle location of texinfo.tex. | 
|---|
| 2948 | my $need_texi_file = 0; | 
|---|
| 2949 | my $texinfodir; | 
|---|
| 2950 | if (var ('TEXINFO_TEX')) | 
|---|
| 2951 | { | 
|---|
| 2952 | # The user defined TEXINFO_TEX so assume he knows what he is | 
|---|
| 2953 | # doing. | 
|---|
| 2954 | $texinfodir = ('$(srcdir)/' | 
|---|
| 2955 | . dirname (variable_value ('TEXINFO_TEX'))); | 
|---|
| 2956 | } | 
|---|
| 2957 | elsif (option 'cygnus') | 
|---|
| 2958 | { | 
|---|
| 2959 | $texinfodir = '$(top_srcdir)/../texinfo'; | 
|---|
| 2960 | define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL); | 
|---|
| 2961 | } | 
|---|
| 2962 | elsif ($config_aux_dir_set_in_configure_in) | 
|---|
| 2963 | { | 
|---|
| 2964 | $texinfodir = $config_aux_dir; | 
|---|
| 2965 | define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL); | 
|---|
| 2966 | $need_texi_file = 2; # so that we require_conf_file later | 
|---|
| 2967 | } | 
|---|
| 2968 | else | 
|---|
| 2969 | { | 
|---|
| 2970 | $texinfodir = '$(srcdir)'; | 
|---|
| 2971 | $need_texi_file = 1; | 
|---|
| 2972 | } | 
|---|
| 2973 | define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL); | 
|---|
| 2974 |  | 
|---|
| 2975 | push (@dist_targets, 'dist-info'); | 
|---|
| 2976 |  | 
|---|
| 2977 | if (! option 'no-installinfo') | 
|---|
| 2978 | { | 
|---|
| 2979 | # Make sure documentation is made and installed first.  Use | 
|---|
| 2980 | # $(INFO_DEPS), not 'info', because otherwise recursive makes | 
|---|
| 2981 | # get run twice during "make all". | 
|---|
| 2982 | unshift (@all, '$(INFO_DEPS)'); | 
|---|
| 2983 | } | 
|---|
| 2984 |  | 
|---|
| 2985 | define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL); | 
|---|
| 2986 | define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL); | 
|---|
| 2987 | define_files_variable ("PSS", @infobase, 'ps', INTERNAL); | 
|---|
| 2988 | define_files_variable ("HTMLS", @infobase, 'html', INTERNAL); | 
|---|
| 2989 |  | 
|---|
| 2990 | # This next isn't strictly needed now -- the places that look here | 
|---|
| 2991 | # could easily be changed to look in info_TEXINFOS.  But this is | 
|---|
| 2992 | # probably better, in case noinst_TEXINFOS is ever supported. | 
|---|
| 2993 | define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL); | 
|---|
| 2994 |  | 
|---|
| 2995 | # Do some error checking.  Note that this file is not required | 
|---|
| 2996 | # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly | 
|---|
| 2997 | # up above. | 
|---|
| 2998 | if ($need_texi_file && ! option 'no-texinfo.tex') | 
|---|
| 2999 | { | 
|---|
| 3000 | if ($need_texi_file > 1) | 
|---|
| 3001 | { | 
|---|
| 3002 | require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, | 
|---|
| 3003 | 'texinfo.tex'); | 
|---|
| 3004 | } | 
|---|
| 3005 | else | 
|---|
| 3006 | { | 
|---|
| 3007 | require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, | 
|---|
| 3008 | 'texinfo.tex'); | 
|---|
| 3009 | } | 
|---|
| 3010 | } | 
|---|
| 3011 |  | 
|---|
| 3012 | return makefile_wrap ("", "\t  ", @texi_cleans); | 
|---|
| 3013 | } | 
|---|
| 3014 |  | 
|---|
| 3015 |  | 
|---|
| 3016 | # handle_texinfo () | 
|---|
| 3017 | # ----------------- | 
|---|
| 3018 | # Handle all Texinfo source. | 
|---|
| 3019 | sub handle_texinfo () | 
|---|
| 3020 | { | 
|---|
| 3021 | reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'"; | 
|---|
| 3022 | # FIXME: I think this is an obsolete future feature name. | 
|---|
| 3023 | reject_var 'html_TEXINFOS', "HTML generation not yet supported"; | 
|---|
| 3024 |  | 
|---|
| 3025 | my $info_texinfos = var ('info_TEXINFOS'); | 
|---|
| 3026 | my $texiclean = ""; | 
|---|
| 3027 | if ($info_texinfos) | 
|---|
| 3028 | { | 
|---|
| 3029 | $texiclean = handle_texinfo_helper ($info_texinfos); | 
|---|
| 3030 | } | 
|---|
| 3031 | $output_rules .=  file_contents ('texinfos', | 
|---|
| 3032 | new Automake::Location, | 
|---|
| 3033 | TEXICLEAN     => $texiclean, | 
|---|
| 3034 | 'LOCAL-TEXIS' => !!$info_texinfos); | 
|---|
| 3035 | } | 
|---|
| 3036 |  | 
|---|
| 3037 |  | 
|---|
| 3038 | # Handle any man pages. | 
|---|
| 3039 | sub handle_man_pages | 
|---|
| 3040 | { | 
|---|
| 3041 | reject_var 'MANS', "`MANS' is an anachronism; use `man_MANS'"; | 
|---|
| 3042 |  | 
|---|
| 3043 | # Find all the sections in use.  We do this by first looking for | 
|---|
| 3044 | # "standard" sections, and then looking for any additional | 
|---|
| 3045 | # sections used in man_MANS. | 
|---|
| 3046 | my (%sections, %vlist); | 
|---|
| 3047 | # We handle nodist_ for uniformity.  man pages aren't distributed | 
|---|
| 3048 | # by default so it isn't actually very important. | 
|---|
| 3049 | foreach my $pfx ('', 'dist_', 'nodist_') | 
|---|
| 3050 | { | 
|---|
| 3051 | # Add more sections as needed. | 
|---|
| 3052 | foreach my $section ('0'..'9', 'n', 'l') | 
|---|
| 3053 | { | 
|---|
| 3054 | my $varname = $pfx . 'man' . $section . '_MANS'; | 
|---|
| 3055 | if (var ($varname)) | 
|---|
| 3056 | { | 
|---|
| 3057 | $sections{$section} = 1; | 
|---|
| 3058 | $varname = '$(' . $varname . ')'; | 
|---|
| 3059 | $vlist{$varname} = 1; | 
|---|
| 3060 |  | 
|---|
| 3061 | &push_dist_common ($varname) | 
|---|
| 3062 | if $pfx eq 'dist_'; | 
|---|
| 3063 | } | 
|---|
| 3064 | } | 
|---|
| 3065 |  | 
|---|
| 3066 | my $varname = $pfx . 'man_MANS'; | 
|---|
| 3067 | my $var = var ($varname); | 
|---|
| 3068 | if ($var) | 
|---|
| 3069 | { | 
|---|
| 3070 | foreach ($var->value_as_list_recursive) | 
|---|
| 3071 | { | 
|---|
| 3072 | # A page like `foo.1c' goes into man1dir. | 
|---|
| 3073 | if (/\.([0-9a-z])([a-z]*)$/) | 
|---|
| 3074 | { | 
|---|
| 3075 | $sections{$1} = 1; | 
|---|
| 3076 | } | 
|---|
| 3077 | } | 
|---|
| 3078 |  | 
|---|
| 3079 | $varname = '$(' . $varname . ')'; | 
|---|
| 3080 | $vlist{$varname} = 1; | 
|---|
| 3081 | &push_dist_common ($varname) | 
|---|
| 3082 | if $pfx eq 'dist_'; | 
|---|
| 3083 | } | 
|---|
| 3084 | } | 
|---|
| 3085 |  | 
|---|
| 3086 | return unless %sections; | 
|---|
| 3087 |  | 
|---|
| 3088 | # Now for each section, generate an install and uninstall rule. | 
|---|
| 3089 | # Sort sections so output is deterministic. | 
|---|
| 3090 | foreach my $section (sort keys %sections) | 
|---|
| 3091 | { | 
|---|
| 3092 | $output_rules .= &file_contents ('mans', | 
|---|
| 3093 | new Automake::Location, | 
|---|
| 3094 | SECTION => $section); | 
|---|
| 3095 | } | 
|---|
| 3096 |  | 
|---|
| 3097 | my @mans = sort keys %vlist; | 
|---|
| 3098 | $output_vars .= file_contents ('mans-vars', | 
|---|
| 3099 | new Automake::Location, | 
|---|
| 3100 | MANS => "@mans"); | 
|---|
| 3101 |  | 
|---|
| 3102 | push (@all, '$(MANS)') | 
|---|
| 3103 | unless option 'no-installman'; | 
|---|
| 3104 | } | 
|---|
| 3105 |  | 
|---|
| 3106 | # Handle DATA variables. | 
|---|
| 3107 | sub handle_data | 
|---|
| 3108 | { | 
|---|
| 3109 | &am_install_var ('-noextra', '-candist', 'data', 'DATA', | 
|---|
| 3110 | 'data', 'sysconf', 'sharedstate', 'localstate', | 
|---|
| 3111 | 'pkgdata', 'lisp', 'noinst', 'check'); | 
|---|
| 3112 | } | 
|---|
| 3113 |  | 
|---|
| 3114 | # Handle TAGS. | 
|---|
| 3115 | sub handle_tags | 
|---|
| 3116 | { | 
|---|
| 3117 | my @tag_deps = (); | 
|---|
| 3118 | my @ctag_deps = (); | 
|---|
| 3119 | if (var ('SUBDIRS')) | 
|---|
| 3120 | { | 
|---|
| 3121 | $output_rules .= ("tags-recursive:\n" | 
|---|
| 3122 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n" | 
|---|
| 3123 | # Never fail here if a subdir fails; it | 
|---|
| 3124 | # isn't important. | 
|---|
| 3125 | . "\t  test \"\$\$subdir\" = . || (cd \$\$subdir" | 
|---|
| 3126 | . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n" | 
|---|
| 3127 | . "\tdone\n"); | 
|---|
| 3128 | push (@tag_deps, 'tags-recursive'); | 
|---|
| 3129 | &depend ('.PHONY', 'tags-recursive'); | 
|---|
| 3130 |  | 
|---|
| 3131 | $output_rules .= ("ctags-recursive:\n" | 
|---|
| 3132 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n" | 
|---|
| 3133 | # Never fail here if a subdir fails; it | 
|---|
| 3134 | # isn't important. | 
|---|
| 3135 | . "\t  test \"\$\$subdir\" = . || (cd \$\$subdir" | 
|---|
| 3136 | . " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n" | 
|---|
| 3137 | . "\tdone\n"); | 
|---|
| 3138 | push (@ctag_deps, 'ctags-recursive'); | 
|---|
| 3139 | &depend ('.PHONY', 'ctags-recursive'); | 
|---|
| 3140 | } | 
|---|
| 3141 |  | 
|---|
| 3142 | if (&saw_sources_p (1) | 
|---|
| 3143 | || var ('ETAGS_ARGS') | 
|---|
| 3144 | || @tag_deps) | 
|---|
| 3145 | { | 
|---|
| 3146 | my @config; | 
|---|
| 3147 | foreach my $spec (@config_headers) | 
|---|
| 3148 | { | 
|---|
| 3149 | my ($out, @ins) = split_config_file_spec ($spec); | 
|---|
| 3150 | foreach my $in (@ins) | 
|---|
| 3151 | { | 
|---|
| 3152 | # If the config header source is in this directory, | 
|---|
| 3153 | # require it. | 
|---|
| 3154 | push @config, basename ($in) | 
|---|
| 3155 | if $relative_dir eq dirname ($in); | 
|---|
| 3156 | } | 
|---|
| 3157 | } | 
|---|
| 3158 | $output_rules .= &file_contents ('tags', | 
|---|
| 3159 | new Automake::Location, | 
|---|
| 3160 | CONFIG    => "@config", | 
|---|
| 3161 | TAGSDIRS  => "@tag_deps", | 
|---|
| 3162 | CTAGSDIRS => "@ctag_deps"); | 
|---|
| 3163 |  | 
|---|
| 3164 | set_seen 'TAGS_DEPENDENCIES'; | 
|---|
| 3165 | } | 
|---|
| 3166 | elsif (reject_var ('TAGS_DEPENDENCIES', | 
|---|
| 3167 | "doesn't make sense to define `TAGS_DEPENDENCIES'" | 
|---|
| 3168 | . "without\nsources or `ETAGS_ARGS'")) | 
|---|
| 3169 | { | 
|---|
| 3170 | } | 
|---|
| 3171 | else | 
|---|
| 3172 | { | 
|---|
| 3173 | # Every Makefile must define some sort of TAGS rule. | 
|---|
| 3174 | # Otherwise, it would be possible for a top-level "make TAGS" | 
|---|
| 3175 | # to fail because some subdirectory failed. | 
|---|
| 3176 | $output_rules .= "tags: TAGS\nTAGS:\n\n"; | 
|---|
| 3177 | # Ditto ctags. | 
|---|
| 3178 | $output_rules .= "ctags: CTAGS\nCTAGS:\n\n"; | 
|---|
| 3179 | } | 
|---|
| 3180 | } | 
|---|
| 3181 |  | 
|---|
| 3182 | # Handle multilib support. | 
|---|
| 3183 | sub handle_multilib | 
|---|
| 3184 | { | 
|---|
| 3185 | if ($seen_multilib && $relative_dir eq '.') | 
|---|
| 3186 | { | 
|---|
| 3187 | $output_rules .= &file_contents ('multilib', new Automake::Location); | 
|---|
| 3188 | push (@all, 'all-multi'); | 
|---|
| 3189 | } | 
|---|
| 3190 | } | 
|---|
| 3191 |  | 
|---|
| 3192 |  | 
|---|
| 3193 | # $BOOLEAN | 
|---|
| 3194 | # &for_dist_common ($A, $B) | 
|---|
| 3195 | # ------------------------- | 
|---|
| 3196 | # Subroutine for &handle_dist: sort files to dist. | 
|---|
| 3197 | # | 
|---|
| 3198 | # We put README first because it then becomes easier to make a | 
|---|
| 3199 | # Usenet-compliant shar file (in these, README must be first). | 
|---|
| 3200 | # | 
|---|
| 3201 | # FIXME: do more ordering of files here. | 
|---|
| 3202 | sub for_dist_common | 
|---|
| 3203 | { | 
|---|
| 3204 | return 0 | 
|---|
| 3205 | if $a eq $b; | 
|---|
| 3206 | return -1 | 
|---|
| 3207 | if $a eq 'README'; | 
|---|
| 3208 | return 1 | 
|---|
| 3209 | if $b eq 'README'; | 
|---|
| 3210 | return $a cmp $b; | 
|---|
| 3211 | } | 
|---|
| 3212 |  | 
|---|
| 3213 |  | 
|---|
| 3214 | # handle_dist | 
|---|
| 3215 | # ----------- | 
|---|
| 3216 | # Handle 'dist' target. | 
|---|
| 3217 | sub handle_dist () | 
|---|
| 3218 | { | 
|---|
| 3219 | # Substutions for distdit.am | 
|---|
| 3220 | my %transform; | 
|---|
| 3221 |  | 
|---|
| 3222 | # Define DIST_SUBDIRS.  This must always be done, regardless of the | 
|---|
| 3223 | # no-dist setting: target like `distclean' or `maintainer-clean' use it. | 
|---|
| 3224 | my $subdirs = var ('SUBDIRS'); | 
|---|
| 3225 | if ($subdirs) | 
|---|
| 3226 | { | 
|---|
| 3227 | # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS | 
|---|
| 3228 | # to all possible directories, and use it.  If DIST_SUBDIRS is | 
|---|
| 3229 | # defined, just use it. | 
|---|
| 3230 | my $dist_subdir_name; | 
|---|
| 3231 | # Note that we check DIST_SUBDIRS first on purpose, so that | 
|---|
| 3232 | # we don't call has_conditional_contents for now reason. | 
|---|
| 3233 | # (In the past one project used so many conditional subdirectories | 
|---|
| 3234 | # that calling has_conditional_contents on SUBDIRS caused | 
|---|
| 3235 | # automake to grow to 150Mb -- this should not happen with | 
|---|
| 3236 | # the current implementation of has_conditional_contents, | 
|---|
| 3237 | # but it's more efficient to avoid the call anyway.) | 
|---|
| 3238 | if (var ('DIST_SUBDIRS')) | 
|---|
| 3239 | { | 
|---|
| 3240 | $dist_subdir_name = 'DIST_SUBDIRS'; | 
|---|
| 3241 | } | 
|---|
| 3242 | elsif ($subdirs->has_conditional_contents) | 
|---|
| 3243 | { | 
|---|
| 3244 | $dist_subdir_name = 'DIST_SUBDIRS'; | 
|---|
| 3245 | define_pretty_variable | 
|---|
| 3246 | ('DIST_SUBDIRS', TRUE, INTERNAL, | 
|---|
| 3247 | uniq ($subdirs->value_as_list_recursive)); | 
|---|
| 3248 | } | 
|---|
| 3249 | else | 
|---|
| 3250 | { | 
|---|
| 3251 | $dist_subdir_name = 'SUBDIRS'; | 
|---|
| 3252 | # We always define this because that is what `distclean' | 
|---|
| 3253 | # wants. | 
|---|
| 3254 | define_pretty_variable ('DIST_SUBDIRS', TRUE, INTERNAL, | 
|---|
| 3255 | '$(SUBDIRS)'); | 
|---|
| 3256 | } | 
|---|
| 3257 |  | 
|---|
| 3258 | $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name; | 
|---|
| 3259 | } | 
|---|
| 3260 |  | 
|---|
| 3261 | # The remaining definitions are only required when a dist target is used. | 
|---|
| 3262 | return if option 'no-dist'; | 
|---|
| 3263 |  | 
|---|
| 3264 | # At least one of the archive formats must be enabled. | 
|---|
| 3265 | if ($relative_dir eq '.') | 
|---|
| 3266 | { | 
|---|
| 3267 | my $archive_defined = option 'no-dist-gzip' ? 0 : 1; | 
|---|
| 3268 | $archive_defined ||= | 
|---|
| 3269 | grep { option "dist-$_" } ('shar', 'zip', 'tarZ', 'bzip2'); | 
|---|
| 3270 | error (option 'no-dist-gzip', | 
|---|
| 3271 | "no-dist-gzip specified but no dist-* specified, " | 
|---|
| 3272 | . "at least one archive format must be enabled") | 
|---|
| 3273 | unless $archive_defined; | 
|---|
| 3274 | } | 
|---|
| 3275 |  | 
|---|
| 3276 | # Look for common files that should be included in distribution. | 
|---|
| 3277 | # If the aux dir is set, and it does not have a Makefile.am, then | 
|---|
| 3278 | # we check for these files there as well. | 
|---|
| 3279 | my $check_aux = 0; | 
|---|
| 3280 | my $auxdir = ''; | 
|---|
| 3281 | if ($relative_dir eq '.' | 
|---|
| 3282 | && $config_aux_dir_set_in_configure_in) | 
|---|
| 3283 | { | 
|---|
| 3284 | ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,; | 
|---|
| 3285 | if (! &is_make_dir ($auxdir)) | 
|---|
| 3286 | { | 
|---|
| 3287 | $check_aux = 1; | 
|---|
| 3288 | } | 
|---|
| 3289 | } | 
|---|
| 3290 | foreach my $cfile (@common_files) | 
|---|
| 3291 | { | 
|---|
| 3292 | if (-f ($relative_dir . "/" . $cfile) | 
|---|
| 3293 | # The file might be absent, but if it can be built it's ok. | 
|---|
| 3294 | || rule $cfile) | 
|---|
| 3295 | { | 
|---|
| 3296 | &push_dist_common ($cfile); | 
|---|
| 3297 | } | 
|---|
| 3298 |  | 
|---|
| 3299 | # Don't use `elsif' here because a file might meaningfully | 
|---|
| 3300 | # appear in both directories. | 
|---|
| 3301 | if ($check_aux && -f ($auxdir . '/' . $cfile)) | 
|---|
| 3302 | { | 
|---|
| 3303 | &push_dist_common ($auxdir . '/' . $cfile); | 
|---|
| 3304 | } | 
|---|
| 3305 | } | 
|---|
| 3306 |  | 
|---|
| 3307 | # We might copy elements from $configure_dist_common to | 
|---|
| 3308 | # %dist_common if we think we need to.  If the file appears in our | 
|---|
| 3309 | # directory, we would have discovered it already, so we don't | 
|---|
| 3310 | # check that.  But if the file is in a subdir without a Makefile, | 
|---|
| 3311 | # we want to distribute it here if we are doing `.'.  Ugly! | 
|---|
| 3312 | if ($relative_dir eq '.') | 
|---|
| 3313 | { | 
|---|
| 3314 | foreach my $file (split (' ' , $configure_dist_common)) | 
|---|
| 3315 | { | 
|---|
| 3316 | push_dist_common ($file) | 
|---|
| 3317 | unless is_make_dir (dirname ($file)); | 
|---|
| 3318 | } | 
|---|
| 3319 | } | 
|---|
| 3320 |  | 
|---|
| 3321 | # Files to distributed.  Don't use ->value_as_list_recursive | 
|---|
| 3322 | # as it recursively expands `$(dist_pkgdata_DATA)' etc. | 
|---|
| 3323 | my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value); | 
|---|
| 3324 | @dist_common = uniq (sort for_dist_common (@dist_common)); | 
|---|
| 3325 | variable_delete 'DIST_COMMON'; | 
|---|
| 3326 | define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common); | 
|---|
| 3327 |  | 
|---|
| 3328 | # Now that we've processed DIST_COMMON, disallow further attempts | 
|---|
| 3329 | # to set it. | 
|---|
| 3330 | $handle_dist_run = 1; | 
|---|
| 3331 |  | 
|---|
| 3332 | # Scan EXTRA_DIST to see if we need to distribute anything from a | 
|---|
| 3333 | # subdir.  If so, add it to the list.  I didn't want to do this | 
|---|
| 3334 | # originally, but there were so many requests that I finally | 
|---|
| 3335 | # relented. | 
|---|
| 3336 | my $extra_dist = var ('EXTRA_DIST'); | 
|---|
| 3337 | if ($extra_dist) | 
|---|
| 3338 | { | 
|---|
| 3339 | # FIXME: This should be fixed to work with conditions.  That | 
|---|
| 3340 | # will require only making the entries in %dist_dirs under the | 
|---|
| 3341 | # appropriate condition.  This is meaningful if the nature of | 
|---|
| 3342 | # the distribution should depend upon the configure options | 
|---|
| 3343 | # used. | 
|---|
| 3344 | foreach ($extra_dist->value_as_list_recursive) | 
|---|
| 3345 | { | 
|---|
| 3346 | next if /^\@.*\@$/; | 
|---|
| 3347 | next unless s,/+[^/]+$,,; | 
|---|
| 3348 | $dist_dirs{$_} = 1 | 
|---|
| 3349 | unless $_ eq '.'; | 
|---|
| 3350 | } | 
|---|
| 3351 | } | 
|---|
| 3352 |  | 
|---|
| 3353 | # We have to check DIST_COMMON for extra directories in case the | 
|---|
| 3354 | # user put a source used in AC_OUTPUT into a subdir. | 
|---|
| 3355 | my $topsrcdir = backname ($relative_dir); | 
|---|
| 3356 | foreach (rvar ('DIST_COMMON')->value_as_list_recursive) | 
|---|
| 3357 | { | 
|---|
| 3358 | next if /^\@.*\@$/; | 
|---|
| 3359 | s/\$\(top_srcdir\)/$topsrcdir/; | 
|---|
| 3360 | s/\$\(srcdir\)/./; | 
|---|
| 3361 | # Strip any leading `./'. | 
|---|
| 3362 | s,^(:?\./+)*,,; | 
|---|
| 3363 | next unless s,/+[^/]+$,,; | 
|---|
| 3364 | $dist_dirs{$_} = 1 | 
|---|
| 3365 | unless $_ eq '.'; | 
|---|
| 3366 | } | 
|---|
| 3367 |  | 
|---|
| 3368 | $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook'; | 
|---|
| 3369 | $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external; | 
|---|
| 3370 |  | 
|---|
| 3371 | # Prepend $(distdir) to each directory given. | 
|---|
| 3372 | my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs; | 
|---|
| 3373 | $transform{'DISTDIRS'} = join (' ', sort keys %rewritten); | 
|---|
| 3374 |  | 
|---|
| 3375 | # If the target `dist-hook' exists, make sure it is run.  This | 
|---|
| 3376 | # allows users to do random weird things to the distribution | 
|---|
| 3377 | # before it is packaged up. | 
|---|
| 3378 | push (@dist_targets, 'dist-hook') | 
|---|
| 3379 | if rule 'dist-hook'; | 
|---|
| 3380 | $transform{'DIST-TARGETS'} = join (' ', @dist_targets); | 
|---|
| 3381 |  | 
|---|
| 3382 | $output_rules .= &file_contents ('distdir', | 
|---|
| 3383 | new Automake::Location, | 
|---|
| 3384 | %transform); | 
|---|
| 3385 | } | 
|---|
| 3386 |  | 
|---|
| 3387 |  | 
|---|
| 3388 | # &handle_subdirs () | 
|---|
| 3389 | # ------------------ | 
|---|
| 3390 | # Handle subdirectories. | 
|---|
| 3391 | sub handle_subdirs () | 
|---|
| 3392 | { | 
|---|
| 3393 | my $subdirs = var ('SUBDIRS'); | 
|---|
| 3394 | return | 
|---|
| 3395 | unless $subdirs; | 
|---|
| 3396 |  | 
|---|
| 3397 | my @subdirs = $subdirs->value_as_list_recursive; | 
|---|
| 3398 | my @dsubdirs = (); | 
|---|
| 3399 | my $dsubdirs = var ('DIST_SUBDIRS'); | 
|---|
| 3400 | @dsubdirs = $dsubdirs->value_as_list_recursive | 
|---|
| 3401 | if $dsubdirs; | 
|---|
| 3402 |  | 
|---|
| 3403 | # If an `obj/' directory exists, BSD make will enter it before | 
|---|
| 3404 | # reading `Makefile'.  Hence the `Makefile' in the current directory | 
|---|
| 3405 | # will not be read. | 
|---|
| 3406 | # | 
|---|
| 3407 | #  % cat Makefile | 
|---|
| 3408 | #  all: | 
|---|
| 3409 | #          echo Hello | 
|---|
| 3410 | #  % cat obj/Makefile | 
|---|
| 3411 | #  all: | 
|---|
| 3412 | #          echo World | 
|---|
| 3413 | #  % make      # GNU make | 
|---|
| 3414 | #  echo Hello | 
|---|
| 3415 | #  Hello | 
|---|
| 3416 | #  % pmake     # BSD make | 
|---|
| 3417 | #  echo World | 
|---|
| 3418 | #  World | 
|---|
| 3419 | msg_var ('portability', 'SUBDIRS', | 
|---|
| 3420 | "naming a subdirectory `obj' causes troubles with BSD make") | 
|---|
| 3421 | if grep ($_ eq 'obj', @subdirs); | 
|---|
| 3422 | msg_var ('portability', 'DIST_SUBDIRS', | 
|---|
| 3423 | "naming a subdirectory `obj' causes troubles with BSD make") | 
|---|
| 3424 | if grep ($_ eq 'obj', @dsubdirs); | 
|---|
| 3425 |  | 
|---|
| 3426 | # Make sure each directory mentioned in SUBDIRS actually exists. | 
|---|
| 3427 | foreach my $dir (@subdirs) | 
|---|
| 3428 | { | 
|---|
| 3429 | # Skip directories substituted by configure. | 
|---|
| 3430 | next if $dir =~ /^\@.*\@$/; | 
|---|
| 3431 |  | 
|---|
| 3432 | if (! -d $relative_dir . '/' . $dir) | 
|---|
| 3433 | { | 
|---|
| 3434 | err_var ('SUBDIRS', "required directory $relative_dir/$dir " | 
|---|
| 3435 | . "does not exist"); | 
|---|
| 3436 | next; | 
|---|
| 3437 | } | 
|---|
| 3438 |  | 
|---|
| 3439 | err_var 'SUBDIRS', "directory should not contain `/'" | 
|---|
| 3440 | if $dir =~ /\//; | 
|---|
| 3441 | } | 
|---|
| 3442 |  | 
|---|
| 3443 | $output_rules .= &file_contents ('subdirs', new Automake::Location); | 
|---|
| 3444 | rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; # Gross! | 
|---|
| 3445 | } | 
|---|
| 3446 |  | 
|---|
| 3447 |  | 
|---|
| 3448 | # ($REGEN, @DEPENDENCIES) | 
|---|
| 3449 | # &scan_aclocal_m4 | 
|---|
| 3450 | # ---------------- | 
|---|
| 3451 | # If aclocal.m4 creation is automated, return the list of its dependencies. | 
|---|
| 3452 | sub scan_aclocal_m4 () | 
|---|
| 3453 | { | 
|---|
| 3454 | my $regen_aclocal = 0; | 
|---|
| 3455 |  | 
|---|
| 3456 | set_seen 'CONFIG_STATUS_DEPENDENCIES'; | 
|---|
| 3457 | set_seen 'CONFIGURE_DEPENDENCIES'; | 
|---|
| 3458 |  | 
|---|
| 3459 | if (-f 'aclocal.m4') | 
|---|
| 3460 | { | 
|---|
| 3461 | &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL); | 
|---|
| 3462 |  | 
|---|
| 3463 | my $aclocal = new Automake::XFile "< aclocal.m4"; | 
|---|
| 3464 | my $line = $aclocal->getline; | 
|---|
| 3465 | $regen_aclocal = $line =~ 'generated automatically by aclocal'; | 
|---|
| 3466 | } | 
|---|
| 3467 |  | 
|---|
| 3468 | my @ac_deps = (); | 
|---|
| 3469 |  | 
|---|
| 3470 | if (set_seen ('ACLOCAL_M4_SOURCES')) | 
|---|
| 3471 | { | 
|---|
| 3472 | push (@ac_deps, '$(ACLOCAL_M4_SOURCES)'); | 
|---|
| 3473 | msg_var ('obsolete', 'ACLOCAL_M4_SOURCES', | 
|---|
| 3474 | "`ACLOCAL_M4_SOURCES' is obsolete.\n" | 
|---|
| 3475 | . "It should be safe to simply remove it."); | 
|---|
| 3476 | } | 
|---|
| 3477 |  | 
|---|
| 3478 | # Note that it might be possible that aclocal.m4 doesn't exist but | 
|---|
| 3479 | # should be auto-generated.  This case probably isn't very | 
|---|
| 3480 | # important. | 
|---|
| 3481 |  | 
|---|
| 3482 | return ($regen_aclocal, @ac_deps); | 
|---|
| 3483 | } | 
|---|
| 3484 |  | 
|---|
| 3485 |  | 
|---|
| 3486 | # @DEPENDENCIES | 
|---|
| 3487 | # &prepend_srcdir (@INPUTS) | 
|---|
| 3488 | # ------------------------- | 
|---|
| 3489 | # Prepend $(srcdir) or $(top_srcdir) to all @INPUTS.  The idea is that | 
|---|
| 3490 | # if an input file has a directory part the same as the current | 
|---|
| 3491 | # directory, then the directory part is simply replaced by $(srcdir). | 
|---|
| 3492 | # But if the directory part is different, then $(top_srcdir) is | 
|---|
| 3493 | # prepended. | 
|---|
| 3494 | sub prepend_srcdir (@) | 
|---|
| 3495 | { | 
|---|
| 3496 | my (@inputs) = @_; | 
|---|
| 3497 | my @newinputs; | 
|---|
| 3498 |  | 
|---|
| 3499 | foreach my $single (@inputs) | 
|---|
| 3500 | { | 
|---|
| 3501 | if (dirname ($single) eq $relative_dir) | 
|---|
| 3502 | { | 
|---|
| 3503 | push (@newinputs, '$(srcdir)/' . basename ($single)); | 
|---|
| 3504 | } | 
|---|
| 3505 | else | 
|---|
| 3506 | { | 
|---|
| 3507 | push (@newinputs, '$(top_srcdir)/' . $single); | 
|---|
| 3508 | } | 
|---|
| 3509 | } | 
|---|
| 3510 | return @newinputs; | 
|---|
| 3511 | } | 
|---|
| 3512 |  | 
|---|
| 3513 | # @DEPENDENCIES | 
|---|
| 3514 | # rewrite_inputs_into_dependencies ($OUTPUT, @INPUTS) | 
|---|
| 3515 | # --------------------------------------------------- | 
|---|
| 3516 | # Compute a list of dependencies appropriate for the rebuild | 
|---|
| 3517 | # rule of | 
|---|
| 3518 | #   AC_CONFIG_FILES($OUTPUT:$INPUT[0]:$INPUTS[1]:...) | 
|---|
| 3519 | # Also distribute $INPUTs which are not build by another AC_CONFIG_FILES. | 
|---|
| 3520 | sub rewrite_inputs_into_dependencies ($@) | 
|---|
| 3521 | { | 
|---|
| 3522 | my ($file, @inputs) = @_; | 
|---|
| 3523 | my @res = (); | 
|---|
| 3524 |  | 
|---|
| 3525 | for my $i (@inputs) | 
|---|
| 3526 | { | 
|---|
| 3527 | if (exists $ac_config_files_location{$i}) | 
|---|
| 3528 | { | 
|---|
| 3529 | my $di = dirname $i; | 
|---|
| 3530 | if ($di eq $relative_dir) | 
|---|
| 3531 | { | 
|---|
| 3532 | $i = basename $i; | 
|---|
| 3533 | } | 
|---|
| 3534 | # In the top-level Makefile we do not use $(top_builddir), because | 
|---|
| 3535 | # we are already there, and since the targets are built without | 
|---|
| 3536 | # a $(top_builddir), it helps BSD Make to match them with | 
|---|
| 3537 | # dependencies. | 
|---|
| 3538 | elsif ($relative_dir ne '.') | 
|---|
| 3539 | { | 
|---|
| 3540 | $i = '$(top_builddir)/' . $i; | 
|---|
| 3541 | } | 
|---|
| 3542 | } | 
|---|
| 3543 | else | 
|---|
| 3544 | { | 
|---|
| 3545 | msg ('error', $ac_config_files_location{$file}, | 
|---|
| 3546 | "required file `$i' not found") | 
|---|
| 3547 | unless exists $output_files{$i} || -f $i; | 
|---|
| 3548 | ($i) = prepend_srcdir ($i); | 
|---|
| 3549 | push_dist_common ($i); | 
|---|
| 3550 | } | 
|---|
| 3551 | push @res, $i; | 
|---|
| 3552 | } | 
|---|
| 3553 | return @res; | 
|---|
| 3554 | } | 
|---|
| 3555 |  | 
|---|
| 3556 |  | 
|---|
| 3557 |  | 
|---|
| 3558 | # &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS) | 
|---|
| 3559 | # ------------------------------------------------------------------ | 
|---|
| 3560 | # Handle remaking and configure stuff. | 
|---|
| 3561 | # We need the name of the input file, to do proper remaking rules. | 
|---|
| 3562 | sub handle_configure ($$$@) | 
|---|
| 3563 | { | 
|---|
| 3564 | my ($makefile_am, $makefile_in, $makefile, @inputs) = @_; | 
|---|
| 3565 |  | 
|---|
| 3566 | prog_error 'empty @inputs' | 
|---|
| 3567 | unless @inputs; | 
|---|
| 3568 |  | 
|---|
| 3569 | my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am, | 
|---|
| 3570 | $makefile_in); | 
|---|
| 3571 | my $rel_makefile = basename $makefile; | 
|---|
| 3572 |  | 
|---|
| 3573 | my $colon_infile = ':' . join (':', @inputs); | 
|---|
| 3574 | $colon_infile = '' if $colon_infile eq ":$makefile.in"; | 
|---|
| 3575 | my @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs); | 
|---|
| 3576 | my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4; | 
|---|
| 3577 | define_pretty_variable ('am__aclocal_m4_deps', TRUE, INTERNAL, | 
|---|
| 3578 | @configure_deps, @aclocal_m4_deps, | 
|---|
| 3579 | '$(top_srcdir)/' . $configure_ac); | 
|---|
| 3580 | my @configuredeps = ('$(am__aclocal_m4_deps)', '$(CONFIGURE_DEPENDENCIES)'); | 
|---|
| 3581 | push @configuredeps, '$(ACLOCAL_M4)' if -f 'aclocal.m4'; | 
|---|
| 3582 | define_pretty_variable ('am__configure_deps', TRUE, INTERNAL, | 
|---|
| 3583 | @configuredeps); | 
|---|
| 3584 |  | 
|---|
| 3585 | $output_rules .= file_contents | 
|---|
| 3586 | ('configure', | 
|---|
| 3587 | new Automake::Location, | 
|---|
| 3588 | MAKEFILE              => $rel_makefile, | 
|---|
| 3589 | 'MAKEFILE-DEPS'       => "@rewritten", | 
|---|
| 3590 | 'CONFIG-MAKEFILE'     => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@', | 
|---|
| 3591 | 'MAKEFILE-IN'         => $rel_makefile_in, | 
|---|
| 3592 | 'MAKEFILE-IN-DEPS'    => "@include_stack", | 
|---|
| 3593 | 'MAKEFILE-AM'         => $rel_makefile_am, | 
|---|
| 3594 | STRICTNESS            => global_option 'cygnus' | 
|---|
| 3595 | ? 'cygnus' : $strictness_name, | 
|---|
| 3596 | 'USE-DEPS'            => global_option 'no-dependencies' | 
|---|
| 3597 | ? ' --ignore-deps' : '', | 
|---|
| 3598 | 'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile", | 
|---|
| 3599 | 'REGEN-ACLOCAL-M4'    => $regen_aclocal_m4); | 
|---|
| 3600 |  | 
|---|
| 3601 | if ($relative_dir eq '.') | 
|---|
| 3602 | { | 
|---|
| 3603 | &push_dist_common ('acconfig.h') | 
|---|
| 3604 | if -f 'acconfig.h'; | 
|---|
| 3605 | } | 
|---|
| 3606 |  | 
|---|
| 3607 | # If we have a configure header, require it. | 
|---|
| 3608 | my $hdr_index = 0; | 
|---|
| 3609 | my @distclean_config; | 
|---|
| 3610 | foreach my $spec (@config_headers) | 
|---|
| 3611 | { | 
|---|
| 3612 | $hdr_index += 1; | 
|---|
| 3613 | # $CONFIG_H_PATH: config.h from top level. | 
|---|
| 3614 | my ($config_h_path, @ins) = split_config_file_spec ($spec); | 
|---|
| 3615 | my $config_h_dir = dirname ($config_h_path); | 
|---|
| 3616 |  | 
|---|
| 3617 | # If the header is in the current directory we want to build | 
|---|
| 3618 | # the header here.  Otherwise, if we're at the topmost | 
|---|
| 3619 | # directory and the header's directory doesn't have a | 
|---|
| 3620 | # Makefile, then we also want to build the header. | 
|---|
| 3621 | if ($relative_dir eq $config_h_dir | 
|---|
| 3622 | || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir))) | 
|---|
| 3623 | { | 
|---|
| 3624 | my ($cn_sans_dir, $stamp_dir); | 
|---|
| 3625 | if ($relative_dir eq $config_h_dir) | 
|---|
| 3626 | { | 
|---|
| 3627 | $cn_sans_dir = basename ($config_h_path); | 
|---|
| 3628 | $stamp_dir = ''; | 
|---|
| 3629 | } | 
|---|
| 3630 | else | 
|---|
| 3631 | { | 
|---|
| 3632 | $cn_sans_dir = $config_h_path; | 
|---|
| 3633 | if ($config_h_dir eq '.') | 
|---|
| 3634 | { | 
|---|
| 3635 | $stamp_dir = ''; | 
|---|
| 3636 | } | 
|---|
| 3637 | else | 
|---|
| 3638 | { | 
|---|
| 3639 | $stamp_dir = $config_h_dir . '/'; | 
|---|
| 3640 | } | 
|---|
| 3641 | } | 
|---|
| 3642 |  | 
|---|
| 3643 | # This will also distribute all inputs. | 
|---|
| 3644 | @ins = rewrite_inputs_into_dependencies ($config_h_path, @ins); | 
|---|
| 3645 |  | 
|---|
| 3646 | # Header defined and in this directory. | 
|---|
| 3647 | my @files; | 
|---|
| 3648 | if (-f $config_h_path . '.top') | 
|---|
| 3649 | { | 
|---|
| 3650 | push (@files, "$cn_sans_dir.top"); | 
|---|
| 3651 | } | 
|---|
| 3652 | if (-f $config_h_path . '.bot') | 
|---|
| 3653 | { | 
|---|
| 3654 | push (@files, "$cn_sans_dir.bot"); | 
|---|
| 3655 | } | 
|---|
| 3656 |  | 
|---|
| 3657 | push_dist_common (@files); | 
|---|
| 3658 |  | 
|---|
| 3659 | # For now, acconfig.h can only appear in the top srcdir. | 
|---|
| 3660 | if (-f 'acconfig.h') | 
|---|
| 3661 | { | 
|---|
| 3662 | push (@files, '$(top_srcdir)/acconfig.h'); | 
|---|
| 3663 | } | 
|---|
| 3664 |  | 
|---|
| 3665 | my $stamp = "${stamp_dir}stamp-h${hdr_index}"; | 
|---|
| 3666 | $output_rules .= | 
|---|
| 3667 | file_contents ('remake-hdr', | 
|---|
| 3668 | new Automake::Location, | 
|---|
| 3669 | FILES            => "@files", | 
|---|
| 3670 | CONFIG_H         => $cn_sans_dir, | 
|---|
| 3671 | CONFIG_HIN       => $ins[0], | 
|---|
| 3672 | CONFIG_H_DEPS    => "@ins", | 
|---|
| 3673 | CONFIG_H_PATH    => $config_h_path, | 
|---|
| 3674 | FIRST_CONFIG_HIN => ($hdr_index == 1), | 
|---|
| 3675 | STAMP            => "$stamp"); | 
|---|
| 3676 |  | 
|---|
| 3677 | push @distclean_config, $cn_sans_dir, $stamp; | 
|---|
| 3678 | } | 
|---|
| 3679 | } | 
|---|
| 3680 |  | 
|---|
| 3681 | $output_rules .= file_contents ('clean-hdr', | 
|---|
| 3682 | new Automake::Location, | 
|---|
| 3683 | FILES => "@distclean_config") | 
|---|
| 3684 | if @distclean_config; | 
|---|
| 3685 |  | 
|---|
| 3686 | # Distribute and define mkinstalldirs only if it is already present | 
|---|
| 3687 | # in the package, for backward compatibility (some people my still | 
|---|
| 3688 | # use $(mkinstalldirs)). | 
|---|
| 3689 | my $mkidpath = $config_aux_path[0] . '/mkinstalldirs'; | 
|---|
| 3690 | if (-f $mkidpath) | 
|---|
| 3691 | { | 
|---|
| 3692 | # Use require_file so that any existingscript gets updated | 
|---|
| 3693 | # by --force-missing. | 
|---|
| 3694 | require_conf_file ($mkidpath, FOREIGN, 'mkinstalldirs'); | 
|---|
| 3695 | define_variable ('mkinstalldirs', | 
|---|
| 3696 | "\$(SHELL) $config_aux_dir/mkinstalldirs", INTERNAL); | 
|---|
| 3697 | } | 
|---|
| 3698 | else | 
|---|
| 3699 | { | 
|---|
| 3700 | define_variable ('mkinstalldirs', '$(mkdir_p)', INTERNAL); | 
|---|
| 3701 | } | 
|---|
| 3702 |  | 
|---|
| 3703 | reject_var ('CONFIG_HEADER', | 
|---|
| 3704 | "`CONFIG_HEADER' is an anachronism; now determined " | 
|---|
| 3705 | . "automatically\nfrom `$configure_ac'"); | 
|---|
| 3706 |  | 
|---|
| 3707 | my @config_h; | 
|---|
| 3708 | foreach my $spec (@config_headers) | 
|---|
| 3709 | { | 
|---|
| 3710 | my ($out, @ins) = split_config_file_spec ($spec); | 
|---|
| 3711 | # Generate CONFIG_HEADER define. | 
|---|
| 3712 | if ($relative_dir eq dirname ($out)) | 
|---|
| 3713 | { | 
|---|
| 3714 | push @config_h, basename ($out); | 
|---|
| 3715 | } | 
|---|
| 3716 | else | 
|---|
| 3717 | { | 
|---|
| 3718 | push @config_h, "\$(top_builddir)/$out"; | 
|---|
| 3719 | } | 
|---|
| 3720 | } | 
|---|
| 3721 | define_variable ("CONFIG_HEADER", "@config_h", INTERNAL) | 
|---|
| 3722 | if @config_h; | 
|---|
| 3723 |  | 
|---|
| 3724 | # Now look for other files in this directory which must be remade | 
|---|
| 3725 | # by config.status, and generate rules for them. | 
|---|
| 3726 | my @actual_other_files = (); | 
|---|
| 3727 | foreach my $lfile (@other_input_files) | 
|---|
| 3728 | { | 
|---|
| 3729 | my $file; | 
|---|
| 3730 | my @inputs; | 
|---|
| 3731 | if ($lfile =~ /^([^:]*):(.*)$/) | 
|---|
| 3732 | { | 
|---|
| 3733 | # This is the ":" syntax of AC_OUTPUT. | 
|---|
| 3734 | $file = $1; | 
|---|
| 3735 | @inputs = split (':', $2); | 
|---|
| 3736 | } | 
|---|
| 3737 | else | 
|---|
| 3738 | { | 
|---|
| 3739 | # Normal usage. | 
|---|
| 3740 | $file = $lfile; | 
|---|
| 3741 | @inputs = $file . '.in'; | 
|---|
| 3742 | } | 
|---|
| 3743 |  | 
|---|
| 3744 | # Automake files should not be stored in here, but in %MAKE_LIST. | 
|---|
| 3745 | prog_error ("$lfile in \@other_input_files\n" | 
|---|
| 3746 | . "\@other_input_files = (@other_input_files)") | 
|---|
| 3747 | if -f $file . '.am'; | 
|---|
| 3748 |  | 
|---|
| 3749 | my $local = basename ($file); | 
|---|
| 3750 |  | 
|---|
| 3751 | # Make sure the dist directory for each input file is created. | 
|---|
| 3752 | # We only have to do this at the topmost level though.  This | 
|---|
| 3753 | # is a bit ugly but it easier than spreading out the logic, | 
|---|
| 3754 | # especially in cases like AC_OUTPUT(foo/out:bar/in), where | 
|---|
| 3755 | # there is no Makefile in bar/. | 
|---|
| 3756 | if ($relative_dir eq '.') | 
|---|
| 3757 | { | 
|---|
| 3758 | foreach (@inputs) | 
|---|
| 3759 | { | 
|---|
| 3760 | $dist_dirs{dirname ($_)} = 1; | 
|---|
| 3761 | } | 
|---|
| 3762 | } | 
|---|
| 3763 |  | 
|---|
| 3764 | # We skip files that aren't in this directory.  However, if | 
|---|
| 3765 | # the file's directory does not have a Makefile, and we are | 
|---|
| 3766 | # currently doing `.', then we create a rule to rebuild the | 
|---|
| 3767 | # file in the subdir. | 
|---|
| 3768 | my $fd = dirname ($file); | 
|---|
| 3769 | if ($fd ne $relative_dir) | 
|---|
| 3770 | { | 
|---|
| 3771 | if ($relative_dir eq '.' && ! &is_make_dir ($fd)) | 
|---|
| 3772 | { | 
|---|
| 3773 | $local = $file; | 
|---|
| 3774 | } | 
|---|
| 3775 | else | 
|---|
| 3776 | { | 
|---|
| 3777 | next; | 
|---|
| 3778 | } | 
|---|
| 3779 | } | 
|---|
| 3780 |  | 
|---|
| 3781 | my @rewritten_inputs = rewrite_inputs_into_dependencies ($file, @inputs); | 
|---|
| 3782 |  | 
|---|
| 3783 | $output_rules .= ($local . ': ' | 
|---|
| 3784 | . '$(top_builddir)/config.status ' | 
|---|
| 3785 | . "@rewritten_inputs\n" | 
|---|
| 3786 | . "\t" | 
|---|
| 3787 | . 'cd $(top_builddir) && ' | 
|---|
| 3788 | . '$(SHELL) ./config.status ' | 
|---|
| 3789 | . ($relative_dir eq '.' ? '' : '$(subdir)/') | 
|---|
| 3790 | . '$@' | 
|---|
| 3791 | . "\n"); | 
|---|
| 3792 | push (@actual_other_files, $local); | 
|---|
| 3793 | } | 
|---|
| 3794 |  | 
|---|
| 3795 | # For links we should clean destinations and distribute sources. | 
|---|
| 3796 | foreach my $spec (@config_links) | 
|---|
| 3797 | { | 
|---|
| 3798 | my ($link, $file) = split /:/, $spec; | 
|---|
| 3799 | # Some people do AC_CONFIG_LINKS($computed).  We only handle | 
|---|
| 3800 | # the DEST:SRC form. | 
|---|
| 3801 | next unless $file; | 
|---|
| 3802 | my $where = $ac_config_files_location{$link}; | 
|---|
| 3803 |  | 
|---|
| 3804 | # Skip destinations that contain shell variables. | 
|---|
| 3805 | if ($link !~ /\$/) | 
|---|
| 3806 | { | 
|---|
| 3807 | # We skip links that aren't in this directory.  However, if | 
|---|
| 3808 | # the link's directory does not have a Makefile, and we are | 
|---|
| 3809 | # currently doing `.', then we add the link to CONFIG_CLEAN_FILES | 
|---|
| 3810 | # in `.'s Makefile.in. | 
|---|
| 3811 | my $local = basename ($link); | 
|---|
| 3812 | my $fd = dirname ($link); | 
|---|
| 3813 | if ($fd ne $relative_dir) | 
|---|
| 3814 | { | 
|---|
| 3815 | if ($relative_dir eq '.' && ! &is_make_dir ($fd)) | 
|---|
| 3816 | { | 
|---|
| 3817 | $local = $link; | 
|---|
| 3818 | } | 
|---|
| 3819 | else | 
|---|
| 3820 | { | 
|---|
| 3821 | $local = undef; | 
|---|
| 3822 | } | 
|---|
| 3823 | } | 
|---|
| 3824 | push @actual_other_files, $local if $local; | 
|---|
| 3825 | } | 
|---|
| 3826 |  | 
|---|
| 3827 | # Do not process sources that contain shell variables. | 
|---|
| 3828 | if ($file !~ /\$/) | 
|---|
| 3829 | { | 
|---|
| 3830 | my $fd = dirname ($file); | 
|---|
| 3831 |  | 
|---|
| 3832 | # Make sure the dist directory for each input file is created. | 
|---|
| 3833 | # We only have to do this at the topmost level though. | 
|---|
| 3834 | if ($relative_dir eq '.') | 
|---|
| 3835 | { | 
|---|
| 3836 | $dist_dirs{$fd} = 1; | 
|---|
| 3837 | } | 
|---|
| 3838 |  | 
|---|
| 3839 | # We distribute files that are in this directory. | 
|---|
| 3840 | # At the top-level (`.') we also distribute files whose | 
|---|
| 3841 | # directory does not have a Makefile. | 
|---|
| 3842 | if (($fd eq $relative_dir) | 
|---|
| 3843 | || ($relative_dir eq '.' && ! &is_make_dir ($fd))) | 
|---|
| 3844 | { | 
|---|
| 3845 | # The following will distribute $file as a side-effect when | 
|---|
| 3846 | # it is appropriate (i.e., when $file is not already an output). | 
|---|
| 3847 | # We do not need the result, just the side-effect. | 
|---|
| 3848 | rewrite_inputs_into_dependencies ($link, $file); | 
|---|
| 3849 | } | 
|---|
| 3850 | } | 
|---|
| 3851 | } | 
|---|
| 3852 |  | 
|---|
| 3853 | # These files get removed by "make distclean". | 
|---|
| 3854 | define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL, | 
|---|
| 3855 | @actual_other_files); | 
|---|
| 3856 | } | 
|---|
| 3857 |  | 
|---|
| 3858 | # Handle C headers. | 
|---|
| 3859 | sub handle_headers | 
|---|
| 3860 | { | 
|---|
| 3861 | my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include', | 
|---|
| 3862 | 'oldinclude', 'pkginclude', | 
|---|
| 3863 | 'noinst', 'check'); | 
|---|
| 3864 | foreach (@r) | 
|---|
| 3865 | { | 
|---|
| 3866 | next unless $_->[1] =~ /\..*$/; | 
|---|
| 3867 | &saw_extension ($&); | 
|---|
| 3868 | } | 
|---|
| 3869 | } | 
|---|
| 3870 |  | 
|---|
| 3871 | sub handle_gettext | 
|---|
| 3872 | { | 
|---|
| 3873 | return if ! $seen_gettext || $relative_dir ne '.'; | 
|---|
| 3874 |  | 
|---|
| 3875 | my $subdirs = var 'SUBDIRS'; | 
|---|
| 3876 |  | 
|---|
| 3877 | if (! $subdirs) | 
|---|
| 3878 | { | 
|---|
| 3879 | err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined"; | 
|---|
| 3880 | return; | 
|---|
| 3881 | } | 
|---|
| 3882 |  | 
|---|
| 3883 | # Perform some sanity checks to help users get the right setup. | 
|---|
| 3884 | # We disable these tests when po/ doesn't exist in order not to disallow | 
|---|
| 3885 | # unusual gettext setups. | 
|---|
| 3886 | # | 
|---|
| 3887 | # Bruno Haible: | 
|---|
| 3888 | # | The idea is: | 
|---|
| 3889 | # | | 
|---|
| 3890 | # |  1) If a package doesn't have a directory po/ at top level, it | 
|---|
| 3891 | # |     will likely have multiple po/ directories in subpackages. | 
|---|
| 3892 | # | | 
|---|
| 3893 | # |  2) It is useful to warn for the absence of intl/ if AM_GNU_GETTEXT | 
|---|
| 3894 | # |     is used without 'external'. It is also useful to warn for the | 
|---|
| 3895 | # |     presence of intl/ if AM_GNU_GETTEXT([external]) is used. Both | 
|---|
| 3896 | # |     warnings apply only to the usual layout of packages, therefore | 
|---|
| 3897 | # |     they should both be disabled if no po/ directory is found at | 
|---|
| 3898 | # |     top level. | 
|---|
| 3899 |  | 
|---|
| 3900 | if (-d 'po') | 
|---|
| 3901 | { | 
|---|
| 3902 | my @subdirs = $subdirs->value_as_list_recursive; | 
|---|
| 3903 |  | 
|---|
| 3904 | msg_var ('syntax', $subdirs, | 
|---|
| 3905 | "AM_GNU_GETTEXT used but `po' not in SUBDIRS") | 
|---|
| 3906 | if ! grep ($_ eq 'po', @subdirs); | 
|---|
| 3907 |  | 
|---|
| 3908 | # intl/ is not required when AM_GNU_GETTEXT is called with | 
|---|
| 3909 | # the `external' option. | 
|---|
| 3910 | msg_var ('syntax', $subdirs, | 
|---|
| 3911 | "AM_GNU_GETTEXT used but `intl' not in SUBDIRS") | 
|---|
| 3912 | if (! $seen_gettext_external | 
|---|
| 3913 | && ! grep ($_ eq 'intl', @subdirs)); | 
|---|
| 3914 |  | 
|---|
| 3915 | # intl/ should not be used with AM_GNU_GETTEXT([external]) | 
|---|
| 3916 | msg_var ('syntax', $subdirs, | 
|---|
| 3917 | "`intl' should not be in SUBDIRS when " | 
|---|
| 3918 | . "AM_GNU_GETTEXT([external]) is used") | 
|---|
| 3919 | if ($seen_gettext_external && grep ($_ eq 'intl', @subdirs)); | 
|---|
| 3920 | } | 
|---|
| 3921 |  | 
|---|
| 3922 | require_file ($ac_gettext_location, GNU, 'ABOUT-NLS'); | 
|---|
| 3923 | } | 
|---|
| 3924 |  | 
|---|
| 3925 | # Handle footer elements. | 
|---|
| 3926 | sub handle_footer | 
|---|
| 3927 | { | 
|---|
| 3928 | # NOTE don't use define_pretty_variable here, because | 
|---|
| 3929 | # $contents{...} is already defined. | 
|---|
| 3930 | $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n" | 
|---|
| 3931 | if variable_value ('SOURCES'); | 
|---|
| 3932 |  | 
|---|
| 3933 | reject_rule ('.SUFFIXES', | 
|---|
| 3934 | "use variable `SUFFIXES', not target `.SUFFIXES'"); | 
|---|
| 3935 |  | 
|---|
| 3936 | # Note: AIX 4.1 /bin/make will fail if any suffix rule appears | 
|---|
| 3937 | # before .SUFFIXES.  So we make sure that .SUFFIXES appears before | 
|---|
| 3938 | # anything else, by sticking it right after the default: target. | 
|---|
| 3939 | $output_header .= ".SUFFIXES:\n"; | 
|---|
| 3940 | my $suffixes = var 'SUFFIXES'; | 
|---|
| 3941 | my @suffixes = Automake::Rule::suffixes; | 
|---|
| 3942 | if (@suffixes || $suffixes) | 
|---|
| 3943 | { | 
|---|
| 3944 | # Make sure SUFFIXES has unique elements.  Sort them to ensure | 
|---|
| 3945 | # the output remains consistent.  However, $(SUFFIXES) is | 
|---|
| 3946 | # always at the start of the list, unsorted.  This is done | 
|---|
| 3947 | # because make will choose rules depending on the ordering of | 
|---|
| 3948 | # suffixes, and this lets the user have some control.  Push | 
|---|
| 3949 | # actual suffixes, and not $(SUFFIXES).  Some versions of make | 
|---|
| 3950 | # do not like variable substitutions on the .SUFFIXES line. | 
|---|
| 3951 | my @user_suffixes = ($suffixes | 
|---|
| 3952 | ? $suffixes->value_as_list_recursive : ()); | 
|---|
| 3953 |  | 
|---|
| 3954 | my %suffixes = map { $_ => 1 } @suffixes; | 
|---|
| 3955 | delete @suffixes{@user_suffixes}; | 
|---|
| 3956 |  | 
|---|
| 3957 | $output_header .= (".SUFFIXES: " | 
|---|
| 3958 | . join (' ', @user_suffixes, sort keys %suffixes) | 
|---|
| 3959 | . "\n"); | 
|---|
| 3960 | } | 
|---|
| 3961 |  | 
|---|
| 3962 | $output_trailer .= file_contents ('footer', new Automake::Location); | 
|---|
| 3963 | } | 
|---|
| 3964 |  | 
|---|
| 3965 |  | 
|---|
| 3966 | # Generate `make install' rules. | 
|---|
| 3967 | sub handle_install () | 
|---|
| 3968 | { | 
|---|
| 3969 | $output_rules .= &file_contents | 
|---|
| 3970 | ('install', | 
|---|
| 3971 | new Automake::Location, | 
|---|
| 3972 | maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES') | 
|---|
| 3973 | ? (" \$(BUILT_SOURCES)\n" | 
|---|
| 3974 | . "\t\$(MAKE) \$(AM_MAKEFLAGS)") | 
|---|
| 3975 | : ''), | 
|---|
| 3976 | 'installdirs-local' => (rule 'installdirs-local' | 
|---|
| 3977 | ? ' installdirs-local' : ''), | 
|---|
| 3978 | am__installdirs => variable_value ('am__installdirs') || ''); | 
|---|
| 3979 | } | 
|---|
| 3980 |  | 
|---|
| 3981 |  | 
|---|
| 3982 | # Deal with all and all-am. | 
|---|
| 3983 | sub handle_all ($) | 
|---|
| 3984 | { | 
|---|
| 3985 | my ($makefile) = @_; | 
|---|
| 3986 |  | 
|---|
| 3987 | # Output `all-am'. | 
|---|
| 3988 |  | 
|---|
| 3989 | # Put this at the beginning for the sake of non-GNU makes.  This | 
|---|
| 3990 | # is still wrong if these makes can run parallel jobs.  But it is | 
|---|
| 3991 | # right enough. | 
|---|
| 3992 | unshift (@all, basename ($makefile)); | 
|---|
| 3993 |  | 
|---|
| 3994 | foreach my $spec (@config_headers) | 
|---|
| 3995 | { | 
|---|
| 3996 | my ($out, @ins) = split_config_file_spec ($spec); | 
|---|
| 3997 | push (@all, basename ($out)) | 
|---|
| 3998 | if dirname ($out) eq $relative_dir; | 
|---|
| 3999 | } | 
|---|
| 4000 |  | 
|---|
| 4001 | # Install `all' hooks. | 
|---|
| 4002 | if (rule "all-local") | 
|---|
| 4003 | { | 
|---|
| 4004 | push (@all, "all-local"); | 
|---|
| 4005 | &depend ('.PHONY', "all-local"); | 
|---|
| 4006 | } | 
|---|
| 4007 |  | 
|---|
| 4008 | &pretty_print_rule ("all-am:", "\t\t", @all); | 
|---|
| 4009 | &depend ('.PHONY', 'all-am', 'all'); | 
|---|
| 4010 |  | 
|---|
| 4011 |  | 
|---|
| 4012 | # Output `all'. | 
|---|
| 4013 |  | 
|---|
| 4014 | my @local_headers = (); | 
|---|
| 4015 | push @local_headers, '$(BUILT_SOURCES)' | 
|---|
| 4016 | if var ('BUILT_SOURCES'); | 
|---|
| 4017 | foreach my $spec (@config_headers) | 
|---|
| 4018 | { | 
|---|
| 4019 | my ($out, @ins) = split_config_file_spec ($spec); | 
|---|
| 4020 | push @local_headers, basename ($out) | 
|---|
| 4021 | if dirname ($out) eq $relative_dir; | 
|---|
| 4022 | } | 
|---|
| 4023 |  | 
|---|
| 4024 | if (@local_headers) | 
|---|
| 4025 | { | 
|---|
| 4026 | # We need to make sure config.h is built before we recurse. | 
|---|
| 4027 | # We also want to make sure that built sources are built | 
|---|
| 4028 | # before any ordinary `all' targets are run.  We can't do this | 
|---|
| 4029 | # by changing the order of dependencies to the "all" because | 
|---|
| 4030 | # that breaks when using parallel makes.  Instead we handle | 
|---|
| 4031 | # things explicitly. | 
|---|
| 4032 | $output_all .= ("all: @local_headers" | 
|---|
| 4033 | . "\n\t" | 
|---|
| 4034 | . '$(MAKE) $(AM_MAKEFLAGS) ' | 
|---|
| 4035 | . (var ('SUBDIRS') ? 'all-recursive' : 'all-am') | 
|---|
| 4036 | . "\n\n"); | 
|---|
| 4037 | } | 
|---|
| 4038 | else | 
|---|
| 4039 | { | 
|---|
| 4040 | $output_all .= "all: " . (var ('SUBDIRS') | 
|---|
| 4041 | ? 'all-recursive' : 'all-am') . "\n\n"; | 
|---|
| 4042 | } | 
|---|
| 4043 | } | 
|---|
| 4044 |  | 
|---|
| 4045 |  | 
|---|
| 4046 | # &do_check_merge_target () | 
|---|
| 4047 | # ------------------------- | 
|---|
| 4048 | # Handle check merge target specially. | 
|---|
| 4049 | sub do_check_merge_target () | 
|---|
| 4050 | { | 
|---|
| 4051 | if (rule 'check-local') | 
|---|
| 4052 | { | 
|---|
| 4053 | # User defined local form of target.  So include it. | 
|---|
| 4054 | push @check_tests, 'check-local'; | 
|---|
| 4055 | depend '.PHONY', 'check-local'; | 
|---|
| 4056 | } | 
|---|
| 4057 |  | 
|---|
| 4058 | # In --cygnus mode, check doesn't depend on all. | 
|---|
| 4059 | if (option 'cygnus') | 
|---|
| 4060 | { | 
|---|
| 4061 | # Just run the local check rules. | 
|---|
| 4062 | pretty_print_rule ('check-am:', "\t\t", @check); | 
|---|
| 4063 | } | 
|---|
| 4064 | else | 
|---|
| 4065 | { | 
|---|
| 4066 | # The check target must depend on the local equivalent of | 
|---|
| 4067 | # `all', to ensure all the primary targets are built.  Then it | 
|---|
| 4068 | # must build the local check rules. | 
|---|
| 4069 | $output_rules .= "check-am: all-am\n"; | 
|---|
| 4070 | pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ", | 
|---|
| 4071 | @check) | 
|---|
| 4072 | if @check; | 
|---|
| 4073 | } | 
|---|
| 4074 | pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ", | 
|---|
| 4075 | @check_tests) | 
|---|
| 4076 | if @check_tests; | 
|---|
| 4077 |  | 
|---|
| 4078 | depend '.PHONY', 'check', 'check-am'; | 
|---|
| 4079 | # Handle recursion.  We have to honor BUILT_SOURCES like for `all:'. | 
|---|
| 4080 | $output_rules .= ("check: " | 
|---|
| 4081 | . (var ('BUILT_SOURCES') | 
|---|
| 4082 | ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) " | 
|---|
| 4083 | : '') | 
|---|
| 4084 | . (var ('SUBDIRS') ? 'check-recursive' : 'check-am') | 
|---|
| 4085 | . "\n"); | 
|---|
| 4086 | } | 
|---|
| 4087 |  | 
|---|
| 4088 | # handle_clean ($MAKEFILE) | 
|---|
| 4089 | # ------------------------ | 
|---|
| 4090 | # Handle all 'clean' targets. | 
|---|
| 4091 | sub handle_clean ($) | 
|---|
| 4092 | { | 
|---|
| 4093 | my ($makefile) = @_; | 
|---|
| 4094 |  | 
|---|
| 4095 | # Clean the files listed in user variables if they exist. | 
|---|
| 4096 | $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN | 
|---|
| 4097 | if var ('MOSTLYCLEANFILES'); | 
|---|
| 4098 | $clean_files{'$(CLEANFILES)'} = CLEAN | 
|---|
| 4099 | if var ('CLEANFILES'); | 
|---|
| 4100 | $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN | 
|---|
| 4101 | if var ('DISTCLEANFILES'); | 
|---|
| 4102 | $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN | 
|---|
| 4103 | if var ('MAINTAINERCLEANFILES'); | 
|---|
| 4104 |  | 
|---|
| 4105 | # Built sources are automatically removed by maintainer-clean. | 
|---|
| 4106 | $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN | 
|---|
| 4107 | if var ('BUILT_SOURCES'); | 
|---|
| 4108 |  | 
|---|
| 4109 | # Compute a list of "rm"s to run for each target. | 
|---|
| 4110 | my %rms = (MOSTLY_CLEAN, [], | 
|---|
| 4111 | CLEAN, [], | 
|---|
| 4112 | DIST_CLEAN, [], | 
|---|
| 4113 | MAINTAINER_CLEAN, []); | 
|---|
| 4114 |  | 
|---|
| 4115 | foreach my $file (keys %clean_files) | 
|---|
| 4116 | { | 
|---|
| 4117 | my $when = $clean_files{$file}; | 
|---|
| 4118 | prog_error 'invalid entry in %clean_files' | 
|---|
| 4119 | unless exists $rms{$when}; | 
|---|
| 4120 |  | 
|---|
| 4121 | my $rm = "rm -f $file"; | 
|---|
| 4122 | # If file is a variable, make sure when don't call `rm -f' without args. | 
|---|
| 4123 | $rm ="test -z \"$file\" || $rm" | 
|---|
| 4124 | if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/); | 
|---|
| 4125 |  | 
|---|
| 4126 | push @{$rms{$when}}, "\t-$rm\n"; | 
|---|
| 4127 | } | 
|---|
| 4128 |  | 
|---|
| 4129 | $output_rules .= &file_contents | 
|---|
| 4130 | ('clean', | 
|---|
| 4131 | new Automake::Location, | 
|---|
| 4132 | MOSTLYCLEAN_RMS      => join ('', @{$rms{&MOSTLY_CLEAN}}), | 
|---|
| 4133 | CLEAN_RMS            => join ('', @{$rms{&CLEAN}}), | 
|---|
| 4134 | DISTCLEAN_RMS        => join ('', @{$rms{&DIST_CLEAN}}), | 
|---|
| 4135 | MAINTAINER_CLEAN_RMS => join ('', @{$rms{&MAINTAINER_CLEAN}}), | 
|---|
| 4136 | MAKEFILE             => basename $makefile, | 
|---|
| 4137 | ); | 
|---|
| 4138 | } | 
|---|
| 4139 |  | 
|---|
| 4140 |  | 
|---|
| 4141 | # &target_cmp ($A, $B) | 
|---|
| 4142 | # -------------------- | 
|---|
| 4143 | # Subroutine for &handle_factored_dependencies to let `.PHONY' be last. | 
|---|
| 4144 | sub target_cmp | 
|---|
| 4145 | { | 
|---|
| 4146 | return 0 | 
|---|
| 4147 | if $a eq $b; | 
|---|
| 4148 | return -1 | 
|---|
| 4149 | if $b eq '.PHONY'; | 
|---|
| 4150 | return 1 | 
|---|
| 4151 | if $a eq '.PHONY'; | 
|---|
| 4152 | return $a cmp $b; | 
|---|
| 4153 | } | 
|---|
| 4154 |  | 
|---|
| 4155 |  | 
|---|
| 4156 | # &handle_factored_dependencies () | 
|---|
| 4157 | # -------------------------------- | 
|---|
| 4158 | # Handle everything related to gathered targets. | 
|---|
| 4159 | sub handle_factored_dependencies | 
|---|
| 4160 | { | 
|---|
| 4161 | # Reject bad hooks. | 
|---|
| 4162 | foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook', | 
|---|
| 4163 | 'uninstall-exec-local', 'uninstall-exec-hook') | 
|---|
| 4164 | { | 
|---|
| 4165 | my $x = $utarg; | 
|---|
| 4166 | $x =~ s/(data|exec)-//; | 
|---|
| 4167 | reject_rule ($utarg, "use `$x', not `$utarg'"); | 
|---|
| 4168 | } | 
|---|
| 4169 |  | 
|---|
| 4170 | reject_rule ('install-local', | 
|---|
| 4171 | "use `install-data-local' or `install-exec-local', " | 
|---|
| 4172 | . "not `install-local'"); | 
|---|
| 4173 |  | 
|---|
| 4174 | reject_rule ('install-info-local', | 
|---|
| 4175 | "`install-info-local' target defined but " | 
|---|
| 4176 | . "`no-installinfo' option not in use") | 
|---|
| 4177 | unless option 'no-installinfo'; | 
|---|
| 4178 |  | 
|---|
| 4179 | # Install the -local hooks. | 
|---|
| 4180 | foreach (keys %dependencies) | 
|---|
| 4181 | { | 
|---|
| 4182 | # Hooks are installed on the -am targets. | 
|---|
| 4183 | s/-am$// or next; | 
|---|
| 4184 | if (rule "$_-local") | 
|---|
| 4185 | { | 
|---|
| 4186 | depend ("$_-am", "$_-local"); | 
|---|
| 4187 | depend ('.PHONY', "$_-local"); | 
|---|
| 4188 | } | 
|---|
| 4189 | } | 
|---|
| 4190 |  | 
|---|
| 4191 | # Install the -hook hooks. | 
|---|
| 4192 | # FIXME: Why not be as liberal as we are with -local hooks? | 
|---|
| 4193 | foreach ('install-exec', 'install-data', 'uninstall') | 
|---|
| 4194 | { | 
|---|
| 4195 | if (rule ("$_-hook")) | 
|---|
| 4196 | { | 
|---|
| 4197 | $actions{"$_-am"} .= | 
|---|
| 4198 | ("\t\@\$(NORMAL_INSTALL)\n" | 
|---|
| 4199 | . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n"); | 
|---|
| 4200 | } | 
|---|
| 4201 | } | 
|---|
| 4202 |  | 
|---|
| 4203 | # All the required targets are phony. | 
|---|
| 4204 | depend ('.PHONY', keys %required_targets); | 
|---|
| 4205 |  | 
|---|
| 4206 | # Actually output gathered targets. | 
|---|
| 4207 | foreach (sort target_cmp keys %dependencies) | 
|---|
| 4208 | { | 
|---|
| 4209 | # If there is nothing about this guy, skip it. | 
|---|
| 4210 | next | 
|---|
| 4211 | unless (@{$dependencies{$_}} | 
|---|
| 4212 | || $actions{$_} | 
|---|
| 4213 | || $required_targets{$_}); | 
|---|
| 4214 |  | 
|---|
| 4215 | # Define gathered targets in undefined conditions. | 
|---|
| 4216 | # FIXME: Right now we must handle .PHONY as an exception, | 
|---|
| 4217 | # because people write things like | 
|---|
| 4218 | #    .PHONY: myphonytarget | 
|---|
| 4219 | # to append dependencies.  This would not work if Automake | 
|---|
| 4220 | # refrained from defining its own .PHONY target as it does | 
|---|
| 4221 | # with other overridden targets. | 
|---|
| 4222 | my @undefined_conds = (TRUE,); | 
|---|
| 4223 | if ($_ ne '.PHONY') | 
|---|
| 4224 | { | 
|---|
| 4225 | @undefined_conds = | 
|---|
| 4226 | Automake::Rule::define ($_, 'internal', | 
|---|
| 4227 | RULE_AUTOMAKE, TRUE, INTERNAL); | 
|---|
| 4228 | } | 
|---|
| 4229 | my @uniq_deps = uniq (sort @{$dependencies{$_}}); | 
|---|
| 4230 | foreach my $cond (@undefined_conds) | 
|---|
| 4231 | { | 
|---|
| 4232 | my $condstr = $cond->subst_string; | 
|---|
| 4233 | &pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps); | 
|---|
| 4234 | $output_rules .= $actions{$_} if defined $actions{$_}; | 
|---|
| 4235 | $output_rules .= "\n"; | 
|---|
| 4236 | } | 
|---|
| 4237 | } | 
|---|
| 4238 | } | 
|---|
| 4239 |  | 
|---|
| 4240 |  | 
|---|
| 4241 | # &handle_tests_dejagnu () | 
|---|
| 4242 | # ------------------------ | 
|---|
| 4243 | sub handle_tests_dejagnu | 
|---|
| 4244 | { | 
|---|
| 4245 | push (@check_tests, 'check-DEJAGNU'); | 
|---|
| 4246 | $output_rules .= file_contents ('dejagnu', new Automake::Location); | 
|---|
| 4247 | } | 
|---|
| 4248 |  | 
|---|
| 4249 |  | 
|---|
| 4250 | # Handle TESTS variable and other checks. | 
|---|
| 4251 | sub handle_tests | 
|---|
| 4252 | { | 
|---|
| 4253 | if (option 'dejagnu') | 
|---|
| 4254 | { | 
|---|
| 4255 | &handle_tests_dejagnu; | 
|---|
| 4256 | } | 
|---|
| 4257 | else | 
|---|
| 4258 | { | 
|---|
| 4259 | foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS') | 
|---|
| 4260 | { | 
|---|
| 4261 | reject_var ($c, "`$c' defined but `dejagnu' not in " | 
|---|
| 4262 | . "`AUTOMAKE_OPTIONS'"); | 
|---|
| 4263 | } | 
|---|
| 4264 | } | 
|---|
| 4265 |  | 
|---|
| 4266 | if (var ('TESTS')) | 
|---|
| 4267 | { | 
|---|
| 4268 | push (@check_tests, 'check-TESTS'); | 
|---|
| 4269 | $output_rules .= &file_contents ('check', new Automake::Location); | 
|---|
| 4270 | } | 
|---|
| 4271 | } | 
|---|
| 4272 |  | 
|---|
| 4273 | # Handle Emacs Lisp. | 
|---|
| 4274 | sub handle_emacs_lisp | 
|---|
| 4275 | { | 
|---|
| 4276 | my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP', | 
|---|
| 4277 | 'lisp', 'noinst'); | 
|---|
| 4278 |  | 
|---|
| 4279 | return if ! @elfiles; | 
|---|
| 4280 |  | 
|---|
| 4281 | define_pretty_variable ('am__ELFILES', TRUE, INTERNAL, | 
|---|
| 4282 | map { $_->[1] } @elfiles); | 
|---|
| 4283 | define_pretty_variable ('am__ELCFILES', TRUE, INTERNAL, | 
|---|
| 4284 | '$(am__ELFILES:.el=.elc)'); | 
|---|
| 4285 | # This one can be overridden by users. | 
|---|
| 4286 | define_pretty_variable ('ELCFILES', TRUE, INTERNAL, '$(am__ELCFILES)'); | 
|---|
| 4287 |  | 
|---|
| 4288 | push @all, '$(ELCFILES)'; | 
|---|
| 4289 |  | 
|---|
| 4290 | require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE, | 
|---|
| 4291 | 'EMACS', 'lispdir'); | 
|---|
| 4292 | require_conf_file ($elfiles[0][0], FOREIGN, 'elisp-comp'); | 
|---|
| 4293 | &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp', INTERNAL); | 
|---|
| 4294 | } | 
|---|
| 4295 |  | 
|---|
| 4296 | # Handle Python | 
|---|
| 4297 | sub handle_python | 
|---|
| 4298 | { | 
|---|
| 4299 | my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON', | 
|---|
| 4300 | 'noinst'); | 
|---|
| 4301 | return if ! @pyfiles; | 
|---|
| 4302 |  | 
|---|
| 4303 | require_variables ($pyfiles[0][0], "Python sources seen", TRUE, 'PYTHON'); | 
|---|
| 4304 | require_conf_file ($pyfiles[0][0], FOREIGN, 'py-compile'); | 
|---|
| 4305 | &define_variable ('py_compile', $config_aux_dir . '/py-compile', INTERNAL); | 
|---|
| 4306 | } | 
|---|
| 4307 |  | 
|---|
| 4308 | # Handle Java. | 
|---|
| 4309 | sub handle_java | 
|---|
| 4310 | { | 
|---|
| 4311 | my @sourcelist = &am_install_var ('-candist', | 
|---|
| 4312 | 'java', 'JAVA', | 
|---|
| 4313 | 'java', 'noinst', 'check'); | 
|---|
| 4314 | return if ! @sourcelist; | 
|---|
| 4315 |  | 
|---|
| 4316 | my @prefix = am_primary_prefixes ('JAVA', 1, | 
|---|
| 4317 | 'java', 'noinst', 'check'); | 
|---|
| 4318 |  | 
|---|
| 4319 | my $dir; | 
|---|
| 4320 | foreach my $curs (@prefix) | 
|---|
| 4321 | { | 
|---|
| 4322 | next | 
|---|
| 4323 | if $curs eq 'EXTRA'; | 
|---|
| 4324 |  | 
|---|
| 4325 | err_var "${curs}_JAVA", "multiple _JAVA primaries in use" | 
|---|
| 4326 | if defined $dir; | 
|---|
| 4327 | $dir = $curs; | 
|---|
| 4328 | } | 
|---|
| 4329 |  | 
|---|
| 4330 |  | 
|---|
| 4331 | push (@all, 'class' . $dir . '.stamp'); | 
|---|
| 4332 | } | 
|---|
| 4333 |  | 
|---|
| 4334 |  | 
|---|
| 4335 | # Handle some of the minor options. | 
|---|
| 4336 | sub handle_minor_options | 
|---|
| 4337 | { | 
|---|
| 4338 | if (option 'readme-alpha') | 
|---|
| 4339 | { | 
|---|
| 4340 | if ($relative_dir eq '.') | 
|---|
| 4341 | { | 
|---|
| 4342 | if ($package_version !~ /^$GNITS_VERSION_PATTERN$/) | 
|---|
| 4343 | { | 
|---|
| 4344 | msg ('error-gnits', $package_version_location, | 
|---|
| 4345 | "version `$package_version' doesn't follow " . | 
|---|
| 4346 | "Gnits standards"); | 
|---|
| 4347 | } | 
|---|
| 4348 | if (defined $1 && -f 'README-alpha') | 
|---|
| 4349 | { | 
|---|
| 4350 | # This means we have an alpha release.  See | 
|---|
| 4351 | # GNITS_VERSION_PATTERN for details. | 
|---|
| 4352 | push_dist_common ('README-alpha'); | 
|---|
| 4353 | } | 
|---|
| 4354 | } | 
|---|
| 4355 | } | 
|---|
| 4356 | } | 
|---|
| 4357 |  | 
|---|
| 4358 | ################################################################ | 
|---|
| 4359 |  | 
|---|
| 4360 | # ($OUTPUT, @INPUTS) | 
|---|
| 4361 | # &split_config_file_spec ($SPEC) | 
|---|
| 4362 | # ------------------------------- | 
|---|
| 4363 | # Decode the Autoconf syntax for config files (files, headers, links | 
|---|
| 4364 | # etc.). | 
|---|
| 4365 | sub split_config_file_spec ($) | 
|---|
| 4366 | { | 
|---|
| 4367 | my ($spec) = @_; | 
|---|
| 4368 | my ($output, @inputs) = split (/:/, $spec); | 
|---|
| 4369 |  | 
|---|
| 4370 | push @inputs, "$output.in" | 
|---|
| 4371 | unless @inputs; | 
|---|
| 4372 |  | 
|---|
| 4373 | return ($output, @inputs); | 
|---|
| 4374 | } | 
|---|
| 4375 |  | 
|---|
| 4376 | # $input | 
|---|
| 4377 | # locate_am (@POSSIBLE_SOURCES) | 
|---|
| 4378 | # ----------------------------- | 
|---|
| 4379 | # AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in | 
|---|
| 4380 | # This functions returns the first *.in file for which a *.am exists. | 
|---|
| 4381 | # It returns undef otherwise. | 
|---|
| 4382 | sub locate_am (@) | 
|---|
| 4383 | { | 
|---|
| 4384 | my (@rest) = @_; | 
|---|
| 4385 | my $input; | 
|---|
| 4386 | foreach my $file (@rest) | 
|---|
| 4387 | { | 
|---|
| 4388 | if (($file =~ /^(.*)\.in$/) && -f "$1.am") | 
|---|
| 4389 | { | 
|---|
| 4390 | $input = $file; | 
|---|
| 4391 | last; | 
|---|
| 4392 | } | 
|---|
| 4393 | } | 
|---|
| 4394 | return $input; | 
|---|
| 4395 | } | 
|---|
| 4396 |  | 
|---|
| 4397 | my %make_list; | 
|---|
| 4398 |  | 
|---|
| 4399 | # &scan_autoconf_config_files ($WHERE, $CONFIG-FILES) | 
|---|
| 4400 | # --------------------------------------------------- | 
|---|
| 4401 | # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES | 
|---|
| 4402 | # (or AC_OUTPUT). | 
|---|
| 4403 | sub scan_autoconf_config_files ($$) | 
|---|
| 4404 | { | 
|---|
| 4405 | my ($where, $config_files) = @_; | 
|---|
| 4406 |  | 
|---|
| 4407 | # Look at potential Makefile.am's. | 
|---|
| 4408 | foreach (split ' ', $config_files) | 
|---|
| 4409 | { | 
|---|
| 4410 | # Must skip empty string for Perl 4. | 
|---|
| 4411 | next if $_ eq "\\" || $_ eq ''; | 
|---|
| 4412 |  | 
|---|
| 4413 | # Handle $local:$input syntax. | 
|---|
| 4414 | my ($local, @rest) = split (/:/); | 
|---|
| 4415 | @rest = ("$local.in",) unless @rest; | 
|---|
| 4416 | my $input = locate_am @rest; | 
|---|
| 4417 | if ($input) | 
|---|
| 4418 | { | 
|---|
| 4419 | # We have a file that automake should generate. | 
|---|
| 4420 | $make_list{$input} = join (':', ($local, @rest)); | 
|---|
| 4421 | } | 
|---|
| 4422 | else | 
|---|
| 4423 | { | 
|---|
| 4424 | # We have a file that automake should cause to be | 
|---|
| 4425 | # rebuilt, but shouldn't generate itself. | 
|---|
| 4426 | push (@other_input_files, $_); | 
|---|
| 4427 | } | 
|---|
| 4428 | $ac_config_files_location{$local} = $where; | 
|---|
| 4429 | } | 
|---|
| 4430 | } | 
|---|
| 4431 |  | 
|---|
| 4432 |  | 
|---|
| 4433 | # &scan_autoconf_traces ($FILENAME) | 
|---|
| 4434 | # --------------------------------- | 
|---|
| 4435 | sub scan_autoconf_traces ($) | 
|---|
| 4436 | { | 
|---|
| 4437 | my ($filename) = @_; | 
|---|
| 4438 |  | 
|---|
| 4439 | # Macros to trace, with their minimal number of arguments. | 
|---|
| 4440 | my %traced = ( | 
|---|
| 4441 | AC_CANONICAL_HOST => 0, | 
|---|
| 4442 | AC_CANONICAL_SYSTEM => 0, | 
|---|
| 4443 | AC_CONFIG_AUX_DIR => 1, | 
|---|
| 4444 | AC_CONFIG_FILES => 1, | 
|---|
| 4445 | AC_CONFIG_HEADERS => 1, | 
|---|
| 4446 | AC_CONFIG_LINKS => 1, | 
|---|
| 4447 | AC_INIT => 0, | 
|---|
| 4448 | AC_LIBSOURCE => 1, | 
|---|
| 4449 | AC_SUBST => 1, | 
|---|
| 4450 | AM_AUTOMAKE_VERSION => 1, | 
|---|
| 4451 | AM_CONDITIONAL => 2, | 
|---|
| 4452 | AM_ENABLE_MULTILIB => 0, | 
|---|
| 4453 | AM_GNU_GETTEXT => 0, | 
|---|
| 4454 | AM_INIT_AUTOMAKE => 0, | 
|---|
| 4455 | AM_MAINTAINER_MODE => 0, | 
|---|
| 4456 | AM_PROG_CC_C_O => 0, | 
|---|
| 4457 | m4_include => 1, | 
|---|
| 4458 | m4_sinclude => 1, | 
|---|
| 4459 | sinclude => 1, | 
|---|
| 4460 | ); | 
|---|
| 4461 |  | 
|---|
| 4462 | my $traces = ($ENV{AUTOCONF} || 'autoconf') . " "; | 
|---|
| 4463 |  | 
|---|
| 4464 | # Use a separator unlikely to be used, not `:', the default, which | 
|---|
| 4465 | # has a precise meaning for AC_CONFIG_FILES and so on. | 
|---|
| 4466 | $traces .= join (' ', | 
|---|
| 4467 | map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' } | 
|---|
| 4468 | (keys %traced)); | 
|---|
| 4469 |  | 
|---|
| 4470 | my $tracefh = new Automake::XFile ("$traces $filename |"); | 
|---|
| 4471 | verb "reading $traces"; | 
|---|
| 4472 |  | 
|---|
| 4473 | while ($_ = $tracefh->getline) | 
|---|
| 4474 | { | 
|---|
| 4475 | chomp; | 
|---|
| 4476 | my ($here, @args) = split /::/; | 
|---|
| 4477 | my $where = new Automake::Location $here; | 
|---|
| 4478 | my $macro = $args[0]; | 
|---|
| 4479 |  | 
|---|
| 4480 | prog_error ("unrequested trace `$macro'") | 
|---|
| 4481 | unless exists $traced{$macro}; | 
|---|
| 4482 |  | 
|---|
| 4483 | # Skip and diagnose malformed calls. | 
|---|
| 4484 | if ($#args < $traced{$macro}) | 
|---|
| 4485 | { | 
|---|
| 4486 | msg ('syntax', $where, "not enough arguments for $macro"); | 
|---|
| 4487 | next; | 
|---|
| 4488 | } | 
|---|
| 4489 |  | 
|---|
| 4490 | # Alphabetical ordering please. | 
|---|
| 4491 | if ($macro eq 'AC_CANONICAL_HOST') | 
|---|
| 4492 | { | 
|---|
| 4493 | if (! $seen_canonical) | 
|---|
| 4494 | { | 
|---|
| 4495 | $seen_canonical = AC_CANONICAL_HOST; | 
|---|
| 4496 | $canonical_location = $where; | 
|---|
| 4497 | } | 
|---|
| 4498 | } | 
|---|
| 4499 | elsif ($macro eq 'AC_CANONICAL_SYSTEM') | 
|---|
| 4500 | { | 
|---|
| 4501 | $seen_canonical = AC_CANONICAL_SYSTEM; | 
|---|
| 4502 | $canonical_location = $where; | 
|---|
| 4503 | } | 
|---|
| 4504 | elsif ($macro eq 'AC_CONFIG_AUX_DIR') | 
|---|
| 4505 | { | 
|---|
| 4506 | @config_aux_path = $args[1]; | 
|---|
| 4507 | $config_aux_dir_set_in_configure_in = 1; | 
|---|
| 4508 | } | 
|---|
| 4509 | elsif ($macro eq 'AC_CONFIG_FILES') | 
|---|
| 4510 | { | 
|---|
| 4511 | # Look at potential Makefile.am's. | 
|---|
| 4512 | scan_autoconf_config_files ($where, $args[1]); | 
|---|
| 4513 | } | 
|---|
| 4514 | elsif ($macro eq 'AC_CONFIG_HEADERS') | 
|---|
| 4515 | { | 
|---|
| 4516 | foreach my $spec (split (' ', $args[1])) | 
|---|
| 4517 | { | 
|---|
| 4518 | my ($dest, @src) = split (':', $spec); | 
|---|
| 4519 | $ac_config_files_location{$dest} = $where; | 
|---|
| 4520 | push @config_headers, $spec; | 
|---|
| 4521 | } | 
|---|
| 4522 | } | 
|---|
| 4523 | elsif ($macro eq 'AC_CONFIG_LINKS') | 
|---|
| 4524 | { | 
|---|
| 4525 | foreach my $spec (split (' ', $args[1])) | 
|---|
| 4526 | { | 
|---|
| 4527 | my ($dest, $src) = split (':', $spec); | 
|---|
| 4528 | $ac_config_files_location{$dest} = $where; | 
|---|
| 4529 | push @config_links, $spec; | 
|---|
| 4530 | } | 
|---|
| 4531 | } | 
|---|
| 4532 | elsif ($macro eq 'AC_INIT') | 
|---|
| 4533 | { | 
|---|
| 4534 | if (defined $args[2]) | 
|---|
| 4535 | { | 
|---|
| 4536 | $package_version = $args[2]; | 
|---|
| 4537 | $package_version_location = $where; | 
|---|
| 4538 | } | 
|---|
| 4539 | } | 
|---|
| 4540 | elsif ($macro eq 'AC_LIBSOURCE') | 
|---|
| 4541 | { | 
|---|
| 4542 | $libsources{$args[1]} = $here; | 
|---|
| 4543 | } | 
|---|
| 4544 | elsif ($macro eq 'AC_SUBST') | 
|---|
| 4545 | { | 
|---|
| 4546 | # Just check for alphanumeric in AC_SUBST.  If you do | 
|---|
| 4547 | # AC_SUBST(5), then too bad. | 
|---|
| 4548 | $configure_vars{$args[1]} = $where | 
|---|
| 4549 | if $args[1] =~ /^\w+$/; | 
|---|
| 4550 | } | 
|---|
| 4551 | elsif ($macro eq 'AM_AUTOMAKE_VERSION') | 
|---|
| 4552 | { | 
|---|
| 4553 | error ($where, | 
|---|
| 4554 | "version mismatch.  This is Automake $VERSION,\n" . | 
|---|
| 4555 | "but the definition used by this AM_INIT_AUTOMAKE\n" . | 
|---|
| 4556 | "comes from Automake $args[1].  You should recreate\n" . | 
|---|
| 4557 | "aclocal.m4 with aclocal and run automake again.\n", | 
|---|
| 4558 | # $? = 63 is used to indicate version mismatch to missing. | 
|---|
| 4559 | exit_code => 63) | 
|---|
| 4560 | if $VERSION ne $args[1]; | 
|---|
| 4561 |  | 
|---|
| 4562 | $seen_automake_version = 1; | 
|---|
| 4563 | } | 
|---|
| 4564 | elsif ($macro eq 'AM_CONDITIONAL') | 
|---|
| 4565 | { | 
|---|
| 4566 | $configure_cond{$args[1]} = $where; | 
|---|
| 4567 | } | 
|---|
| 4568 | elsif ($macro eq 'AM_ENABLE_MULTILIB') | 
|---|
| 4569 | { | 
|---|
| 4570 | $seen_multilib = $where; | 
|---|
| 4571 | } | 
|---|
| 4572 | elsif ($macro eq 'AM_GNU_GETTEXT') | 
|---|
| 4573 | { | 
|---|
| 4574 | $seen_gettext = $where; | 
|---|
| 4575 | $ac_gettext_location = $where; | 
|---|
| 4576 | $seen_gettext_external = grep ($_ eq 'external', @args); | 
|---|
| 4577 | } | 
|---|
| 4578 | elsif ($macro eq 'AM_INIT_AUTOMAKE') | 
|---|
| 4579 | { | 
|---|
| 4580 | $seen_init_automake = $where; | 
|---|
| 4581 | if (defined $args[2]) | 
|---|
| 4582 | { | 
|---|
| 4583 | $package_version = $args[2]; | 
|---|
| 4584 | $package_version_location = $where; | 
|---|
| 4585 | } | 
|---|
| 4586 | elsif (defined $args[1]) | 
|---|
| 4587 | { | 
|---|
| 4588 | exit $exit_code | 
|---|
| 4589 | if (process_global_option_list ($where, | 
|---|
| 4590 | split (' ', $args[1]))); | 
|---|
| 4591 | } | 
|---|
| 4592 | } | 
|---|
| 4593 | elsif ($macro eq 'AM_MAINTAINER_MODE') | 
|---|
| 4594 | { | 
|---|
| 4595 | $seen_maint_mode = $where; | 
|---|
| 4596 | } | 
|---|
| 4597 | elsif ($macro eq 'AM_PROG_CC_C_O') | 
|---|
| 4598 | { | 
|---|
| 4599 | $seen_cc_c_o = $where; | 
|---|
| 4600 | } | 
|---|
| 4601 | elsif ($macro eq 'm4_include' | 
|---|
| 4602 | || $macro eq 'm4_sinclude' | 
|---|
| 4603 | || $macro eq 'sinclude') | 
|---|
| 4604 | { | 
|---|
| 4605 | # Some modified versions of Autoconf don't use | 
|---|
| 4606 | # forzen files.  Consequently it's possible that we see all | 
|---|
| 4607 | # m4_include's performed during Autoconf's startup. | 
|---|
| 4608 | # Obviously we don't want to distribute Autoconf's files | 
|---|
| 4609 | # so we skip absolute filenames here. | 
|---|
| 4610 | push @configure_deps, '$(top_srcdir)/' . $args[1] | 
|---|
| 4611 | unless $here =~ m,^(?:\w:)?[\\/],; | 
|---|
| 4612 | # Keep track of the greatest timestamp. | 
|---|
| 4613 | if (-e $args[1]) | 
|---|
| 4614 | { | 
|---|
| 4615 | my $mtime = mtime $args[1]; | 
|---|
| 4616 | $configure_deps_greatest_timestamp = $mtime | 
|---|
| 4617 | if $mtime > $configure_deps_greatest_timestamp; | 
|---|
| 4618 | } | 
|---|
| 4619 | } | 
|---|
| 4620 | } | 
|---|
| 4621 |  | 
|---|
| 4622 | $tracefh->close; | 
|---|
| 4623 | } | 
|---|
| 4624 |  | 
|---|
| 4625 |  | 
|---|
| 4626 | # &scan_autoconf_files () | 
|---|
| 4627 | # ----------------------- | 
|---|
| 4628 | # Check whether we use `configure.ac' or `configure.in'. | 
|---|
| 4629 | # Scan it (and possibly `aclocal.m4') for interesting things. | 
|---|
| 4630 | # We must scan aclocal.m4 because there might be AC_SUBSTs and such there. | 
|---|
| 4631 | sub scan_autoconf_files () | 
|---|
| 4632 | { | 
|---|
| 4633 | # Reinitialize libsources here.  This isn't really necessary, | 
|---|
| 4634 | # since we currently assume there is only one configure.ac.  But | 
|---|
| 4635 | # that won't always be the case. | 
|---|
| 4636 | %libsources = (); | 
|---|
| 4637 |  | 
|---|
| 4638 | # Keep track of the youngest configure dependency. | 
|---|
| 4639 | $configure_deps_greatest_timestamp = mtime $configure_ac; | 
|---|
| 4640 | if (-e 'aclocal.m4') | 
|---|
| 4641 | { | 
|---|
| 4642 | my $mtime = mtime 'aclocal.m4'; | 
|---|
| 4643 | $configure_deps_greatest_timestamp = $mtime | 
|---|
| 4644 | if $mtime > $configure_deps_greatest_timestamp; | 
|---|
| 4645 | } | 
|---|
| 4646 |  | 
|---|
| 4647 | scan_autoconf_traces ($configure_ac); | 
|---|
| 4648 |  | 
|---|
| 4649 | @configure_input_files = sort keys %make_list; | 
|---|
| 4650 | # Set input and output files if not specified by user. | 
|---|
| 4651 | if (! @input_files) | 
|---|
| 4652 | { | 
|---|
| 4653 | @input_files = @configure_input_files; | 
|---|
| 4654 | %output_files = %make_list; | 
|---|
| 4655 | } | 
|---|
| 4656 |  | 
|---|
| 4657 |  | 
|---|
| 4658 | if (! $seen_init_automake) | 
|---|
| 4659 | { | 
|---|
| 4660 | err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou " | 
|---|
| 4661 | . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE," | 
|---|
| 4662 | . "\nthat aclocal.m4 is present in the top-level directory,\n" | 
|---|
| 4663 | . "and that aclocal.m4 was recently regenerated " | 
|---|
| 4664 | . "(using aclocal)."); | 
|---|
| 4665 | } | 
|---|
| 4666 | else | 
|---|
| 4667 | { | 
|---|
| 4668 | if (! $seen_automake_version) | 
|---|
| 4669 | { | 
|---|
| 4670 | if (-f 'aclocal.m4') | 
|---|
| 4671 | { | 
|---|
| 4672 | error ($seen_init_automake, | 
|---|
| 4673 | "your implementation of AM_INIT_AUTOMAKE comes from " . | 
|---|
| 4674 | "an\nold Automake version.  You should recreate " . | 
|---|
| 4675 | "aclocal.m4\nwith aclocal and run automake again.\n", | 
|---|
| 4676 | # $? = 63 is used to indicate version mismatch to missing. | 
|---|
| 4677 | exit_code => 63); | 
|---|
| 4678 | } | 
|---|
| 4679 | else | 
|---|
| 4680 | { | 
|---|
| 4681 | error ($seen_init_automake, | 
|---|
| 4682 | "no proper implementation of AM_INIT_AUTOMAKE was " . | 
|---|
| 4683 | "found,\nprobably because aclocal.m4 is missing...\n" . | 
|---|
| 4684 | "You should run aclocal to create this file, then\n" . | 
|---|
| 4685 | "run automake again.\n"); | 
|---|
| 4686 | } | 
|---|
| 4687 | } | 
|---|
| 4688 | } | 
|---|
| 4689 |  | 
|---|
| 4690 | # Look for some files we need.  Always check for these.  This | 
|---|
| 4691 | # check must be done for every run, even those where we are only | 
|---|
| 4692 | # looking at a subdir Makefile.  We must set relative_dir so that | 
|---|
| 4693 | # the file-finding machinery works. | 
|---|
| 4694 | # FIXME: Is this broken because it needs dynamic scopes. | 
|---|
| 4695 | # My tests seems to show it's not the case. | 
|---|
| 4696 | $relative_dir = '.'; | 
|---|
| 4697 | require_conf_file ($configure_ac, FOREIGN, 'install-sh', 'missing'); | 
|---|
| 4698 | err_am "`install.sh' is an anachronism; use `install-sh' instead" | 
|---|
| 4699 | if -f $config_aux_path[0] . '/install.sh'; | 
|---|
| 4700 |  | 
|---|
| 4701 | # Preserve dist_common for later. | 
|---|
| 4702 | $configure_dist_common = variable_value ('DIST_COMMON') || ''; | 
|---|
| 4703 | } | 
|---|
| 4704 |  | 
|---|
| 4705 | ################################################################ | 
|---|
| 4706 |  | 
|---|
| 4707 | # Set up for Cygnus mode. | 
|---|
| 4708 | sub check_cygnus | 
|---|
| 4709 | { | 
|---|
| 4710 | my $cygnus = option 'cygnus'; | 
|---|
| 4711 | return unless $cygnus; | 
|---|
| 4712 |  | 
|---|
| 4713 | set_strictness ('foreign'); | 
|---|
| 4714 | set_option ('no-installinfo', $cygnus); | 
|---|
| 4715 | set_option ('no-dependencies', $cygnus); | 
|---|
| 4716 | set_option ('no-dist', $cygnus); | 
|---|
| 4717 |  | 
|---|
| 4718 | err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified" | 
|---|
| 4719 | if !$seen_maint_mode; | 
|---|
| 4720 | } | 
|---|
| 4721 |  | 
|---|
| 4722 | # Do any extra checking for GNU standards. | 
|---|
| 4723 | sub check_gnu_standards | 
|---|
| 4724 | { | 
|---|
| 4725 | if ($relative_dir eq '.') | 
|---|
| 4726 | { | 
|---|
| 4727 | # In top level (or only) directory. | 
|---|
| 4728 | require_file ("$am_file.am", GNU, | 
|---|
| 4729 | qw/INSTALL NEWS README AUTHORS ChangeLog/); | 
|---|
| 4730 |  | 
|---|
| 4731 | # Accept one of these three licenses; default to COPYING. | 
|---|
| 4732 | # Make sure we do not overwrite an existing license. | 
|---|
| 4733 | my $license; | 
|---|
| 4734 | foreach (qw /COPYING COPYING.LIB COPYING.LESSER/) | 
|---|
| 4735 | { | 
|---|
| 4736 | if (-f $_) | 
|---|
| 4737 | { | 
|---|
| 4738 | $license = $_; | 
|---|
| 4739 | last; | 
|---|
| 4740 | } | 
|---|
| 4741 | } | 
|---|
| 4742 | require_file ("$am_file.am", GNU, 'COPYING') | 
|---|
| 4743 | unless $license; | 
|---|
| 4744 | } | 
|---|
| 4745 |  | 
|---|
| 4746 | for my $opt ('no-installman', 'no-installinfo') | 
|---|
| 4747 | { | 
|---|
| 4748 | msg ('error-gnu', option $opt, | 
|---|
| 4749 | "option `$opt' disallowed by GNU standards") | 
|---|
| 4750 | if option $opt; | 
|---|
| 4751 | } | 
|---|
| 4752 | } | 
|---|
| 4753 |  | 
|---|
| 4754 | # Do any extra checking for GNITS standards. | 
|---|
| 4755 | sub check_gnits_standards | 
|---|
| 4756 | { | 
|---|
| 4757 | if ($relative_dir eq '.') | 
|---|
| 4758 | { | 
|---|
| 4759 | # In top level (or only) directory. | 
|---|
| 4760 | require_file ("$am_file.am", GNITS, 'THANKS'); | 
|---|
| 4761 | } | 
|---|
| 4762 | } | 
|---|
| 4763 |  | 
|---|
| 4764 | ################################################################ | 
|---|
| 4765 | # | 
|---|
| 4766 | # Functions to handle files of each language. | 
|---|
| 4767 |  | 
|---|
| 4768 | # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a | 
|---|
| 4769 | # simple formula: Return value is LANG_SUBDIR if the resulting object | 
|---|
| 4770 | # file should be in a subdir if the source file is, LANG_PROCESS if | 
|---|
| 4771 | # file is to be dealt with, LANG_IGNORE otherwise. | 
|---|
| 4772 |  | 
|---|
| 4773 | # Much of the actual processing is handled in | 
|---|
| 4774 | # handle_single_transform_list.  These functions exist so that | 
|---|
| 4775 | # auxiliary information can be recorded for a later cleanup pass. | 
|---|
| 4776 | # Note that the calls to these functions are computed, so don't bother | 
|---|
| 4777 | # searching for their precise names in the source. | 
|---|
| 4778 |  | 
|---|
| 4779 | # This is just a convenience function that can be used to determine | 
|---|
| 4780 | # when a subdir object should be used. | 
|---|
| 4781 | sub lang_sub_obj | 
|---|
| 4782 | { | 
|---|
| 4783 | return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS; | 
|---|
| 4784 | } | 
|---|
| 4785 |  | 
|---|
| 4786 | # Rewrite a single C source file. | 
|---|
| 4787 | sub lang_c_rewrite | 
|---|
| 4788 | { | 
|---|
| 4789 | my ($directory, $base, $ext) = @_; | 
|---|
| 4790 |  | 
|---|
| 4791 | if (option 'ansi2knr' && $base =~ /_$/) | 
|---|
| 4792 | { | 
|---|
| 4793 | # FIXME: include line number in error. | 
|---|
| 4794 | err_am "C source file `$base.c' would be deleted by ansi2knr rules"; | 
|---|
| 4795 | } | 
|---|
| 4796 |  | 
|---|
| 4797 | my $r = LANG_PROCESS; | 
|---|
| 4798 | if (option 'subdir-objects') | 
|---|
| 4799 | { | 
|---|
| 4800 | $r = LANG_SUBDIR; | 
|---|
| 4801 | $base = $directory . '/' . $base | 
|---|
| 4802 | unless $directory eq '.' || $directory eq ''; | 
|---|
| 4803 |  | 
|---|
| 4804 | err_am ("C objects in subdir but `AM_PROG_CC_C_O' " | 
|---|
| 4805 | . "not in `$configure_ac'", | 
|---|
| 4806 | uniq_scope => US_GLOBAL) | 
|---|
| 4807 | unless $seen_cc_c_o; | 
|---|
| 4808 |  | 
|---|
| 4809 | require_conf_file ("$am_file.am", FOREIGN, 'compile'); | 
|---|
| 4810 |  | 
|---|
| 4811 | # In this case we already have the directory information, so | 
|---|
| 4812 | # don't add it again. | 
|---|
| 4813 | $de_ansi_files{$base} = ''; | 
|---|
| 4814 | } | 
|---|
| 4815 | else | 
|---|
| 4816 | { | 
|---|
| 4817 | $de_ansi_files{$base} = (($directory eq '.' || $directory eq '') | 
|---|
| 4818 | ? '' | 
|---|
| 4819 | : "$directory/"); | 
|---|
| 4820 | } | 
|---|
| 4821 |  | 
|---|
| 4822 | return $r; | 
|---|
| 4823 | } | 
|---|
| 4824 |  | 
|---|
| 4825 | # Rewrite a single C++ source file. | 
|---|
| 4826 | sub lang_cxx_rewrite | 
|---|
| 4827 | { | 
|---|
| 4828 | return &lang_sub_obj; | 
|---|
| 4829 | } | 
|---|
| 4830 |  | 
|---|
| 4831 | # Rewrite a single header file. | 
|---|
| 4832 | sub lang_header_rewrite | 
|---|
| 4833 | { | 
|---|
| 4834 | # Header files are simply ignored. | 
|---|
| 4835 | return LANG_IGNORE; | 
|---|
| 4836 | } | 
|---|
| 4837 |  | 
|---|
| 4838 | # Rewrite a single yacc file. | 
|---|
| 4839 | sub lang_yacc_rewrite | 
|---|
| 4840 | { | 
|---|
| 4841 | my ($directory, $base, $ext) = @_; | 
|---|
| 4842 |  | 
|---|
| 4843 | my $r = &lang_sub_obj; | 
|---|
| 4844 | (my $newext = $ext) =~ tr/y/c/; | 
|---|
| 4845 | return ($r, $newext); | 
|---|
| 4846 | } | 
|---|
| 4847 |  | 
|---|
| 4848 | # Rewrite a single yacc++ file. | 
|---|
| 4849 | sub lang_yaccxx_rewrite | 
|---|
| 4850 | { | 
|---|
| 4851 | my ($directory, $base, $ext) = @_; | 
|---|
| 4852 |  | 
|---|
| 4853 | my $r = &lang_sub_obj; | 
|---|
| 4854 | (my $newext = $ext) =~ tr/y/c/; | 
|---|
| 4855 | return ($r, $newext); | 
|---|
| 4856 | } | 
|---|
| 4857 |  | 
|---|
| 4858 | # Rewrite a single lex file. | 
|---|
| 4859 | sub lang_lex_rewrite | 
|---|
| 4860 | { | 
|---|
| 4861 | my ($directory, $base, $ext) = @_; | 
|---|
| 4862 |  | 
|---|
| 4863 | my $r = &lang_sub_obj; | 
|---|
| 4864 | (my $newext = $ext) =~ tr/l/c/; | 
|---|
| 4865 | return ($r, $newext); | 
|---|
| 4866 | } | 
|---|
| 4867 |  | 
|---|
| 4868 | # Rewrite a single lex++ file. | 
|---|
| 4869 | sub lang_lexxx_rewrite | 
|---|
| 4870 | { | 
|---|
| 4871 | my ($directory, $base, $ext) = @_; | 
|---|
| 4872 |  | 
|---|
| 4873 | my $r = &lang_sub_obj; | 
|---|
| 4874 | (my $newext = $ext) =~ tr/l/c/; | 
|---|
| 4875 | return ($r, $newext); | 
|---|
| 4876 | } | 
|---|
| 4877 |  | 
|---|
| 4878 | # Rewrite a single assembly file. | 
|---|
| 4879 | sub lang_asm_rewrite | 
|---|
| 4880 | { | 
|---|
| 4881 | return &lang_sub_obj; | 
|---|
| 4882 | } | 
|---|
| 4883 |  | 
|---|
| 4884 | # Rewrite a single Fortran 77 file. | 
|---|
| 4885 | sub lang_f77_rewrite | 
|---|
| 4886 | { | 
|---|
| 4887 | return LANG_PROCESS; | 
|---|
| 4888 | } | 
|---|
| 4889 |  | 
|---|
| 4890 | # Rewrite a single preprocessed Fortran 77 file. | 
|---|
| 4891 | sub lang_ppf77_rewrite | 
|---|
| 4892 | { | 
|---|
| 4893 | return LANG_PROCESS; | 
|---|
| 4894 | } | 
|---|
| 4895 |  | 
|---|
| 4896 | # Rewrite a single ratfor file. | 
|---|
| 4897 | sub lang_ratfor_rewrite | 
|---|
| 4898 | { | 
|---|
| 4899 | return LANG_PROCESS; | 
|---|
| 4900 | } | 
|---|
| 4901 |  | 
|---|
| 4902 | # Rewrite a single Objective C file. | 
|---|
| 4903 | sub lang_objc_rewrite | 
|---|
| 4904 | { | 
|---|
| 4905 | return &lang_sub_obj; | 
|---|
| 4906 | } | 
|---|
| 4907 |  | 
|---|
| 4908 | # Rewrite a single Java file. | 
|---|
| 4909 | sub lang_java_rewrite | 
|---|
| 4910 | { | 
|---|
| 4911 | return LANG_SUBDIR; | 
|---|
| 4912 | } | 
|---|
| 4913 |  | 
|---|
| 4914 | # The lang_X_finish functions are called after all source file | 
|---|
| 4915 | # processing is done.  Each should handle defining rules for the | 
|---|
| 4916 | # language, etc.  A finish function is only called if a source file of | 
|---|
| 4917 | # the appropriate type has been seen. | 
|---|
| 4918 |  | 
|---|
| 4919 | sub lang_c_finish | 
|---|
| 4920 | { | 
|---|
| 4921 | # Push all libobjs files onto de_ansi_files.  We actually only | 
|---|
| 4922 | # push files which exist in the current directory, and which are | 
|---|
| 4923 | # genuine source files. | 
|---|
| 4924 | foreach my $file (keys %libsources) | 
|---|
| 4925 | { | 
|---|
| 4926 | if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file") | 
|---|
| 4927 | { | 
|---|
| 4928 | $de_ansi_files{$1} = '' | 
|---|
| 4929 | } | 
|---|
| 4930 | } | 
|---|
| 4931 |  | 
|---|
| 4932 | if (option 'ansi2knr' && keys %de_ansi_files) | 
|---|
| 4933 | { | 
|---|
| 4934 | # Make all _.c files depend on their corresponding .c files. | 
|---|
| 4935 | my @objects; | 
|---|
| 4936 | foreach my $base (sort keys %de_ansi_files) | 
|---|
| 4937 | { | 
|---|
| 4938 | # Each _.c file must depend on ansi2knr; otherwise it | 
|---|
| 4939 | # might be used in a parallel build before it is built. | 
|---|
| 4940 | # We need to support files in the srcdir and in the build | 
|---|
| 4941 | # dir (because these files might be auto-generated.  But | 
|---|
| 4942 | # we can't use $< -- some makes only define $< during a | 
|---|
| 4943 | # suffix rule. | 
|---|
| 4944 | my $ansfile = $de_ansi_files{$base} . $base . '.c'; | 
|---|
| 4945 | $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t" | 
|---|
| 4946 | . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) ' | 
|---|
| 4947 | . '`if test -f $(srcdir)/' . $ansfile | 
|---|
| 4948 | . '; then echo $(srcdir)/' . $ansfile | 
|---|
| 4949 | . '; else echo ' . $ansfile . '; fi` ' | 
|---|
| 4950 | . "| sed 's/^# \\([0-9]\\)/#line \\1/' " | 
|---|
| 4951 | . '| $(ANSI2KNR) > $@' | 
|---|
| 4952 | # If ansi2knr fails then we shouldn't | 
|---|
| 4953 | # create the _.c file | 
|---|
| 4954 | . " || rm -f \$\@\n"); | 
|---|
| 4955 | push (@objects, $base . '_.$(OBJEXT)'); | 
|---|
| 4956 | push (@objects, $base . '_.lo') | 
|---|
| 4957 | if var ('LIBTOOL'); | 
|---|
| 4958 | } | 
|---|
| 4959 |  | 
|---|
| 4960 | # Make all _.o (and _.lo) files depend on ansi2knr. | 
|---|
| 4961 | # Use a sneaky little hack to make it print nicely. | 
|---|
| 4962 | &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)'); | 
|---|
| 4963 | } | 
|---|
| 4964 | } | 
|---|
| 4965 |  | 
|---|
| 4966 | # This is a yacc helper which is called whenever we have decided to | 
|---|
| 4967 | # compile a yacc file. | 
|---|
| 4968 | sub lang_yacc_target_hook | 
|---|
| 4969 | { | 
|---|
| 4970 | my ($self, $aggregate, $output, $input) = @_; | 
|---|
| 4971 |  | 
|---|
| 4972 | my $flag = $aggregate . "_YFLAGS"; | 
|---|
| 4973 | my $flagvar = var $flag; | 
|---|
| 4974 | my $YFLAGSvar = var 'YFLAGS'; | 
|---|
| 4975 | if (($flagvar && $flagvar->variable_value =~ /$DASH_D_PATTERN/o) | 
|---|
| 4976 | || ($YFLAGSvar && $YFLAGSvar->variable_value =~ /$DASH_D_PATTERN/o)) | 
|---|
| 4977 | { | 
|---|
| 4978 | (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//; | 
|---|
| 4979 | my $header = $output_base . '.h'; | 
|---|
| 4980 |  | 
|---|
| 4981 | # Found a `-d' that applies to the compilation of this file. | 
|---|
| 4982 | # Add a dependency for the generated header file, and arrange | 
|---|
| 4983 | # for that file to be included in the distribution. | 
|---|
| 4984 | # FIXME: this fails for `nodist_*_SOURCES'. | 
|---|
| 4985 | foreach my $cond (Automake::Rule::define (${header}, 'internal', | 
|---|
| 4986 | RULE_AUTOMAKE, TRUE, | 
|---|
| 4987 | INTERNAL)) | 
|---|
| 4988 | { | 
|---|
| 4989 | my $condstr = $cond->subst_string; | 
|---|
| 4990 | $output_rules .= ("$condstr${header}: $output\n" | 
|---|
| 4991 | # Recover from removal of $header | 
|---|
| 4992 | . "$condstr\t\@if test ! -f \$@; then \\\n" | 
|---|
| 4993 | . "$condstr\t  rm -f $output; \\\n" | 
|---|
| 4994 | . "$condstr\t  \$(MAKE) $output; \\\n" | 
|---|
| 4995 | . "$condstr\telse :; fi\n"); | 
|---|
| 4996 | } | 
|---|
| 4997 | &push_dist_common ($header); | 
|---|
| 4998 |  | 
|---|
| 4999 | # If the files are built in the build directory, then we want | 
|---|
| 5000 | # to remove them with `make clean'.  If they are in srcdir | 
|---|
| 5001 | # they shouldn't be touched.  However, we can't determine this | 
|---|
| 5002 | # statically, and the GNU rules say that yacc/lex output files | 
|---|
| 5003 | # should be removed by maintainer-clean.  So that's what we | 
|---|
| 5004 | # do. | 
|---|
| 5005 | $clean_files{$header} = MAINTAINER_CLEAN; | 
|---|
| 5006 | } | 
|---|
| 5007 | # Erase $OUTPUT on `make maintainer-clean' (by GNU standards). | 
|---|
| 5008 | # See the comment above for $HEADER. | 
|---|
| 5009 | $clean_files{$output} = MAINTAINER_CLEAN; | 
|---|
| 5010 | } | 
|---|
| 5011 |  | 
|---|
| 5012 | # This is a lex helper which is called whenever we have decided to | 
|---|
| 5013 | # compile a lex file. | 
|---|
| 5014 | sub lang_lex_target_hook | 
|---|
| 5015 | { | 
|---|
| 5016 | my ($self, $aggregate, $output, $input) = @_; | 
|---|
| 5017 | # If the files are built in the build directory, then we want to | 
|---|
| 5018 | # remove them with `make clean'.  If they are in srcdir they | 
|---|
| 5019 | # shouldn't be touched.  However, we can't determine this | 
|---|
| 5020 | # statically, and the GNU rules say that yacc/lex output files | 
|---|
| 5021 | # should be removed by maintainer-clean.  So that's what we do. | 
|---|
| 5022 | $clean_files{$output} = MAINTAINER_CLEAN; | 
|---|
| 5023 | } | 
|---|
| 5024 |  | 
|---|
| 5025 | # This is a helper for both lex and yacc. | 
|---|
| 5026 | sub yacc_lex_finish_helper | 
|---|
| 5027 | { | 
|---|
| 5028 | return if defined $language_scratch{'lex-yacc-done'}; | 
|---|
| 5029 | $language_scratch{'lex-yacc-done'} = 1; | 
|---|
| 5030 |  | 
|---|
| 5031 | # If there is more than one distinct yacc (resp lex) source file | 
|---|
| 5032 | # in a given directory, then the `ylwrap' program is required to | 
|---|
| 5033 | # allow parallel builds to work correctly.  FIXME: for now, no | 
|---|
| 5034 | # line number. | 
|---|
| 5035 | require_conf_file ($configure_ac, FOREIGN, 'ylwrap'); | 
|---|
| 5036 | if ($config_aux_dir_set_in_configure_in) | 
|---|
| 5037 | { | 
|---|
| 5038 | &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap", INTERNAL); | 
|---|
| 5039 | } | 
|---|
| 5040 | else | 
|---|
| 5041 | { | 
|---|
| 5042 | &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap', INTERNAL); | 
|---|
| 5043 | } | 
|---|
| 5044 | } | 
|---|
| 5045 |  | 
|---|
| 5046 | sub lang_yacc_finish | 
|---|
| 5047 | { | 
|---|
| 5048 | return if defined $language_scratch{'yacc-done'}; | 
|---|
| 5049 | $language_scratch{'yacc-done'} = 1; | 
|---|
| 5050 |  | 
|---|
| 5051 | reject_var 'YACCFLAGS', "`YACCFLAGS' obsolete; use `YFLAGS' instead"; | 
|---|
| 5052 |  | 
|---|
| 5053 | &yacc_lex_finish_helper | 
|---|
| 5054 | if count_files_for_language ('yacc') > 1; | 
|---|
| 5055 | } | 
|---|
| 5056 |  | 
|---|
| 5057 |  | 
|---|
| 5058 | sub lang_lex_finish | 
|---|
| 5059 | { | 
|---|
| 5060 | return if defined $language_scratch{'lex-done'}; | 
|---|
| 5061 | $language_scratch{'lex-done'} = 1; | 
|---|
| 5062 |  | 
|---|
| 5063 | &yacc_lex_finish_helper | 
|---|
| 5064 | if count_files_for_language ('lex') > 1; | 
|---|
| 5065 | } | 
|---|
| 5066 |  | 
|---|
| 5067 |  | 
|---|
| 5068 | # Given a hash table of linker names, pick the name that has the most | 
|---|
| 5069 | # precedence.  This is lame, but something has to have global | 
|---|
| 5070 | # knowledge in order to eliminate the conflict.  Add more linkers as | 
|---|
| 5071 | # required. | 
|---|
| 5072 | sub resolve_linker | 
|---|
| 5073 | { | 
|---|
| 5074 | my (%linkers) = @_; | 
|---|
| 5075 |  | 
|---|
| 5076 | foreach my $l (qw(GCJLINK CXXLINK F77LINK OBJCLINK)) | 
|---|
| 5077 | { | 
|---|
| 5078 | return $l if defined $linkers{$l}; | 
|---|
| 5079 | } | 
|---|
| 5080 | return 'LINK'; | 
|---|
| 5081 | } | 
|---|
| 5082 |  | 
|---|
| 5083 | # Called to indicate that an extension was used. | 
|---|
| 5084 | sub saw_extension | 
|---|
| 5085 | { | 
|---|
| 5086 | my ($ext) = @_; | 
|---|
| 5087 | if (! defined $extension_seen{$ext}) | 
|---|
| 5088 | { | 
|---|
| 5089 | $extension_seen{$ext} = 1; | 
|---|
| 5090 | } | 
|---|
| 5091 | else | 
|---|
| 5092 | { | 
|---|
| 5093 | ++$extension_seen{$ext}; | 
|---|
| 5094 | } | 
|---|
| 5095 | } | 
|---|
| 5096 |  | 
|---|
| 5097 | # Return the number of files seen for a given language.  Knows about | 
|---|
| 5098 | # special cases we care about.  FIXME: this is hideous.  We need | 
|---|
| 5099 | # something that involves real language objects.  For instance yacc | 
|---|
| 5100 | # and yaccxx could both derive from a common yacc class which would | 
|---|
| 5101 | # know about the strange ylwrap requirement.  (Or better yet we could | 
|---|
| 5102 | # just not support legacy yacc!) | 
|---|
| 5103 | sub count_files_for_language | 
|---|
| 5104 | { | 
|---|
| 5105 | my ($name) = @_; | 
|---|
| 5106 |  | 
|---|
| 5107 | my @names; | 
|---|
| 5108 | if ($name eq 'yacc' || $name eq 'yaccxx') | 
|---|
| 5109 | { | 
|---|
| 5110 | @names = ('yacc', 'yaccxx'); | 
|---|
| 5111 | } | 
|---|
| 5112 | elsif ($name eq 'lex' || $name eq 'lexxx') | 
|---|
| 5113 | { | 
|---|
| 5114 | @names = ('lex', 'lexxx'); | 
|---|
| 5115 | } | 
|---|
| 5116 | else | 
|---|
| 5117 | { | 
|---|
| 5118 | @names = ($name); | 
|---|
| 5119 | } | 
|---|
| 5120 |  | 
|---|
| 5121 | my $r = 0; | 
|---|
| 5122 | foreach $name (@names) | 
|---|
| 5123 | { | 
|---|
| 5124 | my $lang = $languages{$name}; | 
|---|
| 5125 | foreach my $ext (@{$lang->extensions}) | 
|---|
| 5126 | { | 
|---|
| 5127 | $r += $extension_seen{$ext} | 
|---|
| 5128 | if defined $extension_seen{$ext}; | 
|---|
| 5129 | } | 
|---|
| 5130 | } | 
|---|
| 5131 |  | 
|---|
| 5132 | return $r | 
|---|
| 5133 | } | 
|---|
| 5134 |  | 
|---|
| 5135 | # Called to ask whether source files have been seen . If HEADERS is 1, | 
|---|
| 5136 | # headers can be included. | 
|---|
| 5137 | sub saw_sources_p | 
|---|
| 5138 | { | 
|---|
| 5139 | my ($headers) = @_; | 
|---|
| 5140 |  | 
|---|
| 5141 | # count all the sources | 
|---|
| 5142 | my $count = 0; | 
|---|
| 5143 | foreach my $val (values %extension_seen) | 
|---|
| 5144 | { | 
|---|
| 5145 | $count += $val; | 
|---|
| 5146 | } | 
|---|
| 5147 |  | 
|---|
| 5148 | if (!$headers) | 
|---|
| 5149 | { | 
|---|
| 5150 | $count -= count_files_for_language ('header'); | 
|---|
| 5151 | } | 
|---|
| 5152 |  | 
|---|
| 5153 | return $count > 0; | 
|---|
| 5154 | } | 
|---|
| 5155 |  | 
|---|
| 5156 |  | 
|---|
| 5157 | # register_language (%ATTRIBUTE) | 
|---|
| 5158 | # ------------------------------ | 
|---|
| 5159 | # Register a single language. | 
|---|
| 5160 | # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE. | 
|---|
| 5161 | sub register_language (%) | 
|---|
| 5162 | { | 
|---|
| 5163 | my (%option) = @_; | 
|---|
| 5164 |  | 
|---|
| 5165 | # Set the defaults. | 
|---|
| 5166 | $option{'ansi'} = 0 | 
|---|
| 5167 | unless defined $option{'ansi'}; | 
|---|
| 5168 | $option{'autodep'} = 'no' | 
|---|
| 5169 | unless defined $option{'autodep'}; | 
|---|
| 5170 | $option{'linker'} = '' | 
|---|
| 5171 | unless defined $option{'linker'}; | 
|---|
| 5172 | $option{'flags'} = [] | 
|---|
| 5173 | unless defined $option{'flags'}; | 
|---|
| 5174 | $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) } | 
|---|
| 5175 | unless defined $option{'output_extensions'}; | 
|---|
| 5176 |  | 
|---|
| 5177 | my $lang = new Language (%option); | 
|---|
| 5178 |  | 
|---|
| 5179 | # Fill indexes. | 
|---|
| 5180 | $extension_map{$_} = $lang->name foreach @{$lang->extensions}; | 
|---|
| 5181 | $languages{$lang->name} = $lang; | 
|---|
| 5182 |  | 
|---|
| 5183 | # Update the pattern of known extensions. | 
|---|
| 5184 | accept_extensions (@{$lang->extensions}); | 
|---|
| 5185 |  | 
|---|
| 5186 | # Upate the $suffix_rule map. | 
|---|
| 5187 | foreach my $suffix (@{$lang->extensions}) | 
|---|
| 5188 | { | 
|---|
| 5189 | foreach my $dest (&{$lang->output_extensions} ($suffix)) | 
|---|
| 5190 | { | 
|---|
| 5191 | register_suffix_rule (INTERNAL, $suffix, $dest); | 
|---|
| 5192 | } | 
|---|
| 5193 | } | 
|---|
| 5194 | } | 
|---|
| 5195 |  | 
|---|
| 5196 | # derive_suffix ($EXT, $OBJ) | 
|---|
| 5197 | # -------------------------- | 
|---|
| 5198 | # This function is used to find a path from a user-specified suffix $EXT | 
|---|
| 5199 | # to $OBJ or to some other suffix we recognize internally, e.g. `cc'. | 
|---|
| 5200 | sub derive_suffix ($$) | 
|---|
| 5201 | { | 
|---|
| 5202 | my ($source_ext, $obj) = @_; | 
|---|
| 5203 |  | 
|---|
| 5204 | while (! $extension_map{$source_ext} | 
|---|
| 5205 | && $source_ext ne $obj | 
|---|
| 5206 | && exists $suffix_rules->{$source_ext} | 
|---|
| 5207 | && exists $suffix_rules->{$source_ext}{$obj}) | 
|---|
| 5208 | { | 
|---|
| 5209 | $source_ext = $suffix_rules->{$source_ext}{$obj}[0]; | 
|---|
| 5210 | } | 
|---|
| 5211 |  | 
|---|
| 5212 | return $source_ext; | 
|---|
| 5213 | } | 
|---|
| 5214 |  | 
|---|
| 5215 |  | 
|---|
| 5216 | ################################################################ | 
|---|
| 5217 |  | 
|---|
| 5218 | # Pretty-print something and append to output_rules. | 
|---|
| 5219 | sub pretty_print_rule | 
|---|
| 5220 | { | 
|---|
| 5221 | $output_rules .= &makefile_wrap (@_); | 
|---|
| 5222 | } | 
|---|
| 5223 |  | 
|---|
| 5224 |  | 
|---|
| 5225 | ################################################################ | 
|---|
| 5226 |  | 
|---|
| 5227 |  | 
|---|
| 5228 | ## -------------------------------- ## | 
|---|
| 5229 | ## Handling the conditional stack.  ## | 
|---|
| 5230 | ## -------------------------------- ## | 
|---|
| 5231 |  | 
|---|
| 5232 |  | 
|---|
| 5233 | # $STRING | 
|---|
| 5234 | # make_conditional_string ($NEGATE, $COND) | 
|---|
| 5235 | # ---------------------------------------- | 
|---|
| 5236 | sub make_conditional_string ($$) | 
|---|
| 5237 | { | 
|---|
| 5238 | my ($negate, $cond) = @_; | 
|---|
| 5239 | $cond = "${cond}_TRUE" | 
|---|
| 5240 | unless $cond =~ /^TRUE|FALSE$/; | 
|---|
| 5241 | $cond = Automake::Condition::conditional_negate ($cond) | 
|---|
| 5242 | if $negate; | 
|---|
| 5243 | return $cond; | 
|---|
| 5244 | } | 
|---|
| 5245 |  | 
|---|
| 5246 |  | 
|---|
| 5247 | # $COND | 
|---|
| 5248 | # cond_stack_if ($NEGATE, $COND, $WHERE) | 
|---|
| 5249 | # -------------------------------------- | 
|---|
| 5250 | sub cond_stack_if ($$$) | 
|---|
| 5251 | { | 
|---|
| 5252 | my ($negate, $cond, $where) = @_; | 
|---|
| 5253 |  | 
|---|
| 5254 | error $where, "$cond does not appear in AM_CONDITIONAL" | 
|---|
| 5255 | if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/; | 
|---|
| 5256 |  | 
|---|
| 5257 | push (@cond_stack, make_conditional_string ($negate, $cond)); | 
|---|
| 5258 |  | 
|---|
| 5259 | return new Automake::Condition (@cond_stack); | 
|---|
| 5260 | } | 
|---|
| 5261 |  | 
|---|
| 5262 |  | 
|---|
| 5263 | # $COND | 
|---|
| 5264 | # cond_stack_else ($NEGATE, $COND, $WHERE) | 
|---|
| 5265 | # ---------------------------------------- | 
|---|
| 5266 | sub cond_stack_else ($$$) | 
|---|
| 5267 | { | 
|---|
| 5268 | my ($negate, $cond, $where) = @_; | 
|---|
| 5269 |  | 
|---|
| 5270 | if (! @cond_stack) | 
|---|
| 5271 | { | 
|---|
| 5272 | error $where, "else without if"; | 
|---|
| 5273 | return FALSE; | 
|---|
| 5274 | } | 
|---|
| 5275 |  | 
|---|
| 5276 | $cond_stack[$#cond_stack] = | 
|---|
| 5277 | Automake::Condition::conditional_negate ($cond_stack[$#cond_stack]); | 
|---|
| 5278 |  | 
|---|
| 5279 | # If $COND is given, check against it. | 
|---|
| 5280 | if (defined $cond) | 
|---|
| 5281 | { | 
|---|
| 5282 | $cond = make_conditional_string ($negate, $cond); | 
|---|
| 5283 |  | 
|---|
| 5284 | error ($where, "else reminder ($negate$cond) incompatible with " | 
|---|
| 5285 | . "current conditional: $cond_stack[$#cond_stack]") | 
|---|
| 5286 | if $cond_stack[$#cond_stack] ne $cond; | 
|---|
| 5287 | } | 
|---|
| 5288 |  | 
|---|
| 5289 | return new Automake::Condition (@cond_stack); | 
|---|
| 5290 | } | 
|---|
| 5291 |  | 
|---|
| 5292 |  | 
|---|
| 5293 | # $COND | 
|---|
| 5294 | # cond_stack_endif ($NEGATE, $COND, $WHERE) | 
|---|
| 5295 | # ----------------------------------------- | 
|---|
| 5296 | sub cond_stack_endif ($$$) | 
|---|
| 5297 | { | 
|---|
| 5298 | my ($negate, $cond, $where) = @_; | 
|---|
| 5299 | my $old_cond; | 
|---|
| 5300 |  | 
|---|
| 5301 | if (! @cond_stack) | 
|---|
| 5302 | { | 
|---|
| 5303 | error $where, "endif without if"; | 
|---|
| 5304 | return TRUE; | 
|---|
| 5305 | } | 
|---|
| 5306 |  | 
|---|
| 5307 | # If $COND is given, check against it. | 
|---|
| 5308 | if (defined $cond) | 
|---|
| 5309 | { | 
|---|
| 5310 | $cond = make_conditional_string ($negate, $cond); | 
|---|
| 5311 |  | 
|---|
| 5312 | error ($where, "endif reminder ($negate$cond) incompatible with " | 
|---|
| 5313 | . "current conditional: $cond_stack[$#cond_stack]") | 
|---|
| 5314 | if $cond_stack[$#cond_stack] ne $cond; | 
|---|
| 5315 | } | 
|---|
| 5316 |  | 
|---|
| 5317 | pop @cond_stack; | 
|---|
| 5318 |  | 
|---|
| 5319 | return new Automake::Condition (@cond_stack); | 
|---|
| 5320 | } | 
|---|
| 5321 |  | 
|---|
| 5322 |  | 
|---|
| 5323 |  | 
|---|
| 5324 |  | 
|---|
| 5325 |  | 
|---|
| 5326 | ## ------------------------ ## | 
|---|
| 5327 | ## Handling the variables.  ## | 
|---|
| 5328 | ## ------------------------ ## | 
|---|
| 5329 |  | 
|---|
| 5330 |  | 
|---|
| 5331 | # &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE) | 
|---|
| 5332 | # ----------------------------------------------------- | 
|---|
| 5333 | # Like define_variable, but the value is a list, and the variable may | 
|---|
| 5334 | # be defined conditionally.  The second argument is the Condition | 
|---|
| 5335 | # under which the value should be defined; this should be the empty | 
|---|
| 5336 | # string to define the variable unconditionally.  The third argument | 
|---|
| 5337 | # is a list holding the values to use for the variable.  The value is | 
|---|
| 5338 | # pretty printed in the output file. | 
|---|
| 5339 | sub define_pretty_variable ($$$@) | 
|---|
| 5340 | { | 
|---|
| 5341 | my ($var, $cond, $where, @value) = @_; | 
|---|
| 5342 |  | 
|---|
| 5343 | if (! vardef ($var, $cond)) | 
|---|
| 5344 | { | 
|---|
| 5345 | Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value", | 
|---|
| 5346 | '', $where, VAR_PRETTY); | 
|---|
| 5347 | rvar ($var)->rdef ($cond)->set_seen; | 
|---|
| 5348 | } | 
|---|
| 5349 | } | 
|---|
| 5350 |  | 
|---|
| 5351 |  | 
|---|
| 5352 | # define_variable ($VAR, $VALUE, $WHERE) | 
|---|
| 5353 | # -------------------------------------- | 
|---|
| 5354 | # Define a new user variable VAR to VALUE, but only if not already defined. | 
|---|
| 5355 | sub define_variable ($$$) | 
|---|
| 5356 | { | 
|---|
| 5357 | my ($var, $value, $where) = @_; | 
|---|
| 5358 | define_pretty_variable ($var, TRUE, $where, $value); | 
|---|
| 5359 | } | 
|---|
| 5360 |  | 
|---|
| 5361 |  | 
|---|
| 5362 | # define_files_variable ($VAR, \@BASENAME, $EXTENSION, $WHERE) | 
|---|
| 5363 | # ----------------------------------------------------------- | 
|---|
| 5364 | # Define the $VAR which content is the list of file names composed of | 
|---|
| 5365 | # a @BASENAME and the $EXTENSION. | 
|---|
| 5366 | sub define_files_variable ($\@$$) | 
|---|
| 5367 | { | 
|---|
| 5368 | my ($var, $basename, $extension, $where) = @_; | 
|---|
| 5369 | define_variable ($var, | 
|---|
| 5370 | join (' ', map { "$_.$extension" } @$basename), | 
|---|
| 5371 | $where); | 
|---|
| 5372 | } | 
|---|
| 5373 |  | 
|---|
| 5374 |  | 
|---|
| 5375 | # Like define_variable, but define a variable to be the configure | 
|---|
| 5376 | # substitution by the same name. | 
|---|
| 5377 | sub define_configure_variable ($) | 
|---|
| 5378 | { | 
|---|
| 5379 | my ($var) = @_; | 
|---|
| 5380 |  | 
|---|
| 5381 | my $pretty = VAR_ASIS; | 
|---|
| 5382 | my $owner = VAR_CONFIGURE; | 
|---|
| 5383 |  | 
|---|
| 5384 | # Do not output the ANSI2KNR configure variable -- we AC_SUBST | 
|---|
| 5385 | # it in protos.m4, but later redefine it elsewhere.  This is | 
|---|
| 5386 | # pretty hacky.  We also don't output AMDEPBACKSLASH: it might | 
|---|
| 5387 | # be subst'd by `\', which certainly would not be appreciated by | 
|---|
| 5388 | # Make. | 
|---|
| 5389 | if ($var eq 'ANSI2KNR' || $var eq 'AMDEPBACKSLASH') | 
|---|
| 5390 | { | 
|---|
| 5391 | $pretty = VAR_SILENT; | 
|---|
| 5392 | $owner = VAR_AUTOMAKE; | 
|---|
| 5393 | } | 
|---|
| 5394 |  | 
|---|
| 5395 | Automake::Variable::define ($var, $owner, '', TRUE, subst $var, | 
|---|
| 5396 | '', $configure_vars{$var}, $pretty); | 
|---|
| 5397 | } | 
|---|
| 5398 |  | 
|---|
| 5399 |  | 
|---|
| 5400 | # define_compiler_variable ($LANG) | 
|---|
| 5401 | # -------------------------------- | 
|---|
| 5402 | # Define a compiler variable.  We also handle defining the `LT' | 
|---|
| 5403 | # version of the command when using libtool. | 
|---|
| 5404 | sub define_compiler_variable ($) | 
|---|
| 5405 | { | 
|---|
| 5406 | my ($lang) = @_; | 
|---|
| 5407 |  | 
|---|
| 5408 | my ($var, $value) = ($lang->compiler, $lang->compile); | 
|---|
| 5409 | &define_variable ($var, $value, INTERNAL); | 
|---|
| 5410 | &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value", INTERNAL) | 
|---|
| 5411 | if var ('LIBTOOL'); | 
|---|
| 5412 | } | 
|---|
| 5413 |  | 
|---|
| 5414 |  | 
|---|
| 5415 | # define_linker_variable ($LANG) | 
|---|
| 5416 | # ------------------------------ | 
|---|
| 5417 | # Define linker variables. | 
|---|
| 5418 | sub define_linker_variable ($) | 
|---|
| 5419 | { | 
|---|
| 5420 | my ($lang) = @_; | 
|---|
| 5421 |  | 
|---|
| 5422 | my ($var, $value) = ($lang->lder, $lang->ld); | 
|---|
| 5423 | # CCLD = $(CC). | 
|---|
| 5424 | &define_variable ($lang->lder, $lang->ld, INTERNAL); | 
|---|
| 5425 | # CCLINK = $(CCLD) blah blah... | 
|---|
| 5426 | &define_variable ($lang->linker, | 
|---|
| 5427 | ((var ('LIBTOOL') ? '$(LIBTOOL) --mode=link ' : '') | 
|---|
| 5428 | . $lang->link), | 
|---|
| 5429 | INTERNAL); | 
|---|
| 5430 | } | 
|---|
| 5431 |  | 
|---|
| 5432 | ################################################################ | 
|---|
| 5433 |  | 
|---|
| 5434 | # &check_trailing_slash ($WHERE, $LINE) | 
|---|
| 5435 | # -------------------------------------- | 
|---|
| 5436 | # Return 1 iff $LINE ends with a slash. | 
|---|
| 5437 | # Might modify $LINE. | 
|---|
| 5438 | sub check_trailing_slash ($\$) | 
|---|
| 5439 | { | 
|---|
| 5440 | my ($where, $line) = @_; | 
|---|
| 5441 |  | 
|---|
| 5442 | # Ignore `##' lines. | 
|---|
| 5443 | return 0 if $$line =~ /$IGNORE_PATTERN/o; | 
|---|
| 5444 |  | 
|---|
| 5445 | # Catch and fix a common error. | 
|---|
| 5446 | msg "syntax", $where, "whitespace following trailing backslash" | 
|---|
| 5447 | if $$line =~ s/\\\s+\n$/\\\n/; | 
|---|
| 5448 |  | 
|---|
| 5449 | return $$line =~ /\\$/; | 
|---|
| 5450 | } | 
|---|
| 5451 |  | 
|---|
| 5452 |  | 
|---|
| 5453 | # &read_am_file ($AMFILE, $WHERE) | 
|---|
| 5454 | # ------------------------------- | 
|---|
| 5455 | # Read Makefile.am and set up %contents.  Simultaneously copy lines | 
|---|
| 5456 | # from Makefile.am into $output_trailer, or define variables as | 
|---|
| 5457 | # appropriate.  NOTE we put rules in the trailer section.  We want | 
|---|
| 5458 | # user rules to come after our generated stuff. | 
|---|
| 5459 | sub read_am_file ($$) | 
|---|
| 5460 | { | 
|---|
| 5461 | my ($amfile, $where) = @_; | 
|---|
| 5462 |  | 
|---|
| 5463 | my $am_file = new Automake::XFile ("< $amfile"); | 
|---|
| 5464 | verb "reading $amfile"; | 
|---|
| 5465 |  | 
|---|
| 5466 | # Keep track of the youngest output dependency. | 
|---|
| 5467 | my $mtime = mtime $amfile; | 
|---|
| 5468 | $output_deps_greatest_timestamp = $mtime | 
|---|
| 5469 | if $mtime > $output_deps_greatest_timestamp; | 
|---|
| 5470 |  | 
|---|
| 5471 | my $spacing = ''; | 
|---|
| 5472 | my $comment = ''; | 
|---|
| 5473 | my $blank = 0; | 
|---|
| 5474 | my $saw_bk = 0; | 
|---|
| 5475 |  | 
|---|
| 5476 | use constant IN_VAR_DEF => 0; | 
|---|
| 5477 | use constant IN_RULE_DEF => 1; | 
|---|
| 5478 | use constant IN_COMMENT => 2; | 
|---|
| 5479 | my $prev_state = IN_RULE_DEF; | 
|---|
| 5480 |  | 
|---|
| 5481 | while ($_ = $am_file->getline) | 
|---|
| 5482 | { | 
|---|
| 5483 | $where->set ("$amfile:$."); | 
|---|
| 5484 | if (/$IGNORE_PATTERN/o) | 
|---|
| 5485 | { | 
|---|
| 5486 | # Merely delete comments beginning with two hashes. | 
|---|
| 5487 | } | 
|---|
| 5488 | elsif (/$WHITE_PATTERN/o) | 
|---|
| 5489 | { | 
|---|
| 5490 | error $where, "blank line following trailing backslash" | 
|---|
| 5491 | if $saw_bk; | 
|---|
| 5492 | # Stick a single white line before the incoming macro or rule. | 
|---|
| 5493 | $spacing = "\n"; | 
|---|
| 5494 | $blank = 1; | 
|---|
| 5495 | # Flush all comments seen so far. | 
|---|
| 5496 | if ($comment ne '') | 
|---|
| 5497 | { | 
|---|
| 5498 | $output_vars .= $comment; | 
|---|
| 5499 | $comment = ''; | 
|---|
| 5500 | } | 
|---|
| 5501 | } | 
|---|
| 5502 | elsif (/$COMMENT_PATTERN/o) | 
|---|
| 5503 | { | 
|---|
| 5504 | # Stick comments before the incoming macro or rule.  Make | 
|---|
| 5505 | # sure a blank line precedes the first block of comments. | 
|---|
| 5506 | $spacing = "\n" unless $blank; | 
|---|
| 5507 | $blank = 1; | 
|---|
| 5508 | $comment .= $spacing . $_; | 
|---|
| 5509 | $spacing = ''; | 
|---|
| 5510 | $prev_state = IN_COMMENT; | 
|---|
| 5511 | } | 
|---|
| 5512 | else | 
|---|
| 5513 | { | 
|---|
| 5514 | last; | 
|---|
| 5515 | } | 
|---|
| 5516 | $saw_bk = check_trailing_slash ($where, $_); | 
|---|
| 5517 | } | 
|---|
| 5518 |  | 
|---|
| 5519 | # We save the conditional stack on entry, and then check to make | 
|---|
| 5520 | # sure it is the same on exit.  This lets us conditionally include | 
|---|
| 5521 | # other files. | 
|---|
| 5522 | my @saved_cond_stack = @cond_stack; | 
|---|
| 5523 | my $cond = new Automake::Condition (@cond_stack); | 
|---|
| 5524 |  | 
|---|
| 5525 | my $last_var_name = ''; | 
|---|
| 5526 | my $last_var_type = ''; | 
|---|
| 5527 | my $last_var_value = ''; | 
|---|
| 5528 | my $last_where; | 
|---|
| 5529 | # FIXME: shouldn't use $_ in this loop; it is too big. | 
|---|
| 5530 | while ($_) | 
|---|
| 5531 | { | 
|---|
| 5532 | $where->set ("$amfile:$."); | 
|---|
| 5533 |  | 
|---|
| 5534 | # Make sure the line is \n-terminated. | 
|---|
| 5535 | chomp; | 
|---|
| 5536 | $_ .= "\n"; | 
|---|
| 5537 |  | 
|---|
| 5538 | # Don't look at MAINTAINER_MODE_TRUE here.  That shouldn't be | 
|---|
| 5539 | # used by users.  @MAINT@ is an anachronism now. | 
|---|
| 5540 | $_ =~ s/\@MAINT\@//g | 
|---|
| 5541 | unless $seen_maint_mode; | 
|---|
| 5542 |  | 
|---|
| 5543 | my $new_saw_bk = check_trailing_slash ($where, $_); | 
|---|
| 5544 |  | 
|---|
| 5545 | if (/$IGNORE_PATTERN/o) | 
|---|
| 5546 | { | 
|---|
| 5547 | # Merely delete comments beginning with two hashes. | 
|---|
| 5548 | } | 
|---|
| 5549 | elsif (/$WHITE_PATTERN/o) | 
|---|
| 5550 | { | 
|---|
| 5551 | # Stick a single white line before the incoming macro or rule. | 
|---|
| 5552 | $spacing = "\n"; | 
|---|
| 5553 | error $where, "blank line following trailing backslash" | 
|---|
| 5554 | if $saw_bk; | 
|---|
| 5555 | } | 
|---|
| 5556 | elsif (/$COMMENT_PATTERN/o) | 
|---|
| 5557 | { | 
|---|
| 5558 | # Stick comments before the incoming macro or rule. | 
|---|
| 5559 | $comment .= $spacing . $_; | 
|---|
| 5560 | $spacing = ''; | 
|---|
| 5561 | error $where, "comment following trailing backslash" | 
|---|
| 5562 | if $saw_bk && $comment eq ''; | 
|---|
| 5563 | $prev_state = IN_COMMENT; | 
|---|
| 5564 | } | 
|---|
| 5565 | elsif ($saw_bk) | 
|---|
| 5566 | { | 
|---|
| 5567 | if ($prev_state == IN_RULE_DEF) | 
|---|
| 5568 | { | 
|---|
| 5569 | my $cond = new Automake::Condition @cond_stack; | 
|---|
| 5570 | $output_trailer .= $cond->subst_string; | 
|---|
| 5571 | $output_trailer .= $_; | 
|---|
| 5572 | } | 
|---|
| 5573 | elsif ($prev_state == IN_COMMENT) | 
|---|
| 5574 | { | 
|---|
| 5575 | # If the line doesn't start with a `#', add it. | 
|---|
| 5576 | # We do this because a continued comment like | 
|---|
| 5577 | #   # A = foo \ | 
|---|
| 5578 | #         bar \ | 
|---|
| 5579 | #         baz | 
|---|
| 5580 | # is not portable.  BSD make doesn't honor | 
|---|
| 5581 | # escaped newlines in comments. | 
|---|
| 5582 | s/^#?/#/; | 
|---|
| 5583 | $comment .= $spacing . $_; | 
|---|
| 5584 | } | 
|---|
| 5585 | else # $prev_state == IN_VAR_DEF | 
|---|
| 5586 | { | 
|---|
| 5587 | $last_var_value .= ' ' | 
|---|
| 5588 | unless $last_var_value =~ /\s$/; | 
|---|
| 5589 | $last_var_value .= $_; | 
|---|
| 5590 |  | 
|---|
| 5591 | if (!/\\$/) | 
|---|
| 5592 | { | 
|---|
| 5593 | Automake::Variable::define ($last_var_name, VAR_MAKEFILE, | 
|---|
| 5594 | $last_var_type, $cond, | 
|---|
| 5595 | $last_var_value, $comment, | 
|---|
| 5596 | $last_where, VAR_ASIS) | 
|---|
| 5597 | if $cond != FALSE; | 
|---|
| 5598 | $comment = $spacing = ''; | 
|---|
| 5599 | } | 
|---|
| 5600 | } | 
|---|
| 5601 | } | 
|---|
| 5602 |  | 
|---|
| 5603 | elsif (/$IF_PATTERN/o) | 
|---|
| 5604 | { | 
|---|
| 5605 | $cond = cond_stack_if ($1, $2, $where); | 
|---|
| 5606 | } | 
|---|
| 5607 | elsif (/$ELSE_PATTERN/o) | 
|---|
| 5608 | { | 
|---|
| 5609 | $cond = cond_stack_else ($1, $2, $where); | 
|---|
| 5610 | } | 
|---|
| 5611 | elsif (/$ENDIF_PATTERN/o) | 
|---|
| 5612 | { | 
|---|
| 5613 | $cond = cond_stack_endif ($1, $2, $where); | 
|---|
| 5614 | } | 
|---|
| 5615 |  | 
|---|
| 5616 | elsif (/$RULE_PATTERN/o) | 
|---|
| 5617 | { | 
|---|
| 5618 | # Found a rule. | 
|---|
| 5619 | $prev_state = IN_RULE_DEF; | 
|---|
| 5620 |  | 
|---|
| 5621 | # For now we have to output all definitions of user rules | 
|---|
| 5622 | # and can't diagnose duplicates (see the comment in | 
|---|
| 5623 | # rule_define). So we go on and ignore the return value. | 
|---|
| 5624 | Automake::Rule::define ($1, $amfile, RULE_USER, $cond, $where); | 
|---|
| 5625 |  | 
|---|
| 5626 | check_variable_expansions ($_, $where); | 
|---|
| 5627 |  | 
|---|
| 5628 | $output_trailer .= $comment . $spacing; | 
|---|
| 5629 | my $cond = new Automake::Condition @cond_stack; | 
|---|
| 5630 | $output_trailer .= $cond->subst_string; | 
|---|
| 5631 | $output_trailer .= $_; | 
|---|
| 5632 | $comment = $spacing = ''; | 
|---|
| 5633 | } | 
|---|
| 5634 | elsif (/$ASSIGNMENT_PATTERN/o) | 
|---|
| 5635 | { | 
|---|
| 5636 | # Found a macro definition. | 
|---|
| 5637 | $prev_state = IN_VAR_DEF; | 
|---|
| 5638 | $last_var_name = $1; | 
|---|
| 5639 | $last_var_type = $2; | 
|---|
| 5640 | $last_var_value = $3; | 
|---|
| 5641 | $last_where = $where->clone; | 
|---|
| 5642 | if ($3 ne '' && substr ($3, -1) eq "\\") | 
|---|
| 5643 | { | 
|---|
| 5644 | # We preserve the `\' because otherwise the long lines | 
|---|
| 5645 | # that are generated will be truncated by broken | 
|---|
| 5646 | # `sed's. | 
|---|
| 5647 | $last_var_value = $3 . "\n"; | 
|---|
| 5648 | } | 
|---|
| 5649 |  | 
|---|
| 5650 | if (!/\\$/) | 
|---|
| 5651 | { | 
|---|
| 5652 | Automake::Variable::define ($last_var_name, VAR_MAKEFILE, | 
|---|
| 5653 | $last_var_type, $cond, | 
|---|
| 5654 | $last_var_value, $comment, | 
|---|
| 5655 | $last_where, VAR_ASIS) | 
|---|
| 5656 | if $cond != FALSE; | 
|---|
| 5657 | $comment = $spacing = ''; | 
|---|
| 5658 | } | 
|---|
| 5659 | } | 
|---|
| 5660 | elsif (/$INCLUDE_PATTERN/o) | 
|---|
| 5661 | { | 
|---|
| 5662 | my $path = $1; | 
|---|
| 5663 |  | 
|---|
| 5664 | if ($path =~ s/^\$\(top_srcdir\)\///) | 
|---|
| 5665 | { | 
|---|
| 5666 | push (@include_stack, "\$\(top_srcdir\)/$path"); | 
|---|
| 5667 | # Distribute any included file. | 
|---|
| 5668 |  | 
|---|
| 5669 | # Always use the $(top_srcdir) prefix in DIST_COMMON, | 
|---|
| 5670 | # otherwise OSF make will implicitly copy the included | 
|---|
| 5671 | # file in the build tree during `make distdir' to satisfy | 
|---|
| 5672 | # the dependency. | 
|---|
| 5673 | # (subdircond2.test and subdircond3.test will fail.) | 
|---|
| 5674 | push_dist_common ("\$\(top_srcdir\)/$path"); | 
|---|
| 5675 | } | 
|---|
| 5676 | else | 
|---|
| 5677 | { | 
|---|
| 5678 | $path =~ s/\$\(srcdir\)\///; | 
|---|
| 5679 | push (@include_stack, "\$\(srcdir\)/$path"); | 
|---|
| 5680 | # Always use the $(srcdir) prefix in DIST_COMMON, | 
|---|
| 5681 | # otherwise OSF make will implicitly copy the included | 
|---|
| 5682 | # file in the build tree during `make distdir' to satisfy | 
|---|
| 5683 | # the dependency. | 
|---|
| 5684 | # (subdircond2.test and subdircond3.test will fail.) | 
|---|
| 5685 | push_dist_common ("\$\(srcdir\)/$path"); | 
|---|
| 5686 | $path = $relative_dir . "/" . $path if $relative_dir ne '.'; | 
|---|
| 5687 | } | 
|---|
| 5688 | $where->push_context ("`$path' included from here"); | 
|---|
| 5689 | &read_am_file ($path, $where); | 
|---|
| 5690 | $where->pop_context; | 
|---|
| 5691 | } | 
|---|
| 5692 | else | 
|---|
| 5693 | { | 
|---|
| 5694 | # This isn't an error; it is probably a continued rule. | 
|---|
| 5695 | # In fact, this is what we assume. | 
|---|
| 5696 | $prev_state = IN_RULE_DEF; | 
|---|
| 5697 | check_variable_expansions ($_, $where); | 
|---|
| 5698 | $output_trailer .= $comment . $spacing; | 
|---|
| 5699 | my $cond = new Automake::Condition @cond_stack; | 
|---|
| 5700 | $output_trailer .= $cond->subst_string; | 
|---|
| 5701 | $output_trailer .= $_; | 
|---|
| 5702 | $comment = $spacing = ''; | 
|---|
| 5703 | error $where, "`#' comment at start of rule is unportable" | 
|---|
| 5704 | if $_ =~ /^\t\s*\#/; | 
|---|
| 5705 | } | 
|---|
| 5706 |  | 
|---|
| 5707 | $saw_bk = $new_saw_bk; | 
|---|
| 5708 | $_ = $am_file->getline; | 
|---|
| 5709 | } | 
|---|
| 5710 |  | 
|---|
| 5711 | $output_trailer .= $comment; | 
|---|
| 5712 |  | 
|---|
| 5713 | error ($where, "trailing backslash on last line") | 
|---|
| 5714 | if $saw_bk; | 
|---|
| 5715 |  | 
|---|
| 5716 | error ($where, (@cond_stack ? "unterminated conditionals: @cond_stack" | 
|---|
| 5717 | : "too many conditionals closed in include file")) | 
|---|
| 5718 | if "@saved_cond_stack" ne "@cond_stack"; | 
|---|
| 5719 | } | 
|---|
| 5720 |  | 
|---|
| 5721 |  | 
|---|
| 5722 | # define_standard_variables () | 
|---|
| 5723 | # ---------------------------- | 
|---|
| 5724 | # A helper for read_main_am_file which initializes configure variables | 
|---|
| 5725 | # and variables from header-vars.am. | 
|---|
| 5726 | sub define_standard_variables | 
|---|
| 5727 | { | 
|---|
| 5728 | my $saved_output_vars = $output_vars; | 
|---|
| 5729 | my ($comments, undef, $rules) = | 
|---|
| 5730 | file_contents_internal (1, "$libdir/am/header-vars.am", | 
|---|
| 5731 | new Automake::Location); | 
|---|
| 5732 |  | 
|---|
| 5733 | foreach my $var (sort keys %configure_vars) | 
|---|
| 5734 | { | 
|---|
| 5735 | &define_configure_variable ($var); | 
|---|
| 5736 | } | 
|---|
| 5737 |  | 
|---|
| 5738 | $output_vars .= $comments . $rules; | 
|---|
| 5739 | } | 
|---|
| 5740 |  | 
|---|
| 5741 | # Read main am file. | 
|---|
| 5742 | sub read_main_am_file | 
|---|
| 5743 | { | 
|---|
| 5744 | my ($amfile) = @_; | 
|---|
| 5745 |  | 
|---|
| 5746 | # This supports the strange variable tricks we are about to play. | 
|---|
| 5747 | prog_error (macros_dump () . "variable defined before read_main_am_file") | 
|---|
| 5748 | if (scalar (variables) > 0); | 
|---|
| 5749 |  | 
|---|
| 5750 | # Generate copyright header for generated Makefile.in. | 
|---|
| 5751 | # We do discard the output of predefined variables, handled below. | 
|---|
| 5752 | $output_vars = ("# $in_file_name generated by automake " | 
|---|
| 5753 | . $VERSION . " from $am_file_name.\n"); | 
|---|
| 5754 | $output_vars .= '# ' . subst ('configure_input') . "\n"; | 
|---|
| 5755 | $output_vars .= $gen_copyright; | 
|---|
| 5756 |  | 
|---|
| 5757 | # We want to predefine as many variables as possible.  This lets | 
|---|
| 5758 | # the user set them with `+=' in Makefile.am. | 
|---|
| 5759 | &define_standard_variables; | 
|---|
| 5760 |  | 
|---|
| 5761 | # Read user file, which might override some of our values. | 
|---|
| 5762 | &read_am_file ($amfile, new Automake::Location); | 
|---|
| 5763 | } | 
|---|
| 5764 |  | 
|---|
| 5765 |  | 
|---|
| 5766 |  | 
|---|
| 5767 | ################################################################ | 
|---|
| 5768 |  | 
|---|
| 5769 | # $FLATTENED | 
|---|
| 5770 | # &flatten ($STRING) | 
|---|
| 5771 | # ------------------ | 
|---|
| 5772 | # Flatten the $STRING and return the result. | 
|---|
| 5773 | sub flatten | 
|---|
| 5774 | { | 
|---|
| 5775 | $_ = shift; | 
|---|
| 5776 |  | 
|---|
| 5777 | s/\\\n//somg; | 
|---|
| 5778 | s/\s+/ /g; | 
|---|
| 5779 | s/^ //; | 
|---|
| 5780 | s/ $//; | 
|---|
| 5781 |  | 
|---|
| 5782 | return $_; | 
|---|
| 5783 | } | 
|---|
| 5784 |  | 
|---|
| 5785 |  | 
|---|
| 5786 | # @PARAGRAPHS | 
|---|
| 5787 | # &make_paragraphs ($MAKEFILE, [%TRANSFORM]) | 
|---|
| 5788 | # ------------------------------------------ | 
|---|
| 5789 | # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of | 
|---|
| 5790 | # paragraphs. | 
|---|
| 5791 | sub make_paragraphs ($%) | 
|---|
| 5792 | { | 
|---|
| 5793 | my ($file, %transform) = @_; | 
|---|
| 5794 |  | 
|---|
| 5795 | # Complete %transform with global options and make it a Perl | 
|---|
| 5796 | # $command. | 
|---|
| 5797 | my $command = | 
|---|
| 5798 | "s/$IGNORE_PATTERN//gm;" | 
|---|
| 5799 | . transform (%transform, | 
|---|
| 5800 | 'CYGNUS'      => !! option 'cygnus', | 
|---|
| 5801 | 'MAINTAINER-MODE' | 
|---|
| 5802 | => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '', | 
|---|
| 5803 |  | 
|---|
| 5804 | 'BZIP2'       => !! option 'dist-bzip2', | 
|---|
| 5805 | 'COMPRESS'    => !! option 'dist-tarZ', | 
|---|
| 5806 | 'GZIP'        =>  ! option 'no-dist-gzip', | 
|---|
| 5807 | 'SHAR'        => !! option 'dist-shar', | 
|---|
| 5808 | 'ZIP'         => !! option 'dist-zip', | 
|---|
| 5809 |  | 
|---|
| 5810 | 'INSTALL-INFO' =>  ! option 'no-installinfo', | 
|---|
| 5811 | 'INSTALL-MAN'  =>  ! option 'no-installman', | 
|---|
| 5812 | 'CK-NEWS'      => !! option 'check-news', | 
|---|
| 5813 |  | 
|---|
| 5814 | 'SUBDIRS'      => !! var ('SUBDIRS'), | 
|---|
| 5815 | 'TOPDIR'       => backname ($relative_dir), | 
|---|
| 5816 | 'TOPDIR_P'     => $relative_dir eq '.', | 
|---|
| 5817 |  | 
|---|
| 5818 | 'BUILD'    => $seen_canonical == AC_CANONICAL_SYSTEM, | 
|---|
| 5819 | 'HOST'     => $seen_canonical, | 
|---|
| 5820 | 'TARGET'   => $seen_canonical == AC_CANONICAL_SYSTEM, | 
|---|
| 5821 |  | 
|---|
| 5822 | 'LIBTOOL'      => !! var ('LIBTOOL')) | 
|---|
| 5823 | # We don't need more than two consecutive new-lines. | 
|---|
| 5824 | . 's/\n{3,}/\n\n/g'; | 
|---|
| 5825 |  | 
|---|
| 5826 | # Swallow the file and apply the COMMAND. | 
|---|
| 5827 | my $fc_file = new Automake::XFile "< $file"; | 
|---|
| 5828 | # Looks stupid? | 
|---|
| 5829 | verb "reading $file"; | 
|---|
| 5830 | my $saved_dollar_slash = $/; | 
|---|
| 5831 | undef $/; | 
|---|
| 5832 | $_ = $fc_file->getline; | 
|---|
| 5833 | $/ = $saved_dollar_slash; | 
|---|
| 5834 | eval $command; | 
|---|
| 5835 | $fc_file->close; | 
|---|
| 5836 | my $content = $_; | 
|---|
| 5837 |  | 
|---|
| 5838 | # Split at unescaped new lines. | 
|---|
| 5839 | my @lines = split (/(?<!\\)\n/, $content); | 
|---|
| 5840 | my @res; | 
|---|
| 5841 |  | 
|---|
| 5842 | while (defined ($_ = shift @lines)) | 
|---|
| 5843 | { | 
|---|
| 5844 | my $paragraph = "$_"; | 
|---|
| 5845 | # If we are a rule, eat as long as we start with a tab. | 
|---|
| 5846 | if (/$RULE_PATTERN/smo) | 
|---|
| 5847 | { | 
|---|
| 5848 | while (defined ($_ = shift @lines) && $_ =~ /^\t/) | 
|---|
| 5849 | { | 
|---|
| 5850 | $paragraph .= "\n$_"; | 
|---|
| 5851 | } | 
|---|
| 5852 | unshift (@lines, $_); | 
|---|
| 5853 | } | 
|---|
| 5854 |  | 
|---|
| 5855 | # If we are a comments, eat as much comments as you can. | 
|---|
| 5856 | elsif (/$COMMENT_PATTERN/smo) | 
|---|
| 5857 | { | 
|---|
| 5858 | while (defined ($_ = shift @lines) | 
|---|
| 5859 | && $_ =~ /$COMMENT_PATTERN/smo) | 
|---|
| 5860 | { | 
|---|
| 5861 | $paragraph .= "\n$_"; | 
|---|
| 5862 | } | 
|---|
| 5863 | unshift (@lines, $_); | 
|---|
| 5864 | } | 
|---|
| 5865 |  | 
|---|
| 5866 | push @res, $paragraph; | 
|---|
| 5867 | $paragraph = ''; | 
|---|
| 5868 | } | 
|---|
| 5869 |  | 
|---|
| 5870 | return @res; | 
|---|
| 5871 | } | 
|---|
| 5872 |  | 
|---|
| 5873 |  | 
|---|
| 5874 |  | 
|---|
| 5875 | # ($COMMENT, $VARIABLES, $RULES) | 
|---|
| 5876 | # &file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM]) | 
|---|
| 5877 | # ------------------------------------------------------------- | 
|---|
| 5878 | # Return contents of a file from $libdir/am, automatically skipping | 
|---|
| 5879 | # macros or rules which are already known. $IS_AM iff the caller is | 
|---|
| 5880 | # reading an Automake file (as opposed to the user's Makefile.am). | 
|---|
| 5881 | sub file_contents_internal ($$$%) | 
|---|
| 5882 | { | 
|---|
| 5883 | my ($is_am, $file, $where, %transform) = @_; | 
|---|
| 5884 |  | 
|---|
| 5885 | $where->set ($file); | 
|---|
| 5886 |  | 
|---|
| 5887 | my $result_vars = ''; | 
|---|
| 5888 | my $result_rules = ''; | 
|---|
| 5889 | my $comment = ''; | 
|---|
| 5890 | my $spacing = ''; | 
|---|
| 5891 |  | 
|---|
| 5892 | # The following flags are used to track rules spanning across | 
|---|
| 5893 | # multiple paragraphs. | 
|---|
| 5894 | my $is_rule = 0;            # 1 if we are processing a rule. | 
|---|
| 5895 | my $discard_rule = 0;       # 1 if the current rule should not be output. | 
|---|
| 5896 |  | 
|---|
| 5897 | # We save the conditional stack on entry, and then check to make | 
|---|
| 5898 | # sure it is the same on exit.  This lets us conditionally include | 
|---|
| 5899 | # other files. | 
|---|
| 5900 | my @saved_cond_stack = @cond_stack; | 
|---|
| 5901 | my $cond = new Automake::Condition (@cond_stack); | 
|---|
| 5902 |  | 
|---|
| 5903 | foreach (make_paragraphs ($file, %transform)) | 
|---|
| 5904 | { | 
|---|
| 5905 | # FIXME: no line number available. | 
|---|
| 5906 | $where->set ($file); | 
|---|
| 5907 |  | 
|---|
| 5908 | # Sanity checks. | 
|---|
| 5909 | error $where, "blank line following trailing backslash:\n$_" | 
|---|
| 5910 | if /\\$/; | 
|---|
| 5911 | error $where, "comment following trailing backslash:\n$_" | 
|---|
| 5912 | if /\\#/; | 
|---|
| 5913 |  | 
|---|
| 5914 | if (/^$/) | 
|---|
| 5915 | { | 
|---|
| 5916 | $is_rule = 0; | 
|---|
| 5917 | # Stick empty line before the incoming macro or rule. | 
|---|
| 5918 | $spacing = "\n"; | 
|---|
| 5919 | } | 
|---|
| 5920 | elsif (/$COMMENT_PATTERN/mso) | 
|---|
| 5921 | { | 
|---|
| 5922 | $is_rule = 0; | 
|---|
| 5923 | # Stick comments before the incoming macro or rule. | 
|---|
| 5924 | $comment = "$_\n"; | 
|---|
| 5925 | } | 
|---|
| 5926 |  | 
|---|
| 5927 | # Handle inclusion of other files. | 
|---|
| 5928 | elsif (/$INCLUDE_PATTERN/o) | 
|---|
| 5929 | { | 
|---|
| 5930 | if ($cond != FALSE) | 
|---|
| 5931 | { | 
|---|
| 5932 | my $file = ($is_am ? "$libdir/am/" : '') . $1; | 
|---|
| 5933 | $where->push_context ("`$file' included from here"); | 
|---|
| 5934 | # N-ary `.=' fails. | 
|---|
| 5935 | my ($com, $vars, $rules) | 
|---|
| 5936 | = file_contents_internal ($is_am, $file, $where, %transform); | 
|---|
| 5937 | $where->pop_context; | 
|---|
| 5938 | $comment .= $com; | 
|---|
| 5939 | $result_vars .= $vars; | 
|---|
| 5940 | $result_rules .= $rules; | 
|---|
| 5941 | } | 
|---|
| 5942 | } | 
|---|
| 5943 |  | 
|---|
| 5944 | # Handling the conditionals. | 
|---|
| 5945 | elsif (/$IF_PATTERN/o) | 
|---|
| 5946 | { | 
|---|
| 5947 | $cond = cond_stack_if ($1, $2, $file); | 
|---|
| 5948 | } | 
|---|
| 5949 | elsif (/$ELSE_PATTERN/o) | 
|---|
| 5950 | { | 
|---|
| 5951 | $cond = cond_stack_else ($1, $2, $file); | 
|---|
| 5952 | } | 
|---|
| 5953 | elsif (/$ENDIF_PATTERN/o) | 
|---|
| 5954 | { | 
|---|
| 5955 | $cond = cond_stack_endif ($1, $2, $file); | 
|---|
| 5956 | } | 
|---|
| 5957 |  | 
|---|
| 5958 | # Handling rules. | 
|---|
| 5959 | elsif (/$RULE_PATTERN/mso) | 
|---|
| 5960 | { | 
|---|
| 5961 | $is_rule = 1; | 
|---|
| 5962 | $discard_rule = 0; | 
|---|
| 5963 | # Separate relationship from optional actions: the first | 
|---|
| 5964 | # `new-line tab" not preceded by backslash (continuation | 
|---|
| 5965 | # line). | 
|---|
| 5966 | my $paragraph = $_; | 
|---|
| 5967 | /^(.*?)(?:(?<!\\)\n(\t.*))?$/s; | 
|---|
| 5968 | my ($relationship, $actions) = ($1, $2 || ''); | 
|---|
| 5969 |  | 
|---|
| 5970 | # Separate targets from dependencies: the first colon. | 
|---|
| 5971 | $relationship =~ /^([^:]+\S+) *: *(.*)$/som; | 
|---|
| 5972 | my ($targets, $dependencies) = ($1, $2); | 
|---|
| 5973 | # Remove the escaped new lines. | 
|---|
| 5974 | # I don't know why, but I have to use a tmp $flat_deps. | 
|---|
| 5975 | my $flat_deps = &flatten ($dependencies); | 
|---|
| 5976 | my @deps = split (' ', $flat_deps); | 
|---|
| 5977 |  | 
|---|
| 5978 | foreach (split (' ' , $targets)) | 
|---|
| 5979 | { | 
|---|
| 5980 | # FIXME: 1. We are not robust to people defining several targets | 
|---|
| 5981 | # at once, only some of them being in %dependencies.  The | 
|---|
| 5982 | # actions from the targets in %dependencies are usually generated | 
|---|
| 5983 | # from the content of %actions, but if some targets in $targets | 
|---|
| 5984 | # are not in %dependencies the ELSE branch will output | 
|---|
| 5985 | # a rule for all $targets (i.e. the targets which are both | 
|---|
| 5986 | # in %dependencies and $targets will have two rules). | 
|---|
| 5987 |  | 
|---|
| 5988 | # FIXME: 2. The logic here is not able to output a | 
|---|
| 5989 | # multi-paragraph rule several time (e.g. for each condition | 
|---|
| 5990 | # it is defined for) because it only knows the first paragraph. | 
|---|
| 5991 |  | 
|---|
| 5992 | # FIXME: 3. We are not robust to people defining a subset | 
|---|
| 5993 | # of a previously defined "multiple-target" rule.  E.g. | 
|---|
| 5994 | # `foo:' after `foo bar:'. | 
|---|
| 5995 |  | 
|---|
| 5996 | # Output only if not in FALSE. | 
|---|
| 5997 | if (defined $dependencies{$_} && $cond != FALSE) | 
|---|
| 5998 | { | 
|---|
| 5999 | &depend ($_, @deps); | 
|---|
| 6000 | if ($actions{$_}) | 
|---|
| 6001 | { | 
|---|
| 6002 | $actions{$_} .= "\n$actions" if $actions; | 
|---|
| 6003 | } | 
|---|
| 6004 | else | 
|---|
| 6005 | { | 
|---|
| 6006 | $actions{$_} = $actions; | 
|---|
| 6007 | } | 
|---|
| 6008 | } | 
|---|
| 6009 | else | 
|---|
| 6010 | { | 
|---|
| 6011 | # Free-lance dependency.  Output the rule for all the | 
|---|
| 6012 | # targets instead of one by one. | 
|---|
| 6013 | my @undefined_conds = | 
|---|
| 6014 | Automake::Rule::define ($targets, $file, | 
|---|
| 6015 | $is_am ? RULE_AUTOMAKE : RULE_USER, | 
|---|
| 6016 | $cond, $where); | 
|---|
| 6017 | for my $undefined_cond (@undefined_conds) | 
|---|
| 6018 | { | 
|---|
| 6019 | my $condparagraph = $paragraph; | 
|---|
| 6020 | $condparagraph =~ s/^/$undefined_cond->subst_string/gme; | 
|---|
| 6021 | $result_rules .= "$spacing$comment$condparagraph\n"; | 
|---|
| 6022 | } | 
|---|
| 6023 | if (scalar @undefined_conds == 0) | 
|---|
| 6024 | { | 
|---|
| 6025 | # Remember to discard next paragraphs | 
|---|
| 6026 | # if they belong to this rule. | 
|---|
| 6027 | # (but see also FIXME: #2 above.) | 
|---|
| 6028 | $discard_rule = 1; | 
|---|
| 6029 | } | 
|---|
| 6030 | $comment = $spacing = ''; | 
|---|
| 6031 | last; | 
|---|
| 6032 | } | 
|---|
| 6033 | } | 
|---|
| 6034 | } | 
|---|
| 6035 |  | 
|---|
| 6036 | elsif (/$ASSIGNMENT_PATTERN/mso) | 
|---|
| 6037 | { | 
|---|
| 6038 | my ($var, $type, $val) = ($1, $2, $3); | 
|---|
| 6039 | error $where, "variable `$var' with trailing backslash" | 
|---|
| 6040 | if /\\$/; | 
|---|
| 6041 |  | 
|---|
| 6042 | $is_rule = 0; | 
|---|
| 6043 |  | 
|---|
| 6044 | Automake::Variable::define ($var, | 
|---|
| 6045 | $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE, | 
|---|
| 6046 | $type, $cond, $val, $comment, $where, | 
|---|
| 6047 | VAR_ASIS) | 
|---|
| 6048 | if $cond != FALSE; | 
|---|
| 6049 |  | 
|---|
| 6050 | $comment = $spacing = ''; | 
|---|
| 6051 | } | 
|---|
| 6052 | else | 
|---|
| 6053 | { | 
|---|
| 6054 | # This isn't an error; it is probably some tokens which | 
|---|
| 6055 | # configure is supposed to replace, such as `@SET-MAKE@', | 
|---|
| 6056 | # or some part of a rule cut by an if/endif. | 
|---|
| 6057 | if (! $cond->false && ! ($is_rule && $discard_rule)) | 
|---|
| 6058 | { | 
|---|
| 6059 | s/^/$cond->subst_string/gme; | 
|---|
| 6060 | $result_rules .= "$spacing$comment$_\n"; | 
|---|
| 6061 | } | 
|---|
| 6062 | $comment = $spacing = ''; | 
|---|
| 6063 | } | 
|---|
| 6064 | } | 
|---|
| 6065 |  | 
|---|
| 6066 | error ($where, @cond_stack ? | 
|---|
| 6067 | "unterminated conditionals: @cond_stack" : | 
|---|
| 6068 | "too many conditionals closed in include file") | 
|---|
| 6069 | if "@saved_cond_stack" ne "@cond_stack"; | 
|---|
| 6070 |  | 
|---|
| 6071 | return ($comment, $result_vars, $result_rules); | 
|---|
| 6072 | } | 
|---|
| 6073 |  | 
|---|
| 6074 |  | 
|---|
| 6075 | # $CONTENTS | 
|---|
| 6076 | # &file_contents ($BASENAME, $WHERE, [%TRANSFORM]) | 
|---|
| 6077 | # ------------------------------------------------ | 
|---|
| 6078 | # Return contents of a file from $libdir/am, automatically skipping | 
|---|
| 6079 | # macros or rules which are already known. | 
|---|
| 6080 | sub file_contents ($$%) | 
|---|
| 6081 | { | 
|---|
| 6082 | my ($basename, $where, %transform) = @_; | 
|---|
| 6083 | my ($comments, $variables, $rules) = | 
|---|
| 6084 | file_contents_internal (1, "$libdir/am/$basename.am", $where, | 
|---|
| 6085 | %transform); | 
|---|
| 6086 | return "$comments$variables$rules"; | 
|---|
| 6087 | } | 
|---|
| 6088 |  | 
|---|
| 6089 |  | 
|---|
| 6090 | # $REGEXP | 
|---|
| 6091 | # &transform (%PAIRS) | 
|---|
| 6092 | # ------------------- | 
|---|
| 6093 | # For each ($TOKEN, $VAL) in %PAIRS produce a replacement expression | 
|---|
| 6094 | # suitable for file_contents which: | 
|---|
| 6095 | #   - replaces %$TOKEN% with $VAL, | 
|---|
| 6096 | #   - enables/disables ?$TOKEN? and ?!$TOKEN?, | 
|---|
| 6097 | #   - replaces %?$TOKEN% with TRUE or FALSE. | 
|---|
| 6098 | sub transform (%) | 
|---|
| 6099 | { | 
|---|
| 6100 | my (%pairs) = @_; | 
|---|
| 6101 | my $result = ''; | 
|---|
| 6102 |  | 
|---|
| 6103 | while (my ($token, $val) = each %pairs) | 
|---|
| 6104 | { | 
|---|
| 6105 | $result .= "s/\Q%$token%\E/\Q$val\E/gm;"; | 
|---|
| 6106 | if ($val) | 
|---|
| 6107 | { | 
|---|
| 6108 | $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;"; | 
|---|
| 6109 | $result .= "s/\Q%?$token%\E/TRUE/gm;"; | 
|---|
| 6110 | } | 
|---|
| 6111 | else | 
|---|
| 6112 | { | 
|---|
| 6113 | $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;"; | 
|---|
| 6114 | $result .= "s/\Q%?$token%\E/FALSE/gm;"; | 
|---|
| 6115 | } | 
|---|
| 6116 | } | 
|---|
| 6117 |  | 
|---|
| 6118 | return $result; | 
|---|
| 6119 | } | 
|---|
| 6120 |  | 
|---|
| 6121 |  | 
|---|
| 6122 | # &append_exeext ($MACRO) | 
|---|
| 6123 | # ----------------------- | 
|---|
| 6124 | # Macro is an Automake magic macro which primary is PROGRAMS, e.g. | 
|---|
| 6125 | # bin_PROGRAMS.  Make sure these programs have $(EXEEXT) appended. | 
|---|
| 6126 | sub append_exeext ($) | 
|---|
| 6127 | { | 
|---|
| 6128 | my ($macro) = @_; | 
|---|
| 6129 |  | 
|---|
| 6130 | prog_error "append_exeext ($macro)" | 
|---|
| 6131 | unless $macro =~ /_PROGRAMS$/; | 
|---|
| 6132 |  | 
|---|
| 6133 | transform_variable_recursively | 
|---|
| 6134 | ($macro, $macro, 'am__EXEEXT', 0, INTERNAL, | 
|---|
| 6135 | sub { | 
|---|
| 6136 | my ($subvar, $val, $cond, $full_cond) = @_; | 
|---|
| 6137 | # Append $(EXEEXT) unless the user did it already, or it's a | 
|---|
| 6138 | # @substitution@. | 
|---|
| 6139 | $val .= '$(EXEEXT)' unless $val =~ /(?:\$\(EXEEXT\)$|^[@]\w+[@]$)/; | 
|---|
| 6140 | return $val; | 
|---|
| 6141 | }); | 
|---|
| 6142 | } | 
|---|
| 6143 |  | 
|---|
| 6144 |  | 
|---|
| 6145 | # @PREFIX | 
|---|
| 6146 | # &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES) | 
|---|
| 6147 | # ----------------------------------------------------- | 
|---|
| 6148 | # Find all variable prefixes that are used for install directories.  A | 
|---|
| 6149 | # prefix `zar' qualifies iff: | 
|---|
| 6150 | # | 
|---|
| 6151 | # * `zardir' is a variable. | 
|---|
| 6152 | # * `zar_PRIMARY' is a variable. | 
|---|
| 6153 | # | 
|---|
| 6154 | # As a side effect, it looks for misspellings.  It is an error to have | 
|---|
| 6155 | # a variable ending in a "reserved" suffix whose prefix is unknown, e.g. | 
|---|
| 6156 | # "bin_PROGRAMS".  However, unusual prefixes are allowed if a variable | 
|---|
| 6157 | # of the same name (with "dir" appended) exists.  For instance, if the | 
|---|
| 6158 | # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid. | 
|---|
| 6159 | # This is to provide a little extra flexibility in those cases which | 
|---|
| 6160 | # need it. | 
|---|
| 6161 | sub am_primary_prefixes ($$@) | 
|---|
| 6162 | { | 
|---|
| 6163 | my ($primary, $can_dist, @prefixes) = @_; | 
|---|
| 6164 |  | 
|---|
| 6165 | local $_; | 
|---|
| 6166 | my %valid = map { $_ => 0 } @prefixes; | 
|---|
| 6167 | $valid{'EXTRA'} = 0; | 
|---|
| 6168 | foreach my $var (variables) | 
|---|
| 6169 | { | 
|---|
| 6170 | # Automake is allowed to define variables that look like primaries | 
|---|
| 6171 | # but which aren't.  E.g. INSTALL_sh_DATA. | 
|---|
| 6172 | # Autoconf can also define variables like INSTALL_DATA, so | 
|---|
| 6173 | # ignore all configure variables (at least those which are not | 
|---|
| 6174 | # redefined in Makefile.am). | 
|---|
| 6175 | # FIXME: We should make sure that these variables are not | 
|---|
| 6176 | # conditionally defined (or else adjust the condition below). | 
|---|
| 6177 | my $def = $var->def (TRUE); | 
|---|
| 6178 | next if $def && $def->owner != VAR_MAKEFILE; | 
|---|
| 6179 |  | 
|---|
| 6180 | my $varname = $var->name; | 
|---|
| 6181 |  | 
|---|
| 6182 | if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/) | 
|---|
| 6183 | { | 
|---|
| 6184 | my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || ''); | 
|---|
| 6185 | if ($dist ne '' && ! $can_dist) | 
|---|
| 6186 | { | 
|---|
| 6187 | err_var ($var, | 
|---|
| 6188 | "invalid variable `$varname': `dist' is forbidden"); | 
|---|
| 6189 | } | 
|---|
| 6190 | # Standard directories must be explicitly allowed. | 
|---|
| 6191 | elsif (! defined $valid{$X} && exists $standard_prefix{$X}) | 
|---|
| 6192 | { | 
|---|
| 6193 | err_var ($var, | 
|---|
| 6194 | "`${X}dir' is not a legitimate directory " . | 
|---|
| 6195 | "for `$primary'"); | 
|---|
| 6196 | } | 
|---|
| 6197 | # A not explicitly valid directory is allowed if Xdir is defined. | 
|---|
| 6198 | elsif (! defined $valid{$X} && | 
|---|
| 6199 | $var->requires_variables ("`$varname' is used", "${X}dir")) | 
|---|
| 6200 | { | 
|---|
| 6201 | # Nothing to do.  Any error message has been output | 
|---|
| 6202 | # by $var->requires_variables. | 
|---|
| 6203 | } | 
|---|
| 6204 | else | 
|---|
| 6205 | { | 
|---|
| 6206 | # Ensure all extended prefixes are actually used. | 
|---|
| 6207 | $valid{"$base$dist$X"} = 1; | 
|---|
| 6208 | } | 
|---|
| 6209 | } | 
|---|
| 6210 | } | 
|---|
| 6211 |  | 
|---|
| 6212 | # Return only those which are actually defined. | 
|---|
| 6213 | return sort grep { var ($_ . '_' . $primary) } keys %valid; | 
|---|
| 6214 | } | 
|---|
| 6215 |  | 
|---|
| 6216 |  | 
|---|
| 6217 | # Handle `where_HOW' variable magic.  Does all lookups, generates | 
|---|
| 6218 | # install code, and possibly generates code to define the primary | 
|---|
| 6219 | # variable.  The first argument is the name of the .am file to munge, | 
|---|
| 6220 | # the second argument is the primary variable (e.g. HEADERS), and all | 
|---|
| 6221 | # subsequent arguments are possible installation locations. | 
|---|
| 6222 | # | 
|---|
| 6223 | # Returns list of [$location, $value] pairs, where | 
|---|
| 6224 | # $value's are the values in all where_HOW variable, and $location | 
|---|
| 6225 | # there associated location (the place here their parent variables were | 
|---|
| 6226 | # defined). | 
|---|
| 6227 | # | 
|---|
| 6228 | # FIXME: this should be rewritten to be cleaner.  It should be broken | 
|---|
| 6229 | # up into multiple functions. | 
|---|
| 6230 | # | 
|---|
| 6231 | # Usage is: am_install_var (OPTION..., file, HOW, where...) | 
|---|
| 6232 | sub am_install_var | 
|---|
| 6233 | { | 
|---|
| 6234 | my (@args) = @_; | 
|---|
| 6235 |  | 
|---|
| 6236 | my $do_require = 1; | 
|---|
| 6237 | my $can_dist = 0; | 
|---|
| 6238 | my $default_dist = 0; | 
|---|
| 6239 | while (@args) | 
|---|
| 6240 | { | 
|---|
| 6241 | if ($args[0] eq '-noextra') | 
|---|
| 6242 | { | 
|---|
| 6243 | $do_require = 0; | 
|---|
| 6244 | } | 
|---|
| 6245 | elsif ($args[0] eq '-candist') | 
|---|
| 6246 | { | 
|---|
| 6247 | $can_dist = 1; | 
|---|
| 6248 | } | 
|---|
| 6249 | elsif ($args[0] eq '-defaultdist') | 
|---|
| 6250 | { | 
|---|
| 6251 | $default_dist = 1; | 
|---|
| 6252 | $can_dist = 1; | 
|---|
| 6253 | } | 
|---|
| 6254 | elsif ($args[0] !~ /^-/) | 
|---|
| 6255 | { | 
|---|
| 6256 | last; | 
|---|
| 6257 | } | 
|---|
| 6258 | shift (@args); | 
|---|
| 6259 | } | 
|---|
| 6260 |  | 
|---|
| 6261 | my ($file, $primary, @prefix) = @args; | 
|---|
| 6262 |  | 
|---|
| 6263 | # Now that configure substitutions are allowed in where_HOW | 
|---|
| 6264 | # variables, it is an error to actually define the primary.  We | 
|---|
| 6265 | # allow `JAVA', as it is customarily used to mean the Java | 
|---|
| 6266 | # interpreter.  This is but one of several Java hacks.  Similarly, | 
|---|
| 6267 | # `PYTHON' is customarily used to mean the Python interpreter. | 
|---|
| 6268 | reject_var $primary, "`$primary' is an anachronism" | 
|---|
| 6269 | unless $primary eq 'JAVA' || $primary eq 'PYTHON'; | 
|---|
| 6270 |  | 
|---|
| 6271 | # Get the prefixes which are valid and actually used. | 
|---|
| 6272 | @prefix = am_primary_prefixes ($primary, $can_dist, @prefix); | 
|---|
| 6273 |  | 
|---|
| 6274 | # If a primary includes a configure substitution, then the EXTRA_ | 
|---|
| 6275 | # form is required.  Otherwise we can't properly do our job. | 
|---|
| 6276 | my $require_extra; | 
|---|
| 6277 |  | 
|---|
| 6278 | my @used = (); | 
|---|
| 6279 | my @result = (); | 
|---|
| 6280 |  | 
|---|
| 6281 | # True if the iteration is the first one.  Used for instance to | 
|---|
| 6282 | # output parts of the associated file only once. | 
|---|
| 6283 | my $first = 1; | 
|---|
| 6284 | foreach my $X (@prefix) | 
|---|
| 6285 | { | 
|---|
| 6286 | my $nodir_name = $X; | 
|---|
| 6287 | my $one_name = $X . '_' . $primary; | 
|---|
| 6288 | my $one_var = var $one_name; | 
|---|
| 6289 |  | 
|---|
| 6290 | my $strip_subdir = 1; | 
|---|
| 6291 | # If subdir prefix should be preserved, do so. | 
|---|
| 6292 | if ($nodir_name =~ /^nobase_/) | 
|---|
| 6293 | { | 
|---|
| 6294 | $strip_subdir = 0; | 
|---|
| 6295 | $nodir_name =~ s/^nobase_//; | 
|---|
| 6296 | } | 
|---|
| 6297 |  | 
|---|
| 6298 | # If files should be distributed, do so. | 
|---|
| 6299 | my $dist_p = 0; | 
|---|
| 6300 | if ($can_dist) | 
|---|
| 6301 | { | 
|---|
| 6302 | $dist_p = (($default_dist && $nodir_name !~ /^nodist_/) | 
|---|
| 6303 | || (! $default_dist && $nodir_name =~ /^dist_/)); | 
|---|
| 6304 | $nodir_name =~ s/^(dist|nodist)_//; | 
|---|
| 6305 | } | 
|---|
| 6306 |  | 
|---|
| 6307 |  | 
|---|
| 6308 | # Use the location of the currently processed variable. | 
|---|
| 6309 | # We are not processing a particular condition, so pick the first | 
|---|
| 6310 | # available. | 
|---|
| 6311 | my $tmpcond = $one_var->conditions->one_cond; | 
|---|
| 6312 | my $where = $one_var->rdef ($tmpcond)->location->clone; | 
|---|
| 6313 |  | 
|---|
| 6314 | # Append actual contents of where_PRIMARY variable to | 
|---|
| 6315 | # @result, skipping @substitutions@. | 
|---|
| 6316 | foreach my $locvals ($one_var->value_as_list_recursive (location => 1)) | 
|---|
| 6317 | { | 
|---|
| 6318 | my ($loc, $value) = @$locvals; | 
|---|
| 6319 | # Skip configure substitutions. | 
|---|
| 6320 | if ($value =~ /^\@.*\@$/) | 
|---|
| 6321 | { | 
|---|
| 6322 | if ($nodir_name eq 'EXTRA') | 
|---|
| 6323 | { | 
|---|
| 6324 | error ($where, | 
|---|
| 6325 | "`$one_name' contains configure substitution, " | 
|---|
| 6326 | . "but shouldn't"); | 
|---|
| 6327 | } | 
|---|
| 6328 | # Check here to make sure variables defined in | 
|---|
| 6329 | # configure.ac do not imply that EXTRA_PRIMARY | 
|---|
| 6330 | # must be defined. | 
|---|
| 6331 | elsif (! defined $configure_vars{$one_name}) | 
|---|
| 6332 | { | 
|---|
| 6333 | $require_extra = $one_name | 
|---|
| 6334 | if $do_require; | 
|---|
| 6335 | } | 
|---|
| 6336 | } | 
|---|
| 6337 | else | 
|---|
| 6338 | { | 
|---|
| 6339 | push (@result, $locvals); | 
|---|
| 6340 | } | 
|---|
| 6341 | } | 
|---|
| 6342 | # A blatant hack: we rewrite each _PROGRAMS primary to include | 
|---|
| 6343 | # EXEEXT. | 
|---|
| 6344 | append_exeext ($one_name) | 
|---|
| 6345 | if $primary eq 'PROGRAMS'; | 
|---|
| 6346 | # "EXTRA" shouldn't be used when generating clean targets, | 
|---|
| 6347 | # all, or install targets.  We used to warn if EXTRA_FOO was | 
|---|
| 6348 | # defined uselessly, but this was annoying. | 
|---|
| 6349 | next | 
|---|
| 6350 | if $nodir_name eq 'EXTRA'; | 
|---|
| 6351 |  | 
|---|
| 6352 | if ($nodir_name eq 'check') | 
|---|
| 6353 | { | 
|---|
| 6354 | push (@check, '$(' . $one_name . ')'); | 
|---|
| 6355 | } | 
|---|
| 6356 | else | 
|---|
| 6357 | { | 
|---|
| 6358 | push (@used, '$(' . $one_name . ')'); | 
|---|
| 6359 | } | 
|---|
| 6360 |  | 
|---|
| 6361 | # Is this to be installed? | 
|---|
| 6362 | my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check'; | 
|---|
| 6363 |  | 
|---|
| 6364 | # If so, with install-exec? (or install-data?). | 
|---|
| 6365 | my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o); | 
|---|
| 6366 |  | 
|---|
| 6367 | my $check_options_p = $install_p && !! option 'std-options'; | 
|---|
| 6368 |  | 
|---|
| 6369 | # Use the location of the currently processed variable as context. | 
|---|
| 6370 | $where->push_context ("while processing `$one_name'"); | 
|---|
| 6371 |  | 
|---|
| 6372 | # The variable containing all file to distribute. | 
|---|
| 6373 | my $distvar = "\$($one_name)"; | 
|---|
| 6374 | $distvar = shadow_unconditionally ($one_name, $where) | 
|---|
| 6375 | if ($dist_p && $one_var->has_conditional_contents); | 
|---|
| 6376 |  | 
|---|
| 6377 | # Singular form of $PRIMARY. | 
|---|
| 6378 | (my $one_primary = $primary) =~ s/S$//; | 
|---|
| 6379 | $output_rules .= &file_contents ($file, $where, | 
|---|
| 6380 | FIRST => $first, | 
|---|
| 6381 |  | 
|---|
| 6382 | PRIMARY     => $primary, | 
|---|
| 6383 | ONE_PRIMARY => $one_primary, | 
|---|
| 6384 | DIR         => $X, | 
|---|
| 6385 | NDIR        => $nodir_name, | 
|---|
| 6386 | BASE        => $strip_subdir, | 
|---|
| 6387 |  | 
|---|
| 6388 | EXEC      => $exec_p, | 
|---|
| 6389 | INSTALL   => $install_p, | 
|---|
| 6390 | DIST      => $dist_p, | 
|---|
| 6391 | DISTVAR   => $distvar, | 
|---|
| 6392 | 'CK-OPTS' => $check_options_p); | 
|---|
| 6393 |  | 
|---|
| 6394 | $first = 0; | 
|---|
| 6395 | } | 
|---|
| 6396 |  | 
|---|
| 6397 | # The JAVA variable is used as the name of the Java interpreter. | 
|---|
| 6398 | # The PYTHON variable is used as the name of the Python interpreter. | 
|---|
| 6399 | if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON') | 
|---|
| 6400 | { | 
|---|
| 6401 | # Define it. | 
|---|
| 6402 | define_pretty_variable ($primary, TRUE, INTERNAL, @used); | 
|---|
| 6403 | $output_vars .= "\n"; | 
|---|
| 6404 | } | 
|---|
| 6405 |  | 
|---|
| 6406 | err_var ($require_extra, | 
|---|
| 6407 | "`$require_extra' contains configure substitution,\n" | 
|---|
| 6408 | . "but `EXTRA_$primary' not defined") | 
|---|
| 6409 | if ($require_extra && ! var ('EXTRA_' . $primary)); | 
|---|
| 6410 |  | 
|---|
| 6411 | # Push here because PRIMARY might be configure time determined. | 
|---|
| 6412 | push (@all, '$(' . $primary . ')') | 
|---|
| 6413 | if @used && $primary ne 'JAVA' && $primary ne 'PYTHON'; | 
|---|
| 6414 |  | 
|---|
| 6415 | # Make the result unique.  This lets the user use conditionals in | 
|---|
| 6416 | # a natural way, but still lets us program lazily -- we don't have | 
|---|
| 6417 | # to worry about handling a particular object more than once. | 
|---|
| 6418 | # We will keep only one location per object. | 
|---|
| 6419 | my %result = (); | 
|---|
| 6420 | for my $pair (@result) | 
|---|
| 6421 | { | 
|---|
| 6422 | my ($loc, $val) = @$pair; | 
|---|
| 6423 | $result{$val} = $loc; | 
|---|
| 6424 | } | 
|---|
| 6425 | my @l = sort keys %result; | 
|---|
| 6426 | return map { [$result{$_}->clone, $_] } @l; | 
|---|
| 6427 | } | 
|---|
| 6428 |  | 
|---|
| 6429 |  | 
|---|
| 6430 | ################################################################ | 
|---|
| 6431 |  | 
|---|
| 6432 | # Each key in this hash is the name of a directory holding a | 
|---|
| 6433 | # Makefile.in.  These variables are local to `is_make_dir'. | 
|---|
| 6434 | my %make_dirs = (); | 
|---|
| 6435 | my $make_dirs_set = 0; | 
|---|
| 6436 |  | 
|---|
| 6437 | sub is_make_dir | 
|---|
| 6438 | { | 
|---|
| 6439 | my ($dir) = @_; | 
|---|
| 6440 | if (! $make_dirs_set) | 
|---|
| 6441 | { | 
|---|
| 6442 | foreach my $iter (@configure_input_files) | 
|---|
| 6443 | { | 
|---|
| 6444 | $make_dirs{dirname ($iter)} = 1; | 
|---|
| 6445 | } | 
|---|
| 6446 | # We also want to notice Makefile.in's. | 
|---|
| 6447 | foreach my $iter (@other_input_files) | 
|---|
| 6448 | { | 
|---|
| 6449 | if ($iter =~ /Makefile\.in$/) | 
|---|
| 6450 | { | 
|---|
| 6451 | $make_dirs{dirname ($iter)} = 1; | 
|---|
| 6452 | } | 
|---|
| 6453 | } | 
|---|
| 6454 | $make_dirs_set = 1; | 
|---|
| 6455 | } | 
|---|
| 6456 | return defined $make_dirs{$dir}; | 
|---|
| 6457 | } | 
|---|
| 6458 |  | 
|---|
| 6459 | ################################################################ | 
|---|
| 6460 |  | 
|---|
| 6461 | # This variable is local to the "require file" set of functions. | 
|---|
| 6462 | my @require_file_paths = (); | 
|---|
| 6463 |  | 
|---|
| 6464 |  | 
|---|
| 6465 | # &maybe_push_required_file ($DIR, $FILE, $FULLFILE) | 
|---|
| 6466 | # -------------------------------------------------- | 
|---|
| 6467 | # See if we want to push this file onto dist_common.  This function | 
|---|
| 6468 | # encodes the rules for deciding when to do so. | 
|---|
| 6469 | sub maybe_push_required_file | 
|---|
| 6470 | { | 
|---|
| 6471 | my ($dir, $file, $fullfile) = @_; | 
|---|
| 6472 |  | 
|---|
| 6473 | if ($dir eq $relative_dir) | 
|---|
| 6474 | { | 
|---|
| 6475 | push_dist_common ($file); | 
|---|
| 6476 | return 1; | 
|---|
| 6477 | } | 
|---|
| 6478 | elsif ($relative_dir eq '.' && ! &is_make_dir ($dir)) | 
|---|
| 6479 | { | 
|---|
| 6480 | # If we are doing the topmost directory, and the file is in a | 
|---|
| 6481 | # subdir which does not have a Makefile, then we distribute it | 
|---|
| 6482 | # here. | 
|---|
| 6483 |  | 
|---|
| 6484 | # If a required file is above the source tree, it is important | 
|---|
| 6485 | # to prefix it with `$(srcdir)' so that no VPATH search is | 
|---|
| 6486 | # performed.  Otherwise problems occur with Make implementations | 
|---|
| 6487 | # that rewrite and simplify rules whose dependencies are found in a | 
|---|
| 6488 | # VPATH location.  Here is an example with OSF1/Tru64 Make. | 
|---|
| 6489 | # | 
|---|
| 6490 | #   % cat Makefile | 
|---|
| 6491 | #   VPATH = sub | 
|---|
| 6492 | #   distdir: ../a | 
|---|
| 6493 | #           echo ../a | 
|---|
| 6494 | #   % ls | 
|---|
| 6495 | #   Makefile a | 
|---|
| 6496 | #   % make | 
|---|
| 6497 | #   echo a | 
|---|
| 6498 | #   a | 
|---|
| 6499 | # | 
|---|
| 6500 | # Dependency `../a' was found in `sub/../a', but this make | 
|---|
| 6501 | # implementation simplified it as `a'.  (Note that the sub/ | 
|---|
| 6502 | # directory does not even exist.) | 
|---|
| 6503 | # | 
|---|
| 6504 | # This kind of VPATH rewriting seems hard to cancel.  The | 
|---|
| 6505 | # distdir.am hack against VPATH rewriting works only when no | 
|---|
| 6506 | # simplification is done, i.e., for dependencies which are in | 
|---|
| 6507 | # subdirectories, not in enclosing directories.  Hence, in | 
|---|
| 6508 | # the latter case we use a full path to make sure no VPATH | 
|---|
| 6509 | # search occurs. | 
|---|
| 6510 | $fullfile = '$(srcdir)/' . $fullfile | 
|---|
| 6511 | if $dir =~ m,^\.\.(?:$|/),; | 
|---|
| 6512 |  | 
|---|
| 6513 | push_dist_common ($fullfile); | 
|---|
| 6514 | return 1; | 
|---|
| 6515 | } | 
|---|
| 6516 | return 0; | 
|---|
| 6517 | } | 
|---|
| 6518 |  | 
|---|
| 6519 |  | 
|---|
| 6520 | # &require_file_internal ($WHERE, $MYSTRICT, @FILES) | 
|---|
| 6521 | # -------------------------------------------------- | 
|---|
| 6522 | # Verify that the file must exist in the current directory. | 
|---|
| 6523 | # $MYSTRICT is the strictness level at which this file becomes required. | 
|---|
| 6524 | # | 
|---|
| 6525 | # Must set require_file_paths before calling this function. | 
|---|
| 6526 | # require_file_paths is set to hold a single directory (the one in | 
|---|
| 6527 | # which the first file was found) before return. | 
|---|
| 6528 | sub require_file_internal ($$@) | 
|---|
| 6529 | { | 
|---|
| 6530 | my ($where, $mystrict, @files) = @_; | 
|---|
| 6531 |  | 
|---|
| 6532 | foreach my $file (@files) | 
|---|
| 6533 | { | 
|---|
| 6534 | my $fullfile; | 
|---|
| 6535 | my $errdir; | 
|---|
| 6536 | my $errfile; | 
|---|
| 6537 | my $save_dir; | 
|---|
| 6538 |  | 
|---|
| 6539 | my $found_it = 0; | 
|---|
| 6540 | my $dangling_sym = 0; | 
|---|
| 6541 | foreach my $dir (@require_file_paths) | 
|---|
| 6542 | { | 
|---|
| 6543 | $fullfile = $dir . "/" . $file; | 
|---|
| 6544 | $errdir = $dir unless $errdir; | 
|---|
| 6545 |  | 
|---|
| 6546 | # Use different name for "error filename".  Otherwise on | 
|---|
| 6547 | # an error the bad file will be reported as e.g. | 
|---|
| 6548 | # `../../install-sh' when using the default | 
|---|
| 6549 | # config_aux_path. | 
|---|
| 6550 | $errfile = $errdir . '/' . $file; | 
|---|
| 6551 |  | 
|---|
| 6552 | if (-l $fullfile && ! -f $fullfile) | 
|---|
| 6553 | { | 
|---|
| 6554 | $dangling_sym = 1; | 
|---|
| 6555 | last; | 
|---|
| 6556 | } | 
|---|
| 6557 | elsif (-f $fullfile) | 
|---|
| 6558 | { | 
|---|
| 6559 | $found_it = 1; | 
|---|
| 6560 | maybe_push_required_file ($dir, $file, $fullfile); | 
|---|
| 6561 | $save_dir = $dir; | 
|---|
| 6562 | last; | 
|---|
| 6563 | } | 
|---|
| 6564 | } | 
|---|
| 6565 |  | 
|---|
| 6566 | # `--force-missing' only has an effect if `--add-missing' is | 
|---|
| 6567 | # specified. | 
|---|
| 6568 | if ($found_it && (! $add_missing || ! $force_missing)) | 
|---|
| 6569 | { | 
|---|
| 6570 | # Prune the path list. | 
|---|
| 6571 | @require_file_paths = $save_dir; | 
|---|
| 6572 | } | 
|---|
| 6573 | else | 
|---|
| 6574 | { | 
|---|
| 6575 | # If we've already looked for it, we're done.  You might | 
|---|
| 6576 | # wonder why we don't do this before searching for the | 
|---|
| 6577 | # file.  If we do that, then something like | 
|---|
| 6578 | # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into | 
|---|
| 6579 | # DIST_COMMON. | 
|---|
| 6580 | if (! $found_it) | 
|---|
| 6581 | { | 
|---|
| 6582 | next if defined $require_file_found{$fullfile}; | 
|---|
| 6583 | $require_file_found{$fullfile} = 1; | 
|---|
| 6584 | } | 
|---|
| 6585 |  | 
|---|
| 6586 | if ($strictness >= $mystrict) | 
|---|
| 6587 | { | 
|---|
| 6588 | if ($dangling_sym && $add_missing) | 
|---|
| 6589 | { | 
|---|
| 6590 | unlink ($fullfile); | 
|---|
| 6591 | } | 
|---|
| 6592 |  | 
|---|
| 6593 | my $trailer = ''; | 
|---|
| 6594 | my $suppress = 0; | 
|---|
| 6595 |  | 
|---|
| 6596 | # Only install missing files according to our desired | 
|---|
| 6597 | # strictness level. | 
|---|
| 6598 | my $message = "required file `$errfile' not found"; | 
|---|
| 6599 | if ($add_missing) | 
|---|
| 6600 | { | 
|---|
| 6601 | if (-f ("$libdir/$file")) | 
|---|
| 6602 | { | 
|---|
| 6603 | $suppress = 1; | 
|---|
| 6604 |  | 
|---|
| 6605 | # Install the missing file.  Symlink if we | 
|---|
| 6606 | # can, copy if we must.  Note: delete the file | 
|---|
| 6607 | # first, in case it is a dangling symlink. | 
|---|
| 6608 | $message = "installing `$errfile'"; | 
|---|
| 6609 | # Windows Perl will hang if we try to delete a | 
|---|
| 6610 | # file that doesn't exist. | 
|---|
| 6611 | unlink ($errfile) if -f $errfile; | 
|---|
| 6612 | if ($symlink_exists && ! $copy_missing) | 
|---|
| 6613 | { | 
|---|
| 6614 | if (! symlink ("$libdir/$file", $errfile)) | 
|---|
| 6615 | { | 
|---|
| 6616 | $suppress = 0; | 
|---|
| 6617 | $trailer = "; error while making link: $!"; | 
|---|
| 6618 | } | 
|---|
| 6619 | } | 
|---|
| 6620 | elsif (system ('cp', "$libdir/$file", $errfile)) | 
|---|
| 6621 | { | 
|---|
| 6622 | $suppress = 0; | 
|---|
| 6623 | $trailer = "\n    error while copying"; | 
|---|
| 6624 | } | 
|---|
| 6625 | } | 
|---|
| 6626 |  | 
|---|
| 6627 | if (! maybe_push_required_file (dirname ($errfile), | 
|---|
| 6628 | $file, $errfile)) | 
|---|
| 6629 | { | 
|---|
| 6630 | if (! $found_it) | 
|---|
| 6631 | { | 
|---|
| 6632 | # We have added the file but could not push it | 
|---|
| 6633 | # into DIST_COMMON (probably because this is | 
|---|
| 6634 | # an auxiliary file and we are not processing | 
|---|
| 6635 | # the top level Makefile). This is unfortunate, | 
|---|
| 6636 | # since it means we are using a file which is not | 
|---|
| 6637 | # distributed! | 
|---|
| 6638 |  | 
|---|
| 6639 | # Get Automake to be run again: on the second | 
|---|
| 6640 | # run the file will be found, and pushed into | 
|---|
| 6641 | # the toplevel DIST_COMMON automatically. | 
|---|
| 6642 | $automake_needs_to_reprocess_all_files = 1; | 
|---|
| 6643 | } | 
|---|
| 6644 | } | 
|---|
| 6645 |  | 
|---|
| 6646 | # Prune the path list. | 
|---|
| 6647 | @require_file_paths = &dirname ($errfile); | 
|---|
| 6648 | } | 
|---|
| 6649 |  | 
|---|
| 6650 | # If --force-missing was specified, and we have | 
|---|
| 6651 | # actually found the file, then do nothing. | 
|---|
| 6652 | next | 
|---|
| 6653 | if $found_it && $force_missing; | 
|---|
| 6654 |  | 
|---|
| 6655 | # If we couldn' install the file, but it is a target in | 
|---|
| 6656 | # the Makefile, don't print anything.  This allows files | 
|---|
| 6657 | # like README, AUTHORS, or THANKS to be generated. | 
|---|
| 6658 | next | 
|---|
| 6659 | if !$suppress && rule $file; | 
|---|
| 6660 |  | 
|---|
| 6661 | msg ($suppress ? 'note' : 'error', $where, "$message$trailer"); | 
|---|
| 6662 | } | 
|---|
| 6663 | } | 
|---|
| 6664 | } | 
|---|
| 6665 | } | 
|---|
| 6666 |  | 
|---|
| 6667 | # &require_file ($WHERE, $MYSTRICT, @FILES) | 
|---|
| 6668 | # ----------------------------------------- | 
|---|
| 6669 | sub require_file ($$@) | 
|---|
| 6670 | { | 
|---|
| 6671 | my ($where, $mystrict, @files) = @_; | 
|---|
| 6672 | @require_file_paths = $relative_dir; | 
|---|
| 6673 | require_file_internal ($where, $mystrict, @files); | 
|---|
| 6674 | } | 
|---|
| 6675 |  | 
|---|
| 6676 | # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES) | 
|---|
| 6677 | # ----------------------------------------------------------- | 
|---|
| 6678 | sub require_file_with_macro ($$$@) | 
|---|
| 6679 | { | 
|---|
| 6680 | my ($cond, $macro, $mystrict, @files) = @_; | 
|---|
| 6681 | $macro = rvar ($macro) unless ref $macro; | 
|---|
| 6682 | require_file ($macro->rdef ($cond)->location, $mystrict, @files); | 
|---|
| 6683 | } | 
|---|
| 6684 |  | 
|---|
| 6685 |  | 
|---|
| 6686 | # &require_conf_file ($WHERE, $MYSTRICT, @FILES) | 
|---|
| 6687 | # ---------------------------------------------- | 
|---|
| 6688 | # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR. | 
|---|
| 6689 | sub require_conf_file ($$@) | 
|---|
| 6690 | { | 
|---|
| 6691 | my ($where, $mystrict, @files) = @_; | 
|---|
| 6692 | @require_file_paths = @config_aux_path; | 
|---|
| 6693 | require_file_internal ($where, $mystrict, @files); | 
|---|
| 6694 | my $dir = $require_file_paths[0]; | 
|---|
| 6695 | @config_aux_path = @require_file_paths; | 
|---|
| 6696 | # Avoid unsightly '/.'s. | 
|---|
| 6697 | $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir"); | 
|---|
| 6698 | } | 
|---|
| 6699 |  | 
|---|
| 6700 |  | 
|---|
| 6701 | # &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES) | 
|---|
| 6702 | # ---------------------------------------------------------------- | 
|---|
| 6703 | sub require_conf_file_with_macro ($$$@) | 
|---|
| 6704 | { | 
|---|
| 6705 | my ($cond, $macro, $mystrict, @files) = @_; | 
|---|
| 6706 | require_conf_file (rvar ($macro)->rdef ($cond)->location, | 
|---|
| 6707 | $mystrict, @files); | 
|---|
| 6708 | } | 
|---|
| 6709 |  | 
|---|
| 6710 | ################################################################ | 
|---|
| 6711 |  | 
|---|
| 6712 | # &require_build_directory ($DIRECTORY) | 
|---|
| 6713 | # ------------------------------------ | 
|---|
| 6714 | # Emit rules to create $DIRECTORY if needed, and return | 
|---|
| 6715 | # the file that any target requiring this directory should be made | 
|---|
| 6716 | # dependent upon. | 
|---|
| 6717 | sub require_build_directory ($) | 
|---|
| 6718 | { | 
|---|
| 6719 | my $directory = shift; | 
|---|
| 6720 | my $dirstamp = "$directory/\$(am__dirstamp)"; | 
|---|
| 6721 |  | 
|---|
| 6722 | # Don't emit the rule twice. | 
|---|
| 6723 | if (! defined $directory_map{$directory}) | 
|---|
| 6724 | { | 
|---|
| 6725 | $directory_map{$directory} = 1; | 
|---|
| 6726 |  | 
|---|
| 6727 | # Set a variable for the dirstamp basename. | 
|---|
| 6728 | define_pretty_variable ('am__dirstamp', TRUE, INTERNAL, | 
|---|
| 6729 | '$(am__leading_dot)dirstamp'); | 
|---|
| 6730 |  | 
|---|
| 6731 | # Directory must be removed by `make distclean'. | 
|---|
| 6732 | $clean_files{$dirstamp} = DIST_CLEAN; | 
|---|
| 6733 |  | 
|---|
| 6734 | $output_rules .= ("$dirstamp:\n" | 
|---|
| 6735 | . "\t\@\$(mkdir_p) $directory\n" | 
|---|
| 6736 | . "\t\@: > $dirstamp\n"); | 
|---|
| 6737 | } | 
|---|
| 6738 |  | 
|---|
| 6739 | return $dirstamp; | 
|---|
| 6740 | } | 
|---|
| 6741 |  | 
|---|
| 6742 | # &require_build_directory_maybe ($FILE) | 
|---|
| 6743 | # -------------------------------------- | 
|---|
| 6744 | # If $FILE lies in a subdirectory, emit a rule to create this | 
|---|
| 6745 | # directory and return the file that $FILE should be made | 
|---|
| 6746 | # dependent upon.  Otherwise, just return the empty string. | 
|---|
| 6747 | sub require_build_directory_maybe ($) | 
|---|
| 6748 | { | 
|---|
| 6749 | my $file = shift; | 
|---|
| 6750 | my $directory = dirname ($file); | 
|---|
| 6751 |  | 
|---|
| 6752 | if ($directory ne '.') | 
|---|
| 6753 | { | 
|---|
| 6754 | return require_build_directory ($directory); | 
|---|
| 6755 | } | 
|---|
| 6756 | else | 
|---|
| 6757 | { | 
|---|
| 6758 | return ''; | 
|---|
| 6759 | } | 
|---|
| 6760 | } | 
|---|
| 6761 |  | 
|---|
| 6762 | ################################################################ | 
|---|
| 6763 |  | 
|---|
| 6764 | # Push a list of files onto dist_common. | 
|---|
| 6765 | sub push_dist_common | 
|---|
| 6766 | { | 
|---|
| 6767 | prog_error "push_dist_common run after handle_dist" | 
|---|
| 6768 | if $handle_dist_run; | 
|---|
| 6769 | Automake::Variable::define ('DIST_COMMON', VAR_AUTOMAKE, '+', TRUE, "@_", | 
|---|
| 6770 | '', INTERNAL, VAR_PRETTY); | 
|---|
| 6771 | } | 
|---|
| 6772 |  | 
|---|
| 6773 |  | 
|---|
| 6774 | ################################################################ | 
|---|
| 6775 |  | 
|---|
| 6776 | # generate_makefile ($MAKEFILE_AM, $MAKEFILE_IN) | 
|---|
| 6777 | # ---------------------------------------------- | 
|---|
| 6778 | # Generate a Makefile.in given the name of the corresponding Makefile and | 
|---|
| 6779 | # the name of the file output by config.status. | 
|---|
| 6780 | sub generate_makefile ($$) | 
|---|
| 6781 | { | 
|---|
| 6782 | my ($makefile_am, $makefile_in) = @_; | 
|---|
| 6783 |  | 
|---|
| 6784 | # Reset all the Makefile.am related variables. | 
|---|
| 6785 | initialize_per_input; | 
|---|
| 6786 |  | 
|---|
| 6787 | # AUTOMAKE_OPTIONS can contains -W flags to disable or enable | 
|---|
| 6788 | # warnings for this file.  So hold any warning issued before | 
|---|
| 6789 | # we have processed AUTOMAKE_OPTIONS. | 
|---|
| 6790 | buffer_messages ('warning'); | 
|---|
| 6791 |  | 
|---|
| 6792 | # Name of input file ("Makefile.am") and output file | 
|---|
| 6793 | # ("Makefile.in").  These have no directory components. | 
|---|
| 6794 | $am_file_name = basename ($makefile_am); | 
|---|
| 6795 | $in_file_name = basename ($makefile_in); | 
|---|
| 6796 |  | 
|---|
| 6797 | # $OUTPUT is encoded.  If it contains a ":" then the first element | 
|---|
| 6798 | # is the real output file, and all remaining elements are input | 
|---|
| 6799 | # files.  We don't scan or otherwise deal with these input files, | 
|---|
| 6800 | # other than to mark them as dependencies.  See | 
|---|
| 6801 | # &scan_autoconf_files for details. | 
|---|
| 6802 | my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in}); | 
|---|
| 6803 |  | 
|---|
| 6804 | $relative_dir = dirname ($makefile); | 
|---|
| 6805 | $am_relative_dir = dirname ($makefile_am); | 
|---|
| 6806 |  | 
|---|
| 6807 | read_main_am_file ($makefile_am); | 
|---|
| 6808 | if (handle_options) | 
|---|
| 6809 | { | 
|---|
| 6810 | # Process buffered warnings. | 
|---|
| 6811 | flush_messages; | 
|---|
| 6812 | # Fatal error.  Just return, so we can continue with next file. | 
|---|
| 6813 | return; | 
|---|
| 6814 | } | 
|---|
| 6815 | # Process buffered warnings. | 
|---|
| 6816 | flush_messages; | 
|---|
| 6817 |  | 
|---|
| 6818 | # There are a few install-related variables that you should not define. | 
|---|
| 6819 | foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL') | 
|---|
| 6820 | { | 
|---|
| 6821 | my $v = var $var; | 
|---|
| 6822 | if ($v) | 
|---|
| 6823 | { | 
|---|
| 6824 | my $def = $v->def (TRUE); | 
|---|
| 6825 | prog_error "$var not defined in condition TRUE" | 
|---|
| 6826 | unless $def; | 
|---|
| 6827 | reject_var $var, "`$var' should not be defined" | 
|---|
| 6828 | if $def->owner != VAR_AUTOMAKE; | 
|---|
| 6829 | } | 
|---|
| 6830 | } | 
|---|
| 6831 |  | 
|---|
| 6832 | # Catch some obsolete variables. | 
|---|
| 6833 | msg_var ('obsolete', 'INCLUDES', | 
|---|
| 6834 | "`INCLUDES' is the old name for `AM_CPPFLAGS' (or `*_CPPFLAGS')") | 
|---|
| 6835 | if var ('INCLUDES'); | 
|---|
| 6836 |  | 
|---|
| 6837 | # At the toplevel directory, we might need config.guess, config.sub | 
|---|
| 6838 | # or libtool scripts (ltconfig and ltmain.sh). | 
|---|
| 6839 | if ($relative_dir eq '.') | 
|---|
| 6840 | { | 
|---|
| 6841 | # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and | 
|---|
| 6842 | # config.sub. | 
|---|
| 6843 | require_conf_file ($canonical_location, FOREIGN, | 
|---|
| 6844 | 'config.guess', 'config.sub') | 
|---|
| 6845 | if $seen_canonical; | 
|---|
| 6846 | } | 
|---|
| 6847 |  | 
|---|
| 6848 | # Must do this after reading .am file. | 
|---|
| 6849 | define_variable ('subdir', $relative_dir, INTERNAL); | 
|---|
| 6850 |  | 
|---|
| 6851 | # If DIST_SUBDIRS is defined, make sure SUBDIRS is, so that | 
|---|
| 6852 | # recursive rules are enabled. | 
|---|
| 6853 | define_pretty_variable ('SUBDIRS', TRUE, INTERNAL, '') | 
|---|
| 6854 | if var 'DIST_SUBDIRS' && ! var 'SUBDIRS'; | 
|---|
| 6855 |  | 
|---|
| 6856 | # Check first, because we might modify some state. | 
|---|
| 6857 | check_cygnus; | 
|---|
| 6858 | check_gnu_standards; | 
|---|
| 6859 | check_gnits_standards; | 
|---|
| 6860 |  | 
|---|
| 6861 | handle_configure ($makefile_am, $makefile_in, $makefile, @inputs); | 
|---|
| 6862 | handle_gettext; | 
|---|
| 6863 | handle_libraries; | 
|---|
| 6864 | handle_ltlibraries; | 
|---|
| 6865 | handle_programs; | 
|---|
| 6866 | handle_scripts; | 
|---|
| 6867 |  | 
|---|
| 6868 | # This must run first so that the ANSI2KNR definition is generated | 
|---|
| 6869 | # before it is used by the _.c rules.  We have to do this because | 
|---|
| 6870 | # a variable which is used in a dependency must be defined before | 
|---|
| 6871 | # the target, or else make won't properly see it. | 
|---|
| 6872 | handle_compile; | 
|---|
| 6873 | # This must be run after all the sources are scanned. | 
|---|
| 6874 | handle_languages; | 
|---|
| 6875 |  | 
|---|
| 6876 | # We have to run this after dealing with all the programs. | 
|---|
| 6877 | handle_libtool; | 
|---|
| 6878 |  | 
|---|
| 6879 | # Variables used by distdir.am and tags.am. | 
|---|
| 6880 | define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources); | 
|---|
| 6881 | define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources); | 
|---|
| 6882 |  | 
|---|
| 6883 | handle_multilib; | 
|---|
| 6884 | handle_texinfo; | 
|---|
| 6885 | handle_emacs_lisp; | 
|---|
| 6886 | handle_python; | 
|---|
| 6887 | handle_java; | 
|---|
| 6888 | handle_man_pages; | 
|---|
| 6889 | handle_data; | 
|---|
| 6890 | handle_headers; | 
|---|
| 6891 | handle_subdirs; | 
|---|
| 6892 | handle_tags; | 
|---|
| 6893 | handle_minor_options; | 
|---|
| 6894 | handle_tests; | 
|---|
| 6895 |  | 
|---|
| 6896 | # This must come after most other rules. | 
|---|
| 6897 | handle_dist; | 
|---|
| 6898 |  | 
|---|
| 6899 | handle_footer; | 
|---|
| 6900 | do_check_merge_target; | 
|---|
| 6901 | handle_all ($makefile); | 
|---|
| 6902 |  | 
|---|
| 6903 | # FIXME: Gross! | 
|---|
| 6904 | if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS')) | 
|---|
| 6905 | { | 
|---|
| 6906 | $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n"; | 
|---|
| 6907 | } | 
|---|
| 6908 |  | 
|---|
| 6909 | handle_install; | 
|---|
| 6910 | handle_clean ($makefile); | 
|---|
| 6911 | handle_factored_dependencies; | 
|---|
| 6912 |  | 
|---|
| 6913 | # Comes last, because all the above procedures may have | 
|---|
| 6914 | # defined or overridden variables. | 
|---|
| 6915 | $output_vars .= output_variables; | 
|---|
| 6916 |  | 
|---|
| 6917 | check_typos; | 
|---|
| 6918 |  | 
|---|
| 6919 | if (! -d ($output_directory . '/' . $am_relative_dir)) | 
|---|
| 6920 | { | 
|---|
| 6921 | mkdir ($output_directory . '/' . $am_relative_dir, 0755); | 
|---|
| 6922 | } | 
|---|
| 6923 |  | 
|---|
| 6924 | my ($out_file) = $output_directory . '/' . $makefile_in; | 
|---|
| 6925 |  | 
|---|
| 6926 | # We make sure that `all:' is the first target. | 
|---|
| 6927 | my $output = | 
|---|
| 6928 | "$output_vars$output_all$output_header$output_rules$output_trailer"; | 
|---|
| 6929 |  | 
|---|
| 6930 | # Decide whether we must update the output file or not. | 
|---|
| 6931 | # We have to update in the following situations. | 
|---|
| 6932 | #  * $force_generation is set. | 
|---|
| 6933 | #  * any of the output dependencies is younger than the output | 
|---|
| 6934 | #  * the contents of the output is different (this can happen | 
|---|
| 6935 | #    if the project has been populated with a file listed in | 
|---|
| 6936 | #    @common_files since the last run). | 
|---|
| 6937 | # Output's dependencies are split in two sets: | 
|---|
| 6938 | #  * dependencies which are also configure dependencies | 
|---|
| 6939 | #    These do not change between each Makefile.am | 
|---|
| 6940 | #  * other dependencies, specific to the Makefile.am being processed | 
|---|
| 6941 | #    (such as the Makefile.am itself, or any Makefile fragment | 
|---|
| 6942 | #    it includes). | 
|---|
| 6943 | my $timestamp = mtime $out_file; | 
|---|
| 6944 | if (! $force_generation | 
|---|
| 6945 | && $configure_deps_greatest_timestamp < $timestamp | 
|---|
| 6946 | && $output_deps_greatest_timestamp < $timestamp | 
|---|
| 6947 | && $output eq contents ($out_file)) | 
|---|
| 6948 | { | 
|---|
| 6949 | verb "$out_file unchanged"; | 
|---|
| 6950 | # No need to update. | 
|---|
| 6951 | return; | 
|---|
| 6952 | } | 
|---|
| 6953 |  | 
|---|
| 6954 | if (-e $out_file) | 
|---|
| 6955 | { | 
|---|
| 6956 | unlink ($out_file) | 
|---|
| 6957 | or fatal "cannot remove $out_file: $!\n"; | 
|---|
| 6958 | } | 
|---|
| 6959 |  | 
|---|
| 6960 | my $gm_file = new Automake::XFile "> $out_file"; | 
|---|
| 6961 | verb "creating $out_file"; | 
|---|
| 6962 | print $gm_file $output; | 
|---|
| 6963 | } | 
|---|
| 6964 |  | 
|---|
| 6965 | ################################################################ | 
|---|
| 6966 |  | 
|---|
| 6967 |  | 
|---|
| 6968 |  | 
|---|
| 6969 |  | 
|---|
| 6970 | ################################################################ | 
|---|
| 6971 |  | 
|---|
| 6972 | # Print usage information. | 
|---|
| 6973 | sub usage () | 
|---|
| 6974 | { | 
|---|
| 6975 | print "Usage: $0 [OPTION] ... [Makefile]... | 
|---|
| 6976 |  | 
|---|
| 6977 | Generate Makefile.in for configure from Makefile.am. | 
|---|
| 6978 |  | 
|---|
| 6979 | Operation modes: | 
|---|
| 6980 | --help               print this help, then exit | 
|---|
| 6981 | --version            print version number, then exit | 
|---|
| 6982 | -v, --verbose            verbosely list files processed | 
|---|
| 6983 | --no-force           only update Makefile.in's that are out of date | 
|---|
| 6984 | -W, --warnings=CATEGORY  report the warnings falling in CATEGORY | 
|---|
| 6985 |  | 
|---|
| 6986 | Dependency tracking: | 
|---|
| 6987 | -i, --ignore-deps      disable dependency tracking code | 
|---|
| 6988 | --include-deps     enable dependency tracking code | 
|---|
| 6989 |  | 
|---|
| 6990 | Flavors: | 
|---|
| 6991 | --cygnus           assume program is part of Cygnus-style tree | 
|---|
| 6992 | --foreign          set strictness to foreign | 
|---|
| 6993 | --gnits            set strictness to gnits | 
|---|
| 6994 | --gnu              set strictness to gnu | 
|---|
| 6995 |  | 
|---|
| 6996 | Library files: | 
|---|
| 6997 | -a, --add-missing      add missing standard files to package | 
|---|
| 6998 | --libdir=DIR       directory storing library files | 
|---|
| 6999 | -c, --copy             with -a, copy missing files (default is symlink) | 
|---|
| 7000 | -f, --force-missing    force update of standard files | 
|---|
| 7001 |  | 
|---|
| 7002 | "; | 
|---|
| 7003 | Automake::ChannelDefs::usage; | 
|---|
| 7004 |  | 
|---|
| 7005 | my ($last, @lcomm); | 
|---|
| 7006 | $last = ''; | 
|---|
| 7007 | foreach my $iter (sort ((@common_files, @common_sometimes))) | 
|---|
| 7008 | { | 
|---|
| 7009 | push (@lcomm, $iter) unless $iter eq $last; | 
|---|
| 7010 | $last = $iter; | 
|---|
| 7011 | } | 
|---|
| 7012 |  | 
|---|
| 7013 | my @four; | 
|---|
| 7014 | print "\nFiles which are automatically distributed, if found:\n"; | 
|---|
| 7015 | format USAGE_FORMAT = | 
|---|
| 7016 | @<<<<<<<<<<<<<<<<   @<<<<<<<<<<<<<<<<   @<<<<<<<<<<<<<<<<   @<<<<<<<<<<<<<<<< | 
|---|
| 7017 | $four[0],           $four[1],           $four[2],           $four[3] | 
|---|
| 7018 | . | 
|---|
| 7019 | $~ = "USAGE_FORMAT"; | 
|---|
| 7020 |  | 
|---|
| 7021 | my $cols = 4; | 
|---|
| 7022 | my $rows = int(@lcomm / $cols); | 
|---|
| 7023 | my $rest = @lcomm % $cols; | 
|---|
| 7024 |  | 
|---|
| 7025 | if ($rest) | 
|---|
| 7026 | { | 
|---|
| 7027 | $rows++; | 
|---|
| 7028 | } | 
|---|
| 7029 | else | 
|---|
| 7030 | { | 
|---|
| 7031 | $rest = $cols; | 
|---|
| 7032 | } | 
|---|
| 7033 |  | 
|---|
| 7034 | for (my $y = 0; $y < $rows; $y++) | 
|---|
| 7035 | { | 
|---|
| 7036 | @four = ("", "", "", ""); | 
|---|
| 7037 | for (my $x = 0; $x < $cols; $x++) | 
|---|
| 7038 | { | 
|---|
| 7039 | last if $y + 1 == $rows && $x == $rest; | 
|---|
| 7040 |  | 
|---|
| 7041 | my $idx = (($x > $rest) | 
|---|
| 7042 | ?  ($rows * $rest + ($rows - 1) * ($x - $rest)) | 
|---|
| 7043 | : ($rows * $x)); | 
|---|
| 7044 |  | 
|---|
| 7045 | $idx += $y; | 
|---|
| 7046 | $four[$x] = $lcomm[$idx]; | 
|---|
| 7047 | } | 
|---|
| 7048 | write; | 
|---|
| 7049 | } | 
|---|
| 7050 |  | 
|---|
| 7051 | print "\nReport bugs to <bug-automake\@gnu.org>.\n"; | 
|---|
| 7052 |  | 
|---|
| 7053 | # --help always returns 0 per GNU standards. | 
|---|
| 7054 | exit 0; | 
|---|
| 7055 | } | 
|---|
| 7056 |  | 
|---|
| 7057 |  | 
|---|
| 7058 | # &version () | 
|---|
| 7059 | # ----------- | 
|---|
| 7060 | # Print version information | 
|---|
| 7061 | sub version () | 
|---|
| 7062 | { | 
|---|
| 7063 | print <<EOF; | 
|---|
| 7064 | automake (GNU $PACKAGE) $VERSION | 
|---|
| 7065 | Written by Tom Tromey <tromey\@redhat.com>. | 
|---|
| 7066 |  | 
|---|
| 7067 | Copyright 2004 Free Software Foundation, Inc. | 
|---|
| 7068 | This is free software; see the source for copying conditions.  There is NO | 
|---|
| 7069 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 7070 | EOF | 
|---|
| 7071 | # --version always returns 0 per GNU standards. | 
|---|
| 7072 | exit 0; | 
|---|
| 7073 | } | 
|---|
| 7074 |  | 
|---|
| 7075 | ################################################################ | 
|---|
| 7076 |  | 
|---|
| 7077 | # Parse command line. | 
|---|
| 7078 | sub parse_arguments () | 
|---|
| 7079 | { | 
|---|
| 7080 | # Start off as gnu. | 
|---|
| 7081 | set_strictness ('gnu'); | 
|---|
| 7082 |  | 
|---|
| 7083 | my $cli_where = new Automake::Location; | 
|---|
| 7084 | my %cli_options = | 
|---|
| 7085 | ( | 
|---|
| 7086 | 'libdir:s'         => \$libdir, | 
|---|
| 7087 | 'gnu'              => sub { set_strictness ('gnu'); }, | 
|---|
| 7088 | 'gnits'            => sub { set_strictness ('gnits'); }, | 
|---|
| 7089 | 'cygnus'           => sub { set_global_option ('cygnus', $cli_where); }, | 
|---|
| 7090 | 'foreign'          => sub { set_strictness ('foreign'); }, | 
|---|
| 7091 | 'include-deps'     => sub { unset_global_option ('no-dependencies'); }, | 
|---|
| 7092 | 'i|ignore-deps'    => sub { set_global_option ('no-dependencies', | 
|---|
| 7093 | $cli_where); }, | 
|---|
| 7094 | 'no-force'         => sub { $force_generation = 0; }, | 
|---|
| 7095 | 'f|force-missing'  => \$force_missing, | 
|---|
| 7096 | 'o|output-dir:s'   => \$output_directory, | 
|---|
| 7097 | 'a|add-missing'    => \$add_missing, | 
|---|
| 7098 | 'c|copy'           => \$copy_missing, | 
|---|
| 7099 | 'v|verbose'        => sub { setup_channel 'verb', silent => 0; }, | 
|---|
| 7100 | 'W|warnings:s'     => \&parse_warnings, | 
|---|
| 7101 | # These long options (--Werror and --Wno-error) for backward | 
|---|
| 7102 | # compatibility.  Use -Werror and -Wno-error today. | 
|---|
| 7103 | 'Werror'           => sub { parse_warnings 'W', 'error'; }, | 
|---|
| 7104 | 'Wno-error'        => sub { parse_warnings 'W', 'no-error'; }, | 
|---|
| 7105 | ); | 
|---|
| 7106 | use Getopt::Long; | 
|---|
| 7107 | Getopt::Long::config ("bundling", "pass_through"); | 
|---|
| 7108 |  | 
|---|
| 7109 | # See if --version or --help is used.  We want to process these before | 
|---|
| 7110 | # anything else because the GNU Coding Standards require us to | 
|---|
| 7111 | # `exit 0' after processing these options, and we can't guarantee this | 
|---|
| 7112 | # if we treat other options first.  (Handling other options first | 
|---|
| 7113 | # could produce error diagnostics, and in this condition it is | 
|---|
| 7114 | # confusing if Automake does `exit 0'.) | 
|---|
| 7115 | my %cli_options_1st_pass = | 
|---|
| 7116 | ( | 
|---|
| 7117 | 'version' => \&version, | 
|---|
| 7118 | 'help'    => \&usage, | 
|---|
| 7119 | # Recognize all other options (and their arguments) but do nothing. | 
|---|
| 7120 | map { $_ => sub {} } (keys %cli_options) | 
|---|
| 7121 | ); | 
|---|
| 7122 | my @ARGV_backup = @ARGV; | 
|---|
| 7123 | Getopt::Long::GetOptions %cli_options_1st_pass | 
|---|
| 7124 | or exit 1; | 
|---|
| 7125 | @ARGV = @ARGV_backup; | 
|---|
| 7126 |  | 
|---|
| 7127 | # Now *really* process the options.  This time we know | 
|---|
| 7128 | # that --help and --version are not present. | 
|---|
| 7129 | Getopt::Long::GetOptions %cli_options | 
|---|
| 7130 | or exit 1; | 
|---|
| 7131 |  | 
|---|
| 7132 | if (defined $output_directory) | 
|---|
| 7133 | { | 
|---|
| 7134 | msg 'obsolete', "`--output-dir' is deprecated\n"; | 
|---|
| 7135 | } | 
|---|
| 7136 | else | 
|---|
| 7137 | { | 
|---|
| 7138 | # In the next release we'll remove this entirely. | 
|---|
| 7139 | $output_directory = '.'; | 
|---|
| 7140 | } | 
|---|
| 7141 |  | 
|---|
| 7142 | my $errspec = 0; | 
|---|
| 7143 | foreach my $arg (@ARGV) | 
|---|
| 7144 | { | 
|---|
| 7145 | if ($arg =~ /^-./) | 
|---|
| 7146 | { | 
|---|
| 7147 | fatal ("unrecognized option `$arg'\n" | 
|---|
| 7148 | . "Try `$0 --help' for more information."); | 
|---|
| 7149 | } | 
|---|
| 7150 |  | 
|---|
| 7151 | # Handle $local:$input syntax. | 
|---|
| 7152 | my ($local, @rest) = split (/:/, $arg); | 
|---|
| 7153 | @rest = ("$local.in",) unless @rest; | 
|---|
| 7154 | my $input = locate_am @rest; | 
|---|
| 7155 | if ($input) | 
|---|
| 7156 | { | 
|---|
| 7157 | push @input_files, $input; | 
|---|
| 7158 | $output_files{$input} = join (':', ($local, @rest)); | 
|---|
| 7159 | } | 
|---|
| 7160 | else | 
|---|
| 7161 | { | 
|---|
| 7162 | error "no Automake input file found for `$arg'"; | 
|---|
| 7163 | $errspec = 1; | 
|---|
| 7164 | } | 
|---|
| 7165 | } | 
|---|
| 7166 | fatal "no input file found among supplied arguments" | 
|---|
| 7167 | if $errspec && ! @input_files; | 
|---|
| 7168 | } | 
|---|
| 7169 |  | 
|---|
| 7170 | ################################################################ | 
|---|
| 7171 |  | 
|---|
| 7172 | # Parse the WARNINGS environment variable. | 
|---|
| 7173 | parse_WARNINGS; | 
|---|
| 7174 |  | 
|---|
| 7175 | # Parse command line. | 
|---|
| 7176 | parse_arguments; | 
|---|
| 7177 |  | 
|---|
| 7178 | $configure_ac = require_configure_ac; | 
|---|
| 7179 |  | 
|---|
| 7180 | # Do configure.ac scan only once. | 
|---|
| 7181 | scan_autoconf_files; | 
|---|
| 7182 |  | 
|---|
| 7183 | if (! @input_files) | 
|---|
| 7184 | { | 
|---|
| 7185 | my $msg = ''; | 
|---|
| 7186 | $msg = "\nDid you forget AC_CONFIG_FILES([Makefile]) in $configure_ac?" | 
|---|
| 7187 | if -f 'Makefile.am'; | 
|---|
| 7188 | fatal ("no `Makefile.am' found for any configure output$msg"); | 
|---|
| 7189 | } | 
|---|
| 7190 |  | 
|---|
| 7191 | my $automake_has_run = 0; | 
|---|
| 7192 |  | 
|---|
| 7193 | do | 
|---|
| 7194 | { | 
|---|
| 7195 | if ($automake_has_run) | 
|---|
| 7196 | { | 
|---|
| 7197 | verb 'processing Makefiles another time to fix them up.'; | 
|---|
| 7198 | prog_error 'running more than two times should never be needed.' | 
|---|
| 7199 | if $automake_has_run >= 2; | 
|---|
| 7200 | } | 
|---|
| 7201 | $automake_needs_to_reprocess_all_files = 0; | 
|---|
| 7202 |  | 
|---|
| 7203 | # Now do all the work on each file. | 
|---|
| 7204 | foreach my $file (@input_files) | 
|---|
| 7205 | { | 
|---|
| 7206 | ($am_file = $file) =~ s/\.in$//; | 
|---|
| 7207 | if (! -f ($am_file . '.am')) | 
|---|
| 7208 | { | 
|---|
| 7209 | error "`$am_file.am' does not exist"; | 
|---|
| 7210 | } | 
|---|
| 7211 | else | 
|---|
| 7212 | { | 
|---|
| 7213 | # Any warning setting now local to this Makefile.am. | 
|---|
| 7214 | dup_channel_setup; | 
|---|
| 7215 |  | 
|---|
| 7216 | generate_makefile ($am_file . '.am', $file); | 
|---|
| 7217 |  | 
|---|
| 7218 | # Back out any warning setting. | 
|---|
| 7219 | drop_channel_setup; | 
|---|
| 7220 | } | 
|---|
| 7221 | } | 
|---|
| 7222 | ++$automake_has_run; | 
|---|
| 7223 | } | 
|---|
| 7224 | while ($automake_needs_to_reprocess_all_files); | 
|---|
| 7225 |  | 
|---|
| 7226 | exit $exit_code; | 
|---|
| 7227 |  | 
|---|
| 7228 |  | 
|---|
| 7229 | ### Setup "GNU" style for perl-mode and cperl-mode. | 
|---|
| 7230 | ## Local Variables: | 
|---|
| 7231 | ## perl-indent-level: 2 | 
|---|
| 7232 | ## perl-continued-statement-offset: 2 | 
|---|
| 7233 | ## perl-continued-brace-offset: 0 | 
|---|
| 7234 | ## perl-brace-offset: 0 | 
|---|
| 7235 | ## perl-brace-imaginary-offset: 0 | 
|---|
| 7236 | ## perl-label-offset: -2 | 
|---|
| 7237 | ## cperl-indent-level: 2 | 
|---|
| 7238 | ## cperl-brace-offset: 0 | 
|---|
| 7239 | ## cperl-continued-brace-offset: 0 | 
|---|
| 7240 | ## cperl-label-offset: -2 | 
|---|
| 7241 | ## cperl-extra-newline-before-brace: t | 
|---|
| 7242 | ## cperl-merge-trailing-else: nil | 
|---|
| 7243 | ## cperl-continued-statement-offset: 2 | 
|---|
| 7244 | ## End: | 
|---|