Advertisement
Swizzy

libXenon install.sh

Aug 18th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.43 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ "$ID" == "0" ]; then
  4.     echo "Don't run this script as root!!! use your regular user..." 1>&2
  5.     exit 1
  6. fi
  7.  
  8. LOGFILE="`echo $0 | tr "\/" "\n" | head -$(( $slashes -1 )) | tr "\n" "\/"`build.log"
  9. rm $LOGFILE
  10.  
  11. ###########################################################
  12. # Don't touch these unless you know what you are doing... #
  13. ###########################################################
  14.  
  15. LIBXENON=https://github.com/Free60Project/libxenon.git
  16. LIBXENONBRANCH=Swizzy
  17.  
  18. function StartMsg
  19. {
  20.         echo -e -n $@
  21.         echo -e -n ": "
  22. }
  23.  
  24.  
  25. function AllOK
  26. {
  27.         echo -e "Done!"
  28.         rm $LOGFILE
  29. }
  30.  
  31. function FindDependency
  32. {
  33.     StartMsg Looking for \'$1\'
  34.     PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $1 2> /dev/null|grep "install ok installed")
  35.     if [ "" == "$PKG_OK" ]; then
  36.         echo -e "No '$1' Setting up '$1'..."
  37.         sudo apt-get --force-yes --yes install $1 >> $LOGFILE 2>&1 || exit 1
  38.     else
  39.         echo -e "'$1' installed already... skipping..."
  40.     fi
  41. }
  42.  
  43. function InstallDependencies
  44. {
  45.     echo -e "Checking for dependencies..."
  46.     FindDependency libgmp3-dev
  47.     FindDependency libmpfr-dev
  48.     FindDependency libmpc-dev
  49.     FindDependency texinfo
  50.     FindDependency git-core
  51.     FindDependency gettext
  52.     FindDependency build-essential
  53. }
  54.  
  55. function Clone
  56. {
  57.     if [ ! -d $2 ]; then
  58.         echo -e -n "Cloning... "
  59.         git clone $1 >> $LOGFILE 2>&1 || exit 1
  60.     else
  61.         cd $2
  62.         git remote update >> $LOGFILE 2>&1
  63.         git status -uno | grep -q behind
  64.         if [ 0 -eq $? ]; then
  65.             echo -e -n "Updating... "
  66.             git pull >> $LOGFILE 2>&1
  67.                         make clean >> $LOGFILE 2>&1
  68.         else
  69.             echo -e -n "Already Up-To-Date... "
  70.         fi
  71.         cd ..
  72.     fi
  73. }
  74.  
  75. function CloneSpecial
  76. {
  77.     if [ ! -d $2 ]; then
  78.         echo -e -n "Cloning... "
  79.         git clone $1 >> $LOGFILE 2>&1 || exit 1
  80.         cd $2
  81.         git checkout $3
  82.     else
  83.         cd $2
  84.         git checkout $3
  85.         git remote update >> $LOGFILE 2>&1
  86.         git status -uno | grep -q behind
  87.         if [ 0 -eq $? ]; then
  88.             echo -e -n "Updating... "
  89.             git pull >> $LOGFILE 2>&1
  90.                         make clean >> $LOGFILE 2>&1
  91.         else
  92.             echo -e -n "Already Up-To-Date... "
  93.         fi
  94.         cd ..
  95.     fi
  96. }
  97.  
  98. function Compile
  99. {
  100.     echo -e -n "Compiling... "
  101.     cd $1
  102.     make >> $LOGFILE 2>&1 || exit 1
  103.     cd ..
  104. }
  105.  
  106. function CompileSpecial
  107. {
  108.     echo -e -n "Compiling... "
  109.     cd $1
  110.     make -f $2 >> $LOGFILE 2>&1 || exit 1
  111.     cd ..
  112. }
  113.  
  114. function Install
  115. {
  116.     echo -e -n "Installing... "
  117.     cd $1
  118.     make install >> $LOGFILE 2>&1 || exit 1
  119.     cd ..
  120. }
  121.  
  122. function InstallSpecial
  123. {
  124.         echo -e -n "Installing... "
  125.         cd $1
  126.         make -f $2 install >> $LOGFILE 2>&1 || exit 1
  127.         cd ..
  128. }
  129.  
  130. function MakeLibxenon
  131. {
  132.     StartMsg Libxenon
  133.     Clone $LIBXENON libxenon
  134.     AllOK
  135.     cd libxenon
  136.     if [ "" != "$LIBXENONBRANCH" ]; then
  137.         git checkout $LIBXENONBRANCH
  138.     fi
  139.     cd toolchain
  140.     UserPrimaryGroupId=`cat /etc/passwd | grep -Ew ^$USER | cut -d":" -f4`
  141.     UserPrimaryGroup=`cat /etc/group | grep :"$UserPrimaryGroupId": | cut -d":" -f1`
  142.     sudo chown -R $USER:$UserPrimaryGroup /usr/local/xenon
  143.     echo -e "Building toolchain, libxenon and the libs..."
  144.     echo -e "Building the toolchain..."
  145.     bash build-xenon-toolchain toolchain || exit 1
  146.     echo -e "Building libxenon..."
  147.     bash build-xenon-toolchain libxenon || exit 1
  148.     echo -e "Building libs..."
  149.     bash build-xenon-toolchain libs || exit 1
  150.     echo -e "Setting up devkitxenon script..."
  151.     sudo bash -c "printf \"export DEVKITXENON=\\\"/usr/local/xenon\\\"\\\nexport PATH=\\\"\\\$PATH:\\\$DEVKITXENON/bin:\\\$DEVKITXENON/usr/bin\\\"\" >> /etc/profile.d/devkitxenon.sh"
  152.     sudo chmod +x /etc/profile.d/devkitxenon.sh
  153.     export DEVKITXENON="/usr/local/xenon"
  154.     export PATH="$PATH:$DEVKITXENON/bin:$DEVKITXENON/usr/bin"
  155. }
  156.  
  157. StartMsg Looking for \'sudo\'
  158. PKG_OK=$(dpkg-query -W --showformat='${Status}\n' sudo 2> /dev/null|grep "install ok installed") >> /dev/null 2>&1
  159. if [ "" == "$PKG_OK" ]; then
  160.     echo -e "sudo not found! please install it..." 1>&2
  161.     exit 1
  162. else
  163.     echo -e "sudo installed... let's continue shall we?"
  164. fi
  165.  
  166. sudo mkdir -p /usr/local/xenon
  167. if [ "$1" != "notoolchain" ]; then
  168.     InstallDependencies
  169.     MakeLibxenon
  170. fi
  171.  
  172. #StartMsg libFAT-Xenon Swizzy Edition
  173. #CloneSpecial https://github.com/LibXenonProject/fat-xenon.git fat-xenon Swizzy
  174. #Compile fat-xenon
  175. #Install fat-xenon
  176. #AllOK
  177.  
  178. #StartMsg libNTFS-Xenon Swizzy Edition
  179. #CloneSpecial https://github.com/LibXenonProject/ntfs-xenon.git ntfs-xenon Swizzy
  180. #Compile ntfs-xenon
  181. #Install ntfs-xenon
  182. #AllOK
  183.  
  184. StartMsg libSDL
  185. Clone https://github.com/LibXenonProject/libSDLXenon.git libSDLXenon
  186. CompileSpecial libSDLXenon Makefile.xenon
  187. InstallSpecial libSDLXenon Makefile.xenon
  188. AllOK
  189.  
  190. StartMsg SDL_ttf
  191. Clone https://github.com/LibXenonProject/SDL_ttf.git SDL_ttf
  192. Compile SDL_ttf
  193. Install SDL_ttf
  194. AllOK
  195.  
  196. #StartMsg SDL_net
  197. #Clone https://github.com/LibXenonProject/SDL_net.git SDL_net
  198. #
  199. #
  200. #AllOK
  201.  
  202. StartMsg SDL_Image
  203. Clone https://github.com/LibXenonProject/SDL_Image.git SDL_Image
  204. CompileSpecial SDL_Image Makefile.xenon
  205. InstallSpecial SDL_Image Makefile.xenon
  206. AllOK
  207.  
  208. StartMsg SDL_Mixer
  209. Clone https://github.com/LibXenonProject/SDL_Mixer.git SDL_Mixer
  210. CompileSpecial SDL_Mixer Makefile.xenon
  211. InstallSpecial SDL_Mixer Makefile.xenon
  212. AllOK
  213.  
  214. StartMsg libxemit
  215. Clone https://github.com/gligli/libxemit.git libxemit
  216. Compile libxemit
  217. Install libxemit
  218. AllOK
  219.  
  220. StartMsg ZLX
  221. Clone https://github.com/LibXenonProject/ZLX-Library.git ZLX-Library
  222. CompileSpecial ZLX-Library Makefile_lib
  223. InstallSpecial ZLX-Library Makefile_lib
  224. AllOK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement