From e2a1c2a8172fb5c9babda62cc0adb367434a16f5 Mon Sep 17 00:00:00 2001 From: Ivan Tatarinov Date: Thu, 15 Apr 2021 19:21:10 +0300 Subject: [PATCH 1/4] sdk: improve `cmake` usage for cross-compilation for Windows platform --- sdk/src/Toolchain-mingw32.cmake | 23 +++++++++++++++++++++++ sdk/src/Toolchain-mingw64.cmake | 23 +++++++++++++++++++++++ sdk/src/sjasmplus.mk | 16 ++++------------ 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 sdk/src/Toolchain-mingw32.cmake create mode 100644 sdk/src/Toolchain-mingw64.cmake diff --git a/sdk/src/Toolchain-mingw32.cmake b/sdk/src/Toolchain-mingw32.cmake new file mode 100644 index 0000000..542fd31 --- /dev/null +++ b/sdk/src/Toolchain-mingw32.cmake @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2021 Ivan Tatarinov +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# From https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/cross_compiling/Mingw + +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +SET(MINGW_VER i686-w64-mingw32) +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER ${MINGW_VER}-gcc) +SET(CMAKE_CXX_COMPILER ${MINGW_VER}-g++) +SET(CMAKE_RC_COMPILER ${MINGW_VER}-windres) +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/${MINGW_VER} ) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/sdk/src/Toolchain-mingw64.cmake b/sdk/src/Toolchain-mingw64.cmake new file mode 100644 index 0000000..a0af88c --- /dev/null +++ b/sdk/src/Toolchain-mingw64.cmake @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2021 Ivan Tatarinov +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# From https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/cross_compiling/Mingw + +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +SET(MINGW_VER x86_64-w64-mingw32) +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER ${MINGW_VER}-gcc) +SET(CMAKE_CXX_COMPILER ${MINGW_VER}-g++) +SET(CMAKE_RC_COMPILER ${MINGW_VER}-windres) +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/${MINGW_VER} ) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/sdk/src/sjasmplus.mk b/sdk/src/sjasmplus.mk index 0fce22c..35cc03b 100644 --- a/sdk/src/sjasmplus.mk +++ b/sdk/src/sjasmplus.mk @@ -20,20 +20,12 @@ include ../../common.mk -CMAKEFLAGS := - ifeq ($(BUILD),mingw32) -CMAKEFLAGS += CMAKE_SYSTEM_NAME=Windows -CMAKEFLAGS += CMAKE_SYSTEM_PROCESSOR=x86 -CMAKEFLAGS += CMAKE_C_COMPILER=i686-w64-mingw32-gcc -CMAKEFLAGS += CMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -CMAKEFLAGS := $(patsubst %,-D%,$(CMAKEFLAGS)) +CMAKEFLAGS := -DCMAKE_TOOLCHAIN_FILE=../Toolchain-mingw32.cmake else ifeq ($(BUILD),mingw64) -CMAKEFLAGS += CMAKE_SYSTEM_NAME=Windows -CMAKEFLAGS += CMAKE_SYSTEM_PROCESSOR=AMD64 -CMAKEFLAGS += CMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -CMAKEFLAGS += CMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -CMAKEFLAGS := $(patsubst %,-D%,$(CMAKEFLAGS)) +CMAKEFLAGS := -DCMAKE_TOOLCHAIN_FILE=../Toolchain-mingw64.cmake +else +CMAKEFLAGS := endif SJASMPLUS := sjasmplus$(EXECEXT) From b171731c00091c2bcac913c9ebc7162708916b12 Mon Sep 17 00:00:00 2001 From: Ivan Tatarinov Date: Thu, 15 Apr 2021 19:23:10 +0300 Subject: [PATCH 2/4] sdk: added instructions for Debian-based systems in `README.md` --- sdk/README.md | 52 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/sdk/README.md b/sdk/README.md index 0b39ec4..8bf4ae5 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -22,7 +22,37 @@ Check it out by using this [reuse-tool](https://github.com/fsfe/reuse-tool). # 2. Using SDK in GNU environment on Linux, FreeBSD etc. -## 2.1. Build tools +## 2.1. Prepare a build environment + +### 2.1.1. On a Debian-based system (Ubuntu etc.) + +Open terminal and type: + +```bash +# apt install -y build-essential git cmake libboost-all-dev +``` + +**NOTE**: here the first symbol "#" means that the following command must be run as *root* or using `sudo` utility. + +To use cross-compilation for Windows platform install *mingw-w64* package: + +```bash +# apt install -y mingw-w64 +``` + +### 2.1.2. Clone repository + +Choose a directory for project and type: + +```bash +git clone git://github.com/zxdos/zxuno.git zxuno +``` + +Now `zxuno` sub-directory is the ZX-Uno project's root directory and all actions we'll make inside it. + +## 2.2. Build tools + +Go to the project's root directory and type one of the following commands: Command | Target ----|---- @@ -49,13 +79,13 @@ Remember to specify proper file extension (`.exe`) for target when building with make BUILD=mingw64 bin/fcut.exe bin/fpad.exe bin/fpoke.exe ``` -Then you may use **strip** tool to strip debug information from file and thus shrink file's size: +Then you may use `strip` tool to strip debug information from file and thus shrink file's size: ```bash strip bin/fcut.exe bin/fpad.exe bin/fpoke.exe ``` -## 2.2. Clean tools +## 2.3. Clean tools To clean everything type: @@ -63,17 +93,17 @@ To clean everything type: make clean ``` -To clean MinGW builds use appropriate `BUILD` parameter as described in [2.1](#21-build-tools). Example: +To clean MinGW builds use appropriate `BUILD` parameter as described in [2.2](#22-build-tools). Example: ```bash make BUILD=mingw64 clean ``` -## 2.3. Tools usage +## 2.4. Tools usage These tools are supposed to be used mainly in Makefiles and Bash scripts invoked from Makefiles. -### 2.3.1. In Makefiles +### 2.4.1. In Makefiles To use these tools in a Makefile just include `common.mk` file at the beginning of one like this: @@ -86,7 +116,7 @@ Remember to specify correct relative path to it. This will set `ZXUNOSDK` environment variable (on first inclusion only) and update your `PATH` environment variable to point to SDK's tools. These changes are actual for current invocation of `make` utility and all child processes. -### 2.3.2. In Bash scripts +### 2.4.2. In Bash scripts Bash scripts are supposed to be invoked from Makefiles where the correct environment is already prepared by `make` utility so nothing must be done for such scripts. @@ -125,24 +155,24 @@ on Windows platform is disabled right now because of presence of precompiled bin ## 3.1. Build tools The building process is similar to one for GNU on Linux, FreeBSD etc. -See [2.1](#21-build-tools) with addition that you should provide correct target name (specify file extension `.exe`) and also specify parameter `FORCEBUILD=1`. +See [2.2](#22-build-tools) with addition that you should provide correct target name (specify file extension `.exe`) and also specify parameter `FORCEBUILD=1`. ## 3.2. Clean tools The cleaning process is similar to one for GNU on Linux, FreeBSD etc. -See [2.2](#22-clean-tools) with addition that you should specify parameter `FORCECLEAN=1`. +See [2.3](#23-clean-tools) with addition that you should specify parameter `FORCECLEAN=1`. ## 3.3. Tools usage ### 3.3.1. In Makefiles The usage is similar to one for GNU on Linux, FreeBSD etc. -See [2.3.1](#231-in-makefiles). +See [2.4.1](#241-in-makefiles). ### 3.3.2. In Bash scripts The usage is similar to one for GNU on Linux, FreeBSD etc. -See [2.3.2](#232-in-bash-scripts). +See [2.4.2](#242-in-bash-scripts). # 4. Using SDK on Windows without GNU environment From 54499311734c700b8b720467ad13a8661b789cd6 Mon Sep 17 00:00:00 2001 From: Ivan Tatarinov Date: Thu, 15 Apr 2021 19:27:03 +0300 Subject: [PATCH 3/4] software: added explicit prerequisites for `esprst` in `Makefile` --- software/esprst/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/esprst/Makefile b/software/esprst/Makefile index b286114..a93b5b1 100644 --- a/software/esprst/Makefile +++ b/software/esprst/Makefile @@ -7,8 +7,8 @@ include ../../sdk/common.mk .PHONY: all all: esprst -esprst: *.asm - sjasmplus main.asm +esprst: main.asm uart.asm ring.asm + sjasmplus $< .PHONY: clean clean: From 5cf69f5b6ce47209590ac97fbf587659205dec17 Mon Sep 17 00:00:00 2001 From: Ivan Tatarinov Date: Thu, 15 Apr 2021 19:29:15 +0300 Subject: [PATCH 4/4] software: added explicit prerequisites for `ugophy` in `Makefile`, removed autogenerated `ugoph.tap` --- software/ugophy/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/software/ugophy/Makefile b/software/ugophy/Makefile index 7f55c85..cdf74da 100644 --- a/software/ugophy/Makefile +++ b/software/ugophy/Makefile @@ -7,9 +7,9 @@ include ../../sdk/common.mk .PHONY: all all: ugoph.bin -ugoph.bin: *.asm - sjasmplus main.asm +ugoph.bin ugoph.tap: main.asm tscreen.asm keyboard.asm utils.asm wifi.asm gopher.asm render.asm textrender.asm uart.asm ring.asm esxdos.asm vtpl.asm + sjasmplus $< .PHONY: clean clean: - rm -f ugoph.bin + rm -f ugoph.bin ugoph.tap