CMake checks for regular expression support.
[gromacs/qmmm-gamess-us.git] / admin / mknroff.pl
blob2b74e17239156c8240d73dfd33bd88cfcf72d626
1 #!/usr/bin/perl -w
3 # This script will generate all manual pages
4 # in the current directory. It is recommeded that
5 # you run it from the man/man1 subdirectory under
6 # your GROMACS source tree. The manual pages will
7 # be installed by the "make install" command.
9 $bindir = shift || die("Error: provide the binary directory as first argument.");
10 $ptxt = shift || die("give me the location of the programs.txt file");
12 printf "Generating unix manual for GROMACS programs\n";
13 printf "Man pages will be written in the current dir.\n";
14 printf "-------------------------------------------\n";
16 $mam = "Makefile.am";
17 open(MAM,">$mam") || die("Opening $mam for writing");
18 printf(MAM "# This file has been generated by mknroff.pl. Don't edit it.\n");
19 printf(MAM "man_MANS = ");
21 $dir = `pwd`;
22 chomp $dir;
24 @exclude = ( "my_dssp", "copyrgt", "addquote", "GMXRC", "completion.csh",
25 "completion.zsh", "average", "completion.bash", "luck",
26 "xplor2gmx.pl", "mptest", "ffscan", "demux.pl", "gentop", "mkyaw",
27 "tune_dip", "tune_pol", "hrefify", "options", "genvsites",
28 "pdtest", "bastat", "ehole" );
30 %desc = ();
31 open(PPP,"$ptxt") || die("Can't open $ptxt");
32 $npp = 0;
33 while($line = <PPP>) {
34 if ((index($line,"\|") > 0) && (index($line,"HEAD") < 0)) {
35 @tmp = split('\|',$line);
36 if ($#tmp == 1) {
37 if (!defined $desc{$tmp[0]}) {
38 $desc{$tmp[0]} = $tmp[1];
39 $npp++;
41 else {
42 printf("Multiple entries for $tmp[0] in $ptxt\n");
47 printf("npp = $npp\n");
48 close PPP;
50 chdir $bindir;
51 @PROGRAMS = glob("[a-z]*");
52 chdir $dir;
54 $prev = "";
55 foreach $program ( @PROGRAMS ) {
56 $cont = 1;
57 foreach $exc ( @exclude ) {
58 if ( $exc eq $program ) {
59 $cont = 0;
62 # Kick out the double precision variants
63 if ($program ne "${prev}_d" ) {
64 if ($cont && ( -x "$bindir/$program" )) {
65 printf " $program";
66 system("$bindir/$program -quiet -man nroff >& /dev/null");
67 $pn = "${program}.nroff";
68 $p1 = "${program}.1";
69 if ( -f $pn) {
70 open(PN,"$pn") || die("Opening $pn");
71 open(P1,">$p1") || die("Opening $p1 for writing");
72 while($line = <PN>) {
73 chomp $line;
74 if ($line eq $program) {
75 if (defined $desc{$program}) {
76 printf("\n");
77 printf(P1 "$program - $desc{$program}\n");
79 else {
80 printf (" - please add description in $ptxt\n");
81 printf (P1 "$program\n");
84 else {
85 printf(P1 "%s\n",$line);
88 close PN;
89 close P1;
90 unlink $pn;
91 printf(MAM " \\\n\t$p1");
95 $prev = $program;
97 printf(MAM "\n\nEXTRA_DIST = \${man_MANS}\n\n");
98 close MAM;
99 printf("\n");