automake.in
来自「LINUX下的源码工具,可自己分析,或者直接装在系统上作为应用」· IN 代码 · 共 2,342 行 · 第 1/5 页
IN
2,342 行
} 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.in'))[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);}################################################################# 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])?/) { # Got a version number. local ($rmajor, $rminor, $ralpha) = ($1, $2, $3); if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/) { print STDERR "automake: programming error: version is incorrect\n"; exit 1; } local ($tmajor, $tminor, $talpha) = ($1, $2, $3); # 2.0 is better than 1.0. # 1.2 is better than 1.1. # 1.2a is better than 1.2. if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor) || ($rminor == $tminor && $rminor == $tminor && $ralpha gt $talpha)) { &am_line_error ('AUTOMAKE_OPTIONS', "require version $_, only have $VERSION"); 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.in"); &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)" . " ansi2knr" . $objext . "\n\n"); } # Make sure ansi2knr can be found: if no path specified, # specify "./". if ($options{'ansi2knr'} eq 'ansi2knr') { # Substitution from AM_C_PROTOTYPES. This makes it be # built only when necessary. &define_configure_variable ('ANSI2KNR'); # ansi2knr needs to be built before subdirs, so unshift it. unshift (@all, '$(ANSI2KNR)'); } else { # Found in another directory. &define_variable ("ANSI2KNR", $options{'ansi2knr'}); } $output_rules .= &file_contents ('clean-kr'); push (@clean, 'kr'); &push_phony_cleaners ('kr'); $included_knr_compile = 1; } } return $extension;}# Call finish function for each language that was used.sub finish_languages{ local ($ext, $name, $lang, %done); local ($non_c) = 1; foreach $ext (sort keys %extension_seen) { $lang = $extension_map{$ext}; next if defined $done{$lang}; $done{$lang} = 1; $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/; # Compute the function name of the finisher and then call it. $name = 'lang_' . $lang . '_finish'; do $name (); } # If the project is entirely C++ or entirely Fortran 77, don't # bother with the C stuff. But if anything else creeps in, then use # it. if (! $non_c || scalar keys %suffix_rules > 0)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?