feb96a61 |
1 | #!/bin/sh |
8022df01 |
2 | set -e |
feb96a61 |
3 | |
193c11bf |
4 | public_inc=$1 |
5 | asm=$2 |
6 | c_list=$3 |
feb96a61 |
7 | |
193c11bf |
8 | echo -n > $public_inc |
9 | |
10 | cat $asm | fromdos | sed -e \ |
beb04e26 |
11 | '1,/^_rdata.*segment/d;/^_data.*\<ends\>/q;/^[[:blank:];]/d;/^;/d;/^_r\?data\>/d;' | awk '{print $1}' | \ |
feb96a61 |
12 | while read a; do |
13 | test -z "$a" && continue |
7b64f7cd |
14 | case $a in |
15 | __IMPORT_DESCRIPTOR*) |
16 | continue |
17 | ;; |
beb04e26 |
18 | _data) |
19 | continue |
20 | ;; |
7b64f7cd |
21 | *) |
22 | ;; |
23 | esac |
24 | |
193c11bf |
25 | echo "_$a equ $a" >> $public_inc |
26 | echo "PUBLIC _$a" >> $public_inc |
368deb23 |
27 | done |
28 | |
193c11bf |
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 |
368deb23 |
35 | |
193c11bf |
36 | cat $c_list | \ |
beb04e26 |
37 | while read a; do |
193c11bf |
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 |
beb04e26 |
47 | done |
48 | fi |