| #!@PERL@ -w |
| # -*- perl -*- |
| # @configure_input@ |
| |
| eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' |
| if 0; |
| |
| # automake - create Makefile.in from Makefile.am |
| # Copyright (C) 1994-2012 Free Software Foundation, Inc. |
| |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2, or (at your option) |
| # any later version. |
| |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| |
| # You should have received a copy of the GNU General Public License |
| # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| |
| # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>. |
| # Perl reimplementation by Tom Tromey <tromey@redhat.com>, and |
| # Alexandre Duret-Lutz <adl@gnu.org>. |
| |
| package Language; |
| |
| BEGIN |
| { |
| my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@'; |
| unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir); |
| } |
| |
| use Class::Struct (); |
| Class::Struct::struct ( |
| # Short name of the language (c, f77...). |
| 'name' => "\$", |
| # Nice name of the language (C, Fortran 77...). |
| 'Name' => "\$", |
| |
| # List of configure variables which must be defined. |
| 'config_vars' => '@', |
| |
| # 'pure' is '1' or ''. A 'pure' language is one where, if |
| # all the files in a directory are of that language, then we |
| # do not require the C compiler or any code to call it. |
| 'pure' => "\$", |
| |
| 'autodep' => "\$", |
| |
| # Name of the compiling variable (COMPILE). |
| 'compiler' => "\$", |
| # Content of the compiling variable. |
| 'compile' => "\$", |
| # Flag to require compilation without linking (-c). |
| 'compile_flag' => "\$", |
| 'extensions' => '@', |
| # A subroutine to compute a list of possible extensions of |
| # the product given the input extensions. |
| # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo')) |
| 'output_extensions' => "\$", |
| # A list of flag variables used in 'compile'. |
| # (defaults to []) |
| 'flags' => "@", |
| |
| # Any tag to pass to libtool while compiling. |
| 'libtool_tag' => "\$", |
| |
| # The file to use when generating rules for this language. |
| # The default is 'depend2'. |
| 'rule_file' => "\$", |
| |
| # Name of the linking variable (LINK). |
| 'linker' => "\$", |
| # Content of the linking variable. |
| 'link' => "\$", |
| |
| # Name of the compiler variable (CC). |
| 'ccer' => "\$", |
| |
| # Name of the linker variable (LD). |
| 'lder' => "\$", |
| # Content of the linker variable ($(CC)). |
| 'ld' => "\$", |
| |
| # Flag to specify the output file (-o). |
| 'output_flag' => "\$", |
| '_finish' => "\$", |
| |
| # This is a subroutine which is called whenever we finally |
| # determine the context in which a source file will be |
| # compiled. |
| '_target_hook' => "\$", |
| |
| # If TRUE, nodist_ sources will be compiled using specific rules |
| # (i.e. not inference rules). The default is FALSE. |
| 'nodist_specific' => "\$"); |
| |
| |
| sub finish ($) |
| { |
| my ($self) = @_; |
| if (defined $self->_finish) |
| { |
| &{$self->_finish} (@_); |
| } |
| } |
| |
| sub target_hook ($$$$%) |
| { |
| my ($self) = @_; |
| if (defined $self->_target_hook) |
| { |
| &{$self->_target_hook} (@_); |
| } |
| } |
| |
| package Automake; |
| |
| use strict; |
| use Automake::Config; |
| use Automake::General; |
| use Automake::XFile; |
| use Automake::Channels; |
| use Automake::ChannelDefs; |
| use Automake::FileUtils; |
| use Automake::Location; |
| use Automake::Condition qw/TRUE FALSE/; |
| use Automake::DisjConditions; |
| use Automake::Options; |
| use Automake::Variable; |
| use Automake::VarDef; |
| use Automake::Rule; |
| use Automake::RuleDef; |
| use Automake::Wrap 'makefile_wrap'; |
| use File::Basename; |
| use File::Spec; |
| use Carp; |
| |
| ## ----------- ## |
| ## Constants. ## |
| ## ----------- ## |
| |
| # Some regular expressions. One reason to put them here is that it |
| # makes indentation work better in Emacs. |
| |
| # Writing singled-quoted-$-terminated regexes is a pain because |
| # perl-mode thinks of $' as the ${'} variable (instead of a $ followed |
| # by a closing quote. Letting perl-mode think the quote is not closed |
| # leads to all sort of misindentations. On the other hand, defining |
| # regexes as double-quoted strings is far less readable. So usually |
| # we will write: |
| # |
| # $REGEX = '^regex_value' . "\$"; |
| |
| my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n'; |
| my $WHITE_PATTERN = '^\s*' . "\$"; |
| my $COMMENT_PATTERN = '^#'; |
| my $TARGET_PATTERN='[$a-zA-Z0-9_.@%][-.a-zA-Z0-9_(){}/$+@%]*'; |
| # A rule has three parts: a list of targets, a list of dependencies, |
| # and optionally actions. |
| my $RULE_PATTERN = |
| "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$"; |
| |
| # Only recognize leading spaces, not leading tabs. If we recognize |
| # leading tabs here then we need to make the reader smarter, because |
| # otherwise it will think rules like 'foo=bar; \' are errors. |
| my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$"; |
| # This pattern recognizes a Gnits version id and sets $1 if the |
| # release is an alpha release. We also allow a suffix which can be |
| # used to extend the version number with a "fork" identifier. |
| my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?'; |
| |
| my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$"; |
| my $ELSE_PATTERN = |
| '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$"; |
| my $ENDIF_PATTERN = |
| '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$"; |
| my $PATH_PATTERN = '(\w|[+/.-])+'; |
| # This will pass through anything not of the prescribed form. |
| my $INCLUDE_PATTERN = ('^include\s+' |
| . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')' |
| . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')' |
| . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$"); |
| |
| # Directories installed during 'install-exec' phase. |
| my $EXEC_DIR_PATTERN = |
| '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$"; |
| |
| # Values for AC_CANONICAL_* |
| use constant AC_CANONICAL_BUILD => 1; |
| use constant AC_CANONICAL_HOST => 2; |
| use constant AC_CANONICAL_TARGET => 3; |
| |
| # Values indicating when something should be cleaned. |
| use constant MOSTLY_CLEAN => 0; |
| use constant CLEAN => 1; |
| use constant DIST_CLEAN => 2; |
| use constant MAINTAINER_CLEAN => 3; |
| |
| # Libtool files. |
| my @libtool_files = qw(ltmain.sh config.guess config.sub); |
| |
| # Commonly found files we look for and automatically include in |
| # distributed files. |
| my @common_files = ( |
| qw( |
| ABOUT-GNU |
| ABOUT-NLS |
| AUTHORS |
| COPYING |
| COPYING.DOC |
| COPYING.LIB |
| COPYING.LESSER |
| ChangeLog |
| INSTALL |
| NEWS |
| README |
| THANKS |
| TODO |
| ar-lib |
| compile |
| config.guess |
| config.rpath |
| config.sub |
| depcomp |
| install-sh |
| libversion.in |
| mdate-sh |
| missing |
| py-compile |
| texinfo.tex |
| ylwrap |
| ), |
| @libtool_files, |
| ); |
| |
| # Commonly used files we auto-include, but only sometimes. This list |
| # is used for the --help output only. |
| my @common_sometimes = |
| qw( |
| aclocal.m4 |
| configure |
| configure.ac |
| stamp-vti |
| ); |
| |
| # Standard directories from the GNU Coding Standards, and additional |
| # pkg* directories from Automake. Stored in a hash for fast member check. |
| my %standard_prefix = |
| map { $_ => 1 } (qw(bin data dataroot doc dvi exec html include info |
| lib libexec lisp locale localstate man man1 man2 |
| man3 man4 man5 man6 man7 man8 man9 oldinclude pdf |
| pkgdata pkginclude pkglib pkglibexec ps sbin |
| sharedstate sysconf)); |
| |
| # Copyright on generated Makefile.ins. |
| my $gen_copyright = "\ |
| # Copyright (C) 1994-$RELEASE_YEAR Free Software Foundation, Inc. |
| |
| # This Makefile.in is free software; the Free Software Foundation |
| # gives unlimited permission to copy and/or distribute it, |
| # with or without modifications, as long as this notice is preserved. |
| |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
| # even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| # PARTICULAR PURPOSE. |
| "; |
| |
| # These are used when keeping track of whether an object can be built |
| # by two different paths. |
| use constant COMPILE_LIBTOOL => 1; |
| use constant COMPILE_ORDINARY => 2; |
| |
| # We can't always associate a location to a variable or a rule, |
| # when it's defined by Automake. We use INTERNAL in this case. |
| use constant INTERNAL => new Automake::Location; |
| |
| |
| ## ---------------------------------- ## |
| ## Variables related to the options. ## |
| ## ---------------------------------- ## |
| |
| # TRUE if we should always generate Makefile.in. |
| my $force_generation = 1; |
| |
| # From the Perl manual. |
| my $symlink_exists = (eval 'symlink ("", "");', $@ eq ''); |
| |
| # TRUE if missing standard files should be installed. |
| my $add_missing = 0; |
| |
| # TRUE if we should copy missing files; otherwise symlink if possible. |
| my $copy_missing = 0; |
| |
| # TRUE if we should always update files that we know about. |
| my $force_missing = 0; |
| |
| |
| ## ---------------------------------------- ## |
| ## Variables filled during files scanning. ## |
| ## ---------------------------------------- ## |
| |
| # Name of the Autoconf input file. We used to support configure.in |
| # as well once, that that is long obsolete now. |
| my $configure_ac = 'configure.ac'; |
| |
| # Files found by scanning configure.ac for LIBOBJS. |
| my %libsources = (); |
| |
| # Names used in AC_CONFIG_HEADER call. |
| my @config_headers = (); |
| |
| # Names used in AC_CONFIG_LINKS call. |
| my @config_links = (); |
| |
| # List of Makefile.am's to process, and their corresponding outputs. |
| my @input_files = (); |
| my %output_files = (); |
| |
| # Complete list of Makefile.am's that exist. |
| my @configure_input_files = (); |
| |
| # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's, |
| # and their outputs. |
| my @other_input_files = (); |
| # Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears. |
| # The keys are the files created by these macros. |
| my %ac_config_files_location = (); |
| # The condition under which AC_CONFIG_FOOS appears. |
| my %ac_config_files_condition = (); |
| |
| # Directory to search for configure-required files. This |
| # will be computed by &locate_aux_dir and can be set using |
| # AC_CONFIG_AUX_DIR in configure.ac. |
| # $CONFIG_AUX_DIR is the 'raw' directory, valid only in the source-tree. |
| my $config_aux_dir = ''; |
| my $config_aux_dir_set_in_configure_ac = 0; |
| # $AM_CONFIG_AUX_DIR is prefixed with $(top_srcdir), so it can be used |
| # in Makefiles. |
| my $am_config_aux_dir = ''; |
| |
| # Directory to search for AC_LIBSOURCE files, as set by AC_CONFIG_LIBOBJ_DIR |
| # in configure.ac. |
| my $config_libobj_dir = ''; |
| |
| # Whether AM_GNU_GETTEXT has been seen in configure.ac. |
| my $seen_gettext = 0; |
| # Whether AM_GNU_GETTEXT([external]) is used. |
| my $seen_gettext_external = 0; |
| # Where AM_GNU_GETTEXT appears. |
| my $ac_gettext_location; |
| # Whether AM_GNU_GETTEXT_INTL_SUBDIR has been seen. |
| my $seen_gettext_intl = 0; |
| |
| # The arguments of the AM_EXTRA_RECURSIVE_TARGETS call (if any). |
| my @extra_recursive_targets = (); |
| |
| # Lists of tags supported by Libtool. |
| my %libtool_tags = (); |
| # 1 if Libtool uses LT_SUPPORTED_TAG. If it does, then it also |
| # uses AC_REQUIRE_AUX_FILE. |
| my $libtool_new_api = 0; |
| |
| # Most important AC_CANONICAL_* macro seen so far. |
| my $seen_canonical = 0; |
| |
| # Actual version we've seen. |
| my $package_version = ''; |
| |
| # Where version is defined. |
| my $package_version_location; |
| |
| # TRUE if we've seen AM_PROG_AR |
| my $seen_ar = 0; |
| |
| # TRUE if we've seen AM_PROG_CC_C_O |
| my $seen_cc_c_o = 0; |
| |
| # Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument. |
| my %required_aux_file = (); |
| |
| # Where AM_INIT_AUTOMAKE is called; |
| my $seen_init_automake = 0; |
| |
| # TRUE if we've seen AM_AUTOMAKE_VERSION. |
| my $seen_automake_version = 0; |
| |
| # Hash table of discovered configure substitutions. Keys are names, |
| # values are 'FILE:LINE' strings which are used by error message |
| # generation. |
| my %configure_vars = (); |
| |
| # Ignored configure substitutions (i.e., variables not to be output in |
| # Makefile.in) |
| my %ignored_configure_vars = (); |
| |
| # Files included by $configure_ac. |
| my @configure_deps = (); |
| |
| # Greatest timestamp of configure's dependencies. |
| my $configure_deps_greatest_timestamp = 0; |
| |
| # Hash table of AM_CONDITIONAL variables seen in configure. |
| my %configure_cond = (); |
| |
| # This maps extensions onto language names. |
| my %extension_map = (); |
| |
| # List of the distributed files we discovered while reading |
| # configure.ac. |
| my @configure_dist_common = (); |
| |
| # List of the "auto-discovered" distributed files. |
| my @dist_common = (); |
| |
| # This maps languages names onto objects. |
| my %languages = (); |
| # Maps each linker variable onto a language object. |
| my %link_languages = (); |
| |
| # maps extensions to needed source flags. |
| my %sourceflags = (); |
| |
| # List of targets we must always output. |
| # FIXME: Complete, and remove falsely required targets. |
| my %required_targets = |
| ( |
| 'all' => 1, |
| 'dvi' => 1, |
| 'pdf' => 1, |
| 'ps' => 1, |
| 'info' => 1, |
| 'install-info' => 1, |
| 'install' => 1, |
| 'install-data' => 1, |
| 'install-exec' => 1, |
| 'uninstall' => 1, |
| |
| # FIXME: Not required, temporary hacks. |
| # Well, actually they are sort of required: the -recursive |
| # targets will run them anyway... |
| 'html-am' => 1, |
| 'dvi-am' => 1, |
| 'pdf-am' => 1, |
| 'ps-am' => 1, |
| 'info-am' => 1, |
| 'install-data-am' => 1, |
| 'install-exec-am' => 1, |
| 'install-html-am' => 1, |
| 'install-dvi-am' => 1, |
| 'install-pdf-am' => 1, |
| 'install-ps-am' => 1, |
| 'install-info-am' => 1, |
| 'installcheck-am' => 1, |
| 'uninstall-am' => 1, |
| 'tags-am' => 1, |
| 'ctags-am' => 1, |
| 'cscopelist-am' => 1, |
| 'install-man' => 1, |
| ); |
| |
| # The name of the Makefile currently being processed. |
| my $am_file = 'BUG'; |
| |
| ################################################################ |
| |
| ## ------------------------------------------ ## |
| ## Variables reset by &initialize_per_input. ## |
| ## ------------------------------------------ ## |
| |
| # Relative dir of the output makefile. |
| my $relative_dir; |
| |
| # Greatest timestamp of the output's dependencies (excluding |
| # configure's dependencies). |
| my $output_deps_greatest_timestamp; |
| |
| # These variables are used when generating each Makefile.in. |
| # They hold the Makefile.in until it is ready to be printed. |
| my $output_vars; |
| my $output_verbatim; |
| my $output_rules; |
| my $output_trailer; |
| |
| # This is the conditional stack, updated on if/else/endif, and |
| # used to build Condition objects. |
| my @cond_stack; |
| |
| # This holds the set of included files. |
| my @include_stack; |
| |
| # List of dependencies for the obvious targets. |
| my @all; |
| my @check; |
| |
| # Keys in this hash table are files and directories to delete. The |
| # associated value tells when this should happen (MOSTLY_CLEAN, |
| # DIST_CLEAN, etc). |
| my (%clean_files, %clean_dirs); |
| |
| # Value of $(SOURCES), used by tags.am. |
| my @sources; |
| # Sources which go in the distribution. |
| my @dist_sources; |
| |
| # This hash maps object file names onto their corresponding source |
| # file names. This is used to ensure that each object is created |
| # by a single source file. |
| my %object_map; |
| |
| # This hash maps object file names onto an integer value representing |
| # whether this object has been built via ordinary compilation or |
| # libtool compilation (the COMPILE_* constants). |
| my %object_compilation_map; |
| |
| # All .P files. |
| my %dep_files; |
| |
| # This is a list of all targets to run during "make dist". |
| my @dist_targets; |
| |
| # Keep track of all programs and libraries declared in this Makefile, |
| # without $(EXEEXT). @substitutions@ are not listed. |
| my %known_programs; |
| my %known_libraries; |
| my %known_ltlibraries; |
| |
| # This keeps track of which extensions we've seen (that we care |
| # about). |
| my %extension_seen; |
| |
| # This is random scratch space for the language finish functions. |
| # Don't randomly overwrite it; examine other uses of keys first. |
| my %language_scratch; |
| |
| # We keep track of which objects need special (per-executable) |
| # handling on a per-language basis. |
| my %lang_specific_files; |
| |
| # This is set when 'handle_dist' has finished. Once this happens, |
| # we should no longer push on dist_common. |
| my $handle_dist_run; |
| |
| # Used to store a set of linkers needed to generate the sources currently |
| # under consideration. |
| my %linkers_used; |
| |
| # True if we need 'LINK' defined. This is a hack. |
| my $need_link; |
| |
| # Does the generated Makefile have to build some compiled object |
| # (for binary programs, or plain or libtool libraries)? |
| my $must_handle_compiled_objects; |
| |
| # Record each file processed by make_paragraphs. |
| my %transformed_files; |
| |
| ################################################################ |
| |
| ## ---------------------------------------------- ## |
| ## Variables not reset by &initialize_per_input. ## |
| ## ---------------------------------------------- ## |
| |
| # Cache each file processed by make_paragraphs. |
| # (This is different from %transformed_files because |
| # %transformed_files is reset for each file while %am_file_cache |
| # it global to the run.) |
| my %am_file_cache; |
| |
| ################################################################ |
| |
| ## --------------------------------- ## |
| ## Forward subroutine declarations. ## |
| ## --------------------------------- ## |
| sub register_language (%); |
| sub file_contents_internal ($$$%); |
| sub define_files_variable ($\@$$); |
| |
| |
| # &initialize_per_input () |
| # ------------------------ |
| # (Re)-Initialize per-Makefile.am variables. |
| sub initialize_per_input () |
| { |
| reset_local_duplicates (); |
| |
| $relative_dir = undef; |
| |
| $output_deps_greatest_timestamp = 0; |
| |
| $output_vars = ''; |
| $output_verbatim = ''; |
| $output_rules = ''; |
| $output_trailer = ''; |
| |
| @dist_common = (); |
| |
| Automake::Options::reset; |
| Automake::Variable::reset; |
| Automake::Rule::reset; |
| |
| @cond_stack = (); |
| |
| @include_stack = (); |
| |
| @all = (); |
| @check = (); |
| |
| %clean_files = (); |
| %clean_dirs = (); |
| |
| @sources = (); |
| @dist_sources = (); |
| |
| %object_map = (); |
| %object_compilation_map = (); |
| |
| %dep_files = (); |
| |
| @dist_targets = (); |
| |
| %known_programs = (); |
| %known_libraries= (); |
| %known_ltlibraries= (); |
| |
| %extension_seen = (); |
| |
| %language_scratch = (); |
| |
| %lang_specific_files = (); |
| |
| $handle_dist_run = 0; |
| |
| $need_link = 0; |
| |
| $must_handle_compiled_objects = 0; |
| |
| %transformed_files = (); |
| } |
| |
| |
| ################################################################ |
| |
| # Initialize our list of languages that are internally supported. |
| |
| # C. |
| register_language ('name' => 'c', |
| 'Name' => 'C', |
| 'config_vars' => ['CC'], |
| 'autodep' => '', |
| 'flags' => ['CFLAGS', 'CPPFLAGS'], |
| 'ccer' => 'CC', |
| 'compiler' => 'COMPILE', |
| 'compile' => '$(CC) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', |
| 'lder' => 'CCLD', |
| 'ld' => '$(CC)', |
| 'linker' => 'LINK', |
| 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'compile_flag' => '-c', |
| 'libtool_tag' => 'CC', |
| 'extensions' => ['.c']); |
| |
| # C++. |
| register_language ('name' => 'cxx', |
| 'Name' => 'C++', |
| 'config_vars' => ['CXX'], |
| 'linker' => 'CXXLINK', |
| 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'autodep' => 'CXX', |
| 'flags' => ['CXXFLAGS', 'CPPFLAGS'], |
| 'compile' => '$(CXX) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)', |
| 'ccer' => 'CXX', |
| 'compiler' => 'CXXCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'CXX', |
| 'lder' => 'CXXLD', |
| 'ld' => '$(CXX)', |
| 'pure' => 1, |
| 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']); |
| |
| # Objective C. |
| register_language ('name' => 'objc', |
| 'Name' => 'Objective C', |
| 'config_vars' => ['OBJC'], |
| 'linker' => 'OBJCLINK', |
| 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'autodep' => 'OBJC', |
| 'flags' => ['OBJCFLAGS', 'CPPFLAGS'], |
| 'compile' => '$(OBJC) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)', |
| 'ccer' => 'OBJC', |
| 'compiler' => 'OBJCCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'lder' => 'OBJCLD', |
| 'ld' => '$(OBJC)', |
| 'pure' => 1, |
| 'extensions' => ['.m']); |
| |
| # Objective C++. |
| register_language ('name' => 'objcxx', |
| 'Name' => 'Objective C++', |
| 'config_vars' => ['OBJCXX'], |
| 'linker' => 'OBJCXXLINK', |
| 'link' => '$(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'autodep' => 'OBJCXX', |
| 'flags' => ['OBJCXXFLAGS', 'CPPFLAGS'], |
| 'compile' => '$(OBJCXX) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS)', |
| 'ccer' => 'OBJCXX', |
| 'compiler' => 'OBJCXXCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'lder' => 'OBJCXXLD', |
| 'ld' => '$(OBJCXX)', |
| 'pure' => 1, |
| 'extensions' => ['.mm']); |
| |
| # Unified Parallel C. |
| register_language ('name' => 'upc', |
| 'Name' => 'Unified Parallel C', |
| 'config_vars' => ['UPC'], |
| 'linker' => 'UPCLINK', |
| 'link' => '$(UPCLD) $(AM_UPCFLAGS) $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'autodep' => 'UPC', |
| 'flags' => ['UPCFLAGS', 'CPPFLAGS'], |
| 'compile' => '$(UPC) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_UPCFLAGS) $(UPCFLAGS)', |
| 'ccer' => 'UPC', |
| 'compiler' => 'UPCCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'lder' => 'UPCLD', |
| 'ld' => '$(UPC)', |
| 'pure' => 1, |
| 'extensions' => ['.upc']); |
| |
| # Headers. |
| register_language ('name' => 'header', |
| 'Name' => 'Header', |
| 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh', |
| '.hpp', '.inc'], |
| # No output. |
| 'output_extensions' => sub { return () }, |
| # Nothing to do. |
| '_finish' => sub { }); |
| |
| # Vala. |
| register_language ('name' => 'vala', |
| 'Name' => 'Vala', |
| 'config_vars' => ['VALAC'], |
| 'flags' => [], |
| 'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)', |
| 'ccer' => 'VALAC', |
| 'compiler' => 'VALACOMPILE', |
| 'extensions' => ['.vala', '.vapi'], |
| # Vala compilation must be handled in a special way, so |
| # nothing to do or return here. |
| 'output_extensions' => sub { }, |
| 'rule_file' => 'vala', |
| '_finish' => \&lang_vala_finish, |
| '_target_hook' => \&lang_vala_target_hook, |
| 'nodist_specific' => 1); |
| |
| # Yacc (C & C++). |
| register_language ('name' => 'yacc', |
| 'Name' => 'Yacc', |
| 'config_vars' => ['YACC'], |
| 'flags' => ['YFLAGS'], |
| 'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)', |
| 'ccer' => 'YACC', |
| 'compiler' => 'YACCCOMPILE', |
| 'extensions' => ['.y'], |
| 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/; |
| return ($ext,) }, |
| 'rule_file' => 'yacc', |
| '_finish' => \&lang_yacc_lex_finish, |
| '_target_hook' => \&lang_yacc_target_hook, |
| 'nodist_specific' => 1); |
| register_language ('name' => 'yaccxx', |
| 'Name' => 'Yacc (C++)', |
| 'config_vars' => ['YACC'], |
| 'rule_file' => 'yacc', |
| 'flags' => ['YFLAGS'], |
| 'ccer' => 'YACC', |
| 'compiler' => 'YACCCOMPILE', |
| 'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)', |
| 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'], |
| 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/; |
| return ($ext,) }, |
| '_finish' => \&lang_yacc_lex_finish, |
| '_target_hook' => \&lang_yacc_target_hook, |
| 'nodist_specific' => 1); |
| |
| # Lex (C & C++). |
| register_language ('name' => 'lex', |
| 'Name' => 'Lex', |
| 'config_vars' => ['LEX'], |
| 'rule_file' => 'lex', |
| 'flags' => ['LFLAGS'], |
| 'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)', |
| 'ccer' => 'LEX', |
| 'compiler' => 'LEXCOMPILE', |
| 'extensions' => ['.l'], |
| 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/; |
| return ($ext,) }, |
| '_finish' => \&lang_yacc_lex_finish, |
| '_target_hook' => \&lang_lex_target_hook, |
| 'nodist_specific' => 1); |
| register_language ('name' => 'lexxx', |
| 'Name' => 'Lex (C++)', |
| 'config_vars' => ['LEX'], |
| 'rule_file' => 'lex', |
| 'flags' => ['LFLAGS'], |
| 'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)', |
| 'ccer' => 'LEX', |
| 'compiler' => 'LEXCOMPILE', |
| 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'], |
| 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/; |
| return ($ext,) }, |
| '_finish' => \&lang_yacc_lex_finish, |
| '_target_hook' => \&lang_lex_target_hook, |
| 'nodist_specific' => 1); |
| |
| # Assembler. |
| register_language ('name' => 'asm', |
| 'Name' => 'Assembler', |
| 'config_vars' => ['CCAS', 'CCASFLAGS'], |
| |
| 'flags' => ['CCASFLAGS'], |
| # Users can set AM_CCASFLAGS to include, say, DEFS, |
| # or anything else required. They can also set CCAS. |
| # Or simply use Preprocessed Assembler. |
| 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)', |
| 'ccer' => 'CCAS', |
| 'compiler' => 'CCASCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'extensions' => ['.s']); |
| |
| # Preprocessed Assembler. |
| register_language ('name' => 'cppasm', |
| 'Name' => 'Preprocessed Assembler', |
| 'config_vars' => ['CCAS', 'CCASFLAGS'], |
| |
| 'autodep' => 'CCAS', |
| 'flags' => ['CCASFLAGS', 'CPPFLAGS'], |
| 'compile' => '$(CCAS) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)', |
| 'ccer' => 'CPPAS', |
| 'compiler' => 'CPPASCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'extensions' => ['.S', '.sx']); |
| |
| # Fortran 77 |
| register_language ('name' => 'f77', |
| 'Name' => 'Fortran 77', |
| 'config_vars' => ['F77'], |
| 'linker' => 'F77LINK', |
| 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'flags' => ['FFLAGS'], |
| 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)', |
| 'ccer' => 'F77', |
| 'compiler' => 'F77COMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'F77', |
| 'lder' => 'F77LD', |
| 'ld' => '$(F77)', |
| 'pure' => 1, |
| 'extensions' => ['.f', '.for']); |
| |
| # Fortran |
| register_language ('name' => 'fc', |
| 'Name' => 'Fortran', |
| 'config_vars' => ['FC'], |
| 'linker' => 'FCLINK', |
| 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'flags' => ['FCFLAGS'], |
| 'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)', |
| 'ccer' => 'FC', |
| 'compiler' => 'FCCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'FC', |
| 'lder' => 'FCLD', |
| 'ld' => '$(FC)', |
| 'pure' => 1, |
| 'extensions' => ['.f90', '.f95', '.f03', '.f08']); |
| |
| # Preprocessed Fortran |
| register_language ('name' => 'ppfc', |
| 'Name' => 'Preprocessed Fortran', |
| 'config_vars' => ['FC'], |
| 'linker' => 'FCLINK', |
| 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'lder' => 'FCLD', |
| 'ld' => '$(FC)', |
| 'flags' => ['FCFLAGS', 'CPPFLAGS'], |
| 'ccer' => 'PPFC', |
| 'compiler' => 'PPFCCOMPILE', |
| 'compile' => '$(FC) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'FC', |
| 'pure' => 1, |
| 'extensions' => ['.F90','.F95', '.F03', '.F08']); |
| |
| # Preprocessed Fortran 77 |
| # |
| # The current support for preprocessing Fortran 77 just involves |
| # passing "$(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)" |
| # as additional flags to the Fortran 77 compiler, since this is how |
| # GNU Make does it; see the "GNU Make Manual, Edition 0.51 for 'make' |
| # Version 3.76 Beta" (specifically, from info file '(make)Catalogue |
| # of Rules'). |
| # |
| # A better approach would be to write an Autoconf test |
| # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all |
| # Fortran 77 compilers know how to do preprocessing. The Autoconf |
| # macro AC_PROG_FPP should test the Fortran 77 compiler first for |
| # preprocessing capabilities, and then fall back on cpp (if cpp were |
| # available). |
| register_language ('name' => 'ppf77', |
| 'Name' => 'Preprocessed Fortran 77', |
| 'config_vars' => ['F77'], |
| 'linker' => 'F77LINK', |
| 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'lder' => 'F77LD', |
| 'ld' => '$(F77)', |
| 'flags' => ['FFLAGS', 'CPPFLAGS'], |
| 'ccer' => 'PPF77', |
| 'compiler' => 'PPF77COMPILE', |
| 'compile' => '$(F77) $(DEFS) $(AM_DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'F77', |
| 'pure' => 1, |
| 'extensions' => ['.F']); |
| |
| # Ratfor. |
| register_language ('name' => 'ratfor', |
| 'Name' => 'Ratfor', |
| 'config_vars' => ['F77'], |
| 'linker' => 'F77LINK', |
| 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'lder' => 'F77LD', |
| 'ld' => '$(F77)', |
| 'flags' => ['RFLAGS', 'FFLAGS'], |
| # FIXME also FFLAGS. |
| 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)', |
| 'ccer' => 'F77', |
| 'compiler' => 'RCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'F77', |
| 'pure' => 1, |
| 'extensions' => ['.r']); |
| |
| # Java via gcj. |
| register_language ('name' => 'java', |
| 'Name' => 'Java', |
| 'config_vars' => ['GCJ'], |
| 'linker' => 'GCJLINK', |
| 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', |
| 'autodep' => 'GCJ', |
| 'flags' => ['GCJFLAGS'], |
| 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)', |
| 'ccer' => 'GCJ', |
| 'compiler' => 'GCJCOMPILE', |
| 'compile_flag' => '-c', |
| 'output_flag' => '-o', |
| 'libtool_tag' => 'GCJ', |
| 'lder' => 'GCJLD', |
| 'ld' => '$(GCJ)', |
| 'pure' => 1, |
| 'extensions' => ['.java', '.class', '.zip', '.jar']); |
| |
| ################################################################ |
| |
| # Error reporting functions. |
| |
| # err_am ($MESSAGE, [%OPTIONS]) |
| # ----------------------------- |
| # Uncategorized errors about the current Makefile.am. |
| sub err_am ($;%) |
| { |
| msg_am ('error', @_); |
| } |
| |
| # err_ac ($MESSAGE, [%OPTIONS]) |
| # ----------------------------- |
| # Uncategorized errors about configure.ac. |
| sub err_ac ($;%) |
| { |
| msg_ac ('error', @_); |
| } |
| |
| # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS]) |
| # --------------------------------------- |
| # Messages about about the current Makefile.am. |
| sub msg_am ($$;%) |
| { |
| my ($channel, $msg, %opts) = @_; |
| msg $channel, "${am_file}.am", $msg, %opts; |
| } |
| |
| # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS]) |
| # --------------------------------------- |
| # Messages about about configure.ac. |
| sub msg_ac ($$;%) |
| { |
| my ($channel, $msg, %opts) = @_; |
| msg $channel, $configure_ac, $msg, %opts; |
| } |
| |
| ################################################################ |
| |
| # subst ($TEXT) |
| # ------------- |
| # Return a configure-style substitution using the indicated text. |
| # We do this to avoid having the substitutions directly in automake.in; |
| # when we do that they are sometimes removed and this causes confusion |
| # and bugs. |
| sub subst ($) |
| { |
| my ($text) = @_; |
| return '@' . $text . '@'; |
| } |
| |
| ################################################################ |
| |
| |
| # $BACKPATH |
| # &backname ($RELDIR) |
| # -------------------- |
| # If I "cd $RELDIR", then to come back, I should "cd $BACKPATH". |
| # For instance 'src/foo' => '../..'. |
| # Works with non strictly increasing paths, i.e., 'src/../lib' => '..'. |
| sub backname ($) |
| { |
| my ($file) = @_; |
| my @res; |
| foreach (split (/\//, $file)) |
| { |
| next if $_ eq '.' || $_ eq ''; |
| if ($_ eq '..') |
| { |
| pop @res |
| or prog_error ("trying to reverse path '$file' pointing outside tree"); |
| } |
| else |
| { |
| push (@res, '..'); |
| } |
| } |
| return join ('/', @res) || '.'; |
| } |
| |
| ################################################################ |
| |
| # Silent rules handling functions. |
| |
| # verbose_var (NAME) |
| # ------------------ |
| # The public variable stem used to implement silent rules. |
| sub verbose_var ($) |
| { |
| my ($name) = @_; |
| return 'AM_V_' . $name; |
| } |
| |
| # define_verbose_var (NAME, VAL-IF-SILENT, [VAL-IF-VERBOSE]) |
| # ---------------------------------------------------------- |
| # For silent rules, setup VAR and dispatcher, to expand to |
| # VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to |
| # empty) if not. |
| sub define_verbose_var ($$;$) |
| { |
| my ($name, $silent_val, $verbose_val) = @_; |
| $verbose_val = '' unless defined $verbose_val; |
| my $var = verbose_var ($name); |
| define_variable ($var, INTERNAL, "\$($var/\$V)"); |
| Automake::Variable::define ("$var/0", VAR_AUTOMAKE, '', TRUE, |
| $silent_val, '', INTERNAL) |
| if (! vardef ("$var/0", TRUE)); |
| Automake::Variable::define ("$var/1", VAR_AUTOMAKE, '', TRUE, |
| $verbose_val, '', INTERNAL) |
| if (! vardef ("$var/1", TRUE)); |
| } |
| |
| # Above should not be needed in the general automake code. |
| |
| # verbose_flag (NAME) |
| # ------------------- |
| # Contents of %VERBOSE%: variable to expand before rule command. |
| sub verbose_flag ($) |
| { |
| my ($name) = @_; |
| return '$(' . verbose_var ($name) . ')'; |
| } |
| |
| sub verbose_nodep_flag ($) |
| { |
| my ($name) = @_; |
| return '$(' . verbose_var ($name) . subst ('am__nodep') . ')'; |
| } |
| |
| # silent_flag |
| # ----------- |
| # Contents of %SILENT%: variable to expand to '@' when silent. |
| sub silent_flag () |
| { |
| return verbose_flag ('at'); |
| } |
| |
| # define_verbose_tagvar (NAME) |
| # ---------------------------- |
| # Engage the needed silent rules machinery for tag NAME. |
| sub define_verbose_tagvar ($) |
| { |
| my ($name) = @_; |
| define_verbose_var ($name, '@echo " '. $name . ' ' x (8 - length ($name)) . '" $@;'); |
| } |
| |
| # define_verbose_texinfo |
| # ---------------------- |
| # Engage the needed silent rules machinery for assorted texinfo commands. |
| sub define_verbose_texinfo () |
| { |
| my @tagvars = ('DVIPS', 'MAKEINFO', 'INFOHTML', 'TEXI2DVI', 'TEXI2PDF'); |
| foreach my $tag (@tagvars) |
| { |
| define_verbose_tagvar($tag); |
| } |
| define_verbose_var('TEXI_QUIETOPTS', '-q'); |
| define_verbose_var('TEXI_DEVNULL_REDIRECT', '> /dev/null'); |
| } |
| |
| # define_verbose_libtool |
| # ---------------------- |
| # Engage the needed silent rules machinery for 'libtool --silent'. |
| sub define_verbose_libtool () |
| { |
| define_verbose_var ('lt', '--silent'); |
| return verbose_flag ('lt'); |
| } |
| |
| sub handle_silent () |
| { |
| # Define "$(AM_V_P)", expanding to a shell conditional that can be |
| # used in make recipes to determine whether we are being run in |
| # silent mode or not. The choice of the name derives from the LISP |
| # convention of appending the letter 'P' to denote a predicate (see |
| # also "the '-P' convention" in the Jargon File); we do so for lack |
| # of a better convention. |
| define_verbose_var ('P', 'false', ':'); |
| # *Always* provide the user with '$(AM_V_GEN)', unconditionally. |
| define_verbose_tagvar ('GEN'); |
| define_verbose_var ('at', '@'); |
| } |
| |
| |
| ################################################################ |
| |
| |
| # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise. |
| sub handle_options |
| { |
| my $var = var ('AUTOMAKE_OPTIONS'); |
| if ($var) |
| { |
| if ($var->has_conditional_contents) |
| { |
| msg_var ('unsupported', $var, |
| "'AUTOMAKE_OPTIONS' cannot have conditional contents"); |
| } |
| my @options = map { { option => $_->[1], where => $_->[0] } } |
| $var->value_as_list_recursive (cond_filter => TRUE, |
| location => 1); |
| return 1 if process_option_list (@options); |
| } |
| |
| if ($strictness == GNITS) |
| { |
| set_option ('readme-alpha', INTERNAL); |
| set_option ('std-options', INTERNAL); |
| set_option ('check-news', INTERNAL); |
| } |
| |
| return 0; |
| } |
| |
| # shadow_unconditionally ($varname, $where) |
| # ----------------------------------------- |
| # Return a $(variable) that contains all possible values |
| # $varname can take. |
| # If the VAR wasn't defined conditionally, return $(VAR). |
| # Otherwise we create an am__VAR_DIST variable which contains |
| # all possible values, and return $(am__VAR_DIST). |
| sub shadow_unconditionally ($$) |
| { |
| my ($varname, $where) = @_; |
| my $var = var $varname; |
| if ($var->has_conditional_contents) |
| { |
| $varname = "am__${varname}_DIST"; |
| my @files = uniq ($var->value_as_list_recursive); |
| define_variable ($varname, $where, @files); |
| } |
| return "\$($varname)" |
| } |
| |
| # check_user_variables (@LIST) |
| # ---------------------------- |
| # Make sure each variable VAR in @LIST does not exist, suggest using AM_VAR |
| # otherwise. |
| sub check_user_variables (@) |
| { |
| my @dont_override = @_; |
| foreach my $flag (@dont_override) |
| { |
| my $var = var $flag; |
| if ($var) |
| { |
| for my $cond ($var->conditions->conds) |
| { |
| if ($var->rdef ($cond)->owner == VAR_MAKEFILE) |
| { |
| msg_cond_var ('gnu', $cond, $flag, |
| "'$flag' is a user variable, " |
| . "you should not override it;\n" |
| . "use 'AM_$flag' instead"); |
| } |
| } |
| } |
| } |
| } |
| |
| # Call finish function for each language that was used. |
| sub handle_languages |
| { |
| if (! option 'no-dependencies') |
| { |
| # Include auto-dep code. Don't include it if DEP_FILES would |
| # be empty. |
| if (keys %extension_seen && keys %dep_files) |
| { |
| # Set location of depcomp. |
| define_variable ('depcomp', INTERNAL, |
| '$(SHELL) $(am.conf.aux-dir)/depcomp'); |
| |
| require_conf_file ("$am_file.am", FOREIGN, 'depcomp'); |
| |
| my @deplist = sort keys %dep_files; |
| # Generate each 'include' individually. Irix 6 make will |
| # not properly include several files resulting from a |
| # variable expansion; generating many separate includes |
| # seems safest. |
| $output_rules .= "\n"; |
| foreach my $depfile (@deplist) |
| { |
| $output_rules .= subst ('AMDEP_TRUE') . "-include $depfile\n"; |
| $clean_dirs{dirname ($depfile)} = DIST_CLEAN; |
| } |
| } |
| } |
| else |
| { |
| define_variable ('depcomp', INTERNAL, ''); |
| } |
| |
| my %done; |
| |
| # Is the C linker needed? |
| my $needs_c = 0; |
| foreach my $ext (sort keys %extension_seen) |
| { |
| next unless $extension_map{$ext}; |
| |
| my $lang = $languages{$extension_map{$ext}}; |
| |
| my $rule_file = $lang->rule_file || 'depend2'; |
| |
| # Get information on $LANG. |
| my $pfx = $lang->autodep; |
| my $fpfx = ($pfx eq '') ? 'CC' : $pfx; |
| |
| my ($AMDEP, $FASTDEP) = |
| (option 'no-dependencies' || $lang->autodep eq 'no') |
| ? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx"); |
| |
| my $verbose = verbose_flag ($lang->ccer || 'GEN'); |
| my $verbose_nodep = ($AMDEP eq 'FALSE') |
| ? $verbose : verbose_nodep_flag ($lang->ccer || 'GEN'); |
| |
| my %transform = ('EXT' => $ext, |
| 'PFX' => $pfx, |
| 'FPFX' => $fpfx, |
| 'AMDEP' => $AMDEP, |
| 'FASTDEP' => $FASTDEP, |
| '-c' => $lang->compile_flag || '', |
| # These are not used, but they need to be defined |
| # so &transform do not complain. |
| 'DERIVED-EXT' => 'BUG', |
| DIST_SOURCE => 1, |
| VERBOSE => $verbose, |
| 'VERBOSE-NODEP' => $verbose_nodep, |
| ); |
| |
| # Generate the appropriate rules for this extension. |
| if (((! option 'no-dependencies') && $lang->autodep ne 'no') |
| || defined $lang->compile) |
| { |
| # Some C compilers don't support -c -o. Use it only if really |
| # needed. |
| my $output_flag = $lang->output_flag || ''; |
| $output_flag = '-o' |
| if (! $output_flag && $lang->name eq 'c'); |
| |
| # Compute a possible derived extension. |
| # This is not used by depend2.am. |
| my $der_ext = (&{$lang->output_extensions} ($ext))[0]; |
| |
| $output_rules .= |
| file_contents ($rule_file, |
| new Automake::Location, |
| %transform, |
| GENERIC => 1, |
| |
| 'DERIVED-EXT' => $der_ext, |
| |
| BASE => '$*', |
| SOURCE => '$<', |
| SOURCEFLAG => $sourceflags{$ext} || '', |
| OBJ => '$@', |
| LTOBJ => '$@', |
| |
| COMPILE => '$(' . $lang->compiler . ')', |
| LTCOMPILE => '$(LT' . $lang->compiler . ')', |
| -o => $output_flag); |
| } |
| |
| # Now include code for each specially handled object with this |
| # language. |
| my %seen_files = (); |
| foreach my $file (@{$lang_specific_files{$lang->name}}) |
| { |
| my ($derived, $source, $obj, $myext, $srcext, %file_transform) = @$file; |
| |
| # We might see a given object twice, for instance if it is |
| # used under different conditions. |
| next if defined $seen_files{$obj}; |
| $seen_files{$obj} = 1; |
| |
| prog_error ("found " . $lang->name . |
| " in handle_languages, but compiler not defined") |
| unless defined $lang->compile; |
| |
| my $obj_compile = $lang->compile; |
| |
| # Rewrite each occurrence of 'AM_$flag' in the compile |
| # rule into '${derived}_$flag' if it exists. |
| for my $flag (@{$lang->flags}) |
| { |
| my $val = "${derived}_$flag"; |
| $obj_compile =~ s/\(AM_$flag\)/\($val\)/ |
| if set_seen ($val); |
| } |
| |
| my $libtool_tag = ''; |
| if ($lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag}) |
| { |
| $libtool_tag = '--tag=' . $lang->libtool_tag . ' ' |
| } |
| |
| my $ptltflags = "${derived}_LIBTOOLFLAGS"; |
| $ptltflags = 'AM_LIBTOOLFLAGS' unless set_seen $ptltflags; |
| |
| my $ltverbose = define_verbose_libtool (); |
| my $obj_ltcompile = |
| "\$(LIBTOOL) $ltverbose $libtool_tag\$($ptltflags) \$(LIBTOOLFLAGS) " |
| . "--mode=compile $obj_compile"; |
| |
| # We _need_ '-o' for per object rules. |
| my $output_flag = $lang->output_flag || '-o'; |
| |
| $output_rules .= |
| file_contents ($rule_file, |
| new Automake::Location, |
| %transform, |
| GENERIC => 0, |
| |
| BASE => $obj, |
| SOURCE => $source, |
| SOURCEFLAG => $sourceflags{$srcext} || '', |
| # Use $myext and not '.o' here, in case |
| # we are actually building a new source |
| # file -- e.g. via yacc. |
| OBJ => "$obj$myext", |
| LTOBJ => "$obj.lo", |
| |
| VERBOSE => $verbose, |
| 'VERBOSE-NODEP' => $verbose_nodep, |
| COMPILE => $obj_compile, |
| LTCOMPILE => $obj_ltcompile, |
| -o => $output_flag, |
| %file_transform); |
| } |
| |
| # The rest of the loop is done once per language. |
| next if defined $done{$lang}; |
| $done{$lang} = 1; |
| |
| # Load the language dependent Makefile chunks. |
| my %lang = map { uc ($_) => 0 } keys %languages; |
| $lang{uc ($lang->name)} = 1; |
| $output_rules .= file_contents ('lang-compile', |
| new Automake::Location, |
| %transform, %lang); |
| |
| # If the source to a program consists entirely of code from a |
| # 'pure' language, for instance C++ or Fortran 77, then we |
| # don't need the C compiler code. However if we run into |
| # something unusual then we do generate the C code. There are |
| # probably corner cases here that do not work properly. |
| # People linking Java code to Fortran code deserve pain. |
| $needs_c ||= ! $lang->pure; |
| |
| define_compiler_variable ($lang) |
| if ($lang->compile); |
| |
| define_linker_variable ($lang) |
| if ($lang->link); |
| |
| require_variables ("$am_file.am", $lang->Name . " source seen", |
| TRUE, @{$lang->config_vars}); |
| |
| # Call the finisher. |
| $lang->finish; |
| |
| # Flags listed in '->flags' are user variables (per GNU Standards), |
| # they should not be overridden in the Makefile... |
| my @dont_override = @{$lang->flags}; |
| # ... and so is LDFLAGS. |
| push @dont_override, 'LDFLAGS' if $lang->link; |
| |
| check_user_variables @dont_override; |
| } |
| |
| # Non-pure languages, or languages lacking a linker of their own. |
| if ($needs_c || $need_link) |
| { |
| &define_compiler_variable ($languages{'c'}) |
| unless defined $done{$languages{'c'}}; |
| define_linker_variable ($languages{'c'}); |
| } |
| } |
| |
| |
| # append_exeext { PREDICATE } $MACRO |
| # ---------------------------------- |
| # Append $(EXEEXT) to each filename in $F appearing in the Makefile |
| # variable $MACRO if &PREDICATE($F) is true. @substitutions@ are |
| # ignored. |
| # |
| # This is typically used on all filenames of *_PROGRAMS, and filenames |
| # of TESTS that are programs. |
| sub append_exeext (&$) |
| { |
| my ($pred, $macro) = @_; |
| |
| transform_variable_recursively |
| ($macro, $macro, 'am__EXEEXT', 0, INTERNAL, |
| sub { |
| my ($subvar, $val, $cond, $full_cond) = @_; |
| # Append $(EXEEXT) unless the user did it already, or it's a |
| # @substitution@. |
| $val .= '$(EXEEXT)' |
| if $val !~ /(?:\$\(EXEEXT\)$|^[@]\w+[@]$)/ && &$pred ($val); |
| return $val; |
| }); |
| } |
| |
| |
| # Check to make sure a source defined in LIBOBJS is not explicitly |
| # mentioned. This is a separate function (as opposed to being inlined |
| # in handle_source_transform) because it isn't always appropriate to |
| # do this check. |
| sub check_libobjs_sources |
| { |
| my ($one_file, $unxformed) = @_; |
| |
| foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_', |
| 'dist_EXTRA_', 'nodist_EXTRA_') |
| { |
| my @files; |
| my $varname = $prefix . $one_file . '_SOURCES'; |
| my $var = var ($varname); |
| if ($var) |
| { |
| @files = $var->value_as_list_recursive; |
| } |
| elsif ($prefix eq '') |
| { |
| @files = ($unxformed . '.c'); |
| } |
| else |
| { |
| next; |
| } |
| |
| foreach my $file (@files) |
| { |
| err_var ($prefix . $one_file . '_SOURCES', |
| "automatically discovered file '$file' should not" . |
| " be explicitly mentioned") |
| if defined $libsources{$file}; |
| } |
| } |
| } |
| |
| |
| # @OBJECTS |
| # handle_single_transform ($VAR, $TOPPARENT, $DERIVED, $OBJ, $FILE, %TRANSFORM) |
| # ----------------------------------------------------------------------------- |
| # Does much of the actual work for handle_source_transform. |
| # Arguments are: |
| # $VAR is the name of the variable that the source filenames come from |
| # $TOPPARENT is the name of the _SOURCES variable which is being processed |
| # $DERIVED is the name of resulting executable or library |
| # $OBJ is the object extension (e.g., '.lo') |
| # $FILE the source file to transform |
| # %TRANSFORM contains extras arguments to pass to file_contents |
| # when producing explicit rules |
| # Result is a list of the names of objects |
| # %linkers_used will be updated with any linkers needed |
| sub handle_single_transform ($$$$$%) |
| { |
| my ($var, $topparent, $derived, $obj, $_file, %transform) = @_; |
| my @files = ($_file); |
| my @result = (); |
| |
| # Turn sources into objects. We use a while loop like this |
| # because we might add to @files in the loop. |
| while (scalar @files > 0) |
| { |
| $_ = shift @files; |
| |
| # Configure substitutions in _SOURCES variables are errors. |
| if (/^\@.*\@$/) |
| { |
| my $parent_msg = ''; |
| $parent_msg = "\nand is referred to from '$topparent'" |
| if $topparent ne $var->name; |
| err_var ($var, |
| "'" . $var->name . "' includes configure substitution '$_'" |
| . $parent_msg . ";\nconfigure " . |
| "substitutions are not allowed in _SOURCES variables"); |
| next; |
| } |
| |
| # Split file name into base and extension. |
| next if ! /^(?:(.*)\/)?([^\/]*?)(\.[^.]+)$/; |
| prog_error ("source file '$_' missing dotted extension") |
| unless defined $2 and defined $3; |
| my $full = $_; |
| my $directory = $1 || ''; |
| my $base = $2; |
| my $extension = $3; |
| |
| # We must generate a rule for the object if it requires its own flags. |
| my $renamed = 0; |
| my ($linker, $object); |
| |
| # This records whether we've seen a derived source file (e.g. |
| # yacc output). |
| my $derived_source = 0; |
| |
| # This holds the 'aggregate context' of the file we are |
| # currently examining. If the file is compiled with |
| # per-object flags, then it will be the name of the object. |
| # Otherwise it will be 'AM'. This is used by the target hook |
| # language function. |
| my $aggregate = 'AM'; |
| |
| my $lang; |
| if ($extension_map{$extension} && |
| ($lang = $languages{$extension_map{$extension}})) |
| { |
| # Found the language, so see what it says. |
| &saw_extension ($extension); |
| |
| # Do we have per-executable flags for this executable? |
| my $have_per_exec_flags = 0; |
| my @peflags = @{$lang->flags}; |
| push @peflags, 'LIBTOOLFLAGS' if $obj eq '.lo'; |
| foreach my $flag (@peflags) |
| { |
| if (set_seen ("${derived}_$flag")) |
| { |
| $have_per_exec_flags = 1; |
| last; |
| } |
| } |
| |
| # NOTE: computed subr calls here. |
| |
| # The language ignore function can ask not to preprocess |
| # a source file further. |
| my $subr_ignore = \&{'lang_' . $lang->name . '_ignore'}; |
| next if defined &$subr_ignore |
| and &$subr_ignore ($directory, $base, $extension); |
| # The language rewrite function can return a new source |
| # extension which should be applied. This means this |
| # particular language generates another source file which |
| # we must then process further. This happens, for example, |
| # with yacc and lex. |
| my $subr_rewrite = \&{'lang_' . $lang->name . '_rewrite'}; |
| $subr_rewrite = sub { } unless defined &$subr_rewrite; |
| my $source_extension = &$subr_rewrite ($directory, $base, |
| $extension, $obj, |
| $have_per_exec_flags, |
| $var); |
| |
| # Now extract linker and other info. |
| $linker = $lang->linker; |
| |
| my $this_obj_ext; |
| if (defined $source_extension) |
| { |
| $this_obj_ext = $source_extension; |
| $derived_source = 1; |
| } |
| else |
| { |
| $this_obj_ext = $obj; |
| } |
| $object = $base . $this_obj_ext; |
| |
| if ($have_per_exec_flags) |
| { |
| # We have a per-executable flag in effect for this |
| # object. In this case we rewrite the object's |
| # name to ensure it is unique. |
| |
| # We choose the name 'DERIVED_OBJECT' to ensure |
| # (1) uniqueness, and (2) continuity between |
| # invocations. However, this will result in a |
| # name that is too long for losing systems, in |
| # some situations. So we provide _SHORTNAME to |
| # override. |
| |
| my $dname = $derived; |
| my $var = var ($derived . '_SHORTNAME'); |
| if ($var) |
| { |
| # FIXME: should use the same Condition as |
| # the _SOURCES variable. But this is really |
| # silly overkill -- nobody should have |
| # conditional shortnames. |
| $dname = $var->variable_value; |
| } |
| $object = $dname . '-' . $object; |
| |
| prog_error ($lang->name . " flags defined without compiler") |
| if ! defined $lang->compile; |
| |
| $renamed = 1; |
| } |
| |
| # If rewrite said it was ok, put the object into a |
| # subdir. |
| $object = $directory . '/' . $object |
| unless $directory eq ''; |
| |
| # If the object file has been renamed (because per-target |
| # flags are used) we cannot compile the file with an |
| # inference rule: we need an explicit rule. |
| # |
| # If both source and object files are in a subdirectory |
| # then the inference will work. |
| # |
| if ($renamed |
| # We must also use specific rules for a nodist_ source |
| # if its language requests it. |
| || ($lang->nodist_specific && ! $transform{'DIST_SOURCE'})) |
| { |
| my $obj_sans_ext = substr ($object, 0, |
| - length ($this_obj_ext)); |
| my $full_ansi; |
| if ($directory ne '') |
| { |
| $full_ansi = $directory . '/' . $base . $extension; |
| } |
| else |
| { |
| $full_ansi = $base . $extension; |
| } |
| |
| my @specifics = ($full_ansi, $obj_sans_ext, |
| # Only use $this_obj_ext in the derived |
| # source case because in the other case we |
| # *don't* want $(OBJEXT) to appear here. |
| ($derived_source ? $this_obj_ext : '.o'), |
| $extension); |
| |
| # If we renamed the object then we want to use the |
| # per-executable flag name. But if this is simply a |
| # subdir build then we still want to use the AM_ flag |
| # name. |
| if ($renamed) |
| { |
| unshift @specifics, $derived; |
| $aggregate = $derived; |
| } |
| else |
| { |
| unshift @specifics, 'AM'; |
| } |
| |
| # Each item on this list is a reference to a list consisting |
| # of four values followed by additional transform flags for |
| # file_contents. The four values are the derived flag prefix |
| # (e.g. for 'foo_CFLAGS', it is 'foo'), the name of the |
| # source file, the base name of the output file, and |
| # the extension for the object file. |
| push (@{$lang_specific_files{$lang->name}}, |
| [@specifics, %transform]); |
| } |
| } |
| else |
| { |
| # Assume the user has defined a proper explicit or pattern |
| # rule to turn a source file with this extension in an object |
| # file with the same basename and a '.$(OBJEXT)' extension (if |
| # build as part of a program or static library) or a '.lo' |
| # extension (if built as part of a libtool library). |
| $extension = $obj; |
| # This is probably the result of a direct suffix rule. |
| # In this case we just accept the rewrite. |
| $object = "$base$extension"; |
| $object = "$directory/$object" if $directory ne ''; |
| $linker = ''; |
| } |
| |
| # FIXME: this is likely an internal error now that we use |
| # FIXME: subdir-objects unconditionally ... |
| err_am "object '$object' created by '$full' and '$object_map{$object}'" |
| if (defined $object_map{$object} |
| && $object_map{$object} ne $full); |
| |
| my $comp_val = (($object =~ /\.lo$/) |
| ? COMPILE_LIBTOOL : COMPILE_ORDINARY); |
| (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/; |
| if (defined $object_compilation_map{$comp_obj} |
| && $object_compilation_map{$comp_obj} != 0 |
| # Only see the error once. |
| && ($object_compilation_map{$comp_obj} |
| != (COMPILE_LIBTOOL | COMPILE_ORDINARY)) |
| && $object_compilation_map{$comp_obj} != $comp_val) |
| { |
| err_am "object '$comp_obj' created both with libtool and without"; |
| } |
| $object_compilation_map{$comp_obj} |= $comp_val; |
| |
| if (defined $lang) |
| { |
| # Let the language do some special magic if required. |
| $lang->target_hook ($aggregate, $object, $full, %transform); |
| } |
| |
| if ($derived_source) |
| { |
| prog_error ($lang->name . " has automatic dependency tracking") |
| if $lang->autodep ne 'no'; |
| # Make sure this new source file is handled next. That will |
| # make it appear to be at the right place in the list. |
| unshift (@files, $object); |
| # Distribute derived sources unless the source they are |
| # derived from is not. |
| push_dist_common ($object) |
| unless ($topparent =~ /^(?:nobase_)?nodist_/); |
| next; |
| } |
| |
| $linkers_used{$linker} = 1; |
| |
| push (@result, $object); |
| $directory = '.' if $directory eq ''; |
| |
| if (! defined $object_map{$object}) |
| { |
| $object_map{$object} = $full; |
| |
| # For Java, the way we're handling it right now, a |
| # '..' component doesn't make sense. |
| err_am "'$full' should not contain a '..' component" |
| if $lang && $lang->name eq 'java' && $object =~ m{(/|^)\.\./}; |
| |
| # Make sure *all* object files in this object's subdirectory |
| # are removed by "make mostlyclean". Not only this is more |
| # efficient than listing the object files to be removed |
| # individually (which would cause an 'rm' invocation for each |
| # of them -- very inefficient, see bug#10697), it would also |
| # leave stale object files in the subdirectory whenever a |
| # source file there is removed or renamed. |
| $clean_files{"$directory/*.\$(OBJEXT)"} = MOSTLY_CLEAN; |
| if ($object =~ /\.lo$/) |
| { |
| # If we have a libtool object, then we also must remove |
| # any '.lo' objects in the same subdirectory. |
| $clean_files{"$directory/*.lo"} = MOSTLY_CLEAN; |
| $clean_dirs{"$directory/.libs"} = CLEAN; |
| } |
| } |
| |
| # Transform .o or $o file into .P file (for automatic |
| # dependency code). |
| if ($lang && $lang->autodep ne 'no') |
| { |
| my $depfile = $object; |
| $depfile =~ s/\.([^.]*)$/.P$1/; |
| $depfile =~ s/\$\(OBJEXT\)$/o/; |
| $dep_files{dirname ($depfile) . '/$(DEPDIR)/' |
| . basename ($depfile)} = 1; |
| } |
| } |
| |
| return @result; |
| } |
| |
| |
| # $LINKER |
| # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE, |
| # $OBJ, $PARENT, $TOPPARENT, $WHERE, %TRANSFORM) |
| # --------------------------------------------------------------------------- |
| # Define an _OBJECTS variable for a _SOURCES variable (or subvariable) |
| # |
| # Arguments are: |
| # $VAR is the name of the _SOURCES variable |
| # $OBJVAR is the name of the _OBJECTS variable if known (otherwise |
| # it will be generated and returned). |
| # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but |
| # work done to determine the linker will be). |
| # $ONE_FILE is the canonical (transformed) name of object to build |
| # $OBJ is the object extension (i.e. either '.o' or '.lo'). |
| # $TOPPARENT is the _SOURCES variable being processed. |
| # $WHERE context into which this definition is done |
| # %TRANSFORM extra arguments to pass to file_contents when producing |
| # rules |
| # |
| # Result is a pair ($LINKER, $OBJVAR): |
| # $LINKER is a boolean, true if a linker is needed to deal with the objects |
| sub define_objects_from_sources ($$$$$$$%) |
| { |
| my ($var, $objvar, $nodefine, $one_file, |
| $obj, $topparent, $where, %transform) = @_; |
| |
| my $needlinker = ""; |
| |
| transform_variable_recursively |
| ($var, $objvar, 'am__objects', $nodefine, $where, |
| # The transform code to run on each filename. |
| sub { |
| my ($subvar, $val, $cond, $full_cond) = @_; |
| my @trans = handle_single_transform ($subvar, $topparent, |
| $one_file, $obj, $val, |
| %transform); |
| $needlinker = "true" if @trans; |
| return @trans; |
| }); |
| |
| return $needlinker; |
| } |
| |
| |
| # handle_source_transform ($CANON_TARGET, $TARGET, $OBJEXT, $WHERE, %TRANSFORM) |
| # ----------------------------------------------------------------------------- |
| # Handle SOURCE->OBJECT transform for one program or library. |
| # Arguments are: |
| # canonical (transformed) name of target to build |
| # actual target of object to build |
| # object extension (i.e., either '.o' or '$o') |
| # location of the source variable |
| # extra arguments to pass to file_contents when producing rules |
| # Return the name of the linker variable that must be used. |
| # Empty return means just use 'LINK'. |
| sub handle_source_transform ($$$$%) |
| { |
| # one_file is canonical name. unxformed is given name. obj is |
| # object extension. |
| my ($one_file, $unxformed, $obj, $where, %transform) = @_; |
| |
| my $linker = ''; |
| |
| # No point in continuing if _OBJECTS is defined. |
| return if reject_var ($one_file . '_OBJECTS', |
| $one_file . '_OBJECTS should not be defined'); |
| |
| my %used_pfx = (); |
| my $needlinker; |
| %linkers_used = (); |
| foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_', |
| 'dist_EXTRA_', 'nodist_EXTRA_') |
| { |
| my $varname = $prefix . $one_file . "_SOURCES"; |
| my $var = var $varname; |
| next unless $var; |
| |
| # We are going to define _OBJECTS variables using the prefix. |
| # Then we glom them all together. So we can't use the null |
| # prefix here as we need it later. |
| my $xpfx = ($prefix eq '') ? 'am_' : $prefix; |
| |
| # Keep track of which prefixes we saw. |
| $used_pfx{$xpfx} = 1 |
| unless $prefix =~ /EXTRA_/; |
| |
| push @sources, "\$($varname)"; |
| push @dist_sources, shadow_unconditionally ($varname, $where) |
| unless (option ('no-dist') || $prefix =~ /^nodist_/); |
| |
| $needlinker |= |
| define_objects_from_sources ($varname, |
| $xpfx . $one_file . '_OBJECTS', |
| $prefix =~ /EXTRA_/, |
| $one_file, $obj, $varname, $where, |
| DIST_SOURCE => ($prefix !~ /^nodist_/), |
| %transform); |
| } |
| if ($needlinker) |
| { |
| $linker ||= &resolve_linker (%linkers_used); |
| } |
| |
| my @keys = sort keys %used_pfx; |
| if (scalar @keys == 0) |
| { |
| my $ext_var = var ('AM_DEFAULT_SOURCE_EXT'); |
| my $default_source_ext = $ext_var ? variable_value ($ext_var) : '.c'; |
| msg_var ('unsupported', $ext_var, $ext_var->name . " can assume at most one value") |
| if $default_source_ext =~ /[\t ]/; |
| (my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,$default_source_ext,; |
| define_variable ($one_file . "_SOURCES", $where, $default_source); |
| push (@sources, $default_source); |
| push (@dist_sources, $default_source); |
| |
| %linkers_used = (); |
| my (@result) = |
| handle_single_transform ($one_file . '_SOURCES', |
| $one_file . '_SOURCES', |
| $one_file, $obj, |
| $default_source, %transform); |
| $linker ||= &resolve_linker (%linkers_used); |
| define_variable ($one_file . '_OBJECTS', $where, @result); |
| } |
| else |
| { |
| @keys = map { '$(' . $_ . $one_file . '_OBJECTS)' } @keys; |
| define_variable ($one_file . '_OBJECTS', $where, @keys); |
| } |
| |
| # If we want to use 'LINK' we must make sure it is defined. |
| if ($linker eq '') |
| { |
| $need_link = 1; |
| } |
| |
| return $linker; |
| } |
| |
| |
| # handle_lib_objects ($XNAME, $VAR) |
| # --------------------------------- |
| # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables. |
| # Also, generate _DEPENDENCIES variable if appropriate. |
| # Arguments are: |
| # transformed name of object being built, or empty string if no object |
| # name of _LDADD/_LIBADD-type variable to examine |
| # Returns 1 if LIBOBJS seen, 0 otherwise. |
| sub handle_lib_objects |
| { |
| my ($xname, $varname) = @_; |
| |
| my $var = var ($varname); |
| prog_error "'$varname' undefined" |
| unless $var; |
| prog_error "unexpected variable name '$varname'" |
| unless $varname =~ /^(.*)(?:LIB|LD)ADD$/; |
| my $prefix = $1 || 'AM_'; |
| |
| my $seen_libobjs = 0; |
| my $flagvar = 0; |
| |
| transform_variable_recursively |
| ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES', |
| ! $xname, INTERNAL, |
| # Transformation function, run on each filename. |
| sub { |
| my ($subvar, $val, $cond, $full_cond) = @_; |
| |
| if ($val =~ /^-/) |
| { |
| # Skip -lfoo and -Ldir silently; these are explicitly allowed. |
| if ($val !~ /^-[lL]/ && |
| # Skip -dlopen and -dlpreopen; these are explicitly allowed |
| # for Libtool libraries or programs. (Actually we are a bit |
| # lax here since this code also applies to non-libtool |
| # libraries or programs, for which -dlopen and -dlopreopen |
| # are pure nonsense. Diagnosing this doesn't seem very |
| # important: the developer will quickly get complaints from |
| # the linker.) |
| $val !~ /^-dl(?:pre)?open$/ && |
| # Only get this error once. |
| ! $flagvar) |
| { |
| $flagvar = 1; |
| # FIXME: should display a stack of nested variables |
| # as context when $var != $subvar. |
| err_var ($var, "linker flags such as '$val' belong in " |
| . "'${prefix}LDFLAGS'"); |
| } |
| return (); |
| } |
| elsif ($val !~ /^\@.*\@$/) |
| { |
| # Assume we have a file of some sort, and output it into the |
| # dependency variable. Autoconf substitutions are not output; |
| # rarely is a new dependency substituted into e.g. foo_LDADD |
| # -- but bad things (e.g. -lX11) are routinely substituted. |
| # Note that LIBOBJS and ALLOCA are exceptions to this rule, |
| # and handled specially below. |
| return $val; |
| } |
| elsif ($val =~ /^\@(LT)?LIBOBJS\@$/) |
| { |
| handle_LIBOBJS ($subvar, $cond, $1); |
| $seen_libobjs = 1; |
| return $val; |
| } |
| elsif ($val =~ /^\@(LT)?ALLOCA\@$/) |
| { |
| handle_ALLOCA ($subvar, $cond, $1); |
| return $val; |
| } |
| else |
| { |
| return (); |
| } |
| }); |
| |
| return $seen_libobjs; |
| } |
| |
| # handle_LIBOBJS_or_ALLOCA ($VAR) |
| # ------------------------------- |
| # Definitions common to LIBOBJS and ALLOCA. |
| # VAR should be one of LIBOBJS, LTLIBOBJS, ALLOCA, or LTALLOCA. |
| sub handle_LIBOBJS_or_ALLOCA ($) |
| { |
| my ($var) = @_; |
| |
| my $dir = ''; |
| |
| # If LIBOBJS files must be built in another directory we have |
| # to define the 'LIBOBJDIR' make variable. |
| if ($config_libobj_dir && $relative_dir ne $config_libobj_dir) |
| { |
| # In the top-level Makefile we do not use $(top_builddir), because |
| # we are already there, and since the targets are built without |
| # a $(top_builddir), it helps BSD Make to match them with |
| # dependencies. |
| $dir = "$config_libobj_dir/" |
| if $config_libobj_dir ne '.'; |
| $dir = backname ($relative_dir) . "/$dir" |
| if $relative_dir ne '.'; |
| define_variable ('LIBOBJDIR', INTERNAL, $dir); |
| } |
| $clean_files{'$(LIBOBJDIR)*.$(OBJEXT)'} = MOSTLY_CLEAN; |
| $clean_files{'$(LIBOBJDIR)*.lo'} = MOSTLY_CLEAN |
| if $var =~ /^LT/; |
| |
| return $dir; |
| } |
| |
| sub handle_LIBOBJS ($$$) |
| { |
| my ($var, $cond, $lt) = @_; |
| my $myobjext = $lt ? 'lo' : 'o'; |
| $lt ||= ''; |
| |
| $var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS') |
| if ! keys %libsources; |
| |
| my $dir = handle_LIBOBJS_or_ALLOCA "${lt}LIBOBJS"; |
| |
| foreach my $iter (keys %libsources) |
| { |
| if ($iter =~ /\.[cly]$/) |
| { |
| &saw_extension ($&); |
| &saw_extension ('.c'); |
| } |
| |
| if ($iter =~ /\.h$/) |
| { |
| require_libsource_with_macro ($cond, $var, FOREIGN, $iter); |
| } |
| elsif ($iter ne 'alloca.c') |
| { |
| my $rewrite = $iter; |
| $rewrite =~ s/\.c$/.P$myobjext/; |
| $dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1; |
| $rewrite = "^" . quotemeta ($iter) . "\$"; |
| # Only require the file if it is not a built source. |
| my $bs = var ('BUILT_SOURCES'); |
| if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive)) |
| { |
| require_libsource_with_macro ($cond, $var, FOREIGN, $iter); |
| } |
| } |
| } |
| } |
| |
| sub handle_ALLOCA ($$$) |
| { |
| my ($var, $cond, $lt) = @_; |
| my $myobjext = $lt ? 'lo' : 'o'; |
| $lt ||= ''; |
| my $dir = handle_LIBOBJS_or_ALLOCA "${lt}ALLOCA"; |
| |
| $var->requires_variables ("\@${lt}ALLOCA\@ used", $lt . 'ALLOCA'); |
| $dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1; |
| require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c'); |
| &saw_extension ('.c'); |
| } |
| |
| # Canonicalize the input parameter |
| sub canonicalize |
| { |
| my ($string) = @_; |
| $string =~ tr/A-Za-z0-9_\@/_/c; |
| return $string; |
| } |
| |
| # Canonicalize a name, and check to make sure the non-canonical name |
| # is never used. Returns canonical name. Arguments are name and a |
| # list of suffixes to check for. |
| sub check_canonical_spelling |
| { |
| my ($name, @suffixes) = @_; |
| |
| my $xname = &canonicalize ($name); |
| if ($xname ne $name) |
| { |
| foreach my $xt (@suffixes) |
| { |
| reject_var ("$name$xt", "use '$xname$xt', not '$name$xt'"); |
| } |
| } |
| |
| return $xname; |
| } |
| |
| |
| # handle_compile () |
| # ----------------- |
| # Set up the compile suite. |
| sub handle_compile () |
| { |
| return if ! $must_handle_compiled_objects; |
| $output_rules .= file_contents ('compile', |
| new Automake::Location, |
| 'STDINC' => ! option 'nostdinc'); |
| } |
| |
| # handle_libtool () |
| # ----------------- |
| # Handle libtool rules. |
| sub handle_libtool |
| { |
| return unless var ('LIBTOOL'); |
| |
| # Libtool requires some files, but only at top level. |
| # (Starting with Libtool 2.0 we do not have to bother. These |
| # requirements are done with AC_REQUIRE_AUX_FILE.) |
| require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files) |
| if $relative_dir eq '.' && ! $libtool_new_api; |
| |
| check_user_variables 'LIBTOOLFLAGS'; |
| |
| if ($relative_dir eq '.') |
| { |
| $clean_files{"libtool"} = DIST_CLEAN; |
| $clean_files{"config.lt"} = DIST_CLEAN; |
| } |
| } |
| |
| # handle_programs () |
| # ------------------ |
| # Handle C programs. |
| sub handle_programs |
| { |
| my @proglist = &am_install_var ('progs', 'PROGRAMS', |
| 'bin', 'sbin', 'libexec', 'pkglibexec', |
| 'noinst', 'check'); |
| return if ! @proglist; |
| $must_handle_compiled_objects = 1; |
| |
| my $seen_global_libobjs = |
| var ('LDADD') && &handle_lib_objects ('', 'LDADD'); |
| |
| foreach my $pair (@proglist) |
| { |
| my ($where, $one_file) = @$pair; |
| |
| my $seen_libobjs = 0; |
| my $obj = '.$(OBJEXT)'; |
| |
| $known_programs{$one_file} = $where; |
| |
| # Canonicalize names and check for misspellings. |
| my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS', |
| '_SOURCES', '_OBJECTS', |
| '_DEPENDENCIES'); |
| |
| $where->push_context ("while processing program '$one_file'"); |
| $where->set (INTERNAL->get); |
| |
| my $linker = &handle_source_transform ($xname, $one_file, $obj, $where, |
| NONLIBTOOL => 1, LIBTOOL => 0); |
| |
| if (var ($xname . "_LDADD")) |
| { |
| $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD'); |
| } |
| else |
| { |
| # User didn't define prog_LDADD override. So do it. |
| define_variable ($xname . '_LDADD', $where, '$(LDADD)'); |
| |
| # This does a bit too much work. But we need it to |
| # generate _DEPENDENCIES when appropriate. |
| if (var ('LDADD')) |
| { |
| $seen_libobjs = &handle_lib_objects ($xname, 'LDADD'); |
| } |
| } |
| |
| reject_var ($xname . '_LIBADD', |
| "use '${xname}_LDADD', not '${xname}_LIBADD'"); |
| |
| set_seen ($xname . '_LDFLAGS'); |
| |
| # Determine program to use for link. |
| my($xlink, $vlink) = &define_per_target_linker_variable ($linker, $xname); |
| $vlink = verbose_flag ($vlink || 'GEN'); |
| |
| $clean_dirs{dirname ($one_file) . '/.libs'} = CLEAN; |
| |
| $output_rules .= &file_contents ('program', |
| $where, |
| PROGRAM => $one_file, |
| XPROGRAM => $xname, |
| XLINK => $xlink, |
| VERBOSE => $vlink, |
| EXEEXT => '$(EXEEXT)'); |
| |
| if ($seen_libobjs || $seen_global_libobjs) |
| { |
| if (var ($xname . '_LDADD')) |
| { |
| &check_libobjs_sources ($xname, $xname . '_LDADD'); |
| } |
| elsif (var ('LDADD')) |
| { |
| &check_libobjs_sources ($xname, 'LDADD'); |
| } |
| } |
| } |
| } |
| |
| |
| # handle_libraries () |
| # ------------------- |
| # Handle libraries. |
| sub handle_libraries |
| { |
| my @liblist = &am_install_var ('libs', 'LIBRARIES', |
| 'lib', 'pkglib', 'noinst', 'check'); |
| return if ! @liblist; |
| $must_handle_compiled_objects = 1; |
| |
| my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib', |
| 'noinst', 'check'); |
| |
| if (@prefix) |
| { |
| my $var = rvar ($prefix[0] . '_LIBRARIES'); |
| $var->requires_variables ('library used', 'RANLIB'); |
| } |
| |
| define_variable ('AR', INTERNAL, 'ar'); |
| define_variable ('ARFLAGS', INTERNAL, 'cru'); |
| define_verbose_tagvar ('AR'); |
| |
| foreach my $pair (@liblist) |
| { |
| my ($where, $onelib) = @$pair; |
| |
| my $seen_libobjs = 0; |
| # Check that the library fits the standard naming convention. |
| my $bn = basename ($onelib); |
| if ($bn !~ /^lib.*\.a$/) |
| { |
| $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.a/; |
| my $suggestion = dirname ($onelib) . "/$bn"; |
| $suggestion =~ s|^\./||g; |
| msg ('error-gnu/warn', $where, |
| "'$onelib' is not a standard library name\n" |
| . "did you mean '$suggestion'?") |
| } |
| |
| ($known_libraries{$onelib} = $bn) =~ s/\.a$//; |
| |
| $where->push_context ("while processing library '$onelib'"); |
| $where->set (INTERNAL->get); |
| |
| my $obj = '.$(OBJEXT)'; |
| |
| # Canonicalize names and check for misspellings. |
| my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES', |
| '_OBJECTS', '_DEPENDENCIES', |
| '_AR'); |
| |
| if (! var ($xlib . '_AR')) |
| { |
| define_variable ($xlib . '_AR', $where, '$(AR) $(ARFLAGS)'); |
| } |
| |
| # Generate support for conditional object inclusion in |
| # libraries. |
| if (var ($xlib . '_LIBADD')) |
| { |
| if (&handle_lib_objects ($xlib, $xlib . '_LIBADD')) |
| { |
| $seen_libobjs = 1; |
| } |
| } |
| else |
| { |
| define_variable ($xlib . "_LIBADD", $where, ''); |
| } |
| |
| reject_var ($xlib . '_LDADD', |
| "use '${xlib}_LIBADD', not '${xlib}_LDADD'"); |
| |
| &handle_source_transform ($xlib, $onelib, $obj, $where, |
| NONLIBTOOL => 1, LIBTOOL => 0); |
| |
| my $verbose = verbose_flag ('AR'); |
| |
| $output_rules .= &file_contents ('library', |
| $where, |
| VERBOSE => $verbose, |
| LIBRARY => $onelib, |
| XLIBRARY => $xlib); |
| |
| if ($seen_libobjs) |
| { |
| if (var ($xlib . '_LIBADD')) |
| { |
| &check_libobjs_sources ($xlib, $xlib . '_LIBADD'); |
| } |
| } |
| |
| if (! $seen_ar) |
| { |
| msg ('extra-portability', $where, |
| "'$onelib': linking libraries using a non-POSIX\n" |
| . "archiver requires 'AM_PROG_AR' in '$configure_ac'") |
| } |
| } |
| } |
| |
| |
| # handle_ltlibraries () |
| # --------------------- |
| # Handle shared libraries. |
| sub handle_ltlibraries |
| { |
| my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES', |
| 'noinst', 'lib', 'pkglib', 'check'); |
| return if ! @liblist; |
| $must_handle_compiled_objects = 1; |
| |
| my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib', |
| 'noinst', 'check'); |
| |
| if (@prefix) |
| { |
| my $var = rvar ($prefix[0] . '_LTLIBRARIES'); |
| $var->requires_variables ('Libtool library used', 'LIBTOOL'); |
| } |
| |
| my %instdirs = (); |
| my %instsubdirs = (); |
| my %instconds = (); |
| my %liblocations = (); # Location (in Makefile.am) of each library. |
| |
| foreach my $key (@prefix) |
| { |
| # Get the installation directory of each library. |
| my $dir = $key; |
| my $strip_subdir = 1; |
| if ($dir =~ /^nobase_/) |
| { |
| $dir =~ s/^nobase_//; |
| $strip_subdir = 0; |
| } |
| my $var = rvar ($key . '_LTLIBRARIES'); |
| |
| # We reject libraries which are installed in several places |
| # in the same condition, because we can only specify one |
| # '-rpath' option. |
| $var->traverse_recursively |
| (sub |
| { |
| my ($var, $val, $cond, $full_cond) = @_; |
| my $hcond = $full_cond->human; |
| my $where = $var->rdef ($cond)->location; |
| my $ldir = ''; |
| $ldir = '/' . dirname ($val) |
| if (!$strip_subdir); |
| # A library cannot be installed in different directories |
| # in overlapping conditions. |
| if (exists $instconds{$val}) |
| { |
| my ($msg, $acond) = |
| $instconds{$val}->ambiguous_p ($val, $full_cond); |
| |
| if ($msg) |
| { |
| error ($where, $msg, partial => 1); |
| my $dirtxt = "installed " . ($strip_subdir ? "in" : "below") . " '$dir'"; |
| $dirtxt = "built for '$dir'" |
| if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check'; |
| my $dircond = |
| $full_cond->true ? "" : " in condition $hcond"; |
| |
| error ($where, "'$val' should be $dirtxt$dircond ...", |
| partial => 1); |
| |
| my $hacond = $acond->human; |
| my $adir = $instdirs{$val}{$acond}; |
| my $adirtxt = "installed in '$adir'"; |
| $adirtxt = "built for '$adir'" |
| if ($adir eq 'EXTRA' || $adir eq 'noinst' |
| || $adir eq 'check'); |
| my $adircond = $acond->true ? "" : " in condition $hacond"; |
| |
| my $onlyone = ($dir ne $adir) ? |
| ("\nLibtool libraries can be built for only one " |
| . "destination") : ""; |
| |
| error ($liblocations{$val}{$acond}, |
| "... and should also be $adirtxt$adircond.$onlyone"); |
| return; |
| } |
| } |
| else |
| { |
| $instconds{$val} = new Automake::DisjConditions; |
| } |
| $instdirs{$val}{$full_cond} = $dir; |
| $instsubdirs{$val}{$full_cond} = $ldir; |
| $liblocations{$val}{$full_cond} = $where; |
| $instconds{$val} = $instconds{$val}->merge ($full_cond); |
| }, |
| sub |
| { |
| return (); |
| }, |
| skip_ac_subst => 1); |
| } |
| |
| foreach my $pair (@liblist) |
| { |
| my ($where, $onelib) = @$pair; |
| |
| my $seen_libobjs = 0; |
| my $obj = '.lo'; |
| |
| # Canonicalize names and check for misspellings. |
| my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS', |
| '_SOURCES', '_OBJECTS', |
| '_DEPENDENCIES'); |
| |
| # Check that the library fits the standard naming convention. |
| my $libname_rx = '^lib.*\.la'; |
| my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS'); |
| my $ldvar2 = var ('LDFLAGS'); |
| if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive)) |
| || ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive))) |
| { |
| # Relax name checking for libtool modules. |
| $libname_rx = '\.la'; |
| } |
| |
| my $bn = basename ($onelib); |
| if ($bn !~ /$libname_rx$/) |
| { |
| my $type = 'library'; |
| if ($libname_rx eq '\.la') |
| { |
| $bn =~ s/^(lib|)(.*?)(?:\.[^.]*)?$/$1$2.la/; |
| $type = 'module'; |
| } |
| else |
| { |
| $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.la/; |
| } |
| my $suggestion = dirname ($onelib) . "/$bn"; |
| $suggestion =~ s|^\./||g; |
| msg ('error-gnu/warn', $where, |
| "'$onelib' is not a standard libtool $type name\n" |
| . "did you mean '$suggestion'?") |
| } |
| |
| ($known_ltlibraries{$onelib} = $bn) =~ s/\.la$//; |
| |
| $where->push_context ("while processing Libtool library '$onelib'"); |
| $where->set (INTERNAL->get); |
| |
| # Make sure we look at this. |
| set_seen ($xlib . '_LDFLAGS'); |
| |
| # Generate support for conditional object inclusion in |
| # libraries. |
| if (var ($xlib . '_LIBADD')) |
| { |
| if (&handle_lib_objects ($xlib, $xlib . '_LIBADD')) |
| { |
| $seen_libobjs = 1; |
| } |
| } |
| else |
| { |
| define_variable ($xlib . "_LIBADD", $where, ''); |
| } |
| |
| reject_var ("${xlib}_LDADD", |
| "use '${xlib}_LIBADD', not '${xlib}_LDADD'"); |
| |
| |
| my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where, |
| NONLIBTOOL => 0, LIBTOOL => 1); |
| |
| # Determine program to use for link. |
| my($xlink, $vlink) = &define_per_target_linker_variable ($linker, $xlib); |
| $vlink = verbose_flag ($vlink || 'GEN'); |
| |
| my $rpathvar = "am_${xlib}_rpath"; |
| my $rpath = "\$($rpathvar)"; |
| foreach my $rcond ($instconds{$onelib}->conds) |
| { |
| my $val; |
| if ($instdirs{$onelib}{$rcond} eq 'EXTRA' |
| || $instdirs{$onelib}{$rcond} eq 'noinst' |
| || $instdirs{$onelib}{$rcond} eq 'check') |
| { |
| # It's an EXTRA_ library, so we can't specify -rpath, |
| # because we don't know where the library will end up. |
| # The user probably knows, but generally speaking automake |
| # doesn't -- and in fact configure could decide |
| # dynamically between two different locations. |
| $val = ''; |
| } |
| else |
| { |
| $val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)'); |
| $val .= $instsubdirs{$onelib}{$rcond} |
| if defined $instsubdirs{$onelib}{$rcond}; |
| } |
| if ($rcond->true) |
| { |
| # If $rcond is true there is only one condition and |
| # there is no point defining an helper variable. |
| $rpath = $val; |
| } |
| else |
| { |
| define_cond_variable ($rpathvar, $rcond, INTERNAL, $val); |
| } |
| } |
| |
| $clean_dirs{dirname ($onelib) . '/.libs'} = CLEAN; |
| |
| $output_rules .= &file_contents ('ltlibrary', |
| $where, |
| LTLIBRARY => $onelib, |
| XLTLIBRARY => $xlib, |
| RPATH => $rpath, |
| XLINK => $xlink, |
| VERBOSE => $vlink); |
| if ($seen_libobjs) |
| { |
| if (var ($xlib . '_LIBADD')) |
| { |
| &check_libobjs_sources ($xlib, $xlib . '_LIBADD'); |
| } |
| } |
| |
| if (! $seen_ar) |
| { |
| msg ('extra-portability', $where, |
| "'$onelib': linking libtool libraries using a non-POSIX\n" |
| . "archiver requires 'AM_PROG_AR' in '$configure_ac'") |
| } |
| } |
| } |
| |
| |
| # Handle scripts. |
| sub handle_scripts |
| { |
| # NOTE we no longer automatically clean SCRIPTS, because it is |
| # useful to sometimes distribute scripts verbatim. This happens |
| # e.g. in Automake itself. |
| &am_install_var ('-candist', 'scripts', 'SCRIPTS', |
| 'bin', 'sbin', 'libexec', 'pkglibexec', 'pkgdata', |
| 'noinst', 'check'); |
| } |
| |
| |
| |
| |
| ## ------------------------ ## |
| ## Handling Texinfo files. ## |
| ## ------------------------ ## |
| |
| # ($OUTFILE, $VFILE) |
| # &scan_texinfo_file ($FILENAME) |
| # ------------------------------ |
| # $OUTFILE - name of the info file produced by $FILENAME. |
| # $VFILE - name of the version.texi file used (undef if none). |
| sub scan_texinfo_file ($) |
| { |
| my ($filename) = @_; |
| |
| my $texi = new Automake::XFile "< $filename"; |
| verb "reading $filename"; |
| |
| my ($outfile, $vfile); |
| while ($_ = $texi->getline) |
| { |
| if (/^\@setfilename +(\S+)/) |
| { |
| # Honor only the first @setfilename. (It's possible to have |
| # more occurrences later if the manual shows examples of how |
| # to use @setfilename...) |
| next if $outfile; |
| |
| $outfile = $1; |
| if ($outfile !~ /\.info$/) |
| { |
| error ("$filename:$.", |
| "output '$outfile' has unrecognized extension"); |
| return; |
| } |
| } |
| # A "version.texi" file is actually any file whose name matches |
| # "vers*.texi". |
| elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/) |
| { |
| $vfile = $1; |
| } |
| } |
| |
| if (! $outfile) |
| { |
| err_am "'$filename' missing \@setfilename"; |
| return; |
| } |
| |
| my $infobase = basename ($filename); |
| $infobase =~ s/\.texi$//; |
| return ($outfile, $vfile); |
| } |
| |
| # handle_texinfo_helper ($info_texinfos) |
| # -------------------------------------- |
| # Handle all Texinfo source; helper for handle_texinfo. |
| sub handle_texinfo_helper ($) |
| { |
| my ($info_texinfos) = @_; |
| my (@infobase, @info_deps_list, @texi_deps); |
| my %versions; |
| my $done = 0; |
| |
| # Build a regex matching user-cleaned files. |
| my $d = var 'DISTCLEANFILES'; |
| my $c = var 'CLEANFILES'; |
| my @f = (); |
| push @f, $d->value_as_list_recursive (inner_expand => 1) if $d; |
| push @f, $c->value_as_list_recursive (inner_expand => 1) if $c; |
| @f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f; |
| my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$'; |
| |
| foreach my $texi |
| ($info_texinfos->value_as_list_recursive (inner_expand => 1)) |
| { |
| my $infobase = $texi; |
| $infobase =~ s/\.texi$//; |
| |
| if ($infobase eq $texi) |
| { |
| # FIXME: report line number. |
| err_am "texinfo file '$texi' has unrecognized extension"; |
| next; |
| } |
| |
| push @infobase, $infobase; |
| |
| # If 'version.texi' is referenced by input file, then include |
| # automatic versioning capability. |
| my ($out_file, $vtexi) = |
| scan_texinfo_file ("$relative_dir/$texi") |
| or next; |
| # Directory of auxiliary files and build by-products used by texi2dvi |
| # and texi2pdf. |
| $clean_dirs{"$infobase.t2d"} = MOSTLY_CLEAN; |
| $clean_dirs{"$infobase.t2p"} = MOSTLY_CLEAN; |
| |
| # If the Texinfo source is in a subdirectory, create the |
| # resulting info in this subdirectory. If it is in the current |
| # directory, try hard to not prefix "./" because it breaks the |
| # generic rules. |
| my $outdir = dirname ($texi) . '/'; |
| $outdir = "" if $outdir eq './'; |
| $out_file = $outdir . $out_file; |
| |
| # Until Automake 1.6.3, .info files were built in the |
| # source tree. This was an obstacle to the support of |
| # non-distributed .info files, and non-distributed .texi |
| # files. |
| # |
| # * Non-distributed .texi files is important in some packages |
| # where .texi files are built at make time, probably using |
| # other binaries built in the package itself, maybe using |
| # tools or information found on the build host. Because |
| # these files are not distributed they are always rebuilt |
| # at make time; they should therefore not lie in the source |
| # directory. One plan was to support this using |
| # nodist_info_TEXINFOS or something similar. (Doing this |
| # requires some sanity checks. For instance Automake should |
| # not allow: |
| # dist_info_TEXINFOS = foo.texi |
| # nodist_foo_TEXINFOS = included.texi |
| # because a distributed file should never depend on a |
| # non-distributed file.) |
| # |
| # * If .texi files are not distributed, then .info files should |
| # not be distributed either. There are also cases where one |
| # wants to distribute .texi files, but does not want to |
| # distribute the .info files. For instance the Texinfo package |
| # distributes the tool used to build these files; it would |
| # be a waste of space to distribute them. It's not clear |
| # which syntax we should use to indicate that .info files should |
| # not be distributed. Akim Demaille suggested that eventually |
| # we switch to a new syntax: |
| # | Maybe we should take some inspiration from what's already |
| # | done in the rest of Automake. Maybe there is too much |
| # | syntactic sugar here, and you want |
| # | nodist_INFO = bar.info |
| # | dist_bar_info_SOURCES = bar.texi |
| # | bar_texi_DEPENDENCIES = foo.texi |
| # | with a bit of magic to have bar.info represent the whole |
| # | bar*info set. That's a lot more verbose that the current |
| # | situation, but it is # not new, hence the user has less |
| # | to learn. |
| # | |
| # | But there is still too much room for meaningless specs: |
| # | nodist_INFO = bar.info |
| # | dist_bar_info_SOURCES = bar.texi |
| # | dist_PS = bar.ps something-written-by-hand.ps |
| # | nodist_bar_ps_SOURCES = bar.texi |
| # | bar_texi_DEPENDENCIES = foo.texi |
| # | here bar.texi is dist_ in line 2, and nodist_ in 4. |
| # |
| # Back to the point, it should be clear that in order to support |
| # non-distributed .info files, we need to build them in the |
| # build tree, not in the source tree (non-distributed .texi |
| # files are less of a problem, because we do not output build |
| # rules for them). In Automake 1.7 .info build rules have been |
| # largely cleaned up so that .info files get always build in the |
| # build tree, even when distributed. The idea was that |
| # (1) if during a VPATH build the .info file was found to be |
| # absent or out-of-date (in the source tree or in the |
| # build tree), Make would rebuild it in the build tree. |
| # If an up-to-date source-tree of the .info file existed, |
| # make would not rebuild it in the build tree. |
| # (2) having two copies of .info files, one in the source tree |
| # and one (newer) in the build tree is not a problem |
| # because 'make dist' always pick files in the build tree |
| # first. |
| # However it turned out the be a bad idea for several reasons: |
| # * Tru64, OpenBSD, and FreeBSD (not NetBSD) Make do not behave |
| # like GNU Make on point (1) above. These implementations |
| # of Make would always rebuild .info files in the build |
| # tree, even if such files were up to date in the source |
| # tree. Consequently, it was impossible to perform a VPATH |
| # build of a package containing Texinfo files using these |
| # Make implementations. |
| # (Refer to the Autoconf Manual, section "Limitation of |
| # Make", paragraph "VPATH", item "target lookup", for |
| # an account of the differences between these |
| # implementations.) |
| # * The GNU Coding Standards require these files to be built |
| # in the source-tree (when they are distributed, that is). |
| # * Keeping a fresher copy of distributed files in the |
| # build tree can be annoying during development because |
| # - if the files is kept under CVS, you really want it |
| # to be updated in the source tree |
| # - it is confusing that 'make distclean' does not erase |
| # all files in the build tree. |
| # |
| # Consequently, starting with Automake 1.8, .info files are |
| # built in the source tree again. Because we still plan to |
| # support non-distributed .info files at some point, we |
| # have a single variable ($INSRC) that controls whether |
| # the current .info file must be built in the source tree |
| # or in the build tree. Actually this variable is switched |
| # off for .info files that appear to be cleaned; this is |
| # for backward compatibility with package such as Texinfo, |
| # which do things like |
| # info_TEXINFOS = texinfo.texi info-stnd.texi info.texi |
| # DISTCLEANFILES = texinfo texinfo-* info*.info* |
| # # Do not create info files for distribution. |
| # dist-info: |
| # in order not to distribute .info files. |
| my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1; |
| |
| my $soutdir = '$(srcdir)/' . $outdir; |
| $outdir = $soutdir if $insrc; |
| |
| # If user specified file_TEXINFOS, then use that as explicit |
| # dependency list. |
| @texi_deps = (); |
| push (@texi_deps, "$soutdir$vtexi") if $vtexi; |
| |
| my $canonical = canonicalize ($infobase); |
| if (var ($canonical . "_TEXINFOS")) |
| { |
| push (@texi_deps, '$(' . $canonical . '_TEXINFOS)'); |
| push_dist_common ('$(' . $canonical . '_TEXINFOS)'); |
| } |
| |
| (my $dpfx = $out_file) =~ s/\.info$//; |
| $output_rules .= file_contents ('texi-spec', |
| new Automake::Location, |
| DEPS => "@texi_deps", |
| DEST_PREFIX => $dpfx, |
| INSRC => $insrc, |
| SOURCE_REAL => $texi, |
| ); |
| |
| $clean_files{"$dpfx.dvi"} = CLEAN; |
| $clean_files{"$dpfx.pdf"} = CLEAN; |
| $clean_files{"$dpfx.ps"} = CLEAN; |
| # Add to %clean_dirs, not $clean_files, because this will be a |
| # directory (unless '--no-split' is used in MAKEINFOFLAGS). |
| $clean_dirs{"$dpfx.html"} = CLEAN; |
| |
| push @info_deps_list, $out_file; |
| |
| # If a vers*.texi file is needed, emit the rule. |
| if ($vtexi) |
| { |
| err_am ("'$vtexi', included in '$texi', " |
| . "also included in '$versions{$vtexi}'") |
| if defined $versions{$vtexi}; |
| $versions{$vtexi} = $texi; |
| |
| # We number the stamp-vti files. This is doable since the |
| # actual names don't matter much. We only number starting |
| # with the second one, so that the common case looks nice. |
| my $vti = ($done ? $done : 'vti'); |
| ++$done; |
| |
| require_conf_file_with_macro (TRUE, 'info_TEXINFOS', |
| FOREIGN, 'mdate-sh'); |
| $output_rules .= file_contents ('texi-vers', |
| new Automake::Location, |
| TEXI => $texi, |
| VTI => $vti, |
| STAMPVTI => "${soutdir}stamp-$vti", |
| VTEXI => "$soutdir$vtexi"); |
| } |
| } |
| |
| # Handle location of texinfo.tex. |
| my $need_texi_file = 0; |
| my $texinfodir; |
| if (var ('TEXINFO_TEX')) |
| { |
| # The user defined TEXINFO_TEX so assume he knows what he is |
| # doing. |
| $texinfodir = ('$(srcdir)/' |
| . dirname (variable_value ('TEXINFO_TEX'))); |
| } |
| elsif ($config_aux_dir_set_in_configure_ac) |
| { |
| $texinfodir = '$(am.conf.aux-dir)'; |
| define_variable ('TEXINFO_TEX', INTERNAL, "$texinfodir/texinfo.tex"); |
| $need_texi_file = 2; # so that we require_conf_file later |
| } |
| else |
| { |
| $texinfodir = '$(srcdir)'; |
| $need_texi_file = 1; |
| } |
| define_variable ('am__TEXINFO_TEX_DIR', INTERNAL, $texinfodir); |
| |
| push (@dist_targets, 'dist-info'); |
| |
| if (! option 'no-installinfo') |
| { |
| # Make sure documentation is made and installed first. Use |
| # $(INFO_DEPS), not 'info', because otherwise recursive makes |
| # get run twice during "make all". |
| unshift (@all, '$(INFO_DEPS)'); |
| } |
| |
| define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL); |
| define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL); |
| define_files_variable ("PSS", @infobase, 'ps', INTERNAL); |
| define_files_variable ("HTMLS", @infobase, 'html', INTERNAL); |
| |
| # This next isn't strictly needed now -- the places that look here |
| # could easily be changed to look in info_TEXINFOS. But this is |
| # probably better, in case noinst_TEXINFOS is ever supported. |
| define_variable ("TEXINFOS", INTERNAL, variable_value ('info_TEXINFOS')); |
| |
| # Do some error checking. Note that this file is not required |
| # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly |
| # up above. |
| if ($need_texi_file && ! option 'no-texinfo.tex') |
| { |
| if ($need_texi_file > 1) |
| { |
| require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, |
| 'texinfo.tex'); |
| } |
| else |
| { |
| require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, |
| 'texinfo.tex'); |
| } |
| } |
| } |
| |
| |
| # handle_texinfo () |
| # ----------------- |
| # Handle all Texinfo source. |
| sub handle_texinfo () |
| { |
| reject_var 'TEXINFOS', "'TEXINFOS' is an anachronism; use 'info_TEXINFOS'"; |
| # FIXME: I think this is an obsolete future feature name. |
| reject_var 'html_TEXINFOS', "HTML generation not yet supported"; |
| |
| if (my $info_texinfos = var ('info_TEXINFOS')) |
| { |
| define_verbose_texinfo; |
| verbatim ('texibuild'); |
| handle_texinfo_helper ($info_texinfos); |
| } |
| verbatim ('texinfos'); |
| } |
| |
| |
| # Handle any man pages. |
| sub handle_man_pages |
| { |
| reject_var 'MANS', "'MANS' is an anachronism; use 'man_MANS'"; |
| |
| # Find all the sections in use. We do this by first looking for |
| # "standard" sections, and then looking for any additional |
| # sections used in man_MANS. |
| my (%sections, %notrans_sections, %trans_sections, |
| %notrans_vars, %trans_vars, %notrans_sect_vars, %trans_sect_vars); |
| # We handle nodist_ for uniformity. man pages aren't distributed |
| # by default so it isn't actually very important. |
| foreach my $npfx ('', 'notrans_') |
| { |
| foreach my $pfx ('', 'dist_', 'nodist_') |
| { |
| # Add more sections as needed. |
| foreach my $section ('0'..'9', 'n', 'l') |
| { |
| my $varname = $npfx . $pfx . 'man' . $section . '_MANS'; |
| if (var ($varname)) |
| { |
| $sections{$section} = 1; |
| $varname = '$(' . $varname . ')'; |
| if ($npfx eq 'notrans_') |
| { |
| $notrans_sections{$section} = 1; |
| $notrans_sect_vars{$varname} = 1; |
| } |
| else |
| { |
| $trans_sections{$section} = 1; |
| $trans_sect_vars{$varname} = 1; |
| } |
| |
| push_dist_common ($varname) |
| if $pfx eq 'dist_'; |
| } |
| } |
| |
| my $varname = $npfx . $pfx . 'man_MANS'; |
| my $var = var ($varname); |
| if ($var) |
| { |
| foreach ($var->value_as_list_recursive) |
| { |
| # A page like 'foo.1c' goes into man1dir. |
| if (/\.([0-9a-z])([a-z]*)$/) |
| { |
| $sections{$1} = 1; |
| if ($npfx eq 'notrans_') |
| { |
| $notrans_sections{$1} = 1; |
| } |
| else |
| { |
| $trans_sections{$1} = 1; |
| } |
| } |
| } |
| |
| $varname = '$(' . $varname . ')'; |
| if ($npfx eq 'notrans_') |
| { |
| $notrans_vars{$varname} = 1; |
| } |
| else |
| { |
| $trans_vars{$varname} = 1; |
| } |
| push_dist_common ($varname) |
| if $pfx eq 'dist_'; |
| } |
| } |
| } |
| |
| return unless %sections; |
| |
| my @unsorted_deps; |
| |
| # Build section independent variables. |
| my $have_notrans = %notrans_vars; |
| my @notrans_list = sort keys %notrans_vars; |
| my $have_trans = %trans_vars; |
| my @trans_list = sort keys %trans_vars; |
| |
| # Now for each section, generate an install and uninstall rule. |
| # Sort sections so output is deterministic. |
| foreach my $section (sort keys %sections) |
| { |
| # Build section dependent variables. |
| my $notrans_mans = $have_notrans || exists $notrans_sections{$section}; |
| my $trans_mans = $have_trans || exists $trans_sections{$section}; |
| my (%notrans_this_sect, %trans_this_sect); |
| my $expr = 'man' . $section . '_MANS'; |
| foreach my $varname (keys %notrans_sect_vars) |
| { |
| if ($varname =~ /$expr/) |
| { |
| $notrans_this_sect{$varname} = 1; |
| } |
| } |
| foreach my $varname (keys %trans_sect_vars) |
| { |
| if ($varname =~ /$expr/) |
| { |
| $trans_this_sect{$varname} = 1; |
| } |
| } |
| my @notrans_sect_list = sort keys %notrans_this_sect; |
| my @trans_sect_list = sort keys %trans_this_sect; |
| @unsorted_deps = (keys %notrans_vars, keys %trans_vars, |
| keys %notrans_this_sect, keys %trans_this_sect); |
| my @deps = sort @unsorted_deps; |
| $output_rules .= &file_contents ('mans', |
| new Automake::Location, |
| SECTION => $section, |
| DEPS => "@deps", |
| NOTRANS_MANS => $notrans_mans, |
| NOTRANS_SECT_LIST => "@notrans_sect_list", |
| HAVE_NOTRANS => $have_notrans, |
| NOTRANS_LIST => "@notrans_list", |
| TRANS_MANS => $trans_mans, |
| TRANS_SECT_LIST => "@trans_sect_list", |
| HAVE_TRANS => $have_trans, |
| TRANS_LIST => "@trans_list"); |
| } |
| |
| @unsorted_deps = (keys %notrans_vars, keys %trans_vars, |
| keys %notrans_sect_vars, keys %trans_sect_vars); |
| my @mans = sort @unsorted_deps; |
| $output_vars .= file_contents ('mans-vars', |
| new Automake::Location, |
| MANS => "@mans"); |
| |
| push (@all, '$(MANS)') |
| unless option 'no-installman'; |
| } |
| |
| # Handle DATA variables. |
| sub handle_data |
| { |
| &am_install_var ('-noextra', '-candist', 'data', 'DATA', |
| 'data', 'dataroot', 'doc', 'dvi', 'html', 'pdf', |
| 'ps', 'sysconf', 'sharedstate', 'localstate', |
| 'pkgdata', 'lisp', 'noinst', 'check'); |
| } |
| |
| # user_phony_rule ($NAME) |
| # ----------------------- |
| # Return false if rule $NAME does not exist. Otherwise, |
| # declare it as phony, complete its definition (in case it is |
| # conditional), and return its Automake::Rule instance. |
| sub user_phony_rule ($) |
| { |
| my ($name) = @_; |
| my $rule = rule $name; |
| if ($rule) |
| { |
| depend ('.PHONY', $name); |
| # Define $NAME in all condition where it is not already defined, |
| # so that it is always OK to depend on $NAME. |
| for my $c ($rule->not_always_defined_in_cond (TRUE)->conds) |
| { |
| Automake::Rule::define ($name, 'internal', RULE_AUTOMAKE, |
| $c, INTERNAL); |
| $output_rules .= $c->subst_string . "$name:\n"; |
| } |
| } |
| return $rule; |
| } |
| |
| |
| # handle_dist |
| # ----------- |
| # Handle 'dist' target. |
| sub handle_dist () |
| { |
| # Define DIST_SUBDIRS. This must always be done, regardless of the |
| # no-dist setting: target like 'distclean' or 'maintainer-clean' use it. |
| my $subdirs = var ('SUBDIRS'); |
| if ($subdirs) |
| { |
| # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS |
| # to all possible directories, and use it. If DIST_SUBDIRS is |
| # defined, just use it. |
| |
| # Note that we check DIST_SUBDIRS first on purpose, so that |
| # we don't call has_conditional_contents for now reason. |
| # (In the past one project used so many conditional subdirectories |
| # that calling has_conditional_contents on SUBDIRS caused |
| # automake to grow to 150Mb -- this should not happen with |
| # the current implementation of has_conditional_contents, |
| # but it's more efficient to avoid the call anyway.) |
| if (var ('DIST_SUBDIRS')) |
| { |
| } |
| elsif ($subdirs |