From 86785bcd72807c97a3507e87c057ae7bf1d8273a Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 27 Aug 2021 20:12:35 -0400 Subject: [PATCH] Add Dockerfile and make it buildable as-is --- Makefile | 4 +- README.md | 59 +++++---------------------- docker/Dockerfile | 25 ++++++++++++ docker/setup-linux.sh | 94 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 52 deletions(-) create mode 100644 docker/Dockerfile create mode 100755 docker/setup-linux.sh diff --git a/Makefile b/Makefile index e2f00a6..8bc3004 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ OBJDIR = ./obj BINDIR = ./bin TOOLSDIR = ./tools -LINK_FLAGS = -O1 -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lmad -lyaml -lc -lm -ldragonsys -lnosys $(LIBS) -Tn64.ld -PROG_NAME = OS64 +LINK_FLAGS = -O1 -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lmad -lyaml -lc -lm -ldragonsys -lnosys $(LIBS) -Tn64ld.x +PROG_NAME = OS64P CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O1 -I$(INCDIR) -I$(ROOTDIR)/include -I$(ROOTDIR)/mips64-elf/include -lpthread -lrt -D_REENTRANT -DUSE_TRUETYPE $(SET_DEBUG) ASFLAGS = -mtune=vr4300 -march=vr4300 CC = $(GCCN64PREFIX)gcc diff --git a/README.md b/README.md index 122bbc3..496df30 100644 --- a/README.md +++ b/README.md @@ -2,76 +2,35 @@ Alternative Everdrive64 menu - -`Altra64` is an open source menu for [Everdrive64](http://krikzz.com/) and is based on a fork of alt64 which was +`Altra64` is an open source menu for [Everdrive64](http://krikzz.com/) and ed64+ and is based on a fork of alt64 which was originally written by saturnu, and released on the [Everdrive64 forum](http://krikzz.com/forum/index.php?topic=816.0). ## Building -If you want to build the menu, you need an n64 toolchain. When using windows 10 or Ubuntu, installation is totally automated through a script. +If you want to build the menu, you need an n64 toolchain. This is terrible to build, I ended up creating a Dockerfile in the docker folder, instructions included in it. -### Dependencies (installed automatically) -* Windows 10 (Aniversary Update or above) / Ubuntu 16.04 (or above) -* [libdragon](https://github.com/DragonMinded/libdragon) -* [libmikmod (with n64 driver)](https://github.com/networkfusion/libmikmod) -* [libmad-n64](https://github.com/networkfusion/libmad-n64) -* [libyaml](http://pyyaml.org/wiki/LibYAML) - -### Build the Toolchain - -*You may skip this step if it's already installed.* - -Clone this `Altra64` repo to a directory of your choice. - -On Windows 10: -* Ensure that ["Windows Subsystem For Linux (Ubuntu)"](https://msdn.microsoft.com/en-gb/commandline/wsl/install_guide) is installed. -* browse to the tools directory and double click on ```setup-wsfl.cmd```. - -On Ubuntu, browse to the tools directory and run the command ```$ chmod +x ./setup-linux.sh;source ./setup-linux.sh``` +Or if you trust me, you can use the one I built and pushed to docker hub, [moparisthebest/altra64-dev](https://hub.docker.com/r/moparisthebest/altra64-dev) ### Build `Altra64` To build the Rom -from the projects root directory, -On Windows 10 run +from the projects root directory, with docker installed ``` -> build +$ docker run --rm -v "$(pwd):/build" moparisthebest/altra64-dev make ``` -on linux -``` -$ make -``` -If it all worked, you will find `OS64.v64` in the `Altra64` bin directory. - -### Debug Build `Altra64` -To build the debug version of the Rom - -from the projects root directory, -On Windows 10 run -``` -> build debug -``` -on linux -``` -$ make debug -``` -If it all worked, you will find `OS64.v64` in the `Altra64` bin directory. +If it all worked, you will find `OS64.v64` in the `bin` directory. ### Clean `Altra64` + Finally, we can clean the build objects from the project -from the projects root directory, -On Windows 10 run +from the projects root directory ``` -> build clean -``` -on linux -``` -$ make clean +$ docker run --rm -v "$(pwd):/build" moparisthebest/altra64-dev make clean ``` Enjoy! diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..0c7f0ae --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,25 @@ + +# to build and test: +# docker build -t altra64-dev . && docker run --rm -v "$(pwd):/build" -it altra64-dev + +# to use to compile altra64 (or other n64 stuff I guess) +# docker run --rm -v "$(pwd):/build" altra64-dev make + +#FROM ubuntu:18.04 +FROM ubuntu:16.04 + +RUN mkdir /build + +COPY setup-linux.sh /usr/bin/setup-linux.sh + +# run it then delete all build artifacts +RUN /usr/bin/setup-linux.sh && rm -rf /root/* + +ENV N64_INST=/usr/local/libdragon +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/libdragon/bin + +VOLUME [ "/build" ] + +WORKDIR /build + +CMD ["bash"] diff --git a/docker/setup-linux.sh b/docker/setup-linux.sh new file mode 100755 index 0000000..439acef --- /dev/null +++ b/docker/setup-linux.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# +# Copyright (c) 2017 The Altra64 project contributors +# See LICENSE file in the project root for full license information. +# + +set -euxo pipefail + +# Download and install latest updates for the system [sudo req.] +apt-get update +apt-get -y upgrade + +# Install essential packages [sudo req.] +apt-get -y install wget build-essential git texinfo libc6 libgmp-dev libmpfr-dev libmpc-dev libpng-dev zlib1g-dev libtool autoconf + +# change to the users root directory +cd ~/ + +# add a system variable and make it perminent +# echo 'N64_INST=/usr/local/libdragon' >> /etc/environment +# echo 'export N64_INST=/usr/local/libdragon' >> ~/.bashrc +export N64_INST=/usr/local/libdragon +# source ~/.bashrc + +# Pull the latest libdragon source code and make a build directory +git clone https://github.com/dragonminded/libdragon.git +# set to correct commit +cd libdragon && git checkout b26fce6 && cd .. + +# fix issues with the build scripts +sed -i -- 's|${N64_INST:-/usr/local}|/usr/local/libdragon|g' libdragon/tools/build +sed -i -- 's|--with-newlib|--with-newlib --with-system-zlib|g' libdragon/tools/build + +sed -i -- 's| -lpng|\nLDLIBS = -lpng|g' libdragon/tools/mksprite/Makefile +sed -i -- 's| -Werror| -w|g' libdragon/tools/mksprite/Makefile + +# make a build folder for libdragon +mkdir libdragon/build_gcc +cp libdragon/tools/build libdragon/build_gcc + +# run the build script (this will take a while! and if not sudo, will ask for password mid flow!) +cd libdragon/build_gcc +./build + +cd .. +# run the install script [sudo req] +make +make install +make tools +make tools-install + +cd .. +# install libmikmod (custom version) +git clone https://github.com/n64-tools/libmikmod +cd libmikmod/n64 +make +make install +cd .. # we have are in a subfolder, this is not a duplicate... + +cd .. +# install libyaml +git clone https://github.com/yaml/libyaml +cd libyaml +./bootstrap +#$(N64_INST) converterd to $N64_INST below otherwise it will not run on WSFL +export PATH=$PATH:$N64_INST/bin +CFLAGS="-std=gnu99 -march=vr4300 -mtune=vr4300" \ +LDFLAGS="-L$N64_INST/lib -Tn64ld.x" \ +LIBS="-ldragon -lc -ldragonsys -lnosys" \ +./configure --host=mips64-elf --prefix=$N64_INST +make +make install + +cd .. +# install libmad (custom version) +git clone https://github.com/n64-tools/libmad +cd libmad +export PATH=$PATH:$N64_INST/bin +CFLAGS="-std=gnu99 -march=vr4300 -mtune=vr4300" \ +LDFLAGS="-L$N64_INST/lib -Tn64ld.x" \ +LIBS="-ldragon -lc -ldragonsys -lnosys" \ +./configure --host=mips64-elf --prefix=$N64_INST +make +make install + +cd .. + +# Perform cleanup +apt-get -y autoremove +apt-get autoclean + +echo 'export N64_INST=/usr/local/libdragon' >> ~/.bashrc +echo 'export PATH="$PATH:$N64_INST/bin"' >> ~/.bashrc +