├── LICENSE ├── README.md ├── README_MULTI_ARCH.md ├── gcc-base └── Dockerfile ├── gcc-toolchain └── Dockerfile └── kos-toolchain └── Dockerfile /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Ben Baron 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Optimized Dreamcast homebrew development Docker images 2 | 3 | ## Overview 4 | This repository contains a set of 3 Dockerfiles that can be used to build a fully self-contianed and optimized Dreamcast development environment to cross-compile Dreamcast homebrew games and applications based on either the [KallistiOS aka KOS](https://github.com/KallistiOS/KallistiOS) framework or "bare metal" if required. 5 | 6 | All images are based on Alpine linux and they are split into 3 images for size and build time optimization: `gcc-base`, `gcc-toolchain`, and `kos-toolchain`. 7 | 8 | If you only need the SH4 and ARM cross-compilers to use for "bare metal" programming or as a base for your own KOS images, then the only image you need is `einsteinx2/dcdev-gcc-toolchain`. 9 | 10 | If you just want a complete ready to go KOS environment, the only image you need is `einsteinx2/dcdev-kos-toolchain`, though to build that image, the other two are required. 11 | 12 | ## Quick Start 13 | 14 | ### Example GCC 9 Usage (run from your project directory): 15 | **Simple Makefile:** `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-9 make`
16 | **Build Script:** `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-9 ./dc_build.sh`
17 | **Interactive Shell:** `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-9` 18 | 19 | ### Example GCC 4 Usage (run from your project directory): 20 | **Simple Makefile:** `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-4 make`
21 | **Build Script:** `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-4 ./dc_build.sh`
22 | **Interactive Shell:** `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-4` 23 | 24 | These will mount the current folder to `/src` in the container and run whatever command is passed inside a bash shell with all KOS environment variables already set. When passing no command, an interactive bash shell with all KOS variables set is provided if preferred. 25 | 26 | You may execute other commands, of course. There are various utilities included in the image in the `/opt/toolchains/dc/bin` directory that is in the `$PATH` that can do various things like create a IP.BIN file, scramble/unscramble, convert audio and video files to the Dreamcast's format, etc. These commands can be run by simply appending the command to the end of the `docker run` command of the image you want to use. 27 | 28 | Note: These image probably will not compile Dreamshell as that requires a specially patched KOS install. Eventually I'll create images based on these that include the Dreamshell patches. 29 | 30 | ## Images Overview 31 | 32 | All images are optimized using multi-stage builds to keep the final image size and number of layers to a minimum, and only include the minimum set of required tools to have a fully functional development environment. 33 | 34 | ### einsteinx2/dcdev-gcc-base 35 | A stock Alpine Linux image that contains a regular x86_64 GCC compiler toolchain and all necessary tools like make, sed, git, etc that are required to compile the SH4 and ARM cross-compilers as well as the KOS framework. 36 | 37 | ### einsteinx2/dcdev-gcc-toolchain 38 | A stock Alpine Linux image that contains only the SH4 and ARM cross-compiler binaries based on various versions of GCC depending on the image tag, including the SH4 GDB debugger binary, but nothing else. It can be used to directly compile SH4 and ARM code for the Dreamcast that is not based on the KOS framework, such as projects coding "bare metal" using something like [DreamHAL](https://github.com/sega-dreamcast/dreamhal). 39 | 40 | ### einsteinx2/dcdev-kos-toolchain 41 | A stock Alpine Linux image that contains the SH4 and ARM cross-compiler binaries based on various versions of GCC depending on the image tag, the full KOS framework binaries and source code, all KOS-PORTS libraries for things like mp3, ogg, opus, png, jpeg, and SDL 1.2 support, all KOS included utilities and addons, and some external utilities. 42 | 43 | These utiltiies include things like `bin2c` and `bin2o` to include binary files in your code as C headers or linkable objects; and `genromfs` to generate KOS romdisks; `scramble`, `makeip`, and `cdi4dc` to create `CDI` disc images from your homebrew software. All of these utilities are located in the `$PATH` so can be used by simply appending the command to the `docker run` command. 44 | 45 | Also preinstalled are various `apk` packages that are useful for development such as `cdrecord`, `cmake`, `colordiff`, `curl`, `dos2unix`, `gawk`, `git`, `make`, `mkisofs`, `perl`, `python2.7`, `sed`, `svn`, `tree`, `unix2dos`, `wget`, `vim`, etc. 46 | 47 | However, it does not include the standard x86_64 GCC tools as they are not required for Dreamcast homebrew compilation and only increase the image size. 48 | 49 | ## Build Instructions 50 | 51 | ### einsteinx2/dcdev-gcc-base 52 | `docker build -f gcc-base/Dockerfile -t einsteinx2/dcdev-gcc-base:latest .` 53 | 54 | ### einsteinx2/dcdev-gcc-toolchain 55 | **GCC 9:** `docker build -f gcc-toolchain/Dockerfile -t einsteinx2/dcdev-gcc-toolchain:gcc-9 .`
56 | **GCC 4:** `docker build --build-arg KOS_GCC_VER=4 -f gcc-toolchain/Dockerfile -t einsteinx2/dcdev-gcc-toolchain:gcc-4 .` 57 | 58 | ### einsteinx2/dcdev-kos-toolchain 59 | **GCC 9:** `docker build -f kos-toolchain/Dockerfile -t einsteinx2/dcdev-kos-toolchain:gcc-9 .`
60 | **GCC 4:** `docker build --build-arg KOS_GCC_VER=4 -f kos-toolchain/Dockerfile -t einsteinx2/dcdev-kos-toolchain:gcc-4 .` 61 | 62 | ### Additional Build Arguments (only for `gcc-toolchain` and `kos-toolchain`) 63 | There are also a variety of other build arguments you can use when building these images. To see the full details, refer to the comments at the top of each Dockerfile, but here are some of the most useful ones. 64 | 65 | #### ARG VERBOSE=false 66 | Defaults to verbose output off as it should build faster without all of the console printing and is easier to follow the build progress.
67 | To debug build problems, add the flag `--build-arg VERBOSE=true` when building the image to have it print all output from each download and compilation step. 68 | 69 | ### ARG THREADS=0 70 | For maximum speed, set this to the number of CPU threads you have.
71 | When THREADS=0, `$(getconf _NPROCESSORS_ONLN)` will be used to automatically build using the max available threads 72 | i.e. if you have a 4 core / 8 thread CPU, choose 8 (can be set using `--build-arg THREADS=8` when building) 73 | 74 | ### ARG KOS_GCC_VER=9 75 | Choose GCC major version. Supported values are 9 (SH4 9.3/ARM 8.4), 4 (both 4.7.4).
76 | Can be set using `--build-arg KOS_GCC_VER=4` when building, default is 9. 77 | 78 | ### ARG KOS\_REPO, KOS\_BRANCH, PORTS\_REPO, PORTS\_BRANCH 79 | These allow you to specify a git repository URL and branch to use for KOS and/or KOS-PORTS if you do not want to use the current master branch from the upstream KOS repositories, for example if you'd like to build your own fork or work-in-progress branch. 80 | 81 | ## Author 82 | 83 | These images are developed and maintained by [Ben Baron aka einsteinx2](https://github.com/einsteinx2) based on the cross-compiler build scripts and framework from KallistiOS by [Cryptic Allusion (Dan Potter and Lawrence Sebald aka BlueCrab)](http://gamedev.allusion.net/softprj/kos). 84 | -------------------------------------------------------------------------------- /README_MULTI_ARCH.md: -------------------------------------------------------------------------------- 1 | # Multi-arch building 2 | 3 | These are my personal notes on how to build and push these images to Docker Hub with multi-architecture support using Docker's new Buildx system. This assumes Buildx is already installed, as it is by default on macOS. It can also be installed easily on Linux. 4 | 5 | Currently, I'm only building for 2 platforms: x86_64 (`linux/amd64` in Docker) for all modern Intel and AMD machines, and 64bit armv8 aka aarch64 (`linux/arm64` in Docker) for Apple Silicon Macs, Raspberry Pi 3 and 4 (if they're running a 64bit OS), and other modern 64bit ARM single board computers. 6 | 7 | It is trivial to add support for additional platforms like 32bit x86/armv7, for example, by adding `linux/386` and/or `linux/arm/v7` to the `--platform` argument of each buildx command. However, there is significantly increased build time for each emulated platform, so I'm only building for the two most recent and popular ones. 8 | 9 | **NOTE: All commands below are run from the root directory of this repo.** 10 | 11 | 12 | ## Custom Builder 13 | 14 | NOTE: The default builder has a very conservative log limit of only 1MB, which is very quickly reached while compiling GCC. In order to be able to see all of the log output, it's necessary to create a custom builder with larger limits. This is not required if building with verbose mode off (`--build-arg VERBOSE=false`, which is the default), but is invaluable for debugging image build issues. 15 | 16 | 1. Create a new builder with 1GB log limits instead of default 1MB (if not already created) 17 | `docker buildx create --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=1073741824 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=1073741824 --name dcdev --platform linux/amd64,linux/arm64` 18 | 19 | 2. Confirm the builder was created and start it 20 | `docker buildx inspect dcdev --bootstrap` 21 | 22 | ## gcc-base (rarely needs update) 23 | 24 | 1. Set the image version number 25 | `export DCDEV_GCC_BASE_VERSION=2.0.0` 26 | 27 | 2. Build and push the gcc base image (if it needs updating) 28 | `docker buildx build --builder dcdev --platform linux/amd64,linux/arm64 --push -t einsteinx2/dcdev-gcc-base:v$DCDEV_GCC_BASE_VERSION ./gcc-base` 29 | 30 | 3. Test the images 31 | 32 | 4. Update "latest" tag 33 | `docker buildx imagetools create --tag einsteinx2/dcdev-gcc-base:latest einsteinx2/dcdev-gcc-base:v$DCDEV_GCC_BASE_VERSION` 34 | 35 | ## gcc-toolchain (rarely needs update) 36 | 37 | 1. Set the image version number 38 | `export DCDEV_GCC_TOOLCHAIN_VERSION=2.0.0` 39 | 40 | 2. Build and push the GCC toolchain image (if it needs updating) 41 | `docker buildx build --builder dcdev --platform linux/amd64,linux/arm64 --build-arg KOS_GCC_VER=4 --build-arg THREADS=8 --build-arg VERBOSE=true --push -t einsteinx2/dcdev-gcc-toolchain:gcc-4__v$DCDEV_GCC_TOOLCHAIN_VERSION ./gcc-toolchain` 42 | `docker buildx build --builder dcdev --platform linux/amd64,linux/arm64 --build-arg KOS_GCC_VER=9 --build-arg THREADS=8 --build-arg VERBOSE=true --push -t einsteinx2/dcdev-gcc-toolchain:gcc-9__v$DCDEV_GCC_TOOLCHAIN_VERSION ./gcc-toolchain` 43 | 44 | 3. Test the images 45 | 46 | 4. Update the GCC major version tags and latest tag (latest points to GCC 9 version) 47 | `docker buildx imagetools create --tag einsteinx2/dcdev-gcc-toolchain:gcc-4 einsteinx2/dcdev-gcc-toolchain:gcc-4__v$DCDEV_GCC_TOOLCHAIN_VERSION` 48 | `docker buildx imagetools create --tag einsteinx2/dcdev-gcc-toolchain:gcc-9 einsteinx2/dcdev-gcc-toolchain:gcc-9__v$DCDEV_GCC_TOOLCHAIN_VERSION` 49 | `docker buildx imagetools create --tag einsteinx2/dcdev-gcc-toolchain:latest einsteinx2/dcdev-gcc-toolchain:gcc-9__v$DCDEV_GCC_TOOLCHAIN_VERSION` 50 | 51 | 52 | ## kos-toolchain (should be frequently updated to latest KOS) 53 | 54 | 1. Set the image version number 55 | `export DCDEV_KOS_TOOLCHAIN_VERSION=2.0.0` 56 | 57 | 2. Build and push the KOS toolchain image 58 | `docker buildx build --builder dcdev --platform linux/amd64,linux/arm64 --build-arg KOS_GCC_VER=4 --build-arg THREADS=8 --build-arg VERBOSE=true --push -t einsteinx2/dcdev-kos-toolchain:kos-4__v$DCDEV_KOS_TOOLCHAIN_VERSION ./kos-toolchain` 59 | `docker buildx build --builder dcdev --platform linux/amd64,linux/arm64 --build-arg KOS_GCC_VER=9 --build-arg THREADS=8 --build-arg VERBOSE=true --push -t einsteinx2/dcdev-kos-toolchain:kos-9__v$DCDEV_KOS_TOOLCHAIN_VERSION ./kos-toolchain` 60 | 61 | 3. Test the images 62 | 63 | 4. Update the GCC major version tags and latest tag (latest points to GCC 9 version) 64 | `docker buildx imagetools create --tag einsteinx2/dcdev-kos-toolchain:gcc-4 einsteinx2/dcdev-kos-toolchain:gcc-4__v$DCDEV_KOS_TOOLCHAIN_VERSION ` 65 | `docker buildx imagetools create --tag einsteinx2/dcdev-kos-toolchain:gcc-9 einsteinx2/dcdev-kos-toolchain:gcc-9__v$DCDEV_KOS_TOOLCHAIN_VERSION ` 66 | `docker buildx imagetools create --tag einsteinx2/dcdev-kos-toolchain:latest einsteinx2/dcdev-kos-toolchain:gcc-9__v$DCDEV_KOS_TOOLCHAIN_VERSION ` -------------------------------------------------------------------------------- /gcc-base/Dockerfile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------- 2 | # GCC Base Image (einsteinx2/dcdev-gcc-base) 3 | # ------------------------------------------------- 4 | # 5 | # This image is meant to be a minimally sized image to be used as a base image to create the GCC cross-compiler 6 | # toolchain image that will be used to build the final fully functional KOS toolchain images to prevent the need to 7 | # download all of the dependencies each time when rebuilding images locally (or CI if image caching is available). 8 | # When cached locally, this saves hundreds of megabytes of package downloads plus install time. 9 | # 10 | # Build Command: 11 | # -------------- 12 | # `docker build -t einsteinx2/dcdev-gcc-base:latest .` 13 | 14 | 15 | FROM alpine:latest 16 | LABEL maintainer "Ben Baron " 17 | 18 | # Download all necessary dependencies needed to build the KOS GCC cross-compiler toolchain 19 | RUN \ 20 | # Install dependencies 21 | printf "Installing dependencies...\n" \ 22 | && apk --update add --no-cache bash build-base cmake coreutils curl git libjpeg-turbo-dev libpng-dev linux-headers musl-dev patch python2 subversion texinfo tree wget \ 23 | && apk --update add --no-cache libelf-dev --repository=http://dl-cdn.alpinelinux.org/alpine/v3.9/main \ 24 | && rm -rf /var/cache/apk/* \ 25 | && printf "Done.\n" \ 26 | \ 27 | # Prepare .bashrc 28 | && printf ". /etc/profile\n" > ~/.bashrc \ 29 | \ 30 | # Create verbose output toggle script used in child images (file can be appended to by child images to store more environment variables) 31 | && printf 'if $VERBOSE; then\n export REDIRECT="/dev/stdout";\n export NL="\\n";\nelse\n export REDIRECT="/dev/null";\n export NL="";\nfi\n' > /tmp/dockerenv.sh \ 32 | && chmod a+x /tmp/dockerenv.sh 33 | 34 | # Default to /src directory 35 | WORKDIR /src 36 | 37 | # Run any command passed in a bash shell 38 | ENTRYPOINT ["/bin/bash", "-c"] 39 | 40 | # If no command is passed, run an interactive bash shell 41 | CMD ["/bin/bash"] 42 | -------------------------------------------------------------------------------- /gcc-toolchain/Dockerfile: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # KOS GCC Toolchain Image (einsteinx2/dcdev-gcc-toolchain) 3 | # -------------------------------------------------------- 4 | # 5 | # This image is meant to be a minimally sized image to be used as a base image to create the final fully functional 6 | # KOS toolchain images as KOS changes much more often than the GCC cross-compiler toolchain and takes much less time to compile. 7 | # 8 | # Build Commands: 9 | # --------------- 10 | # GCC 9 Toolchain: `docker build -t einsteinx2/dcdev-gcc-toolchain:gcc-9 .` 11 | # GCC 4 Toolchain: `docker build --build-arg KOS_GCC_VER=4 -t einsteinx2/dcdev-gcc-toolchain:gcc-4 .` 12 | 13 | 14 | # 15 | # Global Arguments 16 | # 17 | 18 | # Defaults to verbose output off as it should build faster without all of the console printing. 19 | # To debug build problems, add the flag `--build-arg VERBOSE=true` when building the image to 20 | # have it print all output from each download and compilation step. 21 | # NOTE: If you are using the latest Docker versions with buildx, you'll also need to increase 22 | # the log limit (https://github.com/docker/buildx/issues/484) and add optionally include 23 | # the flag `--progress=plain` if you want to see the full output. 24 | ARG VERBOSE=false 25 | 26 | # For maximum speed, set this to the number of CPU threads you have 27 | # When THREADS=0, `$(getconf _NPROCESSORS_ONLN)` will be used to automatically build using the max available threads 28 | # i.e. if you have a 4 core / 8 thread CPU, choose 8 (can be set using `--build-arg THREADS=8` when building) 29 | ARG THREADS=0 30 | 31 | # KOS git repository and branch to use 32 | # NOTE: To use a different repo or branch, for example to use your own fork instead of upstream, 33 | # add the flag `--build-arg KOS_REPO="https://github.com/your_username/KallistiOS.git"` and/or 34 | # add the flag `--build-arg KOS_BRANCH="your_branch" 35 | ARG KOS_REPO="https://github.com/KallistiOS/KallistiOS.git" 36 | ARG KOS_BRANCH="master" 37 | 38 | # 39 | # First stage: Alpine-based builder image to compile the GCC toolchain 40 | # 41 | 42 | FROM einsteinx2/dcdev-gcc-base:latest as builder 43 | LABEL maintainer "Ben Baron " 44 | 45 | # Choose GCC major version. Supported values are 9 (SH4 9.3/ARM 8.4), 4 (both 4.7.4) 46 | # Can be set using `--build-arg KOS_GCC_VER=4` when building, default is 9) 47 | ARG KOS_GCC_VER=9 48 | 49 | # Set build arguments 50 | ARG TARGETPLATFORM 51 | ARG VERBOSE 52 | ARG THREADS 53 | ARG KOS_REPO 54 | ARG KOS_BRANCH 55 | 56 | # Set environment variables 57 | ENV DCTOOLCHAIN="/opt/toolchains/dc" 58 | ENV KOS="$DCTOOLCHAIN/kos" 59 | ENV DC_CHAIN="$KOS/utils/dc-chain" 60 | ENV DC_CHAIN_CONFIG_MK="$KOS/utils/dc-chain/config.mk" 61 | 62 | # Use the bash shell instead of sh for the build process 63 | SHELL ["/bin/bash", "-c"] 64 | 65 | # Validate KOS_GCC_VER argument and set build variables 66 | RUN if [ "$KOS_GCC_VER" -eq 9 ]; then \ 67 | # Versions for SH4 toolchain 68 | printf "export DOCKER_SH4_BINUTILS_VER=2.34\n" >> /tmp/dockerenv.sh; \ 69 | printf "export DOCKER_SH4_GCC_VER=9.3.0\n" >> /tmp/dockerenv.sh; \ 70 | printf "export DOCKER_SH4_NEWLIB_VER=3.3.0\n" >> /tmp/dockerenv.sh; \ 71 | printf "export DOCKER_SH4_GDB_VER=9.2\n" >> /tmp/dockerenv.sh; \ 72 | printf "export DOCKER_SH4_INSIGHT_VER=6.8-1\n" >> /tmp/dockerenv.sh; \ 73 | # Tarball extensions for SH4 toolchain 74 | printf "export DOCKER_SH4_BINUTILS_EXT=xz\n" >> /tmp/dockerenv.sh; \ 75 | printf "export DOCKER_SH4_GCC_EXT=xz\n" >> /tmp/dockerenv.sh; \ 76 | printf "export DOCKER_SH4_NEWLIB_EXT=gz\n" >> /tmp/dockerenv.sh; \ 77 | printf "export DOCKER_SH4_GDB_EXT=xz\n" >> /tmp/dockerenv.sh; \ 78 | printf "export DOCKER_SH4_INSIGHT_EXT=bz2\n" >> /tmp/dockerenv.sh; \ 79 | # Versions for ARM toolchain 80 | printf "export DOCKER_ARM_BINUTILS_VER=2.34\n" >> /tmp/dockerenv.sh; \ 81 | printf "export DOCKER_ARM_GCC_VER=8.4.0\n" >> /tmp/dockerenv.sh; \ 82 | # Tarball extensions for ARM toolchain 83 | printf "export DOCKER_ARM_BINUTILS_EXT=xz\n" >> /tmp/dockerenv.sh; \ 84 | printf "export DOCKER_ARM_GCC_EXT=xz\n" >> /tmp/dockerenv.sh; \ 85 | elif [ "$KOS_GCC_VER" -eq 4 ]; then \ 86 | # Versions for SH4 toolchain 87 | printf "export DOCKER_SH4_BINUTILS_VER=2.34\n" >> /tmp/dockerenv.sh; \ 88 | printf "export DOCKER_SH4_GCC_VER=4.7.4\n" >> /tmp/dockerenv.sh; \ 89 | printf "export DOCKER_SH4_NEWLIB_VER=2.0.0\n" >> /tmp/dockerenv.sh; \ 90 | printf "export DOCKER_SH4_GDB_VER=9.2\n" >> /tmp/dockerenv.sh; \ 91 | printf "export DOCKER_SH4_INSIGHT_VER=6.8-1\n" >> /tmp/dockerenv.sh; \ 92 | # Tarball extensions for SH4 toolchain 93 | printf "export DOCKER_SH4_BINUTILS_EXT=xz\n" >> /tmp/dockerenv.sh; \ 94 | printf "export DOCKER_SH4_GCC_EXT=bz2\n" >> /tmp/dockerenv.sh; \ 95 | printf "export DOCKER_SH4_NEWLIB_EXT=gz\n" >> /tmp/dockerenv.sh; \ 96 | printf "export DOCKER_SH4_GDB_EXT=xz\n" >> /tmp/dockerenv.sh; \ 97 | printf "export DOCKER_SH4_INSIGHT_EXT=bz2\n" >> /tmp/dockerenv.sh; \ 98 | # Versions for ARM toolchain 99 | printf "export DOCKER_ARM_BINUTILS_VER=2.34\n" >> /tmp/dockerenv.sh; \ 100 | printf "export DOCKER_ARM_GCC_VER=4.7.4\n" >> /tmp/dockerenv.sh; \ 101 | # Tarball extensions for ARM toolchain 102 | printf "export DOCKER_ARM_BINUTILS_EXT=xz\n" >> /tmp/dockerenv.sh; \ 103 | printf "export DOCKER_ARM_GCC_EXT=bz2\n" >> /tmp/dockerenv.sh; \ 104 | else \ 105 | printf "Invalid KOS_GCC_VER specified, supported values are 9 (SH4 9.3/ARM 8.4) and 4 (both 4.7.4)."; \ 106 | exit 1; \ 107 | fi \ 108 | && . /tmp/dockerenv.sh \ 109 | && printf "Building SH4 GCC $DOCKER_SH4_GCC_VER and ARM GCC $DOCKER_ARM_GCC_VER\n" 110 | 111 | # Validate THREADS argument and set build variables 112 | RUN if [ "$THREADS" -eq 0 ] 2>/dev/null; then \ 113 | # If THREADS is 0, default to max possible threads 114 | printf "export DOCKER_THREADS=$(getconf _NPROCESSORS_ONLN)\n" >> /tmp/dockerenv.sh; \ 115 | elif ! [[ -z "${THREADS//[0-9]}" ]]; then \ 116 | # If THREADS is a negative number or any non-integer, print an error and exit 117 | printf "Invalid THREADS specified, please enter a positive integer value\n"; \ 118 | exit 1; \ 119 | else \ 120 | # If THREADS is a positive integer, use that value 121 | printf "export DOCKER_THREADS=$THREADS\n" >> /tmp/dockerenv.sh; \ 122 | fi \ 123 | && . /tmp/dockerenv.sh \ 124 | && printf "Building using $DOCKER_THREADS threads\n" 125 | 126 | # Build the KOS patched GCC cross compiler toolchain for SH4 (Main CPU) and ARM7DI (AICA Control CPU) 127 | RUN \ 128 | # Clone repositories 129 | . /tmp/dockerenv.sh \ 130 | && printf "Cloning latest mainline KOS...$NL" \ 131 | && mkdir -p $DCTOOLCHAIN \ 132 | && git clone --single-branch --branch $KOS_BRANCH $KOS_REPO $KOS &> $REDIRECT \ 133 | && printf "Done.\n" 134 | RUN \ 135 | # Patch the dc-chain config.mk file to set job threads and remove Obj-C support 136 | . /tmp/dockerenv.sh \ 137 | && printf "Copying sample dc-chain config.mk file...$NL" \ 138 | && cp $DC_CHAIN/config.mk.stable.sample $DC_CHAIN_CONFIG_MK \ 139 | && printf "Patching dc-chain config.mk file to set threads and languages...$NL" \ 140 | && sed -i "/^makejobs/c\makejobs=-j$DOCKER_THREADS" $DC_CHAIN_CONFIG_MK \ 141 | && sed -i "/^pass2_languages/c\pass2_languages=c,c++" $DC_CHAIN_CONFIG_MK \ 142 | && sed -i "/^erase/c\erase=0" $DC_CHAIN_CONFIG_MK \ 143 | && printf "Done.\n" 144 | RUN \ 145 | # Patch dc-chain config.mk file to set GCC versions 146 | . /tmp/dockerenv.sh \ 147 | && printf "Patching dc-chain config.mk file to set GCC versions...$NL" \ 148 | \ 149 | && printf "Patching SH4 toolchain versions$NL" \ 150 | && sed -i "/^sh_binutils_ver/c\sh_binutils_ver=$DOCKER_SH4_BINUTILS_VER" $DC_CHAIN_CONFIG_MK \ 151 | && sed -i "/^sh_gcc_ver/c\sh_gcc_ver=$DOCKER_SH4_GCC_VER" $DC_CHAIN_CONFIG_MK \ 152 | && sed -i "/^newlib_ver/c\newlib_ver=$DOCKER_SH4_NEWLIB_VER" $DC_CHAIN_CONFIG_MK \ 153 | && sed -i "/^gdb_ver/c\gdb_ver=$DOCKER_SH4_GDB_VER" $DC_CHAIN_CONFIG_MK \ 154 | && sed -i "/^insight_ver/c\insight_ver=$DOCKER_SH4_INSIGHT_VER" $DC_CHAIN_CONFIG_MK \ 155 | \ 156 | && printf "Patching SH4 toolchain extensions$NL" \ 157 | && sed -i "/^sh_binutils_tarball_type/c\sh_binutils_tarball_type=$DOCKER_SH4_BINUTILS_EXT" $DC_CHAIN_CONFIG_MK \ 158 | && sed -i "/^sh_gcc_tarball_type/c\sh_gcc_tarball_type=$DOCKER_SH4_GCC_EXT" $DC_CHAIN_CONFIG_MK \ 159 | && sed -i "/^newlib_tarball_type/c\newlib_tarball_type=$DOCKER_SH4_NEWLIB_EXT" $DC_CHAIN_CONFIG_MK \ 160 | && sed -i "/^gdb_tarball_type/c\gdb_tarball_type=$DOCKER_SH4_GDB_EXT" $DC_CHAIN_CONFIG_MK \ 161 | && sed -i "/^insight_tarball_type/c\insight_tarball_type=$DOCKER_SH4_INSIGHT_EXT" $DC_CHAIN_CONFIG_MK \ 162 | \ 163 | && printf "Patching ARM toolchain versions$NL" \ 164 | && sed -i "/^arm_binutils_ver/c\arm_binutils_ver=$DOCKER_ARM_BINUTILS_VER" $DC_CHAIN_CONFIG_MK \ 165 | && sed -i "/^arm_gcc_ver/c\arm_gcc_ver=$DOCKER_ARM_GCC_VER" $DC_CHAIN_CONFIG_MK \ 166 | \ 167 | && printf "Patching SH4 toolchain extensions$NL" \ 168 | && sed -i "/^arm_binutils_tarball_type/c\arm_binutils_tarball_type=$DOCKER_ARM_BINUTILS_EXT" $DC_CHAIN_CONFIG_MK \ 169 | && sed -i "/^arm_gcc_tarball_type/c\arm_gcc_tarball_type=$DOCKER_ARM_GCC_EXT" $DC_CHAIN_CONFIG_MK \ 170 | && printf "Done.\n" 171 | RUN \ 172 | # Download and unpack compiler toolchain 173 | . /tmp/dockerenv.sh \ 174 | && cd $DC_CHAIN \ 175 | && printf "Downloading compiler toolchain...$NL" \ 176 | && $DC_CHAIN/download.sh &> $REDIRECT \ 177 | && printf "Done.\nUnpacking compiler toolchain...$NL" \ 178 | && $DC_CHAIN/unpack.sh &> $REDIRECT \ 179 | && printf "Done.\n" 180 | RUN \ 181 | # Patch compiler toolchain 182 | . /tmp/dockerenv.sh \ 183 | && printf "Patching compiler toolchain...$NL" \ 184 | && make -C $DC_CHAIN patch &> $REDIRECT \ 185 | && printf "Done.\n" 186 | RUN \ 187 | # Update arch detection when building GCC 4 for linux/arm64 platform 188 | . /tmp/dockerenv.sh \ 189 | && printf "Updating arch detection if necessary...$NL" \ 190 | && if [ "$KOS_GCC_VER" -eq 4 ] && [ "$TARGETPLATFORM" == "linux/arm64" ]; then \ 191 | printf "Updating config.guess to support $TARGETPLATFORM when building GCC $KOS_GCC_VER...$NL" \ 192 | && wget -O $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' &> $REDIRECT \ 193 | && wget -O $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' &> $REDIRECT \ 194 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/mpc-0.8.1/ \ 195 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/libjava/libltdl/ \ 196 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/libjava/classpath/ \ 197 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/mpfr-2.4.2/ \ 198 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/gmp-4.3.2/ \ 199 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/newlib-$DOCKER_SH4_NEWLIB_VER/ \ 200 | && cp $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.guess $DC_CHAIN/gcc-$DOCKER_SH4_GCC_VER/config.sub $DC_CHAIN/binutils-$DOCKER_SH4_BINUTILS_VER/; \ 201 | else \ 202 | printf "No need to update config.guess since we're building GCC $KOS_GCC_VER on $TARGETPLATFORM...$NL"; \ 203 | fi \ 204 | && printf "Done.\n" 205 | RUN \ 206 | # Build SH4 compiler toolchain 207 | . /tmp/dockerenv.sh \ 208 | && printf "Building SH4 compiler toolchain...$NL" \ 209 | && make -C $DC_CHAIN build-sh4 &> $REDIRECT \ 210 | && printf "Done.\n" 211 | RUN \ 212 | # Build ARM compiler toolchain 213 | . /tmp/dockerenv.sh \ 214 | && printf "Building ARM compiler toolchain...$NL" \ 215 | && make -C $DC_CHAIN build-arm &> $REDIRECT \ 216 | && printf "Done.\n" 217 | RUN \ 218 | # Build debugging tools 219 | . /tmp/dockerenv.sh \ 220 | && printf "Building GDB...$NL" \ 221 | && make -C $DC_CHAIN gdb &> $REDIRECT \ 222 | && printf "Done.\n" 223 | RUN \ 224 | # Prepare files to copy in next stage 225 | . /tmp/dockerenv.sh \ 226 | && printf "Preparing files to copy to next stage...$NL" \ 227 | && mkdir /tmp/copy \ 228 | && mv $DCTOOLCHAIN/sh-elf /tmp/copy \ 229 | && mv $DCTOOLCHAIN/arm-eabi /tmp/copy \ 230 | && mv /tmp/dockerenv.sh /tmp/copy \ 231 | && printf "Done.\n" 232 | 233 | # 234 | # Second stage: Alpine image with only the Dreamcast cross-compiler toolchain (no KOS) and minimal files to reduce image size 235 | # 236 | 237 | FROM alpine:latest 238 | LABEL maintainer "Ben Baron " 239 | 240 | # Set build arguments 241 | ARG VERBOSE 242 | 243 | # Set environment variables 244 | ENV DCTOOLCHAIN="/opt/toolchains/dc" 245 | 246 | # Copy only the compiled toolchains from the build image to save space 247 | COPY --from=builder /tmp/copy $DCTOOLCHAIN 248 | 249 | # Install bash shell and tree 250 | RUN . $DCTOOLCHAIN/dockerenv.sh \ 251 | && rm -f $DCTOOLCHAIN/dockerenv.sh \ 252 | && printf "Installing bash and tree...$NL" \ 253 | && apk --update add --no-cache bash tree &> $REDIRECT \ 254 | && rm -rf /var/cache/apk/* \ 255 | && printf ". /etc/profile\n" > /root/.bashrc \ 256 | && printf "Done.\n" 257 | 258 | # Default to /src directory 259 | WORKDIR /src 260 | 261 | # Run any command passed in a bash shell 262 | ENTRYPOINT ["/bin/bash", "-c"] 263 | 264 | # If no command is passed, run an interactive bash shell 265 | CMD ["/bin/bash"] 266 | -------------------------------------------------------------------------------- /kos-toolchain/Dockerfile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------- 2 | # KOS Complete Toolchain Image (einsteinx2/dcdev-kos-toolchain) 3 | # ------------------------------------------------------------- 4 | # 5 | # This image is meant to be used as a fully featured KOS development environment. It includes both the SH4 and 6 | # ARM cross-compiler toolchains, the full KallistiOS library, all included utilities and addons, and some extra 7 | # useful utilities and programs that you might need to compile any Dreamcast project. It's based on Alpine to keep 8 | # the size to a minimum, though convenience is preferred over a slightly larger image, hence the preinstalled tools 9 | # and the inclusion of the KOS and KOS-PORTS source code rather than the compiled binaries and headers only. 10 | # 11 | # This image contains an entry scipt that automatically loads the KOS environment variables, so it can compile a 12 | # project or use any of the included tools without entering the interactive shell. If no command is provided, an 13 | # interactive bash shell is automatically launched. 14 | # 15 | # Build Commands: 16 | # --------------- 17 | # GCC 9 Toolchain: `docker build -t einsteinx2/dcdev-kos-toolchain:gcc-9 .` 18 | # GCC 4 Toolchain: `docker build --build-arg KOS_GCC_VER=4 -t einsteinx2/dcdev-kos-toolchain:gcc-4 .` 19 | # 20 | # Example GCC 9 Usage (run from your project directory): 21 | # -------------- 22 | # Simple Makefile: `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-9 make` 23 | # Build Script: `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-9 ./dc_build.sh` 24 | # Interactive Shell: `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-9` 25 | # 26 | # Example GCC 4 Usage (run from your project directory): 27 | # -------------- 28 | # Simple Makefile: `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-4 make` 29 | # Build Script: `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-4 ./dc_build.sh` 30 | # Interactive Shell: `docker run -it --rm -v $PWD:/src einsteinx2/dcdev-kos-toolchain:gcc-4` 31 | # 32 | # Notes 33 | # ----- 34 | # More specific tags are provided so you can pin your builds to an exact version of this image if needed. For 35 | # example, you can specify GCC 9.3 by using the einsteinx2/dcdev-kos-toolchain:gcc-9.3 image, or you can specify 36 | # a certain GCC 9.3 image by using a version tag like the einsteinx2/dcdev-kos-toolchain:gcc-9.3__v1.0.0 image. 37 | # This is mostly because while the GCC toolchains don't change very often and are usually compatible as long as 38 | # you're using the same GCC major version (e.g. 9.2 and 9.3), however the KOS library changes more frequently 39 | # and may prevent your project from compiling on a newer version without making some (usually minor) changes. 40 | 41 | 42 | # 43 | # Global Arguments 44 | # 45 | 46 | # Defaults to verbose output off as it should build faster without all of the console printing. 47 | # To debug build problems, add the flag `--build-arg VERBOSE=true` when building the image to 48 | # have it print all output from each download and compilation step. 49 | # NOTE: If you are using the latest Docker versions with buildx, you'll also need to increase 50 | # the log limit (https://github.com/docker/buildx/issues/484) and add optionally include 51 | # the flag `--progress=plain` if you want to see the full output. 52 | ARG VERBOSE=false 53 | 54 | # For maximum speed, set this to the number of CPU threads you have 55 | # When THREADS=0, `$(getconf _NPROCESSORS_ONLN)` will be used to automatically build using the max available threads 56 | # i.e. if you have a 4 core / 8 thread CPU, choose 8 (can be set using `--build-arg THREADS=8` when building) 57 | ARG THREADS=0 58 | 59 | # KOS git repository and branch to use 60 | # NOTE: To use a different repo or branch, for example to use your own fork instead of upstream, 61 | # add the flag `--build-arg KOS_REPO="https://github.com/your_username/KallistiOS.git"` and/or 62 | # add the flag `--build-arg KOS_BRANCH="your_branch" 63 | ARG KOS_REPO="https://github.com/KallistiOS/KallistiOS.git" 64 | ARG KOS_BRANCH="master" 65 | 66 | # KOS-PORTS git repository and branch to use 67 | # NOTE: To use a different repo or branch, for example to use your own fork instead of upstream, 68 | # add the flag `--build-arg PORTS_REPO="https://github.com/your_username/kos-ports.git"` and/or 69 | # add the flag `--build-arg PORTS_BRANCH="your_branch" 70 | ARG PORTS_REPO="https://github.com/KallistiOS/kos-ports.git" 71 | ARG PORTS_BRANCH="master" 72 | 73 | # Choose GCC major version. Supported values are 9 (SH4 9.3/ARM 8.4), 4 (both 4.7.4) 74 | # Can be set using `--build-arg KOS_GCC_VER=4` when building, default is 9) 75 | # NOTE: You can technically use any available tag number from the `einsteinx2/dcdev-gcc-toolchain` image here 76 | ARG KOS_GCC_VER=9 77 | 78 | # 79 | # First stage: Pre-built GCC cross-compiler toolchain to build KOS 80 | # 81 | 82 | FROM einsteinx2/dcdev-gcc-toolchain:gcc-$KOS_GCC_VER as toolchain 83 | FROM einsteinx2/dcdev-gcc-base:latest as builder 84 | LABEL maintainer "Ben Baron " 85 | 86 | # Set build arguments 87 | ARG VERBOSE 88 | ARG THREADS 89 | ARG KOS_REPO 90 | ARG KOS_BRANCH 91 | ARG PORTS_REPO 92 | ARG PORTS_BRANCH 93 | 94 | # Set environment variables 95 | ENV DCTOOLCHAIN="/opt/toolchains/dc" 96 | ENV KOS="$DCTOOLCHAIN/kos" 97 | ENV PORTS="$DCTOOLCHAIN/kos-ports" 98 | 99 | # Use the bash shell instead of sh for the build process 100 | SHELL ["/bin/bash", "-c"] 101 | 102 | # Copy the prebuilt GCC toolchain 103 | COPY --from=toolchain $DCTOOLCHAIN/sh-elf $DCTOOLCHAIN/sh-elf 104 | COPY --from=toolchain $DCTOOLCHAIN/arm-eabi $DCTOOLCHAIN/arm-eabi 105 | 106 | # Validate THREADS argument and set build variables 107 | RUN if [ "$THREADS" -eq 0 ] 2>/dev/null; then \ 108 | # If THREADS is 0, default to max possible threads 109 | printf "export DOCKER_THREADS=$(getconf _NPROCESSORS_ONLN)\n" >> /tmp/dockerenv.sh; \ 110 | elif ! [[ -z "${THREADS//[0-9]}" ]]; then \ 111 | # If THREADS is a negative number or any non-integer, print an error and exit 112 | printf "Invalid THREADS specified, please enter a positive integer value\n"; \ 113 | exit 1; \ 114 | else \ 115 | # If THREADS is a positive integer, use that value 116 | printf "export DOCKER_THREADS=$THREADS\n" >> /tmp/dockerenv.sh; \ 117 | fi \ 118 | && . /tmp/dockerenv.sh \ 119 | && printf "Building using $DOCKER_THREADS threads\n" 120 | 121 | # Build KOS and patched GCC cross-compiler toolchain for SH4 (Main CPU) and ARM7DI (AICA Control CPU) 122 | RUN \ 123 | # Clone repositories 124 | . /tmp/dockerenv.sh \ 125 | && printf "Cloning latest mainline KOS...$NL" \ 126 | && git clone --single-branch --branch $KOS_BRANCH $KOS_REPO $KOS &> $REDIRECT \ 127 | && printf "Done.\nCloning latest mainline KOS PORTS...$NL" \ 128 | && git clone --single-branch --branch $PORTS_BRANCH $PORTS_REPO $PORTS &> $REDIRECT \ 129 | && printf "Done.\n" 130 | RUN \ 131 | # Configure environment 132 | . /tmp/dockerenv.sh \ 133 | && printf "Configuring environment...$NL" \ 134 | && cp $KOS/doc/environ.sh.sample $KOS/environ.sh \ 135 | # NOTE: This is in single quotes on purpose so that ${KOS_BASE} is not evaluated 136 | && printf '. ${KOS_BASE}/environ_dreamcast.sh' >> $KOS/environ.sh \ 137 | # NOTE: This is in double quotes on purpose so that $KOS is evaluated 138 | && printf ". /etc/profile\n. $KOS/environ.sh\n" > /root/.bashrc \ 139 | && printf "Done.\n" 140 | RUN \ 141 | # Build KOS 142 | . /tmp/dockerenv.sh && . $KOS/environ.sh \ 143 | && printf "Building KOS...$NL" \ 144 | && make -j$DOCKER_THREADS -C $KOS &> $REDIRECT \ 145 | && printf "Done.\nCleaning KOS...$NL" \ 146 | && make -j$DOCKER_THREADS -C $KOS clean &> $REDIRECT \ 147 | && printf "Done.\n" 148 | RUN \ 149 | # Build KOS Ports 150 | . /tmp/dockerenv.sh && . $KOS/environ.sh \ 151 | && printf "Building KOS Ports...$NL" \ 152 | && make -C $KOS kos-ports_all &> $REDIRECT \ 153 | && printf "Done.\nCleaning KOS Ports...$NL" \ 154 | && make -C $KOS kos-ports_clean &> $REDIRECT \ 155 | && printf "Done.\n" 156 | RUN \ 157 | # Build KOS addons 158 | . /tmp/dockerenv.sh && . $KOS/environ.sh \ 159 | && printf "Building KOS addons...$NL" \ 160 | && make -j$DOCKER_THREADS -C $KOS/addons &> $REDIRECT \ 161 | && printf "Done.\nCleaning KOS addons...$NL" \ 162 | && find $KOS/addons -name "*.o" -delete \ 163 | && printf "Done.\n" 164 | RUN \ 165 | # Build extra included utilities 166 | . /tmp/dockerenv.sh && . $KOS/environ.sh \ 167 | && printf "Building extra included utilities...$NL" \ 168 | && sed -i 's/^DIRS.*/DIRS = bin2c bincnv dcbumpgen genromfs isotest kmgenc makejitter rdtest scramble vqenc wav2adpcm/' $KOS/utils/Makefile \ 169 | && make -j$DOCKER_THREADS -C $KOS/utils &> $REDIRECT \ 170 | && printf "Done.\nSymlinking extra utilities to $DCTOOLCHAIN/bin so they're in the PATH...$NL" \ 171 | && mkdir -p $DCTOOLCHAIN/bin \ 172 | && ln -s $KOS/utils/bin2c/bin2c $DCTOOLCHAIN/bin/bin2c \ 173 | && ln -s $KOS/utils/bin2o/bin2o $DCTOOLCHAIN/bin/bin2o \ 174 | && ln -s $KOS/utils/dcbumpgen/dcbumpgen $DCTOOLCHAIN/bin/dcbumpgen \ 175 | && ln -s $KOS/utils/genexports/genexports.sh $DCTOOLCHAIN/bin/genexports.sh \ 176 | && ln -s $KOS/utils/genexports/genexportstubs.sh $DCTOOLCHAIN/bin/genexportstubs.sh \ 177 | && ln -s $KOS/utils/genromfs/genromfs $DCTOOLCHAIN/bin/genromfs \ 178 | && ln -s $KOS/utils/ipload/ipload.py $DCTOOLCHAIN/bin/ipload.py \ 179 | && ln -s $KOS/utils/isotest/isotest $DCTOOLCHAIN/bin/isotest \ 180 | && ln -s $KOS/utils/kmgenc/kmgenc $DCTOOLCHAIN/bin/kmgenc \ 181 | && ln -s $KOS/utils/makejitter/makejitter $DCTOOLCHAIN/bin/makejitter \ 182 | && ln -s $KOS/utils/rdtest/rdtest $DCTOOLCHAIN/bin/rdtest \ 183 | && ln -s $KOS/utils/scramble/scramble $DCTOOLCHAIN/bin/scramble \ 184 | && ln -s $KOS/utils/vqenc/vqenc $DCTOOLCHAIN/bin/vqenc \ 185 | && ln -s $KOS/utils/wav2adpcm/wav2adpcm $DCTOOLCHAIN/bin/wav2adpcm \ 186 | && printf "Done.\nCleaning extra included utilities...$NL" \ 187 | && find $KOS/utils -name "*.o" -delete \ 188 | && printf "Done.\n" 189 | RUN \ 190 | # Build extra external utilities 191 | . /tmp/dockerenv.sh && . $KOS/environ.sh \ 192 | && printf "Building extra external utilities...$NL" \ 193 | && mkdir -p $KOS/utils/makeip \ 194 | && cd $KOS/utils/makeip \ 195 | && curl --progress-bar -O http://www.boob.co.uk/files/makeip.tar.gz &> $REDIRECT \ 196 | && tar -xf makeip.tar.gz &> $REDIRECT \ 197 | && rm makeip.tar.gz &> $REDIRECT \ 198 | && gcc makeip.c -o makeip &> $REDIRECT \ 199 | && ln -s $KOS/utils/makeip/makeip $DCTOOLCHAIN/bin/makeip \ 200 | && cd $KOS/utils \ 201 | && git clone https://github.com/einsteinx2/img4dc.git &> $REDIRECT \ 202 | && cd $KOS/utils/img4dc \ 203 | && cmake . &> $REDIRECT \ 204 | && make cdi4dc &> $REDIRECT \ 205 | && ln -s $KOS/utils/img4dc/cdi4dc/cdi4dc $DCTOOLCHAIN/bin/cdi4dc \ 206 | && cd $KOS/utils \ 207 | && git clone https://github.com/sizious/dcload-ip.git &> $REDIRECT \ 208 | && cd $KOS/utils/dcload-ip \ 209 | && make install \ 210 | && printf "Done.\n" 211 | RUN \ 212 | # Prepare files to copy in next stage 213 | . /tmp/dockerenv.sh \ 214 | && printf "Preparing files to copy to next stage...$NL" \ 215 | && mkdir /tmp/copy \ 216 | && mv $DCTOOLCHAIN/sh-elf $DCTOOLCHAIN/arm-eabi $DCTOOLCHAIN/kos $DCTOOLCHAIN/kos-ports $DCTOOLCHAIN/bin /tmp/copy \ 217 | && mv /tmp/dockerenv.sh /root/.bashrc /tmp/copy \ 218 | && printf "Done.\n" 219 | 220 | # 221 | # Second stage: Final Alpine image with the GCC cross-compiler toolchain, KOS, KOS-PORTS, Addons, Utils, and some other useful stuff 222 | # 223 | 224 | FROM alpine:latest 225 | LABEL maintainer "Ben Baron " 226 | 227 | # Set build arguments 228 | ARG VERBOSE 229 | 230 | # Set a local environment variable based on the global arg 231 | ENV DCTOOLCHAIN="/opt/toolchains/dc" 232 | 233 | # Copy only the compiled toolchains from the build image to save space 234 | COPY --from=builder /tmp/copy $DCTOOLCHAIN 235 | 236 | # Install tools and create entry script that loads the KOS environment so make commands can be given directly 237 | RUN \ 238 | # Move copied files into place 239 | . $DCTOOLCHAIN/dockerenv.sh \ 240 | && rm -f $DCTOOLCHAIN/dockerenv.sh \ 241 | && mv $DCTOOLCHAIN/.bashrc /root/.bashrc \ 242 | \ 243 | # Install useful tools for building Dreamcast projects 244 | && printf "Installing useful tools for building Dreamcast projects...$NL" \ 245 | && apk --update add --no-cache \ 246 | bash bison bzip2 cdrkit cmake colordiff coreutils curl flex gawk git linux-headers \ 247 | musl-dev make patch python2 sed subversion tar texinfo tree vim wget &> $REDIRECT \ 248 | && apk --update add --no-cache libelf-dev --repository=http://dl-cdn.alpinelinux.org/alpine/v3.9/main \ 249 | && rm -rf /var/cache/apk/* \ 250 | && printf "Done.\n" \ 251 | \ 252 | # Create entry point script to automatically load KOS environment 253 | && printf "Create entry point script to automatically load KOS environment...$NL" \ 254 | && printf '#!/bin/bash\n. /opt/toolchains/dc/kos/environ.sh\nexec "$@"' > /usr/local/bin/entry.sh \ 255 | && chmod a+x /usr/local/bin/entry.sh \ 256 | && printf "Done.\n" 257 | 258 | # Default to /src directory 259 | WORKDIR /src 260 | 261 | # Run any command passed in a bash shell with the KOS environment loaded 262 | ENTRYPOINT ["/usr/local/bin/entry.sh"] 263 | 264 | # If no command is passed, run an interactive bash shell 265 | CMD ["/bin/bash"] 266 | --------------------------------------------------------------------------------