5 eval "exec /usr/local/bin/perl -S $0 $*"
6 if $running_under_some_shell;
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
26 # Perl reimplementation by Tom Tromey <tromey@drip.colorado.edu>.
29 # Parameters set by configure. Not to be changed.
30 $PACKAGE = "@PACKAGE@";
31 $VERSION = "@VERSION@";
33 $am_dir = "@datadir@/@PACKAGE@";
37 # This is TRUE if GNU make specific automatic dependency generation
38 # code should be included in generated Makefile.in.
39 $use_dependencies = 1;
41 # This holds our (eventual) exit status. We don't actually exit until
42 # we have processed all input files.
45 # These two variables are used when generating each Makefile.in. They
46 # hold the Makefile.in until it is ready to be printed.
51 # Suffixes found during a run.
54 # This holds the contents of a Makefile.am, as parsed by read_am_file.
57 # This holds the "relative directory" of the current Makefile.in. Eg
58 # for src/Makefile.in, this is "src".
61 # Directory where output files go. Actually, output files are
62 # relative to this directory.
63 $output_directory = '.';
65 # This holds a list of files that are included in the distribution.
68 # List of dependencies for the obvious targets.
80 # TRUE if current directory holds any C source files.
81 $dir_holds_sources = 0;
83 # TRUE if install targets should work recursively.
84 $recursive_install = 0;
91 @input_files = &parse_arguments (@ARGV);
93 # Now do all the work on each file.
94 foreach $am_file (@input_files)
96 if (! -f ($am_file . '.am'))
98 print STDERR "automake: $am_file" . ".am: no such file\n";
103 &generate_makefile ($am_file);
110 ################################################################
112 # Parse command line.
115 local (@arglist) = @_;
118 while ($#arglist >= 0)
120 if ($arglist[0] eq "--version")
122 print "Automake version $VERSION\n";
125 elsif ($arglist[0] eq "--help")
129 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
133 elsif ($arglist[0] eq '--amdir')
138 "automake: no argument given for option \`$arglist[0]'\n";
142 $am_dir = $arglist[0];
144 elsif ($arglist[0] eq '--include-deps')
146 $use_dependencies = 0;
148 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
150 # Set output directory.
151 $output_directory = $1;
153 elsif ($arglist[0] eq '--output-dir')
158 "automake: no argument given for option \`$arglist[0]'\n";
162 $output_directory = $arglist[0];
164 elsif ($arglist[0] eq '--')
166 # Stop option processing.
168 push (@make_list, @arglist);
171 elsif ($arglist[0] =~ /^-/)
173 print STDERR "automake: unrecognized option -- \`$arglist[0]'\n";
178 push (@make_list, $arglist[0]);
186 # Look around for some files.
187 push (@make_list, 'Makefile') if -f 'Makefile.am';
189 foreach (<*/Makefile.am>)
192 push (@make_list, $_);
195 if ($#make_list >= 0)
197 print "automake: using ", join (' ', @make_list), "\n";
201 print STDERR "automake: no \"Makefile.am\" found or specified\n";
209 ################################################################
211 # Generate a Makefile.in given the name of the corresponding Makefile.
212 sub generate_makefile
214 local ($makefile) = @_;
216 print "creating ", $makefile, ".in\n";
218 $relative_dir = &dirname ($makefile);
221 $output_trailer = '';
224 # FIXME with new 'dist' target, don't need Makefile.in. Probably
225 # should remove it here.
226 @dist_common = ('Makefile.in', 'Makefile.am');
231 $dir_holds_sources = 0;
232 $recursive_install = 0;
239 # Generate header before reading .am file. The header must come
240 # before anything else, and read_am_file copies code into the
244 # This is always the default target. This gives us freedom to do
245 # things in whatever order is convenient.
246 $output_rules .= "default: all\n\n";
248 &read_am_file ($makefile . '.am');
251 local ($programs) = &am_variable ('PROGRAMS');
252 local ($libprograms) = &am_variable ('AM_LIBPROGRAMS');
253 local ($libraries) = &am_variable ('AM_LIBRARIES');
254 local ($scripts) = &am_variable ('AM_SCRIPTS');
255 local ($libscripts) = &am_variable ('AM_LIBSCRIPTS');
257 &handle_programs ($programs, $libprograms, $libraries);
258 &handle_scripts ($scripts, $libscripts);
259 &handle_libraries ($libraries);
268 &handle_dependencies;
270 &handle_merge_targets;
274 if (! -d ($output_directory . '/' . $relative_dir))
276 &mkdir ($output_directory . '/' . $relative_dir);
278 if (! open (GM_FILE, "> " . $output_directory . '/' . $makefile . ".in"))
280 print STDERR "automake: cannot open ", $makefile, ".in: ", $!, "\n";
285 print GM_FILE $output_vars;
286 print GM_FILE $output_rules;
287 print GM_FILE $output_trailer;
292 ################################################################
294 # Generate header of Makefile.in.
299 . "# Makefile.in generated automatically by automake "
301 . " from Makefile.am\n");
303 $output_vars = $output_vars . &file_contents ('header-vars');
306 # Handle C programs and libraries.
309 local ($programs, $libprograms, $libraries) = @_;
311 if (!$programs && !$libprograms && !$libraries)
316 $dir_holds_sources = 1;
319 $output_vars .= &file_contents ('compile-vars');
320 $output_rules .= &file_contents ('compile');
322 # Check for automatic de-ANSI-fication.
324 push (@suffixes, '.c', '.o');
325 push (@clean, 'compile');
327 if (defined $contents{'@kr@'})
330 push (@suffixes, '._c', '._o');
332 &require_file ('ansi2knr.c');
333 &require_file ('ansi2knr.1');
335 $output_vars .= &file_contents ('kr-vars');
336 $output_rules .= &file_contents ('compile-kr');
337 $output_rules .= &file_contents ('clean-kr');
342 local (@sources, @objects);
343 push (@sources, '${SOURCES}') if (defined $contents{'SOURCES'});
344 push (@objects, '${OBJECTS}') if (defined $contents{'OBJECTS'});
347 foreach $one_file (split (' ', ($programs . ' '
351 # Look for file_SOURCES and file_OBJECTS. FIXME file_OBJECTS
352 # should probably not be used(?)
353 if (defined $contents{$one_file . "_SOURCES"})
355 if (! defined $contents{$one_file . "_OBJECTS"})
357 # Turn sources into objects.
358 $_ = $contents{$one_file . "_SOURCES"};
360 # Ugh: Perl syntax vs Emacs.
361 local ($krc1, $krc2) = ('\.\$\{kr\}c', '\.\$\(kr\)c');
366 s/\.[cCmylfs]/$obj/g;
368 $output_vars .= $one_file . "_OBJECTS = " . $_ . "\n";
371 push (@sources, '${' . $one_file . "_SOURCES}");
372 push (@objects, '${' . $one_file . "_OBJECTS}");
376 $output_vars .= ($one_file . "_SOURCES = " . $one_file . ".c\n"
377 . $one_file . "_OBJECTS = ". $one_file
379 push (@sources, $one_file . '.c');
380 push (@objects, $one_file . $obj);
383 if (defined $contents{'CONFIG_HEADER'})
385 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
386 . $contents{'CONFIG_HEADER'} . "\n");
390 $output_vars .= "\n";
392 # Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
394 $contents{'SOURCES'} = join (' ', @sources);
395 $contents{'OBJECTS'} = join (' ', @objects);
397 # Some boilerplate, and install rules.
400 $output_rules .= &file_contents ('programs');
401 push (@install_exec, "install-programs");
402 push (@uninstall, 'uninstall-programs');
403 push (@clean, 'programs');
404 push (@installdirs, '$(bindir)');
408 $output_rules .= &file_contents ('libprograms');
409 push (@install_exec, 'install-libprograms');
410 push (@uninstall, 'uninstall-libprograms');
411 push (@clean, 'libprograms');
412 push (@installdirs, '$(libexecdir)');
416 if ($programs || $libprograms)
418 local ($fcont) = &file_contents ('program');
420 foreach $one_file (split (' ', $programs . ' ' . $libprograms))
422 if (! defined $contents{$one_file . "_LDADD"})
424 # User didn't define prog_LDADD override. So do it.
425 $output_vars .= $one_file . '_LDADD = ${LDADD}' . "\n";
428 ($munge = $fcont) =~ s/\@PROGRAM\@/$one_file/g;
429 $output_rules .= $munge;
437 local ($libraries) = @_;
439 return if (!$libraries);
441 local (@liblist) = split (' ', $libraries);
443 $output_rules .= &file_contents ('libraries');
444 local ($onefile) = &file_contents ('library');
445 local ($onelib, $munge);
446 foreach $onelib (@liblist)
448 if (! defined $contents{$onelib . '_LIBADD'})
450 # Generate support for conditional objection inclusion in
452 $output_vars .= $onelib . "_LIBADD =\n";
455 ($munge = $onefile) =~ s/\@LIBRARY\@/$onelib/g;
456 $output_rules .= $munge;
459 # Turn "foo" into "libfoo.a" and include macro definition.
460 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
461 $output_vars .= ("LIBFILES = " . join (' ', @liblist) . "\n\n"
462 . &file_contents ('libraries-vars'));
464 push (@install_exec, 'install-libraries');
465 push (@uninstall, 'uninstall-libraries');
466 push (@clean, 'libraries');
472 local ($scripts, $libscripts) = @_;
476 $output_rules .= &file_contents ('scripts');
477 push (@install_exec, 'install-scripts');
478 push (@uninstall, 'uninstall-scripts');
479 push (@clean, 'scripts');
480 push (@installdirs, '$(bindir)');
485 $output_rules .= &file_contents ('libscripts');
486 push (@install_exec, 'install-libscripts');
487 push (@uninstall, 'uninstall-libscripts');
488 push (@clean, 'libscripts');
489 push (@installdirs, '$(libexecdir');
493 # Handle all Texinfo source.
496 local ($texis) = &am_variable ('TEXINFOS');
499 local (@texis) = split (' ', $texis);
502 print STDERR "automake: sorry, only one file allowed in \`TEXINFOS'\n";
508 ($infobase = $texis[0]) =~ s/\.texi$//;
510 # If 'version.texi' is referenced by input file, then include
511 # automatic versioning capability.
512 system ("grep version.texi " . $relative_dir . "/" . $texis[0]
513 . " > /dev/null 2>&1");
517 push (@texis, 'version.texi');
518 push (@dist_common, 'version.texi', 'stamp-vti');
519 push (@clean, 'vti');
522 ($tfile = &file_contents ('texi-version')) =~ s/\@TEXI\@/$texis[0]/g;
523 $output_rules = $output_rules . $tfile;
525 &require_file ('mdate-sh');
528 # If user specified file_TEXINFOS, then use that as explicit
530 if (defined $contents{$infobase . "_TEXINFOS"})
532 push (@texis, "\$" . $infobase . '_TEXINFOS');
533 push (@dist_common, "\$" . $infobase . '_TEXINFOS');
538 $output_rules = ($output_rules . $infobase . ".info: "
539 . join (' ', @texis) . "\n\n");
543 $output_vars = $output_vars . &file_contents ('texinfos-vars');
544 $output_rules = $output_rules . &file_contents ('texinfos');
546 push (@suffixes, '.texi', '.info', '.dvi');
547 push (@uninstall, 'uninstall-info');
548 push (@clean, 'info');
549 push (@info, '$(INFO_DEPS)');
550 push (@dvi, '$(DVIS)');
551 push (@installdirs, '$(infodir)');
552 # Make sure documentation is made and installed first.
553 unshift (@install_data, 'install-info');
554 unshift (@all, 'info');
556 $output_vars .= ("INFOS = " . $infobase . ".info*\n"
557 . "INFO_DEPS = " . $infobase . ".info\n"
558 . "DVIS = " . $infobase . ".dvi\n\n");
560 # Do some error checking.
561 &require_file ('texinfo.tex');
564 # Handle any man pages.
567 return if (! defined $contents{'MANS'});
569 # We generate the manpage install code by hand to avoid the use of
570 # basename in the generated Makefile.
571 local (@mans) = split (' ', $contents{'MANS'});
572 local (%sections, %inames, %secmap, %fullsecmap);
575 m/^(.*)\.([0-9])([a-z]*)$/;
579 $fullsecmap{$1} = $2 . $3;
582 # Generate list of install dirs.
583 $output_rules .= "install-man:\n";
584 foreach (keys %sections)
586 push (@installdirs, '$(mandir)/man' . $_);
587 $output_rules .= ("\t" . '$(top_srcdir)/mkinstalldirs $(mandir)/man'
591 # Generate install target.
593 foreach $key (keys %inames)
595 $_ = $install_man_format;
596 s/\@SECTION\@/$secmap{$key}/g;
597 s/\@MAN\@/$inames{$key}/g;
598 s/\@FULLSECT\@/$fullsecmap{$key}/g;
599 s/\@MANBASE\@/$key/g;
602 $output_rules .= "\n";
604 $output_rules .= "uninstall-man:\n";
605 foreach $key (keys %inames)
607 $_ = $uninstall_man_format;
608 s/\@SECTION\@/$secmap{$key}/g;
609 s/\@MAN\@/$inames{$key}/g;
610 s/\@FULLSECT\@/$fullsecmap{$key}/g;
611 s/\@MANBASE\@/$key/g;
614 $output_rules .= "\n";
616 $output_vars .= &file_contents ('mans-vars');
618 push (@install_data, 'install-man');
619 push (@uninstall, 'uninstall-man');
620 push (@all, '$(MANS)');
623 # Handle DATA and PACKAGEDATA.
626 if (defined $contents{'DATA'})
628 $output_rules .= &file_contents ('data');
629 push (@install_data, 'install-ddata');
630 push (@uninstall, 'uninstall-ddata');
631 push (@installdirs, '$(datadir)');
634 if (defined $contents{'PACKAGEDATA'})
636 $output_rules .= &file_contents ('packagedata');
637 push (@install_data, 'install-pdata');
638 push (@uninstall, 'uninstall-pdata');
639 push (@installdirs, '$(datadir)/$(PACKAGE)');
646 local ($tagging) = 0;
648 if (defined ($contents{'SUBDIRS'}))
650 $output_rules .= &file_contents ('tags');
653 elsif ($dir_holds_sources || defined ($contents{'ETAGS_ARGS'}))
655 $output_rules .= &file_contents ('tags-subd');
661 $output_rules .= &file_contents ('tags-clean');
662 push (@clean, 'tags');
666 # Handle 'dist' target.
669 # Look for common files that should be included in distribution.
671 foreach $cfile (@common_files)
673 if (-f ($relative_dir . "/" . $cfile))
675 push (@dist_common, $cfile);
679 $output_vars .= "DIST_COMMON = " . join (' ', @dist_common) . "\n\n";
682 $output_vars .= &file_contents ('dist-vars');
683 if ($relative_dir ne '.')
686 $output_vars .= "subdir = " . $relative_dir . "\n\n";
687 $output_rules .= &file_contents ('dist-subd');
691 $output_rules .= &file_contents (defined ($contents{'SUBDIRS'})
697 # Handle auto-dependency code.
698 sub handle_dependencies
700 if ($use_dependencies)
702 # Include GNU-make-specific auto-dep code.
703 if ($dir_holds_sources)
705 $output_rules .= &file_contents ('depend');
710 # Include any auto-generated deps that are present.
711 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
714 local ($gpat) = $relative_dir . "/.deps/*.P";
716 foreach $depfile (<${gpat}>)
718 if (! open (DEP_FILE, $depfile))
720 print STDERR "automake: couldn't open $depfile: $!\n";
725 $output_rules .= join ('', <DEP_FILE>);
730 $output_rules .= "\n";
735 # Handle subdirectories.
738 return if (! defined ($contents{'SUBDIRS'}));
740 $output_rules .= &file_contents ('subdirs');
742 push (@all, "all-recursive");
743 push (@check, "check-recursive");
744 push (@info, "info-recursive");
745 push (@dvi, "dvi-recursive");
747 $recursive_install = 1;
750 # Handle remaking and configure stuff.
753 if ($relative_dir ne '.')
756 $output_rules .= &file_contents ('remake-subd');
762 $output_vars .= "ACLOCAL = aclocal.m4\n";
763 push (@dist_common, 'aclocal.m4');
765 $output_rules .= &file_contents ('remake');
767 # Look for some files we need.
768 &require_file ('install-sh');
769 &require_file ('mkinstalldirs');
772 if (defined ($contents{'CONFIG_HEADER'})
773 && $contents{'CONFIG_HEADER'} !~ m,/,)
775 # Header defined and in this directory.
778 $output_vars .= "ACCONFIG = acconfig.h\n";
779 push (@dist_common, 'acconfig.h');
781 if (-f 'config.h.top')
783 $output_vars .= "CONFIG_TOP = config.h.top\n";
784 push (@dist_common, 'config.h.top');
786 if (-f 'config.h.bot')
788 $output_vars .= "CONFIG_BOT = config.h.bot\n";
789 push (@dist_common, 'config.h.bot');
792 push (@dist_common, 'stamp-h.in', $contents{'CONFIG_HEADER'} . '.in');
794 $output_rules .= &file_contents ('remake-hdr');
798 # Handle footer elements.
801 if ($contents{'SOURCES'})
803 $output_vars .= "SOURCES = " . $contents{'SOURCES'} . "\n";
805 if ($contents{'OBJECTS'})
807 $output_vars .= "OBJECTS = " . $contents{'OBJECTS'} . "\n";
809 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
811 $output_vars .= "\n";
814 if (defined $contents{'SUFFIXES'})
816 push (@suffixes, '$(SUFFIXES)');
819 $output_trailer .= ".SUFFIXES:\n";
822 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
824 $output_trailer .= "\n" . &file_contents ('footer');
827 # Deal with installdirs target.
828 sub handle_installdirs
830 # GNU Makefile standards recommend this. FIXME prettyprint rule
832 $output_rules .= ("installdirs:"
833 . ($recursive_install
834 ? " installdirs-recursive\n"
836 if ($#installdirs >= 0)
838 $output_rules .= ("\t\$(top_srcdir)/mkinstalldirs "
839 . join (' ', @installdirs)
842 $output_rules .= "\n";
845 # There are several targets which need to be merged. This is because
846 # their complete definition is compiled from many parts. Note that we
847 # avoid double colon rules, otherwise we'd use them instead.
848 sub handle_merge_targets
850 &do_one_merge_target ('all', @all);
851 &do_one_merge_target ('info', @info);
852 &do_one_merge_target ('dvi', @dvi);
853 &do_one_merge_target ('check', @check);
855 # Handle the various install targets specially. We do this so
856 # that (eg) "make install-exec" will run "install-exec-recursive"
857 # if required, but "make install" won't run it twice. Step one is
858 # to see if the user specified local versions of any of the
860 if (defined $contents{'install-exec-local'})
862 push (@install_exec, 'install-exec-local');
864 if (defined $contents{'install-data-local'})
866 push (@install_data, 'install-data-local');
868 if (defined $contents{'uninstall-local'})
870 push (@uninstall, 'uninstall-local');
873 if (defined $contents{'install-local'})
875 print STDERR "automake: use \`install-data' or \`install-exec', not \`install'\n";
878 # Step two: if we are doing recursive makes, write out the
881 if ($recursive_install)
883 push (@install, 'install-recursive');
884 push (@uninstall, 'uninstall-recursive');
886 if ($#install_exec >= 0)
888 $output_rules .= ('install-exec-am: '
889 . join (' ', @install_exec)
891 @install_exec = ('install-exec-recursive', 'install-exec-am');
892 push (@install, 'install-exec-am');
894 if ($#install_data >= 0)
896 $output_rules .= ('install-data-am: '
897 . join (' ', @install_data)
899 @install_data = ('install-data-recursive', 'install-data-am');
900 push (@install, 'install-data-am');
902 if ($#uninstall >= 0)
904 $output_rules .= ('uninstall-am: '
905 . join (' ', @uninstall)
907 @uninstall = ('uninstall-recursive', 'uninstall-am');
911 # Step three: print definitions users can use.
912 if ($#install_exec >= 0)
914 $output_rules .= ("install-exec: "
915 . join (' ', @install_exec)
917 push (@install, 'install-exec') if (!$recursive_install);
919 if ($#install_data >= 0)
921 $output_rules .= ("install-data: "
922 . join (' ', @install_data)
924 push (@install, 'install-data') if (!$recursive_install);
927 $output_rules .= ('install: '
928 . join (' ', @install)
931 . join (' ', @uninstall)
935 # Helper for handle_merge_targets.
936 sub do_one_merge_target
938 local ($name, @values) = @_;
940 if (defined $contents{$name . '-local'})
942 # User defined local form of target. So include it.
943 push (@values, $name . '-local');
946 $output_rules .= $name . ": " . join (' ', @values) . "\n\n";
949 # Handle all 'clean' targets.
952 push (@clean, 'generic');
953 $output_rules .= &file_contents ('clean');
955 local ($target) = $recursive_install ? 'clean-am' : 'clean';
956 &do_one_clean_target ($target, 'mostly', '', @clean);
957 &do_one_clean_target ($target, '', 'mostly', @clean);
958 &do_one_clean_target ($target, 'dist', '', @clean);
959 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
962 if ($recursive_install)
964 @deps = ('am', 'recursive');
965 &do_one_clean_target ('', 'mostly', '', @deps);
966 &do_one_clean_target ('', '', '', @deps);
967 &do_one_clean_target ('', 'dist', '', @deps);
968 &do_one_clean_target ('', 'maintainer-', '', @deps);
972 # Helper for handle_clean.
973 sub do_one_clean_target
975 local ($target, $name, $last_name, @deps) = @_;
977 # Special case: if target not passed, then don't generate
978 # dependency on next "lower" clean target (eg no
979 # clean<-mostlyclean derivation). In this case the target is
980 # implicitly known to be 'clean'.
981 local ($flag) = $target;
987 $output_rules .= $name . $target . ": ";
990 if ($last_name || $name ne 'mostly')
992 $output_rules .= $last_name . $target . " ";
996 $output_rules .= ($name . 'clean-' . join (' ' . $name . 'clean-', @deps)
999 # FIXME shouldn't we really print these messages before running
1001 if ($name . $target eq 'maintainer-clean')
1003 # Print a special warning.
1005 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
1006 . "\t\@echo \"it deletes files that may require special "
1007 . "tools to rebuild.\"\n");
1009 $output_rules .= "\n";
1012 ################################################################
1014 # Read Makefile.am and set up %contents. Simultaneously copy lines
1015 # from Makefile.am into $output_trailer or $output_vars as
1016 # appropriate. NOTE we put rules in the trailer section. We want
1017 # user rules to come after our generated stuff.
1020 local ($amfile) = @_;
1022 if (! open (AMFILE, $amfile))
1024 print STDERR "automake: couldn't open $amfile: $!\n";
1028 local ($saw_bk) = 0;
1029 local ($was_rule) = 0;
1030 local ($last_var_name) = '';
1040 $output_trailer .= $_ . "\n";
1044 $output_vars .= $_ . "\n";
1045 if (substr ($_, -1) eq "\\")
1047 $contents{$last_var_name} .= substr ($_, 0,
1052 $contents{$last_var_name} .= $_;
1056 elsif ($_ eq '@kr@')
1058 # Special case: this means we want automatic
1059 # de-ANSI-fication. FIXME think of a better way.
1060 $contents{'@kr@'} = 1;
1062 elsif (m/^ *([a-zA-Z_.][a-zA-Z0-9_.]*) *:/)
1066 # Value here doesn't matter; for targets we only note
1069 $output_trailer .= $_ . "\n";
1071 elsif (m/^ *([A-Za-z][A-Za-z0-9_]*)[ ]*=[ ]*(.*)$/)
1073 # Found a variable reference.
1075 $last_var_name = $1;
1076 if (substr ($2, -1) eq "\\")
1078 $contents{$1} = substr ($2, 0, length ($2) - 1);
1084 $output_vars .= $_ . "\n";
1088 # Special rule: if looking at a blank line, append it to
1089 # whatever we saw last.
1092 $output_trailer .= "\n";
1096 $output_vars .= "\n";
1101 # This isn't an error; it is probably a continued rule.
1102 # In fact, this is what we assume.
1103 $output_trailer .= $_ . "\n";
1106 $saw_bk = (substr ($_, -1) eq "\\");
1109 # Include some space after user code.
1110 $output_vars .= "\n";
1111 $output_trailer .= "\n";
1114 ################################################################
1116 # Initialize global variables.
1119 # Helper text for dealing with man pages.
1120 $install_man_format =
1121 ' sect=@SECTION@; \\
1122 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
1123 echo installing @MAN@ as $(mandir)/man$$sect/$$inst; \\
1124 $(INSTALL_DATA) $(srcdir)/@MAN@ $(mandir)/man$$sect/$$inst; \\
1125 if test -d $(mandir)/cat$$sect; then \\
1126 echo formatting @MAN@ as $(mandir)/cat$$sect/$$inst; \\
1127 $(NROFF) -man $(srcdir)/@MAN@ > $(mandir)/cat$$sect/$$inst; \\
1133 $uninstall_man_format =
1134 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
1135 rm -f $(mandir)/man@SECTION@/$$inst $(mandir)/cat@SECTION@/$$inst
1138 # Commonly found files we look for and automatically include in
1142 "THANKS", "TODO", "README", "NEWS", "COPYING", "COPYING.LIB",
1143 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
1144 "config.guess", "config.sub"
1147 # Commonly used files we auto-include, but only sometimes.
1150 "version.texi", "aclocal.m4", "acconfig.h", "config.h.top",
1151 "config.h.bot", "stamp-h.in", "mdate-sh", "ansi2knr.c",
1152 "ansi2knr.1", 'stamp-vti', "mkinstalldirs", "install-sh"
1156 --amdir=DIR directory storing config files
1157 --help print this help, then exit
1158 --include-deps include generated dependencies in Makefile.in
1159 --output-dir=DIR put generated Makefile.in's into DIR
1160 --version print version number, then exit\n";
1164 ################################################################
1166 # Return contents of a file from $am_dir.
1169 local ($basename) = @_;
1170 local ($file) = $am_dir . '/' . $basename . '.am';
1172 if (! open (FC_FILE, $file))
1174 print STDERR "automake: installation error: cannot open \"$file\"\n";
1178 # Yes, we really want to slurp it.
1179 local ($results) = join ('', <FC_FILE>);
1186 # Return contents of some Makefile.am variable. Allow for AM_ style
1190 local ($varname) = @_;
1192 return (defined ($contents{'AM_' . $varname})
1193 ? $contents{'AM_' . $varname}
1194 : $contents{$varname});
1197 ################################################################
1199 # Verify that the file must exist in the current directory.
1203 local ($fullfile) = $relative_dir . "/" . $file;
1207 print STDERR "automake: required file \"$fullfile\" not found\n";
1212 push (@dist_common, $file);
1217 ################################################################
1219 # Return directory name of file.
1225 ($sub = $file) =~ s,/+[^/]+,,g;
1237 local ($dirname) = @_;
1238 system ("mkdir", $dirname);
1241 ################################################################
1243 # Print usage information.
1246 print "Usage: automake [OPTION] ... [Makefile]...\n";
1248 print "\nFiles which are automatically distributed, if found:\n";
1249 $~ = "USAGE_FORMAT";
1250 local (@lcomm) = sort ((@common_files, @common_sometimes));
1252 while ($#lcomm >= 0)
1254 $one = shift (@lcomm);
1255 $two = shift (@lcomm);
1262 format USAGE_FORMAT =
1263 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<