| 1 | # install.awk
|
|---|
| 2 | # awk script to handle "make install". Goal is to eliminate need for
|
|---|
| 3 | # extra utilities (such as sh, mkdir, and cp). This is a hack.
|
|---|
| 4 |
|
|---|
| 5 | function mkinstalldirs(dir, i, ii, j, jj, s, comp, mkdir)
|
|---|
| 6 | {
|
|---|
| 7 | gsub("/", "\\", dir); ii = split(dir, s, " ")
|
|---|
| 8 | print "@echo off" > install_bat
|
|---|
| 9 | print "@echo off" > install_cmd
|
|---|
| 10 | for (i = 1; i <= ii; i++) {
|
|---|
| 11 | jj = split(s[i], comp, "\\"); dir = comp[1];
|
|---|
| 12 | for (j = 1; j <= jj; dir=dir "\\" comp[++j]) {
|
|---|
| 13 | if (substr(dir, length(dir)) == ":" || mkdir[dir]) continue;
|
|---|
| 14 | printf("if not exist %s\\*.* mkdir %s\n", dir, dir) > install_bat
|
|---|
| 15 | printf("if not exist %s\\* mkdir %s\n", dir, dir) > install_cmd
|
|---|
| 16 | mkdir[dir] = 1
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 | close(install_bat); close(install_cmd)
|
|---|
| 20 | system(install)
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | function cp(s, j, n, comp)
|
|---|
| 24 | {
|
|---|
| 25 | gsub("/", "\\", s); n = split(s, comp, " ");
|
|---|
| 26 | print "@echo off" > install_bat
|
|---|
| 27 | print "@echo off" > install_cmd
|
|---|
| 28 | for (j = 1; j < n; j++) {
|
|---|
| 29 | printf("copy %s %s\n", comp[j], comp[n]) > install_cmd
|
|---|
| 30 | if (substr(comp[j], length(comp[j]), 1) == "*")
|
|---|
| 31 | comp[j] = comp[j] ".*"
|
|---|
| 32 | printf("copy %s %s\n", comp[j], comp[n]) > install_bat
|
|---|
| 33 | }
|
|---|
| 34 | close(install_bat); close(install_cmd)
|
|---|
| 35 | system(install)
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | BEGIN{
|
|---|
| 39 | install = "installg"
|
|---|
| 40 | install_bat = install ".bat"; install_cmd = install ".cmd"
|
|---|
| 41 | igawk_cmd = prefix "/bin/igawk.cmd"
|
|---|
| 42 | igawk_bat = prefix "/bin/igawk.bat"
|
|---|
| 43 | igawk = "pc/awklib/igawk"
|
|---|
| 44 |
|
|---|
| 45 | # Make the bin directory
|
|---|
| 46 | mkinstalldirs(prefix "/bin");
|
|---|
| 47 |
|
|---|
| 48 | # Create igawk.cmd for OS/2
|
|---|
| 49 | printf("extproc sh %s/bin/igawk.cmd\nshift\n", prefix) > igawk_cmd
|
|---|
| 50 | while (getline < igawk) print $0 > igawk_cmd
|
|---|
| 51 |
|
|---|
| 52 | # Create igawk.bat for DOS
|
|---|
| 53 | printf("@sh %s/bin/igawk %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9", prefix) > igawk_bat
|
|---|
| 54 |
|
|---|
| 55 | # Do common
|
|---|
| 56 | cp(igawk " *awk.exe " prefix "/bin")
|
|---|
| 57 | mkinstalldirs(prefix "/lib/awk " prefix "/man/man1 " prefix "/info")
|
|---|
| 58 | cp("awklib/eg/lib/* pc/awklib/igawk.awk " prefix "/lib/awk");
|
|---|
| 59 | cp("doc/*.1 " prefix "/man/man1");
|
|---|
| 60 | cp("doc/gawk.info " prefix "/info");
|
|---|
| 61 | cp("doc/gawkinet.info " prefix "/info");
|
|---|
| 62 | }
|
|---|