From cbacdd5d66afbfd363f01a441b40ef2dbf1b0c57 Mon Sep 17 00:00:00 2001 From: Ivan Tatarinov Date: Tue, 27 Apr 2021 18:09:02 +0300 Subject: [PATCH] sdk: followed GNU standards in `src/sjasmplus.mk` --- sdk/Makefile | 15 ++----- sdk/src/Makefile | 91 +++++++++++++++++++++--------------------- sdk/src/sjasmplus.mk | 45 +++++++++++++++++---- sdk/src/tools/Makefile | 2 +- sdk/src/zx7b/Makefile | 2 +- 5 files changed, 89 insertions(+), 66 deletions(-) diff --git a/sdk/Makefile b/sdk/Makefile index 8ede995..c05395e 100644 --- a/sdk/Makefile +++ b/sdk/Makefile @@ -12,13 +12,10 @@ # make [BUILD=] [FORCECLEAN=] clean # # where: -# is one of: mingw32, mingw64. +# - see included `common.mk'. # is 1 to force build, otherwise do not (default). # is 1 to force clean, otherwise do not (default). # is one of: sjasmplus, z88dk, zx7b, tools -# -# Notes: -# BUILD, FORCEBUILD, FORCECLEAN variables may be set in user's environment. include common.mk @@ -46,13 +43,9 @@ export FORCECLEAN .PHONY: all all: sjasmplus z88dk zx7b tools -.PHONY: sjasmplus z88dk -sjasmplus z88dk: | src - $(MAKE) -w -C $| external-$@ - -.PHONY: zx7b tools -zx7b tools: | src - $(MAKE) -w -C $| local-$@ +.PHONY: sjasmplus z88dk zx7b tools +sjasmplus z88dk zx7b tools: | src + $(MAKE) -w -C $| install-$@ .PHONY: clean dist-clean clean dist-clean: | src diff --git a/sdk/src/Makefile b/sdk/src/Makefile index 4fffefc..321e818 100644 --- a/sdk/src/Makefile +++ b/sdk/src/Makefile @@ -7,33 +7,35 @@ # * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) # # Build: -# make [BUILD=] [FORCEBUILD=] [] +# make [BUILD=] [FORCEBUILD=] [install-] # Clean: # make [BUILD=] [FORCECLEAN=] clean|dist-clean # # where: -# is one of: mingw32, mingw64. +# - see included `common.mk'. # is 1 to force build, otherwise do not (default). # is 1 to force clean, otherwise do not (default). # is one of: -# * external-sjasmplus -# * external-z88dk -# * local-zx7b -# * local-tools -# -# Notes: -# BUILD, FORCEBUILD, FORCECLEAN variables may be set in user's environment. +# * sjasmplus +# * z88dk +# * zx7b +# * tools include ../common.mk -INSTALLDIR=../bin +prefix ?= .. +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin + +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) .PHONY: all all:\ - external-sjasmplus\ - external-z88dk\ - local-zx7b\ - local-tools + install-sjasmplus\ + install-z88dk\ + install-zx7b\ + install-tools _DoBuild:=1 _UsePrecompiledOnWindows:=0 @@ -54,17 +56,12 @@ endif # sjasmplus -.PHONY: external-sjasmplus clean-sjasmplus - -external-sjasmplus: $(INSTALLDIR)/sjasmplus$(EXESUFFIX) +.PHONY: install-sjasmplus clean-sjasmplus ifeq ($(_DoBuild),1) -$(INSTALLDIR)/sjasmplus$(EXESUFFIX): sjasmplus/build/sjasmplus$(EXESUFFIX) - cp $< $@ - -sjasmplus/build/sjasmplus$(EXESUFFIX): | sjasmplus/.extracted sjasmplus.mk - $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk +install-sjasmplus: | sjasmplus/.extracted sjasmplus.mk + $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix)) install sjasmplus/.extracted: sjasmplus-src.tgz echo 'f3f6d28af19880ed2cb427b6b427e9bd42371929c7d263dac840fb71de1302d6 $<' >$<.sha256 @@ -78,16 +75,18 @@ 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: +clean-sjasmplus: | sjasmplus.mk if test -d sjasmplus; then $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk clean; fi - rm -f $(INSTALLDIR)/sjasmplus$(EXESUFFIX) + if test -d sjasmplus; then $(MAKE) -w -C sjasmplus -f ../sjasmplus.mk prefix=$(shell realpath --relative-to=sjasmplus $(prefix)) uninstall; fi endif ifeq ($(_UsePrecompiledOnWindows),1) -$(INSTALLDIR)/sjasmplus$(EXESUFFIX): sjasmplus/sjasmplus$(EXESUFFIX) - cp $< $@ +install-sjasmplus: $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX) + +$(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX): sjasmplus/sjasmplus$(EXESUFFIX) + $(INSTALL_PROGRAM) $< $@ sjasmplus/sjasmplus$(EXESUFFIX): | sjasmplus/.extracted @@ -115,14 +114,14 @@ sjasmplus-win64.7z: clean-sjasmplus: rm -rf sjasmplus - rm -f $(INSTALLDIR)/sjasmplus$(EXESUFFIX) + rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX) endif -.PHONY: dist-clean-sjasmplus -dist-clean-sjasmplus: +.PHONY: distclean-sjasmplus +distclean-sjasmplus: rm -rf sjasmplus - rm -f $(INSTALLDIR)/sjasmplus$(EXESUFFIX) + rm -f $(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX) rm -f\ sjasmplus-src.tgz\ sjasmplus-src.tgz.sha256\ @@ -133,7 +132,7 @@ dist-clean-sjasmplus: # z88dk -.PHONY: external-z88dk clean-z88dk +.PHONY: install-z88dk clean-z88dk Z88DK_TARGETS:=\ asmpp.pl\ @@ -157,7 +156,7 @@ Z88DK_TARGETS:=\ z88dk-zx7$(EXESUFFIX)\ zcc$(EXESUFFIX) -external-z88dk: z88dk/.done +install-z88dk: z88dk/.done ifeq ($(_DoBuild),1) @@ -220,24 +219,24 @@ dist-clean-z88dk: # zx7b -.PHONY: local-zx7b clean-zx7b distclean-zx7b +.PHONY: install-zx7b clean-zx7b distclean-zx7b ifeq ($(_DoBuild),1) -local-zx7b: | zx7b - $(MAKE) -w -C $| prefix=../.. install +install-zx7b: | zx7b + $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) install clean-zx7b: | zx7b $(MAKE) -w -C $| clean - $(MAKE) -w -C $| prefix=../.. uninstall + $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall distclean-zx7b: | zx7b $(MAKE) -w -C $| distclean - $(MAKE) -w -C $| prefix=../.. uninstall + $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall else -local-zx7b:; +install-zx7b:; clean-zx7b:; @@ -247,24 +246,24 @@ endif # tools -.PHONY: local-tools clean-tools distclean-tools +.PHONY: install-tools clean-tools distclean-tools ifeq ($(_DoBuild),1) -local-tools: | tools - $(MAKE) -w -C $| prefix=../.. install +install-tools: | tools + $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) install clean-tools: | tools $(MAKE) -w -C $| clean - $(MAKE) -w -C $| prefix=../.. uninstall + $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall distclean-tools: | tools $(MAKE) -w -C $| distclean - $(MAKE) -w -C $| prefix=../.. uninstall + $(MAKE) -w -C $| prefix=$(shell realpath --relative-to=$| $(prefix)) uninstall else -local-tools:; +install-tools:; clean-tools:; @@ -281,7 +280,7 @@ endif .PHONY: dist-clean ifeq ($(_DoClean),1) -dist-clean: dist-clean-sjasmplus dist-clean-z88dk distclean-zx7b distclean-tools +dist-clean: distclean-sjasmplus dist-clean-z88dk distclean-zx7b distclean-tools else -dist-clean: dist-clean-sjasmplus dist-clean-z88dk +dist-clean: distclean-sjasmplus dist-clean-z88dk endif diff --git a/sdk/src/sjasmplus.mk b/sdk/src/sjasmplus.mk index 0bf51de..bc4794f 100644 --- a/sdk/src/sjasmplus.mk +++ b/sdk/src/sjasmplus.mk @@ -8,17 +8,30 @@ # # Build: # make [BUILD=] -w -C sjasmplus -f ../sjasmplus.mk +# Install / Uninstall: +# make [BUILD=] [prefix=] -w -C sjasmplus -f ../sjasmplus.mk install | uninstall # Clean: # make [BUILD=] -w -C sjasmplus -f ../sjasmplus.mk clean # # where: -# is one of: mingw32, mingw64. -# -# Notes: -# BUILD variable may be set in user's environment. +# - 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)) + ifeq ($(BUILD),mingw32) CMAKEFLAGS := -DCMAKE_TOOLCHAIN_FILE=../Toolchain-mingw32.cmake else ifeq ($(BUILD),mingw64) @@ -27,15 +40,33 @@ else CMAKEFLAGS := endif +.PHONY: all +all: $(foreach t,$(BINS),build/$(t)) + +build\ +$(DESTDIR)$(bindir): + mkdir -p $@ + build/sjasmplus$(EXESUFFIX): | build/Makefile $(MAKE) -w -C build build/Makefile: | build cd $| && cmake $(CMAKEFLAGS) .. -build: - mkdir $@ +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +$(DESTDIR)$(bindir)/sjasmplus$(EXESUFFIX): build/sjasmplus$(EXESUFFIX) | $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) $< $@ + +.PHONY: uninstall +uninstall: + rm -f $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) .PHONY: clean clean: - rm -rf build + rm -f $(foreach t,$(BINS),build/$(t)) + +.PHONY: distclean +distclean: + rm -rf build/* diff --git a/sdk/src/tools/Makefile b/sdk/src/tools/Makefile index e616bba..535d941 100644 --- a/sdk/src/tools/Makefile +++ b/sdk/src/tools/Makefile @@ -63,7 +63,7 @@ $(foreach t,$(BINS),$(eval $(call install_bin_rule,$(t)))) .PHONY: uninstall uninstall: - rm -f $(foreach t,$(BINS),$(DESTDIR)$(exec_prefix)/bin/$(t)) + rm -f $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) .PHONY: clean clean: diff --git a/sdk/src/zx7b/Makefile b/sdk/src/zx7b/Makefile index 3fdcdd8..8799501 100644 --- a/sdk/src/zx7b/Makefile +++ b/sdk/src/zx7b/Makefile @@ -50,7 +50,7 @@ $(DESTDIR)$(bindir)/zx7b$(EXESUFFIX): build/zx7b$(EXESUFFIX) | $(DESTDIR)$(bindi .PHONY: uninstall uninstall: - rm -f $(foreach t,$(BINS),$(DESTDIR)$(exec_prefix)/bin/$(t)) + rm -f $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) .PHONY: clean clean: