msxbuild/lib/make/mb_build.mk

65 lines
1.6 KiB
Makefile

MB_BUILD_FLAG_CPU ?= -mz80
MB_BUILD_FLAG_LD ?= --nostdinc
MB_BUILD_SDASM_FLAGS ?= -g -l -c -o
MB_BUILD_SDCC_FLAGS ?=
MB_BUILD_SDAR_FLAGS ?= -rc
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)
endef
define mb_link_asm_lib
@echo === Link module asm lib.
$(MB_BUILD_SDAR_CMD) $(MB_BUILD_SDAR_FLAGS) $(1) $(2)
endef
define mb_link_asm
@echo === Link asm module at $(3)
$(MB_BUILD_SDCC_CMD) $(MB_BUILD_FLAG_CPU) $(MB_BUILD_SDCC_FLAGS) --no-std-crt0 --code-loc $(3) -o $(1) $(2)
endef
define mb_link_asm_0000
$(call mb_link_asm,$(1),$(2),0x0000)
endef
define mb_link_asm_0100
$(call mb_link_asm,$(1),$(2),0x0100)
endef
define mb_link_asm_1000
$(call mb_link_asm,$(1),$(2),0x1000)
endef
define mb_link_asm_4000
$(call mb_link_asm,$(1),$(2),0x4000)
endef
define mb_link_asm_8000
$(call mb_link_asm,$(1),$(2),0x8000)
endef
define mb_link_asm_C000
$(call mb_link_asm,$(1),$(2),0xC000)
endef
define mb_link_asm_dos
$(call mb_link_asm_0100,$(1),$(2))
endef
define mb_hex2com
@echo === Extracting hex2com
cd $(dir $(1)) && $(MB_BUILD_H2B_CMD) -e com $(notdir $(1))
endef
define mb_hex2dat
@echo === Extracting hex2dat
cd $(dir $(1)) && $(MB_BUILD_H2B_CMD) -e dat $(notdir $(1))
endef