├── README.md ├── build_common.sh ├── build_macOS.sh └── patch ├── binutils.patch ├── gcc.patch └── libelf.patch /README.md: -------------------------------------------------------------------------------- 1 | # vitasdk-macOS 2 | PlayStation Vita development under macOS Sierra 3 | =============================================== 4 | 5 | ============== 6 | Why use macOS? 7 | ============== 8 | 9 | I have been developing homebrew stuff for PlayStation platform since last 15 years and since my first Apple laptop with Osx Panther (2003) it has been my development platform. I don't like open a virtual machine with linux or windows to develop, i like more use all directily in my Mac, so for me it is the best option. 10 | 11 | 12 | ============== 13 | Steps 14 | ============== 15 | 16 | 1) Install macOS Sierra. 17 | 18 | I made a clean installation because i like more a fresh install instead of upgrade. I was in Os X Maverick so first i always make a copy of my system in external disk with carbon copy cloner and then check that i can boot from it before install new operating system. You can follow many guides on internet to do it. 19 | 20 | 2) Install Xcode 21 | 22 | Go to apple appstore download and install Xcode (Version 8) 23 | 24 | 3) Install Xcode command line tools 25 | 26 | Go to apple developer site and download and install Command Line Tools (macOS 10.12) for Xcode 8 package 27 | 28 | 4) Install some misc tools that i use often 29 | 30 | * XQuartz from https://www.xquartz.org/index.html 31 | * TextMate from https://macromates.com/ 32 | * iTerm from https://www.iterm2.com/ 33 | * Enable root account (Open Directory Utility in drop down "Edit Menu" enable root user and it will ask you to set a password for root user) 34 | 35 | 5) Install macports (other people use homebrew instead) 36 | 37 | Go to https://www.macports.org/install.php and follow steps described for macOS Sierra 38 | 39 | 40 | ``` 41 | sudo port -v selfupdate 42 | 43 | sudo port install autoconf automake bison flex texinfo ncurses wget libelf zlib libtool git gmp openssl mpfr libmpc unrar subversion bzip2 cmake pkgconfig go python34 44 | 45 | ``` 46 | 47 | 6) Create base directory for vitadev and clone repositories 48 | 49 | ``` 50 | cd /usr/local 51 | sudo mkdir -p vitadev/git 52 | sudo chown -R youruser:staff vitadev 53 | cd vitadev/git 54 | git clone http://github.com/xerpi/libvita2d 55 | git clone http://github.com/xerpi/libftpvita 56 | git clone http://github.com/xerpi/vita_portlibs 57 | git clone http://github.com/frangarcj/psplib4vita 58 | git clone http://github.com/psxdev/debugnet 59 | git clone http://github.com/psxdev/psp2link 60 | git clone http://github.com/psxdev/psp2client 61 | git clone http://github.com/psxdev/vitasdk-macOS 62 | ``` 63 | 64 | 7) Build toolchain and sdk 65 | 66 | ``` 67 | cd vitasdk-macOS 68 | ./build_macOS.sh 69 | ``` 70 | 71 | 8) Install toolchain and sdk 72 | 73 | ``` 74 | cd vitasdk 75 | cp -r bin /usr/local/vitadev 76 | cp -r arm-vita-eabi /usr/local/vitadev 77 | cp -r lib /usr/local/vitadev 78 | cp -r share /usr/local/vitadev 79 | ``` 80 | 81 | 9) Prepare profile with environment 82 | 83 | I use this script vitadev.sh in /usr/local/vitadev customize your own 84 | 85 | ``` 86 | cat /usr/local/vitadev.sh 87 | export VITADEV=/usr/local/vitadev 88 | export VITASDK=/usr/local/vitadev 89 | export PATH=$VITASDK/bin:$PATH 90 | export PSVITAIP=192.168.1.24 91 | ``` 92 | 93 | 10) Development session :) 94 | 95 | ``` 96 | cd /usr/local/vitadev 97 | . ./vitadev.sh 98 | cd git 99 | cd vita_portlibs 100 | make 101 | cd ../libvita2d/libvita2d 102 | make 103 | make install 104 | cd ../../libftpvita/libftpvita 105 | make 106 | make install 107 | cd ../../psplib4vita/psplib 108 | make 109 | make install 110 | cd ../../debugnet/libdebugnet 111 | make 112 | make install 113 | cd ../../psp2link/libpsp2link 114 | make 115 | make install 116 | ``` 117 | 118 | 11) Ready to have a lot of fun :) 119 | 120 | ============== 121 | Versions of software downloaded internally by build proccess 122 | ============== 123 | * http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz 124 | * http://ftp.gnu.org/gnu/gmp/gmp-6.1.1.tar.xz 125 | * http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.xz 126 | * http://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz 127 | * git://sourceware.org/git/binutils-gdb.git 128 | * http://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2 129 | * http://www.mr511.de/software/libelf-1.2.8.tar.gz 130 | * http://isl.gforge.inria.fr/isl-0.17.1.tar.xz 131 | * http://nih.at/libzip/libzip-1.1.3.tar.xz 132 | * http://zlib.net/zlib-1.2.8.tar.xz 133 | * http://github.com/akheron/jansson/archive/v2.8.tar.gz 134 | * http://github.com/vitasdk/vita-headers 135 | * http://github.com/vitasdk/newlib 136 | * http://github.com/vitasdk/pthread-embedded 137 | * http://github.com/vitasdk/vita-toolchain 138 | 139 | 140 | ============== 141 | Credits 142 | ============== 143 | 144 | * Based in soarqin good work at https://github.com/soarqin/vitasdk-msys2 145 | * Previous work for osx at https://github.com/psxdev/vitasdk-buildscripts 146 | 147 | -------------------------------------------------------------------------------- /build_common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOST_NATIVE=x86_64-apple-darwin10 4 | 5 | LIBICONV_VERSION=1.14 6 | GMP_VERSION=6.1.1 7 | MPFR_VERSION=3.1.4 8 | MPC_VERSION=1.0.3 9 | ISL_VERSION=0.17.1 10 | ZLIB_VERSION=1.2.8 11 | LIBZIP_VERSION=1.1.3 12 | LIBELF_VERSION=0.8.13 13 | JANSSON_VERSION=2.8 14 | DLFCN_VERSION=1.0.0 15 | BINUTILS_VERSION=2.27 16 | GCC_VERSION=6.2.0 17 | 18 | JOBS=-j4 19 | 20 | ROOTDIR=`pwd` 21 | PATCHDIR=${ROOTDIR}/patch 22 | DOWNLOADDIR=${ROOTDIR}/download 23 | SRCDIR=${ROOTDIR}/src 24 | BUILDDIR=${ROOTDIR}/build 25 | mkdir -p ${SRCDIR} ${BUILDDIR} 26 | SRCRELDIR=../src 27 | INSTALLDIR=${ROOTDIR}/install 28 | VITASDKROOT=${ROOTDIR}/vitasdk 29 | 30 | 31 | # Strip binary files as in "strip binary" form, for both native(linux/mac) and mingw. 32 | strip_binary() { 33 | set +e 34 | if [ $# -ne 2 ] ; then 35 | warning "strip_binary: Missing arguments" 36 | return 0 37 | fi 38 | local strip="$1" 39 | local bin="$2" 40 | 41 | file $bin | grep -q "(\bELF\b)|(\bPE\b)|(\bPE32\b)" 42 | if [ $? -eq 0 ]; then 43 | $strip $bin 2>/dev/null || true 44 | fi 45 | 46 | set -e 47 | } 48 | -------------------------------------------------------------------------------- /build_macOS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if [ $# -gt 0 ]; then 5 | while test $# -gt 0 6 | do 7 | case "$1" in 8 | --help) (echo "Supported steps: gcc-deps toolchain-deps toolchain dlfcn binutils gcc headers newlib pthread gcc-final strip"; exit 1) 9 | ;; 10 | gcc-deps) STEP1=true 11 | ;; 12 | toolchain-deps) STEP2=true 13 | ;; 14 | toolchain) STEP3=true 15 | ;; 16 | binutils) STEP4=true 17 | ;; 18 | gcc) STEP5=true 19 | ;; 20 | headers) STEP6=true 21 | ;; 22 | newlib) STEP7=true 23 | ;; 24 | pthread) STEP8=true 25 | ;; 26 | gcc-final) STEP9=true 27 | ;; 28 | strip) STEP10=true 29 | ;; 30 | *) (echo "Unsupported $1"; exit 1) 31 | ;; 32 | esac 33 | shift 34 | done 35 | else 36 | STEP1=true 37 | STEP2=true 38 | STEP3=true 39 | STEP4=true 40 | STEP5=true 41 | STEP6=true 42 | STEP7=true 43 | STEP8=true 44 | STEP9=true 45 | STEP10=true 46 | fi 47 | 48 | . ./build_common.sh 49 | 50 | set -e 51 | set -o pipefail 52 | 53 | mkdir -p ${DOWNLOADDIR} ${SRCDIR} ${BUILDDIR} ${INSTALLDIR} 54 | 55 | if [ ${STEP1} ]; then 56 | echo "[Step 1.1] Build libiconv..." 57 | cd ${DOWNLOADDIR} 58 | if [ ! -f libiconv-${LIBICONV_VERSION}.tar.gz ]; then 59 | curl -L -O http://ftp.gnu.org/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz 60 | fi 61 | tar xzf libiconv-${LIBICONV_VERSION}.tar.gz -C ${SRCDIR} 62 | rm -rf ${BUILDDIR}/libiconv-${LIBICONV_VERSION} 63 | mkdir -p ${BUILDDIR}/libiconv-${LIBICONV_VERSION} 64 | cd ${BUILDDIR}/libiconv-${LIBICONV_VERSION} 65 | ../${SRCRELDIR}/libiconv-${LIBICONV_VERSION}/configure --build=${HOST_NATIVE} --host=${HOST_NATIVE} --prefix=${INSTALLDIR} --disable-shared --disable-nls 66 | make ${JOBS} 67 | make install 68 | 69 | echo "[Step 1.2] Build GMP..." 70 | cd ${DOWNLOADDIR} 71 | if [ ! -f gmp-${GMP_VERSION}.tar.xz ]; then 72 | curl -L -O http://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz 73 | fi 74 | tar xJf gmp-${GMP_VERSION}.tar.xz -C ${SRCDIR} 75 | rm -rf ${BUILDDIR}/gmp-${GMP_VERSION} 76 | mkdir -p ${BUILDDIR}/gmp-${GMP_VERSION} 77 | cd ${BUILDDIR}/gmp-${GMP_VERSION} 78 | ../${SRCRELDIR}/gmp-${GMP_VERSION}/configure --build=${HOST_NATIVE} --host=${HOST_NATIVE} --prefix=${INSTALLDIR} --disable-shared --enable-cxx 79 | make ${JOBS} 80 | make install 81 | 82 | echo "[Step 1.3] Build MPFR..." 83 | cd ${DOWNLOADDIR} 84 | if [ ! -f mpfr-${MPFR_VERSION}.tar.xz ]; then 85 | curl -L -O http://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.xz 86 | fi 87 | tar xJf mpfr-${MPFR_VERSION}.tar.xz -C ${SRCDIR} 88 | rm -rf ${BUILDDIR}/mpfr-${MPFR_VERSION} 89 | mkdir -p ${BUILDDIR}/mpfr-${MPFR_VERSION} 90 | cd ${BUILDDIR}/mpfr-${MPFR_VERSION} 91 | ../${SRCRELDIR}/mpfr-${MPFR_VERSION}/configure --build=${HOST_NATIVE} --host=${HOST_NATIVE} --prefix=${INSTALLDIR} --disable-shared --with-gmp=${INSTALLDIR} 92 | make ${JOBS} 93 | make install 94 | 95 | echo "[Step 1.4] Build MPC..." 96 | cd ${DOWNLOADDIR} 97 | if [ ! -f mpc-${MPC_VERSION}.tar.gz ]; then 98 | curl -L -O http://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz 99 | fi 100 | tar xzf mpc-${MPC_VERSION}.tar.gz -C ${SRCDIR} 101 | rm -rf ${BUILDDIR}/mpc-${MPC_VERSION} 102 | mkdir -p ${BUILDDIR}/mpc-${MPC_VERSION} 103 | cd ${BUILDDIR}/mpc-${MPC_VERSION} 104 | ../${SRCRELDIR}/mpc-${MPC_VERSION}/configure --build=${HOST_NATIVE} --host=${HOST_NATIVE} --prefix=${INSTALLDIR} --disable-shared --with-gmp=${INSTALLDIR} --with-mpfr=${INSTALLDIR} 105 | make ${JOBS} 106 | make install 107 | 108 | echo "[Step 1.5] Build ISL..." 109 | cd ${DOWNLOADDIR} 110 | if [ ! -f isl-${ISL_VERSION}.tar.xz ]; then 111 | curl -L -O http://isl.gforge.inria.fr/isl-${ISL_VERSION}.tar.xz 112 | fi 113 | tar xJf isl-${ISL_VERSION}.tar.xz -C ${SRCDIR} 114 | rm -rf ${BUILDDIR}/isl-${ISL_VERSION} 115 | mkdir -p ${BUILDDIR}/isl-${ISL_VERSION} 116 | cd ${BUILDDIR}/isl-${ISL_VERSION} 117 | ../${SRCRELDIR}/isl-${ISL_VERSION}/configure --build=${HOST_NATIVE} --host=${HOST_NATIVE} --prefix=${INSTALLDIR} --disable-shared --with-gmp-prefix=${INSTALLDIR} 118 | make ${JOBS} 119 | make install 120 | fi 121 | 122 | if [ ${STEP2} ]; then 123 | echo "[Step 2.1] Build zlib..." 124 | cd ${DOWNLOADDIR} 125 | if [ ! -f zlib-${ZLIB_VERSION}.tar.xz ]; then 126 | curl -L -O http://zlib.net/zlib-${ZLIB_VERSION}.tar.xz 127 | fi 128 | tar xJf zlib-${ZLIB_VERSION}.tar.xz -C ${SRCDIR} 129 | cd ${SRCDIR}/zlib-${ZLIB_VERSION} 130 | rm -rf ${BUILDDIR}/zlib-${ZLIB_VERSION} 131 | mkdir -p ${BUILDDIR}/zlib-${ZLIB_VERSION} 132 | BINARY_PATH=${INSTALLDIR}/bin INCLUDE_PATH=${INSTALLDIR}/include LIBRARY_PATH=${INSTALLDIR}/lib 133 | ../${SRCRELDIR}/zlib-${ZLIB_VERSION}/configure --static --prefix=${INSTALLDIR} 134 | make ${JOBS} 135 | make install 136 | echo "[Step 2.2] Build libzip..." 137 | cd ${DOWNLOADDIR} 138 | if [ ! -f libzip-${LIBZIP_VERSION}.tar.xz ]; then 139 | curl -L -O https://nih.at/libzip/libzip-${LIBZIP_VERSION}.tar.xz 140 | fi 141 | tar xJf libzip-${LIBZIP_VERSION}.tar.xz -C ${SRCDIR} 142 | rm -rf ${BUILDDIR}/libzip-${LIBZIP_VERSION} 143 | mkdir -p ${BUILDDIR}/libzip-${LIBZIP_VERSION} 144 | cd ${BUILDDIR}/libzip-${LIBZIP_VERSION} 145 | CFLAGS='-DZIP_STATIC' ${SRCDIR}/libzip-${LIBZIP_VERSION}/configure --host=${HOST_NATIVE} --prefix=$INSTALLDIR --disable-shared --enable-static 146 | make ${JOBS} -C lib install 147 | 148 | echo "[Step 2.3] Build libelf..." 149 | cd ${DOWNLOADDIR} 150 | if [ ! -f libelf-${LIBELF_VERSION}.tar.gz ]; then 151 | curl -L -O http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz 152 | fi 153 | tar xzf libelf-${LIBELF_VERSION}.tar.gz -C ${SRCDIR} 154 | cd ${SRCDIR}/libelf-${LIBELF_VERSION} 155 | patch -p1 < ${PATCHDIR}/libelf.patch 156 | rm -rf ${BUILDDIR}/libelf-${LIBELF_VERSION} 157 | mkdir -p ${BUILDDIR}/libelf-${LIBELF_VERSION} 158 | cd ${BUILDDIR}/libelf-${LIBELF_VERSION} 159 | ../${SRCRELDIR}/libelf-${LIBELF_VERSION}/configure --host=${HOST_NATIVE} --prefix=$INSTALLDIR 160 | make ${JOBS} install 161 | 162 | echo "[Step 2.4] Build jansson..." 163 | cd ${DOWNLOADDIR} 164 | if [ ! -f jansson-${JANSSON_VERSION}.tar.gz ]; then 165 | curl -L -o jansson-${JANSSON_VERSION}.tar.gz https://github.com/akheron/jansson/archive/v${JANSSON_VERSION}.tar.gz 166 | fi 167 | tar xzf jansson-${JANSSON_VERSION}.tar.gz -C ${SRCDIR} 168 | rm -rf ${BUILDDIR}/jansson-${JANSSON_VERSION} 169 | mkdir -p ${BUILDDIR}/jansson-${JANSSON_VERSION} 170 | cd ${BUILDDIR}/jansson-${JANSSON_VERSION} 171 | cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DCMAKE_BUILD_TYPE=Release -DJANSSON_BUILD_DOCS=OFF ${SRCDIR}/jansson-${JANSSON_VERSION} 172 | make ${JOBS} install 173 | fi 174 | 175 | if [ ${STEP3} ]; then 176 | echo "[Step 3] Build vita-toolchain..." 177 | if [ ! -d ${SRCDIR}/vita-toolchain/.git ]; then 178 | rm -rf ${SRCDIR}/vita-toolchain 179 | git clone https://github.com/vitasdk/vita-toolchain ${SRCDIR}/vita-toolchain 180 | else 181 | cd ${SRCDIR}/vita-toolchain 182 | git pull origin master 183 | fi 184 | rm -rf ${BUILDDIR}/vita-toolchain 185 | mkdir -p ${BUILDDIR}/vita-toolchain 186 | cd ${BUILDDIR}/vita-toolchain 187 | cmake -G"Unix Makefiles" -DCMAKE_C_FLAGS_RELEASE:STRING="-O3 -DNDEBUG -DZIP_STATIC" -DCMAKE_BUILD_TYPE=Release -DJansson_INCLUDE_DIR=$INSTALLDIR/include/ -DJansson_LIBRARY=$INSTALLDIR/lib/libjansson.a -Dlibelf_INCLUDE_DIR=$INSTALLDIR/include -Dlibelf_LIBRARY=$INSTALLDIR/lib/libelf.a -Dzlib_INCLUDE_DIR=$INSTALLDIR/include/ -Dzlib_LIBRARY=$INSTALLDIR/lib/libz.a -Dlibzip_INCLUDE_DIR=$INSTALLDIR/include/ -Dlibzip_CONFIG_INCLUDE_DIR=$INSTALLDIR/lib/libzip/include -Dlibzip_LIBRARY=$INSTALLDIR/lib/libzip.a -DCMAKE_INSTALL_PREFIX=${VITASDKROOT} -DDEFAULT_JSON=../share/db.json ${SRCDIR}/vita-toolchain 188 | make ${JOBS} install 189 | fi 190 | 191 | if [ ${STEP4} ]; then 192 | echo "[Step 4] Build binutils..." 193 | cd ${SRCDIR} 194 | if [ ! -d ${SRCDIR}/binutils-${BINUTILS_VERSION}/.git ]; then 195 | git clone git://sourceware.org/git/binutils-gdb.git binutils-${BINUTILS_VERSION} 196 | fi 197 | cd binutils-${BINUTILS_VERSION} 198 | patch -p1 < ${PATCHDIR}/binutils.patch 199 | #patch -p1 < ${PATCHDIR}/binutils-mingw.patch 200 | rm -rf ${BUILDDIR}/binutils-${BINUTILS_VERSION} 201 | mkdir -p ${BUILDDIR}/binutils-${BINUTILS_VERSION} 202 | cd ${BUILDDIR}/binutils-${BINUTILS_VERSION} 203 | ../${SRCRELDIR}/binutils-${BINUTILS_VERSION}/configure --host=${HOST_NATIVE} --build=${HOST_NATIVE} --target=arm-vita-eabi --prefix=${VITASDKROOT} --infodir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/info --mandir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/man --htmldir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/html --pdfdir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/pdf --disable-nls --disable-werror --disable-sim --disable-gdb --enable-interwork --enable-plugins --with-sysroot=${VITASDKROOT}/arm-vita-eabi --with-cloog=${INSTALLDIR} --with-isl=${INSTALLDIR} --disable-isl-version-check "--with-pkgversion=GNU Tools for ARM Embedded Processors [VitaSDK for macOS by bigboss]" 204 | make ${JOBS} 205 | make install 206 | fi 207 | 208 | export VITASDK=${VITASDKROOT} 209 | export OLDPATH=${PATH} 210 | export PATH=${VITASDK}/bin:${PATH} 211 | 212 | if [ ${STEP5} ]; then 213 | echo "[Step 5] Build gcc first time..." 214 | cd ${DOWNLOADDIR} 215 | if [ ! -f gcc-${GCC_VERSION}.tar.bz2 ]; then 216 | curl -L -O http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 217 | fi 218 | tar xjf gcc-${GCC_VERSION}.tar.bz2 -C ${SRCDIR} 219 | cd ${SRCDIR}/gcc-${GCC_VERSION} 220 | patch -p1 < ${PATCHDIR}/gcc.patch 221 | #patch -p1 < ${PATCHDIR}/gcc-mingw.patch 222 | rm -rf ${BUILDDIR}/gcc-${GCC_VERSION} 223 | mkdir -p ${BUILDDIR}/gcc-${GCC_VERSION} 224 | cd ${BUILDDIR}/gcc-${GCC_VERSION} 225 | ../${SRCRELDIR}/gcc-${GCC_VERSION}/configure --host=${HOST_NATIVE} --build=${HOST_NATIVE} --target=arm-vita-eabi --prefix=${VITASDKROOT} --libexecdir=${VITASDKROOT}/lib --infodir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/info --mandir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/man --htmldir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/html --pdfdir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/pdf --enable-languages=c,c++ --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-newlib --without-headers --with-gnu-as --with-gnu-ld --with-python-dir=share/gcc-arm-vita-eabi --with-sysroot=${VITASDKROOT}/arm-vita-eabi --with-libiconv-prefix=${INSTALLDIR} --with-gmp=${INSTALLDIR} --with-mpfr=${INSTALLDIR} --with-mpc=${INSTALLDIR} --with-isl=${INSTALLDIR} --with-cloog=${INSTALLDIR} --disable-isl-version-check --with-libelf=${INSTALLDIR} "--with-host-libstdcxx= -Wl,-lstdc++,-lm" "--with-pkgversion=GNU Tools for ARM Embedded Processors [VitaSDK for macOs by bigboss]" --disable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard --with-mode=thumb CXXFLAGS="-g -O2 -fbracket-depth=2048" CFLAGS_FOR_TARGET="-O2" CXXFLAGS_FOR_TARGET="-O2" 226 | make ${JOBS} all-gcc 227 | make install-gcc 228 | fi 229 | 230 | if [ ${STEP6} ]; then 231 | echo "[Step 6] Build vita-headers..." 232 | if [ ! -d ${SRCDIR}/vita-headers/.git ]; then 233 | rm -rf ${SRCDIR}/vita-headers 234 | git clone https://github.com/vitasdk/vita-headers ${SRCDIR}/vita-headers 235 | else 236 | cd ${SRCDIR}/vita-headers 237 | git pull origin master 238 | fi 239 | rm -rf ${BUILDDIR}/vita-headers 240 | mkdir -p ${BUILDDIR}/vita-headers 241 | cd ${BUILDDIR}/vita-headers 242 | vita-libs-gen ${SRCDIR}/vita-headers/db.json . 243 | make ARCH=${VITASDKROOT}/bin/arm-vita-eabi ${JOBS} 244 | cp *.a ${VITASDKROOT}/arm-vita-eabi/lib/ 245 | cp -r ${SRCDIR}/vita-headers/include ${VITASDKROOT}/arm-vita-eabi/ 246 | mkdir -p ${VITASDKROOT}/share 247 | cp ${SRCDIR}/vita-headers/db.json ${VITASDKROOT}/share 248 | fi 249 | 250 | if [ ${STEP7} ]; then 251 | echo "[Step 7] Build newlib..." 252 | if [ ! -d ${SRCDIR}/newlib/.git ]; then 253 | rm -rf ${SRCDIR}/newlib 254 | git clone https://github.com/vitasdk/newlib ${SRCDIR}/newlib 255 | else 256 | cd ${SRCDIR}/newlib 257 | git pull origin vita 258 | fi 259 | rm -rf ${BUILDDIR}/newlib 260 | mkdir -p ${BUILDDIR}/newlib 261 | cd ${BUILDDIR}/newlib 262 | ../${SRCRELDIR}/newlib/configure --host=${HOST_NATIVE} --build=${HOST_NATIVE} --target=arm-vita-eabi --prefix=${VITASDKROOT} --infodir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/info --mandir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/man --htmldir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/html --pdfdir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/pdf --enable-newlib-io-long-long --enable-newlib-register-fini --disable-newlib-supplied-syscalls --disable-nls 263 | make ${JOBS} 264 | make install 265 | fi 266 | 267 | if [ ${STEP8} ]; then 268 | echo "[Step 8] Build pthread..." 269 | if [ ! -d ${SRCDIR}/pthread-embedded/.git ]; then 270 | rm -rf ${SRCDIR}/pthread-embedded 271 | git clone https://github.com/vitasdk/pthread-embedded ${SRCDIR}/pthread-embedded 272 | else 273 | cd ${SRCDIR}/pthread-embedded 274 | git pull origin master 275 | fi 276 | rm -rf ${BUILDDIR}/pthread-embedded 277 | mkdir -p ${BUILDDIR}/pthread-embedded 278 | cd ${BUILDDIR}/pthread-embedded 279 | cp -R ../${SRCRELDIR}/pthread-embedded/* . 280 | cd platform/vita 281 | make ${JOBS} CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections' 282 | make install 283 | fi 284 | 285 | if [ ${STEP9} ]; then 286 | echo "[Step 9] Build gcc final..." 287 | if [ ! -d ${SRCDIR}/gcc-${GCC_VERSION} ]; then 288 | cd ${DOWNLOADDIR} 289 | if [ ! -f gcc-${GCC_VERSION}.tar.bz2 ]; then 290 | curl -L -O http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 291 | fi 292 | tar xjf gcc-${GCC_VERSION}.tar.bz2 -C ${SRCDIR} 293 | cd ${SRCDIR}/gcc-${GCC_VERSION} 294 | patch -p1 < ${PATCHDIR}/gcc.patch 295 | #patch -p1 < ${PATCHDIR}/gcc-mingw.patch 296 | fi 297 | pushd ${VITASDKROOT}/arm-vita-eabi 298 | mkdir -p ./usr 299 | cp -rf include lib usr/ 300 | popd 301 | rm -rf ${BUILDDIR}/gcc-${GCC_VERSION}-final 302 | mkdir -p ${BUILDDIR}/gcc-${GCC_VERSION}-final 303 | cd ${BUILDDIR}/gcc-${GCC_VERSION}-final 304 | ../${SRCRELDIR}/gcc-${GCC_VERSION}/configure --host=${HOST_NATIVE} --build=${HOST_NATIVE} --target=arm-vita-eabi --prefix=${VITASDKROOT} --libexecdir=${VITASDKROOT}/lib --infodir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/info --mandir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/man --htmldir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/html --pdfdir=${VITASDKROOT}/share/doc/gcc-arm-vita-eabi/pdf --enable-languages=c,c++ --enable-plugins --enable-threads=posix --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-libstdcxx-verbose --disable-nls --disable-shared --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-vita-eabi --with-sysroot=${VITASDKROOT}/arm-vita-eabi --with-libiconv-prefix=${INSTALLDIR} --with-gmp=${INSTALLDIR} --with-mpfr=${INSTALLDIR} --with-mpc=${INSTALLDIR} --with-isl=${INSTALLDIR} --with-cloog=${INSTALLDIR} --disable-isl-version-check --with-libelf=${INSTALLDIR} "--with-host-libstdcxx= -Wl,-lstdc++,-lm" "--with-pkgversion=GNU Tools for ARM Embedded Processors [VitaSDK for macOS by bigboss]" --disable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard --with-mode=thumb CXXFLAGS="-g -O2 -fbracket-depth=2048" CFLAGS_FOR_TARGET="-O2" CXXFLAGS_FOR_TARGET="-O2" 305 | make ${JOBS} INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0" 306 | make install 307 | 308 | pushd ${VITASDKROOT} 309 | rm -rf bin/arm-vita-eabi-gccbug 310 | LIBIBERTY_LIBRARIES=`find ${VITASDKROOT}/arm-vita-eabi/lib -name libiberty.a` 311 | for libiberty_lib in $LIBIBERTY_LIBRARIES ; do 312 | rm -rf $libiberty_lib 313 | done 314 | rm -rf ./lib/libiberty.a 315 | rmdir include 316 | rm -rf ./arm-vita-eabi/usr 317 | popd 318 | fi 319 | 320 | if [ ${STEP10} ]; then 321 | echo "[Step 10] Strip binaries..." 322 | 323 | STRIP_BINARIES=`find ${VITASDKROOT}/bin/ -name arm-vita-eabi-\*` 324 | for bin in $STRIP_BINARIES ; do 325 | strip_binary strip $bin 326 | done 327 | 328 | STRIP_BINARIES=`find ${VITASDKROOT}/arm-vita-eabi/bin/ -maxdepth 1 -mindepth 1 -name \*` 329 | for bin in $STRIP_BINARIES ; do 330 | strip_binary strip $bin 331 | done 332 | 333 | STRIP_BINARIES=`find ${VITASDKROOT}/lib/gcc/arm-vita-eabi/${GCC_VERSION}/ -maxdepth 1 -name \* -perm +111 -and ! -type d` 334 | for bin in $STRIP_BINARIES ; do 335 | strip_binary strip $bin 336 | done 337 | 338 | 339 | find ${VITASDKROOT} -name '*.la' -exec rm '{}' ';' 340 | 341 | for target_lib in `find ${VITASDKROOT}/arm-vita-eabi/lib -name \*.a` ; do 342 | arm-vita-eabi-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc $target_lib || true 343 | done 344 | 345 | for target_obj in `find ${VITASDKROOT}/arm-vita-eabi/lib -name \*.o` ; do 346 | arm-vita-eabi-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc $target_obj || true 347 | done 348 | 349 | for target_lib in `find ${VITASDKROOT}/lib/gcc/arm-vita-eabi/${GCC_VERSION} -name \*.a` ; do 350 | arm-vita-eabi-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc $target_lib || true 351 | done 352 | 353 | for target_obj in `find ${VITASDKROOT}/lib/gcc/arm-vita-eabi/${GCC_VERSION} -name \*.o` ; do 354 | arm-vita-eabi-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc $target_obj || true 355 | done 356 | fi 357 | 358 | export PATH=${OLDPATH} 359 | export -n OLDPATH 360 | echo "[DONE] Everything is OK!" 361 | -------------------------------------------------------------------------------- /patch/binutils.patch: -------------------------------------------------------------------------------- 1 | diff -ur orig.binutils/ld/scripttempl/elf.sc binutils/ld/scripttempl/elf.sc > binutils.patch 2 | --- orig.binutils/ld/scripttempl/elf.sc 2016-09-30 21:06:08.000000000 +0200 3 | +++ binutils/ld/scripttempl/elf.sc 2016-09-30 21:21:06.000000000 +0200 4 | @@ -553,7 +553,8 @@ 5 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} 6 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 7 | ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} 8 | - 9 | + /* Hacky hackity hack. Need this because otherwise data segment is not aligned enough. */ 10 | + . = ALIGN(0x10000); 11 | /* Exception handling */ 12 | .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } 13 | .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } 14 | -------------------------------------------------------------------------------- /patch/gcc.patch: -------------------------------------------------------------------------------- 1 | diff -ur gcc-6.2.0-orig/gcc/config/arm/arm-c.c gcc-6.2.0/gcc/config/arm/arm-c.c 2 | --- gcc-6.2.0-orig/gcc/config/arm/arm-c.c 2016-02-24 16:19:12.000000000 +0800 3 | +++ gcc-6.2.0/gcc/config/arm/arm-c.c 2016-09-05 12:36:27.548356500 +0800 4 | @@ -62,6 +62,8 @@ 5 | static void 6 | arm_cpu_builtins (struct cpp_reader* pfile) 7 | { 8 | + builtin_define ("__vita__"); 9 | + 10 | def_or_undef_macro (pfile, "__ARM_FEATURE_DSP", TARGET_DSP_MULTIPLY); 11 | def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT", TARGET_ARM_QBIT); 12 | def_or_undef_macro (pfile, "__ARM_FEATURE_SAT", TARGET_ARM_SAT); 13 | diff -ur gcc-6.2.0-orig/gcc/gcc.c gcc-6.2.0/gcc/gcc.c 14 | --- gcc-6.2.0-orig/gcc/gcc.c 2016-08-15 19:19:34.000000000 +0800 15 | +++ gcc-6.2.0/gcc/gcc.c 2016-09-05 12:33:17.920479300 +0800 16 | @@ -658,8 +658,9 @@ 17 | #endif 18 | 19 | /* config.h can define LIB_SPEC to override the default libraries. */ 20 | +#undef LIB_SPEC 21 | #ifndef LIB_SPEC 22 | -#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}" 23 | +#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} -lSceRtc_stub -lSceKernel_stub -lSceNet_stub" 24 | #endif 25 | 26 | /* When using -fsplit-stack we need to wrap pthread_create, in order -------------------------------------------------------------------------------- /patch/libelf.patch: -------------------------------------------------------------------------------- 1 | diff -ru libelf-0.8.13-orig/configure libelf-0.8.13/configure 2 | --- libelf-0.8.13-orig/configure 2015-08-19 18:51:37.000000000 +0400 3 | +++ libelf-0.8.13/configure 2015-09-22 20:37:30.000000000 +0400 4 | @@ -1595,7 +1595,7 @@ 5 | echo $ac_n "(cached) $ac_c" 1>&6 6 | else 7 | if test "$cross_compiling" = yes; then 8 | - ac_cv_sizeof_long_long=0 9 | + ac_cv_sizeof_long_long=8 10 | else 11 | cat > conftest.$ac_ext <