sdk: followed GNU standards in all Makefiles

This commit is contained in:
Ivan Tatarinov 2021-04-27 23:34:18 +03:00
parent dc99eff4e5
commit 6e2f2a1c53
4 changed files with 211 additions and 123 deletions

View File

@ -7,18 +7,30 @@
# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL)
#
# Build:
# make [BUILD=<BUILD>] [FORCEBUILD=<FB_FLAG>] [<TARGET>]
# make [<FLAGS>] build | build-<TARGET>
# Install:
# make [<FLAGS>] [all | <TARGET> | install-<TARGET>]
# Uninstall:
# make [<FLAGS>] uninstall | uninstall-<TARGET>
# Clean:
# make [BUILD=<BUILD>] [FORCECLEAN=<FC_FLAG>] clean
# make [<FLAGS>] clean | clean-<TARGET>
# make [<FLAGS>] distclean | distclean-<TARGET>
#
# where:
# <FLAGS> are these flags:
# [BUILD=<BUILD>] [FORCEBUILD=<FB_FLAG>] [FORCECLEAN=<FC_FLAG>]
# where values are:
# <BUILD> - see included `common.mk'.
# <FB_FLAG> is 1 to force build, otherwise do not (default).
# <FC_FLAG> is 1 to force clean, otherwise do not (default).
# <TARGET> is one of: sjasmplus, z88dk, zx7b, tools
# <TARGET> is one of the values of `TARGETS' variable.
#
# NOTE: `FORCEBUILD' and `FORCECLEAN' are mainly for Windows platform.
include common.mk
prefix ?= .
ifeq ($(BUILD),mingw32)
FORCEBUILD:=1
else ifeq ($(BUILD),mingw64)
@ -40,13 +52,18 @@ export BUILD
export FORCEBUILD
export FORCECLEAN
TARGETS=sjasmplus z88dk zx7b tools
.PHONY: all
all: sjasmplus z88dk zx7b tools
all: install
.PHONY: sjasmplus z88dk zx7b tools
sjasmplus z88dk zx7b tools: | src
$(MAKE) -w -C $| install-$@
.PHONY: $(TARGETS)
$(TARGETS): | src
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) install-$@
.PHONY: clean dist-clean
clean dist-clean: | src
$(MAKE) -w -C $| $@
.PHONY:\
build install uninstall clean distclean\
$(foreach t,$(TARGETS),build-$(t) install-$(t) uninstall-$(t) clean-$(t) distclean-$(t))
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)) $@

View File

