diff --git a/Makefile b/Makefile index b5271d4..0e43d55 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,7 @@ # Set the TARGETS and PROGRAM values as required. # See makefiles/build.mk for details on directory structure for src files and how to add custom extensions to the build. -TARGETS = atari c64 apple2 apple2enh -#TARGETS = atari +TARGETS = atari c64 apple2 apple2enh coco PROGRAM := fujinet.lib SUB_TASKS := clean disk test release diff --git a/Makefile.coco b/Makefile.coco deleted file mode 100644 index 8e9b575..0000000 --- a/Makefile.coco +++ /dev/null @@ -1,214 +0,0 @@ -## -## Temporary Makefile for CoCo -## intended to be used as reference as its functions are refactored -## into the main Makefile -## -## Author: Thom Cherryhomes -## - -# Adapted from the generic cc65 makefile. -# Notible exceptions: -# - recursive dirs for src -# - final files go into build/ directory instead of root folder (e.g. lbl, com file etc) - -TARGETS := coco -PROGRAM := fujinet.lib -LIBS := -CONFIG := -CFLAGS = -ASFLAGS = -LDFLAGS = -SRCDIR := src -OBJDIR := obj -EMUCMD := -BUILD_DIR = build -CC := cmoc -AS := lwasm -AR := lwar - -# The subfolder src directory to use to build the particular target -# cl65 will get the "TARGET" name, but the src folder will be the "PLATFORM" -PLATFORM_coco := coco - -TARGETOBJDIR := $(OBJDIR)/$(TARGETS) - -ifeq ($(shell echo),) - MKDIR = mkdir -p $1 - RMDIR = rmdir $1 - RMFILES = $(RM) $1 -else - MKDIR = mkdir $(subst /,\,$1) - RMDIR = rmdir $(subst /,\,$1) - RMFILES = $(if $1,del /f $(subst /,\,$1)) -endif -COMMA := , -SPACE := $(N/A) $(N/A) -define NEWLINE - - -endef -# Note: Do not remove any of the two empty lines above ! - -rwildcard=$(wildcard $(1)$(2))$(foreach d,$(wildcard $1*), $(call rwildcard,$d/,$2)) - -TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS)) - -ifeq ($(words $(TARGETLIST)),1) - -PLATFORM_SRC_DIR := $(PLATFORM_$(TARGETLIST))/$(SRCDIR) - -# Set PROGRAM to something like 'myprog.c64'. -override PROGRAM := $(PROGRAM).$(TARGETLIST) - -# Recursive files -SOURCES += $(call rwildcard,$(PLATFORM_SRC_DIR)/,*.s) -SOURCES += $(call rwildcard,$(PLATFORM_SRC_DIR)/,*.c) -SOURCES += $(call rwildcard,common/$(SRCDIR)/,*.s) -SOURCES += $(call rwildcard,common/$(SRCDIR)/,*.c) - -# remove trailing and leading spaces. -SOURCES := $(strip $(SOURCES)) - -# convert from src/your/long/path/foo.[c|s] to obj/your/long/path/foo.o -OBJ1 := $(SOURCES:.c=.o) -OBJECTS := $(OBJ1:.s=.o) -# change from atari/src/ -> obj/atari/ -OBJECTS := $(OBJECTS:$(PLATFORM_SRC_DIR)/%=$(OBJDIR)/$(TARGETLIST)/%) -OBJECTS := $(OBJECTS:common/$(SRCDIR)/%=$(OBJDIR)/common/%) - -DEPENDS := $(OBJECTS:.o=.d) - -LIBS += $(wildcard $(PLATFORM_SRC_DIR)/*.lib) - -ASFLAGS += \ - --asm-include-dir common/inc \ - --asm-include-dir $(PLATFORM_SRC_DIR)/include \ - --asm-include-dir . - -CFLAGS += \ - -O2 \ - -I common/inc \ - -I $(PLATFORM_SRC_DIR)/include \ - -I . - -CHANGELOG = Changelog.md - -# single line with version number in semantic form (e.g. 2.1.3) -VERSION_FILE = version.txt -VERSION_STRING := $(file < $(VERSION_FILE)) - -# include files that are included in the ZIP dist/release target -FN_NW_HEADER = fujinet-network.h -FN_NW_INC = fujinet-network.inc -FN_FUJI_HEADER = fujinet-fuji.h -FN_FUJI_INC = fujinet-fuji.inc - -define _listing_ - CFLAGS += --listing $$(@:.o=.lst) - ASFLAGS += --listing $$(@:.o=.lst) -endef - -define _mapfile_ - LDFLAGS += --mapfile $$@.map -endef - -define _labelfile_ - LDFLAGS += -Ln $$@.lbl -endef - -.SUFFIXES: -.PHONY: all clean dist fujinet.lib.$(TARGETLIST) - -all: fujinet.lib.$(TARGETLIST) - -STATEFILE := Makefile.options --include $(DEPENDS) --include $(STATEFILE) - -ifeq ($(origin _OPTIONS_),file) -OPTIONS = $(_OPTIONS_) -$(eval $(OBJECTS): $(STATEFILE)) -endif - -# Transform the abstract OPTIONS to the actual cc65 options. -$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_))) - -$(OBJDIR): - $(call MKDIR,$@) - -$(TARGETOBJDIR): - $(call MKDIR,$@) - -$(BUILD_DIR): - $(call MKDIR,$@) - -SRC_INC_DIRS := \ - $(sort $(dir $(wildcard $(PLATFORM_SRC_DIR)/*))) \ - $(sort $(dir $(wildcard common/$(SRCDIR)/*))) - -# $(info $$SOURCES = ${SOURCES}) -# $(info $$OBJECTS = ${OBJECTS}) -# $(info $$SRC_INC_DIRS = ${SRC_INC_DIRS}) -# $(info $$ASFLAGS = ${ASFLAGS}) -# $(info $$TARGETOBJDIR = ${TARGETOBJDIR}) -# $(info $$TARGETLIST = ${TARGETLIST}) - -vpath %.c $(SRC_INC_DIRS) - -obj/common/%.o: %.c | $(TARGETOBJDIR) - @$(call MKDIR,$(dir $@)) - $(CC) -c --deps $(CFLAGS) -o $@ $< - -$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR) - @$(call MKDIR,$(dir $@)) - $(CC) -c --deps $(CFLAGS) -o $@ $< - -# vpath %.s $(SRC_INC_DIRS) - -# obj/common/%.o: %.s | $(TARGETOBJDIR) -# @$(call MKDIR,$(dir $@)) -# $(AS) -c --deps $(ASFLAGS) -o $@ $< - -$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR) - @$(call MKDIR,$(dir $@)) - $(CC) -c --deps $(@:.o=.d) $(ASFLAGS) -o $@ $< - -$(BUILD_DIR)/$(PROGRAM): $(OBJECTS) | $(BUILD_DIR) - $(AR) $@ -a $(OBJECTS) - -$(PROGRAM): $(BUILD_DIR)/$(PROGRAM) | $(BUILD_DIR) - -clean: - $(call RMFILES,$(OBJECTS)) - $(call RMFILES,$(DEPENDS)) - $(call RMFILES,$(REMOVES)) - $(call RMFILES,$(BUILD_DIR)/$(PROGRAM)) - -dist: $(PROGRAM) - $(call MKDIR,dist/) - $(call RMFILES,dist/fujinet-$(TARGETLIST)-*.lib) - cp build/$(PROGRAM) dist/fujinet-$(TARGETLIST)-$(VERSION_STRING).lib - cp $(FN_NW_HEADER) dist/ - cp $(FN_NW_INC) dist/ - cp $(FN_FUJI_HEADER) dist/ - cp $(FN_FUJI_INC) dist/ - cp $(CHANGELOG) dist/ - cd dist && zip fujinet-lib-$(TARGETLIST)-$(VERSION_STRING).zip $(CHANGELOG) fujinet-$(TARGETLIST)-$(VERSION_STRING).lib *.h *.inc - $(call RMFILES,dist/fujinet-$(TARGETLIST)-*.lib) - $(call RMFILES,dist/$(CHANGELOG)) - $(call RMFILES,dist/*.h) - $(call RMFILES,dist/*.inc) - -else # $(words $(TARGETLIST)),1 - -all: - $(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t clean all dist$(NEWLINE)) - -endif # $(words $(TARGETLIST)),1 - - -################################################################### -### Place your additional targets in the additional Makefiles ### -### in the same directory - their names have to end with ".mk"! ### -################################################################### --include *.mk diff --git a/atari/src/fn_fuji/fuji_appkey_open_read.c b/atari/src/fn_fuji/fuji_appkey_open_read.c index 13656d6..3d73a00 100644 --- a/atari/src/fn_fuji/fuji_appkey_open_read.c +++ b/atari/src/fn_fuji/fuji_appkey_open_read.c @@ -41,7 +41,7 @@ bool fuji_read_appkey(uint8_t key_id, uint16_t *count, uint8_t *data) open_data[4] = mode; open_data[5] = 0; // reserved byte - copy_fuji_cmd_data(&t_fuji_open_appkey[0]); + copy_fuji_cmd_data(t_fuji_open_appkey); OS.dcb.dbuf = open_data; bus(); if (!fuji_success()) { @@ -49,7 +49,7 @@ bool fuji_read_appkey(uint8_t key_id, uint16_t *count, uint8_t *data) return false; } - copy_fuji_cmd_data(&t_fuji_read_appkey[0]); + copy_fuji_cmd_data(t_fuji_read_appkey); OS.dcb.dbuf = buffer; OS.dcb.dbyt = buffer_size + 2; // add 2 for count bytes bus(); diff --git a/atari/src/fn_fuji/fuji_appkey_open_write.c b/atari/src/fn_fuji/fuji_appkey_open_write.c index 71bc3ef..f9c464c 100644 --- a/atari/src/fn_fuji/fuji_appkey_open_write.c +++ b/atari/src/fn_fuji/fuji_appkey_open_write.c @@ -34,12 +34,12 @@ bool fuji_write_appkey(uint8_t key_id, uint16_t count, uint8_t *data) open_data[4] = 1; // WRITE mode open_data[5] = 0; // reserved byte - copy_fuji_cmd_data((uint8_t *) &t_fuji_open_appkey[0]); + copy_fuji_cmd_data(t_fuji_open_appkey); OS.dcb.dbuf = open_data; bus(); if (!fuji_success()) return false; - copy_fuji_cmd_data(&t_fuji_write_appkey[0]); + copy_fuji_cmd_data(t_fuji_write_appkey); OS.dcb.dbuf = data; OS.dcb.dbyt = keysize; // we have to specify the 64/256/... value in dbyt OS.dcb.daux = count; // ... but the count can be less in daux to tell the FN how much of the buffer needs to be written diff --git a/atari/src/include/fujinet-fuji-atari.h b/atari/src/include/fujinet-fuji-atari.h index 6f40da8..cb12fa2 100644 --- a/atari/src/include/fujinet-fuji-atari.h +++ b/atari/src/include/fujinet-fuji-atari.h @@ -5,6 +5,6 @@ #include bool fuji_success(); -extern uint8_t *t_fuji_open_appkey[]; +extern uint8_t t_fuji_open_appkey[]; #endif // FUJINET_FUJI_ATARI_H \ No newline at end of file diff --git a/makefiles/build.mk b/makefiles/build.mk index 10b0338..9502a94 100644 --- a/makefiles/build.mk +++ b/makefiles/build.mk @@ -9,8 +9,9 @@ ALL_TASKS = DISK_TASKS = -include ./makefiles/os.mk +-include ./makefiles/compiler.mk -CC := cl65 +# CC := cl65 SRCDIR := src BUILD_DIR := build @@ -43,14 +44,14 @@ OBJECTS := $(OBJECTS:common/$(SRCDIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/common/%) DEPENDS := $(OBJECTS:.o=.d) ASFLAGS += \ - --asm-include-dir common/inc \ - --asm-include-dir $(PLATFORM_SRC_DIR)/include \ - --asm-include-dir . + $(INCS_ARG) common/inc \ + $(INCS_ARG) $(PLATFORM_SRC_DIR)/include \ + $(INCS_ARG) . CFLAGS += \ - --include-dir common/inc \ - --include-dir $(PLATFORM_SRC_DIR)/include \ - --include-dir . + $(INCC_ARG) common/inc \ + $(INCC_ARG) $(PLATFORM_SRC_DIR)/include \ + $(INCC_ARG) . FN_NW_HEADER = fujinet-network.h FN_NW_INC = fujinet-network.inc @@ -65,35 +66,12 @@ CHANGELOG = Changelog.md # allow for application specific config -include ./application.mk -define _listing_ - CFLAGS += --listing $$(@:.o=.lst) - ASFLAGS += --listing $$(@:.o=.lst) -endef - -define _mapfile_ - LDFLAGS += --mapfile $$@.map -endef - -define _labelfile_ - LDFLAGS += -Ln $$@.lbl -endef - .SUFFIXES: -.PHONY: all clean release $(DISK_TASKS) $(BUILD_TASKS) $(PROGRAM_TGT) $(ALL_TASKS) +.PHONY: all clean release $(PROGRAM_TGT) $(ALL_TASKS) all: $(ALL_TASKS) $(PROGRAM_TGT) -STATEFILE := Makefile.options -include $(DEPENDS) --include $(STATEFILE) - -ifeq ($(origin _OPTIONS_),file) -OPTIONS = $(_OPTIONS_) -$(eval $(OBJECTS): $(STATEFILE)) -endif - -# Transform the abstract OPTIONS to the actual cc65 options. -$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_))) ifeq ($(BUILD_DIR),) BUILD_DIR := build @@ -128,25 +106,44 @@ vpath %.c $(SRC_INC_DIRS) $(OBJDIR)/$(CURRENT_TARGET)/common/%.o: %.c | $(TARGETOBJDIR) @$(call MKDIR,$(dir $@)) - $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $< +ifeq ($(CC),cl65) + $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) --listing $(@:.o=.lst) -Ln $@.lbl -o $@ $< +else + $(CC) -c --deps $(CFLAGS) -o $@ $< 2>/dev/null +endif $(OBJDIR)/$(CURRENT_TARGET)/%.o: %.c $(VERSION_FILE) | $(OBJDIR) @$(call MKDIR,$(dir $@)) +ifeq ($(CC),cl65) $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $< +else + $(CC) -c --deps $(CFLAGS) -o $@ $< 2>/dev/null +endif vpath %.s $(SRC_INC_DIRS) -$(OBJDIR)/$(CURRENT_TARGET)/common/%.o: %.s | $(TARGETOBJDIR) - @$(call MKDIR,$(dir $@)) - $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< +## For now, no asm in common dirs... as it would be compiler specific +# $(OBJDIR)/$(CURRENT_TARGET)/common/%.o: %.s | $(TARGETOBJDIR) +# @$(call MKDIR,$(dir $@)) +# ifeq ($(CC),cl65) +# $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< +# else +# endif $(OBJDIR)/$(CURRENT_TARGET)/%.o: %.s $(VERSION_FILE) | $(OBJDIR) @$(call MKDIR,$(dir $@)) - $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - +ifeq ($(CC),cl65) + $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) --listing $(@:.o=.lst) -Ln $@.lbl -o $@ $< +else + $(CC) -c --deps $(@:.o=.d) $(ASFLAGS) -o $@ $< +endif $(BUILD_DIR)/$(PROGRAM_TGT): $(OBJECTS) | $(BUILD_DIR) - ar65 a $@ $(OBJECTS) +ifeq ($(CC),cl65) + $(AR) a $@ $(OBJECTS) +else + $(AR) $@ -a $(OBJECTS) +endif $(PROGRAM_TGT): $(BUILD_DIR)/$(PROGRAM_TGT) | $(BUILD_DIR) diff --git a/makefiles/common.mk b/makefiles/common.mk index 0ceb18a..6d7a60e 100644 --- a/makefiles/common.mk +++ b/makefiles/common.mk @@ -1,4 +1,2 @@ VERSION_FILE := version.txt VERSION_STRING := $(file < $(VERSION_FILE)) - -CFLAGS += -Osir \ No newline at end of file diff --git a/makefiles/compiler-cc65.mk b/makefiles/compiler-cc65.mk new file mode 100644 index 0000000..e9ef062 --- /dev/null +++ b/makefiles/compiler-cc65.mk @@ -0,0 +1,6 @@ +CC := cl65 +AR := ar65 +CFLAGS := -Osir + +INCC_ARG := --include-dir +INCS_ARG := --asm-include-dir diff --git a/makefiles/compiler-cmoc.mk b/makefiles/compiler-cmoc.mk new file mode 100644 index 0000000..21a6544 --- /dev/null +++ b/makefiles/compiler-cmoc.mk @@ -0,0 +1,6 @@ +CC := cmoc +AR := lwar +CFLAGS := -O2 + +INCC_ARG := -I +INCS_ARG := -I diff --git a/makefiles/compiler.mk b/makefiles/compiler.mk new file mode 100644 index 0000000..7ece2e0 --- /dev/null +++ b/makefiles/compiler.mk @@ -0,0 +1,11 @@ +# sets the compiler and C args according to the target + +ifeq ($(CURRENT_TARGET),coco) + +-include makefiles/compiler-cmoc.mk + +else + +-include makefiles/compiler-cc65.mk + +endif \ No newline at end of file diff --git a/makefiles/os.mk b/makefiles/os.mk index 0561de3..4033780 100644 --- a/makefiles/os.mk +++ b/makefiles/os.mk @@ -8,18 +8,21 @@ endif CURRENT_PLATFORM_apple2 := apple2 CURRENT_PLATFORM_apple2enh := apple2 + CURRENT_PLATFORM_atari := atari CURRENT_PLATFORM_atarixl := atari + CURRENT_PLATFORM_c64 := commodore CURRENT_PLATFORM_c128 := commodore CURRENT_PLATFORM_c16 := commodore CURRENT_PLATFORM_pet := commodore CURRENT_PLATFORM_plus4 := commodore -#CURRENT_PLATFORM_x16 := commodore CURRENT_PLATFORM_cbm510 := commodore CURRENT_PLATFORM_cbm610 := commodore CURRENT_PLATFORM_vic20 := commodore +CURRENT_PLATFORM_coco := coco + CURRENT_PLATFORM = $(CURRENT_PLATFORM_$(CURRENT_TARGET)) ifeq '$(findstring ;,$(PATH))' ';'