msxbuild/lib/make/mb_msxhub.mk

34 lines
1.8 KiB
Makefile

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_fetch_file
@echo === Fetch msxhub file
$(call mb_mkdir,$(dir $(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(1))))
test -f $(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)/$(subst $(MB_MSXHUB_API)/,,$(2))),,$(call _mb_msxhub_fetch_file,$(2)))
$(if $(wildcard $(dir $(1))$(call _mb_lowercase,$(notdir $(1)))),,$(call mb_copy,$(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(2)),$(dir $(1))$(call _mb_lowercase,$(notdir $(1)))))
endef
define mb_msxhub_get_dos2
$(call mb_msxhub_file,$(1)/MSXDOS2.SYS,$(MB_MSXHUB_API)/MSXDOS2/2.20-1/get/MSXDOS2/MSXDOS2.SYS)
$(call mb_msxhub_file,$(1)/COMMAND2.COM,$(MB_MSXHUB_API)/MSXDOS2/2.20-1/get/MSXDOS2/COMMAND2.COM)
endef
define mb_msxhub_get_macro80
$(call mb_msxhub_file,$(1)/CREF80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/CREF80.COM)
$(call mb_msxhub_file,$(1)/L80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/L80.COM)
$(call mb_msxhub_file,$(1)/LIB80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/LIB80.COM)
$(call mb_msxhub_file,$(1)/M80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/M80.COM)
endef