msxbuild/lib/make/mb_msxhub.mk

50 lines
2.4 KiB
Makefile

MB_CACHE ?=~/.cache
MB_MSXHUB_API ?= https://msxhub.com/api
MB_MSXHUB_CACHE ?= $(MB_CACHE)/msxhub/repro-v0
MB_MSXHUB_WGET ?= wget
# NOTE: with HDD import/export we get duplicate files after openMSX run, so force to lowercase.
define _mb_lowercase
$(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(1)))))))))))))))))))))))))))
endef
define _mb_msxhub_file_fetch
@echo === Fetch msxhub file
$(if $(wildcard $(dir $(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(1)))),,$(call mb_mkdir,$(dir $(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(1)))))
$(if $(wildcard $(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(1))),,$(MB_MSXHUB_WGET) -O $(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(1)) $(1))
endef
define mb_msxhub_file
$(if $(wildcard $(MB_MSXHUB_CACHE)/$(2)),,$(call _mb_msxhub_file_fetch,$(MB_MSXHUB_API)/$(2)))
$(if $(wildcard $(1)/$(call _mb_lowercase,$(notdir $(2)))),,$(call mb_copy,$(MB_MSXHUB_CACHE)/$(2),$(1)/$(call _mb_lowercase,$(notdir $(2)))))
$(if $(filter true,$(3)),$(call mb_copy,$(MB_MSXHUB_CACHE)/$(2),$(1)/$(call _mb_lowercase,$(notdir $(2)))))
endef
define mb_msxhub_get_dos1
$(call mb_msxhub_file,$(1),MSXDOS1/1.03-2/get/MSXDOS1/MSXDOS.SYS)
$(call mb_msxhub_file,$(1),MSXDOS1/1.03-2/get/MSXDOS1/COMMAND.COM)
endef
define mb_msxhub_get_dos2
$(call mb_msxhub_file,$(1),MSXDOS2/2.20-1/get/MSXDOS2/MSXDOS2.SYS)
#$(call mb_msxhub_file,$(1),MSXDOS2/2.20-1/get/MSXDOS2/COMMAND2.COM)
$(call mb_msxhub_file,$(1),NEXTOR/2.1.0-1/get/NEXTOR/COMMAND2.COM)
endef
define mb_msxhub_get_nextor
$(call mb_msxhub_file,$(1),MSXDOS2/2.20-1/get/MSXDOS2/MSXDOS2.SYS)
#$(call mb_msxhub_file,$(1),MSXDOS2/2.20-1/get/MSXDOS2/COMMAND2.COM)
$(call mb_msxhub_file,$(1),NEXTOR/2.1.0-1/get/NEXTOR/COMMAND2.COM)
$(call mb_msxhub_file,$(1),NEXTOR/2.1.0-1/get/NEXTOR/NEXTOR.SYS)
$(call mb_msxhub_file,$(1),NEXTOR/2.1.0-1/get/NEXTOR/NSYSVER.COM)
endef
define mb_msxhub_get_macro80
$(call mb_msxhub_file,$(1),MACRO80/2.0-1/get/MACRO80/CREF80.COM)
$(call mb_msxhub_file,$(1),MACRO80/2.0-1/get/MACRO80/L80.COM)
$(call mb_msxhub_file,$(1),MACRO80/2.0-1/get/MACRO80/LIB80.COM)
$(call mb_msxhub_file,$(1),MACRO80/2.0-1/get/MACRO80/M80.COM)
endef