Compare commits
2 commits
656c3436da
...
4b1d4e1d20
Author | SHA1 | Date | |
---|---|---|---|
Willem Cazander | 4b1d4e1d20 | ||
Willem Cazander | 6cec28f1bc |
|
@ -5,4 +5,5 @@
|
|||
|
||||
#PATH_SDCC ?= /usr/bin
|
||||
#PATH_HEX2BIN ?= /usr/bin
|
||||
#PATH_UNIX2DOS ?= /usr/bin
|
||||
#PATH_OPENMSX ?= /opt/openMSX/bin/
|
||||
|
|
|
@ -20,6 +20,7 @@ for your specific needs or contribute a fix or feature.
|
|||
* sdcc
|
||||
* hex2bin
|
||||
* wget
|
||||
* unix2dos
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -27,6 +28,7 @@ Include the msxbuild.mk file from your Makefile.
|
|||
And override the required paths;
|
||||
* PATH_SDCC ?= /usr/bin
|
||||
* PATH_HEX2BIN ?= /usr/bin
|
||||
* PATH_UNIX2DOS ?= /usr/bin
|
||||
* PATH_OPENMSX ?= /opt/openMSX/bin/
|
||||
* PATH_MSXBUILD ?= /opt/msxbuild
|
||||
|
||||
|
@ -50,9 +52,10 @@ Current set is WIP.
|
|||
* mb_hex2com
|
||||
* mb_hex2dat
|
||||
* mb_openmsx_dos2
|
||||
* mb_openmsx_macro80
|
||||
* mb_msxhub_file
|
||||
* mb_msxhub_get_dos2_sys
|
||||
* mb_msxhub_get_dos2_com
|
||||
* mb_msxhub_get_dos2
|
||||
* mb_msxhub_get_macro80
|
||||
* mb_assert_file_equals = note: text file only
|
||||
* mb_autoexec_append_cmd
|
||||
* mb_autoexec_append_echo
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
define _mb_assert_success
|
||||
@echo success: mb_assert_$(1)\; \'$(2)\'
|
||||
endef
|
||||
define _mb_assert_failure
|
||||
@echo failure: mb_assert_$(1)\; \'$(2)\'
|
||||
@exit 1
|
||||
endef
|
||||
define _mb_assert_if
|
||||
$(if $(1),$(call _mb_assert_success,$(2),$(3)),$(call _mb_assert_failure,$(2),$(3)))
|
||||
endef
|
||||
define _mb_assert_if_not
|
||||
$(if $(1),$(call _mb_assert_failure,$(2),$(3)),$(call _mb_assert_success,$(2),$(3)))
|
||||
endef
|
||||
|
||||
# FIXME: Not stable
|
||||
#define mb_assert_file_contains
|
||||
# $(call _mb_assert_if,$(findstring $(2),$(file < $(1))),file_contains,$(2))
|
||||
#endef
|
||||
define mb_assert_file_equals
|
||||
$(call _mb_assert_if_not,$(subst $(2),,$(file < $(1))),file_equals,$(2))
|
||||
endef
|
||||
|
||||
# Assert that the variable(s) are set and doesn't have non-empty values.
|
||||
# Params;
|
||||
# 1. Variable name(s) to validate.
|
||||
# 2. (optional) Error message to user.
|
||||
define mb_assert_defined
|
||||
$(strip $(foreach 1,$1,$(call _mb_assert_defined_error,$1,$(strip $(value 2)))))
|
||||
endef
|
||||
define _mb_assert_defined_error
|
||||
$(if $(value $1),,$(error Undefined $1$(if $2, ($2))))
|
||||
endef
|
|
@ -21,6 +21,9 @@ endif
|
|||
# Remove space after separator
|
||||
MB_PSEP = $(strip $(MB_SEP))
|
||||
|
||||
# Needed for comma in call arguments (like for l80.com)
|
||||
MB_COMMA:=,
|
||||
|
||||
define mb_clean
|
||||
@echo === Cleaning build folder.
|
||||
test $(1) && $(MB_RMDIR) $(1)
|
||||
|
|
|
@ -7,11 +7,16 @@ MB_BUILD_H2B_CMD ?= $(PATH_HEX2BIN)/hex2bin
|
|||
MB_BUILD_SDCC_CMD ?= $(PATH_SDCC)/sdcc
|
||||
MB_BUILD_SDASM_CMD ?= $(PATH_SDCC)/sdasz80
|
||||
MB_BUILD_SDAR_CMD ?= $(PATH_SDCC)/sdar
|
||||
MB_BUILD_UNIX2DOS_CMD ?= $(PATH_UNIX2DOS)/unix2dos
|
||||
|
||||
# TODO: Add C + mixed support;
|
||||
#$(MB_SDASM) -I$(MB_LIBASM_SRC)/include
|
||||
#-l$(LIBASM_LINK)
|
||||
|
||||
define mb_unix2dos
|
||||
$(MB_BUILD_UNIX2DOS_CMD) -n $(1) $(2)
|
||||
endef
|
||||
|
||||
define mb_compile_asm
|
||||
@echo === Compile module asm.
|
||||
$(MB_BUILD_SDASM_CMD) $(MB_BUILD_SDASM_FLAGS) $(1) $(2)
|
||||
|
|
|
@ -16,13 +16,18 @@ endef
|
|||
|
||||
define mb_msxhub_file
|
||||
$(if $(wildcard $(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(2))),,$(call _mb_msxhub_fetch_file,$(2)))
|
||||
$(call mb_copy,$(MB_MSXHUB_CACHE)/$(subst $(MB_MSXHUB_API)/,,$(2)),$(dir $(1))$(call _mb_lowercase,$(notdir $(1))))
|
||||
$(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_sys
|
||||
define mb_msxhub_get_dos2
|
||||
$(call mb_msxhub_file,$(1)/MSXDOS2.SYS,$(MB_MSXHUB_API)/MSXDOS2/2.20-1/get/MSXDOS2/MSXDOS2.SYS)
|
||||
endef
|
||||
define mb_msxhub_get_dos2_com
|
||||
$(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
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ MB_OPENMSX_BOOT_TIMEOUT ?= 25
|
|||
MB_OPENMSX_MACHINE ?= Philips_NMS_8250
|
||||
MB_OPENMSX_JOYPORTA ?=
|
||||
MB_OPENMSX_JOYPORTB ?=
|
||||
MB_OPENMSX_SETTING ?= $(PATH_MSXBUILD)/lib/openmsx/boot_settings.xml
|
||||
# Workaround for include msxbuild.mk file and 'older' openmsx segfaults on relative settings path.
|
||||
MB_OPENMSX_SETTING := $(if $(realpath $(PATH_MSXBUILD)),$(realpath $(PATH_MSXBUILD)),$(PATH_MSXBUILD))/lib/openmsx/boot_settings.xml
|
||||
MB_OPENMSX_EXTS ?=
|
||||
MB_OPENMSX_EXTRA_MEM ?= -ext ram4mb
|
||||
MB_OPENMSX_ARGS = \
|
||||
|
@ -32,17 +33,25 @@ define _mb_openmsx_run
|
|||
JOYPORTB=$(MB_OPENMSX_JOYPORTB) \
|
||||
$(MB_OPENMSX_CMD)
|
||||
endef
|
||||
|
||||
define _mb_openmsx_run_dos
|
||||
$(call mb_msxhub_file,$(1)/omsxctl.com,$(MB_MSXHUB_API)/OMSXCTL/1.0-1/get/OMSXCTL/omsxctl.com)
|
||||
$(call _mb_openmsx_run,$(1))
|
||||
endef
|
||||
|
||||
# TODO: add msx1+allversions of dos to https://github.com/fr3nd/msxhub-packages/issues/18
|
||||
#define mb_openmsx_dos1
|
||||
# cp build/msxdos1/* $(1)
|
||||
# $(call mb_msxhub_get_dos1,$(1))
|
||||
# $(call _mb_openmsx_run_dos,$(1))
|
||||
#endef
|
||||
|
||||
define mb_openmsx_dos2
|
||||
$(call mb_msxhub_get_dos2_sys,$(1))
|
||||
$(call mb_msxhub_get_dos2_com,$(1))
|
||||
$(call _mb_openmsx_run_dos, $(1))
|
||||
$(call mb_msxhub_get_dos2,$(1))
|
||||
$(call _mb_openmsx_run_dos,$(1))
|
||||
endef
|
||||
|
||||
define mb_openmsx_macro80
|
||||
$(call mb_msxhub_get_macro80,$(1))
|
||||
$(call mb_openmsx_dos2,$(1))
|
||||
endef
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# Setup required tools paths
|
||||
PATH_HEX2BIN ?= /usr/bin
|
||||
PATH_SDCC ?= /usr/bin
|
||||
PATH_UNIX2DOS ?= /usr/bin
|
||||
PATH_OPENMSX ?= /usr/bin
|
||||
PATH_MSXBUILD ?= $(dir $(lastword $(MAKEFILE_LIST)))../..
|
||||
|
||||
|
@ -13,5 +14,4 @@ include $(PATH_MSXBUILD)/lib/make/mb_base.mk
|
|||
include $(PATH_MSXBUILD)/lib/make/mb_autoexec.mk
|
||||
include $(PATH_MSXBUILD)/lib/make/mb_msxhub.mk
|
||||
include $(PATH_MSXBUILD)/lib/make/mb_openmsx.mk
|
||||
include $(PATH_MSXBUILD)/lib/make/mb_assert.mk
|
||||
include $(PATH_MSXBUILD)/lib/make/mb_build.mk
|
||||
|
|
9
test/0module.mk
Normal file
9
test/0module.mk
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
BUILD_HELP += \\n\\t* assert-all \(Run all asertion tests\)
|
||||
BUILD_TEST := \
|
||||
test-ahello-m80-assert \
|
||||
test-ahello-sdcc-assert
|
||||
|
||||
.PHONY: assert-all
|
||||
assert-all: $(BUILD_TEST)
|
||||
@echo All assertions completed.
|
32
test/ahello-m80/0module.mk
Normal file
32
test/ahello-m80/0module.mk
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
TEST_AHELLO_M80 := $(PATH_BIN)/test/ahello-m80
|
||||
BUILD_HELP += \\n\\t* $(TEST_AHELLO_M80)/ahello.com\\n\\t* test-ahello-m80-run\\n\\t* test-ahello-m80-assert
|
||||
|
||||
$(TEST_AHELLO_M80):
|
||||
$(call mb_mkdir,$(TEST_AHELLO_M80))
|
||||
|
||||
$(TEST_AHELLO_M80)/%.mac: test/ahello-m80/%.mac | $(TEST_AHELLO_M80)
|
||||
$(call mb_unix2dos,$<,$@)
|
||||
|
||||
$(TEST_AHELLO_M80)/ahello.rel: $(TEST_AHELLO_M80)/ahello.mac
|
||||
$(call mb_autoexec_cmd,$(TEST_AHELLO_M80),m80 =ahello/Z)
|
||||
$(call mb_openmsx_macro80,$(TEST_AHELLO_M80))
|
||||
|
||||
$(TEST_AHELLO_M80)/ahello.hex: $(TEST_AHELLO_M80)/ahello.rel
|
||||
$(call mb_autoexec_cmd,$(TEST_AHELLO_M80),l80 ahello$(MB_COMMA)ahello/N/X/Y/E)
|
||||
$(call mb_openmsx_macro80,$(TEST_AHELLO_M80))
|
||||
|
||||
$(TEST_AHELLO_M80)/ahello.com: $(TEST_AHELLO_M80)/ahello.hex
|
||||
$(call mb_hex2com,$(TEST_AHELLO_M80)/ahello.hex,$(TEST_AHELLO_M80)/ahello.com)
|
||||
|
||||
.PHONY: test-ahello-m80-run
|
||||
test-ahello-m80-run: $(TEST_AHELLO_M80)/ahello.com
|
||||
$(call mb_autoexec_open_gui,$(TEST_AHELLO_M80))
|
||||
$(call mb_openmsx_macro80,$(TEST_AHELLO_M80))
|
||||
|
||||
.PHONY: test-ahello-m80-assert
|
||||
test-ahello-m80-assert: $(TEST_AHELLO_M80)/ahello.com
|
||||
$(call mb_delete,$(TEST_AHELLO_M80)/test.out)
|
||||
$(call mb_autoexec_cmd_test,$(TEST_AHELLO_M80),ahello > test.out)
|
||||
$(call mb_openmsx_macro80,$(TEST_AHELLO_M80))
|
||||
grep "M80: Hello world..." $(TEST_AHELLO_M80)/test.out
|
20
test/ahello-m80/ahello.mac
Normal file
20
test/ahello-m80/ahello.mac
Normal file
|
@ -0,0 +1,20 @@
|
|||
title M80 CP/M Hello world
|
||||
.Z80
|
||||
|
||||
WRITESTR EQU 9h
|
||||
BDOS EQU 5h
|
||||
|
||||
ASEG
|
||||
ORG 0100H
|
||||
|
||||
MAIN:
|
||||
LD C,WRITESTR
|
||||
LD DE,TXT_HELLO
|
||||
CALL BDOS
|
||||
RET
|
||||
|
||||
TXT_HELLO:
|
||||
DB "M80: Hello world...$"
|
||||
|
||||
END
|
||||
DSEG
|
27
test/ahello-sdcc/0module.mk
Normal file
27
test/ahello-sdcc/0module.mk
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
TEST_AHELLO_SDCC := $(PATH_BIN)/test/ahello-sdcc
|
||||
BUILD_HELP += \\n\\t* $(TEST_AHELLO_SDCC)/ahello.com\\n\\t* test-ahello-sdcc-run\\n\\t* test-ahello-sdcc-assert
|
||||
|
||||
$(TEST_AHELLO_SDCC):
|
||||
$(call mb_mkdir,$(TEST_AHELLO_SDCC))
|
||||
|
||||
$(TEST_AHELLO_SDCC)/%.rel: test/ahello-sdcc/%.asm | $(TEST_AHELLO_SDCC)
|
||||
$(call mb_compile_asm,$@,$<)
|
||||
|
||||
$(TEST_AHELLO_SDCC)/ahello.hex: $(TEST_AHELLO_SDCC)/ahello.rel
|
||||
$(call mb_link_asm_dos,$(TEST_AHELLO_SDCC)/ahello.hex,$(TEST_AHELLO_SDCC)/ahello.rel)
|
||||
|
||||
$(TEST_AHELLO_SDCC)/ahello.com: $(TEST_AHELLO_SDCC)/ahello.hex
|
||||
$(call mb_hex2com,$(TEST_AHELLO_SDCC)/ahello.hex,$(TEST_AHELLO_SDCC)/ahello.com)
|
||||
|
||||
.PHONY: test-ahello-sdcc-run
|
||||
test-ahello-sdcc-run: $(TEST_AHELLO_SDCC)/ahello.com
|
||||
$(call mb_autoexec_open_gui,$(TEST_AHELLO_SDCC))
|
||||
$(call mb_openmsx_dos2,$(TEST_AHELLO_SDCC))
|
||||
|
||||
.PHONY: test-ahello-sdcc-assert
|
||||
test-ahello-sdcc-assert: $(TEST_AHELLO_SDCC)/ahello.com
|
||||
$(call mb_delete,$(TEST_AHELLO_SDCC)/test.out)
|
||||
$(call mb_autoexec_cmd_test,$(TEST_AHELLO_SDCC),ahello > test.out)
|
||||
$(call mb_openmsx_dos2,$(TEST_AHELLO_SDCC))
|
||||
grep "SDCC: Hello world..." $(TEST_AHELLO_SDCC)/test.out
|
|
@ -31,7 +31,7 @@ PUT_TXT:
|
|||
JR PUT_TXT
|
||||
|
||||
TXT_HELLO:
|
||||
.str "Hello world..."
|
||||
.str "SDCC: Hello world..."
|
||||
.db 0x1D
|
||||
|
||||
TXT_HELLO_SRC:
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
ASM_HELLO_NAME := ahello
|
||||
ASM_HELLO_RUN := run-$(ASM_HELLO_NAME)
|
||||
ASM_HELLO_TEST := test-$(ASM_HELLO_NAME)
|
||||
ASM_HELLO_SRC := test/$(ASM_HELLO_NAME)
|
||||
ASM_HELLO_BIN := $(PATH_BIN)/test/$(ASM_HELLO_NAME)
|
||||
ASM_HELLO_HEX := $(ASM_HELLO_BIN)/$(ASM_HELLO_NAME).hex
|
||||
ASM_HELLO_COM := $(ASM_HELLO_BIN)/$(ASM_HELLO_NAME).com
|
||||
ASM_HELLO_RELS := $(ASM_HELLO_BIN)/$(ASM_HELLO_NAME).rel
|
||||
ASM_HELLO_CODE := $(ASM_HELLO_SRC)/$(ASM_HELLO_NAME).asm
|
||||
BUILD_HELP += \\n\\t* $(ASM_HELLO_COM)\\n\\t* $(ASM_HELLO_RUN)\\n\\t* $(ASM_HELLO_TEST) \(Change txt in hello.asm and run again\)
|
||||
|
||||
$(ASM_HELLO_BIN):
|
||||
$(call mb_mkdir,$(ASM_HELLO_BIN))
|
||||
|
||||
$(ASM_HELLO_BIN)/%.rel: $(ASM_HELLO_SRC)/%.asm | $(ASM_HELLO_BIN)
|
||||
$(call mb_compile_asm,$@,$<)
|
||||
|
||||
$(ASM_HELLO_HEX): $(ASM_HELLO_RELS)
|
||||
$(call mb_link_asm_dos,$(ASM_HELLO_HEX),$(ASM_HELLO_RELS))
|
||||
|
||||
$(ASM_HELLO_COM): $(ASM_HELLO_HEX)
|
||||
$(call mb_hex2com,$(ASM_HELLO_HEX),$(ASM_HELLO_COM))
|
||||
|
||||
$(ASM_HELLO_RUN): $(ASM_HELLO_COM)
|
||||
$(call mb_autoexec_open_gui,$(ASM_HELLO_BIN))
|
||||
$(call mb_openmsx_dos2,$(ASM_HELLO_BIN))
|
||||
|
||||
$(ASM_HELLO_TEST): $(ASM_HELLO_COM)
|
||||
$(call mb_delete,$(ASM_HELLO_BIN)/test.out)
|
||||
$(call mb_autoexec_cmd_test,$(ASM_HELLO_BIN),$(ASM_HELLO_NAME) > test.out)
|
||||
$(call mb_openmsx_dos2,$(ASM_HELLO_BIN))
|
||||
$(call mb_assert_file_equals,$(ASM_HELLO_BIN)/test.out,Hello world...from asm.)
|
Loading…
Reference in a new issue