build-x11vnc.tcl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/usr/bin/env tclsh
  2. #
  3. # Build x11vnc for the current platform.
  4. #
  5. # Copyright 2015-2017 OpenIndex.de.
  6. # Distributed under the MIT License.
  7. # See accompanying LICENSE.txt file or at http://opensource.org/licenses/MIT
  8. #
  9. # ------------------------------------------------------------------------------
  10. #
  11. # GENERAL NOTES
  12. #
  13. # - This script is currently only used on Linux systems.
  14. #
  15. # - Mac OS X seems to be supported by x11vnc. But we currently did not manage
  16. # to make the compiled binary work properly. Therefore we're currently using
  17. # a precompiled OSXvnc for Mac OS X (https://github.com/stweil/OSXvnc).
  18. #
  19. # - Windows is not supported by x11vnc. Therefore this script cannot be used on
  20. # these systems. Instead we're currently using a precompiled TightVNC for
  21. # Windows (http://www.tightvnc.com/).
  22. #
  23. set BASE_DIR [file normalize [file dirname $argv0]]
  24. set BUILD_DIR [file join $BASE_DIR "build"]
  25. set TARGET_DIR [file join $BASE_DIR "target" "x11vnc"]
  26. set X11VNC_DIR [file join $BUILD_DIR "x11vnc-0.9.13"]
  27. set X11VNC_URL "http://downloads.sourceforge.net/project/libvncserver/x11vnc/0.9.13/x11vnc-0.9.13.tar.gz"
  28. proc download {url} {
  29. if {![catch {exec which wget} wget]} {
  30. exec wget -q $url >@ stdout
  31. return 1
  32. }
  33. if {![catch {exec which curl} curl]} {
  34. exec curl -L -O -s $url >@ stdout
  35. return 1
  36. }
  37. error "Can't download '$url'! Neither wget nor curl is available."
  38. }
  39. proc is_darwin {} {
  40. global tcl_platform
  41. set os [string tolower $tcl_platform(os)]
  42. return [string match "darwin*" $os]
  43. }
  44. proc is_linux {} {
  45. global tcl_platform
  46. set os [string tolower $tcl_platform(os)]
  47. return [string match "linux*" $os]
  48. }
  49. proc is_windows {} {
  50. global tcl_platform
  51. set os [string tolower $tcl_platform(os)]
  52. return [string match "windows*" $os]
  53. }
  54. if {[is_windows]} {
  55. error "Building x11vnc for Windows is not supported!"
  56. }
  57. fconfigure stdout -buffering none
  58. fconfigure stderr -buffering none
  59. if {![file exists $BUILD_DIR]} {
  60. file mkdir $BUILD_DIR
  61. }
  62. # download
  63. if {![file exists $X11VNC_DIR]} {
  64. puts ""
  65. puts [string repeat "-" 50]
  66. puts " Download x11vnc."
  67. puts [string repeat "-" 50]
  68. cd $BUILD_DIR
  69. download $X11VNC_URL
  70. exec -ignorestderr tar xvfz "x11vnc-0.9.13.tar.gz" >@ stdout
  71. }
  72. cd $X11VNC_DIR
  73. # cleanup
  74. puts ""
  75. puts [string repeat "-" 50]
  76. puts " Cleanup x11vnc."
  77. puts [string repeat "-" 50]
  78. if {[file exists $TARGET_DIR]} {
  79. file delete -force $TARGET_DIR
  80. }
  81. if {[catch {exec make clean >@ stdout}]} {
  82. puts "No cleanup was executed."
  83. puts $::errorInfo
  84. }
  85. # configure
  86. puts ""
  87. puts [string repeat "-" 50]
  88. puts " Configure x11vnc."
  89. puts [string repeat "-" 50]
  90. set options {}
  91. lappend options "--without-avahi"
  92. lappend options "--without-jpeg"
  93. lappend options "--without-macosx-native"
  94. lappend options "--without-ssl"
  95. lappend options "--without-gnutls"
  96. lappend options "--without-crypt"
  97. lappend options "--without-crypto"
  98. lappend options "--without-client-tls"
  99. lappend options "--without-xinerama"
  100. exec bash configure {*}$options >@ stdout
  101. # make
  102. puts ""
  103. puts [string repeat "-" 50]
  104. puts " Build x11vnc."
  105. puts [string repeat "-" 50]
  106. exec -ignorestderr make >@ stdout
  107. # finish
  108. puts ""
  109. puts [string repeat "-" 50]
  110. puts " Finished build process."
  111. puts [string repeat "-" 50]
  112. set output [file join $X11VNC_DIR "x11vnc" "x11vnc"]
  113. if {![file isfile $output]} {
  114. puts "ERROR: No compiled binary was found!"
  115. exit 1
  116. }
  117. if {![file exists $TARGET_DIR]} {
  118. file mkdir $TARGET_DIR
  119. }
  120. file copy $output $TARGET_DIR
  121. puts "Compiled binaries were saved to:"
  122. puts "$TARGET_DIR"
  123. puts [string repeat "-" 50]
  124. puts ""
  125. exit 0