aboutsummaryrefslogtreecommitdiff
path: root/bin
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
parent53f35813d89de6f7c91883277129ffda3ca5b772 (diff)
downloadgnunet-c8e5e28048dd9605f7958ef95f2a6dd626658069.tar.gz
gnunet-c8e5e28048dd9605f7958ef95f2a6dd626658069.zip
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')
-rw-r--r--bin/Makefile.am6
-rwxr-xr-xbin/dosubst.awk47
2 files changed, 53 insertions, 0 deletions
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 @@
1EXTRA_DIST = \
2 dosubst.awk \
3 grephdr.sh \
4 grepsrc.sh \
5 pogen.sh \
6 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 @@
1# Dedicated to the public domain.
2# SPDX-License-Identifier: 0BSD
3#
4# awk script to substitute variables in scripts and applications.
5#
6# You can pass these variables to it in Makefiles or on the
7# commandline:
8# bdir="$(bindir)"
9# py="$(PYTHON)"
10# awkay="$(AWK_BINARY)"
11# pfx="$(prefix)"
12# prl="$(PERL)"
13# sysconfdirectory="$(sysconfdir)"
14# pkgdatadirectory="$(pkgdatadir)"
15
16{
17
18 if (/@bindirectory@/) {
19 gsub("@bindirectory@",bdir) ;
20 }
21
22 if (/@PYTHONEXE@/) {
23 gsub("@PYTHONEXE@",py) ;
24 }
25
26 if (/@AWKEXE@/) {
27 gsub("@AWKEXE@",awkay) ;
28 }
29
30 if (/@SUBSTPREFIX@/) {
31 gsub("@SUBSTPREFIX@",pfx) ;
32 }
33
34 if (/@PERLEXE@/) {
35 gsub("@PERLEXE@",prl) ;
36 }
37
38 if (/@SYSCONFDIR@/) {
39 gsub("@SYSCONFDIR@",sysconfdirectory) ;
40 }
41
42 if (/@PKGDATADIRECTORY@/) {
43 gsub("@PKGDATADIRECTORY@",pkgdatadirectory) ;
44 }
45
46 print $0 ;
47}