File: make_ico.awk

package info (click to toggle)
noweb 2.13-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,540 kB
  • sloc: sh: 2,580; ansic: 1,829; makefile: 903; perl: 781; lisp: 757; awk: 174; csh: 3
file content (50 lines) | stat: -rw-r--r-- 1,644 bytes parent folder | download | duplicates (11)
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
48
49
50
# edits noweb/src/icon/makefile for Ms-Dos + PC386 + Icon 386 9.0 + DJGPP + MKS 4.2
# tested with noweb 2.7a

BEGIN { print "# generated MsDos makefile, original in makefile.old" }

/SHELL=/ { $0 = "# " $0 } # disable SHELL def

/BINEXECS=/ { # add .exe extension
  s = "";
  for (k = 1; k <= NF; ++k)
     s = s sprintf("%s.exe ", $k);
  $0 = s
}

function splitLineTooLong() { # appends to strings s1 & s2 (does not initialize them)
   for (k = 1; k <= NF; ++k) 
      if (match($k, "\\."))
         s1 = s1 $k " ";
      else
         s2 = s2 $k ".exe ";
 }
/LIBEXECS=/ { # split in 2 parts (to avoid 128 chars command.com overflow) and add .exe if no extension is provided
   s1 = ""; s2 = ""; 
   if ($NF == "\\") { # tackles problem of a '\' meaning continue in next line
      $NF = ""; 
      NF = NF - 1;
      splitLineTooLong();
      getline;  # read next line due to '\' continuation char
   }
   splitLineTooLong();
   printf("LIBEXECS2=%s\n", s1);
   $0 = s2;
}

/^EXECS=/ { $0 = $0 " $(LIBEXECS2)" }  # because now LIBEXECS is split into LIBEXECS and LIBEXECS2

/cp \$\(LIBEXECS\)/ { printf("\tcp $(LIBEXECS2) $(LIB)\n"); } # the new LIBEXECS2 also need to be copied

/\/bin\/rm/ { $1 = "\trm" } # rm might not be at "/bin/rm", remember to add the tab \t

/\$\(ICON.\) -o/ { 
    if (!match($3, "\\."))  { # if no extension add .exe
       sub(/[a-z0-9]+/, "&.exe", $3);
       $1 = "\t" $1 " -I"   # add -I  option to icon translator (see Icon 386 9.0 Ms-Dos docs)
     }
  }

/^[a-z0-9]+: [a-z0-9]+\.icn/ && NF == 2 { sub(/[a-z0-9]+/, "&.exe", $1) } # add .exe 

{ print $0 } # prints the line (which might have been changed)