Advertisement
Karlson2k

mingw-w64-xbmc-build-0.9.5.3.sh

Nov 26th, 2012
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 114.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ################################################################################
  4. # MingGW-w64 Build Script 3.1.0k
  5. ################################################################################
  6. # Copyright (C) 2011-2012  Kyle Schwarz
  7. # Copyright (C) 2012 Karlson2k (Evgeny Grin)
  8. #
  9. # This program is free software: you can redistribute it and/or modify it under
  10. # the terms of the GNU General Public License as published by the Free Software
  11. # Foundation, either version 3 of the License, or (at your option) any later
  12. # version.
  13. #
  14. # This program is distributed in the hope that it will be useful, but WITHOUT
  15. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  17. # details.
  18. #
  19. # You should have received a copy of the GNU General Public License along with
  20. # this program.  If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # The GNU General Public License can be found at the end of this file.
  23. #
  24. # Written by Kyle Schwarz, report any bugs to <kyle.r.schwarz@gmail.com>
  25. # Modified by Karlson2k, report bugs to http://forum.xbmc.org/private.php?action=send&uid=77145
  26. #
  27. # This script will build MinGW-w64 for Win32 and Win64.
  28. #
  29. # This version will build the following packages into the toolchain:
  30. #   mingw-w64
  31. #   gmp
  32. #   mpfr
  33. #   mpc
  34. #   ppl
  35. #   cloog-ppl
  36. #   binutils
  37. #   gcc
  38. #
  39. # Overhauled by Karlson2k to be build under MSYS, primary for XBMC
  40. ################################################################################
  41.  
  42. test_opt () {
  43. test_valid_opt 'build_type' 'win32' 'win64' 'multi'
  44. test_valid_opt 'mingw_w64_ver' "$mingw_w64_release_ver" 'svn'
  45. test_valid_opt 'thread_lib' 'winpthreads' 'pthreads-w32' 'disable'
  46. check_cpu_count_optarg
  47. test_valid_opt 'binutils_ver' "$binutils_release_ver" 'cvs'
  48. if [[ "$binutils_ver" = 'cvs' ]]; then
  49.   if ! type -P makeinfo >/dev/null; then
  50.     $clear
  51.     echo "makeinfo is needed to compile the CVS version of binutils and will need be installed. On Debian it is part of the 'texinfo' software package."
  52.     exit 1
  53.   fi
  54. fi
  55. test_valid_opt 'gcc_ver' "$gcc_47_ver" "$gcc_46_ver" "$gcc_45_ver" 'svn'
  56. check_gcc_langs_optarg
  57. }
  58.  
  59. test_valid_opt () {
  60. if [[ -z "${!1}" ]]; then
  61.   return
  62. fi
  63. local opt
  64. local valid_arg
  65. opt="$1"
  66. shift
  67.  
  68. for args do
  69.   if [[ "$args" = "${!opt}" ]]; then
  70.     valid_arg='yes'
  71.   fi
  72. done
  73.  
  74. if [[ "$valid_arg" != 'yes' ]]; then
  75.   $clear
  76.   echo "Error, '${!opt}' is not a valid option for --${opt//_/-}. The valid options are: ${*}"
  77.   exit 1
  78. fi
  79. }
  80.  
  81. about () {
  82. $clear
  83. read -p \
  84. '################################################################################
  85. #                                                                              #
  86. #                        MingGW-w64 Build Script k-0.9.5.3                     #
  87. #                                                                              #
  88. #                                                                              #
  89. #            This script will build MinGW-w64 for Win32 and Win64.             #
  90. #                                                                              #
  91. #      This version can build the following packages into the toolchain        #
  92. #                                                                              #
  93. #          mingw-w64                        gmp                                #
  94. #                                                                              #
  95. #          mpfr                             mpc                                #
  96. #                                                                              #
  97. #          ppl                              cloog-ppl                          #
  98. #                                                                              #
  99. #          binutils                         gcc                                #
  100. #                                                                              #
  101. #          cloog                            isl                                #
  102. #                                                                              #
  103. #          winpthreads                      threads-win32                      #
  104. #                                                                              #
  105. #                                                                              #
  106. #                            Press Enter to continue                           #
  107. #                                                                              #
  108. #                     Copyright (C) 2011-2012 Kyle Schwarz                     #
  109. #                     Copyright (C) 2012 Karlson2k                             #
  110. #                This program comes with ABSOLUTELY NO WARRANTY                #
  111. #                                                                              #
  112. ################################################################################'
  113. }
  114.  
  115. display_help () {
  116. cat <<EOF
  117. Compile MinGW-w64 as a cross-toolchain for Win32 or Win64
  118.  
  119. Available options are specified in parentheses.
  120.  
  121. Defaults for the options are specified in brackets.
  122.  
  123. General:
  124.   -h, --help     display this help and exit
  125.   -a, --about    display the "About" page
  126.   -V, --version  display version information and exit
  127.  
  128. Compile Options:
  129.   --build-type=TYPE         compile for TYPE (win32, win64, multi) [multi]
  130.   --default-configure       compile with default options for all unset options
  131.   --interactive             ask for all unset options
  132.   --allow-overwrite         allow overwrite if no updates are found
  133.   --rebuild-all             rebuild all packages
  134.   --mingw-w64-ver=NUMBER    compile with MinGW-w64 VERSION ($mingw_w64_release_ver, svn)
  135.                             [svn]
  136.   --cpu-count=NUMBER        use NUMBER of cores/threads to compile with
  137.   --binutils-ver=VERSION    compile with binutils VERSION ($binutils_release_ver, cvs) [$binutils_release_ver]
  138.   --gcc-ver=VERSION         compile with GCC VERSION ($gcc_47_ver, $gcc_46_ver, $gcc_45_ver, svn)
  139.                             [$gcc_47_ver]
  140.   --gcc-langs=LANG1,LANG2   compile GCC with support for additional LANG (ada,
  141.                             fortran, go, java, objc, obj-c++, all) [fortran]
  142.   --enable-nls              enable "Native Language Support"
  143.                             warning: enabled NLS could reduce portability    
  144.   --disable-shared          compile a static only toolchain
  145.   --threads=LIB             compile with support for thread LIB (winpthreads,
  146.                             pthreads-w32, disable) [pthreads-w32]
  147.   --clean-build             remove the unneeded directories after a successful
  148.                             compile, leaving only the built toolchain. The
  149.                             'build', 'source', and 'packages' directories will
  150.                             be removed.
  151.   --with-mingw-w64-additional-tools
  152.                             rebuild MinGW-w64 at final stage using final GCC build,
  153.                             with additional MinGW tools and libraries
  154.  
  155. Report bugs to http://forum.xbmc.org/private.php?action=send&uid=77145.
  156. EOF
  157. }
  158.  
  159. yes_no_sel () {
  160. unset user_input
  161. local question="$1"
  162. shift
  163. $clear
  164. while [[ "$user_input" != [YyNn] ]]; do
  165.   echo -n "$question"
  166.   read user_input
  167.   if [[ "$user_input" != [YyNn] ]]; then
  168.     $clear; echo 'Your selection was not vaild, please try again.'; echo
  169.   fi
  170. done
  171. }
  172.  
  173. var_in_array() {
  174. local var=$1
  175. local array
  176. shift
  177. for array; do
  178.   [[ $var = "$array" ]] && return
  179. done
  180. return 1
  181. }
  182.  
  183. create_pkg_dirs () {
  184. local pkg_name
  185. pkg_name="$1"
  186. mkdir -p "$pkg_name"
  187. cd "$pkg_name" || exit 1
  188. mkdir -p 'build' 'source'
  189. cd 'source' || exit 1
  190. }
  191.  
  192. use_cpu_count () {
  193. if [[ "$interactive" == "yes" && "$cpu_count" -ge '2' ]]; then
  194.   while [[ "$select_cpu_count" != [1-$cpu_count] ]]; do
  195.     $clear; echo -n "A total of $cpu_count cores/threads were found. How many would you like to use to compile MinGW-w64? You can set this option with: '--cpu-count=NUMBER', see --help for more information. [1-$cpu_count]: "
  196.     read select_cpu_count
  197.   done
  198.   cpu_count="$select_cpu_count"
  199. elif [[ "$cpu_count" -gt '7' && "$build_sys" = "Msys" ]]; then
  200.   cpu_count="7" # Using 8 or more threads on Msys could cause "make" hangs
  201. fi
  202.  
  203. if [[ "$cpu_count" -lt '1' ]]; then
  204.   yes_no_sel 'The number of cores/threads could not be found, would you like to manually enter the number of cores/threads your CPU has? (If "n" is selected, one core/thread will be used). [y/n]: '
  205.   if [[ "$user_input" = [Yy] ]]; then
  206.     $clear; echo -n 'Please enter the number of cores/threads your CPU has. (Make sure the number you enter is correct, trying to use more cores/threads than your CPU has can cause your system to crash).: '
  207.     read cpu_count
  208.   else
  209.     cpu_count='1'
  210.   fi
  211. fi
  212. }
  213.  
  214. make_link () {
  215. if [ "$link_style" = "msys" ]; then
  216.   if [ -d $1 ]; then
  217.     cmd /c "mklink /j \"$2\" \"$1\""
  218.   else
  219.     ln $1 $2
  220.   fi
  221. else
  222.   ln -s $1 $2
  223. fi
  224. }
  225.  
  226. pkg_touch_success () {
  227. local pkg_name pkg_state pkg_ver pkg_arch
  228. pkg_name="$1"
  229. pkg_ver="$2"
  230. pkg_state="$3"
  231. pkg_arch="$4"
  232. shift 4
  233. case "$pkg_state" in
  234.   "download" ) pkg_arch="all" ;;
  235.   "patch" ) pkg_arch="all" ;;
  236. esac
  237. mkdir -pv "$touch_files_dir/$pkg_name"
  238. touch "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-$pkg_arch.$pkg_state" || exit 100
  239. }
  240.  
  241. pkg_touch_unsuccess () {
  242. local pkg_name pkg_state pkg_ver pkg_arch
  243. pkg_name="$1"
  244. pkg_ver="$2"
  245. pkg_state="$3"
  246. pkg_arch="$4"
  247. shift 4
  248. local pathname="$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-$pkg_arch."
  249. case "$pkg_state" in
  250.   "download" ) rm -fv "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-"* ;;
  251.   "patch" ) rm -fv "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-"*."patch"
  252.             rm -fv "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-"*."configure"
  253.             rm -fv "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-"*."make"
  254.             rm -fv "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-"*."install" ;;
  255.   "configure" ) rm -fv "${pathname}configure"
  256.                 rm -fv "${pathname}make"
  257.                 rm -fv "${pathname}install" ;;
  258.   "make" )  rm -fv "${pathname}make"
  259.             rm -fv "${pathname}install" ;;
  260.   "install" )   rm -fv "${pathname}install" ;;
  261. esac
  262. return 0
  263. }
  264.  
  265. check_pkg_touch_success () {
  266. local pkg_name pkg_state pkg_ver pkg_arch
  267. pkg_name="$1"
  268. pkg_ver="$2"
  269. pkg_state="$3"
  270. pkg_arch="$4"
  271. shift 4
  272. case "$pkg_state" in
  273.   "download" ) pkg_arch="all" ;;
  274.   "patch" ) pkg_arch="all" ;;
  275. esac
  276. if [[ -f "$touch_files_dir/$pkg_name/$pkg_name-$pkg_ver-$pkg_arch.$pkg_state" ]]; then
  277.   return 0
  278. fi
  279. pkg_touch_unsuccess "$pkg_name" "$pkg_ver" "$pkg_state" "$pkg_arch"
  280. return 1
  281. }
  282.  
  283. choose_mingw_w64_ver () {
  284. $clear
  285. while [[ "$mingw_w64_ver_select" != [1-3] ]]; do
  286. cat <<EOF
  287. Which MinGW-w64 version would you like to build? You can set this option with: '--mingw-w64-ver=NUMBER', see --help for more information.
  288.   1. MinGW-w64 SVN (default)
  289.   2. MinGW-w64 $mingw_w64_release_ver
  290. EOF
  291. echo -n 'Choose which MinGW-w64 version would would like to build. [1-2]: '
  292. read mingw_w64_ver_select
  293. case "$mingw_w64_ver_select" in
  294.   1 ) mingw_w64_ver='svn' ;;
  295.   2 ) mingw_w64_ver="$mingw_w64_release_ver" ;;
  296.   * ) $clear; echo 'Your selection was not valid, please try again.'; echo ;;
  297. esac
  298. done
  299. }
  300.  
  301. choose_binutils_ver () {
  302. $clear
  303. while [[ "$binutils_ver_select" != [1-3] ]]; do
  304. cat <<EOF
  305. Which Binutils version would you like to build? You can set this option with: '--binutils-ver=VERSION', see --help for more information.
  306.   1. Binutils $binutils_release_ver (default)
  307.   2. Binutils cvs
  308. EOF
  309. echo -n 'Choose which Binutils version would would like to build. [1-2]: '
  310. read binutils_ver_select
  311. case "$binutils_ver_select" in
  312.   1 ) binutils_ver="$binutils_release_ver" ;;
  313.   2 ) binutils_ver='cvs' ;;
  314.   * ) $clear; echo 'Your selection was not valid, please try again.'; echo ;;
  315. esac
  316. done
  317. }
  318.  
  319. choose_gcc_ver () {
  320. $clear
  321. while [[ "$gcc_ver_select" != [1-3] ]]; do
  322. cat <<EOF
  323. Which GCC version would you like to build? You can set this option with: '--gcc-ver=VERSION', see --help for more information.
  324.   1. GCC $gcc_47_ver (default)
  325.   2. GCC $gcc_46_ver
  326.   3. GCC $gcc_45_ver
  327.   4. GCC svn
  328. EOF
  329. echo -n 'Choose which GCC version would would like to build. [1-4]: '
  330. read gcc_ver_select
  331. case "$gcc_ver_select" in
  332.   1 ) gcc_ver="$gcc_47_ver" ;;
  333.   2 ) gcc_ver="$gcc_46_ver" ;;
  334.   3 ) gcc_ver="$gcc_45_ver" ;;
  335.   4 ) gcc_ver='svn' ;;
  336.   * ) $clear; echo 'Your selection was not valid, please try again.'; echo ;;
  337. esac
  338. done
  339. }
  340.  
  341. choose_static_build () {
  342. yes_no_sel "Would you like to build a fully static build? You can set this option with: '--disable-shared', see --help for more information. (Select \"n\" if you are not sure, \"n\" is the default). [y/n]: "
  343. if [[ "$user_input" = [Yy] ]]; then
  344.   static_build=('--disable-shared' '--enable-static')
  345. else
  346.   unset static_build
  347. fi
  348. }
  349.  
  350. choose_disable_nls () {
  351. yes_no_sel "Would you like to enable NLS support? Native Language Support (NLS), which lets GCC/Binutils output diagnostics in languages other than American English. You can set this option with: '--enable-nls', see --help for more information. (Select \"n\" if you are not sure, \"n\" is the default). [y/n]: "
  352. if [[ "$user_input" = [Nn] ]]; then
  353.   disable_nls=('--disable-nls')
  354. else
  355.   unset disable_nls
  356. fi
  357. }
  358.  
  359. choose_lang_sel () {
  360. yes_no_sel "Would you like to manualy configure which languages GCC will support? You can set this option with: '--gcc-langs=LANG1,LANG2', see --help for more information. (if \"n\" is input only C, C++ and Fortran will be enabled). [y/n]: "
  361. if [[ "$user_input" = [Yy] ]]; then
  362.   $clear
  363.   set_langs
  364. else
  365.   enabled_langs=('c' 'c++' 'fortran')
  366. fi
  367. }
  368.  
  369. set_langs () {
  370. if [[ "$gcc_ver" != "$gcc_45_ver" ]]; then
  371.   all_langs=('ada' 'c' 'c++' 'fortran' 'go' 'java' 'objc' 'obj-c++')
  372.   formated_langs=('Ada' 'C' 'C++' 'Fortran' 'Go' 'Java' 'Objective-C' 'Objective-C++')
  373. else
  374.   all_langs=('ada' 'c' 'c++' 'fortran' 'java' 'objc' 'obj-c++')
  375.   formated_langs=('Ada' 'C' 'C++' 'Fortran' 'Java' 'Objective-C' 'Objective-C++')
  376. fi
  377.  
  378. cat <<'EOF'
  379. Choose which languages you would like GCC to support.
  380.   1. C, C++ and Fortran (default)
  381.   2. All detected
  382.   3. C, C++ and manually choose for each other language.
  383. EOF
  384. echo -n 'Input your choice [1-3]: '
  385. read sel_set_langs
  386. case "$sel_set_langs" in
  387.   1 ) enabled_langs=('c' 'c++' 'fortran')
  388.       $clear
  389.       confirm_langs ;;
  390.   2 ) enabled_langs=('all')
  391.       $clear
  392.       confirm_langs ;;
  393.   3 ) custom_langs ;;
  394.   * ) $clear; echo 'Your selection was not vaild, please try again.'; echo
  395.       set_langs
  396. esac
  397. }
  398.  
  399. custom_langs () {
  400. unset enabled_langs
  401. local num='-1'
  402. for lang in "${formated_langs[@]}"; do
  403.   ((num++))
  404.   if [[ "${all_langs[$num]}" = "c" || "${all_langs[$num]}" = "c++" ]]; then
  405.     enabled_langs=("${enabled_langs[@]}" "${all_langs[$num]}")
  406.     continue
  407.   fi
  408.   yes_no_sel "Would you like to build GCC with $lang support? [y/n]: "
  409.   if [[ "$user_input" = [Yy] ]]; then
  410.     enabled_langs=("${enabled_langs[@]}" "${all_langs[$num]}")
  411.   fi
  412. done
  413. confirm_langs
  414. }
  415.  
  416. confirm_langs () {
  417. if [[ "$enabled_langs" = 'all' ]]; then
  418.   echo 'GCC will attempt to detect and build all of the following languages. It will silently disable the languages it can not find. (A "*" indicates that GCC will attempt to support the language).'
  419. else
  420.   echo 'The following languages will be supported in GCC. If one of the selected languages can not be found on your system when GCC is built it will fail and you will need to rerun this script after you have installed the failed language. (A "*" indicates that GCC will support the language).'
  421. fi
  422.  
  423. local num='0'
  424. for lang in "${all_langs[@]}"; do
  425.   if var_in_array "$lang" "${enabled_langs[@]}" || [[ "${enabled_langs}" = 'all' ]]; then
  426.     echo "  [*] ${formated_langs[$num]}"
  427.   else
  428.     echo "  [ ] ${formated_langs[$num]}"
  429.   fi
  430.   ((num++))
  431. done
  432.  
  433. echo -n 'Are the languages selected correct? (if "n" is selected, you will be allowed to reconfigure you language selection). [y/n]: '
  434. read user_input
  435. case "$user_input" in
  436.   [Nn] ) $clear
  437.          unset enabled_langs
  438.          set_langs ;;
  439.   [Yy] ) ;;
  440.   *    ) $clear; echo 'Your selection was not valid, please try again.'; echo
  441.          confirm_langs ;;
  442. esac
  443. }
  444.  
  445. download_extract () {
  446. local package_name="$1"
  447. local download_url="$2"
  448. local archive_ext="$3"
  449. local force_overwrite="$4"
  450. shift 4
  451.  
  452. case "$archive_ext" in
  453.   'tar.gz' ) archive_type='z' ;;
  454.   'tar.bz2' ) archive_type='j' ;;
  455.   'tar.xz' ) archive_type='J' ;;
  456. esac
  457.  
  458. if [[ -d "$package_name" && "$force_overwrite" != "force" ]]; then
  459.   return 0
  460. fi
  461.  
  462. if [[ ! -f "$package_name.$archive_ext" ]]; then
  463.   wget "$download_url.$archive_ext"  || exit 1
  464. fi
  465.  
  466. if tar -xv"$archive_type"f "$package_name.$archive_ext"; then
  467.   return 0
  468. else
  469.   rm -rfv "$package_name.$archive_ext" "$package_name"
  470.   wget "$download_url.$archive_ext"  || exit 1
  471.   tar -xv"$archive_type"f "$package_name.$archive_ext" || exit 1
  472. fi
  473. }
  474.  
  475. clean_build () {
  476. cd '..'
  477. rm -frv 'build' || exit 1
  478. mkdir -p 'build'
  479. cd 'build' || exit 1
  480. }
  481.  
  482. #########################################################################################################################################################################
  483. ####################################### Main build function #############################################################################################################
  484. build_mingw_w64 () {
  485. target_arch="$1"
  486. case "$target_arch" in
  487.   'win32' ) mingw_w64_target="$target_i686"; mingw_w64_prefix="$mingw_w64_i686_prefix" ;;
  488.   'win64' ) mingw_w64_target="$target_x86_64"; mingw_w64_prefix="$mingw_w64_x86_64_prefix" ;;
  489. esac
  490. shift 1
  491.  
  492. if [[ "$rebuild" = 'yes' ]]; then
  493.   rm -rf "$touch_files_dir"
  494.   mkdir -vp "$touch_files_dir"
  495. fi
  496. cd "$working_dir" || exit 1
  497.  
  498. echo
  499. echo "*******************************************************************************"
  500. echo "************************** Cleaning *******************************************"
  501. echo
  502. rmdir -v "${mingw_w64_prefix}/mingw" 2> /dev/null
  503. rm -frv "$mingw_w64_prefix"
  504.  
  505. cd 'packages' || exit 1
  506. create_pkg_dirs 'gcc'
  507. mkdir -p "$packages_dir/gcc/packages"
  508. if [[ "$gcc_ver" = "$gcc_47_ver" || "$gcc_ver" = 'svn' ]]; then
  509.   remake_binutils_with_gcc="yes"
  510. fi
  511.  
  512. build_binutils
  513.  
  514. if [[ "$build_sys" = "Msys" ]]; then
  515.   cd "$mingw_w64_prefix/bin"
  516.   export PATH="$(pwd -L):$PATH"
  517. else
  518.   export PATH="$mingw_w64_prefix/bin:$PATH"
  519. fi
  520.  
  521. cd "$mingw_w64_build_dir" || exit 100
  522. headers_source="$mingw_w64_source_dir/mingw-w64-$mingw_w64_ver/mingw-w64-headers"
  523. headers_prefix="$mingw_w64_prefix/$mingw_w64_target"
  524. if [[ ! -d "$mingw_w64_build_dir/$mingw_w64_ver-${mingw_w64_target}-headers" ]] || ! check_pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-headers"; then
  525.   pkg_touch_unsuccess 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-headers"
  526.   echo
  527.   echo "*******************************************************************************"
  528.   echo "************************** Cleaning MinGW64 headers ***************************"
  529.   echo
  530.   rm -frv "$mingw_w64_ver-$mingw_w64_target-headers"
  531.   mkdir -p "$mingw_w64_ver-$mingw_w64_target-headers"
  532.   cd "$mingw_w64_ver-$mingw_w64_target-headers" || exit 100
  533.   echo
  534.   echo "*******************************************************************************"
  535.   echo "************************** Configuring MinGW64 headers ************************"
  536.   echo
  537.   "$headers_source/configure" --enable-sdk=all --build="$system_type" --host="$mingw_w64_target" --prefix="$headers_prefix" || exit 1
  538. fi
  539. pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-headers"
  540.  
  541. cd "$mingw_w64_build_dir/$mingw_w64_ver-${mingw_w64_target}-headers" || exit 100
  542. echo
  543. echo "*******************************************************************************"
  544. echo "************************** Installing MinGW64 headers *************************"
  545. echo
  546. make install-strip || exit 1
  547. cd "$mingw_w64_prefix" || exit 1
  548. # make_link "./$mingw_w64_target" './mingw' # not needed with "native-system-headers"
  549.  
  550. build_gmp
  551. build_mpfr
  552. build_mpc
  553. build_ppl
  554. build_cloog_ppl
  555. build_isl
  556. build_cloog
  557.  
  558. # Build GCC core
  559. cd "$packages_dir/gcc/source" || exit 1
  560. if [[ ! -d "$packages_dir/gcc/source/gcc-$gcc_ver" ]] || ! check_pkg_touch_success 'gcc' "$gcc_ver" 'download' "$mingw_w64_target"; then
  561.   pkg_touch_unsuccess 'gcc' "$gcc_ver" 'download' "$mingw_w64_target"
  562.   echo
  563.   echo "*******************************************************************************"
  564.   echo "************************** Downloading GCC ************************************"
  565.   echo
  566.   if [[ "$gcc_ver" != 'svn' ]]; then
  567.     download_extract "gcc-$gcc_ver" "ftp://ftp.gnu.org/gnu/gcc/gcc-$gcc_ver/gcc-$gcc_ver" 'tar.bz2'
  568.   else
  569.     if [[ -d 'gcc-svn' ]]; then
  570.       cd 'gcc-svn' || exit 100
  571.       touch "../svn-version"
  572.       read -r svn_ver_before < "../svn-version"
  573.       svn update || exit 1
  574.       svn_ver_after=$(svn info | grep "^Revision: "); svn_ver_after=${svn_ver_after:10}
  575.       echo "$svn_ver_after" > "../svn-version"
  576.       cd '..' || exit 100
  577.       if [[ "$svn_ver_before" != "$svn_ver_after" ]]; then
  578.         rm -fv "$touch_files_dir/gcc/gcc-svn-"*
  579.       fi
  580.     else
  581.       svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc-svn || exit 1
  582.       cd 'gcc-svn' || exit 100
  583.       svn_ver_after=$(svn info | grep "^Revision: "); svn_ver_after=${svn_ver_after:10}
  584.       echo "$svn_ver_after" > "../svn-version"
  585.       cd '..' || exit 100
  586.       rm -fv "$touch_files_dir/gcc/gcc-svn-"*
  587.     fi
  588.   fi
  589.   pushd "gcc-$gcc_ver"
  590.   wget -O ecj.jar ftp://sourceware.org/pub/java/ecj-latest.jar
  591.   popd
  592.   pkg_touch_success 'gcc' "$gcc_ver" 'download' "$mingw_w64_target"
  593. fi
  594.  
  595. if [[ "$remake_binutils_with_gcc" = "yes" ]]; then
  596.   if ! check_pkg_touch_success 'gcc' "$gcc_ver" 'patch' "$mingw_w64_target"; then
  597.     local binutilssource="../../binutils/source/binutils-$binutils_ver"
  598.     make_link "$binutilssource/bfd" "gcc-$gcc_ver/bfd"
  599.     make_link "$binutilssource/binutils" "gcc-$gcc_ver/binutils"
  600.     make_link "$binutilssource/cpu" "gcc-$gcc_ver/cpu"
  601.     make_link "$binutilssource/elfcpp" "gcc-$gcc_ver/elfcpp"
  602.     make_link "$binutilssource/etc" "gcc-$gcc_ver/etc"
  603.     make_link "$binutilssource/gas" "gcc-$gcc_ver/gas"
  604.     make_link "$binutilssource/gprof" "gcc-$gcc_ver/gprof"
  605.     make_link "$binutilssource/ld" "gcc-$gcc_ver/ld"
  606.     make_link "$binutilssource/opcodes"  "gcc-$gcc_ver/opcodes"
  607.     make_link "$binutilssource/texinfo" "gcc-$gcc_ver/texinfo"
  608.     if [[ "$gcc_ver" = "$gcc_47_ver" ]]; then
  609.       cp -vf "$packages_dir/gcc/source/gcc-$gcc_ver/include/splay-tree.h" "$packages_dir/gcc/source/gcc-$gcc_ver/include/splay-tree-gcc.h"
  610.       cp -vfr "$binutilssource/config" "$binutilssource/include" "$binutilssource/intl" "$binutilssource/libiberty" \
  611.         -t "$packages_dir/gcc/source/gcc-$gcc_ver"
  612.       cp -vf "$packages_dir/gcc/source/gcc-$gcc_ver/include/splay-tree-gcc.h" "$packages_dir/gcc/source/gcc-$gcc_ver/include/splay-tree.h"
  613.     else
  614.       cp -vur "$binutilssource/config" "$binutilssource/include" \
  615.         -t "$packages_dir/gcc/source/gcc-$gcc_ver"
  616.     fi
  617.     pkg_touch_success 'gcc' "$gcc_ver" 'patch' "$mingw_w64_target"
  618.   fi
  619. else
  620.   if check_pkg_touch_success 'gcc' "$gcc_ver" 'patch' "$mingw_w64_target"; then
  621.     pkg_touch_unsuccess 'gcc' "$gcc_ver" 'patch' "$mingw_w64_target"
  622.   fi
  623. fi
  624.  
  625. cd "$working_dir/packages/gcc" || exit 1
  626. # now in packages/gcc
  627.  
  628. if [[ ! -d "build/$gcc_ver-$mingw_w64_target" ]] || ! check_pkg_touch_success 'gcc' "$gcc_ver" 'configure' "$mingw_w64_target"; then
  629.   pkg_touch_unsuccess 'gcc' "$gcc_ver" 'configure' "$mingw_w64_target"
  630.   echo
  631.   echo "*******************************************************************************"
  632.   echo "************************** Cleaning GCC ***************************************"
  633.   echo
  634.   # now in packages/gcc
  635.   mkdir -vp "build"
  636.   cd "build" || exit 100
  637.   # now in packages/gcc/build
  638.   rm -frv "$gcc_ver-$mingw_w64_target"
  639.   mkdir -vp "$gcc_ver-$mingw_w64_target"
  640.   cd "$gcc_ver-$mingw_w64_target" || exit 100
  641.  
  642.   case "$gcc_ver" in
  643.     "$gcc_47_ver" ) configure_gcc "$gcc_47_ver" || exit 1 ;;
  644.     "$gcc_46_ver" ) configure_gcc "$gcc_46_ver" || exit 1 ;;
  645.     "$gcc_45_ver" ) configure_gcc "$gcc_45_ver" || exit 1 ;;
  646.     'svn'         ) configure_gcc 'svn' || exit 1 ;;
  647.   esac
  648.   pkg_touch_success 'gcc' "$gcc_ver" 'configure' "$mingw_w64_target"
  649. fi
  650.  
  651. cd "$working_dir/packages/gcc/build/$gcc_ver-$mingw_w64_target" || exit 100
  652. if ! check_pkg_touch_success 'gcc' "$gcc_ver" 'make' "$mingw_w64_target"; then
  653.   echo
  654.   echo "*******************************************************************************"
  655.   echo "************************** Making GCC core ************************************"
  656.   echo
  657.   make -j "$cpu_count" all-gcc || exit 1
  658. fi
  659. echo
  660. echo "*******************************************************************************"
  661. echo "************************** Installing GCC core ********************************"
  662. echo
  663. make -j "$cpu_count" install-gcc || exit 1
  664.  
  665. # Build mingw-w64 CRT
  666. cd "$mingw_w64_build_dir" || exit 100
  667. crt_source="$mingw_w64_source_dir/mingw-w64-$mingw_w64_ver/mingw-w64-crt"
  668. crt_prefix="$mingw_w64_prefix/$mingw_w64_target"
  669. if [[ "$target_arch" = 'win32' ]]; then
  670.   crt_arch_flag="--enable-lib32 --disable-lib64 --enable-leading-underscores"
  671. else
  672.   crt_arch_flag="--disable-lib32 --enable-lib64 --disable-leading-underscores"
  673. fi
  674. if [[ ! -d "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-crt" ]] || ! check_pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-crt"; then
  675.   pkg_touch_unsuccess 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-crt"
  676.   echo
  677.   echo "*******************************************************************************"
  678.   echo "************************** Cleaning MinGW64 CRT *******************************"
  679.   echo
  680.   rm -frv "$mingw_w64_ver-$mingw_w64_target-crt"
  681.   mkdir -p "$mingw_w64_ver-$mingw_w64_target-crt"
  682.   cd "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-crt" || exit 100
  683.   echo
  684.   echo "*******************************************************************************"
  685.   echo "************************** Configuring MinGW64 CRT ****************************"
  686.   echo
  687.   if [[ "$target_arch" = 'win32' ]]; then
  688.     crt_arch_flag="--enable-lib32 --disable-lib64 --enable-leading-underscores"
  689.   else
  690.     crt_arch_flag="--disable-lib32 --enable-lib64 --disable-leading-underscores"
  691.   fi
  692.   "$crt_source/configure" --build="$system_type" --host="$mingw_w64_target" --prefix="$crt_prefix" --with-sysroot="$crt_prefix" --disable-libce $crt_arch_flag || exit 1
  693. fi
  694. pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-crt"
  695.  
  696. cd "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-crt" || exit 100
  697. if ! check_pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'make' "${mingw_w64_target}-crt"; then
  698.   echo
  699.   echo "*******************************************************************************"
  700.   echo "************************** Making MinGW64 CRT *********************************"
  701.   echo
  702.   make -j "$cpu_count" || exit 1
  703. fi
  704. pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'make' "${mingw_w64_target}-crt"
  705. echo
  706. echo "*******************************************************************************"
  707. echo "************************** Installing MinGW64 CRT *****************************"
  708. echo
  709. make -j "$cpu_count" install-strip || exit 1
  710.  
  711. if [[ "$thread_lib" != 'disable' ]]; then
  712.   build_thread_lib "$mingw_w64_target" "$mingw_w64_prefix/$mingw_w64_target" || exit 1
  713. fi
  714.  
  715. # Build full GCC
  716. cd "$packages_dir/gcc/build/$gcc_ver-$mingw_w64_target" || exit 100
  717. if ! check_pkg_touch_success 'gcc' "$gcc_ver" 'make' "$mingw_w64_target"; then
  718.   echo
  719.   echo "*******************************************************************************"
  720.   echo "************************** Making full GCC ************************************"
  721.   echo
  722.   make -j "$cpu_count" || exit 1
  723. fi
  724. pkg_touch_success 'gcc' "$gcc_ver" 'make' "$mingw_w64_target"
  725. echo
  726. echo "*******************************************************************************"
  727. echo "************************** Installing full GCC ********************************"
  728. echo
  729. make -j "$cpu_count" install-strip || exit 1
  730.  
  731. if [[ "$with_mingw_tools" = 'yes' ]]; then
  732.   mingw_full_rebuild
  733. fi  
  734. return 0
  735. }
  736.  
  737. download_source () {
  738. case "$1" in
  739.   'multi' ) if [[ -d "$mingw_w64_i686_prefix" && -d "$mingw_w64_x86_64_prefix" ]]; then  prefix_present='yes'; fi ;;
  740.   'win32' ) if [[ -d "$mingw_w64_i686_prefix" ]]; then  prefix_present='yes'; fi ;;
  741.   'win64' ) if [[ -d "$mingw_w64_x86_64_prefix" ]]; then  prefix_present='yes'; fi ;;
  742. esac
  743. shift
  744. mkdir -p 'packages' 'source' 'build'
  745. cd 'packages' || exit 1
  746. rm -frv 'config.guess'
  747. wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' || { ping -c 1 git.savannah.gnu.org >/dev/null 2>&1 || $clear; echo 'savannah.gnu.org seems to be offline right now and is needed to download the file "config.guess", please try again later.'; echo; rm -f 'config.guess' && exit 1; }
  748. system_type="$(sh config.guess)"
  749.  
  750. cd "$mingw_w64_source_dir" || exit 1
  751. echo
  752. echo "*******************************************************************************"
  753. echo "************************** Downloading MinGW64 ********************************"
  754. echo
  755. if [[ "$mingw_w64_ver" = 'svn' ]]; then
  756.   if [[ -d 'mingw-w64-svn' ]]; then
  757.     cd 'mingw-w64-svn' || exit 1
  758.     touch "../svn-version"
  759.     read -r svn_ver_before < "../svn-version"
  760.     svn update -r ${mingw_w64_svn_rev:=HEAD} || exit 1
  761.     svn_ver_after=$(svn info | grep "^Revision: "); svn_ver_after=${svn_ver_after:10}
  762.     echo "$svn_ver_after" > "../svn-version"
  763.     if [[ "$svn_ver_before" != "$svn_ver_after" ]]; then
  764.       rm -fv "$touch_files_dir/mingw_w64/mingw_w64-svn"*
  765.     elif [[ "$allow_overwrite" != 'yes' &&  "$prefix_present" = 'yes' ]]; then
  766.       yes_no_sel "MinGW-w64 is already the latest version, continue with the build anyway? You can set this option with: '--allow-overwrite', see '--help' for more information. [y/n]: "
  767.       if [[ "$user_input" = [Nn] ]]; then
  768.         exit 0
  769.       fi
  770.     fi
  771.   else
  772.     mkdir -p 'mingw-w64-svn'
  773.     svn checkout -r ${mingw_w64_svn_rev:=HEAD} http://mingw-w64.svn.sourceforge.net/svnroot/mingw-w64/trunk 'mingw-w64-svn' || exit 100
  774.     cd 'mingw-w64-svn'
  775.     svn_ver_after=$(svn info | grep "^Revision: "); svn_ver_after=${svn_ver_after:10}
  776.     echo $svn_ver_after > "../svn-version"
  777.   fi
  778. else
  779.   if [[ -d "mingw-w64-$mingw_w64_ver" && "$allow_overwrite" != 'yes' &&  "$prefix_present" = 'yes' ]]; then
  780.     yes_no_sel "MinGW-w64 is already the latest version, continue with the build anyway? You can set this option with: '--allow-overwrite', see '--help' for more information. [y/n]: "
  781.     if [[ "$user_input" = [Nn] ]]; then
  782.       exit 0
  783.     fi
  784.   fi
  785.  
  786.   if [[ ! -d "mingw-w64-$mingw_w64_ver" || ! -f "mingw-w64-$mingw_w64_ver.tar.gz" ]]; then
  787.     rm -f "mingw-w64-$mingw_w64_ver.tar.gz" "mingw-w64-$mingw_w64_ver"
  788.     wget -O "mingw-w64-$mingw_w64_ver.tar.gz" http://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${mingw_w64_ver}.tar.gz
  789.     tar -xvzf "mingw-w64-$mingw_w64_ver.tar.gz"
  790.     mv "mingw-w64-v$mingw_w64_ver" "mingw-w64-$mingw_w64_ver"
  791.   fi
  792. fi
  793. }
  794.  
  795. clean_build_fn () {
  796. if [[ "$clean_build" = 'yes' ]]; then
  797.   cd "$working_dir" && rm -frv 'build' 'packages' 'source'
  798.   return
  799. fi
  800. if [[ "$default_config" = 'yes' ]]; then
  801.   return
  802. fi
  803. unset user_input
  804. echo
  805. while [[ "$user_input" != [YyNn] ]]; do
  806.   echo -n "Would you like to clean the build, leaving only the built toolchain? You can set this option with: '--clean-build', see --help for more information. The 'build', 'packages', and 'source' directories along with all files within them will be removed if \"y\" is selected. [y/n]: "
  807.   read user_input
  808.   if [[ "$user_input" = [Yy] ]]; then
  809.     cd "$working_dir" && rm -frv 'build' 'packages' 'source'
  810.   fi
  811.   if [[ "$user_input" != [YyNn] ]]; then
  812.     echo; echo 'Your selection was not vaild, please try again.'; echo
  813.   fi
  814. done
  815. }
  816.  
  817. build_binutils () {
  818. cd "$packages_dir" || exit 1
  819. create_pkg_dirs 'binutils' || exit 1
  820. cd "$packages_dir/binutils/source" || exit 1
  821. echo
  822. echo "*******************************************************************************"
  823. echo "************************** Downloading binutils *******************************"
  824. echo
  825. if [[ "$binutils_ver" != 'cvs' ]]; then
  826.   download_extract "binutils-$binutils_ver" "ftp://ftp.gnu.org/gnu/binutils/binutils-$binutils_ver" 'tar.gz'
  827. else
  828.   if [[ -d 'binutils-cvs' ]]; then
  829.     cd 'binutils-cvs' || exit 1
  830.     read -r oldmd5 _ < <(md5sum './ChangeLog')
  831.     cvs update || exit 1
  832.     read -r newmd5 _ < <(md5sum './ChangeLog')
  833.     if [[ "$oldmd5" != "$newmd5" ]]; then
  834.       rm -rf "$touch_files_dir/binutils/binutils-cvs-"*
  835.     fi
  836.     cd '..'
  837.   else
  838.     cvs -d :pserver:anoncvs@sourceware.org:/cvs/src checkout binutils || exit 1
  839.     mv 'src' 'binutils-cvs'
  840.   fi
  841. fi
  842.  
  843. cd '../build' || exit 1
  844.  
  845. local arch_flag
  846. if [[ "$target_arch" = "win32" ]]; then
  847.   arch_flag="--with-multilib-list=m32 --enable-leading-mingw64-underscores"
  848. else
  849.   arch_flag="--with-multilib-list=m64 --disable-leading-mingw64-underscores"
  850. fi
  851.  
  852. if [[ ! -d "$packages_dir/binutils/build/$binutils_ver-$mingw_w64_target" ]] || ! check_pkg_touch_success 'binutils' "$binutils_ver" 'configure' "$mingw_w64_target"; then
  853.   pkg_touch_unsuccess 'binutils' "$binutils_ver" 'configure' "$mingw_w64_target"
  854.   echo
  855.   echo "*******************************************************************************"
  856.   echo "************************** Cleaning binutils **********************************"
  857.   echo
  858.   rm -rfv "$binutils_ver-$mingw_w64_target"
  859.   mkdir "$binutils_ver-$mingw_w64_target"
  860.   echo
  861.   echo "*******************************************************************************"
  862.   echo "************************** Configuring binutils *******************************"
  863.   echo
  864.   cd "$binutils_ver-$mingw_w64_target" || exit 1
  865.   CC=gcc LDFLAGS="-static" "../../source/binutils-$binutils_ver/configure" \
  866.     --build="$system_type" --target="$mingw_w64_target" "${static_build[@]}" "${disable_nls[@]}" \
  867.     --disable-multilib --with-sysroot="$mingw_w64_prefix" --prefix="$mingw_w64_prefix" \
  868.     --enable-lto $arch_flag || exit 1
  869. fi
  870. pkg_touch_success 'binutils' "$binutils_ver" 'configure' "$mingw_w64_target"
  871.  
  872. cd "$packages_dir/binutils/build/$binutils_ver-$mingw_w64_target" || exit 1
  873. if ! check_pkg_touch_success 'binutils' "$binutils_ver" 'make' "$mingw_w64_target"; then
  874.   echo
  875.   echo "*******************************************************************************"
  876.   echo "************************** Making binutils ************************************"
  877.   echo
  878.   make -j "$cpu_count" || exit 1
  879. fi
  880. pkg_touch_success 'binutils' "$binutils_ver" 'make' "$mingw_w64_target"
  881. echo
  882. echo "*******************************************************************************"
  883. echo "************************** Installing binutils ********************************"
  884. echo
  885. make -j "$cpu_count" install-strip || exit 1
  886. }
  887.  
  888. configure_gcc () {
  889. case "$@" in
  890.   "$gcc_47_ver" ) unset gcc_ldflags ;;
  891.   "$gcc_46_ver" ) gcc_ldflags=("-L$gmp_prefix/lib" "-L$ppl_prefix/lib") ;;
  892.   "$gcc_45_ver" ) unset gcc_ldflags ;;
  893.   'svn'         ) gcc_ldflags=("-L$gmp_prefix/lib") ;;
  894. esac
  895.  
  896. if [[ "$enabled_langs" != *,* ]]; then
  897.   printf -v enabled_langs "%s," "${enabled_langs[@]}"
  898.   enabled_langs="${enabled_langs%,}"
  899. fi
  900.  
  901. local libgomp_flag
  902. if [[ "$thread_lib" != "disable" ]]; then
  903.   export target_configargs="CPPFLAGS=-DPTW32_STATIC_LIB"
  904.   libgomp_flag="--enable-libgomp"
  905. fi
  906.  
  907. local gcc_path="../../source/gcc-$gcc_ver"
  908.  
  909. local arch_flag
  910. if [[ "$target_arch" = "win32" ]]; then
  911.   arch_flag="--disable-sjlj-exceptions --with-multilib-list=m32 --with-dwarf2 --with-arch=pentium3 --enable-leading-mingw64-underscores"
  912. else
  913.   arch_flag="--enable-sjlj-exceptions --with-multilib-list=m64 --with-fpmath=sse  --with-arch=core2 --disable-leading-mingw64-underscores"
  914. fi
  915.  
  916. echo
  917. echo "*******************************************************************************"
  918. echo "************************** Configuring GCC ************************************"
  919. echo
  920.  
  921. if [[ "$gcc_ver" = 'svn' ]]; then
  922. CC=gcc LDFLAGS="${gcc_ldflags[*]} -static" "$gcc_path/configure" \
  923.   --build="$system_type" \
  924.   --host="$system_type" \
  925.   --target="$mingw_w64_target" \
  926.   "${static_build[@]}" "${disable_nls[@]}" \
  927.   --disable-multilib \
  928.   --prefix="$mingw_w64_prefix" \
  929.   --with-sysroot="$mingw_w64_prefix" \
  930.   --with-native-system-header-dir="/$mingw_w64_target/include" \
  931.   --with-mpc="$mpc_prefix" \
  932.   --with-mpfr="$mpfr_prefix" \
  933.   --with-gmp="$gmp_prefix" \
  934.   --with-ppl="$ppl_prefix" \
  935.   --with-cloog="$cloog_prefix" \
  936.   --with-isl="$isl_prefix" \
  937.   --enable-languages="$enabled_langs" \
  938.   --enable-threads=win32 \
  939.   --enable-fully-dynamic-string \
  940.   --enable-bootstrap \
  941.   --enable-version-specific-runtime-libs \
  942.   ${arch_flag} ${libgomp_flag} \
  943.   --enable-lto \
  944.   --disable-win32-registry \
  945.   --with-win32-nlsapi=unicode || exit 1
  946. elif [[ "$gcc_ver" = "$gcc_47_ver" ]]; then
  947. CC=gcc LDFLAGS="${gcc_ldflags[*]} -static" "$gcc_path/configure" \
  948.   --build="$system_type" \
  949.   --host="$system_type" \
  950.   --target="$mingw_w64_target" \
  951.   "${static_build[@]}" "${disable_nls[@]}" \
  952.   --disable-multilib \
  953.   --prefix="$mingw_w64_prefix" \
  954.   --with-sysroot="$mingw_w64_prefix" \
  955.   --with-local-prefix="$mingw_w64_prefix/local" \
  956.   --with-native-system-header-dir="/$mingw_w64_target/include" \
  957.   --with-host-libstdcxx="-lstdc++" \
  958.   --enable-cloog-backend=isl \
  959.   --disable-cloog-version-check \
  960.   --disable-ppl-version-check \
  961.   --with-mpc="$mpc_prefix" \
  962.   --with-mpfr="$mpfr_prefix" \
  963.   --with-gmp="$gmp_prefix" \
  964.   --with-ppl="$ppl_prefix" \
  965.   --with-cloog="$cloog_prefix" \
  966.   --with-isl="$isl_prefix" \
  967.   --enable-languages="$enabled_langs" \
  968.   --disable-build-poststage1-with-cxx \
  969.   --disable-build-with-cxx \
  970.   --enable-threads=win32 \
  971.   --enable-fully-dynamic-string \
  972.   --enable-version-specific-runtime-libs \
  973.   ${arch_flag} ${libgomp_flag} \
  974.   --enable-lto \
  975.   --disable-win32-registry \
  976.   --with-win32-nlsapi=unicode || exit 1
  977. else
  978. CC=gcc LDFLAGS="${gcc_ldflags[*]} -static" "$gcc_path/configure" \
  979.   --build="$system_type" \
  980.   --target="$mingw_w64_target" \
  981.   "${static_build[@]}" "${disable_nls[@]}" \
  982.   --disable-multilib \
  983.   --prefix="$mingw_w64_prefix" \
  984.   --with-sysroot="$mingw_w64_prefix" \
  985.   --with-local-prefix="$mingw_w64_prefix/local" \
  986.   --with-mpc="$mpc_prefix" \
  987.   --with-mpfr="$mpfr_prefix" \
  988.   --with-gmp="$gmp_prefix" \
  989.   --with-host-libstdcxx="-lstdc++" \
  990.   --with-ppl="$ppl_prefix" \
  991.   --with-cloog="$cloog_ppl_prefix" \
  992.   --enable-languages="$enabled_langs" \
  993.   --enable-threads=win32 \
  994.   --enable-fully-dynamic-string \
  995.   --enable-bootstrap \
  996.   --enable-version-specific-runtime-libs \
  997.   $arch_flag \
  998.   --enable-lto \
  999.   --disable-win32-registry \
  1000.   --with-win32-nlsapi=unicode || exit 1
  1001. fi
  1002. # make configure-gcc || exit 1
  1003. }
  1004.  
  1005. build_gmp () {
  1006. if [[ "$gcc_ver" = "$gcc_45_ver" ]]; then
  1007.   gmp_ver='4.3.2'
  1008. else
  1009.   gmp_ver="$gmp_release_ver"
  1010. fi
  1011.  
  1012. gmp_prefix="$gcc_packages_dir/gmp/gmp-$gmp_ver-$uname_m"
  1013.  
  1014. if check_pkg_touch_success 'gmp' "$gmp_ver" 'install' "$uname_m"; then
  1015.   return
  1016. fi
  1017.  
  1018. cd "$gcc_packages_dir" || exit 1
  1019. create_pkg_dirs 'gmp' || exit 1
  1020.  
  1021. echo
  1022. echo "*******************************************************************************"
  1023. echo "************************** Downloading GMP ************************************"
  1024. echo
  1025. download_extract "gmp-$gmp_ver" "ftp://ftp.gnu.org/gnu/gmp/gmp-$gmp_ver" 'tar.bz2'
  1026. if [[ -d "$gcc_packages_dir/gmp/build/$gmp_ver" ]] || ! check_pkg_touch_success 'gmp' "$gmp_ver" 'configure' "$uname_m"; then
  1027.   check_pkg_touch_unsuccess 'gmp' "$gmp_ver" 'configure' "$uname_m"
  1028.   echo
  1029.   echo "*******************************************************************************"
  1030.   echo "************************** Cleaning GMP ***************************************"
  1031.   echo
  1032.   cd "$gcc_packages_dir/gmp" || exit 100
  1033.   mkdir -vp "build"
  1034.   cd "build" || exit 100
  1035.   rm -frv "$gmp_ver"  
  1036.   mkdir -vp "$gmp_ver"
  1037.   cd "$gmp_ver" || exit 100
  1038.   echo
  1039.   echo "*******************************************************************************"
  1040.   echo "************************** Configuring GMP ************************************"
  1041.   echo
  1042.   CC=gcc LDFLAGS="-static" "../../source/gmp-$gmp_ver/configure" --build="$system_type" --prefix="$gmp_prefix" --disable-shared --enable-static --enable-cxx CPPFLAGS='-fexceptions' --enable-fat || exit 1
  1043. fi
  1044. pkg_touch_success 'gmp' "$gmp_ver" 'configure' "$uname_m"
  1045.  
  1046. cd "$gcc_packages_dir/gmp/build/$gmp_ver" || exit 100
  1047. if ! check_pkg_touch_success 'gmp' "$gmp_ver" 'make' "$uname_m"; then
  1048.   echo
  1049.   echo "*******************************************************************************"
  1050.   echo "************************** Making GMP *****************************************"
  1051.   echo
  1052.   make -j "$cpu_count" || exit 1
  1053. fi
  1054. pkg_touch_success 'gmp' "$gmp_ver" 'make' "$uname_m"
  1055.  
  1056. if ! check_pkg_touch_success 'gmp' "$gmp_ver" 'install' "$uname_m"; then
  1057.   echo
  1058.   echo "*******************************************************************************"
  1059.   echo "************************** Installing GMP *************************************"
  1060.   echo
  1061.   make install || exit 1
  1062. fi
  1063. pkg_touch_success 'gmp' "$gmp_ver" 'install' "$uname_m"
  1064. }
  1065.  
  1066. build_mpfr () {
  1067. mpfr_prefix="$gcc_packages_dir/mpfr/mpfr-$mpfr_ver-$uname_m"
  1068.  
  1069. if check_pkg_touch_success 'mpfr' "$mpfr_ver" 'install' "$uname_m"; then
  1070.   return
  1071. fi
  1072.  
  1073. cd "$gcc_packages_dir" || exit 100
  1074. create_pkg_dirs 'mpfr' || exit 1
  1075.  
  1076. echo
  1077. echo "*******************************************************************************"
  1078. echo "************************** Downloading MPFR ***********************************"
  1079. echo
  1080. download_extract "mpfr-$mpfr_ver" "http://www.mpfr.org/mpfr-current/mpfr-$mpfr_ver" 'tar.xz'
  1081. cd "$gcc_packages_dir/mpfr/source/mpfr-$mpfr_ver" || exit 1
  1082. if [[ -f "$gcc_packages_dir/mpfr/source/mpfr-$mpfr_ver/allpatches" ]]; then
  1083.   patch -R -Z -p1 -i allpatches
  1084. fi
  1085. if ! check_pkg_touch_success 'mpfr' "$mpfr_ver" 'patch' "$uname_m"; then
  1086.   wget http://www.mpfr.org/mpfr-3.1.1/allpatches || exit 1
  1087.   patch -N -Z -p1 -i allpatches || exit 1
  1088. fi
  1089. pkg_touch_success 'mpfr' "$mpfr_ver" 'patch' "$uname_m"
  1090.  
  1091. if [[ ! -d "$gcc_packages_dir/mpfr/build/$mpfr_ver" ]] || ! check_pkg_touch_success 'mpfr' "$mpfr_ver" 'configure' "$uname_m"; then
  1092.   pkg_touch_unsuccess 'mpfr' "$mpfr_ver" 'configure' "$uname_m"
  1093.   echo
  1094.   echo "*******************************************************************************"
  1095.   echo "************************** Cleaning MPFR **************************************"
  1096.   echo
  1097.   cd "$gcc_packages_dir/mpfr" || exit 100
  1098.   mkdir -vp "build"
  1099.   cd "build" || exit 100
  1100.   rm -frv "$mpfr_ver"  
  1101.   mkdir -vp "$mpfr_ver"
  1102.   cd "$mpfr_ver" || exit 100
  1103.   echo
  1104.   echo "*******************************************************************************"
  1105.   echo "************************** Configuring MPFR ***********************************"
  1106.   echo
  1107.   CC=gcc LDFLAGS="-static" "../../source/mpfr-$mpfr_ver/configure" --build="$system_type" --prefix="$mpfr_prefix" \
  1108.     --disable-shared --enable-static --with-gmp-build="${gmp_prefix}/../build/$gmp_ver" --disable-dependency-tracking || exit 1
  1109. fi
  1110. pkg_touch_success 'mpfr' "$mpfr_ver" 'configure' "$uname_m"
  1111.  
  1112. cd "$gcc_packages_dir/mpfr/build/$mpfr_ver" || exit 100
  1113. if ! check_pkg_touch_success 'mpfr' "$mpfr_ver" 'make' "$uname_m"; then
  1114.   echo
  1115.   echo "*******************************************************************************"
  1116.   echo "************************** Making MPFR ****************************************"
  1117.   echo
  1118.   make -j "$cpu_count" || exit 1
  1119. fi
  1120. pkg_touch_success 'mpfr' "$mpfr_ver" 'make' "$uname_m"
  1121.  
  1122. if ! check_pkg_touch_success 'mpfr' "$mpfr_ver" 'install' "$uname_m"; then
  1123.   echo
  1124.   echo "*******************************************************************************"
  1125.   echo "************************** Installing MPFR ************************************"
  1126.   echo
  1127.   make install || exit 1
  1128. fi
  1129. pkg_touch_success 'mpfr' "$mpfr_ver" 'install' "$uname_m"
  1130. }
  1131.  
  1132. build_mpc () {
  1133. mpc_prefix="$gcc_packages_dir/mpc/mpc-$mpc_ver-$uname_m"
  1134.  
  1135. if check_pkg_touch_success 'mpc' "$mpc_release_ver" 'install' "$uname_m"; then
  1136.   return
  1137. fi
  1138.  
  1139. cd "$gcc_packages_dir" || exit 100
  1140. create_pkg_dirs 'mpc' || exit 1
  1141.  
  1142. echo
  1143. echo "*******************************************************************************"
  1144. echo "************************** Downloading MPC ************************************"
  1145. echo
  1146. download_extract "mpc-$mpc_release_ver" "http://www.multiprecision.org/mpc/download/mpc-$mpc_release_ver" 'tar.gz'
  1147.  
  1148. if [[ ! -d "$gcc_packages_dir/mpc/build/$mpc_ver" ]] || ! check_pkg_touch_success 'mpc' "$mpc_release_ver" 'configure' "$uname_m"; then
  1149.   check_pkg_touch_unsuccess 'mpc' "$mpc_release_ver" 'configure' "$uname_m"
  1150.   echo
  1151.   echo "*******************************************************************************"
  1152.   echo "************************** Cleaning MPC ***************************************"
  1153.   echo
  1154.   cd "$gcc_packages_dir/mpc" || exit 100
  1155.   mkdir -vp "build"
  1156.   cd "build" || exit 100
  1157.   rm -frv "$mpc_ver"  
  1158.   mkdir -vp "$mpc_ver"
  1159.   cd "$mpc_ver" || exit 100
  1160.   echo
  1161.   echo "*******************************************************************************"
  1162.   echo "************************** Configuring MPC ************************************"
  1163.   echo
  1164.   CC=gcc LDFLAGS="-static" "../../source/mpc-$mpc_release_ver/configure" --build="$system_type" --prefix="$mpc_prefix" --with-gmp="$gmp_prefix" --with-mpfr="$mpfr_prefix" --disable-shared --enable-static --disable-dependency-tracking || exit 1
  1165. fi
  1166. pkg_touch_success 'mpc' "$mpc_release_ver" 'configure' "$uname_m"
  1167.  
  1168. cd "$gcc_packages_dir/mpc/build/$mpc_ver" || exit 100
  1169. if ! check_pkg_touch_success 'mpc' "$mpc_release_ver" 'make' "$uname_m"; then
  1170.   echo
  1171.   echo "*******************************************************************************"
  1172.   echo "************************** Making MPC *****************************************"
  1173.   echo
  1174.   make -j "$cpu_count" || exit 1
  1175. fi
  1176. pkg_touch_success 'mpc' "$mpc_release_ver" 'make' "$uname_m"
  1177.  
  1178. if ! check_pkg_touch_success 'mpc' "$mpc_release_ver" 'install' "$uname_m"; then
  1179.   echo
  1180.   echo "*******************************************************************************"
  1181.   echo "************************** Installing MPC *************************************"
  1182.   echo
  1183.   make install || exit 1
  1184. fi
  1185. pkg_touch_success 'mpc' "$mpc_release_ver" 'install' "$uname_m"
  1186. }
  1187.  
  1188. build_ppl () {
  1189. case "$gcc_ver" in
  1190.   "$gcc_45_ver" ) ppl_ver='0.10.2' ;;
  1191.   'svn' | "$gcc_47_ver" ) ppl_ver="$ppl_release_ver" ;;
  1192.   *  ) ppl_ver='0.12.1' ;;
  1193. esac
  1194.  
  1195. ppl_prefix="$gcc_packages_dir/ppl/ppl-$ppl_ver-$uname_m"
  1196.  
  1197. if check_pkg_touch_success 'ppl' "$ppl_ver" 'install' "$uname_m"; then
  1198.   return
  1199. fi
  1200.  
  1201. cd "$gcc_packages_dir" || exit 100
  1202. create_pkg_dirs 'ppl' || exit 1
  1203.  
  1204. echo
  1205. echo "*******************************************************************************"
  1206. echo "************************** Downloading PPL ************************************"
  1207. echo
  1208. download_extract "ppl-$ppl_ver" "ftp://ftp.cs.unipr.it/pub/ppl/releases/$ppl_ver/ppl-$ppl_ver" 'tar.xz'
  1209. if [[ ! -d "$gcc_packages_dir/ppl/build/$ppl_ver" ]] || ! check_pkg_touch_success 'ppl' "$ppl_ver" 'configure' "$uname_m"; then
  1210.   check_pkg_touch_unsuccess 'ppl' "$ppl_ver" 'configure' "$uname_m"
  1211.   echo
  1212.   echo "*******************************************************************************"
  1213.   echo "************************** Cleaning PPL ***************************************"
  1214.   echo
  1215.   cd "$gcc_packages_dir/ppl" || exit 100
  1216.   mkdir -vp "build"
  1217.   cd "build" || exit 100
  1218.   rm -frv "$ppl_ver"  
  1219.   mkdir -vp "$ppl_ver"
  1220.   cd "$ppl_ver" || exit 100
  1221.   echo
  1222.   echo "*******************************************************************************"
  1223.   echo "************************** Configuring PPL ************************************"
  1224.   echo
  1225.   # be sure to set "--enable-optimization=zero" or lib will fail at least at Polyhedron\memory2.cc test (even with "-O1" optimization)
  1226.   case "$ppl_ver" in
  1227.     '0.10.2' ) CC=gcc LDFLAGS="-static" "../../source/ppl-$ppl_ver/configure" --build="$system_type" --prefix="$ppl_prefix" --enable-static --disable-shared --enable-watchdog --with-libgmp-prefix="$gmp_prefix" CPPFLAGS='-fexceptions' --disable-dependency-tracking || exit 1 ;;
  1228.     * ) CC=gcc LDFLAGS="-static" "../../source/ppl-$ppl_ver/configure" --build="$system_type" --prefix="$ppl_prefix" --enable-static --disable-shared \
  1229.            --with-gmp="$gmp_prefix" CPPFLAGS='-fexceptions' --disable-dependency-tracking  --enable-pch --enable-optimization=zero --enable-interfaces=cxx,c,java \
  1230.            || exit 1 ;;
  1231. #           --enable-instantiations=all
  1232.   esac
  1233. fi
  1234. pkg_touch_success 'ppl' "$ppl_ver" 'configure' "$uname_m"
  1235.  
  1236. cd "$gcc_packages_dir/ppl/build/$ppl_ver" || exit 100
  1237. if ! check_pkg_touch_success 'ppl' "$ppl_ver" 'make' "$uname_m"; then
  1238.   echo
  1239.   echo "*******************************************************************************"
  1240.   echo "************************** Making PPL *****************************************"
  1241.   echo
  1242.   if [[ "$ppl_ver" != "$ppl_release_ver" && "$cpu_count" -ge '2' ]]; then
  1243.     make -j 2 || exit 1
  1244.   else
  1245.     make -j "$cpu_count" || exit 1
  1246.   fi
  1247. fi
  1248. pkg_touch_success 'ppl' "$ppl_ver" 'make' "$uname_m"
  1249.  
  1250. if ! check_pkg_touch_success 'ppl' "$ppl_ver" 'install' "$uname_m"; then
  1251.   echo
  1252.   echo "*******************************************************************************"
  1253.   echo "************************** Installing PPL *************************************"
  1254.   echo
  1255.   make install || exit 1
  1256. fi
  1257. pkg_touch_success 'ppl' "$ppl_ver" 'install' "$uname_m"
  1258. }
  1259.  
  1260. build_cloog_ppl () {
  1261. cloog_ppl_prefix="$gcc_packages_dir/cloog-ppl/cloog-ppl-$cloog_ppl_ver-$uname_m"
  1262.  
  1263. if [[ "$gcc_ver" = 'svn' || "$gcc_ver" = "$gcc_47_ver" ]]; then
  1264.   return
  1265. fi
  1266.  
  1267. if check_pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'install' "$uname_m"; then
  1268.   return
  1269. fi
  1270.  
  1271. cd "$gcc_packages_dir" || exit 100
  1272. create_pkg_dirs 'cloog-ppl' || exit 1
  1273.  
  1274. echo
  1275. echo "*******************************************************************************"
  1276. echo "************************** Downloading CLooG-PPL ******************************"
  1277. echo
  1278. download_extract "cloog-ppl-$cloog_ppl_release_ver" "ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-$cloog_ppl_release_ver" 'tar.gz'
  1279. if [[ ! -d "$gcc_packages_dir/cloog-ppl/build/$cloog_ppl_ver" ]] || ! check_pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'configure' "$uname_m"; then
  1280.   check_pkg_touch_unsuccess 'cloog_ppl' "$cloog_ppl_release_ver" 'configure' "$uname_m"
  1281.   echo
  1282.   echo "*******************************************************************************"
  1283.   echo "************************** Cleaning CLooG-PPL *********************************"
  1284.   echo
  1285.   cd "$gcc_packages_dir/cloog-ppl" || exit 100
  1286.   mkdir -vp "build"
  1287.   cd "build" || exit 100
  1288.   rm -frv "$cloog_ppl_ver"  
  1289.   mkdir -vp "$cloog_ppl_ver"
  1290.   cd "$cloog_ppl_ver" || exit 100
  1291.   echo
  1292.   echo "*******************************************************************************"
  1293.   echo "************************** Configuring CLooG-PPL ******************************"
  1294.   echo
  1295.   CC=gcc LDFLAGS="-static" "../../source/cloog-ppl-$cloog_ppl_release_ver/configure" --build="$system_type" --prefix="$cloog_ppl_prefix" --enable-static --disable-shared --with-gmp="$gmp_prefix" --with-ppl="$ppl_prefix" --with-host-libstdcxx='-lstdc++'  --disable-dependency-tracking || exit 1
  1296. fi
  1297. pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'configure' "$uname_m"
  1298.  
  1299. cd "$gcc_packages_dir/cloog-ppl/build/$cloog_ppl_ver" || exit 100
  1300. if ! check_pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'make' "$uname_m"; then
  1301.   echo
  1302.   echo "*******************************************************************************"
  1303.   echo "************************** Making CLooG-PPL ***********************************"
  1304.   echo
  1305.   make -j "$cpu_count" || exit 1
  1306. fi
  1307. pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'make' "$uname_m"
  1308.  
  1309. if ! check_pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'install' "$uname_m"; then
  1310.   echo
  1311.   echo "*******************************************************************************"
  1312.   echo "************************** Installing CLooG-PPL *******************************"
  1313.   echo
  1314.   make install || exit 1
  1315. fi
  1316. pkg_touch_success 'cloog_ppl' "$cloog_ppl_release_ver" 'install' "$uname_m"
  1317. }
  1318.  
  1319. build_isl () {
  1320. isl_prefix="$gcc_packages_dir/isl/isl-$isl_ver-$uname_m"
  1321.  
  1322. if [[ "$gcc_ver" != 'svn' && "$gcc_ver" != "$gcc_47_ver" ]]; then
  1323.   return
  1324. fi
  1325. if check_pkg_touch_success 'isl' "$isl_release_ver" 'install' "$uname_m"; then
  1326.   return
  1327. fi
  1328. cd "$gcc_packages_dir" || exit 1
  1329. create_pkg_dirs 'isl' || exit 1
  1330.  
  1331. echo
  1332. echo "*******************************************************************************"
  1333. echo "************************** Downloading isl ************************************"
  1334. echo
  1335. download_extract "isl-$isl_release_ver" "ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-$isl_release_ver" 'tar.bz2'
  1336. if [[ ! -d "$gcc_packages_dir/isl/build/$isl_ver" ]] || ! check_pkg_touch_success 'isl' "$isl_release_ver" 'configure' "$uname_m"; then
  1337.   check_pkg_touch_unsuccess 'isl' "$isl_release_ver" 'configure' "$uname_m"
  1338.   echo
  1339.   echo "*******************************************************************************"
  1340.   echo "************************** Cleaning isl ***************************************"
  1341.   echo
  1342.   cd "$gcc_packages_dir/isl" || exit 100
  1343.   mkdir -vp "build"
  1344.   cd "build" || exit 100
  1345.   rm -frv "$isl_ver"  
  1346.   mkdir -vp "$isl_ver"
  1347.   cd "$isl_ver" || exit 100
  1348.   echo
  1349.   echo "*******************************************************************************"
  1350.   echo "************************** Configuring isl ************************************"
  1351.   echo
  1352.   CC=gcc LDFLAGS="-static" "../../source/isl-$isl_release_ver/configure" --prefix="$isl_prefix" --build="$system_type" \
  1353.     --enable-static --disable-shared --with-gmp-builddir="$gmp_prefix/../build/$gmp_ver" --with-piplib=no --with-clang=no --disable-dependency-tracking || exit 1
  1354. fi
  1355. pkg_touch_success 'isl' "$isl_release_ver" 'configure' "$uname_m"
  1356.  
  1357. cd "$gcc_packages_dir/isl/build/$isl_ver" || exit 100
  1358. if ! check_pkg_touch_success 'isl' "$isl_release_ver" 'make' "$uname_m"; then
  1359.   echo
  1360.   echo "*******************************************************************************"
  1361.   echo "************************** Making isl *****************************************"
  1362.   echo
  1363.   make -j "$cpu_count" || exit 1
  1364. fi
  1365. pkg_touch_success 'isl' "$isl_release_ver" 'make' "$uname_m"
  1366.  
  1367. if ! check_pkg_touch_success 'isl' "$isl_release_ver" 'install' "$uname_m"; then
  1368.   echo
  1369.   echo "*******************************************************************************"
  1370.   echo "************************** Installing isl *************************************"
  1371.   echo
  1372.   make install || exit 1
  1373. fi
  1374. pkg_touch_success 'isl' "$isl_release_ver" 'install' "$uname_m"
  1375. }
  1376.  
  1377. build_cloog () {
  1378. cloog_prefix="$gcc_packages_dir/cloog/cloog-$cloog_ver-$uname_m"
  1379.  
  1380. if [[ "$gcc_ver" != 'svn' && "$gcc_ver" != "$gcc_47_ver" ]]; then
  1381.   return
  1382. fi
  1383. if check_pkg_touch_success 'cloog' "$cloog_release_ver" 'install' "$uname_m"; then
  1384.   return
  1385. fi
  1386.  
  1387. cd "$gcc_packages_dir" || exit 1
  1388. create_pkg_dirs 'cloog' || exit 1
  1389.  
  1390. echo
  1391. echo "*******************************************************************************"
  1392. echo "************************** Downloading CLooG **********************************"
  1393. echo
  1394. download_extract "cloog-$cloog_release_ver" "http://www.bastoul.net/cloog/pages/download/cloog-$cloog_release_ver" 'tar.gz'
  1395. if [[ ! -d "$gcc_packages_dir/cloog/build/$cloog_ver" ]] || ! check_pkg_touch_success 'cloog' "$cloog_release_ver" 'configure' "$uname_m"; then
  1396.   check_pkg_touch_unsuccess 'cloog' "$cloog_release_ver" 'configure' "$uname_m"
  1397.   echo
  1398.   echo "*******************************************************************************"
  1399.   echo "************************** Cleaning CLooG *************************************"
  1400.   echo
  1401.   cd "$gcc_packages_dir/cloog" || exit 100
  1402.   mkdir -vp "build"
  1403.   cd "build" || exit 100
  1404.   rm -frv "$cloog_ver"  
  1405.   mkdir -vp "$cloog_ver"
  1406.   cd "$cloog_ver" || exit 100
  1407.   echo
  1408.   echo "*******************************************************************************"
  1409.   echo "************************** Configuring CLooG **********************************"
  1410.   echo
  1411.   CC=gcc LDFLAGS="-static" "../../source/cloog-$cloog_release_ver/configure" --prefix="$cloog_prefix" --build="$system_type" --enable-static --disable-shared --with-isl-prefix="$isl_prefix" --with-gmp-prefix="$gmp_prefix" --with-osl=no --with-bits=gmp || exit 1
  1412. fi
  1413. pkg_touch_success 'cloog' "$cloog_release_ver" 'configure' "$uname_m"
  1414.  
  1415. cd "$gcc_packages_dir/cloog/build/$cloog_ver" || exit 100
  1416. if ! check_pkg_touch_success 'cloog' "$cloog_release_ver" 'make' "$uname_m"; then
  1417.   echo
  1418.   echo "*******************************************************************************"
  1419.   echo "************************** Making CLooG ***************************************"
  1420.   echo
  1421.   make -j "$cpu_count" || exit 1
  1422. fi
  1423. pkg_touch_success 'cloog' "$cloog_release_ver" 'make' "$uname_m"
  1424.  
  1425. if ! check_pkg_touch_success 'cloog' "$cloog_release_ver" 'install' "$uname_m"; then
  1426.   echo
  1427.   echo "*******************************************************************************"
  1428.   echo "************************** Installing CLooG ***********************************"
  1429.   echo
  1430.   make install || exit 1
  1431. fi
  1432. if [[ "$gcc_ver" = "$gcc_47_ver" ]]; then
  1433.    cp -fvr "$isl_prefix/lib" "$isl_prefix/include" -t "$cloog_prefix"
  1434. fi
  1435. pkg_touch_success 'cloog' "$cloog_release_ver" 'install' "$uname_m"
  1436. }
  1437.  
  1438. check_missing_packages () {
  1439. local check_packages=('bison' 'm4' 'flex' 'svn' 'gcc' 'yasm' 'cvs' 'g++' 'make' 'patch')
  1440. for package in "${check_packages[@]}"; do
  1441.   type -P "$package" >/dev/null || missing_packages=("$package" "${missing_packages[@]}")
  1442. done
  1443.  
  1444. if [[ -n "${missing_packages[@]}" ]]; then
  1445.   $clear
  1446.   echo "Could not find the following packages: ${missing_packages[@]}"
  1447.   echo 'Install the missing packages before running this script.'
  1448.  exit 1
  1449. fi
  1450. }
  1451.  
  1452. build_pthreads_w32 () {
  1453. local target prefix
  1454. target="$1"
  1455. prefix="$2"
  1456. shift 2
  1457. pthreads_w32_ver="${pthreads_w32_ver:-pthreads_w32_release_ver}"
  1458. cd "$packages_dir" || exit 100
  1459. create_pkg_dirs 'pthreads-w32' || exit 1
  1460.  
  1461. if [[ "$pthreads_w32_ver" != 'cvs' ]]; then
  1462.   if [[ ! -d "$packages_dir/pthreads-w32/source/pthreads-w32-${pthreads_w32_ver}" ]] || ! check_pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'download' "$target"; then
  1463.     pkg_touch_unsuccess 'pthreads-w32' "${pthreads_w32_ver}" 'download' "$target"
  1464.     echo
  1465.     echo "*******************************************************************************"
  1466.     echo "************************** Precleaning pthreads-w32 ***************************"
  1467.     echo
  1468.     rm -fvr "$packages_dir/pthreads-w32/source/pthreads-w32-${pthreads_w32_ver}"
  1469.     echo
  1470.     echo "*******************************************************************************"
  1471.     echo "************************** Downloading pthreads-w32 ***************************"
  1472.     echo
  1473.     download_extract "pthreads-w32-${pthreads_w32_ver:=pthreads_w32_release_ver}" "ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-${pthreads_w32_release_ver}" 'tar.gz'
  1474.     pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'download' "$target"
  1475.   fi
  1476. else
  1477.   if [[ ! -d "$packages_dir/pthreads-w32/source/pthreads-w32-${pthreads_w32_ver}/CVS" ]]; then
  1478.     pkg_touch_unsuccess 'pthreads-w32' "${pthreads_w32_ver}" 'download' "$target"
  1479.     echo
  1480.     echo "*******************************************************************************"
  1481.     echo "************************** Precleaning pthreads-w32 ***************************"
  1482.     echo
  1483.     rm -fvr "$packages_dir/pthreads-w32/source/pthreads-w32-${pthreads_w32_ver}"
  1484.     echo
  1485.     echo "*******************************************************************************"
  1486.     echo "************************** Downloading pthreads-w32 ***************************"
  1487.     echo
  1488.     cvs -d :pserver:anonymous@sourceware.org:/cvs/pthreads-win32 checkout pthreads || exit 70
  1489.     mv -fv "pthreads" "pthreads-w32-${pthreads_w32_ver}" || exit 100
  1490.     cd "pthreads-w32-${pthreads_w32_ver}" || exit 100
  1491.     md5_after=$(md5sum "CVS/Entries"); md5_after="${md5_after:0:32}"
  1492.     echo "$md5_after" > "../cvs-md5"
  1493.   else
  1494.     cd "pthreads-w32-${pthreads_w32_ver}" || exit 100
  1495.     touch "../cvs-md5"
  1496.     read -r md5_before < "../cvs-md5"
  1497.     echo
  1498.     echo "*******************************************************************************"
  1499.     echo "************************** Downloading pthreads-w32 ***************************"
  1500.     echo
  1501.     cvs update || exit 70
  1502.     md5_after=$(md5sum "CVS/Entries"); md5_after="${md5_after:0:32}"
  1503.     echo "$md5_after" > "../cvs-md5"
  1504.     if [[ "$md5_before" != "$md5_after" ]]; then
  1505.       pkg_touch_unsuccess 'pthreads-w32' "${pthreads_w32_ver}" 'download' "$target"
  1506.     fi
  1507.   fi
  1508.   pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'download' "$target"
  1509. fi
  1510.  
  1511. local make_flags make_target
  1512. make_target="GC-static"
  1513. if [[ "$target" = "$uname_m" ]]; then
  1514.   prefix="$packages_dir/pthreads-w32/pthreads-w32-${pthreads_w32_ver}"
  1515.   unset make_flags
  1516. elif [[ "$target" == i686-* ]]; then
  1517.   make_flags="CROSS=${target}- "
  1518. elif [[ "$target" == x86_64-* ]]; then
  1519.   make_flags="CROSS=${target}- "
  1520. else
  1521.   echo "Unknown target: $target"
  1522.   exit 50
  1523. fi
  1524.  
  1525. if [[ "$pthreads_w32_ver" = 'cvs' ]]; then
  1526.   make_flags+=" DESTROOT=$prefix"
  1527.   if [[ "$target" == i686-* ]]; then
  1528.     make_flags+=" ARCH=-m32"
  1529.   elif [[ "$target" == x86_64-* ]]; then
  1530.     make_flags+=" ARCH=-m64"
  1531.   fi
  1532. fi
  1533.  
  1534. if [[ ! -d "$packages_dir/pthreads-w32/build/${pthreads_w32_ver}-$target" ]] || ! check_pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'configure' "$target"; then
  1535.   pkg_touch_unsuccess 'pthreads-w32' "${pthreads_w32_ver}" 'configure' "$target"
  1536.   cd "$packages_dir/pthreads-w32" || exit 100
  1537.   echo
  1538.   echo "*******************************************************************************"
  1539.   echo "************************** Cleaning pthreads-w32 ******************************"
  1540.   echo
  1541.   mkdir -p "build"
  1542.   cd "build" || exit 100
  1543.   rm -frv "${pthreads_w32_ver}-$target"
  1544.   mkdir -p "${pthreads_w32_ver}-$target"
  1545.   cd "${pthreads_w32_ver}-$target" || exit 100
  1546.   echo
  1547.   echo "*******************************************************************************"
  1548.   echo "************************** Configuring pthreads-w32 ***************************"
  1549.   echo
  1550.   cp -rfv "$packages_dir/pthreads-w32/source/pthreads-w32-${pthreads_w32_ver}/"* -t "./" || exit 100
  1551.   pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'configure' "$target"
  1552. fi
  1553.  
  1554. cd "$packages_dir/pthreads-w32/build/${pthreads_w32_ver}-$target" || exit 100
  1555. if ! check_pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'make' "$target"; then
  1556.   pkg_touch_unsuccess 'pthreads-w32' "${pthreads_w32_ver}" 'make' "$target"
  1557.   echo
  1558.   echo "*******************************************************************************"
  1559.   echo "************************** Making pthreads-w32 ********************************"
  1560.   echo
  1561.   make realclean
  1562.   make $make_flags clean $make_target || exit 30
  1563.   pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'make' "$target"
  1564. fi
  1565.  
  1566. if [[ "$target" = "$uname_m" ]]; then
  1567.   if ! check_pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'install' "$target"; then
  1568.     echo
  1569.     echo "*******************************************************************************"
  1570.     echo "************************** Installing pthreads-w32 ****************************"
  1571.     echo
  1572.     mkdir -p "$prefix/lib" "$prefix/include"
  1573.     cp 'libpthreadGC2.a' "$prefix/lib/libpthread.a" || exit 200
  1574.     cp 'pthread.h' 'sched.h' 'semaphore.h' -t "$prefix/include/" || exit 200
  1575.     pkg_touch_success 'pthreads-w32' "${pthreads_w32_ver}" 'install' "$target"
  1576.   fi
  1577. else
  1578.   echo
  1579.   echo "*******************************************************************************"
  1580.   echo "************************** Installing pthreads-w32 ****************************"
  1581.   echo
  1582.   #if [[ "$pthreads_w32_ver" != 'cvs' ]]; then
  1583.     cp 'libpthreadGC2.a' "$prefix/lib/libpthread.a" || exit 200
  1584.     cp 'pthread.h' 'sched.h' 'semaphore.h' -t "$prefix/include/" || exit 200
  1585.   #else
  1586.   #  make $make_flags install || exit 40 # works only for shared lib for now
  1587.   #fi
  1588. fi    
  1589. }
  1590.  
  1591. build_winpthreads () {
  1592. local target prefix
  1593. target="$1"
  1594. prefix="$2"
  1595. cd "$packages_dir" || exit 100
  1596. create_pkg_dirs 'winpthreads' || exit 100
  1597. cd "$packages_dir/winpthreads/source" || exit 100
  1598. echo
  1599. echo "*******************************************************************************"
  1600. echo "************************** Downloading winpthreads ****************************"
  1601. echo
  1602. if [[ -d "$packages_dir/winpthreads/source/winpthreads-svn" ]]; then
  1603.   cd 'winpthreads-svn' || exit 100
  1604.   touch "../svn-version"
  1605.   read -r svn_ver_before < "../svn-version"
  1606.   svn update || exit 1
  1607.   svn_ver_after=$(svn info | grep "^Revision: "); svn_ver_after=${svn_ver_after:10}
  1608.   echo "$svn_ver_after" > "../svn-version"
  1609.   if [[ "$svn_ver_before" != "$svn_ver_after" ]]; then
  1610.     rm -fv "$touch_files_dir/winpthreads/winpthreads-svn"*
  1611.   fi
  1612.   pkg_touch_success 'winpthreads' "svn" 'download' "$target"
  1613. else
  1614.   mkdir -p 'winpthreads-svn'
  1615.   svn checkout http://mingw-w64.svn.sourceforge.net/svnroot/mingw-w64/experimental/winpthreads 'winpthreads-svn' || exit 1
  1616.   cd 'winpthreads-svn' || exit 100
  1617.   svn_ver_after=$(svn info | grep "^Revision: "); svn_ver_after=${svn_ver_after:10}
  1618.   echo $svn_ver_after > "../svn-version"
  1619.   pkg_touch_success 'winpthreads' "svn" 'download' "$target"
  1620. fi
  1621.  
  1622. if [[ ! -d "$packages_dir/winpthreads/build/svn-$target" ]] || ! check_pkg_touch_success 'winpthreads' "svn" 'configure' "$target"; then
  1623.   pkg_touch_unsuccess 'winpthreads' "svn" 'configure' "$target"
  1624.   cd "$packages_dir/winpthreads" || exit 100
  1625.   echo
  1626.   echo "*******************************************************************************"
  1627.   echo "************************** Cleaning winpthreads *******************************"
  1628.   echo
  1629.   mkdir -p "build"
  1630.   cd "build" || exit 100
  1631.   rm -frv "svn-$target"
  1632.   mkdir -p "svn-$target"
  1633.   cd "svn-$target" || exit 100
  1634.   echo
  1635.   echo "*******************************************************************************"
  1636.   echo "************************** Configuring winpthreads ****************************"
  1637.   echo
  1638.   '../../source/winpthreads-svn/configure' --build="$system_type" --host="$mingw_w64_target" \
  1639.     --disable-shared --enable-static --prefix="$mingw_w64_prefix" || exit 20
  1640. fi
  1641. pkg_touch_success 'winpthreads' "svn" 'configure' "$target"
  1642.  
  1643. cd "$packages_dir/winpthreads/build/svn-$target" || exit 100
  1644.  
  1645. if ! check_pkg_touch_success 'winpthreads' "svn" 'make' "$target"; then
  1646.   echo
  1647.   echo "*******************************************************************************"
  1648.   echo "************************** Making winpthreads *******************************"
  1649.   echo
  1650.   make -j "$cpu_count" || exit 1
  1651. fi  
  1652. pkg_touch_success 'winpthreads' "svn" 'make' "$target"
  1653.  
  1654. echo
  1655. echo "*******************************************************************************"
  1656. echo "************************** Installing winpthreads *******************************"
  1657. echo
  1658. make install || exit 1
  1659. }
  1660.  
  1661. build_thread_lib () {
  1662. local target prefix
  1663. target="$1"
  1664. prefix="$2"
  1665. shift 2
  1666. case "$thread_lib" in
  1667.   'winpthreads' ) build_winpthreads "$target" "$prefix" ;;
  1668.   'pthreads-w32' ) build_pthreads_w32 "$target" "$prefix" ;;
  1669.   'disable' ) ;;
  1670.   * ) build_winpthreads "$target" "$prefix" ;;
  1671. esac
  1672. }
  1673.  
  1674. mingw_full_rebuild () {
  1675. local source="$mingw_w64_source_dir/mingw-w64-$mingw_w64_ver"
  1676. local headers_prefix="$mingw_w64_prefix/$mingw_w64_target"
  1677. local prefix="$mingw_w64_prefix/$mingw_w64_target"
  1678.  
  1679. cd "$mingw_w64_build_dir" || exit 100
  1680. if [[ ! -d "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-headers-full" ]] || ! check_pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "$mingw_w64_target-headers-full"; then
  1681.   check_pkg_touch_unsuccess 'mingw_w64' "$mingw_w64_ver" 'configure' "$mingw_w64_target-headers-full"
  1682.   echo
  1683.   echo "*******************************************************************************"
  1684.   echo "************************** Cleaning MinGW64 full headers **********************"
  1685.   echo
  1686.   rm -frv "$mingw_w64_ver-$mingw_w64_target-headers-full"
  1687.   mkdir -p "$mingw_w64_ver-$mingw_w64_target-headers-full"
  1688.   cd "$mingw_w64_ver-$mingw_w64_target-headers-full" || exit 100
  1689.   echo
  1690.   echo "*******************************************************************************"
  1691.   echo "************************** Configuring MinGW64 full headers *******************"
  1692.   echo
  1693.   "$source/mingw-w64-headers/configure" --enable-sdk=all --build="$system_type" --host="$mingw_w64_target" --prefix="$headers_prefix" --enable-delay-import-libs || exit 100
  1694. fi
  1695. pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "$mingw_w64_target-headers-full"
  1696.  
  1697. cd "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-headers-full" || exit 100
  1698. echo
  1699. echo "*******************************************************************************"
  1700. echo "************************** Installing MinGW64 full headers ********************"
  1701. echo
  1702. make -j "$cpu_count" install-strip || exit 1
  1703.  
  1704. local arch_flag
  1705. if [[ "$mingw_w64_target" == i686-* ]]; then
  1706.   arch_flag="--with-libraries=all"
  1707. else
  1708.   arch_flag="--with-libraries=libmangle"
  1709. fi
  1710.  
  1711. cd "$mingw_w64_build_dir" || exit 100
  1712. if [[ ! -d "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_ver-$mingw_w64_target-full" ]] || ! check_pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-full"; then
  1713.   check_pkg_touch_unsuccess 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-full"
  1714.   echo
  1715.   echo "*******************************************************************************"
  1716.   echo "************************** Cleaning MinGW64 full ******************************"
  1717.   echo
  1718.   rm -rvf "$mingw_w64_target"
  1719.   mkdir -p "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-full" || exit 100
  1720.   cd "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-full" || exit 100
  1721.   echo
  1722.   echo "*******************************************************************************"
  1723.   echo "************************** Configuring MinGW64 full ***************************"
  1724.   echo
  1725.   "$source/configure" --build="$system_type" --host="$mingw_w64_target" --prefix="$prefix" $arch_flag \
  1726.     --with-tools=all --enable-idl --without-headers $crt_arch_flag || exit 1
  1727. fi
  1728. pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'configure' "${mingw_w64_target}-full"
  1729.  
  1730. cd "$mingw_w64_build_dir/$mingw_w64_ver-$mingw_w64_target-full" || exit 100
  1731. if ! check_pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'make' "${mingw_w64_target}-full"; then
  1732.   echo
  1733.   echo "*******************************************************************************"
  1734.   echo "************************** Making MinGW64 full ********************************"
  1735.   echo
  1736.   make -j "$cpu_count" || exit 1
  1737. fi
  1738. pkg_touch_success 'mingw_w64' "$mingw_w64_ver" 'make' "${mingw_w64_target}-full"
  1739.  
  1740. echo
  1741. echo "*******************************************************************************"
  1742. echo "************************** Installing MinGW64 full ****************************"
  1743. echo
  1744. make -j "$cpu_count" install-strip || exit 1
  1745. }
  1746.  
  1747. completed_build () {
  1748. local arch="$1"
  1749. case "$arch" in
  1750.   'win32' ) mingw_w64_path_prefix="$mingw_w64_i686_prefix" ;;
  1751.   'win64' ) mingw_w64_path_prefix="$mingw_w64_x86_64_prefix" ;;
  1752. esac
  1753. echo "The MinGW-w64 bin directory needs to be added to the PATH variable so the system can find it, for ${arch} this can be done with: export PATH=\"${mingw_w64_path_prefix}/bin:\$PATH\""
  1754. }
  1755.  
  1756. no_errors='MinGW-w64 has been built without errors.'
  1757.  
  1758. ####################################### Main build selection function ################################################
  1759. build_mingw_w64_toolchain () {
  1760. local arch
  1761. arch="$1"
  1762. check_missing_packages || exit 1
  1763. if [[ -z "$build_type" || -z "$mingw_w64_ver" || -z "$binutils_ver" || -z "$gcc_ver" || -z "$enabled_langs" ]]; then
  1764.   configure_build_fn || exit 1
  1765. fi
  1766. if [[ -z "$cpu_count_opt" ]]; then
  1767.   use_cpu_count
  1768. else
  1769.   cpu_cout=$cpu_count_opt
  1770. fi
  1771.  
  1772. download_source "$arch" || exit 1
  1773. case "$arch" in
  1774.   'multi' ) build_mingw_w64 'win32' && build_mingw_w64 'win64' || exit 1 ;;
  1775.   'win32' ) build_mingw_w64 'win32' || exit 1 ;;
  1776.   'win64' ) build_mingw_w64 'win64' || exit 1 ;;
  1777. esac
  1778. $clear
  1779. clean_build_fn
  1780. echo "$no_errors"
  1781. if [[ "$arch" = "multi" ]]; then
  1782.   completed_build 'win32'
  1783.   completed_build 'win64'
  1784. else
  1785.   completed_build "$1"
  1786. fi
  1787. }
  1788.  
  1789. check_cpu_count_optarg () {
  1790. cpu_count="$(grep -c processor /proc/cpuinfo 2> /dev/null)"
  1791. if [[ -z "$sys_cpu_count" ]]; then
  1792.   cpu_count=$NUMBER_OF_PROCESSORS
  1793. fi
  1794. if [[ "$cpu_count_opt" -gt "$cpu_count"  ]]; then
  1795.   yes_no_sel "The input number of cores/threads was higher than the number detected ($cpu_count were detected). Trying to use more cores/threads than your CPU has can cause your system to crash. Are you sure you want to continue? [y/n]: "
  1796.   if [[ "$user_input" = [Nn] ]]; then
  1797.     exit 1
  1798.   fi
  1799. fi  
  1800. }
  1801.  
  1802. check_gcc_langs_optarg () {
  1803. if [[ "$gcc_ver" = "$gcc_45_ver" && "$enabled_langs" = *go* ]]; then
  1804.   echo "The language \"Go\" is not supported by GCC version $gcc_ver"
  1805.   exit 1
  1806. fi
  1807. }
  1808.  
  1809. main_menu () {
  1810. if [[ -z "$build_type" && "$interactive" != "yes" ]]; then
  1811.   build_type='multi'
  1812. fi
  1813. if [[ "$build_type" != '' ]]; then
  1814.   build_mingw_w64_toolchain "$build_type"
  1815.   exit 0
  1816. fi
  1817. while [[ "$build_choice" != [1-3] ]]; do
  1818. if [[ -n "${unknown_opts[@]}" ]]; then
  1819.   echo -n 'Unknown option(s)'
  1820.   for unknown_opt in "${unknown_opts[@]}"; do
  1821.     echo -n " '$unknown_opt'"
  1822.   done
  1823.   echo ', ignored.'; echo
  1824. fi
  1825. cat <<'EOF'
  1826. What version of MinGW-w64 would you like to build or update?
  1827.   1. Both Win32 and Win64
  1828.   2. Win32 (32-bit only)
  1829.   3. Win64 (64-bit only)
  1830.   4. About
  1831.   5. Exit
  1832. EOF
  1833. echo -n 'Input your choice [1-5]: '
  1834. read build_choice
  1835. case "$build_choice" in
  1836.   1 ) build_mingw_w64_toolchain 'multi' ;;
  1837.   2 ) build_mingw_w64_toolchain 'win32' ;;
  1838.   3 ) build_mingw_w64_toolchain 'win64' ;;
  1839.   4 ) about; $clear ;;
  1840.   5 ) exit 0 ;;
  1841.   * ) $clear;  echo 'Your choice was not valid, please try again.'; echo ;;
  1842. esac
  1843. done
  1844. }
  1845.  
  1846. configure_build_fn () {
  1847. if [[ "$interactive" == "yes" ]]; then
  1848. yes_no_sel 'Would you like to manually choose which package versions to build into MinGW-w64 yourself, and configure the build? [y/n]: '
  1849. if [[ "$user_input" = [Yy] ]]; then
  1850.   if [[ -z "$mingw_w64_ver" ]]; then
  1851.     choose_mingw_w64_ver
  1852.   fi
  1853.   if [[ -z "$binutils_ver" ]]; then
  1854.     choose_binutils_ver
  1855.   fi
  1856.   if [[ -z "$gcc_ver" ]]; then
  1857.     choose_gcc_ver
  1858.   fi
  1859.   if [[ -z "$static_build" ]]; then
  1860.     choose_static_build
  1861.   fi
  1862.   if [[ ! -z "$disable_nls" ]]; then
  1863.     choose_disable_nls
  1864.   fi
  1865.   if [[ -z "$enabled_langs" ]]; then
  1866.     choose_lang_sel
  1867.   fi
  1868.   default_configure
  1869. else
  1870.   default_configure
  1871. fi
  1872. else
  1873. default_configure
  1874. fi
  1875. }
  1876.  
  1877. default_configure () {
  1878. default_config='yes'
  1879. if [[ -z "$mingw_w64_ver" ]]; then
  1880.   mingw_w64_ver='svn'
  1881. fi
  1882. if [[ -z "$binutils_ver" ]]; then
  1883.   binutils_ver="$binutils_release_ver"
  1884. fi
  1885. if [[ -z "$gcc_ver" ]]; then
  1886.   gcc_ver="$gcc_47_ver"
  1887. fi
  1888. if [[ -z "$enabled_langs" ]]; then
  1889.   enabled_langs=('c' 'c++' 'fortran')
  1890. fi
  1891. if [[ -z "$thread_lib" ]]; then
  1892.   thread_lib='pthreads-w32'
  1893. fi
  1894. mpfr_ver=$mpfr_release_ver
  1895. mpc_ver=$mpc_release_ver
  1896. cloog_ppl_ver=$cloog_ppl_release_ver
  1897. gmp_ver=$gmp_release_ver
  1898. ppl_ver=$ppl_release_ver
  1899. isl_ver=$isl_release_ver
  1900. cloog_ver=$cloog_release_ver
  1901. #pthreads_w32_ver=${pthreads_w32_ver:-$pthreads_w32_release_ver}
  1902. pthreads_w32_ver="cvs"
  1903. }
  1904.  
  1905. ############################# MAIN ###########################################
  1906.  
  1907. # Variables
  1908. working_dir="$(pwd)"
  1909. uname_m="$(uname -m)"
  1910. target_i686='i686-w64-mingw32'
  1911. target_x86_64='x86_64-w64-mingw32'
  1912. build_sys="$(uname -o)"
  1913.  
  1914. ## Versions
  1915. mingw_w64_release_ver='2.0.7'
  1916. mingw_w64_svn_rev="5478" # set to "" for latest
  1917. gcc_47_ver='4.7.2'
  1918. gcc_46_ver='4.6.3'
  1919. gcc_45_ver='4.5.3'
  1920. mpfr_release_ver='3.1.1'
  1921. mpc_release_ver='1.0.1'
  1922. cloog_ppl_release_ver='0.15.11'
  1923. binutils_release_ver='2.23.1'
  1924. gmp_release_ver='5.0.5'
  1925. ppl_release_ver='1.0'
  1926. isl_release_ver='0.10'
  1927. cloog_release_ver='0.17.0'
  1928. pthreads_w32_release_ver='2-9-1-release'
  1929.  
  1930. ## Locations
  1931. mingw_w64_source_dir="$working_dir/source"
  1932. mingw_w64_build_dir="$working_dir/build"
  1933. touch_files_dir="$mingw_w64_build_dir/touch-files"
  1934. packages_dir="$working_dir/packages"
  1935. gcc_packages_dir="$packages_dir/gcc/packages"
  1936.  
  1937. ## Prefixes
  1938. mingw_w64_i686_prefix="$working_dir/mingw-w64-i686"
  1939. mingw_w64_x86_64_prefix="$working_dir/mingw-w64-x86_64"
  1940.  
  1941. if which clear 1>/dev/null 2>/dev/null; then
  1942.   clear="clear"
  1943. elif which clsb 1>/dev/null 2>/dev/null; then
  1944.   clear="clsb"
  1945. elif which cls 1>/dev/null 2>/dev/null; then
  1946.   clear="cls"
  1947. else
  1948.   clear=""
  1949. fi
  1950.  
  1951. if [[ "$build_sys" = "Msys" ]]; then
  1952.   rm -r testtmplnkdir 2> /dev/null
  1953.   mkdir -p testtmpdstdir
  1954.   cmd /c "mklink /j testtmplnkdir testtmpdstdir" 1>/dev/null 2>/dev/null
  1955.   if [ $? = 0 ] && [ -d "testtmplnkdir" ]; then
  1956.     link_style="msys"
  1957.   else
  1958.     link_style="coreutils"  
  1959.   fi
  1960.   rm -r testtmplnkdir 2> /dev/null
  1961.   rm -r testtmpdstdir 2> /dev/null
  1962. else
  1963.   link_style="coreutils"
  1964. fi
  1965.  
  1966. disable_nls=('--disable-nls')
  1967.  
  1968. while true; do
  1969.   case $1 in
  1970.     -h | --help ) display_help; exit 0 ;;
  1971.     -a | --about ) about; exit 0 ;;
  1972.     -V | --version ) echo '3.1.0'; exit 0 ;;
  1973.     --build-type=* ) build_type="${1#*=}"; shift ;;
  1974.     --default-configure ) default_configure; shift ;;
  1975.     --rebuild-all ) rebuild='yes'; shift ;;
  1976.     --allow-overwrite ) allow_overwrite='yes'; shift ;;
  1977.     --mingw-w64-ver=* ) mingw_w64_ver="${1#*=}"; shift ;;
  1978.     --cpu-count=* ) cpu_count_opt="${1#*=}"; shift ;;
  1979.     --binutils-ver=* ) binutils_ver="${1#*=}"; shift ;;
  1980.     --gcc-ver=* ) gcc_ver="${1#*=}"; shift ;;
  1981.     --gcc-langs=* ) enabled_langs="${1#*=}"; shift ;;
  1982.     --enable-nls ) unset disable_nls; shift ;;
  1983.     --disable-shared ) static_build=('--disable-shared' '--enable-static'); shift ;;
  1984.     --threads=* ) thread_lib="${1#*=}"; shift ;;
  1985.     --clean-build ) clean_build='yes'; shift ;;
  1986.     --interactive ) interactive='yes'; shift ;;
  1987.     --with-mingw-w64-additional-tools ) with_mingw_tools='yes'; shift ;;
  1988.     --without-mingw-w64-additional-tools ) unset with_mingw_tools; shift ;;
  1989.     -- ) shift; break ;;
  1990.     -* ) echo "Error, unknown option: '$1'."; exit 1 ;;
  1991.     * ) break ;;
  1992.   esac
  1993. done
  1994.  
  1995. test_opt
  1996.  
  1997. main_menu
  1998.  
  1999. exit 0
  2000.  
  2001. #                     GNU GENERAL PUBLIC LICENSE
  2002. #                        Version 3, 29 June 2007
  2003. #
  2004. #  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  2005. #  Everyone is permitted to copy and distribute verbatim copies
  2006. #  of this license document, but changing it is not allowed.
  2007. #
  2008. #                             Preamble
  2009. #
  2010. #   The GNU General Public License is a free, copyleft license for
  2011. # software and other kinds of works.
  2012. #
  2013. #   The licenses for most software and other practical works are designed
  2014. # to take away your freedom to share and change the works.  By contrast,
  2015. # the GNU General Public License is intended to guarantee your freedom to
  2016. # share and change all versions of a program--to make sure it remains free
  2017. # software for all its users.  We, the Free Software Foundation, use the
  2018. # GNU General Public License for most of our software; it applies also to
  2019. # any other work released this way by its authors.  You can apply it to
  2020. # your programs, too.
  2021. #
  2022. #   When we speak of free software, we are referring to freedom, not
  2023. # price.  Our General Public Licenses are designed to make sure that you
  2024. # have the freedom to distribute copies of free software (and charge for
  2025. # them if you wish), that you receive source code or can get it if you
  2026. # want it, that you can change the software or use pieces of it in new
  2027. # free programs, and that you know you can do these things.
  2028. #
  2029. #   To protect your rights, we need to prevent others from denying you
  2030. # these rights or asking you to surrender the rights.  Therefore, you have
  2031. # certain responsibilities if you distribute copies of the software, or if
  2032. # you modify it: responsibilities to respect the freedom of others.
  2033. #
  2034. #   For example, if you distribute copies of such a program, whether
  2035. # gratis or for a fee, you must pass on to the recipients the same
  2036. # freedoms that you received.  You must make sure that they, too, receive
  2037. # or can get the source code.  And you must show them these terms so they
  2038. # know their rights.
  2039. #
  2040. #   Developers that use the GNU GPL protect your rights with two steps:
  2041. # (1) assert copyright on the software, and (2) offer you this License
  2042. # giving you legal permission to copy, distribute and/or modify it.
  2043. #
  2044. #   For the developers' and authors' protection, the GPL clearly explains
  2045. # that there is no warranty for this free software.  For both users' and
  2046. # authors' sake, the GPL requires that modified versions be marked as
  2047. # changed, so that their problems will not be attributed erroneously to
  2048. # authors of previous versions.
  2049. #
  2050. #   Some devices are designed to deny users access to install or run
  2051. # modified versions of the software inside them, although the manufacturer
  2052. # can do so.  This is fundamentally incompatible with the aim of
  2053. # protecting users' freedom to change the software.  The systematic
  2054. # pattern of such abuse occurs in the area of products for individuals to
  2055. # use, which is precisely where it is most unacceptable.  Therefore, we
  2056. # have designed this version of the GPL to prohibit the practice for those
  2057. # products.  If such problems arise substantially in other domains, we
  2058. # stand ready to extend this provision to those domains in future versions
  2059. # of the GPL, as needed to protect the freedom of users.
  2060. #
  2061. #   Finally, every program is threatened constantly by software patents.
  2062. # States should not allow patents to restrict development and use of
  2063. # software on general-purpose computers, but in those that do, we wish to
  2064. # avoid the special danger that patents applied to a free program could
  2065. # make it effectively proprietary.  To prevent this, the GPL assures that
  2066. # patents cannot be used to render the program non-free.
  2067. #
  2068. #   The precise terms and conditions for copying, distribution and
  2069. # modification follow.
  2070. #
  2071. #                        TERMS AND CONDITIONS
  2072. #
  2073. #   0. Definitions.
  2074. #
  2075. #   "This License" refers to version 3 of the GNU General Public License.
  2076. #
  2077. #   "Copyright" also means copyright-like laws that apply to other kinds of
  2078. # works, such as semiconductor masks.
  2079. #
  2080. #   "The Program" refers to any copyrightable work licensed under this
  2081. # License.  Each licensee is addressed as "you".  "Licensees" and
  2082. # "recipients" may be individuals or organizations.
  2083. #
  2084. #   To "modify" a work means to copy from or adapt all or part of the work
  2085. # in a fashion requiring copyright permission, other than the making of an
  2086. # exact copy.  The resulting work is called a "modified version" of the
  2087. # earlier work or a work "based on" the earlier work.
  2088. #
  2089. #   A "covered work" means either the unmodified Program or a work based
  2090. # on the Program.
  2091. #
  2092. #   To "propagate" a work means to do anything with it that, without
  2093. # permission, would make you directly or secondarily liable for
  2094. # infringement under applicable copyright law, except executing it on a
  2095. # computer or modifying a private copy.  Propagation includes copying,
  2096. # distribution (with or without modification), making available to the
  2097. # public, and in some countries other activities as well.
  2098. #
  2099. #   To "convey" a work means any kind of propagation that enables other
  2100. # parties to make or receive copies.  Mere interaction with a user through
  2101. # a computer network, with no transfer of a copy, is not conveying.
  2102. #
  2103. #   An interactive user interface displays "Appropriate Legal Notices"
  2104. # to the extent that it includes a convenient and prominently visible
  2105. # feature that (1) displays an appropriate copyright notice, and (2)
  2106. # tells the user that there is no warranty for the work (except to the
  2107. # extent that warranties are provided), that licensees may convey the
  2108. # work under this License, and how to view a copy of this License.  If
  2109. # the interface presents a list of user commands or options, such as a
  2110. # menu, a prominent item in the list meets this criterion.
  2111. #
  2112. #   1. Source Code.
  2113. #
  2114. #   The "source code" for a work means the preferred form of the work
  2115. # for making modifications to it.  "Object code" means any non-source
  2116. # form of a work.
  2117. #
  2118. #   A "Standard Interface" means an interface that either is an official
  2119. # standard defined by a recognized standards body, or, in the case of
  2120. # interfaces specified for a particular programming language, one that
  2121. # is widely used among developers working in that language.
  2122. #
  2123. #   The "System Libraries" of an executable work include anything, other
  2124. # than the work as a whole, that (a) is included in the normal form of
  2125. # packaging a Major Component, but which is not part of that Major
  2126. # Component, and (b) serves only to enable use of the work with that
  2127. # Major Component, or to implement a Standard Interface for which an
  2128. # implementation is available to the public in source code form.  A
  2129. # "Major Component", in this context, means a major essential component
  2130. # (kernel, window system, and so on) of the specific operating system
  2131. # (if any) on which the executable work runs, or a compiler used to
  2132. # produce the work, or an object code interpreter used to run it.
  2133. #
  2134. #   The "Corresponding Source" for a work in object code form means all
  2135. # the source code needed to generate, install, and (for an executable
  2136. # work) run the object code and to modify the work, including scripts to
  2137. # control those activities.  However, it does not include the work's
  2138. # System Libraries, or general-purpose tools or generally available free
  2139. # programs which are used unmodified in performing those activities but
  2140. # which are not part of the work.  For example, Corresponding Source
  2141. # includes interface definition files associated with source files for
  2142. # the work, and the source code for shared libraries and dynamically
  2143. # linked subprograms that the work is specifically designed to require,
  2144. # such as by intimate data communication or control flow between those
  2145. # subprograms and other parts of the work.
  2146. #
  2147. #   The Corresponding Source need not include anything that users
  2148. # can regenerate automatically from other parts of the Corresponding
  2149. # Source.
  2150. #
  2151. #   The Corresponding Source for a work in source code form is that
  2152. # same work.
  2153. #
  2154. #   2. Basic Permissions.
  2155. #
  2156. #   All rights granted under this License are granted for the term of
  2157. # copyright on the Program, and are irrevocable provided the stated
  2158. # conditions are met.  This License explicitly affirms your unlimited
  2159. # permission to run the unmodified Program.  The output from running a
  2160. # covered work is covered by this License only if the output, given its
  2161. # content, constitutes a covered work.  This License acknowledges your
  2162. # rights of fair use or other equivalent, as provided by copyright law.
  2163. #
  2164. #   You may make, run and propagate covered works that you do not
  2165. # convey, without conditions so long as your license otherwise remains
  2166. # in force.  You may convey covered works to others for the sole purpose
  2167. # of having them make modifications exclusively for you, or provide you
  2168. # with facilities for running those works, provided that you comply with
  2169. # the terms of this License in conveying all material for which you do
  2170. # not control copyright.  Those thus making or running the covered works
  2171. # for you must do so exclusively on your behalf, under your direction
  2172. # and control, on terms that prohibit them from making any copies of
  2173. # your copyrighted material outside their relationship with you.
  2174. #
  2175. #   Conveying under any other circumstances is permitted solely under
  2176. # the conditions stated below.  Sublicensing is not allowed; section 10
  2177. # makes it unnecessary.
  2178. #
  2179. #   3. Protecting Users' Legal Rights From Anti-Circumvention Law.
  2180. #
  2181. #   No covered work shall be deemed part of an effective technological
  2182. # measure under any applicable law fulfilling obligations under article
  2183. # 11 of the WIPO copyright treaty adopted on 20 December 1996, or
  2184. # similar laws prohibiting or restricting circumvention of such
  2185. # measures.
  2186. #
  2187. #   When you convey a covered work, you waive any legal power to forbid
  2188. # circumvention of technological measures to the extent such circumvention
  2189. # is effected by exercising rights under this License with respect to
  2190. # the covered work, and you disclaim any intention to limit operation or
  2191. # modification of the work as a means of enforcing, against the work's
  2192. # users, your or third parties' legal rights to forbid circumvention of
  2193. # technological measures.
  2194. #
  2195. #   4. Conveying Verbatim Copies.
  2196. #
  2197. #   You may convey verbatim copies of the Program's source code as you
  2198. # receive it, in any medium, provided that you conspicuously and
  2199. # appropriately publish on each copy an appropriate copyright notice;
  2200. # keep intact all notices stating that this License and any
  2201. # non-permissive terms added in accord with section 7 apply to the code;
  2202. # keep intact all notices of the absence of any warranty; and give all
  2203. # recipients a copy of this License along with the Program.
  2204. #
  2205. #   You may charge any price or no price for each copy that you convey,
  2206. # and you may offer support or warranty protection for a fee.
  2207. #
  2208. #   5. Conveying Modified Source Versions.
  2209. #
  2210. #   You may convey a work based on the Program, or the modifications to
  2211. # produce it from the Program, in the form of source code under the
  2212. # terms of section 4, provided that you also meet all of these conditions:
  2213. #
  2214. #     a) The work must carry prominent notices stating that you modified
  2215. #     it, and giving a relevant date.
  2216. #
  2217. #     b) The work must carry prominent notices stating that it is
  2218. #     released under this License and any conditions added under section
  2219. #     7.  This requirement modifies the requirement in section 4 to
  2220. #     "keep intact all notices".
  2221. #
  2222. #     c) You must license the entire work, as a whole, under this
  2223. #     License to anyone who comes into possession of a copy.  This
  2224. #     License will therefore apply, along with any applicable section 7
  2225. #     additional terms, to the whole of the work, and all its parts,
  2226. #     regardless of how they are packaged.  This License gives no
  2227. #     permission to license the work in any other way, but it does not
  2228. #     invalidate such permission if you have separately received it.
  2229. #
  2230. #     d) If the work has interactive user interfaces, each must display
  2231. #     Appropriate Legal Notices; however, if the Program has interactive
  2232. #     interfaces that do not display Appropriate Legal Notices, your
  2233. #     work need not make them do so.
  2234. #
  2235. #   A compilation of a covered work with other separate and independent
  2236. # works, which are not by their nature extensions of the covered work,
  2237. # and which are not combined with it such as to form a larger program,
  2238. # in or on a volume of a storage or distribution medium, is called an
  2239. # "aggregate" if the compilation and its resulting copyright are not
  2240. # used to limit the access or legal rights of the compilation's users
  2241. # beyond what the individual works permit.  Inclusion of a covered work
  2242. # in an aggregate does not cause this License to apply to the other
  2243. # parts of the aggregate.
  2244. #
  2245. #   6. Conveying Non-Source Forms.
  2246. #
  2247. #   You may convey a covered work in object code form under the terms
  2248. # of sections 4 and 5, provided that you also convey the
  2249. # machine-readable Corresponding Source under the terms of this License,
  2250. # in one of these ways:
  2251. #
  2252. #     a) Convey the object code in, or embodied in, a physical product
  2253. #     (including a physical distribution medium), accompanied by the
  2254. #     Corresponding Source fixed on a durable physical medium
  2255. #     customarily used for software interchange.
  2256. #
  2257. #     b) Convey the object code in, or embodied in, a physical product
  2258. #     (including a physical distribution medium), accompanied by a
  2259. #     written offer, valid for at least three years and valid for as
  2260. #     long as you offer spare parts or customer support for that product
  2261. #     model, to give anyone who possesses the object code either (1) a
  2262. #     copy of the Corresponding Source for all the software in the
  2263. #     product that is covered by this License, on a durable physical
  2264. #     medium customarily used for software interchange, for a price no
  2265. #     more than your reasonable cost of physically performing this
  2266. #     conveying of source, or (2) access to copy the
  2267. #     Corresponding Source from a network server at no charge.
  2268. #
  2269. #     c) Convey individual copies of the object code with a copy of the
  2270. #     written offer to provide the Corresponding Source.  This
  2271. #     alternative is allowed only occasionally and noncommercially, and
  2272. #     only if you received the object code with such an offer, in accord
  2273. #     with subsection 6b.
  2274. #
  2275. #     d) Convey the object code by offering access from a designated
  2276. #     place (gratis or for a charge), and offer equivalent access to the
  2277. #     Corresponding Source in the same way through the same place at no
  2278. #     further charge.  You need not require recipients to copy the
  2279. #     Corresponding Source along with the object code.  If the place to
  2280. #     copy the object code is a network server, the Corresponding Source
  2281. #     may be on a different server (operated by you or a third party)
  2282. #     that supports equivalent copying facilities, provided you maintain
  2283. #     clear directions next to the object code saying where to find the
  2284. #     Corresponding Source.  Regardless of what server hosts the
  2285. #     Corresponding Source, you remain obligated to ensure that it is
  2286. #     available for as long as needed to satisfy these requirements.
  2287. #
  2288. #     e) Convey the object code using peer-to-peer transmission, provided
  2289. #     you inform other peers where the object code and Corresponding
  2290. #     Source of the work are being offered to the general public at no
  2291. #     charge under subsection 6d.
  2292. #
  2293. #   A separable portion of the object code, whose source code is excluded
  2294. # from the Corresponding Source as a System Library, need not be
  2295. # included in conveying the object code work.
  2296. #
  2297. #   A "User Product" is either (1) a "consumer product", which means any
  2298. # tangible personal property which is normally used for personal, family,
  2299. # or household purposes, or (2) anything designed or sold for incorporation
  2300. # into a dwelling.  In determining whether a product is a consumer product,
  2301. # doubtful cases shall be resolved in favor of coverage.  For a particular
  2302. # product received by a particular user, "normally used" refers to a
  2303. # typical or common use of that class of product, regardless of the status
  2304. # of the particular user or of the way in which the particular user
  2305. # actually uses, or expects or is expected to use, the product.  A product
  2306. # is a consumer product regardless of whether the product has substantial
  2307. # commercial, industrial or non-consumer uses, unless such uses represent
  2308. # the only significant mode of use of the product.
  2309. #
  2310. #   "Installation Information" for a User Product means any methods,
  2311. # procedures, authorization keys, or other information required to install
  2312. # and execute modified versions of a covered work in that User Product from
  2313. # a modified version of its Corresponding Source.  The information must
  2314. # suffice to ensure that the continued functioning of the modified object
  2315. # code is in no case prevented or interfered with solely because
  2316. # modification has been made.
  2317. #
  2318. #   If you convey an object code work under this section in, or with, or
  2319. # specifically for use in, a User Product, and the conveying occurs as
  2320. # part of a transaction in which the right of possession and use of the
  2321. # User Product is transferred to the recipient in perpetuity or for a
  2322. # fixed term (regardless of how the transaction is characterized), the
  2323. # Corresponding Source conveyed under this section must be accompanied
  2324. # by the Installation Information.  But this requirement does not apply
  2325. # if neither you nor any third party retains the ability to install
  2326. # modified object code on the User Product (for example, the work has
  2327. # been installed in ROM).
  2328. #
  2329. #   The requirement to provide Installation Information does not include a
  2330. # requirement to continue to provide support service, warranty, or updates
  2331. # for a work that has been modified or installed by the recipient, or for
  2332. # the User Product in which it has been modified or installed.  Access to a
  2333. # network may be denied when the modification itself materially and
  2334. # adversely affects the operation of the network or violates the rules and
  2335. # protocols for communication across the network.
  2336. #
  2337. #   Corresponding Source conveyed, and Installation Information provided,
  2338. # in accord with this section must be in a format that is publicly
  2339. # documented (and with an implementation available to the public in
  2340. # source code form), and must require no special password or key for
  2341. # unpacking, reading or copying.
  2342. #
  2343. #   7. Additional Terms.
  2344. #
  2345. #   "Additional permissions" are terms that supplement the terms of this
  2346. # License by making exceptions from one or more of its conditions.
  2347. # Additional permissions that are applicable to the entire Program shall
  2348. # be treated as though they were included in this License, to the extent
  2349. # that they are valid under applicable law.  If additional permissions
  2350. # apply only to part of the Program, that part may be used separately
  2351. # under those permissions, but the entire Program remains governed by
  2352. # this License without regard to the additional permissions.
  2353. #
  2354. #   When you convey a copy of a covered work, you may at your option
  2355. # remove any additional permissions from that copy, or from any part of
  2356. # it.  (Additional permissions may be written to require their own
  2357. # removal in certain cases when you modify the work.)  You may place
  2358. # additional permissions on material, added by you to a covered work,
  2359. # for which you have or can give appropriate copyright permission.
  2360. #
  2361. #   Notwithstanding any other provision of this License, for material you
  2362. # add to a covered work, you may (if authorized by the copyright holders of
  2363. # that material) supplement the terms of this License with terms:
  2364. #
  2365. #     a) Disclaiming warranty or limiting liability differently from the
  2366. #     terms of sections 15 and 16 of this License; or
  2367. #
  2368. #     b) Requiring preservation of specified reasonable legal notices or
  2369. #     author attributions in that material or in the Appropriate Legal
  2370. #     Notices displayed by works containing it; or
  2371. #
  2372. #     c) Prohibiting misrepresentation of the origin of that material, or
  2373. #     requiring that modified versions of such material be marked in
  2374. #     reasonable ways as different from the original version; or
  2375. #
  2376. #     d) Limiting the use for publicity purposes of names of licensors or
  2377. #     authors of the material; or
  2378. #
  2379. #     e) Declining to grant rights under trademark law for use of some
  2380. #     trade names, trademarks, or service marks; or
  2381. #
  2382. #     f) Requiring indemnification of licensors and authors of that
  2383. #     material by anyone who conveys the material (or modified versions of
  2384. #     it) with contractual assumptions of liability to the recipient, for
  2385. #     any liability that these contractual assumptions directly impose on
  2386. #     those licensors and authors.
  2387. #
  2388. #   All other non-permissive additional terms are considered "further
  2389. # restrictions" within the meaning of section 10.  If the Program as you
  2390. # received it, or any part of it, contains a notice stating that it is
  2391. # governed by this License along with a term that is a further
  2392. # restriction, you may remove that term.  If a license document contains
  2393. # a further restriction but permits relicensing or conveying under this
  2394. # License, you may add to a covered work material governed by the terms
  2395. # of that license document, provided that the further restriction does
  2396. # not survive such relicensing or conveying.
  2397. #
  2398. #   If you add terms to a covered work in accord with this section, you
  2399. # must place, in the relevant source files, a statement of the
  2400. # additional terms that apply to those files, or a notice indicating
  2401. # where to find the applicable terms.
  2402. #
  2403. #   Additional terms, permissive or non-permissive, may be stated in the
  2404. # form of a separately written license, or stated as exceptions;
  2405. # the above requirements apply either way.
  2406. #
  2407. #   8. Termination.
  2408. #
  2409. #   You may not propagate or modify a covered work except as expressly
  2410. # provided under this License.  Any attempt otherwise to propagate or
  2411. # modify it is void, and will automatically terminate your rights under
  2412. # this License (including any patent licenses granted under the third
  2413. # paragraph of section 11).
  2414. #
  2415. #   However, if you cease all violation of this License, then your
  2416. # license from a particular copyright holder is reinstated (a)
  2417. # provisionally, unless and until the copyright holder explicitly and
  2418. # finally terminates your license, and (b) permanently, if the copyright
  2419. # holder fails to notify you of the violation by some reasonable means
  2420. # prior to 60 days after the cessation.
  2421. #
  2422. #   Moreover, your license from a particular copyright holder is
  2423. # reinstated permanently if the copyright holder notifies you of the
  2424. # violation by some reasonable means, this is the first time you have
  2425. # received notice of violation of this License (for any work) from that
  2426. # copyright holder, and you cure the violation prior to 30 days after
  2427. # your receipt of the notice.
  2428. #
  2429. #   Termination of your rights under this section does not terminate the
  2430. # licenses of parties who have received copies or rights from you under
  2431. # this License.  If your rights have been terminated and not permanently
  2432. # reinstated, you do not qualify to receive new licenses for the same
  2433. # material under section 10.
  2434. #
  2435. #   9. Acceptance Not Required for Having Copies.
  2436. #
  2437. #   You are not required to accept this License in order to receive or
  2438. # run a copy of the Program.  Ancillary propagation of a covered work
  2439. # occurring solely as a consequence of using peer-to-peer transmission
  2440. # to receive a copy likewise does not require acceptance.  However,
  2441. # nothing other than this License grants you permission to propagate or
  2442. # modify any covered work.  These actions infringe copyright if you do
  2443. # not accept this License.  Therefore, by modifying or propagating a
  2444. # covered work, you indicate your acceptance of this License to do so.
  2445. #
  2446. #   10. Automatic Licensing of Downstream Recipients.
  2447. #
  2448. #   Each time you convey a covered work, the recipient automatically
  2449. # receives a license from the original licensors, to run, modify and
  2450. # propagate that work, subject to this License.  You are not responsible
  2451. # for enforcing compliance by third parties with this License.
  2452. #
  2453. #   An "entity transaction" is a transaction transferring control of an
  2454. # organization, or substantially all assets of one, or subdividing an
  2455. # organization, or merging organizations.  If propagation of a covered
  2456. # work results from an entity transaction, each party to that
  2457. # transaction who receives a copy of the work also receives whatever
  2458. # licenses to the work the party's predecessor in interest had or could
  2459. # give under the previous paragraph, plus a right to possession of the
  2460. # Corresponding Source of the work from the predecessor in interest, if
  2461. # the predecessor has it or can get it with reasonable efforts.
  2462. #
  2463. #   You may not impose any further restrictions on the exercise of the
  2464. # rights granted or affirmed under this License.  For example, you may
  2465. # not impose a license fee, royalty, or other charge for exercise of
  2466. # rights granted under this License, and you may not initiate litigation
  2467. # (including a cross-claim or counterclaim in a lawsuit) alleging that
  2468. # any patent claim is infringed by making, using, selling, offering for
  2469. # sale, or importing the Program or any portion of it.
  2470. #
  2471. #   11. Patents.
  2472. #
  2473. #   A "contributor" is a copyright holder who authorizes use under this
  2474. # License of the Program or a work on which the Program is based.  The
  2475. # work thus licensed is called the contributor's "contributor version".
  2476. #
  2477. #   A contributor's "essential patent claims" are all patent claims
  2478. # owned or controlled by the contributor, whether already acquired or
  2479. # hereafter acquired, that would be infringed by some manner, permitted
  2480. # by this License, of making, using, or selling its contributor version,
  2481. # but do not include claims that would be infringed only as a
  2482. # consequence of further modification of the contributor version.  For
  2483. # purposes of this definition, "control" includes the right to grant
  2484. # patent sublicenses in a manner consistent with the requirements of
  2485. # this License.
  2486. #
  2487. #   Each contributor grants you a non-exclusive, worldwide, royalty-free
  2488. # patent license under the contributor's essential patent claims, to
  2489. # make, use, sell, offer for sale, import and otherwise run, modify and
  2490. # propagate the contents of its contributor version.
  2491. #
  2492. #   In the following three paragraphs, a "patent license" is any express
  2493. # agreement or commitment, however denominated, not to enforce a patent
  2494. # (such as an express permission to practice a patent or covenant not to
  2495. # sue for patent infringement).  To "grant" such a patent license to a
  2496. # party means to make such an agreement or commitment not to enforce a
  2497. # patent against the party.
  2498. #
  2499. #   If you convey a covered work, knowingly relying on a patent license,
  2500. # and the Corresponding Source of the work is not available for anyone
  2501. # to copy, free of charge and under the terms of this License, through a
  2502. # publicly available network server or other readily accessible means,
  2503. # then you must either (1) cause the Corresponding Source to be so
  2504. # available, or (2) arrange to deprive yourself of the benefit of the
  2505. # patent license for this particular work, or (3) arrange, in a manner
  2506. # consistent with the requirements of this License, to extend the patent
  2507. # license to downstream recipients.  "Knowingly relying" means you have
  2508. # actual knowledge that, but for the patent license, your conveying the
  2509. # covered work in a country, or your recipient's use of the covered work
  2510. # in a country, would infringe one or more identifiable patents in that
  2511. # country that you have reason to believe are valid.
  2512. #
  2513. #   If, pursuant to or in connection with a single transaction or
  2514. # arrangement, you convey, or propagate by procuring conveyance of, a
  2515. # covered work, and grant a patent license to some of the parties
  2516. # receiving the covered work authorizing them to use, propagate, modify
  2517. # or convey a specific copy of the covered work, then the patent license
  2518. # you grant is automatically extended to all recipients of the covered
  2519. # work and works based on it.
  2520. #
  2521. #   A patent license is "discriminatory" if it does not include within
  2522. # the scope of its coverage, prohibits the exercise of, or is
  2523. # conditioned on the non-exercise of one or more of the rights that are
  2524. # specifically granted under this License.  You may not convey a covered
  2525. # work if you are a party to an arrangement with a third party that is
  2526. # in the business of distributing software, under which you make payment
  2527. # to the third party based on the extent of your activity of conveying
  2528. # the work, and under which the third party grants, to any of the
  2529. # parties who would receive the covered work from you, a discriminatory
  2530. # patent license (a) in connection with copies of the covered work
  2531. # conveyed by you (or copies made from those copies), or (b) primarily
  2532. # for and in connection with specific products or compilations that
  2533. # contain the covered work, unless you entered into that arrangement,
  2534. # or that patent license was granted, prior to 28 March 2007.
  2535. #
  2536. #   Nothing in this License shall be construed as excluding or limiting
  2537. # any implied license or other defenses to infringement that may
  2538. # otherwise be available to you under applicable patent law.
  2539. #
  2540. #   12. No Surrender of Others' Freedom.
  2541. #
  2542. #   If conditions are imposed on you (whether by court order, agreement or
  2543. # otherwise) that contradict the conditions of this License, they do not
  2544. # excuse you from the conditions of this License.  If you cannot convey a
  2545. # covered work so as to satisfy simultaneously your obligations under this
  2546. # License and any other pertinent obligations, then as a consequence you may
  2547. # not convey it at all.  For example, if you agree to terms that obligate you
  2548. # to collect a royalty for further conveying from those to whom you convey
  2549. # the Program, the only way you could satisfy both those terms and this
  2550. # License would be to refrain entirely from conveying the Program.
  2551. #
  2552. #   13. Use with the GNU Affero General Public License.
  2553. #
  2554. #   Notwithstanding any other provision of this License, you have
  2555. # permission to link or combine any covered work with a work licensed
  2556. # under version 3 of the GNU Affero General Public License into a single
  2557. # combined work, and to convey the resulting work.  The terms of this
  2558. # License will continue to apply to the part which is the covered work,
  2559. # but the special requirements of the GNU Affero General Public License,
  2560. # section 13, concerning interaction through a network will apply to the
  2561. # combination as such.
  2562. #
  2563. #   14. Revised Versions of this License.
  2564. #
  2565. #   The Free Software Foundation may publish revised and/or new versions of
  2566. # the GNU General Public License from time to time.  Such new versions will
  2567. # be similar in spirit to the present version, but may differ in detail to
  2568. # address new problems or concerns.
  2569. #
  2570. #   Each version is given a distinguishing version number.  If the
  2571. # Program specifies that a certain numbered version of the GNU General
  2572. # Public License "or any later version" applies to it, you have the
  2573. # option of following the terms and conditions either of that numbered
  2574. # version or of any later version published by the Free Software
  2575. # Foundation.  If the Program does not specify a version number of the
  2576. # GNU General Public License, you may choose any version ever published
  2577. # by the Free Software Foundation.
  2578. #
  2579. #   If the Program specifies that a proxy can decide which future
  2580. # versions of the GNU General Public License can be used, that proxy's
  2581. # public statement of acceptance of a version permanently authorizes you
  2582. # to choose that version for the Program.
  2583. #
  2584. #   Later license versions may give you additional or different
  2585. # permissions.  However, no additional obligations are imposed on any
  2586. # author or copyright holder as a result of your choosing to follow a
  2587. # later version.
  2588. #
  2589. #   15. Disclaimer of Warranty.
  2590. #
  2591. #   THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  2592. # APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  2593. # HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
  2594. # OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
  2595. # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  2596. # PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
  2597. # IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
  2598. # ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  2599. #
  2600. #   16. Limitation of Liability.
  2601. #
  2602. #   IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  2603. # WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
  2604. # THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
  2605. # GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  2606. # USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  2607. # DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
  2608. # PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
  2609. # EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
  2610. # SUCH DAMAGES.
  2611. #
  2612. #   17. Interpretation of Sections 15 and 16.
  2613. #
  2614. #   If the disclaimer of warranty and limitation of liability provided
  2615. # above cannot be given local legal effect according to their terms,
  2616. # reviewing courts shall apply local law that most closely approximates
  2617. # an absolute waiver of all civil liability in connection with the
  2618. # Program, unless a warranty or assumption of liability accompanies a
  2619. # copy of the Program in return for a fee.
  2620. #
  2621. #                      END OF TERMS AND CONDITIONS
  2622. #
  2623. #             How to Apply These Terms to Your New Programs
  2624. #
  2625. #   If you develop a new program, and you want it to be of the greatest
  2626. # possible use to the public, the best way to achieve this is to make it
  2627. # free software which everyone can redistribute and change under these terms.
  2628. #
  2629. #   To do so, attach the following notices to the program.  It is safest
  2630. # to attach them to the start of each source file to most effectively
  2631. # state the exclusion of warranty; and each file should have at least
  2632. # the "copyright" line and a pointer to where the full notice is found.
  2633. #
  2634. #     <one line to give the program's name and a brief idea of what it does.>
  2635. #     Copyright (C) <year>  <name of author>
  2636. #
  2637. #     This program is free software: you can redistribute it and/or modify
  2638. #     it under the terms of the GNU General Public License as published by
  2639. #     the Free Software Foundation, either version 3 of the License, or
  2640. #     (at your option) any later version.
  2641. #
  2642. #     This program is distributed in the hope that it will be useful,
  2643. #     but WITHOUT ANY WARRANTY; without even the implied warranty of
  2644. #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2645. #     GNU General Public License for more details.
  2646. #
  2647. #     You should have received a copy of the GNU General Public License
  2648. #     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  2649. #
  2650. # Also add information on how to contact you by electronic and paper mail.
  2651. #
  2652. #   If the program does terminal interaction, make it output a short
  2653. # notice like this when it starts in an interactive mode:
  2654. #
  2655. #     <program>  Copyright (C) <year>  <name of author>
  2656. #     This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  2657. #     This is free software, and you are welcome to redistribute it
  2658. #     under certain conditions; type `show c' for details.
  2659. #
  2660. # The hypothetical commands `show w' and `show c' should show the appropriate
  2661. # parts of the General Public License.  Of course, your program's commands
  2662. # might be different; for a GUI interface, you would use an "about box".
  2663. #
  2664. #   You should also get your employer (if you work as a programmer) or school,
  2665. # if any, to sign a "copyright disclaimer" for the program, if necessary.
  2666. # For more information on this, and how to apply and follow the GNU GPL, see
  2667. # <http://www.gnu.org/licenses/>.
  2668. #
  2669. #   The GNU General Public License does not permit incorporating your program
  2670. # into proprietary programs.  If your program is a subroutine library, you
  2671. # may consider it more useful to permit linking proprietary applications with
  2672. # the library.  If this is what you want to do, use the GNU Lesser General
  2673. # Public License instead of this License.  But first, please read
  2674. # <http://www.gnu.org/philosophy/why-not-lgpl.html>.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement