File: lt-compile-resource

package info (click to toggle)
abiword 3.0.2-2%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 60,060 kB
  • sloc: cpp: 476,293; ansic: 15,499; makefile: 5,791; sh: 4,359; xml: 3,332; yacc: 1,818; lex: 1,104; perl: 40; python: 6
file content (78 lines) | stat: -rwxr-xr-x 2,152 bytes parent folder | download | duplicates (105)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh

# Script to compile a resource file for a DLL in the same way that
# libtool would, if it knew about .rc files.

# This kinda sucks, but the alternative would be to teach autoconf,
# automake, and libtool about compiling .rc files.  That would be
# doable, but waiting for those changes to propagate to official
# versions of those tools would take some time.

# The command line arguments are:
# $1: the name of the .rc file to compile if it exists
# $2: the name of the resource libtool object file to produce

rcfile=$1
lo=$2
case "$lo" in
*.lo) 
    resfile=.libs/`basename $lo .lo`.o
    ;;
*)
    echo libtool object name should end with .lo
    exit 1
    ;;
esac
d=`dirname $0`

# Create .libs if not there already
[ ! -d .libs ] && mkdir .libs

# Super-ugly hack: libtool can work in two ways on Win32: Either it
# uses .lo files which are the real object files in "this" directory,
# or it creates .o files in the .libs subdirectory, and the .lo file
# is a small text file. We try to deduce which case this is by
# checking if there are any .o files in .libs. This requires that the
# resource file gets built last in the Makefile.

o_files_in_dotlibs=`echo .libs/*.o`
case "$o_files_in_dotlibs" in
    .libs/\*.o)
	use_script=false
	;;
    *)  use_script=true
	;;
esac

# Another way of working of libtool: When compiling with --enable-static and
# --disable-shared options, the .lo file can be still a small text file, and
# the .o files are created in the same directory as the .lo files.

o_files_in_dot=`echo ./*.o`
case "$o_files_in_dot" in
    ./\*.o)
    	use_script=$use_script
    	;;
    *)	use_script=true
    	;;
esac    	

# Try to compile resource file
$d/compile-resource $rcfile $resfile && {
    if [ $use_script = true ]; then
	# Handcraft a libtool object
	# libtool checks for a second line matching "Generated by .* libtool"!
	(echo "# $lo"
	echo "# Generated by lt-compile-resource, compatible with libtool"
	echo "pic_object=$resfile"
	echo "non_pic_object=none") >$lo
    else
	mv $resfile $lo
    fi
    # Success
    exit 0
}

# If unsuccessful (no .rc file, or some error in it) return failure

exit 1