├── .gitignore ├── LICENSE ├── README.md ├── makefile ├── set_environment_variables.sh └── set_environment_variables_permanently.sh /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.Identifier 2 | **/*.swp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Arthur Rodrigues de Carvalho Chagas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CTMZ_Toolchain 2 | C cross compiler toolchain targeting M68K and Z80 microprocessors (Neo Geo/Mega Drive/Master System) should compile under Linux and Windows (With MSYS2/WSL) Mac was not been tested, but should work with the necessary dependencies. 3 | 4 | The makefile download software latest versions from their respective mirrors by default. To use a different version, change the ```$(LINK...)``` variables. 5 | 6 | **Dependencies** 7 | 8 | Ubuntu 9 | ``` 10 | apt-get install make texinfo bison flex unzip gcc g++ curl python expat diffutils libgmp-dev libmpfr-dev mpc libmpc-dev libisl-dev libc++-dev libboost-all-dev 11 | ``` 12 | Windows (MSYS2 MinGW terminal) 13 | ``` 14 | pacman -S make texinfo bison flex unzip mingw-w64-x86_64-gcc mingw-w64-x86_64-curl mingw-w64-x86_64-python mingw-w64-x86_64-expat mingw-w64-x86_64-diffutils mingw-w64-x86_64-gmp mingw-w64-x86_64-mpfr mingw-w64-x86_64-mpc mingw-w64-x86_64-isl mingw-w64-x86_64-libc++ mingw-w64-x86_64-boost 15 | ``` 16 | 17 | **NeoGeo and Mega Drive compiler toolchain** 18 | ``` 19 | make install_gcc-newlib_m68k && make install_sdcc_z80 20 | ``` 21 | **The Master System only needs SDCC** 22 | ``` 23 | make install_sdcc_z80 24 | ``` 25 | 26 | **To set the environment variables** 27 | ``` 28 | source set_environment_variables.sh 29 | ``` 30 | 31 | **To set the environment variables permanently** 32 | ``` 33 | # Add environment variables to ~/.bash_profile 34 | source set_environment_variables_permanently.sh 35 | ``` 36 | 37 | **Windows extra information - Using the Toolchain outside of MSYS2 MinGW terminal** 38 | 39 | You may want to use this Toolchain outside of MSYS2 MinGW terminal on Windows, for use in IDE's, in order to do that, copy any needed libraries to the Toolchain /bin folder. ``ldd`` command can help you with that. Only files inside ``/mingw64/bin/`` are needed. 40 | 41 | Usage example: 42 | ``` 43 | ldd ./m68k-elf-gcc 44 | ``` 45 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # CTMZ 2 | CTMZ_HOME = $(PWD) 3 | 4 | # PATH 5 | PATH := $(PATH):$(CTMZ_HOME)/Toolchain-M68K/bin:$(CTMZ_HOME)/Toolchain-Z80/bin 6 | 7 | # File archiver 8 | FILE_ARCHIVER = unzip 9 | 10 | # Binutils-GDB 11 | LINK_BINUTILS-GDB = https://codeload.github.com/bminor/binutils-gdb/zip/master 12 | DOWN_BINUTILS-GDB = binutils-gdb.zip 13 | PATH_BINUTILS-GDB = binutils-gdb-master 14 | 15 | # GCC 16 | LINK_GCC = https://codeload.github.com/gcc-mirror/gcc/zip/master 17 | DOWN_GCC = GCC.zip 18 | PATH_GCC = gcc-master 19 | 20 | # Newlib 21 | LINK_NEWLIB = https://codeload.github.com/bminor/newlib/zip/master 22 | DOWN_NEWLIB = Newlib.zip 23 | PATH_NEWLIB = newlib-master 24 | 25 | # SDCC 26 | LINK_SDCC = https://codeload.github.com/swegener/sdcc/zip/master 27 | DOWN_SDCC = SDCC.zip 28 | PATH_SDCC = sdcc-master 29 | 30 | all: install_gcc-newlib_m68k install_sdcc_z80 31 | 32 | $(DOWN_BINUTILS-GDB): 33 | curl $(LINK_BINUTILS-GDB) -o $(DOWN_BINUTILS-GDB) 34 | 35 | $(PATH_BINUTILS-GDB): $(DOWN_BINUTILS-GDB) 36 | $(FILE_ARCHIVER) $(DOWN_BINUTILS-GDB) 37 | 38 | $(DOWN_GCC): 39 | curl $(LINK_GCC) -o $(DOWN_GCC) 40 | 41 | $(PATH_GCC): $(DOWN_GCC) 42 | $(FILE_ARCHIVER) $(DOWN_GCC) 43 | 44 | $(DOWN_NEWLIB): 45 | curl $(LINK_NEWLIB) -o $(DOWN_NEWLIB) 46 | 47 | $(PATH_NEWLIB): $(DOWN_NEWLIB) 48 | $(FILE_ARCHIVER) $(DOWN_NEWLIB) 49 | 50 | $(DOWN_SDCC): 51 | curl $(LINK_SDCC) -o $(DOWN_SDCC) 52 | 53 | $(PATH_SDCC): $(DOWN_SDCC) 54 | $(FILE_ARCHIVER) $(DOWN_SDCC) 55 | 56 | install_binutils-gdb_m68k: $(PATH_BINUTILS-GDB) 57 | mkdir -p $(PATH_BINUTILS-GDB)/build 58 | cd $(PATH_BINUTILS-GDB)/build && ../configure --target=m68k-elf --prefix=$(CTMZ_HOME)/Toolchain-M68K --with-cpu=m68000 --enable-install-libbfd --enable-shared=no --disable-multilib --disable-tls --disable-nls --disable-werror 59 | make -j8 all LDFLAGS=-Wl,--allow-multiple-definition -C $(PATH_BINUTILS-GDB)/build 60 | make install -C $(PATH_BINUTILS-GDB)/build 61 | touch $@ 62 | 63 | install_gcc_m68k: $(PATH_BINUTILS-GDB) $(PATH_GCC) install_binutils-gdb_m68k 64 | mkdir -p $(PATH_GCC)/build 65 | cd $(PATH_GCC)/build && ../configure --target=m68k-elf --prefix=$(CTMZ_HOME)/Toolchain-M68K --enable-languages=c --with-cpu=m68000 --without-headers --disable-libstdcxx --disable-libquadmath --disable-libssp --disable-libstacktrace --disable-threads --disable-tls --disable-multilib --enable-shared=no --disable-nls --disable-werror 66 | make -j8 all-gcc -C $(PATH_GCC)/build 67 | make install-gcc -C $(PATH_GCC)/build 68 | touch $@ 69 | 70 | install_newlib_m68k: $(PATH_BINUTILS-GDB) $(PATH_GCC) $(PATH_NEWLIB) install_binutils-gdb_m68k install_gcc_m68k 71 | mkdir -p $(PATH_NEWLIB)/build 72 | cd $(PATH_NEWLIB)/build && ../configure --target=m68k-elf --prefix=$(CTMZ_HOME)/Toolchain-M68K --with-cpu=m68000 --enable-shared=no --disable-nls --disable-werror 73 | make -j8 all -C $(PATH_NEWLIB)/build 74 | make install -C $(PATH_NEWLIB)/build 75 | touch $@ 76 | 77 | install_gcc-newlib_m68k: $(PATH_BINUTILS-GDB) $(PATH_GCC) $(PATH_NEWLIB) install_binutils-gdb_m68k install_gcc_m68k install_newlib_m68k 78 | cd $(PATH_GCC)/build && ../configure --target=m68k-elf --prefix=$(CTMZ_HOME)/Toolchain-M68K --enable-languages=c --with-cpu=m68000 --without-headers --with-newlib --disable-libquadmath --disable-libssp --disable-libstacktrace --disable-libstdcxx --disable-threads --disable-tls --disable-multilib --enable-shared=no --disable-nls --disable-werror 79 | make -j8 all -C $(PATH_GCC)/build 80 | make install -C $(PATH_GCC)/build 81 | touch $@ 82 | 83 | install_sdcc_z80: $(PATH_SDCC) 84 | mkdir -p $(PATH_SDCC)/build 85 | cd $(PATH_SDCC)/build && ../configure --prefix=$(CTMZ_HOME)/Toolchain-Z80 --disable-non-free --enable-z80-port --disable-mcs51-port --disable-pic14-port --disable-pic16-port --disable-gbz80-port --disable-tlcs90-port --disable-stm8-port --disable-avr-port --disable-ds390-port --disable-ds400-port --disable-hc08-port --disable-pic-port --disable-pic16-port --disable-xa51-port --disable-s08-port --disable-z180-port --disable-r2k-port --disable-r3ka-port 86 | make -j8 -C $(PATH_SDCC)/build 87 | make install -C $(PATH_SDCC)/build 88 | touch $@ 89 | 90 | clean: 91 | rm -rf $(DOWN_BINUTILS-GDB) 92 | rm -rf $(DOWN_GCC) 93 | rm -rf $(DOWN_NEWLIB) 94 | rm -rf $(DOWN_SDCC) 95 | 96 | rm -rf $(PATH_BINUTILS-GDB) 97 | rm -rf $(PATH_GCC) 98 | rm -rf $(PATH_NEWLIB) 99 | rm -rf $(PATH_SDCC) 100 | 101 | rm -rf $(CTMZ_HOME)/Toolchain-M68K 102 | rm -rf $(CTMZ_HOME)/Toolchain-Z80 103 | rm -rf install_binutils-gdb_m68k install_gcc_m68k install_newlib_m68k install_gcc-newlib_m68k install_sdcc_z80 104 | 105 | .PHONY: clean all 106 | -------------------------------------------------------------------------------- /set_environment_variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export CTMZ_HOME=$PWD 3 | export PATH=$PATH:$CTMZ_HOME/Toolchain-M68K/bin 4 | export PATH=$PATH:$CTMZ_HOME/Toolchain-Z80/bin 5 | -------------------------------------------------------------------------------- /set_environment_variables_permanently.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "" >> ~/.bash_profile 3 | echo "# CTMZ_Toolchain environment variables" >> ~/.bash_profile 4 | echo "export CTMZ_HOME=$PWD" >> ~/.bash_profile 5 | echo "export PATH=\$PATH:\$CTMZ_HOME/Toolchain-M68K/bin" >> ~/.bash_profile 6 | echo "export PATH=\$PATH:\$CTMZ_HOME/Toolchain-Z80/bin" >> ~/.bash_profile 7 | --------------------------------------------------------------------------------