]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/msys2_install.sh
Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements (#4520)
[qmk_firmware.git] / util / msys2_install.sh
1 #!/bin/bash
2
3 dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 download_dir=~/qmk_utils
5 avrtools=avr8-gnu-toolchain
6 armtools=gcc-arm-none-eabi
7 installflip=false
8
9 echo "Installing dependencies needed for the installation (quazip)"
10 pacman --needed -S msys/unzip msys/p7zip base-devel msys/git mingw-w64-x86_64-toolchain
11
12 source "$dir/win_shared_install.sh"
13
14 function install_avr {
15     rm -f -r "$avrtools"
16     wget "http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip"
17     7z x avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip
18     mv avr8-gnu-toolchain-win32_x86/ avr8-gnu-toolchain
19     rm __MACOSX -R
20     rm avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip
21     pacman --needed -S mingw-w64-x86_64-avrdude
22 }
23
24 function install_arm {
25     wget -O gcc-arm-none-eabi.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32.zip?product=GNU%20ARM%20Embedded%20Toolchain,ZIP,,Windows,6-2017-q2-update"
26     unzip -d gcc-arm-none-eabi gcc-arm-none-eabi.zip
27     rm gcc-arm-none-eabi.zip
28 }
29
30 function extract_flip {
31     rm -f -r flip
32     7z -oflip x FlipInstaller.exe
33 }
34
35 pushd "$download_dir"
36
37 if [ -f "FlipInstaller.exe" ]; then
38     echo
39     echo "Extracting flip"
40     extract_flip
41 fi
42
43 if [ ! -d "$avrtools" ]; then
44     while true; do
45         echo
46         echo "The AVR toolchain is not installed."
47         echo "This is needed for building AVR based keboards."
48         read -p "Do you want to install it? (Y/N) " res
49         case $res in
50             [Yy]* ) install_avr; break;;
51             [Nn]* ) break;;
52             * ) echo "Invalid answer";;
53         esac
54     done
55 else
56     while true; do
57         echo
58         echo "The AVR toolchain is already installed"
59         read -p "Do you want to reinstall? (Y/N) " res
60         case $res in
61             [Yy]* ) install_avr; break;;
62             [Nn]* ) break;;
63             * ) echo "Invalid answer";;
64         esac
65     done
66 fi
67
68 if [ ! -d "$armtools" ]; then
69     while true; do
70         echo
71         echo "The ARM toolchain is not installed."
72         echo "This is needed for building ARM based keyboards."
73         read -p "Do you want to install it? (Y/N) " res
74         case $res in
75             [Yy]* ) install_arm; break;;
76             [Nn]* ) break;;
77             * ) echo "Invalid answer";;
78         esac
79     done
80 else
81     while true; do
82         echo
83         echo "The ARM toolchain is already installed"
84         read -p "Do you want to reinstall? (Y/N) " res
85         case $res in
86             [Yy]* ) install_arm; break;;
87             [Nn]* ) break;;
88             * ) echo "Invalid answer";;
89         esac
90     done
91 fi
92 popd
93
94 cp -f "$dir/activate_msys2.sh" "$download_dir/"
95
96 if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
97 then
98     echo
99     echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
100     echo "Not adding it twice!"
101 else
102     while true; do
103         echo
104         echo "Do you want to add 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
105         echo ".bashrc file? Without this make won't find the needed utils, so if you don't"
106         echo "want to do it automatically, then you have to do it manually later."
107         read -p "(Y/N)? " res
108         case $res in
109             [Yy]* ) echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; break;;
110             [Nn]* ) break;;
111             * ) echo "Invalid answer";;
112         esac
113     done
114 fi
115
116 echo
117 echo "******************************************************************************"
118 echo "Installation completed!"
119 echo "Please close this Window and restart MSYS2 MinGW"
120 echo "******************************************************************************"