| 1 |
#!/usr/bin/awk |
| 2 |
|
| 3 |
function which(c,path) { |
| 4 |
cmd = "test -x " c; |
| 5 |
|
| 6 |
if (system(cmd)==0) { |
| 7 |
return c; |
| 8 |
} |
| 9 |
|
| 10 |
sub(/\/.*\//,"",c); |
| 11 |
for (dir in path) { |
| 12 |
cmd = "test -x " path[dir] "/" c; |
| 13 |
if (system(cmd)==0) { |
| 14 |
return path[dir] "/" c; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
return c; |
| 20 |
} |
| 21 |
|
| 22 |
# used to replace "use lib utils.pm" with "use lib @libexecdir" |
| 23 |
# |
| 24 |
function led() { |
| 25 |
led1 = "@libexecdir@"; |
| 26 |
led2 = "@exec_prefix@"; |
| 27 |
led3 = "@prefix@"; |
| 28 |
if ( match(led1, /^\$\{exec_prefix\}/ ) != 0 ) { |
| 29 |
return "\"" led3 "/libexec\" " ; |
| 30 |
|
| 31 |
} |
| 32 |
return "\"" led1 "\"" ; |
| 33 |
} |
| 34 |
|
| 35 |
BEGIN { |
| 36 |
split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
# scripting language (first line) |
| 41 |
|
| 42 |
/^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");} |
| 43 |
/^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");} |
| 44 |
/^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");} |
| 45 |
/^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");} |
| 46 |
|
| 47 |
# add to libexecdir to INC for perl utils.pm |
| 48 |
/^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } } |
| 49 |
|
| 50 |
|
| 51 |
# Replace the placeholders with the values from configure |
| 52 |
/#PERL#/ {sub(/#PERL#/,"@PERL@");} |
| 53 |
/my \$NOINSTLEVEL = 'unknown'/ {sub(/unknown/,"@NOINSTLEVEL@");} |
| 54 |
/my \$CELSIUS = 1;/ {sub(/1/,"@CELSIUS@");} |
| 55 |
/my \$PERFDATA = 1;/ {sub(/1/,"@PERFDATA@");} |
| 56 |
/my \$EXTENDEDINFO = 1;/ {sub(/1/,"@EXTENDEDINFO@");} |
| 57 |
/my \$HWINFO = 1;/ {sub(/1/,"@HWINFO@");} |
| 58 |
/my \$HPACUCLI = 1;/ {sub(/1/,"@HPACUCLI@");} |
| 59 |
/version => '.*',/ {sub(/'.*'/,"'@PACKAGE_VERSION@'");} |
| 60 |
|
| 61 |
{ |
| 62 |
print; |
| 63 |
} |
| 64 |
|