@if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi
proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h
- perl $(srcdir)/mkproto.pl $(srcdir)/*.c $(srcdir)/lib/compat.c
+ awk -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c
man: rsync.1 rsyncd.conf.5 man-copy
--- /dev/null
+#!/usr/bin/awk -f
+
+BEGIN {
+ while ((getline i < "proto.h") > 0) old_protos = old_protos ? old_protos "\n" i : i
+ protos = "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n"
+}
+
+inheader {
+ protos = protos "\n" ((inheader = /\)[ \t]*$/ ? 0 : 1) ? $0 : $0 ";")
+ next
+}
+
+/^FN_(LOCAL|GLOBAL)_[^(]+\([^,()]+/ {
+ local = /^FN_LOCAL/
+ gsub(/^FN_(LOC|GLOB)AL_|,.*$/, "")
+ sub(/^BOOL\(/, "BOOL ")
+ sub(/^CHAR\(/, "char ")
+ sub(/^INTEGER\(/, "int ")
+ sub(/^STRING\(/, "char *")
+ protos = protos "\n" $0 (local ? "(int module_id);" : "(void);")
+ next
+}
+
+/^static|^extern|;/||!/^[A-Za-z][A-Za-z0-9_]* / { next }
+
+/\(.*\)[ \t]*$/ {
+ protos = protos "\n" $0 ";"
+ next
+}
+
+/\(/ {
+ inheader = 1
+ protos = protos "\n" $0
+}
+
+END {
+ if (old_protos != protos) print protos > "proto.h"
+ printf "" > "proto.h-tstamp"
+}
+++ /dev/null
-# generate prototypes for rsync
-
-$old_protos = '';
-if (open(IN, 'proto.h')) {
- $old_protos = join('', <IN>);
- close IN;
-}
-
-%FN_MAP = (
- BOOL => 'BOOL ',
- CHAR => 'char ',
- INTEGER => 'int ',
- STRING => 'char *',
-);
-
-$inheader = 0;
-$protos = qq|/* This file is automatically generated with "make proto". DO NOT EDIT */\n\n|;
-
-while (<>) {
- if ($inheader) {
- if (/[)][ \t]*$/) {
- $inheader = 0;
- s/$/;/;
- }
- $protos .= $_;
- } elsif (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) {
- $ret = $FN_MAP{$2};
- $func = $3;
- $arg = $1 eq 'LOCAL' ? 'int module_id' : 'void';
- $protos .= "$ret$func($arg);\n";
- } elsif (/^static|^extern/ || /[;]/ || !/^[A-Za-z][A-Za-z0-9_]* /) {
- ;
- } elsif (/[(].*[)][ \t]*$/) {
- s/$/;/;
- $protos .= $_;
- } elsif (/[(]/) {
- $inheader = 1;
- $protos .= $_;
- }
-}
-
-if ($old_protos ne $protos) {
- open(OUT, '>proto.h') or die $!;
- print OUT $protos;
- close OUT;
-}
-
-open(OUT, '>proto.h-tstamp') and close OUT;