diff --git a/Makefile b/Makefile index b039a09..7b02406 100644 --- a/Makefile +++ b/Makefile @@ -15,30 +15,19 @@ include sdk/common.mk -INSTALL_DIR=SD +# Use uppercase for FAT filesystem +prefix ?= SD +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/BIN -UTILS_TARGETS=\ - BACK16M\ - BACKZX2\ - BACKZXD\ - BACKUP\ - CORCLEAN\ - COREBIOS\ - ROMSBACK\ - ROMSUPGR\ - UPGR16M\ - UPGRZX2\ - UPGRZXD\ - UPGRADE - -UTILS_INSTALL_DIR=$(INSTALL_DIR)/BIN +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) +RM = rm -f SOFTWARE_TARGETS=\ ESPRST\ IWCONFIG -SOFTWARE_INSTALL_DIR=$(INSTALL_DIR)/BIN - .PHONY: all all:\ install-utils\ @@ -48,36 +37,27 @@ all:\ # utils .PHONY: install-utils -install-utils: $(foreach t,$(UTILS_TARGETS),$(UTILS_INSTALL_DIR)/$(t)) | utils - -# $1 = target -define utils_rule = -$$(UTILS_INSTALL_DIR)/$1: utils/build/$1 | utils - mv $$< $$@ -utils/build/$1: | utils - $$(MAKE) -w -C $$| build/$$(@F) -endef - -$(foreach t,$(UTILS_TARGETS),$(eval $(call utils_rule,$(t)))) +install-utils: | utils + $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) install .PHONY: clean-utils clean-utils: | utils $(MAKE) -w -C $| clean .PHONY: uninstall-utils -uninstall-utils: clean-utils - rm -f $(foreach t,$(UTILS_TARGETS),$(UTILS_INSTALL_DIR)/$(t)) +uninstall-utils: clean-utils | utils + $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) uninstall # software .PHONY: install-software -install-software: $(foreach t,$(SOFTWARE_TARGETS),$(SOFTWARE_INSTALL_DIR)/$(t)) +install-software: $(foreach t,$(SOFTWARE_TARGETS),$(DESTDIR)$(bindir)/$(t)) -$(SOFTWARE_INSTALL_DIR)/ESPRST: software/esprst/esprst - mv $< $@ +$(DESTDIR)$(bindir)/ESPRST: software/esprst/esprst + $(INSTALL) $< $@ -$(SOFTWARE_INSTALL_DIR)/IWCONFIG: software/iwconfig/IWCONFIG - mv $< $@ +$(DESTDIR)$(bindir)/IWCONFIG: software/iwconfig/IWCONFIG + $(INSTALL) $< $@ software/esprst/esprst: | software/esprst $(MAKE) -w -C $| @@ -94,7 +74,7 @@ clean-software: |\ .PHONY: uninstall-software uninstall-software: clean-software - rm -f $(foreach t,$(SOFTWARE_TARGETS),$(SOFTWARE_INSTALL_DIR)/$(t)) + $(RM) $(foreach t,$(SOFTWARE_TARGETS),$(DESTDIR)$(bindir)/$(t)) # clean diff --git a/sdk/LICENSES/Unlicense.txt b/sdk/LICENSES/Unlicense.txt new file mode 100644 index 0000000..cde4ac6 --- /dev/null +++ b/sdk/LICENSES/Unlicense.txt @@ -0,0 +1,10 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/utils/Print.inc b/sdk/include/Print.inc similarity index 100% rename from utils/Print.inc rename to sdk/include/Print.inc diff --git a/utils/rdflsh.inc b/sdk/include/rdflsh.inc similarity index 100% rename from utils/rdflsh.inc rename to sdk/include/rdflsh.inc diff --git a/utils/rst28.inc b/sdk/include/rst28.inc similarity index 100% rename from utils/rst28.inc rename to sdk/include/rst28.inc diff --git a/utils/wrflsh.inc b/sdk/include/wrflsh.inc similarity index 100% rename from utils/wrflsh.inc rename to sdk/include/wrflsh.inc diff --git a/utils/Makefile b/utils/Makefile index 4fa787f..3c7de30 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -1,24 +1,48 @@ +# 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 +# make [ ...] +# Install / Uninstall: +# make [prefix=] install | uninstall # Clean: -# make clean +# make clean | distclean # -# SPDX-FileCopyrightText: 2021 Ivan Tatarinov -# -# SPDX-License-Identifier: GPL-3.0-or-later +# where: +# is one of values for `BINS' variable prefixed with "build/" +# (see target `all' below). +# is a prefix directory to install files into. include ../sdk/common.mk -INC_DIR = ../sdk/include -BUILD_DIR = build -AS = sjasmplus -AFLAGS = --nobanner -I$(INC_DIR) +srcdir = . +# Use uppercase for FAT filesystem +prefix ?= . +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/BIN -TARGETS=\ +# Disable execution mode for FAT filesystem +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) -m 644 +RM = rm -f + +INCLUDEDIR = ../sdk/include +AS = sjasmplus +ifeq ($(USE_SJASMPLUS_VERSION),sjasmplus) +AFLAGS = --nobanner +else ifeq ($(USE_SJASMPLUS_VERSION),z00m128) +AFLAGS = --nologo +else +AFLAGS = +endif +AFLAGS += -I$(INCLUDEDIR) + +BINS=\ BACK16M\ BACKZX2\ BACKZXD\ @@ -32,131 +56,155 @@ TARGETS=\ UPGRZXD\ UPGRADE -.PHONY: all -all: $(foreach t,$(TARGETS),$(BUILD_DIR)/$(t)) +TMPS=\ + back32m.def\ + upgr32m.def -$(BUILD_DIR): +.PHONY: all +all: $(foreach t,$(BINS),build/$(t)) + +build\ +$(DESTDIR)$(bindir): mkdir -p $@ -$(BUILD_DIR)/BACK16M: back16m.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/BACK16M: $(srcdir)/back16m.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/BACKZX2: back32m.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/BACKZX2: $(srcdir)/back32m.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build echo ' define zxdos 1' >back32m.def $(AS) $(AFLAGS) --raw=$@ $< rm -f back32m.def -$(BUILD_DIR)/BACKZXD: back32m.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/BACKZXD: $(srcdir)/back32m.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build echo ' define zxdos 0' >back32m.def $(AS) $(AFLAGS) --raw=$@ $< rm -f back32m.def -$(BUILD_DIR)/BACKUP: backup.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/BACKUP: $(srcdir)/backup.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/CORCLEAN: corclean.asm\ - $(INC_DIR)/zxuno.def\ - Print.inc\ - rdflsh.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/CORCLEAN: $(srcdir)/corclean.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/COREBIOS: corebios.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/COREBIOS: $(srcdir)/corebios.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/ROMSBACK: romsback.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/ROMSBACK: $(srcdir)/romsback.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/ROMSUPGR: romsupgr.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - rdflsh.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/ROMSUPGR: $(srcdir)/romsupgr.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/rdflsh.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/UPGR16M: upgr16m.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/UPGR16M: $(srcdir)/upgr16m.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< -$(BUILD_DIR)/UPGRZX2: upgr32m.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/UPGRZX2: $(srcdir)/upgr32m.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build echo ' define zxdos 1' >upgr32m.def $(AS) $(AFLAGS) --raw=$@ $< rm -f upgr32m.def -$(BUILD_DIR)/UPGRZXD: upgr32m.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/UPGRZXD: $(srcdir)/upgr32m.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build echo ' define zxdos 0' >upgr32m.def $(AS) $(AFLAGS) --raw=$@ $< rm -f upgr32m.def -$(BUILD_DIR)/UPGRADE: upgrade.asm\ - $(INC_DIR)/zxuno.def\ - $(INC_DIR)/esxdos.def\ - Print.inc\ - wrflsh.inc\ - rst28.inc\ - | $(BUILD_DIR) +build/UPGRADE: $(srcdir)/upgrade.asm\ + $(INCLUDEDIR)/zxuno.def\ + $(INCLUDEDIR)/esxdos.def\ + $(INCLUDEDIR)/Print.inc\ + $(INCLUDEDIR)/wrflsh.inc\ + $(INCLUDEDIR)/rst28.inc\ + | build $(AS) $(AFLAGS) --raw=$@ $< +# $1 = target +define install_bin_rule = +$$(DESTDIR)$$(bindir)/$1: build/$1 | $$(DESTDIR)$$(bindir) + $$(INSTALL_PROGRAM) $$< $$@ +endef + +$(foreach t,$(BINS),$(eval $(call install_bin_rule,$(t)))) + +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +.PHONY: uninstall +uninstall: + $(RM) $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + .PHONY: clean clean: - rm -f back32m.def upgr32m.def - rm -f $(foreach t,$(TARGETS),$(BUILD_DIR)/$(t)) + rm -f $(TMPS) $(foreach t,$(BINS),build/$(t)) + +.PHONY: distclean +distclean: + rm -f $(TMPS) + rm -rf build/*