mono-test-install 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #!/bin/bash
  2. #
  3. # Does various checks for people that we can use to diagnose
  4. # an end user installation
  5. #
  6. temp_cs=temp$$.cs
  7. temp_exe=temp$$.exe
  8. if test -f $temp_cs; then
  9. echo Error: need a temporary file name, and $temp_cs already exists
  10. echo Run this program from a different directory, or delete the file and try again.
  11. exit 1
  12. fi
  13. set `echo $PATH | sed 's/:/ /g'`
  14. while test x$1 != x; do
  15. if test -x $1/mono; then
  16. if test x$monocmd = x; then
  17. monocmd=$1/mono
  18. else
  19. other_monos="$1/mono $other_monos"
  20. fi
  21. fi
  22. shift
  23. done
  24. echo Active Mono: $monocmd
  25. if test "x$other_monos" != x; then
  26. echo "Other Mono executables: $other_monos"
  27. fi
  28. #
  29. # Check that the pkg-config mono points to this mono
  30. #
  31. if pkg-config --modversion mono >& /dev/null; then
  32. pkg_config_mono=`(cd \`pkg-config --variable prefix mono\`/bin; pwd)`/mono
  33. if test $pkg_config_mono != $monocmd; then
  34. echo "Error: pkg-config Mono installation points to a different install"
  35. echo " than the Mono found:"
  36. echo " Mono on PATH: $monocmd"
  37. echo " Mono from pkg-config: $pkg_config_mono"
  38. exit 1
  39. fi
  40. else
  41. echo "Warning: pkg-config could not find mono installed on this system"
  42. fi
  43. ##########################################################################################
  44. #
  45. # Tests below this point require the dotnet install
  46. #
  47. #
  48. #
  49. # Check that -pkg:dotnet is available
  50. #
  51. if pkg-config --modversion dotnet >& /dev/null; then
  52. echo ""
  53. else
  54. echo "No dotnet pkgconfig found, Windows.Forms, System.Drawing and others will not work"
  55. exit 1
  56. fi
  57. case `uname` in
  58. Darwin)
  59. macos=true
  60. libgdiplus=libgdiplus.dylib
  61. LD_PATH=DYLD_LIBRARY_PATH
  62. ;;
  63. *)
  64. macos=false;
  65. libgdiplus=libgdiplus.so
  66. LD_PATH=LD_LIBRARY_PATH
  67. ;;
  68. esac
  69. search_libgdiplus_on_path()
  70. {
  71. libgdiplus_found=false
  72. if $macos; then
  73. set `echo $DYLD_LIBRARY_PATH | sed 's/:/ /g'`
  74. else
  75. set `echo $LD_LIBRARY_PATH | sed 's/:/ /g'`
  76. fi
  77. while test x$1 != x; do
  78. if test -e $1/$libgdiplus; then
  79. echo " The $libgdiplus is found on $libdir/$libgdiplus"
  80. libgdiplus_found=true
  81. libgdiplus_path=$1/$libgdiplus
  82. break
  83. fi
  84. shift
  85. done
  86. }
  87. #
  88. # Check GDI+ installation
  89. #
  90. cat > $temp_cs <<EOF
  91. using System;
  92. using System.Drawing;
  93. class X {
  94. static void Main ()
  95. {
  96. Bitmap b = new Bitmap (100, 100);
  97. }
  98. }
  99. EOF
  100. if mcs -pkg:dotnet $temp_cs >& /dev/null; then
  101. if mono $temp_exe >& /dev/null; then
  102. echo Your have a working System.Drawing setup
  103. else
  104. echo Your system has a broken System.Drawing setup
  105. if mono $temp_exe 2>&1 | grep 'System.DllNotFoundException: gdiplus.dll' > /dev/null; then
  106. echo " your gdiplus.dll can not be loaded"
  107. libdir=`dirname $monocmd`/../lib
  108. if test -f $libdir/$libgdiplus; then
  109. echo " The $libgdiplus is found on $libdir/$libgdiplus"
  110. if test -e $libdir/$libgdiplus; then
  111. libgdiplus_path=$libdir/$libgdiplus
  112. libgdiplus_found=true
  113. else
  114. echo " but it seems to be a broken link"
  115. fi
  116. else
  117. search_libgdiplus_on_path
  118. fi
  119. if $libgdiplus_found; then
  120. echo ssss
  121. if which ldd >/dev/null; then
  122. LANG=C dirs=`ldd $libgdiplus_path | grep 'not found'`
  123. if echo $dirs | grep 'not found' >& /dev/null; then
  124. echo " libgdiplus is missing the following dependencies to run:"
  125. echo $dirs | sed 's/^/ /'
  126. fi
  127. fi
  128. else
  129. echo " No libgdiplus was found on your $LD_PATH"
  130. fi
  131. fi
  132. fi
  133. else
  134. echo Failed to compile sample System.Drawing program, your installation is broken
  135. exit 1
  136. fi