setup_mingw32.cmake 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. # ***** BEGIN GPL LICENSE BLOCK *****
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ***** END GPL LICENSE BLOCK *****
  18. ####################################################################################################################
  19. # Mingw32 Builds
  20. ####################################################################################################################
  21. # This installs mingw32+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3
  22. ####################################################################################################################
  23. message("LIBDIR = ${LIBDIR}")
  24. macro(cmake_to_msys_path MsysPath ResultingPath)
  25. string(REPLACE ":" "" TmpPath "${MsysPath}")
  26. string(SUBSTRING ${TmpPath} 0 1 Drive)
  27. string(SUBSTRING ${TmpPath} 1 255 PathPart)
  28. string(TOLOWER ${Drive} LowerDrive)
  29. string(CONCAT ${ResultingPath} "/" ${LowerDrive} ${PathPart})
  30. endmacro()
  31. cmake_to_msys_path(${LIBDIR} mingw_LIBDIR)
  32. message("mingw_LIBDIR = ${mingw_LIBDIR}")
  33. message("Checking for mingw32")
  34. # download mingw32
  35. if(NOT EXISTS "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z")
  36. message("Downloading mingw32")
  37. file(DOWNLOAD "https://astuteinternet.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.4/threads-win32/sjlj/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z" "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z")
  38. endif()
  39. # make mingw root directory
  40. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw")
  41. execute_process(
  42. COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/mingw
  43. WORKING_DIRECTORY ${DOWNLOAD_DIR}
  44. )
  45. endif()
  46. # extract mingw32
  47. if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd") AND (EXISTS "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z"))
  48. message("Extracting mingw32")
  49. execute_process(
  50. COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z
  51. WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw
  52. )
  53. endif()
  54. message("Checking for pkg-config")
  55. if(NOT EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
  56. message("Downloading pkg-config")
  57. file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
  58. endif()
  59. # extract pkgconfig
  60. if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe") AND (EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"))
  61. message("Extracting pkg-config")
  62. execute_process(
  63. COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"
  64. WORKING_DIRECTORY ${DOWNLOAD_DIR}/
  65. )
  66. execute_process(
  67. COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1/bin/pkg-config.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe"
  68. )
  69. endif()
  70. message("Checking for nasm")
  71. if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip")
  72. message("Downloading nasm")
  73. file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/win32/nasm-2.13.02-win32.zip" "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip")
  74. endif()
  75. # extract nasm
  76. if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe") AND (EXISTS "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip"))
  77. message("Extracting nasm")
  78. execute_process(
  79. COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip"
  80. WORKING_DIRECTORY ${DOWNLOAD_DIR}/
  81. )
  82. execute_process(
  83. COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.13.02/nasm.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe"
  84. )
  85. endif()
  86. SET(NASM_PATH ${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe)
  87. message("Checking for mingwGet")
  88. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
  89. message("Downloading mingw-get")
  90. file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
  91. endif()
  92. # extract mingw_get
  93. if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"))
  94. message("Extracting mingw-get")
  95. execute_process(
  96. COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"
  97. WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/
  98. )
  99. endif()
  100. if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/make.exe"))
  101. message("Installing MSYS")
  102. execute_process(
  103. COMMAND ${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get install msys msys-patch
  104. WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/bin/
  105. )
  106. endif()
  107. if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/mktemp.exe"))
  108. message("Installing mktemp")
  109. execute_process(
  110. COMMAND ${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get install msys msys-mktemp
  111. WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/bin/
  112. )
  113. endif()
  114. message("Checking for CoreUtils")
  115. # download old core_utils for pr.exe (ffmpeg needs it to build)
  116. if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
  117. message("Downloading CoreUtils 5.97")
  118. file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2" "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
  119. endif()
  120. if((EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe"))
  121. message("Installing pr from CoreUtils 5.97")
  122. execute_process(
  123. COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/tmp_coreutils
  124. WORKING_DIRECTORY ${DOWNLOAD_DIR}
  125. )
  126. execute_process(
  127. COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2
  128. WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
  129. )
  130. execute_process(
  131. COMMAND ${CMAKE_COMMAND} -E copy ${DOWNLOAD_DIR}/tmp_coreutils/coreutils-5.97/bin/pr.exe "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe"
  132. WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
  133. )
  134. endif()
  135. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd")
  136. message("Installing ming32sh.cmd")
  137. execute_process(
  138. COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming32sh.cmd ${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd
  139. )
  140. endif()
  141. message("Checking for perl")
  142. # download perl for libvpx
  143. if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")
  144. message("Downloading perl")
  145. file(DOWNLOAD "http://strawberryperl.com/download/5.22.1.3/strawberry-perl-5.22.1.3-32bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")
  146. endif()
  147. # make perl root directory
  148. if(NOT EXISTS "${DOWNLOAD_DIR}/perl32")
  149. execute_process(
  150. COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/perl32
  151. WORKING_DIRECTORY ${DOWNLOAD_DIR}
  152. )
  153. endif()
  154. # extract perl
  155. if((NOT EXISTS "${DOWNLOAD_DIR}/perl32/portable.perl") AND (EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip"))
  156. message("Extracting perl")
  157. execute_process(
  158. COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip
  159. WORKING_DIRECTORY ${DOWNLOAD_DIR}/perl32
  160. )
  161. endif()
  162. # get yasm for vpx
  163. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe")
  164. message("Downloading yasm")
  165. file(DOWNLOAD "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe")
  166. endif()
  167. message("checking i686-w64-mingw32-strings")
  168. # copy strings.exe to i686-w64-mingw32-strings for x264
  169. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe")
  170. message("fixing i686-w64-mingw32-strings.exe")
  171. execute_process(
  172. COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strings.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe"
  173. )
  174. endif()
  175. message("checking i686-w64-mingw32-ar.exe")
  176. # copy ar.exe to i686-w64-mingw32-ar.exe for x264
  177. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe")
  178. message("fixing i686-w64-mingw32-ar.exe")
  179. execute_process(
  180. COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ar.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe"
  181. )
  182. endif()
  183. message("checking i686-w64-mingw32-strip.exe")
  184. # copy strip.exe to i686-w64-mingw32-strip.exe for x264
  185. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe")
  186. message("fixing i686-w64-mingw32-strip.exe")
  187. execute_process(
  188. COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strip.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe"
  189. )
  190. endif()
  191. message("checking i686-w64-mingw32-ranlib.exe")
  192. # copy ranlib.exe to i686-w64-mingw32-ranlib.exe for x264
  193. if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe")
  194. message("fixing i686-w64-mingw32-ranlib.exe")
  195. execute_process(
  196. COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe"
  197. )
  198. endif()