msxbuild/lib/make/msxbuild.mk

105 lines
2.9 KiB
Makefile
Raw Normal View History

2020-12-23 17:14:13 +00:00
#
2021-07-04 00:12:48 +00:00
# msxbuild.mk - Makefile helper to use with msx projects.
2020-12-23 17:14:13 +00:00
#
# Setup default tools paths
2021-07-06 18:42:46 +00:00
PATH_SDCC ?= /usr/bin
PATH_OPENMSX ?= /usr/bin
PATH_MSXBUILD ?= $(dir $(lastword $(MAKEFILE_LIST)))../..
PATH_MSXBUILD_REAL := $(if $(realpath $(PATH_MSXBUILD)),$(realpath $(PATH_MSXBUILD)),$(PATH_MSXBUILD))
2024-06-29 22:49:23 +00:00
# Include extra features
include $(PATH_MSXBUILD)/lib/make/mb_doc.mk
include $(PATH_MSXBUILD)/lib/make/mb_sdcc.mk
include $(PATH_MSXBUILD)/lib/make/mb_flight.mk
include $(PATH_MSXBUILD)/lib/make/mb_msxrom.mk
include $(PATH_MSXBUILD)/lib/make/mb_msxhub.mk
include $(PATH_MSXBUILD)/lib/make/mb_msxpipe.mk
include $(PATH_MSXBUILD)/lib/make/mb_openmsx.mk
include $(PATH_MSXBUILD)/lib/make/mb_autoexec.mk
2020-12-23 17:14:13 +00:00
# OS cmds
ifeq ($(OS),Windows_NT)
MB_RM = del /F /Q
MB_RMDIR = RMDIR /S /Q
MB_MKDIR = mkdir
MB_COPY = copy
MB_ERRIGNORE = 2>NUL || true
MB_SEP=\\
MB_CACHE ?= %LOCALAPPDATA%
else
MB_RM = rm -f
MB_RMDIR = rm -rf
MB_MKDIR = mkdir -p
MB_COPY = cp
MB_ERRIGNORE = 2>/dev/null
MB_SEP=/
MB_CACHE ?= ~/.cache
endif
# Remove space after separator
MB_PSEP = $(strip $(MB_SEP))
# Special chars call arguments (like for l80.com)
MB_CHAR_COMMA := ","
2024-07-03 11:30:35 +00:00
MB_CHAR_SPACE := $(subst ,, )
MB_CHAR_GT := ">"
MB_CHAR_LT := "<"
MB_CHAR_CDATA_START := "<![CDATA["
MB_CHAR_CDATA_END := "]]>"
define mb_rwildcard
$(foreach d,$(wildcard $1*),$(call mb_rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
endef
# Simple inline ascii 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_clean
2024-07-01 01:15:31 +00:00
@echo === Cleaning build folder
$(MB_RMDIR) $(1)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_clean,"Removed the full folder.","<dir>")
define mb_mkdir
$(MB_MKDIR) $(1)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_mkdir,"Creates an folder.","<dir>")
define mb_delete
$(MB_RM) $(1)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_delete,"Deletes an file.","<file>")
define mb_copy
$(MB_COPY) $(1) $(2)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_copy,"Copy an file.","<in> <out>")
define mb_unix2dos
unix2dos -q -n $(1) $(2)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_unix2dos,"Converts an unix file to dos.","<in> <out>")
define mb_dos2unix
dos2unix -q -n $(1) $(2)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_dos2unix,"Converts an dos file to unix.","<in> <out>")
define mb_create_dist
2024-06-30 02:37:21 +00:00
@echo === Creating distribution archive
tar -czf $(2) -C $(1) `ls $(1)`
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_create_dist,"Create an distribution archive.","<dir> <artifact>")