Blame build/win32/lt-compile-resource

rpm-build 9243a4
#!/bin/sh
rpm-build 9243a4
rpm-build 9243a4
# Script to compile a resource file for a DLL in the same way that
rpm-build 9243a4
# libtool would, if it knew about .rc files.
rpm-build 9243a4
rpm-build 9243a4
# This kinda sucks, but the alternative would be to teach autoconf,
rpm-build 9243a4
# automake, and libtool about compiling .rc files.  That would be
rpm-build 9243a4
# doable, but waiting for those changes to propagate to official
rpm-build 9243a4
# versions of those tools would take some time.
rpm-build 9243a4
rpm-build 9243a4
# The command line arguments are:
rpm-build 9243a4
# $1: the name of the .rc file to compile if it exists
rpm-build 9243a4
# $2: the name of the resource libtool object file to produce
rpm-build 9243a4
rpm-build 9243a4
rcfile=$1
rpm-build 9243a4
lo=$2
rpm-build 9243a4
case "$lo" in
rpm-build 9243a4
*.lo) 
rpm-build 9243a4
    resfile=.libs/`basename $lo .lo`.o
rpm-build 9243a4
    ;;
rpm-build 9243a4
*)
rpm-build 9243a4
    echo libtool object name should end with .lo
rpm-build 9243a4
    exit 1
rpm-build 9243a4
    ;;
rpm-build 9243a4
esac
rpm-build 9243a4
d=`dirname $0`
rpm-build 9243a4
rpm-build 9243a4
# Create .libs if not there already
rpm-build 9243a4
[ ! -d .libs ] && mkdir .libs
rpm-build 9243a4
rpm-build 9243a4
# Super-ugly hack: libtool can work in two ways on Win32: Either it
rpm-build 9243a4
# uses .lo files which are the real object files in "this" directory,
rpm-build 9243a4
# or it creates .o files in the .libs subdirectory, and the .lo file
rpm-build 9243a4
# is a small text file. We try to deduce which case this is by
rpm-build 9243a4
# checking if there are any .o files in .libs. This requires that the
rpm-build 9243a4
# resource file gets built last in the Makefile.
rpm-build 9243a4
rpm-build 9243a4
o_files_in_dotlibs=`echo .libs/*.o`
rpm-build 9243a4
case "$o_files_in_dotlibs" in
rpm-build 9243a4
    .libs/\*.o)
rpm-build 9243a4
	use_script=false
rpm-build 9243a4
	;;
rpm-build 9243a4
    *)  use_script=true
rpm-build 9243a4
	;;
rpm-build 9243a4
esac
rpm-build 9243a4
rpm-build 9243a4
# Another way of working of libtool: When compiling with --enable-static and
rpm-build 9243a4
# --disable-shared options, the .lo file can be still a small text file, and
rpm-build 9243a4
# the .o files are created in the same directory as the .lo files.
rpm-build 9243a4
rpm-build 9243a4
o_files_in_dot=`echo ./*.o`
rpm-build 9243a4
case "$o_files_in_dot" in
rpm-build 9243a4
    ./\*.o)
rpm-build 9243a4
    	use_script=$use_script
rpm-build 9243a4
    	;;
rpm-build 9243a4
    *)	use_script=true
rpm-build 9243a4
    	;;
rpm-build 9243a4
esac    	
rpm-build 9243a4
rpm-build 9243a4
# Try to compile resource file
rpm-build 9243a4
$d/compile-resource $rcfile $resfile && {
rpm-build 9243a4
    if [ $use_script = true ]; then
rpm-build 9243a4
	# Handcraft a libtool object
rpm-build 9243a4
	# libtool checks for a second line matching "Generated by .* libtool"!
rpm-build 9243a4
	(echo "# $lo"
rpm-build 9243a4
	echo "# Generated by lt-compile-resource, compatible with libtool"
rpm-build 9243a4
	echo "pic_object=$resfile"
rpm-build 9243a4
	echo "non_pic_object=none") >$lo
rpm-build 9243a4
    else
rpm-build 9243a4
	mv $resfile $lo
rpm-build 9243a4
    fi
rpm-build 9243a4
    # Success
rpm-build 9243a4
    exit 0
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
# If unsuccessful (no .rc file, or some error in it) return failure
rpm-build 9243a4
rpm-build 9243a4
exit 1