File: asmdef.sh

package info (click to toggle)
allegro4.1 2%3A4.1.15-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,924 kB
  • ctags: 14,030
  • sloc: ansic: 121,716; asm: 16,973; cpp: 3,840; sh: 2,114; makefile: 706; objc: 561; python: 181; pascal: 105; perl: 73
file content (53 lines) | stat: -rwxr-xr-x 1,305 bytes parent folder | download | duplicates (3)
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
51
52
53
#!/bin/sh

# This script, by Neil Townsend, is for cross-compilers to parse the `asmdef.s'
# file and generate `asmdef.inc'.

# 1. Get the comments
grep "/\*" $1 | cut -f 2 -d '"' | cut -f 1 -d \\ > $2
echo >> $2

# 2. Get the real stuff
list=`grep ".long" $1 | sed -e s/.*.long//`
if [ -z "$list" ]; then
  list=`grep ".word" $1 | sed -e s/.*.word//`
fi
if [ -z "$list" ]; then
  echo "$0: unable to parse assembly file $1"
  exit 1
fi

while [ 1 = 1 ]; do
    c=`echo $list | cut -f 1 -d " "`:
    if [ $c = "0:" ]; then break; fi
    n=`awk /$c/,/ascii/ $1 | grep "ascii" | cut -f 2 -d '"' | cut -f 1 -d '\'`
    if [ -z "$n" ]; then
      n=`awk /$c/,/string/ $1 | grep "string" | cut -f 2 -d '"' | cut -f 1 -d '\'`
    fi
    if [ -z "$n" ]; then
      echo "$0: unable to parse assembly file $1"
      exit 1
    fi
    f=`echo $n | cut -b 1`
    if [ $f = "#" ]; then
      f2=`echo $n | cut -b 2`
      if [ $f2 = "#" ]; then
        n=`echo $n | cut -b 3-`
	echo "#ifndef $n" >> $2
	echo "#define $n" >> $2
	echo "#endif" >> $2
	echo >> $2
      else
        echo $n >> $2
      fi
    else
      v=`echo $list | cut -f 2 -d " "`
      if [ $n = "NEWLINE" ]; then echo >> $2;
      else
        echo "#define $n $v" >> $2
      fi
    fi
    list=`echo $list | cut -f 3- -d " "`
done

echo >> $2