Merge pull request #37 from ivan-tat/master

sdk: improve `cmake` MinGW cross-compilation setup, update `README.md`
This commit is contained in:
Ivan Tatarinov 2021-04-15 19:34:39 +03:00 committed by GitHub
commit 0940c194d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 96 additions and 28 deletions

View File

@ -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

View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2021 Ivan Tatarinov <ivan-tat@ya.ru>
#
# 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)

View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2021 Ivan Tatarinov <ivan-tat@ya.ru>
#
# 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)

View File

@ -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)

View File

@ -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:

View File

@ -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