4 # (c)1999-2000 Paul Sokolovsky
5 # a2dll is distrubuted under GNU General Public License, see http://www.gnu.org
9 echo 'a2dll 1.0: convert static library into win32 dll'
10 echo ' by <Paul.Sokolovsky@technologist.com>'
11 echo 'Usage: a2dll <staticlib> [-o <dllname>] [linker commands:-L,-l,-s] [--relink]'
21 -\? |
-h* |
--h*) usage
;;
22 -o ) out
="$2"; shift; shift;;
23 --relink) relink
=1; shift;;
24 -* ) libs
="$libs $1"; shift;;
34 base
=`basename $in .a`
38 out
=`awk -v n=$base 'BEGIN {print substr(n,4); exit;}'`.dll
41 if [ "$relink" != "1" ]
44 /usr
/bin
/mkdir
-p .dll
51 echo Creating shared library
\'$out\'
53 dllwrap
--export-all -o ..
/$out `ls` $libs >..
/ld.err
2>&1
56 if [ `wc ld.err|awk ' {print $1}' ` -gt 2 ]
58 echo Linking error
, consult
file \'ld.err
\', correct errors
, and run
59 echo \'$0 $cmdline --relink\'
69 # we use pexports on dll instead of dlltool on objects for this,
72 # 2. I just saw that dlltool lies about assembly-sourced files, it
73 # lists their symbols as data
75 pexports
$out >$base.def
77 # create import library
80 dlltool
--dllname $out --def $base.def
--output-lib $in
82 # finally, we check whether dll exports data symbols
83 # if yes, we suggest user on steps to perform
85 pexports
$out |
awk '/DATA/ { print $1}' >$out.data
89 echo Shared library exports data symbols
, they are listed \
90 in \'$out.data
\'. For using them
in client application
, you should mark \
91 them as __declspec\
(dllimport\
) in library headers. You can quickly \
92 find places where these data symbols declared by issuing
94 echo " grep -f $out.data *.h"
96 echo in library header directory. Also note that this step is optional
, you can postpone \
97 it
until you
\'ll get during linking unresolved symbol _imp__\
<something\
>, where \
98 \
<something\
> is one of the symbols listed
in $out.data. Read documentation \
99 \
(static2dll_howto.txt\
) for more information.