summaryrefslogtreecommitdiff
path: root/bin/dosubst.awk
blob: 3ed0403dd16978796317953155e2b77a9416a8f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 ;
}