msxbuild/lib/make/麥加系統擴大/mb_autoexec.mk

181 lines
10 KiB
Makefile
Raw Normal View History

2020-12-23 17:14:13 +00:00
MB_AUTOEXEC_SHOW_VERSION ?= off
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_VERSION,"Print OS version on boot.")
MB_AUTOEXEC_SHOW_PATH ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_PATH,"Print search path on boot.")
MB_AUTOEXEC_SHOW_INIT ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_INIT,"Print msxbuild init message on boot.")
MB_AUTOEXEC_SHOW_HOST ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_HOST,"Print host machine on boot.")
MB_AUTOEXEC_SHOW_USER ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_USER,"Print host user on boot.")
MB_AUTOEXEC_SHOW_FOLDER ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_FOLDER,"Print host folder on boot.")
MB_AUTOEXEC_SHOW_TARGET ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SHOW_TARGET,"Print host target on boot.")
MB_AUTOEXEC_STARTUP_TIMEOUT ?= 60
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_STARTUP_TIMEOUT,"Startup failure timeout of autoexec.")
MB_AUTOEXEC_STARTUP_EXITCODE ?= 124
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_STARTUP_EXITCODE,"Startup failure exit code of autoexec.")
MB_AUTOEXEC_SAFE_TEST_TIMEOUT ?= 120
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SAFE_TEST_TIMEOUT,"Safe test execution failure timeout.")
MB_AUTOEXEC_SAFE_TEST_EXITCODE ?= 1
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SAFE_TEST_EXITCODE,"Safe test execution failure exit code.")
MB_AUTOEXEC_SAFE_CMD_TIMEOUT ?= 300
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SAFE_CMD_TIMEOUT,"Safe command execution failure timeout.")
MB_AUTOEXEC_SAFE_CMD_EXITCODE ?= 1
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_SAFE_CMD_EXITCODE,"Safe command execution failure exit code.")
2020-12-23 17:14:13 +00:00
MB_AUTOEXEC_STARTUP_NOTE ?=
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_STARTUP_NOTE,"When set this startup note message is shown.")
MB_AUTOEXEC_COLOR_FG ?= 151
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_COLOR_FG,"Default foreground color if none is given.")
MB_AUTOEXEC_COLOR_BG ?= 000
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_COLOR_BG,"Default background color if none if given.")
2024-07-03 11:30:35 +00:00
MB_AUTOEXEC_EMBED_VARS ?=
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_EMBED_VARS,"List of host env variables to copy to msx as 'MSX_x' variables.")
2024-07-03 11:30:35 +00:00
MB_AUTOEXEC_EMBED_USER ?= USER
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_EMBED_USER,"Embedds this host variable to the msx as 'MB_USER' variable.")
MB_AUTOEXEC_TIME_FORMAT ?= 24
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_TIME_FORMAT,"The time format the msx will get set to.")
MB_AUTOEXEC_DATE_FORMAT ?= DD/MM/YY
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_DATE_FORMAT,"The time format the msx will get set to.")
MB_AUTOEXEC_PROMPT_FORMAT ?= %MB_USER%@%_CWD%*
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_PROMPT_FORMAT,"The prompt format for command 2.40 and higher.")
MB_AUTOEXEC_PROMPT_SPACE ?= on
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable,MB_AUTOEXEC_PROMPT_SPACE,"When on adds an white space after the prompt format.")
2020-12-23 17:14:13 +00:00
define mb_autoexec_append_cmd
$(MB__    )echo -e "$(2)\r" >> $(1)/autoexec.bat
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_cmd,"Appends an command.","<dir> <command>")
2020-12-23 17:14:13 +00:00
define mb_autoexec_append_echo
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),echo $(subst >,&gt;,$(2)))
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_echo,"Appends an echo message.","<dir> <message>")
2020-12-23 17:14:13 +00:00
define mb_autoexec_append_rem
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),rem $(2))
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_rem,"Appends an script remark.","<dir> <remark>")
define mb_autoexec_append_show_gui
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl headless_show_gui)
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_show_gui,"Appends headless show gui command.","<dir>")
2020-12-23 17:14:13 +00:00
define mb_autoexec_append_stop_fail
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl fail_after 0)
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_stop_fail,"Appends stop automatic failure command.","<dir>")
2020-12-23 17:14:13 +00:00
define mb_autoexec_append_exit
$(MB__    )$(if $(filter on,$(MB_FLIGHT_SCREEN)),$(call mb_make_call,mb_autoexec_append_save_screenshot,$(1)))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl headless_exit)
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_exit,"Appends exit emulation command.","<dir>")
define mb_autoexec_append_plug_porta
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl boot_exec_plug_porta $(2))
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_plug_porta,"Appends an plug device into joyporta action.","<dir> <plug-dev>")
define mb_autoexec_append_plug_portb
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl boot_exec_plug_portb $(2))
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_plug_portb,"Appends an plug device into joyportb action.","<dir> <plug-dev>")
define mb_autoexec_append_save_screenshot
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl night_flight_save_screenshot $(2))
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_save_screenshot,"Appends save screenshot command.","<dir> [prefix]")
define mb_autoexec_append_save_video
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl night_flight_save_video $(2))
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_save_video,"Appends save video command.","<dir> [prefix]")
define mb_autoexec_append_safe_test
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl fail_after $(if $(3),$(3),$(MB_AUTOEXEC_SAFE_TEST_TIMEOUT)) seconds err_test $(if $(4),$(4),$(MB_AUTOEXEC_SAFE_TEST_EXITCODE)))
$(MB__    )$(call mb_make_call,mb_autoexec_append_echo,$(1),mb::safe test $(2))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),$(2))
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_safe_test,"Appends running a safe test.","<dir> <cmd> [timeout] [exit-code]")
define mb_autoexec_append_safe_cmd
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl fail_after $(if $(3),$(3),$(MB_AUTOEXEC_SAFE_CMD_TIMEOUT)) seconds err_cmd $(if $(4),$(4),$(MB_AUTOEXEC_SAFE_CMD_EXITCODE)))
$(MB__    )$(call mb_make_call,mb_autoexec_append_echo,$(1),mb::safe command $(2))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),$(2))
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_append_safe_cmd,"Appends running a safe command.","<dir> <cmd> [timeout] [exit-code]")
define _mb_autoexec_write_preboot
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),$(2)mbboot80)
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),$(2)omsxctl boot_exec_setcolor $(if $(3),$(3),$(MB_AUTOEXEC_COLOR_FG)) $(if $(4),$(4),$(MB_AUTOEXEC_COLOR_BG)))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),$(2)omsxctl fail_after $(MB_AUTOEXEC_STARTUP_TIMEOUT) seconds err_exec $(MB_AUTOEXEC_STARTUP_EXITCODE))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_INIT)),$(call mb_make_call,mb_autoexec_append_cmd,$(1),$(2)omsxctl boot_exec_show_init))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_VERSION)),$(call mb_make_call,mb_autoexec_append_cmd,$(1),ver))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),PATH + A:\;)
$(MB__    )$(if $(wildcard $(1)/utils),$(call mb_make_call,mb_autoexec_append_cmd,$(1),PATH + A:\UTILS))
endef
2020-12-23 17:14:13 +00:00
define mb_autoexec_write_default
$(MB__    )$(call mb_make_call,mb_os_echo_command,$(MB_I18N_AUTOEXEC_WRITE) $@)
$(MB__    )@echo -n "" > $(1)/autoexec.bat
$(MB__    )$(if $(wildcard $(1)/utils),$(call mb_make_call,_mb_autoexec_write_preboot,$(1),utils\,$(2),$(3)),$(call mb_make_call,_mb_autoexec_write_preboot,$(1),,$(2),$(3)))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_HOST)),$(call mb_make_call,mb_autoexec_append_cmd,$(1),omsxctl boot_exec_show_host))
$(MB__    )$(if $(MB_AUTOEXEC_STARTUP_NOTE),$(call mb_make_call,mb_autoexec_append_echo,$(1),mb::note $(MB_AUTOEXEC_STARTUP_NOTE)))
$(MB__    )$(if $(filter on,$(MB_FLIGHT_VIDEO)),$(call mb_make_call,mb_autoexec_append_save_video,$(1)))
$(MB__    )echo -n -e "$(subst $(MB_MAKE_SPACE)set,set,$(foreach var,$(MB_AUTOEXEC_EMBED_VARS),set MSX_$(var)$(MB_MAKE_EQUALS)$($(var))\r\n))" >> $(1)/autoexec.bat
$(MB__    )echo -n -e "$(subst $(MB_MAKE_SPACE)set,set,$(foreach var,$(MB_AUTOEXEC_EMBED_VARS),echo MSX_$(var)$(MB_MAKE_EQUALS)%MSX_$(var)%\r\n))" >> $(1)/autoexec.bat
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),set TIME$(MB_MAKE_EQUALS)$(MB_AUTOEXEC_TIME_FORMAT))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),set DATE$(MB_MAKE_EQUALS)$(MB_AUTOEXEC_DATE_FORMAT))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_PATH)),$(call mb_make_call,mb_autoexec_append_cmd,$(1),echo mb::path %PATH%))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),set MB_SNAIL$(MB_MAKE_EQUALS)$(notdir $@))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),set MB_USER$(MB_MAKE_EQUALS)$($(MB_AUTOEXEC_EMBED_USER)))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_USER)),$(call mb_make_call,mb_autoexec_append_echo,$(1),mb::user %MB_USER%))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),set MB_SLIME$(MB_MAKE_EQUALS)$(1))
$(MB__    )$(call mb_make_call,mb_autoexec_append_cmd,$(1),set MB_TARGET$(MB_MAKE_EQUALS)$@)
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_FOLDER)),$(call mb_make_call,mb_autoexec_append_echo,$(1),mb::bath %MB_SLIME%))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_SHOW_TARGET)),$(call mb_make_call,mb_autoexec_append_echo,$(1),mb::pipe %MB_TARGET%))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_PROMPT_SPACE)),$(call mb_make_call,mb_autoexec_append_cmd,$(1),set PROMPT \"$(value MB_AUTOEXEC_PROMPT_FORMAT)$(MB_MAKE_SPACE)\"))
$(MB__    )$(if $(filter on,$(MB_AUTOEXEC_PROMPT_SPACE)),,$(call mb_make_call,mb_autoexec_append_cmd,$(1),,set PROMPT \"$(value MB_AUTOEXEC_PROMPT_FORMAT)\"))
2020-12-23 17:14:13 +00:00
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_autoexec_write_default,"Write a default autoexec.bat file.","<dir> [fg-color] [bg-color]")
2020-12-23 17:14:13 +00:00