From a16b6046bd7f281b64a370dbdb68baaf4c1857ff Mon Sep 17 00:00:00 2001 From: Ivan Tatarinov Date: Wed, 5 May 2021 22:36:05 +0300 Subject: [PATCH] sdk: added alternative `sjasmplus` compiler by aprisobal * sdk: `sjasmplus` compiler by aprisobal is default now --- sdk/.gitignore | 5 ++ sdk/Makefile | 12 +++- sdk/README.md | 14 +++++ sdk/common.mk | 5 ++ sdk/src/.gitignore | 5 ++ sdk/src/Makefile | 115 ++++++++++++++++++++++++++++++++--- sdk/src/sjasmplus-z00m128.mk | 58 ++++++++++++++++++ sdk/src/sjasmplus.mk | 3 - 8 files changed, 206 insertions(+), 11 deletions(-) create mode 100644 sdk/.gitignore create mode 100644 sdk/src/sjasmplus-z00m128.mk diff --git a/sdk/.gitignore b/sdk/.gitignore new file mode 100644 index 0000000..b7d2960 --- /dev/null +++ b/sdk/.gitignore @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2021 Ivan Tatarinov +# +# SPDX-License-Identifier: CC0-1.0 + +conf.mk diff --git a/sdk/Makefile b/sdk/Makefile index a96011d..7342b5c 100644 --- a/sdk/Makefile +++ b/sdk/Makefile @@ -6,6 +6,8 @@ # * GNU on Linux, FreeBSD etc. # * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) # +# Configure: +# make configure [] # Build: # make [] build | build- # Install: @@ -17,6 +19,8 @@ # make [] distclean | distclean- # # where: +# is a set of parameters of type = +# USE_SJASMPLUS_VERSION: sjasmplus, z00m128 (default). # are these flags: # [BUILD=] [FORCEBUILD=] [FORCECLEAN=] # where values are: @@ -62,8 +66,14 @@ $(TARGETS): | src $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) install-$@ .PHONY:\ - build install uninstall clean distclean\ + configure build install uninstall clean distclean\ $(foreach t,$(TARGETS),build-$(t) install-$(t) uninstall-$(t) clean-$(t) distclean-$(t)) + +configure: + @echo '# This is a local configuration file for Make.' >conf.mk;\ + echo '# This file is generated automatically by `make configure`.' >>conf.mk;\ + echo 'USE_SJASMPLUS_VERSION=$(USE_SJASMPLUS_VERSION)' >>conf.mk + build install uninstall clean distclean \ $(foreach t,$(TARGETS),build-$(t) install-$(t) uninstall-$(t) clean-$(t) distclean-$(t)): | src $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) $@ diff --git a/sdk/README.md b/sdk/README.md index c93451f..26a7e92 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -10,6 +10,7 @@ No one yet. This document is under [GNU FDL-1.3 or later](https://spdx.org/licenses/GFDL-1.3-or-later.html) license. SJAsmPlus Z80 Assembler is distributed under [zlib](https://spdx.org/licenses/Zlib.html) license. +SJAsmPlus Z80 Assembler by aprisobal (*z00m128*) is distributed under [BSD 3-Clause "New" or "Revised"](https://spdx.org/licenses/BSD-3-Clause.html) license. z88dk is distributed under [Clarified Artistic](https://spdx.org/licenses/ClArtistic.html) license. LodePNG C/C++ library is distributed under [zlib](https://spdx.org/licenses/Zlib.html) license. @@ -71,6 +72,8 @@ Go to the project's root directory, enter `sdk` sub-directory and type one of th Command | Description ----|---- +`make configure` | Configure build with default values (on first call) +`make configure ` | Configure build with explicit values `make` | Build and install all tools from sources `make ` | Build and install only the TARGET from sources `make BUILD=` | Cross-build and install all tools from sources for Windows platform @@ -78,6 +81,12 @@ Command | Description where: +`` is a series of parameters of type `=`. + +Value of `` | Possible values | Description +----|----|---- +`USE_SJASMPLUS_VERSION` | `sjasmplus`, `z00m128` | Version of SJAsmPlus Z80 Compiler to use. Default is `z00m128` (aprisobal). + Value of `TARGET` | Origin | Description ----|----|---- `sjasmplus` | downloaded | SJAsmPlus Z80 Assembler @@ -194,6 +203,8 @@ Go to the project's root directory, enter `sdk` sub-directory and type one of th Command | Description ----|---- +`make configure` | Configure build with default values (on first call) +`make configure ` | Configure build with explicit values `make` | **Quick setup** of all tools (download precompiled binaries and install them) `make ` | **Qucik setup** of the TARGET only `make FORCEBUILD=1` | Build and install all tools from sources @@ -201,6 +212,8 @@ Command | Description where: +`` is a series of parameters as described in [2.2](#22-build-tools). + Value of `TARGET` | Sources origin | Binaries origin (**Quick setup**) | Build from sources ----|----|----|---- `sjasmplus` | downloaded | downloaded (**yes**) | available @@ -280,6 +293,7 @@ These changes are actual for current invocation of command shell and all child p * [cmd](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) - command interpreter in Windows * [Windows commands](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands) * [SJAsmPlus](https://github.com/sjasmplus/sjasmplus) - Z80 Assembler +* [SJAsmPlus by aprisobal](https://github.com/z00m128/sjasmplus) - Z80 Assembler * [Z88DK](https://github.com/z88dk/z88dk) - The Development Kit for Z80 Computers * [LodePNG](https://github.com/lvandeve/lodepng) - PNG encoder and decoder in C and C++ * [Open Source FPGA Foundation Formed to Accelerate Widespread Adoption of Programmable Logic](https://osfpga.org/osfpga-foundation-launched/) - news article (April 8, 2021) diff --git a/sdk/common.mk b/sdk/common.mk index 669f321..7ed8b64 100644 --- a/sdk/common.mk +++ b/sdk/common.mk @@ -31,6 +31,11 @@ export PATH endif # !ZXSDK +-include $(ZXSDK)/conf.mk + +# Default values +USE_SJASMPLUS_VERSION ?= z00m128 + ifeq ($(OS),Windows_NT) EXESUFFIX := .exe DLLSUFFIX := .dll diff --git a/sdk/src/.gitignore b/sdk/src/.gitignore index e1b2444..a802977 100644 --- a/sdk/src/.gitignore +++ b/sdk/src/.gitignore @@ -9,6 +9,11 @@ sjasmplus-win32.7z sjasmplus-win32.7z.sha256 sjasmplus-win64.7z sjasmplus-win64.7z.sha256 +sjasmplus-z00m128 +sjasmplus-z00m128-src.tgz +sjasmplus-z00m128-src.tgz.sha256 +sjasmplus-z00m128-win32.zip +sjasmplus-z00m128-win32.zip.sha256 z88dk z88dk-src.tgz z88dk-src.tgz.sha256 diff --git a/sdk/src/Makefile b/sdk/src/Makefile index 92a8b95..86ef448 100644 --- a/sdk/src/Makefile +++ b/sdk/src/Makefile @@ -53,25 +53,24 @@ distclean: $(foreach t,$(TARGETS),distclean-$(t)) _DoBuild:=1 _UsePrecompiledOnWindows:=0 +_DoClean:=1 ifeq ($(OS),Windows_NT) ifneq ($(FORCEBUILD),1) _DoBuild:=0 _UsePrecompiledOnWindows:=1 endif -endif - -_DoClean:=1 -ifeq ($(OS),Windows_NT) ifneq ($(FORCECLEAN),1) _DoClean:=0 endif -endif +endif # $(OS)==Windows_NT # sjasmplus .PHONY: $(foreach a,build install uninstall clean distclean,$(a)-sjasmplus) +ifeq ($(USE_SJASMPLUS_VERSION),sjasmplus) + ifeq ($(_DoBuild),1) build-sjasmplus: | sjasmplus/.extracted sjasmplus.mk @@ -95,14 +94,14 @@ install-sjasmplus: | sjasmplus/.extracted sjasmplus.mk ifeq ($(_DoClean),1) uninstall-sjasmplus: | sjasmplus.mk - if test -f sjasmplus; then\ + if test -d sjasmplus; then\ $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix)) uninstall;\ else\ rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX);\ fi clean-sjasmplus: | sjasmplus.mk - if test -f sjasmplus; then $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk clean; fi + if test -d sjasmplus; then $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk clean; fi else # !_DoClean @@ -176,6 +175,108 @@ distclean-sjasmplus:; endif # !_DoClean +else ifeq ($(USE_SJASMPLUS_VERSION),z00m128) + +ifeq ($(_DoBuild),1) + +build-sjasmplus: | sjasmplus-z00m128/.extracted sjasmplus-z00m128.mk + $(MAKE) -w -C sjasmplus -f ../sjasmplus-z00m128.mk prefix=$(shell realpath --relative-to=sjasmplus-z00m128 $(prefix)) + +sjasmplus-z00m128/.extracted: sjasmplus-z00m128-src.tgz + echo '114807bf53d3526b4d1ae7d40f3050b9ee98220df74931efc1e6d1fe5aba3d02 $<' >$<.sha256 + sha256sum -c $<.sha256 + rm -f $<.sha256 + rm -rf $(@D) sjasmplus-1.18.2 + tar -xzf $< + mv sjasmplus-1.18.2 $(@D) + touch $@ + +sjasmplus-z00m128-src.tgz: + wget -c https://github.com/z00m128/sjasmplus/archive/refs/tags/v1.18.2.tar.gz -O $@ + +install-sjasmplus: | sjasmplus-z00m128/.extracted sjasmplus-z00m128.mk + $(MAKE) -w -C sjasmplus-z00m128 -f ../sjasmplus-z00m128.mk prefix=$(shell realpath --relative-to=sjasmplus-z00m128 $(prefix)) install + +ifeq ($(_DoClean),1) + +uninstall-sjasmplus: | sjasmplus-z00m128.mk + if test -d sjasmplus-z00m128; then\ + $(MAKE) -w -C sjasmplus-z00m128 -f ../sjasmplus-z00m128.mk prefix=$(shell realpath --relative-to=sjasmplus-z00m128 $(prefix)) uninstall;\ + else\ + rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX);\ + fi + +clean-sjasmplus: | sjasmplus-z00m128.mk + if test -d sjasmplus-z00m128; then $(MAKE) -w -C sjasmplus-z00m128 -f ../sjasmplus-z00m128.mk clean; fi + +else # !_DoClean + +uninstall-sjasmplus clean-sjasmplus:; + +endif # !_DoClean +endif # _DoBuild + +ifeq ($(_UsePrecompiledOnWindows),1) + +build-sjasmplus: sjasmplus-z00m128/sjasmplus$(EXESUFFIX) + +sjasmplus-z00m128/sjasmplus$(EXESUFFIX): | sjasmplus-z00m128/.extracted + +SJASMPLUS_ARCHIVE := sjasmplus-z00m128-win32.zip +SJASMPLUS_ARCHIVE_SHA256 := 848bca2522d6febbf3e3c48c634731ecd61899166f5922ed15857e8063c3dc4b + +sjasmplus-z00m128/.extracted: $(SJASMPLUS_ARCHIVE) + echo '$(SJASMPLUS_ARCHIVE_SHA256) $<' >$<.sha256 + sha256sum -c $<.sha256 + rm -f $<.sha256 + rm -rf $(@D) + unzip -nq $< + mv sjasmplus-1.18.2.win $(@D) + touch $@ + +sjasmplus-z00m128-win32.zip: + wget -c https://github.com/z00m128/sjasmplus/releases/download/v1.18.2/sjasmplus-1.18.2.win.zip -O $@ + +install-sjasmplus: $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX) + +$(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX): sjasmplus-z00m128/sjasmplus$(EXESUFFIX) + $(INSTALL_PROGRAM) $< $@ + +ifeq ($(_DoClean),1) + +uninstall-sjasmplus: + rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX) + +clean-sjasmplus: + rm -rf sjasmplus-z00m128 + +else # !_DoClean + +uninstall-sjasmplus clean-sjasmplus:; + +endif # !_DoClean +endif # _UsePrecompiledOnWindows + +ifeq ($(_DoClean),1) + +distclean-sjasmplus: + rm -rf sjasmplus-z00m128 + rm -f\ + sjasmplus-z00m128-src.tgz\ + sjasmplus-z00m128-src.tgz.sha256\ + sjasmplus-z00m128-win32.zip\ + sjasmplus-z00m128-win32.zip.sha256 + +else # !_DoClean + +distclean-sjasmplus:; + +endif # !_DoClean + +else +$(error Unknown SJAsmPlus version selected: `$(USE_SJASMPLUS_VERSION)') +endif + # z88dk .PHONY: $(foreach a,build install uninstall clean distclean,$(a)-z88dk) diff --git a/sdk/src/sjasmplus-z00m128.mk b/sdk/src/sjasmplus-z00m128.mk new file mode 100644 index 0000000..404e428 --- /dev/null +++ b/sdk/src/sjasmplus-z00m128.mk @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2021 Ivan Tatarinov +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Supported environments: +# * GNU on Linux, FreeBSD etc. +# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) +# +# Build: +# make [BUILD=] -w -C sjasmplus-z00m128 -f ../sjasmplus-z00m128.mk +# Install / Uninstall: +# make [BUILD=] [prefix=] -w -C sjasmplus-z00m128 -f ../sjasmplus-z00m128.mk install | uninstall +# Clean: +# make [BUILD=] -w -C sjasmplus-z00m128 -f ../sjasmplus-z00m128.mk clean +# +# where: +# - see included `common.mk'. +# is a prefix directory to install files into. + +include ../../common.mk + +srcdir = . +prefix ?= /usr/local +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin + +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) + +BINS = sjasmplus$(EXESUFFIX) + +.PHONY: all +all: $(foreach t,$(BINS),build/$(t)) + +build\ +$(DESTDIR)$(bindir): + mkdir -p $@ + +sjasmplus$(EXESUFFIX): | Makefile + $(MAKE) clean + $(MAKE) + +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +$(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX): sjasmplus$(EXESUFFIX) | $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) $< $@ + +.PHONY: uninstall +uninstall: + rm -f $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +.PHONY: clean +clean: + $(MAKE) clean + +.PHONY: distclean +distclean: clean diff --git a/sdk/src/sjasmplus.mk b/sdk/src/sjasmplus.mk index bc4794f..70fcc0d 100644 --- a/sdk/src/sjasmplus.mk +++ b/sdk/src/sjasmplus.mk @@ -29,9 +29,6 @@ INSTALL_PROGRAM ?= $(INSTALL) BINS = sjasmplus$(EXESUFFIX) -.PHONY: all -all: $(foreach t,$(BINS),build/$(t)) - ifeq ($(BUILD),mingw32) CMAKEFLAGS := -DCMAKE_TOOLCHAIN_FILE=../Toolchain-mingw32.cmake else ifeq ($(BUILD),mingw64)