11#! /bin/bash
2- # toolchain-mingw.sh by Miigotu (miigotu@hotmail .com)
2+ # toolchain-mingw.sh by Miigotu (miigotu@gmail .com)
33
4+ # shellcheck disable=SC2016
45MINGW32EXPORTS=\
56(' export GITINSTALLDIR=/c/msysgit' \
67' export PATH="$PATH:$GITINSTALLDIR/bin"' \
@@ -21,167 +22,167 @@ RESTART=0
2122
2223ask_permission ()
2324{
24- if [ $DO_SET_EXPORTS -ne 0 ]; then
25- if [ $HAS_ANSWERED -ne 1 ]; then
26- echo -e " \E[1;31mWARNING:\E[0m\E[1m If you continue, his script will modify your global profile!\E[0m"
27- echo
28- echo The purpose of this change is to add export paths to your profile.
29- echo To undo this, edit /etc/profile and removing these lines from the bottom:
30- echo -e ' (\E[4mNote:\E[0m These are also the exports that will be added, take note.)'
31- echo
32- echo -e ' \E[0;32m export GITINSTALLDIR=/c/msysgit'
33- echo ' export PATH="$PATH:$GITINSTALLDIR/bin"'
34- echo ' export PATH="$PATH:$GITINSTALLDIR/mingw/bin"'
35- echo ' export PYINSTALLDIR=/c/python27'
36- echo ' export PATH="$PATH:$PYINSTALLDIR"'
37- echo ' export PS3DEV=/usr/local/ps3dev'
38- echo ' export PATH="$PATH:$PS3DEV/bin"'
39- echo ' export PATH="$PATH:$PS3DEV/host/ppu/bin"'
40- echo ' export PATH="$PATH:$PS3DEV/host/spu/bin"'
41- echo ' export PSL1GHT=$PS3DEV/psl1ght'
42- echo -e ' export PATH="$PATH:$PSL1GHT/host/bin"\E[0m'
43- echo
44- echo It is highly recommended that you do this, to have the same build that most
45- echo others have, so that it is easier for others to help you when you have issues.
46- echo Also, the buildscripts will fail if certain paths and variables are not set.
47- echo
48- echo -e ' \E[1mDo you want to set these exports?\E[0m'
49- echo
50-
51- PS3=" Enter 1, 2, or 3: "
52- options=(" Yes, change my profile for me." " No, I have set them myself, but continue." " Quit, I will set them myself." )
53- select opt in " ${options[@]} "
54- do
55- case $opt in
56- " Yes, change my profile for me." )
57- DO_SET_EXPORTS=1
58- HAS_ANSWERED=1
59- break
60- ;;
61- " No, I have set them myself, but continue." )
62- DO_SET_EXPORTS=0
63- HAS_ANSWERED=1
64- break
65- ;;
66- " Quit, I will set them myself." )
67- echo
68- echo -e " \E[1mExitting, Run this script again when you are ready.\E[0m"
69- exit 0
70- ;;
71- * ) echo Invalid option, please try again.
72- ;;
73- esac
74- done
75- fi
76- fi
25+ if [ $DO_SET_EXPORTS -ne 0 ]; then
26+ # shellcheck disable=SC2016
27+ if [ $HAS_ANSWERED -ne 1 ]; then
28+ env echo -e " \E[1;31mWARNING:\E[0m\E[1m If you continue, his script will modify your global profile!\E[0m"
29+ env echo
30+ env echo The purpose of this change is to add export paths to your profile.
31+ env echo To undo this, edit /etc/profile and removing these lines from the bottom:
32+ env echo -e ' (\E[4mNote:\E[0m These are also the exports that will be added, take note.)'
33+ env echo
34+ env echo -e ' \E[0;32m export GITINSTALLDIR=/c/msysgit'
35+ env echo ' export PATH="$PATH:$GITINSTALLDIR/bin"'
36+ env echo ' export PATH="$PATH:$GITINSTALLDIR/mingw/bin"'
37+ env echo ' export PYINSTALLDIR=/c/python27'
38+ env echo ' export PATH="$PATH:$PYINSTALLDIR"'
39+ env echo ' export PS3DEV=/usr/local/ps3dev'
40+ env echo ' export PATH="$PATH:$PS3DEV/bin"'
41+ env echo ' export PATH="$PATH:$PS3DEV/host/ppu/bin"'
42+ env echo ' export PATH="$PATH:$PS3DEV/host/spu/bin"'
43+ env echo ' export PSL1GHT=$PS3DEV/psl1ght'
44+ env echo -e ' export PATH="$PATH:$PSL1GHT/host/bin"\E[0m'
45+ env echo
46+ env echo ' It is highly recommended that you do this, to have the same build that most'
47+ env echo ' others have, so that it is easier for others to help you when you have issues.'
48+ env echo ' Also, the build scripts will fail if certain paths and variables are not set.'
49+ env echo
50+ env echo -e ' \E[1mDo you want to set these exports?\E[0m'
51+ env echo
52+
53+ PS3=" Enter 1, 2, or 3: "
54+ options=(" Yes, change my profile for me." " No, I have set them myself, but continue." " Quit, I will set them myself." )
55+ select opt in " ${options[@]} "
56+ do
57+ case $opt in
58+ " Yes, change my profile for me." )
59+ DO_SET_EXPORTS=1
60+ HAS_ANSWERED=1
61+ break
62+ ;;
63+ " No, I have set them myself, but continue." )
64+ DO_SET_EXPORTS=0
65+ HAS_ANSWERED=1
66+ break
67+ ;;
68+ " Quit, I will set them myself." )
69+ env echo
70+ env echo -e " \E[1mExiting, Run this script again when you are ready.\E[0m"
71+ exit 0
72+ ;;
73+ * ) env echo Invalid option, please try again.
74+ ;;
75+ esac
76+ done
77+ fi
78+ fi
7779}
7880
79- if [ $MSYSTEM == MINGW32 ]; then
80- for(( i = 0 ; i < ${# MINGW32EXPORTS[*]} ; i++ )) ; do
81- if ! grep -q " ${MINGW32EXPORTS[${i}]} " /etc/profile; then
82- ask_permission
83- if [ $DO_SET_EXPORTS -ne 0 ]; then
84- if [ $NEWLINE -ne 1 ]; then
85- echo >> /etc/profile # #In cases where no new line is at EOF.
86- NEWLINE=1
87- fi
88- echo ${MINGW32EXPORTS[${i}]} >> /etc/profile
89- RESTART=1
90- fi
91- fi
92- done
93- if [ $RESTART -eq 1 ]; then
94- echo -e " Please restart mingw, or type \E[1m'. /etc/profile'\E[0m (without quotes)"
95- echo " and then run this script again."
96- exit 1
97- fi
98-
99- INSTALL_PACKAGES=
100-
101- # # Install Dependancy packages
102- if [ ! -f /usr//include/gmp.h ]; then
103- INSTALL_PACKAGES+=" msys-libgmp-dev gmp gmp-dev "
104- fi
105- if [ ! -f /usr//include/crypt.h ]; then
106- INSTALL_PACKAGES+=" msys-libcrypt "
107- fi
108- if [ ! -f /usr/include/zlib.h ]; then
109- INSTALL_PACKAGES+=" msys-zlib "
110- fi
111- if [ ! -f /mingw/include/zlib.h ]; then
112- INSTALL_PACKAGES+=" libz "
113- fi
114- if [ ! -f /mingw/include/curses.h ]; then
115- INSTALL_PACKAGES+=" libpdcurses "
116- fi
117- if [ ! -f /mingw/bin/pexports ]; then
118- INSTALL_PACKAGES+=" pexports "
119- fi
120- if [ ! -f /usr/bin/wget ]; then
121- INSTALL_PACKAGES+=" msys-wget "
122- fi
123- if [ ! -f /usr/bin/patch ]; then
124- INSTALL_PACKAGES+=" msys-patch "
125- fi
126- if [ ! -f /usr/bin/unzip ]; then
127- INSTALL_PACKAGES+=" msys-unzip "
128- fi
129- if [ ! -f /usr/include/openssl/sha.h ]; then
130- INSTALL_PACKAGES+=" msys-libopenssl "
131- fi
132-
133- if [ ${INSTALL_PACKAGES} ]; then
134- mingw-get install $INSTALL_PACKAGES
135- fi
136-
137- # # Create the build directory.
138- mkdir -p build && cd build || { echo " ERROR: Could not create the build directory." ; exit 1; }
139-
140- # # Install libelf
141- if [ ! -f /mingw/include/libelf.h ]; then
142- wget http://www.mr511.de/software/libelf-0.8.13.tar.gz
143- tar -zxvf libelf-0.8.13.tar.gz
144- cd libelf-0.8.13
145- ./configure --prefix=" /mingw"
146- make -j4 && make install
147- cd ..
148- fi
149-
150-
151- # # Install pkg-config and dependancy dll's
152- if [ ! -f /usr/bin/pkg-config ]; then
153- wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.25-1_win32.zip
154- unzip -o pkg-config_0.25-1_win32.zip bin/* .exe -d /usr > NUL
155- fi
156- if [ ! -f /usr/bin/intl.dll ]; then
157- wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
158- unzip -o gettext-runtime_0.18.1.1-2_win32.zip bin/* .dll -d /usr > NUL
159- fi
160- if [ ! -f /usr/bin/libglib-2.0-0.dll ]; then
161- wget https://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.26/glib_2.26.1-1_win32.zip
162- unzip -o glib_2.26.1-1_win32.zip bin/* .dll -d /usr > NUL
163- fi
164-
165- rm -Rf pkg-config_0.25-1_win32.zip glib_2.26.1-1_win32.zip gettext-runtime_0.18.1.1-2_win32.zip libelf-0.8.13.tar.gz libelf-0.8.13
166-
167- # # Convert python.dll to a shared library
168- if [ ! -f $PYINSTALLDIR /libs/libpython27.a ]; then
169- PYDLL=" $WINDIR \SysWOW64\python27.dll"
170- pexports " $PYDLL " > python27.def
171- if [ $? != 0 ]; then
172- PYDLL=" $WINDIR \System32\python27.dll"
173- pexports " $PYDLL " > python27.def
174- fi
175- dlltool --dllname " $PYDLL " --def python27.def --output-lib libpython27.a
176- mv libpython27.a $PYINSTALLDIR /libs
177- rm -Rf python27.def
178- fi
179-
180- # # Enter the ps3toolchain directory.
181- cd ..
182-
183- # # Run the toolchain script.
184- ./toolchain.sh $@ || { echo " ERROR: Could not run the toolchain script." ; exit 1; }
81+ if [ " $MSYSTEM " == MINGW32 ]; then
82+ for(( i = 0 ; i < ${# MINGW32EXPORTS[*]} ; i++ )) ; do
83+ if ! grep -q " ${MINGW32EXPORTS[${i}]} " /etc/profile; then
84+ ask_permission
85+ if [ $DO_SET_EXPORTS -ne 0 ]; then
86+ if [ $NEWLINE -ne 1 ]; then
87+ env echo >> /etc/profile # #In cases where no new line is at EOF.
88+ NEWLINE=1
89+ fi
90+ env echo " ${MINGW32EXPORTS[${i}]} " >> /etc/profile
91+ RESTART=1
92+ fi
93+ fi
94+ done
95+ if [ $RESTART -eq 1 ]; then
96+ env echo -e " Please restart mingw, or type \E[1m'. /etc/profile'\E[0m (without quotes)"
97+ env echo " and then run this script again."
98+ exit 1
99+ fi
100+
101+ INSTALL_PACKAGES=
102+
103+ # # Install Dependency packages
104+ if [ ! -f /usr//include/gmp.h ]; then
105+ INSTALL_PACKAGES+=" msys-libgmp-dev gmp gmp-dev "
106+ fi
107+ if [ ! -f /usr//include/crypt.h ]; then
108+ INSTALL_PACKAGES+=" msys-libcrypt "
109+ fi
110+ if [ ! -f /usr/include/zlib.h ]; then
111+ INSTALL_PACKAGES+=" msys-zlib "
112+ fi
113+ if [ ! -f /mingw/include/zlib.h ]; then
114+ INSTALL_PACKAGES+=" libz "
115+ fi
116+ if [ ! -f /mingw/include/curses.h ]; then
117+ INSTALL_PACKAGES+=" libpdcurses "
118+ fi
119+ if [ ! -f /mingw/bin/pexports ]; then
120+ INSTALL_PACKAGES+=" pexports "
121+ fi
122+ if [ ! -f /usr/bin/wget ]; then
123+ INSTALL_PACKAGES+=" msys-wget "
124+ fi
125+ if [ ! -f /usr/bin/patch ]; then
126+ INSTALL_PACKAGES+=" msys-patch "
127+ fi
128+ if [ ! -f /usr/bin/unzip ]; then
129+ INSTALL_PACKAGES+=" msys-unzip "
130+ fi
131+ if [ ! -f /usr/include/openssl/sha.h ]; then
132+ INSTALL_PACKAGES+=" msys-libopenssl "
133+ fi
134+
135+ if [ " ${INSTALL_PACKAGES} " ]; then
136+ mingw-get install " $INSTALL_PACKAGES "
137+ fi
138+
139+ # # Create the build directory.
140+ (mkdir -p build && cd build) || { env echo " ERROR: Could not create the build directory." ; exit 1; }
141+
142+ # # Install libelf
143+ if [ ! -f /mingw/include/libelf.h ]; then
144+ wget http://www.mr511.de/software/libelf-0.8.13.tar.gz
145+ tar -zxvf libelf-0.8.13.tar.gz
146+ cd libelf-0.8.13 || { env echo " ERROR: Extracting libelf failed." ; exit 1; }
147+ ./configure --prefix=" /mingw"
148+ make -j4 && make install
149+ cd ..
150+ fi
151+
152+
153+ # # Install pkg-config and dependency dll's
154+ if [ ! -f /usr/bin/pkg-config ]; then
155+ wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.25-1_win32.zip
156+ unzip -o pkg-config_0.25-1_win32.zip bin/* .exe -d /usr > NUL
157+ fi
158+ if [ ! -f /usr/bin/intl.dll ]; then
159+ wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
160+ unzip -o gettext-runtime_0.18.1.1-2_win32.zip bin/* .dll -d /usr > NUL
161+ fi
162+ if [ ! -f /usr/bin/libglib-2.0-0.dll ]; then
163+ wget https://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.26/glib_2.26.1-1_win32.zip
164+ unzip -o glib_2.26.1-1_win32.zip bin/* .dll -d /usr > NUL
165+ fi
166+
167+ rm -Rf pkg-config_0.25-1_win32.zip glib_2.26.1-1_win32.zip gettext-runtime_0.18.1.1-2_win32.zip libelf-0.8.13.tar.gz libelf-0.8.13
168+
169+ # # Convert python.dll to a shared library
170+ if [ ! -f " $PYINSTALLDIR " /libs/libpython27.a ]; then
171+ PYDLL=" $WINDIR \SysWOW64\python27.dll"
172+ if ! pexports " $PYDLL " > python27.def; then
173+ PYDLL=" $WINDIR \System32\python27.dll"
174+ pexports " $PYDLL " > python27.def
175+ fi
176+ dlltool --dllname " $PYDLL " --def python27.def --output-lib libpython27.a
177+ mv libpython27.a " $PYINSTALLDIR " /libs
178+ rm -Rf python27.def
179+ fi
180+
181+ # # Enter the ps3toolchain directory.
182+ cd ..
183+
184+ # # Run the toolchain script.
185+ ./toolchain.sh " $@ " || { env echo " ERROR: Could not run the toolchain script." ; exit 1; }
185186else
186- echo " MinGW was not detected as your kernel, exitting ."
187+ env echo " MinGW was not detected as your kernel, exiting ."
187188fi
0 commit comments