From c8e5e28048dd9605f7958ef95f2a6dd626658069 Mon Sep 17 00:00:00 2001 From: ng0 Date: Mon, 2 Dec 2019 15:30:56 +0000 Subject: 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. --- bin/Makefile.am | 6 ++++++ bin/dosubst.awk | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 bin/Makefile.am create mode 100755 bin/dosubst.awk (limited to 'bin') diff --git a/bin/Makefile.am b/bin/Makefile.am new file mode 100644 index 000000000..6c11e26ef --- /dev/null +++ b/bin/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = \ + dosubst.awk \ + grephdr.sh \ + grepsrc.sh \ + pogen.sh \ + rename.sh 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 ; +} -- cgit v1.2.3