summaryrefslogtreecommitdiff
path: root/bin/dosubst.awk
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-12-02 15:30:56 +0000
committerng0 <ng0@n0.is>2019-12-02 15:30:56 +0000
commitc8e5e28048dd9605f7958ef95f2a6dd626658069 (patch)
tree52375a14cc93c4161a658b4c7a1926dda11d8909 /bin/dosubst.awk
parent53f35813d89de6f7c91883277129ffda3ca5b772 (diff)
rewrite sed logic used in Makefiles and move into dosubst awk script.
include 'bin' and its files in dist files, this is where dosubst is located. While the invocation (passing of the variables) is not optimal (yet, will be changed), this will in the end allow sharing code between Makefiles better, and maybe drop sed usage in the future.
Diffstat (limited to 'bin/dosubst.awk')
-rwxr-xr-xbin/dosubst.awk47
1 files changed, 47 insertions, 0 deletions
diff --git a/bin/dosubst.awk b/bin/dosubst.awk
new file mode 100755
index 000000000..3ed0403dd
--- /dev/null
+++ b/bin/dosubst.awk
@@ -0,0 +1,47 @@
+# Dedicated to the public domain.
+# SPDX-License-Identifier: 0BSD
+#
+# awk script to substitute variables in scripts and applications.
+#
+# You can pass these variables to it in Makefiles or on the
+# commandline:
+# bdir="$(bindir)"
+# py="$(PYTHON)"
+# awkay="$(AWK_BINARY)"
+# pfx="$(prefix)"
+# prl="$(PERL)"
+# sysconfdirectory="$(sysconfdir)"
+# pkgdatadirectory="$(pkgdatadir)"
+
+{
+
+ if (/@bindirectory@/) {
+ gsub("@bindirectory@",bdir) ;
+ }
+
+ if (/@PYTHONEXE@/) {
+ gsub("@PYTHONEXE@",py) ;
+ }
+
+ if (/@AWKEXE@/) {
+ gsub("@AWKEXE@",awkay) ;
+ }
+
+ if (/@SUBSTPREFIX@/) {
+ gsub("@SUBSTPREFIX@",pfx) ;
+ }
+
+ if (/@PERLEXE@/) {
+ gsub("@PERLEXE@",prl) ;
+ }
+
+ if (/@SYSCONFDIR@/) {
+ gsub("@SYSCONFDIR@",sysconfdirectory) ;
+ }
+
+ if (/@PKGDATADIRECTORY@/) {
+ gsub("@PKGDATADIRECTORY@",pkgdatadirectory) ;
+ }
+
+ print $0 ;
+}