diff --git a/sdk/src/Makefile b/sdk/src/Makefile index 5ef4c9a..4fffefc 100644 --- a/sdk/src/Makefile +++ b/sdk/src/Makefile @@ -220,30 +220,30 @@ dist-clean-z88dk: # zx7b -.PHONY: local-zx7b clean-zx7b - -local-zx7b: $(INSTALLDIR)/zx7b$(EXESUFFIX) +.PHONY: local-zx7b clean-zx7b distclean-zx7b ifeq ($(_DoBuild),1) -$(INSTALLDIR)/zx7b$(EXESUFFIX): zx7b/zx7b$(EXESUFFIX) - cp $< $@ - -zx7b/zx7b$(EXESUFFIX): | zx7b - $(MAKE) -w -C $| +local-zx7b: | zx7b + $(MAKE) -w -C $| prefix=../.. install clean-zx7b: | zx7b $(MAKE) -w -C $| clean - rm -f $(INSTALLDIR)/zx7b$(EXESUFFIX) + $(MAKE) -w -C $| prefix=../.. uninstall + +distclean-zx7b: | zx7b + $(MAKE) -w -C $| distclean + $(MAKE) -w -C $| prefix=../.. uninstall else +local-zx7b:; + clean-zx7b:; -endif +distclean-zx7b:; -.PHONY: dist-clean-zx7b -dist-clean-zx7b: clean-zx7b +endif # tools @@ -281,7 +281,7 @@ endif .PHONY: dist-clean ifeq ($(_DoClean),1) -dist-clean: dist-clean-sjasmplus dist-clean-z88dk dist-clean-zx7b distclean-tools +dist-clean: dist-clean-sjasmplus dist-clean-z88dk distclean-zx7b distclean-tools else dist-clean: dist-clean-sjasmplus dist-clean-z88dk endif diff --git a/sdk/src/zx7b/.gitignore b/sdk/src/zx7b/.gitignore index 8a1f2e9..82e29a6 100644 --- a/sdk/src/zx7b/.gitignore +++ b/sdk/src/zx7b/.gitignore @@ -2,5 +2,4 @@ # # SPDX-License-Identifier: CC0-1.0 -zx7b -zx7b.exe +build diff --git a/sdk/src/zx7b/Makefile b/sdk/src/zx7b/Makefile index c2b9b28..1a59830 100644 --- a/sdk/src/zx7b/Makefile +++ b/sdk/src/zx7b/Makefile @@ -7,27 +7,55 @@ # * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) # # Build: -# make [BUILD=] [] +# make [BUILD=] [ ...] +# Install / Uninstall: +# make [BUILD=] [prefix=] install | uninstall # Clean: # make [BUILD=] clean +# make distclean # # where: # is one of: mingw32, mingw64. -# is the value of TARGET variable (see below). +# is one of values for `BINS' variable prefixed with "build/" +# (see target `all' below). +# is a prefix directory to install files into. # # Notes: -# BUILD variable may be set in user's environment. +# `BUILD', `prefix' variables may be set in user's environment. include ../../common.mk -TARGET := zx7b$(EXESUFFIX) +srcdir = . +prefix ?= /usr/local +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin + +BINS = zx7b$(EXESUFFIX) .PHONY: all -all: $(TARGET) +all: $(foreach t,$(BINS),build/$(t)) -%$(EXESUFFIX): %.c Makefile +build\ +$(DESTDIR)$(bindir): + mkdir -p $@ + +build/zx7b$(EXESUFFIX): $(srcdir)/zx7b.c Makefile | build $(CC) $(CFLAGS) -o $@ $< +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +$(DESTDIR)$(bindir)/zx7b$(EXESUFFIX): build/zx7b$(EXESUFFIX) | $(DESTDIR)$(bindir) + cp $< $@ + +.PHONY: uninstall +uninstall: + rm -f $(foreach t,$(BINS),$(DESTDIR)$(exec_prefix)/bin/$(t)) + .PHONY: clean clean: - rm -f $(TARGET) + rm -f $(foreach t,$(BINS),build/$(t)) + +.PHONY: distclean +distclean: + rm -rf build/*