📄 automake.in
字号:
elsif ($arglist[0] eq '--no-force') { $force_generation = 0; } elsif ($arglist[0] =~ /^--output-dir=(.*)$/) { # Set output directory. $output_directory = $1; } elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o') { &require_argument (@arglist); shift (@arglist); $output_directory = $arglist[0]; } elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a') { $add_missing = 1; } elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c') { $copy_missing = 1; } elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v') { $verbose = 1; } elsif ($arglist[0] eq '--') { # Stop option processing. shift (@arglist); push (@input_files, @arglist); last; } elsif ($arglist[0] =~ /^-/) { die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n"; } else { # Handle $local:$input syntax. Note that we only examine # the first ":" file to see if it is automake input; the # rest are just taken verbatim. We still keep all the # files around for dependency checking, however. local ($local, $input, @rest) = split (/:/, $arglist[0]); if (! $input) { $input = $local; } else { # Strip .in; later on .am is tacked on. That is how # the automake input file is found. Maybe not the # best way, but it is easy to explain. FIXME: should # be error if .in is missing. $input =~ s/\.in$//; } push (@input_files, $input); $output_files{$input} = join (':', ($local, @rest)); } shift (@arglist); } # Take global strictness from whatever we currently have set. $default_strictness = $strictness; $default_strictness_name = $strictness_name;}# Ensure argument exists, or die.sub require_argument{ local ($arg, @arglist) = @_; die "automake: no argument given for option \`$arg'\n" if ! @arglist;}################################################################# Generate a Makefile.in given the name of the corresponding Makefile and# the name of the file output by config.status.sub generate_makefile{ local ($output, $makefile) = @_; ($am_file_name = $makefile) =~ s/^.*\///; $in_file_name = $am_file_name . '.in'; $am_file_name .= '.am'; # $OUTPUT is encoded. If it contains a ":" then the first element # is the real output file, and all remaining elements are input # files. We don't scan or otherwise deal with these input file, # other than to mark them as dependencies. See scan_configure for # details. local (@secondary_inputs); ($output, @secondary_inputs) = split (/:/, $output); &initialize_per_input; $relative_dir = &dirname ($output); $am_relative_dir = &dirname ($makefile); # At the toplevel directory, we might need config.guess, config.sub # or libtool scripts (ltconfig and ltmain.sh). if ($relative_dir eq '.') { # libtool requires some files. &require_conf_file_with_conf_line ($libtool_line, $FOREIGN, @libtoolize_files) if $seen_libtool; # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and # config.sub. &require_config_file ($FOREIGN, 'config.guess', 'config.sub') if $seen_canonical; } # We still need Makefile.in here, because sometimes the `dist' # target doesn't re-run automake. if ($am_relative_dir eq $relative_dir) { # Only distribute the files if they are in the same subdir as # the generated makefile. &push_dist_common ($in_file_name, $am_file_name); } push (@sources, '$(SOURCES)') if &variable_defined ('SOURCES'); push (@objects, '$(OBJECTS)') if &variable_defined ('OBJECTS'); &read_main_am_file ($makefile . '.am'); if (&handle_options) { # Fatal error. Just return, so we can continue with next file. return; } # Check first, because we might modify some state. &check_cygnus; &check_gnu_standards; &check_gnits_standards; &handle_configure ($output, $makefile, @secondary_inputs); &handle_gettext; &handle_libraries; &handle_ltlibraries; &handle_programs; &handle_scripts; &handle_built_sources; # This must be run after all the sources are scanned. &finish_languages; # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend # on this (but currently does). $contents{'SOURCES'} = join (' ', @sources); $contents{'OBJECTS'} = join (' ', @objects); &handle_multilib; &handle_texinfo; &handle_emacs_lisp; &handle_java; &handle_man_pages; &handle_data; &handle_headers; &handle_subdirs; &handle_tags; &handle_minor_options; &handle_dist ($makefile); &handle_dependencies; &handle_tests; &handle_footer; &handle_merge_targets ($output); &handle_installdirs; &handle_clean; &handle_phony; &check_typos; if (! -d ($output_directory . '/' . $am_relative_dir)) { mkdir ($output_directory . '/' . $am_relative_dir, 0755); } local ($out_file) = $output_directory . '/' . $makefile . ".in"; if (! $force_generation && -e $out_file) { local ($am_time) = (stat ($makefile . '.am'))[9]; local ($in_time) = (stat ($out_file))[9]; # FIXME: should cache these times. local ($conf_time) = (stat ($configure_ac))[9]; # FIXME: how to do unsigned comparison? if ($am_time < $in_time || $am_time < $conf_time) { # No need to update. return; } if (-f 'aclocal.m4') { local ($acl_time) = (stat _)[9]; return if ($am_time < $acl_time); } } if (! open (GM_FILE, "> " . $out_file)) { warn "automake: ${am_file}.in: cannot write: $!\n"; $exit_status = 1; return; } print "automake: creating ", $makefile, ".in\n" if $verbose; print GM_FILE $output_vars; # We make sure that `all:' is the first target. print GM_FILE $output_all; print GM_FILE $output_header; print GM_FILE $output_rules; print GM_FILE $output_trailer; close (GM_FILE);}################################################################# A helper which handles the logic of requiring a version number in# AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.sub version_check ($$$$){ my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4); &prog_error ("version is incorrect: $VERSION") if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/; my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4); $rfork ||= ''; $tfork ||= ''; my $rminorminor = 0; my $tminorminor = 0; # Some versions were labelled like `1.4-p3a'. This is the same as # an alpha release labelled `1.4.3a'. However, a version like # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral: # always listen to the users. if ($rfork =~ /p([0-9]+)([a-z]?)/) { $rminorminor = $1; # `1.4a-p3b' never existed. But we'll accept it anyway. $ralpha = $ralpha || $2 || ''; $rfork = ''; } if ($tfork =~ /p([0-9]+)([a-z]?)/) { $tminorminor = $1; # `1.4a-p3b' never existed. But we'll accept it anyway. $talpha = $talpha || $2 || ''; $tfork = ''; } $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0; $tminorminor = 99 if $talpha ne '' && $tminorminor == 0; # 2.0 is better than 1.0. # 1.2 is better than 1.1. # 1.2a is better than 1.2. # If we require 3.4n-foo then we require something # >= 3.4n, with the `foo' fork identifier. # The $r* variables are what the user specified. # The $t* variables denote automake itself. if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor) || ($rminor == $tminor && $rminor == $tminor && $rminorminor > $tminorminor) || ($rminor == $tminor && $rminor == $tminor && $rminorminor == $tminorminor && $ralpha gt $talpha) || ($rfork ne '' && $rfork ne $tfork)) { &am_line_error ('AUTOMAKE_OPTIONS', "require version $_, but have $VERSION"); return 1; } return 0;}# Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.sub handle_options{ if (&variable_defined ('AUTOMAKE_OPTIONS')) { foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', '')) { $options{$_} = 1; if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign') { &set_strictness ($_); } elsif ($_ eq 'cygnus') { $cygnus_mode = 1; } elsif (/ansi2knr/) { # An option like "../lib/ansi2knr" is allowed. With # no path prefix, we assume the required programs are # in this directory. We save the actual option for # later. $options{'ansi2knr'} = $_; } elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo' || $_ eq 'dist-shar' || $_ eq 'dist-zip' || $_ eq 'dist-tarZ' || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex' || $_ eq 'readme-alpha' || $_ eq 'check-news') { # Explicitly recognize these. } elsif ($_ eq 'no-dependencies') { $use_dependencies = 0; } elsif (/([0-9]+)\.([0-9]+)([a-z]?)(-[A-Za-z0-9]+)?/) { # Got a version number. if (version_check ($1, $2, $3, $4)) { return 1; } } else { &am_line_error ('AUTOMAKE_OPTIONS', "option \`" . $_ . "\' not recognized"); } } } if ($strictness == $GNITS) { $options{'readme-alpha'} = 1; $options{'check-news'} = 1; } return 0;}# Return object extension. Just once, put some code into the output.# Argument is the name of the output filesub get_object_extension{ local ($out) = @_; # Maybe require libtool library object files. local ($extension) = '.o'; $extension = '.$(OBJEXT)' if $seen_objext; $extension = '.lo' if ($out =~ /\.la$/); if (! $included_generic_compile) { # Boilerplate. local ($xform) = ''; if (&variable_defined ('CONFIG_HEADER')) { local ($one_hdr); foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER'))) { local ($var); ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g; $xform .= ' ' if $xform; $xform .= '-I' . $var; } } $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;'; $output_vars .= &file_contents_with_transform ($xform, 'comp-vars'); $xform = (($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;') . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')); $output_rules .= &file_contents_with_transform ($xform, 'compile'); &push_phony_cleaners ('compile'); # If using X, include some extra variable definitions. NOTE # we don't want to force these into CFLAGS or anything, # because not all programs will necessarily use X. if ($seen_path_xtra) { local ($var); foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS') { &define_configure_variable ($var); } } push (@suffixes, '.c', '.o', '.S', '.s'); push (@suffixes, '.obj') if $seen_objext; push (@clean, 'compile'); $included_generic_compile = 1; } if ($seen_libtool && ! $included_libtool_compile) { # Output the libtool compilation rules. $output_rules .= &file_contents_with_transform ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;', 'libtool'); &push_phony_cleaners ('libtool'); push (@suffixes, '.lo'); push (@clean, 'libtool'); $included_libtool_compile = 1; } # Check for automatic de-ANSI-fication. if (defined $options{'ansi2knr'}) { $extension = '$U' . $extension; if (! $included_knr_compile) { if (! $am_c_prototypes) { &am_line_error ('AUTOMAKE_OPTIONS', "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in \`$configure_ac'"); &keyed_aclocal_warning ('AM_C_PROTOTYPES'); # Only give this error once. $am_c_prototypes = 1; } # Only require ansi2knr files if they should appear in # this directory. if ($options{'ansi2knr'} eq 'ansi2knr') { &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN, 'ansi2knr.c', 'ansi2knr.1'); $output_rules .= &file_contents ('kr-extra'); push (@clean, 'krextra'); &push_phony_cleaners ('krextra'); } # Generate rules to build ansi2knr. If it is in some # other directory, then generate dependencies but have the # rule just run elsewhere. $objext = $seen_objext ? ".$(OBJEXT)" : ".o"; $output_rules .= ($options{'ansi2knr'} . ': ' . $options{'ansi2knr'} . $objext . "\n"); if ($options{'ansi2knr'} eq 'ansi2knr') { $output_rules .= ("\t\$(LINK) ansi2knr" . $objext . " \$(LIBS)\n" . "ansi2knr" . $objext . ": \$(CONFIG_HEADER)\n\n"); } else { $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'}) . " && \$(MAKE) \$(AM_MAKEFLAGS) " . "ansi2knr\n\n"); # This is required for non-GNU makes. $output_rules .= ($options{'ansi2knr'} . $objext . ":\n"); $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'}) . " && \$(MAKE) \$(AM_MAKEFLAGS)"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -