├── .github └── workflows │ ├── compilation.yml │ └── docker.yml ├── .gitignore ├── Dockerfile ├── README.md ├── depends └── check-pspdev.sh ├── prepare.sh ├── scripts ├── 001-allegrex.sh └── 002-extra.sh └── toolchain.sh /.github/workflows/compilation.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | repository_dispatch: 7 | types: [run_build] 8 | 9 | jobs: 10 | build-docker: 11 | runs-on: ubuntu-latest 12 | container: ${{ matrix.os[0] }}:${{ matrix.os[1] }} 13 | strategy: 14 | matrix: 15 | os: [ 16 | [alpine, latest], 17 | [fedora, latest], 18 | ] 19 | fail-fast: false 20 | steps: 21 | - name: Install dependencies Alpine 22 | if: matrix.os[0] == 'alpine' 23 | run: | 24 | apk add --no-cache build-base bash gcc git make autoconf automake python3 py3-pip cmake pkgconfig libarchive-dev openssl-dev gpgme-dev \ 25 | libtool flex bison texinfo gmp-dev mpfr-dev mpc1-dev readline-dev ncurses-dev gawk 26 | 27 | - name: Install dependencies Fedora 28 | if: matrix.os[0] == 'fedora' 29 | run: | 30 | dnf -y install @development-tools gcc gcc-c++ g++ wget git autoconf automake python3 python3-pip make cmake pkgconf \ 31 | libarchive-devel openssl-devel gpgme-devel libtool gettext texinfo bison flex gmp-devel mpfr-devel libmpc-devel ncurses-devel \ 32 | diffutils glibc-gconv-extra xz gawk file 33 | 34 | - uses: actions/checkout@v4 35 | 36 | - name: Compile Tools 37 | run: | 38 | chown -R $(id -nu):$(id -ng) . 39 | export PSPDEV=$PWD/pspdev 40 | export PATH=$PATH:$PSPDEV/bin 41 | ./toolchain.sh 42 | 43 | - name: Get short SHA 44 | id: slug 45 | run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT 46 | 47 | - name: Compress pspdev folder 48 | run: | 49 | tar -zcvf pspdev.tar.gz pspdev 50 | 51 | - uses: actions/upload-artifact@v4 52 | with: 53 | name: pspdev-${{ steps.slug.outputs.sha8 }}-${{ matrix.os[0] }} 54 | path: pspdev.tar.gz 55 | 56 | 57 | build-VM: 58 | runs-on: ${{ matrix.os[0] }} 59 | strategy: 60 | matrix: 61 | os: [ 62 | [macos-latest, arm64, bash], 63 | [macos-13, x86_64, bash], 64 | [ubuntu-latest, x86_64, bash], 65 | ] 66 | fail-fast: false 67 | defaults: 68 | run: 69 | shell: ${{ matrix.os[2] }} {0} 70 | 71 | steps: 72 | - uses: actions/checkout@v4 73 | 74 | - name : Install dependencies on required OS 75 | run: | 76 | ./prepare.sh 77 | 78 | - name: Compile Tools 79 | run: | 80 | export PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH" # This really is only needed for macOS 81 | export PATH="$(brew --prefix libtool)/libexec/gnubin:$PATH" # This really is only needed for macOS 82 | export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:$(brew --prefix openssl)/lib/pkgconfig" #This really is only needed for macOS 83 | export PSPDEV=$PWD/pspdev 84 | export PATH=$PATH:$PSPDEV/bin 85 | ./toolchain.sh 86 | 87 | - name: Get short SHA 88 | id: slug 89 | run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT 90 | 91 | - name: Compress pspdev folder 92 | run: | 93 | tar -zcvf pspdev.tar.gz pspdev 94 | 95 | - uses: actions/upload-artifact@v4 96 | with: 97 | name: pspdev-${{ steps.slug.outputs.sha8 }}-${{ matrix.os[0] }}-${{ matrix.os[1] }} 98 | path: pspdev.tar.gz 99 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: CI-Docker 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | repository_dispatch: 8 | types: [run_build] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | 17 | - name: Login to Github registry 18 | uses: docker/login-action@v3 19 | with: 20 | username: ${{ github.actor }} 21 | password: ${{ secrets.GITHUB_TOKEN }} 22 | registry: ghcr.io 23 | 24 | - uses: docker/build-push-action@v5 25 | with: 26 | context: . 27 | push: true 28 | tags: ghcr.io/${{ github.repository }}:latest 29 | build-args: | 30 | BASE_DOCKER_ALLEGREX_IMAGE=ghcr.io/${{ github.repository_owner }}/psptoolchain-allegrex:latest 31 | BASE_DOCKER_EXTRA_IMAGE=ghcr.io/${{ github.repository_owner }}/psptoolchain-extra:latest 32 | 33 | - name: Send Compile action 34 | run: | 35 | export DISPATCH_ACTION="$(echo run_build)" 36 | echo "NEW_DISPATCH_ACTION=$DISPATCH_ACTION" >> $GITHUB_ENV 37 | 38 | - name: Repository Dispatch 39 | uses: peter-evans/repository-dispatch@v3 40 | with: 41 | repository: ${{ github.repository_owner }}/pspsdk 42 | token: ${{ secrets.DISPATCH_TOKEN }} 43 | event-type: ${{ env.NEW_DISPATCH_ACTION }} 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /pspdev/ 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # ARGS for defining tags 2 | ARG BASE_DOCKER_ALLEGREX_IMAGE 3 | ARG BASE_DOCKER_EXTRA_IMAGE 4 | 5 | # Allegrex stage of Dockerfile 6 | FROM $BASE_DOCKER_ALLEGREX_IMAGE 7 | 8 | RUN mv ${PSPDEV}/build.txt ${PSPDEV}/build0.txt 9 | 10 | # Extra stage of Dockerfile 11 | FROM $BASE_DOCKER_EXTRA_IMAGE 12 | 13 | RUN mv ${PSPDEV}/build.txt ${PSPDEV}/build1.txt 14 | 15 | # Second stage of Dockerfile 16 | FROM alpine:latest 17 | 18 | ENV PSPDEV /usr/local/pspdev 19 | 20 | COPY --from=0 ${PSPDEV} ${PSPDEV} 21 | COPY --from=1 ${PSPDEV} ${PSPDEV} 22 | COPY . . 23 | 24 | RUN cat ${PSPDEV}/build0.txt ${PSPDEV}/build1.txt > ${PSPDEV}/build.txt && \ 25 | rm ${PSPDEV}/build0.txt ${PSPDEV}/build1.txt && \ 26 | apk add --no-cache git && \ 27 | git log -1 --format="psptoolchain %H %cs %s" >> ${PSPDEV}/build.txt 28 | 29 | # Last stage with everything combined 30 | FROM alpine:latest 31 | 32 | ENV PSPDEV /usr/local/pspdev 33 | ENV PATH $PATH:${PSPDEV}/bin 34 | 35 | COPY --from=2 ${PSPDEV} ${PSPDEV} 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # psptoolchain 2 | 3 | [![CI](https://img.shields.io/github/actions/workflow/status/pspdev/psptoolchain/.github/workflows/compilation.yml?branch=master&style=for-the-badge&logo=github&label=CI)](https://github.com/pspdev/psptoolchain/actions?query=workflow:CI) 4 | [![CI-Docker](https://img.shields.io/github/actions/workflow/status/pspdev/psptoolchain/.github/workflows/docker.yml?branch=master&style=for-the-badge&logo=github&label=CI-Docker)](https://github.com/pspdev/psptoolchain/actions?query=workflow:CI-Docker) 5 | 6 | This program will automatically build and install the whole compiler and other tools used in the creation of homebrew software for the Sony PlayStation Portable® videogame system. 7 | 8 | ## **ATENTION!** 9 | 10 | If you're trying to install in your machine the **WHOLE PSP Development Environment** this is **NOT** the repo to use, you should use instead the [pspdev](https://github.com/pspdev/pspdev "pspdev") repo. 11 | 12 | ## What these scripts do 13 | 14 | These scripts download (`git clone`) and install: 15 | 16 | - [psptoolchain-allegrex](https://github.com/pspdev/psptoolchain-allegrex "psptoolchain-allegrex") 17 | - [psptoolchain-extra](https://github.com/pspdev/psptoolchain-extra "psptoolchain-extra") 18 | 19 | ## Requirements 20 | 21 | 1. Install gcc/clang, make, cmake, patch, git, texinfo, flex, bison, gettext, wget, gsl, gmp, mpfr, mpc, readline, libarchive, gpgme, bash, openssl and libtool if you don't have those. 22 | We offer a script to help you for installing dependencies: 23 | 24 | ### Ubuntu/Debian, Fedora, OSX 25 | ```bash 26 | sudo ./prepare.sh 27 | ``` 28 | [MacPorts]: http://www.macports.org/ 29 | [HomeBrew]: http://brew.sh/ 30 | 31 | 2. Ensure that you have enough permissions for managing PSPDEV location (default to `/usr/local/pspdev`, but you can use a different path). PSPDEV location MUST NOT have spaces or special characters in its path! PSPDEV should be an absolute path. On Unix systems, if the command `mkdir -p $PSPDEV` fails for you, you can set access for the current user by running commands: 32 | ```bash 33 | export PSPDEV=/usr/local/pspdev 34 | sudo mkdir -p $PSPDEV 35 | sudo chown -R $USER: $PSPDEV 36 | ``` 37 | 38 | 3. Add this to your login script (example: `~/.bash_profile`) 39 | **Note:** Ensure that you have full access to the PSPDEV path. You can change the PSPDEV path with the following requirements: only use absolute paths, don't use spaces, only use Latin characters. 40 | ```bash 41 | export PSPDEV=/usr/local/pspdev 42 | export PATH=$PATH:$PSPDEV/bin 43 | ``` 44 | 45 | 4. Run toolchain.sh 46 | ```bash 47 | ./toolchain.sh 48 | ``` 49 | 50 | ## Thanks 51 | 52 | Visit the following sites to learn more: 53 | 54 | [PSP-DEV Wiki](https://pspdev.github.io/) 55 | 56 | [PSP Homebrew Community Discord](https://discord.gg/bePrj9W) 57 | -------------------------------------------------------------------------------- /depends/check-pspdev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # check-pspdev.sh by Naomi Peori (naomi@peori.ca) 3 | 4 | ## Check if $PSPDEV is set. 5 | if test ! $PSPDEV; then { echo "ERROR: Set \$PSPDEV before continuing."; exit 1; } fi 6 | 7 | ## Check for the $PSPDEV directory. 8 | ls -ld $PSPDEV > /dev/null 2>&1 || mkdir -p $PSPDEV > /dev/null 2>&1 || { echo "ERROR: Create $PSPDEV before continuing."; exit 1; } 9 | 10 | ## Check for write permission. 11 | touch $PSPDEV/test.tmp > /dev/null 2>&1 || { echo "ERROR: Grant write permissions for $PSPDEV before continuing."; exit 1; } 12 | rm $PSPDEV/test.tmp 13 | 14 | ## Check for $PSPDEV/bin in the path. 15 | echo $PATH | grep $PSPDEV/bin > /dev/null 2>&1 || { echo "ERROR: Add $PSPDEV/bin to your path before continuing."; exit 1; } 16 | 17 | -------------------------------------------------------------------------------- /prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Detecting OS and installing packages required for PSP Toolchain" 4 | 5 | #Handle macOS first 6 | if [ "$(uname -s)" = "Darwin" ]; then 7 | ## Check if using brew 8 | if command -v brew &> /dev/null; then 9 | brew update 10 | brew install gettext texinfo bison flex gnu-sed ncurses gsl gmp mpfr autoconf automake cmake libusb-compat libarchive gpgme bash openssl libtool 11 | brew reinstall openssl # https://github.com/Homebrew/homebrew-core/issues/169728#issuecomment-2074958306 12 | fi 13 | ## Check if using MacPorts 14 | if command -v port &> /dev/null; then 15 | sudo port install autoconf automake cmake doxygen gsed libelf libtool pkgconfig 16 | fi 17 | else 18 | 19 | TESTOS=$(cat /etc/os-release | grep -w "ID" | cut -d '=' -f2) 20 | 21 | case $TESTOS in 22 | 23 | ubuntu | debian) 24 | sudo apt-get update 25 | sudo apt-get -y install texinfo bison flex gettext libgmp3-dev libmpfr-dev libmpc-dev libusb-dev libreadline-dev libcurl4 libcurl4-openssl-dev libssl-dev libarchive-dev libgpgme-dev \ 26 | libz-dev 27 | ;; 28 | rhel | fedora) 29 | dnf -y install @development-tools gcc gcc-c++ g++ wget git autoconf automake python3 python3-pip make cmake pkgconf \ 30 | libarchive-devel openssl-devel gpgme-devel libtool gettext texinfo bison flex gmp-devel mpfr-devel libmpc-devel ncurses-devel diffutils \ 31 | libusb-compat-0.1-devel readline-devel libcurl-devel which glibc-gconv-extra xz gawk file 32 | ;; 33 | gentoo) 34 | sudo emerge --noreplace net-misc/wget dev-vcs/git dev-python/pip sys-apps/fakeroot \ 35 | app-arch/libarchive app-crypt/gpgme sys-devel/bison sys-devel/flex\ 36 | dev-libs/mpc dev-libs/libusb-compat 37 | ;; 38 | arch) 39 | sudo pacman -Sy gcc clang make cmake patch git texinfo flex bison gettext wget gsl gmp mpfr libmpc libusb readline libarchive gpgme bash openssl libtool libusb-compat boost python-pip 40 | ;; 41 | *) 42 | echo "$TESTOS not supported here" 43 | ;; 44 | esac 45 | 46 | fi 47 | -------------------------------------------------------------------------------- /scripts/001-allegrex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # allegrex.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) 3 | 4 | ## Download the source code. 5 | REPO_URL="https://github.com/pspdev/psptoolchain-allegrex" 6 | REPO_FOLDER="psptoolchain-allegrex" 7 | 8 | # Checking if a specific TAG has been selected, it is passed using parameter $1 9 | [ -z "$1" ] && REPO_REFERENCE="main" || REPO_REFERENCE=$1 10 | echo "Using repo reference $REPO_REFERENCE" 11 | 12 | if test ! -d "$REPO_FOLDER"; then 13 | git clone $REPO_URL -b "${REPO_REFERENCE}" || exit 1 14 | fi 15 | cd "$REPO_FOLDER" && git fetch origin && git reset --hard "origin/${REPO_REFERENCE}" && git checkout "${REPO_REFERENCE}" || exit 1 16 | 17 | ## Build and install. 18 | ./toolchain.sh || { exit 1; } 19 | -------------------------------------------------------------------------------- /scripts/002-extra.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # extra.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) 3 | 4 | ## Download the source code. 5 | REPO_URL="https://github.com/pspdev/psptoolchain-extra" 6 | REPO_FOLDER="psptoolchain-extra" 7 | 8 | # Checking if a specific TAG has been selected, it is passed using parameter $1 9 | [ -z "$1" ] && REPO_REFERENCE="main" || REPO_REFERENCE=$1 10 | echo "Using repo reference $REPO_REFERENCE" 11 | 12 | if test ! -d "$REPO_FOLDER"; then 13 | git clone $REPO_URL -b "${REPO_REFERENCE}" || exit 1 14 | fi 15 | cd "$REPO_FOLDER" && git fetch origin && git reset --hard "origin/${REPO_REFERENCE}" && git checkout "${REPO_REFERENCE}" || exit 1 16 | 17 | ## Build and install. 18 | ./build-all.sh || { exit 1; } -------------------------------------------------------------------------------- /toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # toolchain.sh by fjtrujy 3 | 4 | ## Enter the pspdev directory. 5 | cd "$(dirname "$0")" || { echo "ERROR: Could not enter the pspdev directory."; exit 1; } 6 | 7 | ## Create the build directory. 8 | mkdir -p build || { echo "ERROR: Could not create the build directory."; exit 1; } 9 | 10 | ## Enter the build directory. 11 | cd build || { echo "ERROR: Could not enter the build directory."; exit 1; } 12 | 13 | ## Fetch the depend scripts. 14 | DEPEND_SCRIPTS=($(ls ../depends/*.sh | sort)) 15 | 16 | ## Run all the depend scripts. 17 | for SCRIPT in ${DEPEND_SCRIPTS[@]}; do "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } done 18 | 19 | ## Check if repo is in a tag, to install this specfic PSP Dev environment 20 | if git describe --exact-match --tags $(git log -n1 --pretty='%h') >/dev/null 2>&1; then 21 | TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h')) 22 | if [ "$TAG" = "latest" ]; then 23 | ## Ignore latest tag, as this tag is for service purposes only 24 | echo "Installing latest environment status" 25 | TAG=""; 26 | else 27 | echo "Instaling specific version $TAG"; 28 | fi 29 | else 30 | echo "Installing latest environment status" 31 | TAG="" 32 | fi 33 | 34 | ## Fetch the build scripts. 35 | BUILD_SCRIPTS=($(ls ../scripts/*.sh | sort)) 36 | 37 | ## If specific steps were requested... 38 | if [ "$1" ]; then 39 | 40 | ## Run the requested build scripts. 41 | for STEP in "$@"; do "${BUILD_SCRIPTS[$STEP-1]}" "$TAG" || { echo "${BUILD_SCRIPTS[$STEP-1]}: Failed."; exit 1; } done 42 | 43 | else 44 | 45 | ## Run the all build scripts. 46 | for SCRIPT in ${BUILD_SCRIPTS[@]}; do "$SCRIPT" "$TAG" || { echo "$SCRIPT: Failed."; exit 1; } done 47 | 48 | fi 49 | 50 | ## Store build information 51 | BUILD_FILE="${PSPDEV}/build.txt" 52 | if [[ -f "${BUILD_FILE}" ]]; then 53 | sed -i'' '/^psptoolchain /d' "${BUILD_FILE}" 54 | fi 55 | git log -1 --format="psptoolchain %H %cs %s" >> "${BUILD_FILE}" 56 | --------------------------------------------------------------------------------