summaryrefslogtreecommitdiff
path: root/mkproto.awk
diff options
context:
space:
mode:
authorEthan Sommer via rsync <rsync@lists.samba.org>2020-04-07 13:01:45 -0700
committerWayne Davison <wayned@samba.org>2020-04-07 13:08:05 -0700
commit795268bb7cf5c077320243d7f037836adf19aa41 (patch)
tree20052492e74c9124654c3cff78edef7d74f7feb2 /mkproto.awk
parent70cbc66b7f504f9ba5f396aeafa38aa8d483b799 (diff)
downloadrsync-795268bb7cf5c077320243d7f037836adf19aa41.tar.gz
Replace mkproto.pl with mkproto.awk
This replaces the build dependency on perl with one on awk which is already used throughout the build system and is much more ubiquitous than perl.
Diffstat (limited to 'mkproto.awk')
-rw-r--r--mkproto.awk39
1 files changed, 39 insertions, 0 deletions
diff --git a/mkproto.awk b/mkproto.awk
new file mode 100644
index 00000000..ab97d54f
--- /dev/null
+++ b/mkproto.awk
@@ -0,0 +1,39 @@
+#!/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"
+}