quakespasm/Windows/SDL2/watcom/def2lbc.awk
Ozkan Sezer ef3c9f708d automate SDL[2].lib generation from def file for watcom
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1472 af15c1b1-3010-417e-b628-4374ebc0bcbd
2017-08-10 14:02:46 +00:00

38 lines
1.1 KiB
Awk

# get uppercased module name
/^[ \t]*LIBRARY/ { ModuleName = toupper( $2 ); next }
# skip uninteresting lines
/^[ \t]*(EXPORTS|;)/ { next }
# NB: Calling conventions essentially do not exist on non-x86 platforms,
# we simply strip the decoration unless 'cpu' equals 386.
# process fastcall symbols "@symbol@size"
/^[ \t]*@[A-Za-z0-9_]+@[0-9]+/ {
split( $1, parts, "@" ) # split the import name on the at signs
if( cpu == "386" )
printf( "++'%s'.'%s'..'%s'\n", $1, ModuleName, parts[2] )
else
printf( "++'%s'.'%s'\n", parts[2], ModuleName )
next
}
# process stdcall symbols using "symbol@size" format
/^[ \t]*[A-Za-z0-9_]+@[0-9]+/ {
split( $1, parts, "@" ) # split the import name on the at sign
if( cpu == "386" )
printf( "++'_%s'.'%s'..'%s'\n", $1, ModuleName, parts[1] )
else
printf( "++'%s'.'%s'\n", parts[1], ModuleName )
next
}
# process cdecl symbols using plain "symbol" format
/^[ \t]*[A-Za-z0-9_]+/ {
split( $1, parts, "@" ) # split the import name on the at sign
if( cpu == "386" )
printf( "++'_%s'.'%s'..'%s'\n", $1, ModuleName, $1 )
else
printf( "++'%s'.'%s'\n", parts[1], ModuleName )
next
}