@ -40,6 +40,8 @@ Open terminal and type:
# apt install -y build-essential git
```
to install `build-essential` and `git` packages.
**NOTE**: here the first symbol "#" means that the following command must be run as *root* or using `sudo` utility.
Additional packages for targets:
@ -49,11 +51,7 @@ Target | Packages
`sjasmplus` | cmake libboost-all-dev libxml2-dev
`z88dk` | dos2unix libboost-all-dev texinfo texi2html libxml2-dev subversion bison flex zlib1g-dev m4
To use cross-compilation for Windows platform install *mingw-w64* package:
```
# apt install -y mingw-w64
```
To use cross-compilation for Windows platform install *mingw-w64* package.
### 2.1.2. Clone repository
@ -71,10 +69,10 @@ Go to the project's root directory, enter `sdk` sub-directory and type one of th
Command | Description
----|----
`make` | Build all tools from sources
`make <TARGET>` | Build only the TARGET from sources
`make BUILD=<BUILD>` | Cross-build all tools from sources for Windows platform
`make BUILD=<BUILD> <TARGET>` | Cross-build only the TARGET from sources for Windows platform
`make` | Build and install all tools from sources
`make <TARGET>` | Build and install only the TARGET from sources
`make BUILD=<BUILD>` | Cross-build and install all tools from sources for Windows platform
`make BUILD=<BUILD> <TARGET>` | Cross-build and install only the TARGET from sources for Windows platform
where:
@ -90,6 +88,8 @@ Value of `BUILD` | Target system
`mingw32` | Windows with i686 architecture (32-bits)
`mingw64` | Windows with AMD64 architecture (64-bits)
Compiled binaries are installed into `bin` sub-directory.
Example:
```bash
@ -102,24 +102,24 @@ Then you may use `strip` tool to strip debug information from file and thus shri
strip bin/*.exe
```
For more options see [`Makefile`](Makefile).
## 2.3. Clean tools
Go to the project's root directory, enter `sdk` sub-directory and type one of the following commands:
Command | Description
----|----
`make uninstall` | remove installed binaries
`make clean` | clean after compilation from sources
`make dist-clean` | acts like `clean` but also removes temporary and downloaded files
`make distclean` | acts like `clean` but also remove temporary and downloaded files
`make BUILD=<BUILD> uninstall` | remove installed binaries for Windows platform
`make BUILD=<BUILD> clean` | clean after compilation from sources for Windows platform
`make BUILD=<BUILD> dist-clean` | acts like `clean` for Windows platform but also removes temporary and downloaded files
`make BUILD=<BUILD> distclean` | acts like `clean` for Windows platform but also remove temporary and downloaded files
Value of `BUILD` is described in [2.2](#22-build-tools).
Example:
```bash
make BUILD=mingw64 clean
```
For more options see [`Makefile`](Makefile).
## 2.4. Tools usage
@ -190,19 +190,19 @@ Go to the project's root directory, enter `sdk` sub-directory and type one of th
Command | Description
----|----
`make` | Quick setup of all tools
`make <TARGET>` | Qucik setup of the TARGET only
`make FORCEBUILD=1` | Build all tools from sources
`make FORCEBUILD=1 <TARGET>` | Build only the TARGET from sources
`make` | **Quick setup** of all tools (download precompiled binaries and install them)
`make <TARGET>` | **Qucik setup** of the TARGET only
`make FORCEBUILD=1` | Build and install all tools from sources
`make FORCEBUILD=1 <TARGET>` | Build and install only the TARGET from sources
where:
Value of `TARGET` | Origin | Quick setup | Build from sources
Value of `TARGET` | Sources origin | Binaries origin (**Quick setup**) | Build from sources
----|----|----|----
`sjasmplus` | downloaded | available | available
`z88dk` | downloaded | available | available
`zx7b` | `src/zx7b` | N/A | available
`tools` | `src/tools` | N/A | available
`sjasmplus` | downloaded | downloaded (**yes**) | available
`z88dk` | downloaded | downloaded (**yes**) | available
`zx7b` | local | precompiled locally (**no**) | available
`tools` | local | precompiled locally (**no**) | available
Then you may use `strip` tool to strip debug information from file and thus shrink file's size. Example:
@ -210,22 +210,22 @@ Then you may use `strip` tool to strip debug information from file and thus shri
strip bin/*.exe
```
For more options see [`Makefile`](Makefile).
## 3.3. Clean tools
Go to the project's root directory, enter `sdk` sub-directory and type one of the following commands:
Command | Description
----|----
`make clean` | removes downloaded precompiled binaries only
`make dist-clean` | acts as `clean` but also removes temporary and downloaded files
`make FORCECLEAN=1 clean` | clean after compilation from sources
`make FORCECLEAN=1 dist-clean` | acts as forced `clean` but also removes temporary and downloaded files
`make FORCECLEAN=1 uninstall` | remove installed binaries from SDK after quick setup
`make FORCECLEAN=1 clean` | clean sources from downloaded binaries after quick setup
`make FORCECLEAN=1 distclean` | acts as forced `clean` but also removes temporary and downloaded files
`make FORCEBUILD=1 FORCECLEAN=1 uninstall` | remove all installed binaries from SDK
`make FORCEBUILD=1 FORCECLEAN=1 clean` | clean SDK after compilation from sources
`make FORCEBUILD=1 FORCECLEAN=1 distclean` | acts as forced `clean` after compilation from sources but also removes temporary and downloaded files
Example:
```bash
make FORCECLEAN=1 clean
```
For more options see [`Makefile`](Makefile).
## 3.4. Tools usage

View File

@ -7,19 +7,25 @@
# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL)
#
# Build:
# make [BUILD=<BUILD>] [FORCEBUILD=<FB_FLAG>] [install-<TARGET>]
# make [<FLAGS>] build | build-<TARGET>
# Install:
# make [<FLAGS>] [all | install | install-<TARGET>]
# Uninstall:
# make [<FLAGS>] uninstall | uninstall-<TARGET>
# Clean:
# make [BUILD=<BUILD>] [FORCECLEAN=<FC_FLAG>] clean|dist-clean
# make [<FLAGS>] clean | clean-<TARGET>
# make [<FLAGS>] distclean | distclean-<TARGET>
#
# where:
# <FLAGS> are:
# [BUILD=<BUILD>] [FORCEBUILD=<FB_FLAG>] [FORCECLEAN=<FC_FLAG>]
# where values are:
# <BUILD> - see included `common.mk'.
# <FB_FLAG> is 1 to force build, otherwise do not (default).
# <FC_FLAG> is 1 to force clean, otherwise do not (default).
# <TARGET> is one of:
# * sjasmplus
# * z88dk
# * zx7b
# * tools
# <TARGET> is one of the values of `TARGETS' variable.
#
# NOTE: `FORCEBUILD' and `FORCECLEAN' are mainly for Windows platform.
include ../common.mk
@ -30,12 +36,19 @@ bindir ?= $(exec_prefix)/bin
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL)
.PHONY: all
all:\
install-sjasmplus\
install-z88dk\
install-zx7b\
install-tools
TARGETS=\
sjasmplus\
z88dk\
zx7b\
tools
.PHONY: all build install uninstall clean distclean
all: install
build: $(foreach t,$(TARGETS),build-$(t))
install: $(foreach t,$(TARGETS),install-$(t))
uninstall: $(foreach t,$(TARGETS),uninstall-$(t))
clean: $(foreach t,$(TARGETS),clean-$(t))
distclean: $(foreach t,$(TARGETS),distclean-$(t))
_DoBuild:=1
_UsePrecompiledOnWindows:=0
@ -56,12 +69,12 @@ endif
# sjasmplus
.PHONY: install-sjasmplus clean-sjasmplus
.PHONY: $(foreach a,build install uninstall clean distclean,$(a)-sjasmplus)
ifeq ($(_DoBuild),1)
install-sjasmplus: | sjasmplus/.extracted sjasmplus.mk
$(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix)) install
build-sjasmplus: | sjasmplus/.extracted sjasmplus.mk
$(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix))
sjasmplus/.extracted: sjasmplus-src.tgz
echo 'f3f6d28af19880ed2cb427b6b427e9bd42371929c7d263dac840fb71de1302d6 $<' >$<.sha256
@ -75,18 +88,31 @@ sjasmplus/.extracted: sjasmplus-src.tgz
sjasmplus-src.tgz:
wget -c https://github.com/sjasmplus/sjasmplus/archive/refs/tags/20190306.1.tar.gz -O $@
clean-sjasmplus: | sjasmplus.mk
if test -d sjasmplus; then $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk clean; fi
if test -d sjasmplus; then $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix)) uninstall; fi
install-sjasmplus: | sjasmplus/.extracted sjasmplus.mk
$(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix)) install
endif
ifeq ($(_DoClean),1)
uninstall-sjasmplus: | sjasmplus.mk
if test -f 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
else # !_DoClean
uninstall-sjasmplus clean-sjasmplus:;
endif # !_DoClean
endif # _DoBuild
ifeq ($(_UsePrecompiledOnWindows),1)
install-sjasmplus: $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX)
$(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX): sjasmplus/sjasmplus$(EXESUFFIX)
$(INSTALL_PROGRAM) $< $@
build-sjasmplus: sjasmplus/sjasmplus$(EXESUFFIX)
sjasmplus/sjasmplus$(EXESUFFIX): | sjasmplus/.extracted
@ -112,16 +138,29 @@ sjasmplus-win32.7z:
sjasmplus-win64.7z:
wget -c https://github.com/sjasmplus/sjasmplus/releases/download/20190306.1/sjasmplus-win64-20190306.1.7z -O $@
install-sjasmplus: $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX)
$(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX): sjasmplus/sjasmplus$(EXESUFFIX)
$(INSTALL_PROGRAM) $< $@
ifeq ($(_DoClean),1)
uninstall-sjasmplus:
rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX)
clean-sjasmplus:
rm -rf sjasmplus
rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX)
endif
else # !_DoClean
.PHONY: distclean-sjasmplus
distclean-sjasmplus:
rm -rf sjasmplus
rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX)
uninstall-sjasmplus clean-sjasmplus:;
endif # !_DoClean
endif # _UsePrecompiledOnWindows
ifeq ($(_DoClean),1)
distclean-sjasmplus: clean-sjasmplus
rm -f\
sjasmplus-src.tgz\
sjasmplus-src.tgz.sha256\
@ -130,11 +169,17 @@ distclean-sjasmplus:
sjasmplus-win64.7z\
sjasmplus-win64.7z.sha256
else # !_DoClean
distclean-sjasmplus:;
endif # !_DoClean
# z88dk
.PHONY: install-z88dk clean-z88dk
.PHONY: $(foreach a,build install uninstall clean distclean,$(a)-z88dk)
Z88DK_TARGETS:=\
Z88DK_BINS:=\
asmpp.pl\
sccz80$(EXESUFFIX)\
z80asm$(EXESUFFIX)\
@ -156,7 +201,7 @@ Z88DK_TARGETS:=\
z88dk-zx7$(EXESUFFIX)\
zcc$(EXESUFFIX)
install-z88dk: z88dk/.done
build-z88dk install-z88dk: z88dk/.done
ifeq ($(_DoBuild),1)
@ -167,7 +212,7 @@ endif
z88dk/.done: | z88dk/.extracted z88dk.mk
$(MAKE) -w -C z88dk -f ../z88dk.mk
cd z88dk/bin && test x $(patsubst %,-a -x %,$(Z88DK_TARGETS))
cd z88dk/bin && test x $(patsubst %,-a -x %,$(Z88DK_BINS))
touch $@
z88dk/.extracted: z88dk-src.tgz
@ -182,13 +227,22 @@ z88dk/.extracted: z88dk-src.tgz
z88dk-src.tgz:
wget -c https://github.com/z88dk/z88dk/releases/download/v2.1/z88dk-src-2.1.tgz -O $@
uninstall-z88dk:;
ifeq ($(_DoClean),1)
# This does not work:
#clean-z88dk: | z88dk.mk
# if test -d z88dk; then $(MAKE) -w -C z88dk -f ../z88dk.mk clean && rm -f z88dk/.done; fi
clean-z88dk:
rm -rf z88dk
endif
else # !_DoClean
clean-z88dk:;
endif # !_DoClean
endif # _DoBuild
ifeq ($(_UsePrecompiledOnWindows),1)
@ -203,84 +257,101 @@ z88dk/.done: z88dk-win32.zip
z88dk-win32.zip:
wget -c https://github.com/z88dk/z88dk/releases/download/v2.1/z88dk-win32-2.1.zip -O $@
uninstall-z88dk:;
ifeq ($(_DoClean),1)
clean-z88dk:
rm -rf z88dk
endif
else # !_DoClean
.PHONY: dist-clean-z88dk
dist-clean-z88dk:
rm -rf z88dk
clean-z88dk:;
endif # !_DoClean
endif # _UsePrecompiledOnWindows
ifeq ($(_DoClean),1)
distclean-z88dk: clean-z88dk
rm -f\
z88dk-src.tgz\
z88dk-src.tgz.sha256\
z88dk-win32.zip\
z88dk-win32.zip.sha256
else # !_DoClean
distclean-z88dk:;
endif # !_DoClean
# zx7b
.PHONY: install-zx7b clean-zx7b distclean-zx7b
.PHONY: $(foreach a,build install uninstall clean distclean,$(a)-zx7b)
ifeq ($(_DoBuild),1)
build-zx7b: | zx7b
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix))
install-zx7b: | zx7b
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) install
else # !_DoBuild
build-zx7b install-zx7b:;
endif # !_DoBuild
ifeq ($(_DoClean),1)
uninstall-zx7b: | zx7b
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall
clean-zx7b: | zx7b
$(MAKE) -w -C $| clean
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall
distclean-zx7b: | zx7b
$(MAKE) -w -C $| distclean
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall
else
else # !_DoClean
install-zx7b:;
uninstall-zx7b clean-zx7b distclean-zx7b:;
clean-zx7b:;
distclean-zx7b:;
endif
endif # !_DoClean
# tools
.PHONY: install-tools clean-tools distclean-tools
.PHONY: $(foreach a,build install uninstall clean distclean,$(a)-tools)
ifeq ($(_DoBuild),1)
build-tools: | tools
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix))
install-tools: | tools
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) install
else # !_DoBuild
build-tools install-tools:;
endif # !_DoBuild
ifeq ($(_DoClean),1)
uninstall-tools: | tools
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall
clean-tools: | tools
$(MAKE) -w -C $| clean
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall
distclean-tools: | tools
$(MAKE) -w -C $| distclean
$(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall
else
else # !_DoClean
install-tools:;
uninstall-tools clean-tools distclean-tools:;
clean-tools:;
distclean-tools:;
endif
.PHONY: clean
ifeq ($(_DoClean),1)
clean: clean-sjasmplus clean-z88dk clean-zx7b clean-tools
else
clean: clean-sjasmplus clean-z88dk
endif
.PHONY: dist-clean
ifeq ($(_DoClean),1)
dist-clean: distclean-sjasmplus dist-clean-z88dk distclean-zx7b distclean-tools
else
dist-clean: distclean-sjasmplus dist-clean-z88dk
endif
endif # !_DoClean

View File

@ -9,13 +9,10 @@
# Build:
# make [BUILD=<BUILD>] -w -C z88dk -f ../z88dk.mk
# Clean:
# make [BUILD=<BUILD>] -w -C z88dk -f ../z88dk.mk clean
# make [BUILD=<BUILD>] -w -C z88dk -f ../z88dk.mk clean | distclean
#
# where:
# <BUILD> is one of: mingw32, mingw64.
#
# Notes:
# BUILD variable may be set in user's environment.
include ../../common.mk
@ -24,7 +21,10 @@ all: | build.sh
chmod 777 $|
./build.sh
.PHONY: clean
clean: | build.sh
.PHONY: install uninstall
install uninstall:;
.PHONY: clean distclean
clean distclean: | build.sh
chmod 777 $|
./build.sh -C