3 # Script to compile a resource file for a DLL in the same way that
4 # libtool would, if it knew about .rc files.
6 # This kinda sucks, but the alternative would be to teach autoconf,
7 # automake, and libtool about compiling .rc files. That would be
8 # doable, but waiting for those changes to propagate to official
9 # versions of those tools would take some time.
11 # The command line arguments are:
12 # $1: the name of the .rc file to compile if it exists
13 # $2: the name of the resource libtool object file to produce
19 resfile=.libs/`basename $lo .lo`.o
22 echo libtool object name should end with .lo
28 # Create .libs if not there already
29 [ ! -d .libs ] && mkdir .libs
31 # Super-ugly hack: libtool can work in two ways on Win32: Either it
32 # uses .lo files which are the real object files in "this" directory,
33 # or it creates .o files in the .libs subdirectory, and the .lo file
34 # is a small text file. We try to deduce which case this is by
35 # checking if there are any .o files in .libs. This requires that the
36 # resource file gets built last in the Makefile.
38 o_files_in_dotlibs=`echo .libs/*.o`
39 case "$o_files_in_dotlibs" in
47 # Another way of working of libtool: When compiling with --enable-static and
48 # --disable-shared options, the .lo file can be still a small text file, and
49 # the .o files are created in the same directory as the .lo files.
51 o_files_in_dot=`echo ./*.o`
52 case "$o_files_in_dot" in
54 use_script=$use_script
60 # Try to compile resource file
61 $d/compile-resource $rcfile $resfile && {
62 if [ $use_script = true ]; then
63 # Handcraft a libtool object
64 # libtool checks for a second line matching "Generated by .* libtool"!
66 echo "# Generated by lt-compile-resource, compatible with libtool"
67 echo "pic_object=$resfile"
68 echo "non_pic_object=none") >$lo
76 # If unsuccessful (no .rc file, or some error in it) return failure