| 1 | #!/bin/sh |
| 2 | set -e |
| 3 | |
| 4 | public_inc=$1 |
| 5 | asm=$2 |
| 6 | c_list=$3 |
| 7 | |
| 8 | echo -n > $public_inc |
| 9 | |
| 10 | cat $asm | fromdos | sed -e \ |
| 11 | '1,/^_rdata.*segment/d;/^_data.*\<ends\>/q;/^[[:blank:];]/d;/^;/d;/^_r\?data\>/d;' | awk '{print $1}' | \ |
| 12 | while read a; do |
| 13 | test -z "$a" && continue |
| 14 | case $a in |
| 15 | __IMPORT_DESCRIPTOR*) |
| 16 | continue |
| 17 | ;; |
| 18 | _data) |
| 19 | continue |
| 20 | ;; |
| 21 | *) |
| 22 | ;; |
| 23 | esac |
| 24 | |
| 25 | echo "_$a equ $a" >> $public_inc |
| 26 | echo "PUBLIC _$a" >> $public_inc |
| 27 | done |
| 28 | |
| 29 | if test -n "$c_list"; then |
| 30 | # make a list of functions in asm |
| 31 | grep '\<endp\>' $asm | awk '{print $1}' | grep -v '\<rm_' \ |
| 32 | > ${asm}_funcs || true |
| 33 | |
| 34 | echo "; funcs called from C" >> $public_inc |
| 35 | |
| 36 | cat $c_list | \ |
| 37 | while read a; do |
| 38 | name=`echo $a | awk -F@ '{print $1}'` |
| 39 | n=`grep "\<$name\>" ${asm}_funcs` || \ |
| 40 | n=`grep "\<_$name\>" ${asm}_funcs` || true |
| 41 | if test -z "$n"; then |
| 42 | echo "\"$name\" is expected to be in asm, but was not found" |
| 43 | rm $public_inc |
| 44 | exit 1 |
| 45 | fi |
| 46 | echo "PUBLIC $n" >> $public_inc |
| 47 | done |
| 48 | fi |