1#!/bin/sh 2 3# Script to compile a resource file for a DLL in the same way that 4# libtool would, if it knew about .rc files. 5 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. 10 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 14 15rcfile=$1 16lo=$2 17case "$lo" in 18*.lo) 19 resfile=.libs/`basename $lo .lo`.o 20 ;; 21*) 22 echo libtool object name should end with .lo 23 exit 1 24 ;; 25esac 26d=`dirname $0` 27 28# Create .libs if not there already 29[ ! -d .libs ] && mkdir .libs 30 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. 37 38o_files_in_dotlibs=`echo .libs/*.o` 39case "$o_files_in_dotlibs" in 40 .libs/\*.o) 41 use_script=false 42 ;; 43 *) use_script=true 44 ;; 45esac 46 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. 50 51o_files_in_dot=`echo ./*.o` 52case "$o_files_in_dot" in 53 ./\*.o) 54 use_script=$use_script 55 ;; 56 *) use_script=true 57 ;; 58esac 59 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"! 65 (echo "# $lo" 66 echo "# Generated by lt-compile-resource, compatible with libtool" 67 echo "pic_object=$resfile" 68 echo "non_pic_object=none") >$lo 69 else 70 mv $resfile $lo 71 fi 72 # Success 73 exit 0 74} 75 76# If unsuccessful (no .rc file, or some error in it) return failure 77 78exit 1 79