summaryrefslogtreecommitdiff
path: root/scripts/mono-test-install
blob: af0727f9844d09b6258fd3927fd8f9792664e2c8 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
#
# Does various checks for people that we can use to diagnose
# an end user installation
#
temp_cs=temp$$.cs
temp_exe=temp$$.exe
if test -f $temp_cs; then
    echo Error: need a temporary file name, and $temp_cs already exists
    echo Run this program from a different directory, or delete the file and try again.
    exit 1
fi

set `echo $PATH | sed 's/:/ /g'`

while test x$1 != x; do
    if test -x $1/mono; then
	if test x$monocmd = x; then
	   monocmd=$1/mono
        else
	   other_monos="$1/mono $other_monos"
	fi
    fi
    shift
done

echo Active Mono: $monocmd

if test "x$other_monos" != x; then
	echo "Other Mono executables: $other_monos"
fi


#
# Check that the pkg-config mono points to this mono
#
if pkg-config --modversion mono >& /dev/null; then 
        pkg_config_mono=`(cd \`pkg-config --variable prefix mono\`/bin; pwd)`/mono
	if test $pkg_config_mono != $monocmd; then
	    echo "Error: pkg-config Mono installation points to a different install"
	    echo "       than the Mono found:"
	    echo "       Mono on PATH: $monocmd"
	    echo "       Mono from pkg-config: $pkg_config_mono"
	fi
else 
        echo "Warning: pkg-config could not find mono installed on this system"
fi

##########################################################################################
#
# Tests below this point require the dotnet install
#
#

#
# Check that -pkg:dotnet is available
#
if pkg-config --modversion dotnet >& /dev/null; then
       echo ""
else
       echo "No dotnet pkgconfig found, Windows.Forms, System.Drawing and others will not work"
       exit 1
fi

case `uname` in
    Darwin) 
    	macos=true
    	libgdiplus=libgdiplus.dylib
	LD_PATH=DYLD_LIBRARY_PATH
	;;
    *) 
    	macos=false;
	libgdiplus=libgdiplus.so
	LD_PATH=LD_LIBRARY_PATH
	;;
esac

search_libgdiplus_on_path()
{
    libgdiplus_found=false
	if $macos; then
	    set `echo $DYLD_LIBRARY_PATH | sed 's/:/ /g'`
	else
	    set `echo $LD_LIBRARY_PATH | sed 's/:/ /g'`
	fi
	while test x$1 != x; do
	    if test -e $1/$libgdiplus; then
		   echo "    The $libgdiplus is found on $libdir/$libgdiplus"
		   libgdiplus_found=true
		   libgdiplus_path=$1/$libgdiplus
		   break
	    fi
	    shift
	done
}

#
# Check GDI+ installation
#
cat > $temp_cs <<EOF
using System;
using System.Drawing;

class X { 
    static void Main ()
    {
	    Bitmap b = new Bitmap (100, 100);
    }
}
EOF
if mcs -pkg:dotnet $temp_cs >& /dev/null; then
    if mono $temp_exe >& /dev/null; then
	echo Your have a working System.Drawing setup
    else
        echo Your system has a broken System.Drawing setup
        if mono $temp_exe 2>&1 | grep 'System.DllNotFoundException: gdiplus.dll' > /dev/null; then
	   echo "    your gdiplus.dll can not be loaded"

	   libdir=`dirname $monocmd`/../lib
	   if test -f $libdir/$libgdiplus; then
	       echo "    The $libgdiplus is found on $libdir/$libgdiplus"
	       if test -e $libdir/$libgdiplus; then
		   libgdiplus_path=$libdir/$libgdiplus
		   libgdiplus_found=true
	       else
		   echo "    but it seems to be a broken link"
	       fi
	   else
	       search_libgdiplus_on_path
	   fi
	   if $libgdiplus_found; then
	       echo ssss 
	       if which ldd >/dev/null; then
		   LANG=C dirs=`ldd $libgdiplus_path | grep 'not found'`
		   if echo $dirs | grep 'not found' >& /dev/null; then
		       echo "    libgdiplus is missing the following dependencies to run:"
		       echo $dirs | sed 's/^/        /'
		   fi
	       fi 
	   else
	       echo "    No libgdiplus was found on your $LD_PATH"
	   fi
	fi
    fi
else
    echo Failed to compile sample System.Drawing program, your installation is broken
    exit 1
fi

cat > $temp_cs <<EOF
using System;
using System.Reflection;
using System.IO;

class Program {

    public static void Main()
    {
        object watcher = new FileSystemWatcher()
            .GetType ()
            .GetField ("watcher", BindingFlags.NonPublic | BindingFlags.Static)
            .GetValue (null);
        
        Console.WriteLine ("Your file system watcher is: {0}",
                   watcher != null
                   ? watcher.GetType ().FullName
                   : "unknown");
    }
}
EOF

if mcs $temp_cs >& /dev/null; then
    mono $temp_exe
else
    echo Failed to compile sample test program, your installation is broken
    exit 1
fi