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) = (defined ($contents{'AM_PROGRAMS'})
252 ? $contents{'AM_PROGRAMS'}
253 : $contents{'PROGRAMS'});
254 local ($libprograms) = (defined ($contents{'AM_LIBPROGRAMS'})
255 ? $contents{'AM_LIBPROGRAMS'}
256 : $contents{'LIBPROGRAMS'});
257 local ($libraries) = (defined ($contents{'AM_LIBRARIES'})
258 ? $contents{'AM_LIBRARIES'}
259 : $contents{'LIBRARIES'});
260 local ($scripts) = (defined ($contents{'AM_SCRIPTS'})
261 ? $contents{'AM_SCRIPTS'}
262 : $contents{'SCRIPTS'});
263 local ($libscripts) = (defined ($contents{'AM_LIBSCRIPTS'})
264 ? $contents{'AM_LIBSCRIPTS'}
265 : $contents{'LIBSCRIPTS'});
267 &handle_programs ($programs, $libprograms, $libraries);
268 &handle_scripts ($scripts, $libscripts);
269 &handle_libraries ($libraries);
278 &handle_dependencies;
280 &handle_merge_targets;
284 if (! open (GM_FILE, "> " $output_directory . '/' . $makefile . ".in"))
286 print STDERR "automake: cannot open ", $makefile, ".in: ", $!, "\n";
291 print GM_FILE $output_vars;
292 print GM_FILE $output_rules;
293 print GM_FILE $output_trailer;
298 ################################################################
300 # Generate header of Makefile.in.
305 . "# Makefile.in generated automatically by automake "
307 . " from Makefile.am\n");
309 $output_vars = $output_vars . &file_contents ('header-vars');
312 # Handle C programs and libraries.
315 local ($programs, $libprograms, $libraries) = @_;
317 if (!$programs && !$libprograms && !$libraries)
322 $dir_holds_sources = 1;
325 $output_vars .= &file_contents ('compile-vars');
326 $output_rules .= &file_contents ('compile');
328 # Check for automatic de-ANSI-fication.
330 push (@suffixes, '.c', '.o');
331 push (@clean, 'compile');
333 if (defined $contents{'@kr@'})
336 push (@suffixes, '._c', '._o');
338 &require_file ('ansi2knr.c');
339 &require_file ('ansi2knr.1');
341 $output_vars .= &file_contents ('kr-vars');
342 $output_rules .= &file_contents ('compile-kr');
343 $output_rules .= &file_contents ('clean-kr');
348 local (@sources, @objects);
349 push (@sources, '${SOURCES}') if (defined $contents{'SOURCES'});
350 push (@objects, '${OBJECTS}') if (defined $contents{'OBJECTS'});
353 foreach $one_file (split (' ', ($programs . ' '
357 # Look for file_SOURCES and file_OBJECTS. FIXME file_OBJECTS
358 # should probably not be used(?)
359 if (defined $contents{$one_file . "_SOURCES"})
361 if (! defined $contents{$one_file . "_OBJECTS"})
363 # Turn sources into objects.
364 $_ = $contents{$one_file . "_SOURCES"};
366 # Ugh: Perl syntax vs Emacs.
367 local ($krc1, $krc2) = ('\.\$\{kr\}c', '\.\$\(kr\)c');
372 s/\.[cCmylfs]/$obj/g;
374 $output_vars .= $one_file . "_OBJECTS = " . $_ . "\n";
377 push (@sources, '${' . $one_file . "_SOURCES}");
378 push (@objects, '${' . $one_file . "_OBJECTS}");
382 $output_vars .= ($one_file . "_SOURCES = " . $one_file . ".c\n"
383 . $one_file . "_OBJECTS = ". $one_file
385 push (@sources, $one_file . '.c');
386 push (@objects, $one_file . $obj);
389 if (defined $contents{'CONFIG_HEADER'})
391 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
392 . $contents{'CONFIG_HEADER'} . "\n");
396 $output_vars .= "\n";
398 # Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
400 $contents{'SOURCES'} = join (' ', @sources);
401 $contents{'OBJECTS'} = join (' ', @objects);
403 # Some boilerplate, and install rules.
406 $output_rules .= &file_contents ('programs');
407 push (@install_exec, "install-programs");
408 push (@uninstall, 'uninstall-programs');
409 push (@clean, 'programs');
410 push (@installdirs, '$(bindir)');
414 $output_rules .= &file_contents ('libprograms');
415 push (@install_exec, 'install-libprograms');
416 push (@uninstall, 'uninstall-libprograms');
417 push (@clean, 'libprograms');
418 push (@installdirs, '$(libexecdir)');
422 if ($programs || $libprograms)
424 local ($fcont) = &file_contents ('program');
426 foreach $one_file (split (' ', $programs . ' ' . $libprograms))
428 if (! defined $contents{$one_file . "_LDADD"})
430 # User didn't define prog_LDADD override. So do it.
431 $output_vars .= $one_file . '_LDADD = ${LDADD}' . "\n";
434 ($munge = $fcont) =~ s/@PROGRAM@/$one_file/g;
435 $output_rules .= $munge;
443 local ($libraries) = @_;
445 return if (!$libraries);
447 local (@liblist) = split (' ', $libraries);
449 $output_rules .= &file_contents ('libraries');
450 local ($onefile) = &file_contents ('library');
451 local ($onelib, $munge);
452 foreach $onelib (@liblist)
454 ($munge = $onefile) =~ s/@LIBRARY@/$onelib/g;
455 $output_rules .= $munge;
458 # Turn "foo" into "libfoo.a" and include macro definition.
459 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
460 $output_vars .= ("LIBFILES = " . join (' ', @liblist) . "\n\n"
461 . &file_contents ('libraries-vars'));
463 push (@install_exec, 'install-libraries');
464 push (@uninstall, 'uninstall-libraries');
465 push (@clean, 'libraries');
471 local ($scripts, $libscripts) = @_;
475 $output_rules .= &file_contents ('scripts');
476 push (@install_exec, 'install-scripts');
477 push (@uninstall, 'uninstall-scripts');
478 push (@clean, 'scripts');
479 push (@installdirs, '$(bindir)');
484 $output_rules .= &file_contents ('libscripts');
485 push (@install_exec, 'install-libscripts');
486 push (@uninstall, 'uninstall-libscripts');
487 push (@clean, 'libscripts');
488 push (@installdirs, '$(libexecdir');
492 # Handle all Texinfo source.
495 return if (! defined $contents{TEXINFOS});
497 local (@texis) = split (' ', $contents{TEXINFOS});
500 print STDERR "automake: sorry, only one file allowed in \`TEXINFOS'\n";
506 ($infobase = $texis[0]) =~ s/\.texi$//;
508 # If 'version.texi' is referenced by input file, then include
509 # automatic versioning capability.
510 system ("grep version.texi " . $relative_dir . "/" . $texis[0]
511 . " > /dev/null 2>&1");
515 push (@texis, 'version.texi');
516 push (@dist_common, 'version.texi', 'stamp-vti');
517 push (@clean, 'vti');
520 ($tfile = &file_contents ('texi-version')) =~ s/@TEXI@/$texis[0]/g;
521 $output_rules = $output_rules . $tfile;
523 &require_file ('mdate-sh');
526 # If user specified file_TEXINFOS, then use that as explicit
528 if (defined $contents{$infobase . "_TEXINFOS"})
530 push (@texis, "\$" . $infobase . '_TEXINFOS');
531 push (@dist_common, "\$" . $infobase . '_TEXINFOS');
536 $output_rules = ($output_rules . $infobase . ".info: "
537 . join (' ', @texis) . "\n\n");
541 $output_vars = $output_vars . &file_contents ('texinfos-vars');
542 $output_rules = $output_rules . &file_contents ('texinfos');
544 push (@suffixes, '.texi', '.info', '.dvi');
545 push (@uninstall, 'uninstall-info');
546 push (@clean, 'info');
547 push (@info, '$(INFO_DEPS)');
548 push (@dvi, '$(DVIS)');
549 push (@installdirs, '$(infodir)');
550 # Make sure documentation is made and installed first.
551 unshift (@install_data, 'install-info');
552 unshift (@all, 'info');
554 $output_vars .= ("INFOS = " . $infobase . ".info*\n"
555 . "INFO_DEPS = " . $infobase . ".info\n"
556 . "DVIS = " . $infobase . ".dvi\n\n");
558 # Do some error checking.
559 &require_file ('texinfo.tex');
562 # Handle any man pages.
565 return if (! defined $contents{'MANS'});
567 # We generate the manpage install code by hand to avoid the use of
568 # basename in the generated Makefile.
569 local (@mans) = split (' ', $contents{'MANS'});
570 local (%sections, %inames, %secmap, %fullsecmap);
573 m/^(.*)\.([0-9])([a-z]*)$/;
577 $fullsecmap{$1} = $2 . $3;
580 # Generate list of install dirs.
581 $output_rules .= "install-man:\n";
582 foreach (keys %sections)
584 push (@installdirs, '$(mandir)/man' . $_);
585 $output_rules .= ("\t" . '$(top_srcdir)/mkinstalldirs $(mandir)/man'
589 # Generate install target.
591 foreach $key (keys %inames)
593 $_ = $install_man_format;
594 s/@SECTION@/$secmap{$key}/g;
595 s/@MAN@/$inames{$key}/g;
596 s/@FULLSECT@/$fullsecmap{$key}/g;
600 $output_rules .= "\n";
602 $output_rules .= "uninstall-man:\n";
603 foreach $key (keys %inames)
605 $_ = $uninstall_man_format;
606 s/@SECTION@/$secmap{$key}/g;
607 s/@MAN@/$inames{$key}/g;
608 s/@FULLSECT@/$fullsecmap{$key}/g;
612 $output_rules .= "\n";
614 $output_vars .= &file_contents ('mans-vars');
616 push (@install_data, 'install-man');
617 push (@uninstall, 'uninstall-man');
618 push (@all, '$(MANS)');
621 # Handle DATA and PACKAGEDATA.
624 if (defined $contents{'DATA'})
626 $output_rules .= &file_contents ('data');
627 push (@install_data, 'install-ddata');
628 push (@uninstall, 'uninstall-ddata');
629 push (@installdirs, '$(datadir)');
632 if (defined $contents{'PACKAGEDATA'})
634 $output_rules .= &file_contents ('packagedata');
635 push (@install_data, 'install-pdata');
636 push (@uninstall, 'uninstall-pdata');
637 push (@installdirs, '$(datadir)/$(PACKAGE)');
644 local ($tagging) = 0;
646 if (defined ($contents{'SUBDIRS'}))
648 $output_rules .= &file_contents ('tags');
651 elsif ($dir_holds_sources || defined ($contents{'ETAGS_ARGS'}))
653 $output_rules .= &file_contents ('tags-subd');
659 $output_rules .= &file_contents ('tags-clean');
660 push (@clean, 'tags');
664 # Handle 'dist' target.
667 # Look for common files that should be included in distribution.
669 foreach $cfile (@common_files)
671 if (-f ($relative_dir . "/" . $cfile))
673 push (@dist_common, $cfile);
677 $output_vars .= "DIST_COMMON = " . join (' ', @dist_common) . "\n\n";
680 $output_vars .= &file_contents ('dist-vars');
681 if ($relative_dir ne '.')
684 $output_vars .= "subdir = " . $relative_dir . "\n\n";
685 $output_rules .= &file_contents ('dist-subd');
689 $output_rules .= &file_contents (defined ($contents{'SUBDIRS'})
695 # Handle auto-dependency code.
696 sub handle_dependencies
698 if ($use_dependencies)
700 # Include GNU-make-specific auto-dep code.
701 if ($dir_holds_sources)
703 $output_rules .= &file_contents ('depend');
708 # Include any auto-generated deps that are present.
709 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
712 local ($gpat) = $relative_dir . "/.deps/*.P";
714 foreach $depfile (<${gpat}>)
716 if (! open (DEP_FILE, $depfile))
718 print STDERR "automake: couldn't open $depfile: $!\n";
723 $output_rules .= join ('', <DEP_FILE>);
728 $output_rules .= "\n";
733 # Handle subdirectories.
736 return if (! defined ($contents{'SUBDIRS'}));
738 $output_rules .= &file_contents ('subdirs');
740 push (@all, "all-recursive");
741 push (@check, "check-recursive");
742 push (@info, "info-recursive");
743 push (@dvi, "dvi-recursive");
745 $recursive_install = 1;
748 # Handle remaking and configure stuff.
751 if ($relative_dir ne '.')
754 $output_rules .= &file_contents ('remake-subd');
760 $output_vars .= "ACLOCAL = aclocal.m4\n";
761 push (@dist_common, 'aclocal.m4');
763 $output_rules .= &file_contents ('remake');
765 # Look for some files we need.
766 &require_file ('install-sh');
767 &require_file ('mkinstalldirs');
770 if (defined ($contents{'CONFIG_HEADER'})
771 && $contents{'CONFIG_HEADER'} !~ m,/,)
773 # Header defined and in this directory.
776 $output_vars .= "ACCONFIG = acconfig.h\n";
777 push (@dist_common, 'acconfig.h');
779 if (-f 'config.h.top')
781 $output_vars .= "CONFIG_TOP = config.h.top\n";
782 push (@dist_common, 'config.h.top');
784 if (-f 'config.h.bot')
786 $output_vars .= "CONFIG_BOT = config.h.bot\n";
787 push (@dist_common, 'config.h.bot');
790 push (@dist_common, 'stamp-h.in', $contents{'CONFIG_HEADER'} . '.in');
792 $output_rules .= &file_contents ('remake-hdr');
796 # Handle footer elements.
799 if ($contents{'SOURCES'})
801 $output_vars .= "SOURCES = " . $contents{'SOURCES'} . "\n";
803 if ($contents{'OBJECTS'})
805 $output_vars .= "OBJECTS = " . $contents{'OBJECTS'} . "\n";
807 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
809 $output_vars .= "\n";
812 $output_trailer .= ".SUFFIXES:\n";
815 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
817 $output_trailer .= "\n" . &file_contents ('footer');
820 # Deal with installdirs target.
821 sub handle_installdirs
823 # GNU Makefile standards recommend this. FIXME prettyprint rule
825 $output_rules .= ("installdirs:"
826 . ($recursive_install
827 ? " installdirs-recursive\n"
829 if ($#installdirs >= 0)
831 $output_rules .= ("\t\$(top_srcdir)/mkinstalldirs "
832 . join (' ', @installdirs)
835 $output_rules .= "\n";
838 # There are several targets which need to be merged. This is because
839 # their complete definition is compiled from many parts. Note that we
840 # avoid double colon rules, otherwise we'd use them instead.
841 sub handle_merge_targets
843 &do_one_merge_target ('all', @all);
844 &do_one_merge_target ('info', @info);
845 &do_one_merge_target ('dvi', @dvi);
846 &do_one_merge_target ('check', @check);
848 # Handle the various install targets specially. We do this so
849 # that (eg) "make install-exec" will run "install-exec-recursive"
850 # if required, but "make install" won't run it twice. Step one is
851 # to see if the user specified local versions of any of the
853 if (defined $contents{'install-exec-local'})
855 push (@install_exec, 'install-exec-local');
857 if (defined $contents{'install-data-local'})
859 push (@install_data, 'install-data-local');
861 if (defined $contents{'uninstall-local'})
863 push (@uninstall, 'uninstall-local');
866 if (defined $contents{'install-local'})
868 print STDERR "automake: use \`install-data' or \`install-exec', not \`install'\n";
871 # Step two: if we are doing recursive makes, write out the
874 if ($recursive_install)
876 push (@install, 'install-recursive');
877 push (@uninstall, 'uninstall-recursive');
879 if ($#install_exec >= 0)
881 $output_rules .= ('install-exec-am: '
882 . join (' ', @install_exec)
884 @install_exec = ('install-exec-recursive', 'install-exec-am');
885 push (@install, 'install-exec-am');
887 if ($#install_data >= 0)
889 $output_rules .= ('install-data-am: '
890 . join (' ', @install_data)
892 @install_data = ('install-data-recursive', 'install-data-am');
893 push (@install, 'install-data-am');
895 if ($#uninstall >= 0)
897 $output_rules .= ('uninstall-am: '
898 . join (' ', @uninstall)
900 @uninstall = ('uninstall-recursive', 'uninstall-am');
904 # Step three: print definitions users can use.
905 if ($#install_exec >= 0)
907 $output_rules .= ("install-exec: "
908 . join (' ', @install_exec)
910 push (@install, 'install-exec') if (!$recursive_install);
912 if ($#install_data >= 0)
914 $output_rules .= ("install-data: "
915 . join (' ', @install_data)
917 push (@install, 'install-data') if (!$recursive_install);
920 $output_rules .= ('install: '
921 . join (' ', @install)
924 . join (' ', @uninstall)
928 # Helper for handle_merge_targets.
929 sub do_one_merge_target
931 local ($name, @values) = @_;
933 if (defined $contents{$name . '-local'})
935 # User defined local form of target. So include it.
936 push (@values, $name . '-local');
939 $output_rules .= $name . ": " . join (' ', @values) . "\n\n";
942 # Handle all 'clean' targets.
945 push (@clean, 'generic');
946 $output_rules .= &file_contents ('clean');
948 local ($target) = $recursive_install ? 'clean-am' : 'clean';
949 &do_one_clean_target ($target, 'mostly', '', @clean);
950 &do_one_clean_target ($target, '', 'mostly', @clean);
951 &do_one_clean_target ($target, 'dist', '', @clean);
952 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
955 if ($recursive_install)
957 @deps = ('am', 'recursive');
958 &do_one_clean_target ('', 'mostly', '', @deps);
959 &do_one_clean_target ('', '', '', @deps);
960 &do_one_clean_target ('', 'dist', '', @deps);
961 &do_one_clean_target ('', 'maintainer-', '', @deps);
965 # Helper for handle_clean.
966 sub do_one_clean_target
968 local ($target, $name, $last_name, @deps) = @_;
970 # Special case: if target not passed, then don't generate
971 # dependency on next "lower" clean target (eg no
972 # clean<-mostlyclean derivation). In this case the target is
973 # implicitly known to be 'clean'.
974 local ($flag) = $target;
980 $output_rules .= $name . $target . ": ";
983 if ($last_name || $name ne 'mostly')
985 $output_rules .= $last_name . $target . " ";
989 $output_rules .= ($name . 'clean-' . join (' ' . $name . 'clean-', @deps)
992 # FIXME shouldn't we really print these messages before running
994 if ($name . $target eq 'maintainer-clean')
996 # Print a special warning.
998 ("\t@echo \"This command is intended for maintainers to use;\"\n"
999 . "\t@echo \"it deletes files that may require special "
1000 . "tools to rebuild.\"\n");
1002 $output_rules .= "\n";
1005 ################################################################
1007 # Read Makefile.am and set up %contents. Simultaneously copy lines
1008 # from Makefile.am into $output_trailer or $output_vars as
1009 # appropriate. NOTE we put rules in the trailer section. We want
1010 # user rules to come after our generated stuff.
1013 local ($amfile) = @_;
1015 if (! open (AMFILE, $amfile))
1017 print STDERR "automake: couldn't open $amfile: $!\n";
1021 local ($saw_bk) = 0;
1022 local ($was_rule) = 0;
1023 local ($last_var_name) = '';
1033 $output_trailer .= $_ . "\n";
1037 $output_vars .= $_ . "\n";
1038 if (substr ($_, -1) eq "\\")
1040 $contents{$last_var_name} .= substr ($_, 0,
1045 $contents{$last_var_name} .= $_;
1049 elsif ($_ eq '@kr@')
1051 # Special case: this means we want automatic
1052 # de-ANSI-fication. FIXME think of a better way.
1053 $contents{'@kr@'} = 1;
1055 elsif (m/^ *([a-zA-Z_.][a-zA-Z0-9_.]*) *:/)
1059 # Value here doesn't matter; for targets we only note
1062 $output_trailer .= $_ . "\n";
1064 elsif (m/^ *([A-Za-z][A-Za-z0-9_]*)[ ]*=[ ]*(.*)$/)
1066 # Found a variable reference.
1068 $last_var_name = $1;
1069 if (substr ($2, -1) eq "\\")
1071 $contents{$1} = substr ($2, 0, length ($2) - 1);
1077 $output_vars .= $_ . "\n";
1081 # Special rule: if looking at a blank line, append it to
1082 # whatever we saw last.
1085 $output_trailer .= "\n";
1089 $output_vars .= "\n";
1094 # This isn't an error; it is probably a continued rule.
1095 # In fact, this is what we assume.
1096 $output_trailer .= $_ . "\n";
1099 $saw_bk = (substr ($_, -1) eq "\\");
1102 # Include some space after user code.
1103 $output_vars .= "\n";
1104 $output_trailer .= "\n";
1107 ################################################################
1109 # Initialize global variables.
1112 # Helper text for dealing with man pages.
1113 $install_man_format =
1114 ' sect=@SECTION@; \\
1115 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
1116 echo installing @MAN@ as $(mandir)/man$$sect/$$inst; \\
1117 $(INSTALL_DATA) $(srcdir)/@MAN@ $(mandir)/man$$sect/$$inst; \\
1118 if test -d $(mandir)/cat$$sect; then \\
1119 echo formatting @MAN@ as $(mandir)/cat$$sect/$$inst; \\
1120 $(NROFF) -man $(srcdir)/@MAN@ > $(mandir)/cat$$sect/$$inst; \\
1126 $uninstall_man_format =
1127 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
1128 rm -f $(mandir)/man@SECTION@/$$inst $(mandir)/cat@SECTION@/$$inst
1131 # Commonly found files we look for and automatically include in
1135 "THANKS", "TODO", "README", "NEWS", "COPYING", "COPYING.LIB",
1136 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
1137 "config.guess", "config.sub"
1140 # Commonly used files we auto-include, but only sometimes.
1143 "version.texi", "aclocal.m4", "acconfig.h", "config.h.top",
1144 "config.h.bot", "stamp-h.in", "mdate-sh", "ansi2knr.c",
1145 "ansi2knr.1", 'stamp-vti', "mkinstalldirs", "install-sh"
1149 --amdir=DIR directory storing config files
1150 --help print this help, then exit
1151 --include-deps include generated dependencies in Makefile.in
1152 --output-dir=DIR put generated Makefile.in's into DIR
1153 --version print version number, then exit\n";
1157 ################################################################
1159 # Return contents of a file from $am_dir.
1162 local ($basename) = @_;
1163 local ($file) = $am_dir . '/' . $basename . '.am';
1165 if (! open (FC_FILE, $file))
1167 print STDERR "automake: installation error: cannot open \"$file\"\n";
1171 # Yes, we really want to slurp it.
1172 local ($results) = join ('', <FC_FILE>);
1179 ################################################################
1181 # Verify that the file must exist in the current directory.
1185 local ($fullfile) = $relative_dir . "/" . $file;
1189 print STDERR "automake: required file \"$fullfile\" not found\n";
1194 push (@dist_common, $file);
1199 ################################################################
1201 # Return directory name of file.
1207 ($sub = $file) =~ s,/+[^/]+,,g;
1216 ################################################################
1218 # Print usage information.
1221 print "Usage: automake [OPTION] ... [Makefile]...\n";
1223 print "\nFiles which are automatically distributed, if found:\n";
1224 $~ = "USAGE_FORMAT";
1225 local (@lcomm) = sort ((@common_files, @common_sometimes));
1227 while ($#lcomm >= 0)
1229 $one = shift (@lcomm);
1230 $two = shift (@lcomm);
1237 format USAGE_FORMAT =
1238 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<