diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe27fdd0..f9743d3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,13 +22,13 @@ jobs: # - msdos # MSDOS doesn't seem to build yet container: - image: fozztexx/defoogi:1.4.1 + image: fozztexx/defoogi:1.4.2 steps: - uses: actions/checkout@v4 - name: Build - run: make -f Makefile.${{ matrix.platform }} r2r + run: make ${{ matrix.platform }}/r2r - name: Upload artifact for ${{ matrix.platform }} uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index 5aa4db2b..7733b99d 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,5 @@ fujinet-lib/* # IDE files .vscode/* *.o +*.orig +*.rej diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f9442e47 --- /dev/null +++ b/Makefile @@ -0,0 +1,104 @@ +PRODUCT = config +PLATFORMS = coco apple2 atari c64 adam pmd85 + +# Not currently in buildable state +#PLATFORMS += dragon +#PLATFORMS += msdos +#PLATFORMS += pc6001 +#PLATFORMS += pc8801 +#PLATFORMS += rc2014 + +# Require special toolchains +#PLATFORMS += apple2cda +#PLATFORMS += apple2gs + +# You can run 'make ' to build for a specific platform, +# or 'make /' for a platform-specific target. +# Example shortcuts: +# make coco → build for coco +# make apple2/disk → build the 'disk' target for apple2 + +# SRC_DIRS may use the literal %PLATFORM% token. +# It expands to the chosen PLATFORM plus any of its combos. +SRC_DIRS = src src/%PLATFORM% + +# FUJINET_LIB can be +# - a version number such as 4.7.6 +# - a directory which contains the libs for each platform +# - a zip file with an archived fujinet-lib +# - a URL to a git repo +# - empty which will use whatever is the latest +# - undefined, no fujinet-lib will be used +FUJINET_LIB = + +# Some platforms don’t use FUJINET_LIB; set this to allow builds to continue +# even if the library isn’t present. +FUJINET_LIB_OPTIONAL = 1 + +# Define extra dirs ("combos") that expand with a platform. +# Format: platform+=combo1,combo2 +PLATFORM_COMBOS = \ + c64+=commodore \ + atarixe+=atari \ + msxrom+=msx \ + msxdos+=msx \ + dragon+=coco + +include makefiles/toplevel-rules.mk + +######################################## +# Common things + +CFLAGS = -DBUILD_$(PLATFORM_UC) +CFLAGS_EXTRA_CC65 = -Os +CFLAGS_EXTRA_Z88DK = -Os + +######################################## +# CoCo customization + +AUTOEXEC_COCO = dist.coco/autoexec.bas +CFGLOAD_COCO = src/coco/cfgload/cfgload.asm +CFGLOAD_BIN = r2r/coco/cfgload.bin +DISK_EXTRA_DEPS_COCO := $(AUTOEXEC_COCO) $(CFGLOAD_BIN) + +$(CFGLOAD_BIN):: $(CFGLOAD_COCO) | $(R2R_PD) + lwasm -b -9 -o $@ $< + +# $1 == decb flags +# $2 == source file +# $3 == disk image +define coco-copy + DEST="$$(basename $2 | tr '[:lower:]' '[:upper:]')" ; \ + decb copy $1 $2 $3,$${DEST} +endef + +coco/disk-post:: + $(call coco-copy,-t -0,$(AUTOEXEC_COCO),$(DISK)) + $(call coco-copy,-b -2,$(CFGLOAD_BIN),$(DISK)) + +######################################## +# Apple II customization + +A2_LINKER_CFG = src/apple2/config.cfg +EXECUTABLE_EXTRA_DEPS_APPLE2 = $(A2_LINKER_CFG) +LDFLAGS_EXTRA_APPLE2 = -C $(A2_LINKER_CFG) + +######################################## +# Atari customization + +EXTRA_INCLUDE_ATARI = src/atari/asminc + +######################################## +# Commodore 64 customization + +CFLAGS_EXTRA_C64 = -DUSE_EDITSTRING + +######################################## +# CoCo customization + +CFLAGS_EXTRA_COCO = -Wno-assign-in-condition + +######################################## +# Adam customization + +LDFLAGS_EXTRA_ADAM = -lndos diff --git a/Makefile.adam b/Makefile.adam deleted file mode 100644 index 7c7fb2dc..00000000 --- a/Makefile.adam +++ /dev/null @@ -1,57 +0,0 @@ -TARGET_EXEC ?= autorun.ddp - -BUILD_DIR ?= ./build -SRC_DIRS ?= ./src -R2R_DIR ?= ./r2r/adam -R2R_BIN := $(R2R_DIR)/$(TARGET_EXEC) - -ADDL_DIR1 := ../eoslib/src -ADDL_DIR2 := ../smartkeyslib/src - -ADDL_LIB1 := eos.lib -ADDL_LIB2 := smartkeys.lib - -CC=zcc -AS=zcc - -SRCS := $(wildcard $(SRC_DIRS)/*.c) $(wildcard $(SRC_DIRS)/adam/*.c) -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) -DEPS := $(OBJS:.o=.d) - -CFLAGS=+coleco -subtype=adam -DBUILD_ADAM -I$(ADDL_DIR1) -I$(ADDL_DIR2) -LDFLAGS=+coleco -subtype=adam -create-app -lndos -l$(ADDL_LIB1) -l$(ADDL_LIB2) -ASFLAGS=+coleco -subtype=adam - -INC_DIRS := $(shell find $(SRC_DIRS) -type d) -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -$(R2R_BIN): $(OBJS) | $(R2R_DIR) - $(CC) -o$@ $(LDFLAGS) $(OBJS) - -.PHONY: dist autorun clean r2r - -dist: $(R2R_BIN) - cp $< ../fujinet-platformio/data/webui/device_specific/BUILD_ADAM/ - -# Create the "Ready 2 Run" executable/disk -r2r: $(R2R_BIN) - -# c source -$(BUILD_DIR)/%.c.o: %.c - $(MKDIR_P) $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -# asm source -$(BUILD_DIR)/%.asm.o: %.asm - $(MKDIR_P) $(dir $@) - $(AS) $(ASFLAGS) -c $< -o $@ - -$(R2R_DIR): - $(MKDIR_P) $@ - -clean: - $(RM) -r autorun* $(BUILD_DIR) $(R2R_DIR) - --include $(DEPS) - -MKDIR_P ?= mkdir -p diff --git a/Makefile.apple2 b/Makefile.apple2 deleted file mode 100644 index 3241cb05..00000000 --- a/Makefile.apple2 +++ /dev/null @@ -1,412 +0,0 @@ -############################################################################### -### Generic Makefile for cc65 projects - full version with abstract options ### -### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" Łogiewa ### -############################################################################### - -############################################################################### -### In order to override defaults - values can be assigned to the variables ### -############################################################################### - -# Space or comma separated list of cc65 supported target platforms to build for. -# Default: c64 (lowercase!) -TARGETS := apple2 -FUJINET_LIB_VERSION = 4.7.9 -FUJINET_LIB = fujinet-lib -FUJINET_LIB_VERSION_DIR = $(FUJINET_LIB)/$(FUJINET_LIB_VERSION)-$(TARGETS) - -# Name of the final, single-file executable. -# Default: name of the current dir with target name appended -PROGRAM := config -R2R_DIR := r2r/$(TARGETS) -DISK := $(R2R_DIR)/autorun.po - -# Path(s) to additional libraries required for linking the program -# Use only if you don't want to place copies of the libraries in SRCDIR -# Default: none -LIBS := - -# Custom linker configuration file -# Use only if you don't want to place it in SRCDIR -# Default: none -CONFIG := - -# Additional C compiler flags and options. -# Default: none -CFLAGS = -Os -DBUILD_APPLE2 - -# Additional assembler flags and options. -# Default: none -ASFLAGS = - -# Additional linker flags and options. -# Default: none -LDFLAGS = $(LDFLAGS.$(TARGETS)) -LDFLAGS.apple2 = --mapfile config.map - -# Path to the directory containing C and ASM sources. -# Default: src -SRCDIR := - -# Path to the directory where object files are to be stored (inside respective target subdirectories). -# Default: obj -OBJDIR := - -# Command used to run the emulator. -# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload -EMUCMD := - -# Optional commands used before starting the emulation process, and after finishing it. -# Default: none -#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate" -#PREEMUCMD := osascript -e "tell application \"X11\" to activate" -#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false" -#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate" -PREEMUCMD := -POSTEMUCMD := - -# On Windows machines VICE emulators may not be available in the PATH by default. -# In such case, please set the variable below to point to directory containing -# VICE emulators. -#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\" -VICE_HOME := - -# Options state file name. You should not need to change this, but for those -# rare cases when you feel you really need to name it differently - here you are -STATEFILE := Makefile.options - -################################################################################### -#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! #### -################################################################################### - -################################################################################### -### Mapping abstract options to the actual compiler, assembler and linker flags ### -### Predefined compiler, assembler and linker flags, used with abstract options ### -### valid for 2.14.x. Consult the documentation of your cc65 version before use ### -################################################################################### - -# Compiler flags used to tell the compiler to optimise for SPEED -define _optspeed_ - CFLAGS += -Oris -endef - -# Compiler flags used to tell the compiler to optimise for SIZE -define _optsize_ - CFLAGS += -Or -endef - -# Compiler and assembler flags for generating listings -define _listing_ - CFLAGS += --listing $$(@:.o=.lst) - ASFLAGS += --listing $$(@:.o=.lst) - REMOVES += $(addsuffix .lst,$(basename $(OBJECTS))) -endef - -# Linker flags for generating map file -define _mapfile_ - LDFLAGS += --mapfile $$@.map - REMOVES += $(PROGRAM).map -endef - -# Linker flags for generating VICE label file -define _labelfile_ - LDFLAGS += -Ln $$@.lbl - REMOVES += $(PROGRAM).lbl -endef - -# Linker flags for generating a debug file -define _debugfile_ - LDFLAGS += -Wl --dbgfile,$$@.dbg - REMOVES += $(PROGRAM).dbg -endef - -############################################################################### -### Defaults to be used if nothing defined in the editable sections above ### -############################################################################### - -# Presume the C64 target like the cl65 compile & link utility does. -# Set TARGETS to override. -ifeq ($(TARGETS),) - TARGETS := c64 -endif - -# Presume we're in a project directory so name the program like the current -# directory. Set PROGRAM to override. -ifeq ($(PROGRAM),) - PROGRAM := $(notdir $(CURDIR)) -endif - -# Presume the C and asm source files to be located in the subdirectory 'src'. -# Set SRCDIR to override. -ifeq ($(SRCDIR),) - SRCDIR := src -endif - -# Presume the object and dependency files to be located in the subdirectory -# 'obj' (which will be created). Set OBJDIR to override. -ifeq ($(OBJDIR),) - OBJDIR := obj -endif -TARGETOBJDIR := $(OBJDIR)/$(TARGETS) - -# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily -# rely on cl65 being added to the PATH in this scenario. -ifdef CC65_HOME - CC := $(CC65_HOME)/bin/cl65 -else - CC := cl65 -endif - -# Default emulator commands and options for particular targets. -# Set EMUCMD to override. -c64_EMUCMD := $(VICE_HOME)xscpu64 -VICIIdsize -autostart -c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload -vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload -pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload -plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload -# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option -c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload -cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload -cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload -atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run - -ifeq ($(EMUCMD),) - EMUCMD = $($(CC65TARGET)_EMUCMD) -endif - -############################################################################### -### The magic begins ### -############################################################################### - -# The "Native Win32" GNU Make contains quite some workarounds to get along with -# cmd.exe as shell. However it does not provide means to determine that it does -# actually activate those workarounds. Especially does $(SHELL) NOT contain the -# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to -# execute the command 'echo' without any parameters. Only cmd.exe will return a -# non-empy string - saying 'ECHO is on/off'. -# -# Many "Native Win32" prorams accept '/' as directory delimiter just fine. How- -# ever the internal commands of cmd.exe generally require '\' to be used. -# -# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a -# '-p' to create parent directories as needed. -# -# cmd.exe has an internal command 'del' that reports a syntax error if executed -# without any file so make sure to call it only if there's an actual argument. -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 ! - -TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS)) - -ifeq ($(words $(TARGETLIST)),1) - -FUJINET_LIB_DOWNLOAD_URL = https://github.com/FujiNetWIFI/fujinet-lib/releases/download/v$(FUJINET_LIB_VERSION)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_DOWNLOAD_FILE = $(FUJINET_LIB)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip - -# Set PROGRAM to something like 'myprog.c64'. -override PROGRAM := $(PROGRAM) - -# Set SOURCES to something like 'src/foo.c src/bar.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES := $(wildcard $(SRCDIR)/*.c) -SOURCES += $(wildcard $(SRCDIR)/*.s) -SOURCES += $(wildcard $(SRCDIR)/*.asm) -SOURCES += $(wildcard $(SRCDIR)/*.a65) - -# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.c) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.s) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.asm) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.a65) - -# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'. -OBJECTS := $(addsuffix .o,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES))))) - -# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'. -DEPENDS := $(OBJECTS:.o=.d) - -# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'. -LIBS += $(wildcard $(SRCDIR)/*.lib) -LIBS += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.lib) -LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib - -# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'. -CONFIG += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.cfg) -CONFIG += $(wildcard $(SRCDIR)/*.cfg) - -# Select CONFIG file to use. Target specific configs have higher priority. -ifneq ($(word 2,$(CONFIG)),) - CONFIG := $(firstword $(CONFIG)) - $(info Using config file $(CONFIG) for linking) -endif - -ASFLAGS += --asm-include-dir src/$(TARGETLIST)/asminc --asm-include-dir $(FUJINET_LIB_VERSION_DIR) -CFLAGS += --include-dir $(FUJINET_LIB_VERSION_DIR) -DUSING_FUJINET_LIB - -.SUFFIXES: -.PHONY: all test clean get_fujinet_lib zap love dist r2r - -all: get_fujinet_lib $(PROGRAM) - --include $(DEPENDS) --include $(STATEFILE) - -# If OPTIONS are given on the command line then save them to STATEFILE -# if (and only if) they have actually changed. But if OPTIONS are not -# given on the command line then load them from STATEFILE. Have object -# files depend on STATEFILE only if it actually exists. -ifeq ($(origin OPTIONS),command line) - ifneq ($(OPTIONS),$(_OPTIONS_)) - ifeq ($(OPTIONS),) - $(info Removing OPTIONS) - $(shell $(RM) $(STATEFILE)) - $(eval $(STATEFILE):) - else - $(info Saving OPTIONS=$(OPTIONS)) - $(shell echo _OPTIONS_=$(OPTIONS) > $(STATEFILE)) - endif - $(eval $(OBJECTS): $(STATEFILE)) - endif -else - ifeq ($(origin _OPTIONS_),file) - $(info Using saved OPTIONS=$(_OPTIONS_)) - OPTIONS = $(_OPTIONS_) - $(eval $(OBJECTS): $(STATEFILE)) - endif -endif - -# Transform the abstract OPTIONS to the actual cc65 options. -$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_))) - -# Strip potential variant suffix from the actual cc65 target. -CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST))) - -get_fujinet_lib: - @if [ ! -f "$(FUJINET_LIB_DOWNLOAD_FILE)" ]; then \ - if [ -d "$(FUJINET_LIB_VERSION_DIR)" ]; then \ - echo "A directory already exists with version $(FUJINET_LIB_VERSION) - please remove it first"; \ - exit 1; \ - fi; \ - HTTPSTATUS=$$(curl -Is $(FUJINET_LIB_DOWNLOAD_URL) | head -n 1 | awk '{print $$2}'); \ - if [ "$${HTTPSTATUS}" == "404" ]; then \ - echo "ERROR: Unable to find file $(FUJINET_LIB_DOWNLOAD_URL)"; \ - exit 1; \ - fi; \ - echo "Downloading fujinet-lib for $(TARGETLIST) version $(FUJINET_LIB_VERSION) from $(FUJINET_LIB_DOWNLOAD_URL)"; \ - mkdir -p $(FUJINET_LIB); \ - curl -L $(FUJINET_LIB_DOWNLOAD_URL) -o $(FUJINET_LIB_DOWNLOAD_FILE); \ - echo "Unzipping to $(FUJINET_LIB)"; \ - unzip -o $(FUJINET_LIB_DOWNLOAD_FILE) -d $(FUJINET_LIB_VERSION_DIR); \ - echo "Unzip complete."; \ - fi - -# The remaining targets. -$(TARGETOBJDIR): - $(call MKDIR,$@) - -$(R2R_DIR): - $(call MKDIR,$@) - -vpath %.c $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $< - -vpath %.s $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -vpath %.asm $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.asm | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -vpath %.a65 $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.a65 | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -$(PROGRAM): $(CONFIG) $(OBJECTS) $(LIBS) - $(CC) -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^) - -test: $(PROGRAM) - $(PREEMUCMD) - $(EMUCMD) $< - $(POSTEMUCMD) - -$(DISK): $(PROGRAM) | $(R2R_DIR) - cp dist.apple2/bootable.po $@ - ./dist.apple2/add-file.sh $@ config config.system - -dist: $(DISK) - @( \ - echo "Attempting to copy $(DISK) to firmware folder outside of project" ; \ - if [ -d ../fujinet-firmware/ ] ; then \ - echo "Copying into ../fujinet-firmware" ; \ - cp dist.apple2/dist.po ../fujinet-firmware/data/webui/device_specific/BUILD_APPLE/$(DISK) ; \ - elif [ -d ../fujinet-platformio/ ] ; then \ - echo "Copying into ../fujinet-platformio (NOTE: please consider renaming to updated fujinet-firmware name)" ; \ - cp dist.apple2/dist.po ../fujinet-platformio/data/webui/device_specific/BUILD_APPLE/$(DISK) ; \ - else \ - echo "ERROR: Could not find fujinet firmware folder to copy $(DISK) to." ; \ - echo "Tried ../fujinet-firmware, and ../fujinet-platformio" ; \ - exit 1 ; \ - fi ; \ - ) - -# Create the "Ready 2 Run" executable/disk -r2r: get_fujinet_lib $(DISK) - -gendebug: $(PROGRAM) - @echo "Generating debug.scr script for AppleWin" - @echo 'echo "Loading symbols"' > debug.scr - @awk '{printf("sym %s = %s\n", substr($$3, 2), $$2)}' < $(PROGRAM).lbl >> debug.scr - @echo 'bpx _main' >> debug.scr - @echo 'bpx _fuji_close_directory' >> debug.scr - -clean: - $(call RMFILES,$(OBJECTS)) - $(call RMFILES,$(DEPENDS)) - $(call RMFILES,$(REMOVES)) - $(call RMFILES,$(PROGRAM)) - $(call RMFILES,*.map) - rm -rf dist/ $(R2R_DIR) - -else # $(words $(TARGETLIST)),1 - -all test clean: - $(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE)) - -endif # $(words $(TARGETLIST)),1 - -OBJDIRLIST := $(wildcard $(OBJDIR)/*) - -zap: - $(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.o $o/*.d $o/*.lst)$(NEWLINE)) - $(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE)) - -$(call RMDIR,$(OBJDIR)) - -$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE)) - -love: - @echo "Not war, eh?" - -################################################################### -### Place your additional targets in the additional Makefiles ### -### in the same directory - their names have to end with ".mk"! ### -################################################################### --include *.mk diff --git a/Makefile.apple2cda b/Makefile.apple2cda deleted file mode 100644 index d8b9d500..00000000 --- a/Makefile.apple2cda +++ /dev/null @@ -1,334 +0,0 @@ -############################################################################### -### Generic Makefile for cc65 projects - full version with abstract options ### -### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" Łogiewa ### -############################################################################### - -############################################################################### -### In order to override defaults - values can be assigned to the variables ### -############################################################################### - -# Space or comma separated list of cc65 supported target platforms to build for. -# Default: c64 (lowercase!) -TARGETS := apple2gs -FUJINET_LIB_VERSION = 4.7.3 -FUJINET_LIB = fujinet-lib -FUJINET_LIB_VERSION_DIR = $(FUJINET_LIB)/$(FUJINET_LIB_VERSION)-$(TARGETS) - -PF_apple2gs := apple2 - -# Name of the final, single-file executable. -# Default: name of the current dir with target name appended -PROGRAM := config - -# Path(s) to additional libraries required for linking the program -# Use only if you don't want to place copies of the libraries in SRCDIR -# Default: none -LIBS := - -# Custom linker configuration file -# Use only if you don't want to place it in SRCDIR -# Default: none -CONFIG := - -# Additional C compiler flags and options. -# Default: none -CFLAGS = -I -P +F cc=-p\"src:apple2:orcac.h\" cc=-isrc cc=-isrc:apple2 cc=-ifujinet-lib cc=-dBUILD_APPLE2 cc=-d__APPLE2__ cc=-dBUILD_A2CDA - -# Additional assembler flags and options. -# Default: none -ASFLAGS = -P - -# Additional linker flags and options. -# Default: none -LDFLAGS = $(LDFLAGS.$(TARGETS)) - -# Path to the directory containing C and ASM sources. -# Default: src -SRCDIR := - -# Path to the directory where object files are to be stored (inside respective target subdirectories). -# Default: obj -OBJDIR := - -# Command used to run the emulator. -# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload -EMUCMD := - -# Optional commands used before starting the emulation process, and after finishing it. -# Default: none -#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate" -#PREEMUCMD := osascript -e "tell application \"X11\" to activate" -#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false" -#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate" -PREEMUCMD := -POSTEMUCMD := - -# On Windows machines VICE emulators may not be available in the PATH by default. -# In such case, please set the variable below to point to directory containing -# VICE emulators. -#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\" -VICE_HOME := - -# Options state file name. You should not need to change this, but for those -# rare cases when you feel you really need to name it differently - here you are -STATEFILE := Makefile.options - -################################################################################### -#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! #### -################################################################################### - -################################################################################### -### Mapping abstract options to the actual compiler, assembler and linker flags ### -### Predefined compiler, assembler and linker flags, used with abstract options ### -### valid for 2.14.x. Consult the documentation of your cc65 version before use ### -################################################################################### - - -############################################################################### -### Defaults to be used if nothing defined in the editable sections above ### -############################################################################### - -# Presume the C64 target like the cl65 compile & link utility does. -# Set TARGETS to override. -ifeq ($(TARGETS),) - TARGETS := c64 -endif - -# Presume we're in a project directory so name the program like the current -# directory. Set PROGRAM to override. -ifeq ($(PROGRAM),) - PROGRAM := $(notdir $(CURDIR)) -endif - -# Presume the C and asm source files to be located in the subdirectory 'src'. -# Set SRCDIR to override. -ifeq ($(SRCDIR),) - SRCDIR := src -endif - -# Presume the object and dependency files to be located in the subdirectory -# 'obj' (which will be created). Set OBJDIR to override. -ifeq ($(OBJDIR),) - OBJDIR := obj -endif -TARGETOBJDIR := $(OBJDIR)/$(TARGETS) - -# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily -# rely on cl65 being added to the PATH in this scenario. -ifdef CC65_HOME - CC := $(CC65_HOME)/bin/cl65 -else - CC := cl65 -endif -CC := iix compile -LINKER := iix link - -# Default emulator commands and options for particular targets. -# Set EMUCMD to override. -c64_EMUCMD := $(VICE_HOME)xscpu64 -VICIIdsize -autostart -c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload -vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload -pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload -plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload -# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option -c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload -cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload -cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload -atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run - -ifeq ($(EMUCMD),) - EMUCMD = $($(CC65TARGET)_EMUCMD) -endif - -############################################################################### -### The magic begins ### -############################################################################### - -# The "Native Win32" GNU Make contains quite some workarounds to get along with -# cmd.exe as shell. However it does not provide means to determine that it does -# actually activate those workarounds. Especially does $(SHELL) NOT contain the -# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to -# execute the command 'echo' without any parameters. Only cmd.exe will return a -# non-empy string - saying 'ECHO is on/off'. -# -# Many "Native Win32" prorams accept '/' as directory delimiter just fine. How- -# ever the internal commands of cmd.exe generally require '\' to be used. -# -# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a -# '-p' to create parent directories as needed. -# -# cmd.exe has an internal command 'del' that reports a syntax error if executed -# without any file so make sure to call it only if there's an actual argument. -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 ! - -TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS)) - -ifeq ($(words $(TARGETLIST)),1) - -CURRENT_PLATFORM := $(PF_$(TARGETLIST)) -$(info CURRENT_PLATFORM = $(CURRENT_PLATFORM)) - -FUJINET_LIB_DOWNLOAD_URL = https://github.com/FujiNetWIFI/fujinet-lib/releases/download/v$(FUJINET_LIB_VERSION)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_DOWNLOAD_FILE = $(FUJINET_LIB)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip - -# Set PROGRAM to something like 'myprog.c64'. -override PROGRAM := $(PROGRAM) - -# Set SOURCES to something like 'src/foo.c src/bar.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES := $(wildcard $(SRCDIR)/*.c) -#SOURCES += $(wildcard $(SRCDIR)/*.s) -SOURCES += $(wildcard $(SRCDIR)/*.asm) -#SOURCES += $(wildcard $(SRCDIR)/*.a65) - -# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.c) -#SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.s) -SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/orcam/*.asm) -#SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.a65) - -# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'. -OBJECTS := $(addsuffix .root,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES))))) - -# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'. -DEPENDS := $(OBJECTS:.root=.d) - -# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'. -LIBS += $(wildcard $(SRCDIR)/*.lib) -LIBS += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.lib) -#LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib -LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib - -# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'. -CONFIG += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.cfg) -CONFIG += $(wildcard $(SRCDIR)/*.cfg) - -# Select CONFIG file to use. Target specific configs have higher priority. -ifneq ($(word 2,$(CONFIG)),) - CONFIG := $(firstword $(CONFIG)) - $(info Using config file $(CONFIG) for linking) -endif - -#ASFLAGS += --asm-include-dir src/$(TARGETLIST)/asminc --asm-include-dir $(FUJINET_LIB_VERSION_DIR) -CFLAGS += cc=-i$(FUJINET_LIB_VERSION_DIR) cc=-dUSING_FUJINET_LIB - -.SUFFIXES: -.PHONY: all test clean get_fujinet_lib zap love - -all: get_fujinet_lib $(PROGRAM) - --include $(DEPENDS) - -# Strip potential variant suffix from the actual cc65 target. -CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST))) - -get_fujinet_lib: - @if [ ! -f "$(FUJINET_LIB_DOWNLOAD_FILE)" ]; then \ - if [ -d "$(FUJINET_LIB_VERSION_DIR)" ]; then \ - echo "A directory already exists with version $(FUJINET_LIB_VERSION) - please remove it first"; \ - exit 1; \ - fi; \ - HTTPSTATUS=$$(curl -Is $(FUJINET_LIB_DOWNLOAD_URL) | head -n 1 | awk '{print $$2}'); \ - if [ "$${HTTPSTATUS}" == "404" ]; then \ - echo "ERROR: Unable to find file $(FUJINET_LIB_DOWNLOAD_URL)"; \ - exit 1; \ - fi; \ - echo "Downloading fujinet-lib for $(TARGETLIST) version $(FUJINET_LIB_VERSION) from $(FUJINET_LIB_DOWNLOAD_URL)"; \ - mkdir -p $(FUJINET_LIB); \ - curl -L $(FUJINET_LIB_DOWNLOAD_URL) -o $(FUJINET_LIB_DOWNLOAD_FILE); \ - echo "Unzipping to $(FUJINET_LIB)"; \ - unzip -o $(FUJINET_LIB_DOWNLOAD_FILE) -d $(FUJINET_LIB_VERSION_DIR); \ - iix chtyp -t lib $(FUJINET_LIB_VERSION_DIR)/fujinet-apple2gs-$(FUJINET_LIB_VERSION).lib; \ - echo "Unzip complete."; \ - fi - -# The remaining targets. -$(TARGETOBJDIR): - $(call MKDIR,$@) - -vpath %.c $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.c | $(TARGETOBJDIR) - $(CC) $(CFLAGS) $< keep=$(TARGETOBJDIR)/$$ - -vpath %.s $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.s | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -vpath %.asm $(SRCDIR)/$(CURRENT_PLATFORM)/orcam $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.asm | $(TARGETOBJDIR) - $(CC) $(ASFLAGS) $< keep=$(subst .root,,$@) - -vpath %.a65 $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.a65 | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -$(PROGRAM): $(OBJECTS) $(LIBS) - $(LINKER) $(subst .root,,$^) keep=$@ - -test: $(PROGRAM) - $(PREEMUCMD) - $(EMUCMD) $< - $(POSTEMUCMD) - -dist: $(PROGRAM) - cp dist.apple2/bootable.po dist.apple2/dist.po - ./dist.apple2/add-file.sh dist.apple2/dist.po config fuji.da cda -# cp dist.apple2/dist.po ../fujinet-platformio/data/webui/device_specific/BUILD_APPLE/autorun.po -gendebug: $(PROGRAM) - @echo "Generating debug.scr script for AppleWin" - @echo 'echo "Loading symbols"' > debug.scr - @awk '{printf("sym %s = %s\n", substr($$3, 2), $$2)}' < $(PROGRAM).lbl >> debug.scr - @echo 'bpx _main' >> debug.scr - @echo 'bpx _fuji_close_directory' >> debug.scr - -clean: - $(call RMFILES,$(OBJECTS)) - $(call RMFILES,$(DEPENDS)) - $(call RMFILES,$(REMOVES)) - $(call RMFILES,$(PROGRAM)) - $(call RMFILES,*.map) - rm -rf dist/ - -else # $(words $(TARGETLIST)),1 - -all test clean: - $(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE)) - -endif # $(words $(TARGETLIST)),1 - -OBJDIRLIST := $(wildcard $(OBJDIR)/*) - -zap: - $(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.root $o/*.a $o/*.lst)$(NEWLINE)) - $(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE)) - -$(call RMDIR,$(OBJDIR)) - -$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE)) - -love: - @echo "Not war, eh?" - -################################################################### -### Place your additional targets in the additional Makefiles ### -### in the same directory - their names have to end with ".mk"! ### -################################################################### --include *.mk diff --git a/Makefile.apple2gs b/Makefile.apple2gs deleted file mode 100644 index 8aedc4cb..00000000 --- a/Makefile.apple2gs +++ /dev/null @@ -1,334 +0,0 @@ -############################################################################### -### Generic Makefile for cc65 projects - full version with abstract options ### -### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" Łogiewa ### -############################################################################### - -############################################################################### -### In order to override defaults - values can be assigned to the variables ### -############################################################################### - -# Space or comma separated list of cc65 supported target platforms to build for. -# Default: c64 (lowercase!) -TARGETS := apple2gs -FUJINET_LIB_VERSION = 4.7.3 -FUJINET_LIB = fujinet-lib -FUJINET_LIB_VERSION_DIR = $(FUJINET_LIB)/$(FUJINET_LIB_VERSION)-$(TARGETS) - -PF_apple2gs := apple2 - -# Name of the final, single-file executable. -# Default: name of the current dir with target name appended -PROGRAM := config - -# Path(s) to additional libraries required for linking the program -# Use only if you don't want to place copies of the libraries in SRCDIR -# Default: none -LIBS := - -# Custom linker configuration file -# Use only if you don't want to place it in SRCDIR -# Default: none -CONFIG := - -# Additional C compiler flags and options. -# Default: none -CFLAGS = -I -P +F cc=-p\"src:apple2:orcac.h\" cc=-isrc cc=-isrc:apple2 cc=-ifujinet-lib cc=-dBUILD_APPLE2 cc=-d__APPLE2__ - -# Additional assembler flags and options. -# Default: none -ASFLAGS = -P - -# Additional linker flags and options. -# Default: none -LDFLAGS = $(LDFLAGS.$(TARGETS)) - -# Path to the directory containing C and ASM sources. -# Default: src -SRCDIR := - -# Path to the directory where object files are to be stored (inside respective target subdirectories). -# Default: obj -OBJDIR := - -# Command used to run the emulator. -# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload -EMUCMD := - -# Optional commands used before starting the emulation process, and after finishing it. -# Default: none -#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate" -#PREEMUCMD := osascript -e "tell application \"X11\" to activate" -#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false" -#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate" -PREEMUCMD := -POSTEMUCMD := - -# On Windows machines VICE emulators may not be available in the PATH by default. -# In such case, please set the variable below to point to directory containing -# VICE emulators. -#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\" -VICE_HOME := - -# Options state file name. You should not need to change this, but for those -# rare cases when you feel you really need to name it differently - here you are -STATEFILE := Makefile.options - -################################################################################### -#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! #### -################################################################################### - -################################################################################### -### Mapping abstract options to the actual compiler, assembler and linker flags ### -### Predefined compiler, assembler and linker flags, used with abstract options ### -### valid for 2.14.x. Consult the documentation of your cc65 version before use ### -################################################################################### - - -############################################################################### -### Defaults to be used if nothing defined in the editable sections above ### -############################################################################### - -# Presume the C64 target like the cl65 compile & link utility does. -# Set TARGETS to override. -ifeq ($(TARGETS),) - TARGETS := c64 -endif - -# Presume we're in a project directory so name the program like the current -# directory. Set PROGRAM to override. -ifeq ($(PROGRAM),) - PROGRAM := $(notdir $(CURDIR)) -endif - -# Presume the C and asm source files to be located in the subdirectory 'src'. -# Set SRCDIR to override. -ifeq ($(SRCDIR),) - SRCDIR := src -endif - -# Presume the object and dependency files to be located in the subdirectory -# 'obj' (which will be created). Set OBJDIR to override. -ifeq ($(OBJDIR),) - OBJDIR := obj -endif -TARGETOBJDIR := $(OBJDIR)/$(TARGETS) - -# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily -# rely on cl65 being added to the PATH in this scenario. -ifdef CC65_HOME - CC := $(CC65_HOME)/bin/cl65 -else - CC := cl65 -endif -CC := iix compile -LINKER := iix link - -# Default emulator commands and options for particular targets. -# Set EMUCMD to override. -c64_EMUCMD := $(VICE_HOME)xscpu64 -VICIIdsize -autostart -c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload -vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload -pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload -plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload -# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option -c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload -cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload -cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload -atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run - -ifeq ($(EMUCMD),) - EMUCMD = $($(CC65TARGET)_EMUCMD) -endif - -############################################################################### -### The magic begins ### -############################################################################### - -# The "Native Win32" GNU Make contains quite some workarounds to get along with -# cmd.exe as shell. However it does not provide means to determine that it does -# actually activate those workarounds. Especially does $(SHELL) NOT contain the -# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to -# execute the command 'echo' without any parameters. Only cmd.exe will return a -# non-empy string - saying 'ECHO is on/off'. -# -# Many "Native Win32" prorams accept '/' as directory delimiter just fine. How- -# ever the internal commands of cmd.exe generally require '\' to be used. -# -# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a -# '-p' to create parent directories as needed. -# -# cmd.exe has an internal command 'del' that reports a syntax error if executed -# without any file so make sure to call it only if there's an actual argument. -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 ! - -TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS)) - -ifeq ($(words $(TARGETLIST)),1) - -CURRENT_PLATFORM := $(PF_$(TARGETLIST)) -$(info CURRENT_PLATFORM = $(CURRENT_PLATFORM)) - -FUJINET_LIB_DOWNLOAD_URL = https://github.com/FujiNetWIFI/fujinet-lib/releases/download/v$(FUJINET_LIB_VERSION)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_DOWNLOAD_FILE = $(FUJINET_LIB)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip - -# Set PROGRAM to something like 'myprog.c64'. -override PROGRAM := $(PROGRAM) - -# Set SOURCES to something like 'src/foo.c src/bar.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES := $(wildcard $(SRCDIR)/*.c) -#SOURCES += $(wildcard $(SRCDIR)/*.s) -SOURCES += $(wildcard $(SRCDIR)/*.asm) -#SOURCES += $(wildcard $(SRCDIR)/*.a65) - -# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.c) -#SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.s) -SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.asm) -#SOURCES += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.a65) - -# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'. -OBJECTS := $(addsuffix .root,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES))))) - -# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'. -DEPENDS := $(OBJECTS:.root=.d) - -# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'. -LIBS += $(wildcard $(SRCDIR)/*.lib) -LIBS += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.lib) -#LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib -LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib - -# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'. -CONFIG += $(wildcard $(SRCDIR)/$(CURRENT_PLATFORM)/*.cfg) -CONFIG += $(wildcard $(SRCDIR)/*.cfg) - -# Select CONFIG file to use. Target specific configs have higher priority. -ifneq ($(word 2,$(CONFIG)),) - CONFIG := $(firstword $(CONFIG)) - $(info Using config file $(CONFIG) for linking) -endif - -#ASFLAGS += --asm-include-dir src/$(TARGETLIST)/asminc --asm-include-dir $(FUJINET_LIB_VERSION_DIR) -CFLAGS += cc=-i$(FUJINET_LIB_VERSION_DIR) cc=-dUSING_FUJINET_LIB - -.SUFFIXES: -.PHONY: all test clean get_fujinet_lib zap love - -all: get_fujinet_lib $(PROGRAM) - --include $(DEPENDS) - -# Strip potential variant suffix from the actual cc65 target. -CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST))) - -get_fujinet_lib: - @if [ ! -f "$(FUJINET_LIB_DOWNLOAD_FILE)" ]; then \ - if [ -d "$(FUJINET_LIB_VERSION_DIR)" ]; then \ - echo "A directory already exists with version $(FUJINET_LIB_VERSION) - please remove it first"; \ - exit 1; \ - fi; \ - HTTPSTATUS=$$(curl -Is $(FUJINET_LIB_DOWNLOAD_URL) | head -n 1 | awk '{print $$2}'); \ - if [ "$${HTTPSTATUS}" == "404" ]; then \ - echo "ERROR: Unable to find file $(FUJINET_LIB_DOWNLOAD_URL)"; \ - exit 1; \ - fi; \ - echo "Downloading fujinet-lib for $(TARGETLIST) version $(FUJINET_LIB_VERSION) from $(FUJINET_LIB_DOWNLOAD_URL)"; \ - mkdir -p $(FUJINET_LIB); \ - curl -L $(FUJINET_LIB_DOWNLOAD_URL) -o $(FUJINET_LIB_DOWNLOAD_FILE); \ - echo "Unzipping to $(FUJINET_LIB)"; \ - unzip -o $(FUJINET_LIB_DOWNLOAD_FILE) -d $(FUJINET_LIB_VERSION_DIR); \ - iix chtyp -t lib $(FUJINET_LIB_VERSION_DIR)/fujinet-apple2gs-$(FUJINET_LIB_VERSION).lib; \ - echo "Unzip complete."; \ - fi - -# The remaining targets. -$(TARGETOBJDIR): - $(call MKDIR,$@) - -vpath %.c $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.c | $(TARGETOBJDIR) - $(CC) $(CFLAGS) $< keep=$(TARGETOBJDIR)/$$ - -vpath %.s $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.s | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -vpath %.asm $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.asm | $(TARGETOBJDIR) - $(CC) $(ASFLAGS) $< keep=$(subst .root,,$@) - -vpath %.a65 $(SRCDIR)/$(CURRENT_PLATFORM) $(SRCDIR) - -$(TARGETOBJDIR)/%.root: %.a65 | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -$(PROGRAM): $(OBJECTS) $(LIBS) - $(LINKER) $(subst .root,,$^) keep=$@ - -test: $(PROGRAM) - $(PREEMUCMD) - $(EMUCMD) $< - $(POSTEMUCMD) - -dist: $(PROGRAM) - cp dist.apple2/bootable.po dist.apple2/dist.po - ./dist.apple2/add-file.sh dist.apple2/dist.po config config exe -# cp dist.apple2/dist.po ../fujinet-platformio/data/webui/device_specific/BUILD_APPLE/autorun.po -gendebug: $(PROGRAM) - @echo "Generating debug.scr script for AppleWin" - @echo 'echo "Loading symbols"' > debug.scr - @awk '{printf("sym %s = %s\n", substr($$3, 2), $$2)}' < $(PROGRAM).lbl >> debug.scr - @echo 'bpx _main' >> debug.scr - @echo 'bpx _fuji_close_directory' >> debug.scr - -clean: - $(call RMFILES,$(OBJECTS)) - $(call RMFILES,$(DEPENDS)) - $(call RMFILES,$(REMOVES)) - $(call RMFILES,$(PROGRAM)) - $(call RMFILES,*.map) - rm -rf dist/ - -else # $(words $(TARGETLIST)),1 - -all test clean: - $(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE)) - -endif # $(words $(TARGETLIST)),1 - -OBJDIRLIST := $(wildcard $(OBJDIR)/*) - -zap: - $(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.root $o/*.a $o/*.lst)$(NEWLINE)) - $(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE)) - -$(call RMDIR,$(OBJDIR)) - -$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE)) - -love: - @echo "Not war, eh?" - -################################################################### -### Place your additional targets in the additional Makefiles ### -### in the same directory - their names have to end with ".mk"! ### -################################################################### --include *.mk diff --git a/Makefile.atari b/Makefile.atari deleted file mode 100644 index 5ac0fc53..00000000 --- a/Makefile.atari +++ /dev/null @@ -1,428 +0,0 @@ -############################################################################### -### Generic Makefile for cc65 projects - full version with abstract options ### -### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" Łogiewa ### -############################################################################### - -############################################################################### -### In order to override defaults - values can be assigned to the variables ### -############################################################################### - -# Space or comma separated list of cc65 supported target platforms to build for. -# Default: c64 (lowercase!) -TARGETS := atari - -FUJINET_LIB_VERSION = 4.7.4 -FUJINET_LIB = fujinet-lib -FUJINET_LIB_VERSION_DIR = $(FUJINET_LIB)/$(FUJINET_LIB_VERSION)-$(TARGETS) - -# Name of the final, single-file executable. -# Default: name of the current dir with target name appended -PROGRAM := config -R2R_DIR := r2r/$(TARGETS) -R2R_BIN := $(R2R_DIR)/autorun.atr - -# Path(s) to additional libraries required for linking the program -# Use only if you don't want to place copies of the libraries in SRCDIR -# Default: none -LIBS := - -# Custom linker configuration file -# Use only if you don't want to place it in SRCDIR -# Default: none -CONFIG := - -# Additional C compiler flags and options. -# Default: none -CFLAGS = -Os -DBUILD_ATARI - -# Additional assembler flags and options. -# Default: none -ASFLAGS = - -# Additional linker flags and options. -# Default: none -LDFLAGS = $(LDFLAGS.$(TARGETS)) -LDFLAGS.atari = --mapfile config.map - -# Path to the directory containing C and ASM sources. -# Default: src -SRCDIR := - -# Path to the directory where object files are to be stored (inside respective target subdirectories). -# Default: obj -OBJDIR := - -# Command used to run the emulator. -# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload -EMUCMD := - -# Optional commands used before starting the emulation process, and after finishing it. -# Default: none -#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate" -#PREEMUCMD := osascript -e "tell application \"X11\" to activate" -#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false" -#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate" -PREEMUCMD := -POSTEMUCMD := - -# On Windows machines VICE emulators may not be available in the PATH by default. -# In such case, please set the variable below to point to directory containing -# VICE emulators. -#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\" -VICE_HOME := - -# Options state file name. You should not need to change this, but for those -# rare cases when you feel you really need to name it differently - here you are -STATEFILE := Makefile.options - -################################################################################### -#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! #### -################################################################################### - -################################################################################### -### Mapping abstract options to the actual compiler, assembler and linker flags ### -### Predefined compiler, assembler and linker flags, used with abstract options ### -### valid for 2.14.x. Consult the documentation of your cc65 version before use ### -################################################################################### - -# Compiler flags used to tell the compiler to optimise for SPEED -define _optspeed_ - CFLAGS += -Oris -endef - -# Compiler flags used to tell the compiler to optimise for SIZE -define _optsize_ - CFLAGS += -Or -endef - -# Compiler and assembler flags for generating listings -define _listing_ - CFLAGS += --listing $$(@:.o=.lst) - ASFLAGS += --listing $$(@:.o=.lst) - REMOVES += $(addsuffix .lst,$(basename $(OBJECTS))) -endef - -# Linker flags for generating map file -define _mapfile_ - LDFLAGS += --mapfile $$@.map - REMOVES += $(PROGRAM).map -endef - -# Linker flags for generating VICE label file -define _labelfile_ - LDFLAGS += -Ln $$@.lbl - REMOVES += $(PROGRAM).lbl -endef - -# Linker flags for generating a debug file -define _debugfile_ - LDFLAGS += -Wl --dbgfile,$$@.dbg - REMOVES += $(PROGRAM).dbg -endef - -############################################################################### -### Defaults to be used if nothing defined in the editable sections above ### -############################################################################### - -# Presume the C64 target like the cl65 compile & link utility does. -# Set TARGETS to override. -ifeq ($(TARGETS),) - TARGETS := c64 -endif - -# Presume we're in a project directory so name the program like the current -# directory. Set PROGRAM to override. -ifeq ($(PROGRAM),) - PROGRAM := $(notdir $(CURDIR)) -endif - -# Presume the C and asm source files to be located in the subdirectory 'src'. -# Set SRCDIR to override. -ifeq ($(SRCDIR),) - SRCDIR := src -endif - -# Presume the object and dependency files to be located in the subdirectory -# 'obj' (which will be created). Set OBJDIR to override. -ifeq ($(OBJDIR),) - OBJDIR := obj -endif -TARGETOBJDIR := $(OBJDIR)/$(TARGETS) - -# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily -# rely on cl65 being added to the PATH in this scenario. -ifdef CC65_HOME - CC := $(CC65_HOME)/bin/cl65 -else - CC := cl65 -endif - -# Default emulator commands and options for particular targets. -# Set EMUCMD to override. -c64_EMUCMD := $(VICE_HOME)xscpu64 -VICIIdsize -autostart -c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload -vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload -pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload -plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload -# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option -c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload -cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload -cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload -#atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run - -ifeq '$(findstring ;,$(PATH))' ';' - detected_OS := Windows -else - detected_OS := $(shell uname 2>/dev/null || echo Unknown) - detected_OS := $(patsubst CYGWIN%,Cygwin,$(detected_OS)) - detected_OS := $(patsubst MSYS%,MSYS,$(detected_OS)) - detected_OS := $(patsubst MINGW%,MSYS,$(detected_OS)) -endif - -XS := "" -ifeq ($(detected_OS),$(filter $(detected_OS),MSYS MINGW)) -# need an eXtra Slash for altirra things - XS := / -endif - -LBL_SYM := $(XS)/debugcmd: ".loadsym $(PROGRAM).com.lbl" - -ALTIRRA ?= $(ALTIRRA_HOME)/Altirra64.exe \ - $(XS)/portable $(XS)/portablealt:altirra-debug.ini \ - $(XS)/debug \ - $(LBL_SYM) \ - $(XS)/debugcmd: "bp _debug" - -# Add any additional break points by copying last line - -atari_EMUCMD := $(ALTIRRA) - -ifeq ($(EMUCMD),) - EMUCMD = $($(CC65TARGET)_EMUCMD) -endif - -############################################################################### -### The magic begins ### -############################################################################### - -# The "Native Win32" GNU Make contains quite some workarounds to get along with -# cmd.exe as shell. However it does not provide means to determine that it does -# actually activate those workarounds. Especially does $(SHELL) NOT contain the -# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to -# execute the command 'echo' without any parameters. Only cmd.exe will return a -# non-empy string - saying 'ECHO is on/off'. -# -# Many "Native Win32" prorams accept '/' as directory delimiter just fine. How- -# ever the internal commands of cmd.exe generally require '\' to be used. -# -# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a -# '-p' to create parent directories as needed. -# -# cmd.exe has an internal command 'del' that reports a syntax error if executed -# without any file so make sure to call it only if there's an actual argument. -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 ! - -TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS)) - -ifeq ($(words $(TARGETLIST)),1) - -FUJINET_LIB_DOWNLOAD_URL = https://github.com/FujiNetWIFI/fujinet-lib/releases/download/v$(FUJINET_LIB_VERSION)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_DOWNLOAD_FILE = $(FUJINET_LIB)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip - -# Set PROGRAM to something like 'myprog.c64'. -override PROGRAM := $(PROGRAM).com - -# Set SOURCES to something like 'src/foo.c src/bar.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES := $(wildcard $(SRCDIR)/*.c) -SOURCES += $(wildcard $(SRCDIR)/*.s) -SOURCES += $(wildcard $(SRCDIR)/*.asm) -SOURCES += $(wildcard $(SRCDIR)/*.a65) - -# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'. -# Use of assembler files with names ending differently than .s is deprecated! -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.c) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.s) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.asm) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.a65) - -# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'. -OBJECTS := $(addsuffix .o,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES))))) - -# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'. -DEPENDS := $(OBJECTS:.o=.d) - -# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'. -LIBS += $(wildcard $(SRCDIR)/*.lib) -LIBS += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.lib) -LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib - -# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'. -CONFIG += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.cfg) -CONFIG += $(wildcard $(SRCDIR)/*.cfg) - -# Select CONFIG file to use. Target specific configs have higher priority. -ifneq ($(word 2,$(CONFIG)),) - CONFIG := $(firstword $(CONFIG)) - $(info Using config file $(CONFIG) for linking) -endif - -ASFLAGS += --asm-include-dir src/$(TARGETLIST)/asminc --asm-include-dir $(FUJINET_LIB_VERSION_DIR) -CFLAGS += --include-dir $(FUJINET_LIB_VERSION_DIR) -DUSING_FUJINET_LIB - -.SUFFIXES: -.PHONY: all test clean get_fujinet_lib zap r2r - -all: get_fujinet_lib $(PROGRAM) - --include $(DEPENDS) --include $(STATEFILE) - -# If OPTIONS are given on the command line then save them to STATEFILE -# if (and only if) they have actually changed. But if OPTIONS are not -# given on the command line then load them from STATEFILE. Have object -# files depend on STATEFILE only if it actually exists. -ifeq ($(origin OPTIONS),command line) - ifneq ($(OPTIONS),$(_OPTIONS_)) - ifeq ($(OPTIONS),) - $(info Removing OPTIONS) - $(shell $(RM) $(STATEFILE)) - $(eval $(STATEFILE):) - else - $(info Saving OPTIONS=$(OPTIONS)) - $(shell echo _OPTIONS_=$(OPTIONS) > $(STATEFILE)) - endif - $(eval $(OBJECTS): $(STATEFILE)) - endif -else - ifeq ($(origin _OPTIONS_),file) - $(info Using saved OPTIONS=$(_OPTIONS_)) - OPTIONS = $(_OPTIONS_) - $(eval $(OBJECTS): $(STATEFILE)) - endif -endif - -# Transform the abstract OPTIONS to the actual cc65 options. -$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_))) - -# Strip potential variant suffix from the actual cc65 target. -CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST))) - -get_fujinet_lib: - @if [ ! -f "$(FUJINET_LIB_DOWNLOAD_FILE)" ]; then \ - if [ -d "$(FUJINET_LIB_VERSION_DIR)" ]; then \ - echo "A directory already exists with version $(FUJINET_LIB_VERSION) - please remove it first"; \ - exit 1; \ - fi; \ - HTTPSTATUS=$$(curl -Is $(FUJINET_LIB_DOWNLOAD_URL) | head -n 1 | awk '{print $$2}'); \ - if [ "$${HTTPSTATUS}" == "404" ]; then \ - echo "ERROR: Unable to find file $(FUJINET_LIB_DOWNLOAD_URL)"; \ - exit 1; \ - fi; \ - echo "Downloading fujinet-lib for $(TARGETLIST) version $(FUJINET_LIB_VERSION) from $(FUJINET_LIB_DOWNLOAD_URL)"; \ - mkdir -p $(FUJINET_LIB); \ - curl -L $(FUJINET_LIB_DOWNLOAD_URL) -o $(FUJINET_LIB_DOWNLOAD_FILE); \ - echo "Unzipping to $(FUJINET_LIB)"; \ - unzip -o $(FUJINET_LIB_DOWNLOAD_FILE) -d $(FUJINET_LIB_VERSION_DIR); \ - echo "Unzip complete."; \ - fi - -# The remaining targets. -$(TARGETOBJDIR): - $(call MKDIR,$@) - -$(R2R_DIR): - $(call MKDIR,$@) - -vpath %.c $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $< - -vpath %.s $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -$(PROGRAM): $(CONFIG) $(OBJECTS) $(LIBS) - $(CC) -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^) - -# Create the "Ready 2 Run" executable/disk -r2r: get_fujinet_lib $(R2R_BIN) - -test: $(PROGRAM) - $(PREEMUCMD) - $(EMUCMD) $< - $(POSTEMUCMD) - -test-atr: $(PROGRAM) dist - $(PREEMUCMD) \ - $(EMUCMD) //disk $(R2R_BIN) \ - $(POSTEMUCMD) - -$(R2R_BIN): $(PROGRAM) | $(R2R_DIR) - mkdir -p dist - cp ../fujinet-tools/pre_migration/atari/dist/*.com dist/ || true - cp $(PROGRAM) dist/ - dir2atr -m -S -B picoboot.bin $@ dist/ - -dist: $(R2R_BIN) - -dist-z: $(PROGRAM) - @if [ -d "../fujinet-config-loader" ] ; then \ - echo "Found fujinet-config-loader, creating compressed $(R2R_BIN)"; \ - $(MAKE) -C ../fujinet-config-loader clean dist > /dev/null 2>&1 ; \ - if [ $$? -ne 0 ] ; then \ - echo "ERROR running compressor"; \ - exit 1; \ - fi; \ - cp ../fujinet-config-loader/autorun-zx0.atr ./$(R2R_BIN); \ - echo "Compressed file saved as $(R2R_BIN)"; \ - else \ - echo "ERROR: Could not find fujinet-config-loader in sibling directory to current."; \ - exit 1; \ - fi - -clean: - $(call RMFILES,$(OBJECTS)) - $(call RMFILES,$(DEPENDS)) - $(call RMFILES,$(REMOVES)) - $(call RMFILES,$(PROGRAM)) - $(call RMFILES,*.map) - rm -rf dist/ - -else # $(words $(TARGETLIST)),1 - -all test clean: - $(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE)) - -endif # $(words $(TARGETLIST)),1 - -OBJDIRLIST := $(wildcard $(OBJDIR)/*) - -zap: - $(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.o $o/*.d $o/*.lst)$(NEWLINE)) - $(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE)) - -$(call RMDIR,$(OBJDIR)) - -$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE)) - -################################################################### -### Place your additional targets in the additional Makefiles ### -### in the same directory - their names have to end with ".mk"! ### -################################################################### --include *.mk diff --git a/Makefile.c64 b/Makefile.c64 deleted file mode 100644 index 086fd0a9..00000000 --- a/Makefile.c64 +++ /dev/null @@ -1,379 +0,0 @@ -############################################################################### -### Generic Makefile for cc65 projects - full version with abstract options ### -### V1.3.0(w) 2010 - 2013 Oliver Schmidt & Patryk "Silver Dream !" Łogiewa ### -############################################################################### - -############################################################################### -### In order to override defaults - values can be assigned to the variables ### -############################################################################### - -# Space or comma separated list of cc65 supported target platforms to build for. -# Default: c64 (lowercase!) -TARGETS := c64 - -FUJINET_LIB_VERSION = 4.7.9 -FUJINET_LIB = fujinet-lib -FUJINET_LIB_VERSION_DIR = $(FUJINET_LIB)/$(FUJINET_LIB_VERSION)-$(TARGETS) - -# Name of the final, single-file executable. -# Default: name of the current dir with target name appended -PROGRAM := config -R2R_DIR := r2r/$(TARGETS) -R2R_BIN := $(R2R_DIR)/$(PROGRAM).prg - -# Path(s) to additional libraries required for linking the program -# Use only if you don't want to place copies of the libraries in SRCDIR -# Default: none -LIBS := - -# Custom linker configuration file -# Use only if you don't want to place it in SRCDIR -# Default: none -CONFIG := - -# Additional C compiler flags and options. -# Default: none -CFLAGS = -Os -DBUILD_C64 -DUSE_EDITSTRING - -# Additional assembler flags and options. -# Default: none -ASFLAGS = - -# Additional linker flags and options. -# Default: none -LDFLAGS = $(LDFLAGS.$(TARGETS)) - -# Path to the directory containing C and ASM sources. -# Default: src -SRCDIR := - -# Path to the directory to output binary to -# Default: ~/Workspace/tnfs -DESTDIR := - -# Path to the directory where object files are to be stored (inside respective target subdirectories). -# Default: obj -OBJDIR := - -# Command used to run the emulator. -# Default: depending on target platform. For default (c64) target: x64 -kernal kernal -VICIIdsize -autoload -EMUCMD := - -# Optional commands used before starting the emulation process, and after finishing it. -# Default: none -#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate" -#PREEMUCMD := osascript -e "tell application \"X11\" to activate" -#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false" -#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate" -PREEMUCMD := -POSTEMUCMD := - -# On Windows machines VICE emulators may not be available in the PATH by default. -# In such case, please set the variable below to point to directory containing -# VICE emulators. -#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\" -VICE_HOME := - -# Options state file name. You should not need to change this, but for those -# rare cases when you feel you really need to name it differently - here you are -STATEFILE := Makefile.options - -################################################################################### -#### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! #### -################################################################################### - -################################################################################### -### Mapping abstract options to the actual compiler, assembler and linker flags ### -### Predefined compiler, assembler and linker flags, used with abstract options ### -### valid for 2.14.x. Consult the documentation of your cc65 version before use ### -################################################################################### - -# Compiler flags used to tell the compiler to optimise for SPEED -define _optspeed_ - CFLAGS += -Oris -endef - -# Compiler flags used to tell the compiler to optimise for SIZE -define _optsize_ - CFLAGS += -Or -endef - -# Compiler and assembler flags for generating listings -define _listing_ - CFLAGS += --listing $$(@:.o=.lst) - ASFLAGS += --listing $$(@:.o=.lst) - REMOVES += $(addsuffix .lst,$(basename $(OBJECTS))) -endef - -# Linker flags for generating map file -define _mapfile_ - LDFLAGS += --mapfile $$@.map - REMOVES += $(PROGRAM).map -endef - -# Linker flags for generating VICE label file -define _labelfile_ - LDFLAGS += -Ln $$@.lbl - REMOVES += $(PROGRAM).lbl -endef - -# Linker flags for generating a debug file -define _debugfile_ - LDFLAGS += -Wl --dbgfile,$$@.dbg - REMOVES += $(PROGRAM).dbg -endef - -############################################################################### -### Defaults to be used if nothing defined in the editable sections above ### -############################################################################### - -# Presume the C64 target like the cl65 compile & link utility does. -# Set TARGETS to override. -ifeq ($(TARGETS),) - TARGETS := c64 -endif - -# Presume we're in a project directory so name the program like the current -# directory. Set PROGRAM to override. -ifeq ($(PROGRAM),) - PROGRAM := $(notdir $(CURDIR)) -endif - -# Presume the C and asm source files to be located in the subdirectory 'src'. -# Set SRCDIR to override. -ifeq ($(SRCDIR),) - SRCDIR := src -endif - -# Presume the destination for the binary in the subdirectory '/Workspace/tnfs'. -# Set DESTDIR to override. -ifeq ($(DESTDIR),) - DESTDIR := ~/Workspace/tnfs -endif - -# Presume the object and dependency files to be located in the subdirectory -# 'obj' (which will be created). Set OBJDIR to override. -ifeq ($(OBJDIR),) - OBJDIR := obj -endif -TARGETOBJDIR := $(OBJDIR)/$(TARGETS) - -# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily -# rely on cl65 being added to the PATH in this scenario. -ifdef CC65_HOME - CC := $(CC65_HOME)/bin/cl65 -else - CC := cl65 -endif - -# Default emulator commands and options for particular targets. -# Set EMUCMD to override. -c64_EMUCMD := $(VICE_HOME)xscpu64 -VICIIdsize -autostart -c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload -vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload -pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload -plus4_EMUCMD := $(VICE_HOME)xplus4 -TEDdsize -autoload -# So far there is no x16 emulator in VICE (why??) so we have to use xplus4 with -memsize option -c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload -cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload -cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload -atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run - -ifeq ($(EMUCMD),) - EMUCMD = $($(CC65TARGET)_EMUCMD) -endif - -############################################################################### -### The magic begins ### -############################################################################### - -# The "Native Win32" GNU Make contains quite some workarounds to get along with -# cmd.exe as shell. However it does not provide means to determine that it does -# actually activate those workarounds. Especially does $(SHELL) NOT contain the -# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to -# execute the command 'echo' without any parameters. Only cmd.exe will return a -# non-empy string - saying 'ECHO is on/off'. -# -# Many "Native Win32" prorams accept '/' as directory delimiter just fine. How- -# ever the internal commands of cmd.exe generally require '\' to be used. -# -# cmd.exe has an internal command 'mkdir' that doesn't understand nor require a -# '-p' to create parent directories as needed. -# -# cmd.exe has an internal command 'del' that reports a syntax error if executed -# without any file so make sure to call it only if there's an actual argument. -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 ! - -TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS)) - -ifeq ($(words $(TARGETLIST)),1) - -FUJINET_LIB_DOWNLOAD_URL = https://github.com/FujiNetWIFI/fujinet-lib/releases/download/v$(FUJINET_LIB_VERSION)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_DOWNLOAD_FILE = $(FUJINET_LIB)/fujinet-lib-$(TARGETLIST)-$(FUJINET_LIB_VERSION).zip - -# Set PROGRAM to something like 'myprog.c64'. -override PROGRAM := $(PROGRAM) - -# Set SOURCES to something like 'src/foo.c src/bar.s'. -SOURCES := $(wildcard $(SRCDIR)/*.c) -SOURCES += $(wildcard $(SRCDIR)/*.s) - -# Add to SOURCES something like 'src/c64/me.c src/c64/too.s'. -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.c) -SOURCES += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.s) - -# Set OBJECTS to something like 'obj/c64/foo.o obj/c64/bar.o'. -OBJECTS := $(addsuffix .o,$(basename $(addprefix $(TARGETOBJDIR)/,$(notdir $(SOURCES))))) - -# Set DEPENDS to something like 'obj/c64/foo.d obj/c64/bar.d'. -DEPENDS := $(OBJECTS:.o=.d) - -# Add to LIBS something like 'src/foo.lib src/c64/bar.lib'. -LIBS += $(wildcard $(SRCDIR)/*.lib) -LIBS += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.lib) -LIBS += $(FUJINET_LIB_VERSION_DIR)/fujinet-$(TARGETLIST)-$(FUJINET_LIB_VERSION).lib - -# Add to CONFIG something like 'src/c64/bar.cfg src/foo.cfg'. -CONFIG += $(wildcard $(SRCDIR)/$(TARGETLIST)/*.cfg) -CONFIG += $(wildcard $(SRCDIR)/*.cfg) - -# Select CONFIG file to use. Target specific configs have higher priority. -ifneq ($(word 2,$(CONFIG)),) - CONFIG := $(firstword $(CONFIG)) - $(info Using config file $(CONFIG) for linking) -endif - -ASFLAGS += --asm-include-dir src/$(TARGETLIST)/asminc --asm-include-dir $(FUJINET_LIB_VERSION_DIR) -CFLAGS += --include-dir $(FUJINET_LIB_VERSION_DIR) -DUSING_FUJINET_LIB - -.SUFFIXES: -.PHONY: all test clean get_fujinet_lib zap r2r - -all: get_fujinet_lib $(R2R_BIN) - --include $(DEPENDS) --include $(STATEFILE) - -# If OPTIONS are given on the command line then save them to STATEFILE -# if (and only if) they have actually changed. But if OPTIONS are not -# given on the command line then load them from STATEFILE. Have object -# files depend on STATEFILE only if it actually exists. -ifeq ($(origin OPTIONS),command line) - ifneq ($(OPTIONS),$(_OPTIONS_)) - ifeq ($(OPTIONS),) - $(info Removing OPTIONS) - $(shell $(RM) $(STATEFILE)) - $(eval $(STATEFILE):) - else - $(info Saving OPTIONS=$(OPTIONS)) - $(shell echo _OPTIONS_=$(OPTIONS) > $(STATEFILE)) - endif - $(eval $(OBJECTS): $(STATEFILE)) - endif -else - ifeq ($(origin _OPTIONS_),file) - $(info Using saved OPTIONS=$(_OPTIONS_)) - OPTIONS = $(_OPTIONS_) - $(eval $(OBJECTS): $(STATEFILE)) - endif -endif - -# Transform the abstract OPTIONS to the actual cc65 options. -$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_))) - -# Strip potential variant suffix from the actual cc65 target. -CC65TARGET := $(firstword $(subst .,$(SPACE),$(TARGETLIST))) - -get_fujinet_lib: - @if [ ! -f "$(FUJINET_LIB_DOWNLOAD_FILE)" ]; then \ - if [ -d "$(FUJINET_LIB_VERSION_DIR)" ]; then \ - echo "A directory already exists with version $(FUJINET_LIB_VERSION) - please remove it first"; \ - exit 1; \ - fi; \ - HTTPSTATUS=$$(curl -Is $(FUJINET_LIB_DOWNLOAD_URL) | head -n 1 | awk '{print $$2}'); \ - if [ "$${HTTPSTATUS}" == "404" ]; then \ - echo "ERROR: Unable to find file $(FUJINET_LIB_DOWNLOAD_URL)"; \ - exit 1; \ - fi; \ - echo "Downloading fujinet-lib for $(TARGETLIST) version $(FUJINET_LIB_VERSION) from $(FUJINET_LIB_DOWNLOAD_URL)"; \ - mkdir -p $(FUJINET_LIB); \ - curl -L $(FUJINET_LIB_DOWNLOAD_URL) -o $(FUJINET_LIB_DOWNLOAD_FILE); \ - echo "Unzipping to $(FUJINET_LIB)"; \ - unzip -o $(FUJINET_LIB_DOWNLOAD_FILE) -d $(FUJINET_LIB_VERSION_DIR); \ - echo "Unzip complete."; \ - fi - -# The remaining targets. -$(TARGETOBJDIR): - $(call MKDIR,$@) - -$(R2R_DIR): - $(call MKDIR,$@) - -vpath %.c $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $< - -vpath %.s $(SRCDIR)/$(TARGETLIST) $(SRCDIR) - -$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR) - $(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $< - -$(R2R_BIN): $(CONFIG) $(OBJECTS) $(LIBS) | $(R2R_DIR) - $(CC) -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^) - -# Create the "Ready 2 Run" executable/disk -r2r: get_fujinet_lib $(R2R_BIN) - -test: $(PROGRAM) - $(PREEMUCMD) - $(EMUCMD) $< - $(POSTEMUCMD) - -dist: $(PROGRAM) - exomizer sfx sys config - cp a.out $(DESTDIR)/config - -clean: - $(call RMFILES,$(OBJECTS)) - $(call RMFILES,$(DEPENDS)) - $(call RMFILES,$(REMOVES)) - $(call RMFILES,$(PROGRAM)) - $(call RMFILES,*.map) - -else # $(words $(TARGETLIST)),1 - -all test clean: - $(foreach t,$(TARGETLIST),$(MAKE) TARGETS=$t $@$(NEWLINE)) - -endif # $(words $(TARGETLIST)),1 - -OBJDIRLIST := $(wildcard $(OBJDIR)/*) - -zap: - $(foreach o,$(OBJDIRLIST),-$(call RMFILES,$o/*.o $o/*.d $o/*.lst)$(NEWLINE)) - $(foreach o,$(OBJDIRLIST),-$(call RMDIR,$o)$(NEWLINE)) - -$(call RMDIR,$(OBJDIR)) - -$(call RMFILES,$(basename $(PROGRAM)).* $(STATEFILE)) - -################################################################### -### Place your additional targets in the additional Makefiles ### -### in the same directory - their names have to end with ".mk"! ### -################################################################### --include *.mk diff --git a/Makefile.coco b/Makefile.coco deleted file mode 100644 index 308942e6..00000000 --- a/Makefile.coco +++ /dev/null @@ -1,85 +0,0 @@ -# Makefile for Building CoCo Config with CMOC - -CC=cmoc -AS=lwasm -CP=cp -ECHO=echo -FIRMWARE_DIR="../fujinet-firmware" -CURRENT_TARGET := coco -TARGET_EXEC=config.bin -DISK=autorun.dsk -R2R_DIR=r2r/coco -R2R_BIN=$(R2R_DIR)/$(DISK) - -FUJINET_LIB_VERSION = 4.7.9 -FUJINET_LIB = fujinet-lib - -FUJINET_LIB_VERSION_DIR = $(FUJINET_LIB)/$(FUJINET_LIB_VERSION)-$(CURRENT_TARGET) -FUJINET_LIB_PATH = $(FUJINET_LIB_VERSION_DIR)/fujinet-$(CURRENT_TARGET)-$(FUJINET_LIB_VERSION).lib -FUJINET_LIB_DOWNLOAD_URL = https://github.com/FujiNetWIFI/fujinet-lib/releases/download/v$(FUJINET_LIB_VERSION)/fujinet-lib-$(CURRENT_TARGET)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_DOWNLOAD_FILE = $(FUJINET_LIB)/fujinet-lib-$(CURRENT_TARGET)-$(FUJINET_LIB_VERSION).zip -FUJINET_LIB_BASENAME := $(notdir $(FUJINET_LIB_PATH)) -FUJINET_LIB_SYMLINK := libfujinet-$(CURRENT_TARGET)-$(FUJINET_LIB_VERSION).lib.a - -LIBS=-L $(FUJINET_LIB_VERSION_DIR) -l$(FUJINET_LIB_BASENAME) -CFLAGS=-DUSING_FUJINET_LIB -I$(FUJINET_LIB_VERSION_DIR) -Wno-assign-in-condition -LIMITFLAGS=--org=0E00 --limit=7C00 - -OBJS = check_wifi.o connect_wifi.o destination_host_slot.o hosts_and_devices.o main.o perform_copy.o select_file.o select_slot.o set_wifi.o show_info.o bar.o die.o input.o system.o mount_and_boot.o screen.o strrchr.o strendswith.o pause.o -$(TARGET_EXEC): $(OBJS) - $(CC) $(LIMITFLAGS) -o $@ $^ $(LIBS) - -cfgload.bin: - $(AS) -o $@ src/coco/cfgload.asm - -$(R2R_BIN): $(TARGET_EXEC) cfgload.bin dist.coco/autoexec.bas | $(R2R_DIR) - $(RM) $@ - decb dskini $@ - decb copy -t -0 dist.coco/autoexec.bas $@,AUTOEXEC.BAS - writecocofile $@ cfgload.bin - writecocofile $@ $< - -dist: $(R2R_BIN) cfgload.bin - $(CP) $< $(FIRMWARE_DIR)/data/webui/device_specific/BUILD_COCO/ - $(ECHO) Now, Do a Upload Filesystem task. - -.PHONY: r2r get_fujinet_lib - -# Create the "Ready 2 Run" executable/disk -r2r: $(R2R_BIN) - -get_fujinet_lib: - @if [ ! -f "$(FUJINET_LIB_DOWNLOAD_FILE)" ]; then \ - if [ -d "$(FUJINET_LIB_VERSION_DIR)" ]; then \ - echo "A directory already exists with version $(FUJINET_LIB_VERSION) - please remove it first"; \ - exit 1; \ - fi; \ - HTTPSTATUS=$$(curl -Is $(FUJINET_LIB_DOWNLOAD_URL) | head -n 1 | awk '{print $$2}'); \ - if [ "$${HTTPSTATUS}" == "404" ]; then \ - echo "ERROR: Unable to find file $(FUJINET_LIB_DOWNLOAD_URL)"; \ - exit 1; \ - fi; \ - echo "Downloading fujinet-lib for $(CURRENT_TARGET) version $(FUJINET_LIB_VERSION) from $(FUJINET_LIB_DOWNLOAD_URL)"; \ - mkdir -p $(FUJINET_LIB); \ - curl -L $(FUJINET_LIB_DOWNLOAD_URL) -o $(FUJINET_LIB_DOWNLOAD_FILE); \ - echo "Unzipping to $(FUJINET_LIB)"; \ - unzip -o $(FUJINET_LIB_DOWNLOAD_FILE) -d $(FUJINET_LIB_VERSION_DIR); \ - echo "Unzip complete."; \ - cd "$(FUJINET_LIB_VERSION_DIR)" && ln -sf "$(FUJINET_LIB_BASENAME)" "$(FUJINET_LIB_SYMLINK)" ; \ - fi - -$(R2R_DIR): - mkdir -p $@ - -%.o: %.c get_fujinet_lib - $(CC) $(CFLAGS) -c -o $@ $< - -vpath %.c src src/coco - -clean: - $(RM) *.o - $(RM) coco/*.o - $(RM) cfgload.bin - $(RM) $(TARGET_EXEC) - $(RM) $(DISK) - $(RM) $(R2R_BIN) diff --git a/Makefile.dragon b/Makefile.dragon deleted file mode 100644 index f80f0a24..00000000 --- a/Makefile.dragon +++ /dev/null @@ -1,107 +0,0 @@ -# Makefile for Building CoCo Config with CMOC - -CC=cmoc -AS=lwasm -CP=cp -MV=mv -CFLAGS=-c --dragon -DDRAGON -O2 --no-relocate -ECHO=echo -FIRMWARE_DIR="../fujinet-firmware" - -all: configd.bin configx.bin - -CONFIGOBJS = check_wifi.o connect_wifi.o destination_host_slot.o hosts_and_devices.o main.o perform_copy.o select_file.o select_slot.o set_wifi.o show_info.o bar.o die.o input.o io.o mount_and_boot.o screen.o strrchr.o pause.o - - -#HIRESLIB = src/coco/hirestxt-0.5.0/libhirestxt_dgn.a - -configd.bin: $(CONFIGOBJS) - $(CC) --dragon --org=2601 --limit=7800 -O2 --no-relocate -o configd.bin $(CONFIGOBJS) - #$(CC) --dragon --raw -o configd.bin $(HIRESLIB) $(CONFIGOBJS) - $(ECHO) Now, Do a Upload Filesystem task. - rm -f autorund.vdk - dragondos new autorund.vdk 360 - dragondos list autorund.vdk - #for i in $^; do dragondos insertbinary ./autorund.vdk $$i 0x2601 0x2601; done - dragondos insertbinary ./autorund.vdk ./configd.bin 0x2601 0x2601 - dragondos list autorund.vdk - $(CP) autorund.vdk ~/tnfs/ - $(CP) autorund.vdk ../fujinet-firmware/data/webui/device_specific/BUILD_COCO/ - $(CP) autorund.vdk ../fujinet-firmware/data/BUILD_COCO/ - $(CP) configd.bin AUTOLOAD.DWL - $(CP) AUTOLOAD.DWL ../fujinet-firmware/data/BUILD_COCO/ - $(CP) AUTOLOAD.DWL ../fujinet-firmware/data/webui/device_specific/BUILD_COCO/ - - $(ECHO) Now, Do a Upload Filesystem task. - -# One option for autoload is to just create the config file as a dragon binary and load this with the DW4 named object mechanism -# -configx.bin: check_wifi.o connect_wifi.o destination_host_slot.o hosts_and_devices.o main.o perform_copy.o select_file.o select_slot.o set_wifi.o show_info.o bar.o die.o input.o io.o mount_and_boot.o screen.o strrchr.o pause.o - $(CC) --verbose -O2 --dragon -o configx.bin $(HIRESLIB) check_wifi.o connect_wifi.o destination_host_slot.o hosts_and_devices.o main.o perform_copy.o select_file.o select_slot.o set_wifi.o show_info.o bar.o die.o input.o io.o mount_and_boot.o screen.o strrchr.o pause.o -# --org=2601 --limit=7800 -# $(CP) configx.bin AUTOLOAD.DWL -# $(CP) AUTOLOAD.DWL ../original/data/BUILD_COCO/AUTOLOAD.DWL -# $(CP) AUTOLOAD.DWL ../original/data/webui/device_specific/BUILD_COCO/AUTOLOAD.DWL - -pause.o: src/coco/pause.c - $(CC) $(CFLAGS) src/coco/pause.c - -strrchr.o: src/coco/strrchr.c - $(CC) $(CFLAGS) src/coco/strrchr.c - -check_wifi.o: src/check_wifi.c - $(CC) $(CFLAGS) src/check_wifi.c - -connect_wifi.o: src/connect_wifi.c - $(CC) $(CFLAGS) src/connect_wifi.c - -destination_host_slot.o: src/destination_host_slot.c - $(CC) $(CFLAGS) src/destination_host_slot.c - -hosts_and_devices.o: src/hosts_and_devices.c - $(CC) $(CFLAGS) src/hosts_and_devices.c - -main.o: src/main.c - $(CC) $(CFLAGS) src/main.c - -perform_copy.o: src/perform_copy.c - $(CC) $(CFLAGS) src/perform_copy.c - -select_file.o: src/select_file.c - $(CC) $(CFLAGS) src/select_file.c - -select_slot.o: src/select_slot.c - $(CC) $(CFLAGS) src/select_slot.c - -set_wifi.o: src/set_wifi.c - $(CC) $(CFLAGS) src/set_wifi.c - -show_info.o: src/show_info.c - $(CC) $(CFLAGS) src/show_info.c - -bar.o: src/coco/bar.c - $(CC) $(CFLAGS) src/coco/bar.c - -die.o: src/coco/die.c - $(CC) $(CFLAGS) src/coco/die.c - -input.o: src/coco/input.c - $(CC) $(CFLAGS) src/coco/input.c - -io.o: src/coco/io.c - $(CC) $(CFLAGS) src/coco/io.c - -mount_and_boot.o: src/coco/mount_and_boot.c - $(CC) $(CFLAGS) src/coco/mount_and_boot.c - -screen.o: src/coco/screen.c - $(CC) $(CFLAGS) src/coco/screen.c - -clean: - $(RM) *.o - $(RM) coco/*.o - $(RM) config.bin - $(RM) autorund.vdk - $(RM) AUTOLOAD.DWL - - diff --git a/Makefile.msdos b/Makefile.msdos deleted file mode 100644 index c7ab97f3..00000000 --- a/Makefile.msdos +++ /dev/null @@ -1,74 +0,0 @@ -TARGET = config.com -R2R_DIR = r2r/msdos -R2R_BIN = $(R2R_DIR)/$(TARGET) - -CC = wcc -CFLAGS = -q -0 -bt=dos -ms -osh $(CPPFLAGS) -i=src -i=src/msdos - -LD = wlink OPTION quiet -LDFLAGS = SYSTEM dos com OPTION MAP - -OBJS = src/check_wifi.obj src/connect_wifi.obj src/destination_host_slot.obj src/hosts_and_devices.obj src/main.obj src/perform_copy.obj src/select_file.obj src/select_slot.obj src/set_wifi.obj src/show_info.obj src/msdos/bar.obj src/msdos/die.obj src/msdos/input.obj src/msdos/io.obj src/msdos/mount_and_boot.obj src/msdos/screen.obj -SOURCE = src/check_wifi.c src/connect_wifi.c src/destination_host_slot.c src/hosts_and_devices.c src/main.c src/perform_copy.c src/select_file.c src/select_slot.c src/set_wifi.c src/show_info.c src/msdos/bar.c src/msdos/die.c src/msdos/input.c src/msdos/io.c src/msdos/mount_and_boot.c src/msdos/screen.c - -all: $(TARGET) - -# Create the "Ready 2 Run" executable/disk -r2r: $(R2R_BIN) - -$(R2R_BIN): $(OBJS) | $(R2R_DIR) - $(LD) $(LDFLAGS) NAME $@ - -$(R2R_DIR): - mkdir -p $@ - -src/check_wifi.obj: src/check_wifi.c - $(CC) $(CFLAGS) src/check_wifi.c - -src/connect_wifi.obj: src/connect_wifi.c - $(CC) $(CFLAGS) src/connect_wifi.c - -src/destination_host_slot.obj: src/destination_host_slot.c - $(CC) $(CFLAGS) src/destination_host_slot.c - -src/hosts_and_devices.obj: src/hosts_and_devices.c - $(CC) $(CFLAGS) src/hosts_and_devices.c - -src/main.obj: src/main.c - $(CC) $(CFLAGS) src/main.c - -src/perform_copy.obj: src/perform_copy.c - $(CC) $(CFLAGS) src/perform_copy.c - -src/select_file.obj: src/select_file.c - $(CC) $(CFLAGS) src/select_file.c - -src/select_slot.obj: src/select_slot.c - $(CC) $(CFLAGS) src/select_slot.c - -src/set_wifi.obj: src/set_wifi.c - $(CC) $(CFLAGS) src/set_wifi.c - -src/show_info.obj: src/show_info.c - $(CC) $(CFLAGS) src/show_info.c - -src/msdos/bar.obj: src/msdos/bar.c - $(CC) $(CFLAGS) src/msdos/bar.c - -src/msdos/die.obj: src/msdos/die.c - $(CC) $(CFLAGS) src/msdos/die.c - -src/msdos/input.obj: src/msdos/input.c - $(CC) $(CFLAGS) src/msdos/input.c - -src/msdos/io.obj: src/msdos/io.c - $(CC) $(CFLAGS) src/msdos/io.c - -src/msdos/mount_and_boot.obj: src/msdos/mount_and_boot.c - $(CC) $(CFLAGS) src/msdos/mount_and_boot.c - -src/msdos/screen.obj: src/msdos/screen.c - $(CC) $(CFLAGS) src/msdos/screen.c - -clean: .SYMBOLIC - rm -f $(OBJS) $(OUT) diff --git a/Makefile.pc6001 b/Makefile.pc6001 deleted file mode 100644 index 801d5645..00000000 --- a/Makefile.pc6001 +++ /dev/null @@ -1,47 +0,0 @@ -TARGET_EXEC ?= autorun - -BUILD_DIR ?= ./build -SRC_DIRS ?= ./src - -ADDL_DIR1 := -ADDL_DIR2 := - -ADDL_LIB1 := -ADDL_LIB2 := - -CC=zcc -AS=zcc - -SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *_pc6001.asm) -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) -DEPS := $(OBJS:.o=.d) - -CFLAGS=+pc6001 -DBUILD_PC6001 -LDFLAGS=+pc6001 -o$(TARGET_EXEC) -create-app -ASFLAGS=+pc6001 - -INC_DIRS := $(shell find $(SRC_DIRS) -type d) -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) - #cp autorun.ddp ../fujinet-platformio/data/BUILD_PC6001/ - -# c source -$(BUILD_DIR)/%.c.o: %.c - $(MKDIR_P) $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -# asm source -$(BUILD_DIR)/%.asm.o: %.asm - $(MKDIR_P) $(dir $@) - $(AS) $(ASFLAGS) -c $< -o $@ - -.PHONY: clean - -clean: - $(RM) -r autorun* $(BUILD_DIR) - --include $(DEPS) - -MKDIR_P ?= mkdir -p diff --git a/Makefile.pc8801 b/Makefile.pc8801 deleted file mode 100644 index 3c3359d9..00000000 --- a/Makefile.pc8801 +++ /dev/null @@ -1,47 +0,0 @@ -TARGET_EXEC ?= autorun.d88 - -BUILD_DIR ?= ./build -SRC_DIRS ?= ./src - -ADDL_DIR1 := -ADDL_DIR2 := - -ADDL_LIB1 := -ADDL_LIB2 := - -CC=zcc -AS=zcc - -SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *_pc8801.asm) -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) -DEPS := $(OBJS:.o=.d) - -CFLAGS=+pc88 -subtype=disk -DBUILD_PC8801 -LDFLAGS=+pc88 -subtype=disk -o$(TARGET_EXEC) -create-app -ASFLAGS=+pc88 -subtype=disk - -INC_DIRS := $(shell find $(SRC_DIRS) -type d) -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) - #cp autorun.ddp ../fujinet-platformio/data/BUILD_PC8801/ - -# c source -$(BUILD_DIR)/%.c.o: %.c - $(MKDIR_P) $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -# asm source -$(BUILD_DIR)/%.asm.o: %.asm - $(MKDIR_P) $(dir $@) - $(AS) $(ASFLAGS) -c $< -o $@ - -.PHONY: clean - -clean: - $(RM) -r autorun* $(BUILD_DIR) - --include $(DEPS) - -MKDIR_P ?= mkdir -p diff --git a/Makefile.pmd85 b/Makefile.pmd85 deleted file mode 100644 index 5b4d682b..00000000 --- a/Makefile.pmd85 +++ /dev/null @@ -1,63 +0,0 @@ -TARGET_EXEC ?= config.bin - -BUILD_DIR ?= ./build -SRC_DIRS ?= ./src - -CC=zcc -AS=zcc - -SRCS := $(wildcard $(SRC_DIRS)/*.c) $(wildcard $(SRC_DIRS)/pmd85/*.c) -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) -DEPS := $(OBJS:.o=.d) - -# C to ASM, for debug -ASMGEN := $(SRCS:%=$(BUILD_DIR)/%.asm) - -CFLAGS=+pmd85 -DBUILD_PMD85 -LDFLAGS=+pmd85 -create-app -o $(TARGET_EXEC) -ASFLAGS=+pmd85 - -INC_DIRS := $(shell find $(SRC_DIRS) -type d) -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -# ROM Module -autorun.rmm: romload.bin $(BUILD_DIR)/$(TARGET_EXEC) - (cat romload.bin; dd if=$(BUILD_DIR)/$(TARGET_EXEC) count=4 bs=1 status=none; \ - dd if=$(BUILD_DIR)/$(TARGET_EXEC) skip=13 bs=1 status=none) > autorun.rmm -# cp autorun.rmm ../fujinet-firmware/data/webui/device_specific/BUILD_PMD85/ - -# $(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) $(ASMGEN) -$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) - mv $(TARGET_EXEC) $(BUILD_DIR) - mv $$(basename $(TARGET_EXEC) .bin).ptp $(BUILD_DIR) - -# ROM Module boot code -romload.bin: - printf '\xcd\x00\x8c\x00\x00\xff\x5f\x00\x00' > romload.bin - -# c source to asm, for debug -$(BUILD_DIR)/%.c.asm: %.c - $(MKDIR_P) $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -a $< -o $@ - -# c source -$(BUILD_DIR)/%.c.o: %.c - $(MKDIR_P) $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -# asm source -$(BUILD_DIR)/%.asm.o: %.asm - $(MKDIR_P) $(dir $@) - $(AS) $(ASFLAGS) -c $< -o $@ - -.PHONY: clean all - -clean: - $(RM) -r autorun* romload.bin $(BUILD_DIR) - -all: autorun.rmm - --include $(DEPS) - -MKDIR_P ?= mkdir -p diff --git a/Makefile.rc2014 b/Makefile.rc2014 deleted file mode 100644 index b4c01dbc..00000000 --- a/Makefile.rc2014 +++ /dev/null @@ -1,44 +0,0 @@ -TARGET_EXEC ?= fnconfig - -BUILD_DIR ?= ./build -SRC_DIRS ?= ./src - -LIB_PROJECT := -l../fujinet-rc2014/libfn_cpm -l../fujinet-rc2014/libfujinet -LIB_PROJECT_INC := ../fujinet-rc2014/lib/include - -CC=zcc -AS=zcc - -SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *_rc2014.asm) -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) -DEPS := $(OBJS:.o=.d) - -CFLAGS=+cpm -DBUILD_RC2014 -I$(LIB_PROJECT_INC) -compiler=sdcc -clib=ansi -pragma-redirect:fputc_cons=fputc_cons_generic -LDFLAGS=+cpm -create-app -I$(LIB_PROJECT_INC) -o$(TARGET_EXEC) -ASFLAGS=+cpm - -INC_DIRS := $(shell find $(SRC_DIRS) -type d) -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) $(LIB_PROJECT) - #cp autorun.ddp ../fujinet-platformio/data/BUILD_ADAM/ - -# c source -$(BUILD_DIR)/%.c.o: %.c - $(MKDIR_P) $(dir $@) - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -# asm source -$(BUILD_DIR)/%.asm.o: %.asm - $(MKDIR_P) $(dir $@) - $(AS) $(ASFLAGS) -c $< -o $@ - -.PHONY: clean - -clean: - $(RM) -r FNCONFIG* fnconfig* $(BUILD_DIR) - --include $(DEPS) - -MKDIR_P ?= mkdir -p diff --git a/copy_libs.sh b/copy_libs.sh deleted file mode 100644 index db1f40f8..00000000 --- a/copy_libs.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# This script will copy the generated FUJINET-LIB zips from a local development directory -# set by FUJI_LIB_DIR, allowing using non-published versions of the libraries - -# specify platforms to copy, eventually will include pet, vic20 etc. -PLATFORMS="apple2 apple2enh c64 atari" -FUJI_LIB_DIR=${FUJI_LIB_DIR:-/d/dev/atari/fujinet/fujinet-lib} - -ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -#VERSION=$(grep '^FUJINET_LIB_VERSION :=' makefiles/fujinet-lib.mk | awk '{print $3}') -VERSION=4.6.2 - -#rm -rf ${ROOT_DIR}/fujinet-lib -mkdir ${ROOT_DIR}/fujinet-lib > /dev/null 2>&1 - -for platform in ${PLATFORMS}; do - ZIP_FILE=${FUJI_LIB_DIR}/dist/fujinet-lib-${platform}-${VERSION}.zip - - if [ ! -f ${ZIP_FILE} ]; then - echo "Couldn't find $ZIP_FILE" - exit 1 - fi - - cp ${ZIP_FILE} ${ROOT_DIR}/fujinet-lib - rm -rf ${ROOT_DIR}/fujinet-lib/${VERSION}-${platform} - unzip ${ZIP_FILE} -d ${ROOT_DIR}/fujinet-lib/${VERSION}-${platform} -done diff --git a/dist.apple2/add-file.sh b/dist.apple2/add-file.sh deleted file mode 100755 index b1394475..00000000 --- a/dist.apple2/add-file.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -if [ $# -lt 3 ]; then - echo "Usage: $(basename $0) DISK.po FILE_TO_ADD NAME [TYPE]" - echo " Copies FILE_TO_ADD to DISK.po giving it name NAME" - echo " If TYPE is given, it will be used, othwerwise, AppleSingle (as) type is assumed" - exit 1 -fi - -JAVA_LOCATION=$(which java) -if [ $? -eq 1 ]; then - echo "Unable to find java on command line. You must have a working java at least version 11 to use this script." - exit 1 -fi - -DISKFILE=$1 -if [ ! -f $DISKFILE ]; then - echo "Unable to find target DISK." - exit 1 -fi - -INFILE=$2 -if [ ! -f $INFILE ]; then - echo "Unable to find file to put on disk." - exit 1 -fi - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/get-binaries.sh - -NAME=$3 - -# Types are listed in https://github.com/AppleCommander/AppleCommander/blob/main/lib/ac-api/src/main/resources/com/webcodepro/applecommander/storage/os/prodos/ProdosFileTypes.properties -# Typically "cda" or "exe" are used. "as" means use -as flag instead of -p -TYPE="as" -if [ $# -eq 4 ]; then - TYPE=$4 -fi - -if [ "$TYPE" == "as" ]; then - ${AC} -as ${DISKFILE} ${NAME} < ${INFILE} -else - ${AC} -p ${DISKFILE} ${NAME} ${TYPE} < ${INFILE} -fi diff --git a/dist.apple2/bootable.po b/dist.apple2/bootable.po deleted file mode 100644 index 57aba7ad..00000000 Binary files a/dist.apple2/bootable.po and /dev/null differ diff --git a/dist.apple2/dist.po b/dist.apple2/dist.po deleted file mode 100644 index e48fdafd..00000000 Binary files a/dist.apple2/dist.po and /dev/null differ diff --git a/dist.apple2/get-binaries.sh b/dist.apple2/get-binaries.sh deleted file mode 100755 index e2b2e454..00000000 --- a/dist.apple2/get-binaries.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# Source this file, e.g. -# source ../dist.apple2/get-binaries.sh - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -OLD_VER="1.8.0" -if [ -f "${SCRIPT_DIR}/AppleCommander-ac-${OLD_VER}.jar" ] ; then - rm ${SCRIPT_DIR}/AppleCommander-ac-${OLD_VER}.jar - rm ${SCRIPT_DIR}/AppleCommander-acx-${OLD_VER}.jar -fi - -AC_VER="1.9.0" -AC="java -jar ${SCRIPT_DIR}/AppleCommander-ac-${AC_VER}.jar" -ACX="java -jar ${SCRIPT_DIR}/AppleCommander-acx-${AC_VER}.jar" - - -if [ ! -f ${SCRIPT_DIR}/AppleCommander-ac-${AC_VER}.jar ]; then - curl -s -L -o ${SCRIPT_DIR}/AppleCommander-ac-${AC_VER}.jar https://github.com/AppleCommander/AppleCommander/releases/download/${AC_VER}/AppleCommander-ac-${AC_VER}.jar - curl -s -L -o ${SCRIPT_DIR}/AppleCommander-acx-${AC_VER}.jar https://github.com/AppleCommander/AppleCommander/releases/download/${AC_VER}/AppleCommander-acx-${AC_VER}.jar -fi diff --git a/dist.apple2/mk-bitsy.sh b/dist.apple2/mk-bitsy.sh deleted file mode 100755 index a1f5c0f1..00000000 --- a/dist.apple2/mk-bitsy.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -if [ $# -ne 2 ] ; then - echo "Usage: $(basename $0) name.po VOLUMENAME" - echo "Creates name.po and places BITSY.BOOT files on it, ready to copy applications onto." - exit 1 -fi - -JAVA_LOCATION=$(which java) -if [ $? -eq 1 ]; then - echo "Unable to find java on command line. You must have a working java at least version 11 to use this script." - exit 1 -fi - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/get-binaries.sh - -if [ ! -f ${SCRIPT_DIR}/ProDOS_2_4_2.dsk ]; then - curl -s -L -o ${SCRIPT_DIR}/ProDOS_2_4_2.dsk https://mirrors.apple2.org.za/ftp.apple.asimov.net/images/masters/prodos/ProDOS_2_4_2.dsk -fi - -DISKNAME=$1 -# Convert underscores and hyphens to fullstops in the name, as they aren't allowed. Maybe others! -VOLUMENAME=$(echo $2 | tr '_-' '.') -if [ -f $DISKNAME ] ; then - rm $DISKNAME -fi - -SRC_PRODOS=${SCRIPT_DIR}/ProDOS_2_4_2.dsk - -export ACX_DISK_NAME=${DISKNAME} - -${ACX} create --prodos -f ${SRC_PRODOS} -${ACX} rm -f BASIC.SYSTEM -${ACX} copy --from ${SRC_PRODOS} BITSY.BOOT QUIT.SYSTEM BASIC.SYSTEM -${ACX} rename-disk ${VOLUMENAME} diff --git a/makefiles/0_DO_NOT_CUSTOMIZE_THESE_FILES.md b/makefiles/0_DO_NOT_CUSTOMIZE_THESE_FILES.md new file mode 120000 index 00000000..42061c01 --- /dev/null +++ b/makefiles/0_DO_NOT_CUSTOMIZE_THESE_FILES.md @@ -0,0 +1 @@ +README.md \ No newline at end of file diff --git a/makefiles/README.md b/makefiles/README.md new file mode 100644 index 00000000..db55c304 --- /dev/null +++ b/makefiles/README.md @@ -0,0 +1,284 @@ +# Makefile Framework + +This directory provides a modular framework of Makefiles. + +The main goal is to make it easy to: + +* Add new computer platforms by dropping in a new + platforms/.mk file. +* Avoid per-project hacks inside platform makefiles. +* Keep all project-specific customization in the top-level Makefile, + where it’s visible and easy to maintain. + +Think of this as a library of Makefiles. + +* `platforms/*.mk` files provide reusable rules — how to build + executables, how to create disk images, and other platform-specific + steps. +* `toolchains/*.mk` files define compiler-specific flags and helper + functions. +* The project’s top-level Makefile ties everything together, declaring + what to build while reusing the shared rules. + +The result is a modular system: platforms and toolchains know *how* to +build, and the top-level Makefile defines *what* to build. + +## 1. The Top-Level Makefile + +The **project’s Makefile** is the only file you should need to edit +when starting a new project. It contains: + +- Your project’s `PRODUCT` name. +- The `PLATFORMS` you want to build for. +- The `SRC_DIRS` containing your source code. +- Optional project-specific rules or custom targets. + +You can run: + +``` +make +``` + +This will build for every platform listed in the `PLATFORMS` variable. + +Or, you can build for a single platform or platform-specific target: + +``` +make +make / +``` + +Examples: + +``` +make coco +make apple2/disk +``` + +### FujiNet library (`FUJINET_LIB`) + +This variable specifies which FujiNet library to use when building your project. It supports several formats: + +* **Version number** — e.g., `4.7.6` +* **Directory** — a path containing the libraries for each platform +* **Zip archive** — a locally built or downloaded zip file containing the library +* **Git repository URL** — a remote repo to clone +* **Empty** — automatically uses the latest available library +* **Undefined** — disables use of a FujiNet library entirely + +#### Example + +``` +# Use FujiNet library version 4.7.6 +FUJINET_LIB = 4.7.6 +``` + +### Source directories (`SRC_DIRS`) + +`SRC_DIRS` lists the directories `make` should search for source +files. You can use the literal `%PLATFORM%` token to have directories +expand automatically based on the platform being built. + +Example: + +``` +SRC_DIRS = src src/%PLATFORM% +``` + +> Note: `%PLATFORM%` is used instead of `$(PLATFORM)` to avoid + accidental expansion in unrelated directory names. See Platform + Combos below. + +### Platform Combos (`PLATFORM_COMBOS`) + +`PLATFORM_COMBOS` defines extra directories (or “combo” platforms) +that are automatically included whenever a main platform is +built. This lets a single platform pull in multiple source directories. + +Format: + +``` +PLATFORM_COMBOS = \ + platform1+=combo1,combo2 \ + platform2+=comboA,comboB +``` + +Example: + +``` +PLATFORM_COMBOS = \ + c64+=commodore,eightbit \ + atarixe+=atari +``` + +With `SRC_DIRS = src src/%PLATFORM%`, building for `c64` would expand `%PLATFORM%` into: + +- `src/c64` +- `src/commodore` +- `src/eightbit` + +### The `r2r` Target + +The `r2r` target is the **default build output** for a platform. It +will always build the platform’s executable. For some platforms, it +also creates a bootable disk image. + +For example: + +- On **CoCo**, `r2r` builds a `.bin` file and a `.dsk` disk image. +- On **Apple II**, `r2r` builds an AppleSingle file and a `.po` disk image. +- Other platforms behave similarly depending on their toolchains. + +#### Output Location + +All build artifacts go under the `r2r//` directory: + +- Executables: `r2r//.` +- Optional disk images: `r2r//.dsk` + +### Customizing Per Platform or Compiler + +There are two kinds of per-platform/per-compiler variables: + +1. Extra include directories – add paths for the compiler and assembler to search: + * Use `EXTRA_INCLUDE` or `EXTRA_INCLUDE_`to specify one or + more directories. They are automatically added to `-I` flags + during compilation and assembly. +2. Extras flags – add flags or options without removing the defaults: + * Example: `LDFLAGS_EXTRA_COCO` adds extra linker flags when building for CoCo. +3. Overrides – completely replace the default for a platform: + * Example: `CC_APPLE2` sets the compiler to use for Apple II, + replacing the default `cc65` setup. + +### Platform-specific r2r or disk steps + +You can add platform-specific actions by defining double-colon targets: + +``` +/r2r:: +/disk:: +``` + +Examples: + +``` +coco/r2r:: coco/custom-step1 +coco/r2r:: coco/custom-step2 +``` + +Or define a full recipe: + +``` +coco/r2r:: + echo "Doing something special for Coco r2r" + ./tools/special-process coco +``` + +Notes: + +* Double-colon `::` allows multiple isolated definitions for the same target without overwriting existing ones. +* You can also use single-colon `:` if you want a single line with multiple dependencies: + +``` +coco/r2r: coco/custom-step1 coco/custom-step2 +``` + +This mechanism allows you to build additional things for a specific +platform when building standard targets. + +### Post-build hooks and extra dependencies + +For advanced customization, you can define extra dependencies and +post-build targets. These allow you to: + +* Ensure extra files are built or up to date before a main build step. +* Run additional commands **after** a build step, without modifying the main recipe. + +#### Key points + +* The extra dependencies variables (e.g., `EXECUTABLE_EXTRA_DEPS_COCO`, + `DISK_EXTRA_DEPS_COCO`, `R2R_EXTRA_DEPS_COCO`) **do not automatically + add files to the output**. They only make sure that your custom + files are rebuilt when modified. +* You are responsible for handling these extra dependencies + appropriately in your post-build steps. For instance, adding files + to a disk requires platform-specific commands. + +#### Example: Adding files to a COCO disk + +``` +DISK_EXTRA_DEPS_COCO := r2r/coco/4voice.bin basic/coco/song.bas + +coco/disk-post:: + decb copy -b -2 r2r/coco/4voice.bin "$(DISK),4VOICE.BIN" + decb copy -t -0 basic/coco/song.bas "$(DISK),SONG.BAS" +``` + +Notes: + +* Each `/disk-post` target must be defined if you want + post-processing for that platform. +* Multiple post targets for the same platform can coexist thanks to + double-colon `::`. +* This mechanism allows you to safely manipulate build outputs like + executables or disk images without changing the original recipes. + +--- + +## 2. Mid-Level Files + +There are three “mid-level” Makefiles that provide shared rules: + +- **`common.mk`** + Defines shared variables and helper rules. + +- **`toplevel-rules.mk`** + Provides project-wide rules for building, cleaning, and delegating + into the platform Makefiles. This file is what ties the + `platforms/*.mk` and `toolchains/*.mk` files into your project. + +- **`tc-common.mk`** + Provides common things for the `toolchains/*.mk` files. + +--- + +## 3. Platform Makefiles (`platforms/*.mk`) + +Each file in `platforms/` defines how to build for a **specific computer platform**. +This includes: + +- How to build the main executable (`EXECUTABLE`). +- How to package artifacts (like creating a disk image). +- Any special quirks for that system’s toolchain. + +--- + +## 4. Tool Chain Makefiles (`toolchains/*.mk`) + +These files define toolchain-specific behavior, such as: + +- How to compile `.c` or `.s` files. +- What flags to use for linking. +- What commands to use for `LD`, `CC`, or `AR`. + +For example, you can override the linker for a project like this in your top-level Makefile: + +``` +LD_COCO = ./my-custom-ld-wrapper.sh +``` + +Then your wrapper script can call the real linker and perform additional steps on the output. + +This keeps toolchain logic reusable across multiple platforms. + +--- + +## Summary + +- **Top-level Makefile**: project-specific: define `PLATFORM`, `PRODUCT`, and any extra targets. +- **common.mk, toplevel-rules.mk, tc-common.mk**: glue: connect top-level, platforms, and toolchains. +- **platforms/*.mk**: platform-specific: rules for executables, disk images, quirks. +- **toolchains/*.mk**: toolchain-specific: flags and build rules. + +All customization should happen in the **top-level Makefile**. +The rest of the framework is designed to be reused without modification. diff --git a/makefiles/common.mk b/makefiles/common.mk new file mode 100644 index 00000000..8be02f5f --- /dev/null +++ b/makefiles/common.mk @@ -0,0 +1,172 @@ +define pop + $(wordlist 1, $(shell echo $$(($(words $(1)) - 1))), $(1)) +endef + +# Automatically figure out PLATFORM from the .mk file that included us +PLATFORM_MK := $(call pop,$(MAKEFILE_LIST)) +PLATFORM := $(basename $(notdir $(lastword $(PLATFORM_MK)))) +PLATFORM_UC := $(shell echo "$(PLATFORM)" | tr '[:lower:]' '[:upper:]') +$(info Building for PLATFORM=$(PLATFORM)) + +# Add GIT_VERSION macro define to CFLAGS, includes tag if available, +# short commit hash, appends '*' if changes haven't been commited +CFLAGS += -DGIT_VERSION='\"$(shell git rev-parse --short HEAD)$(shell git status --porcelain | grep -q '^[ MADRCU]' && echo '*')\"' + +include $(MWD)/../Makefile + +# Add GIT_VERSION macro define to CFLAGS, includes tag if available, +# short commit hash, appends '*' if changes haven't been commited +CFLAGS += -DGIT_VERSION='\"$(shell git rev-parse --short HEAD)$(shell git status --porcelain | grep -q '^[ MADRCU]' && echo '*')\"' + +IS_LIBRARY := $(if $(filter %.lib,$(PRODUCT)),1,0) +ifeq ($(IS_LIBRARY),1) + PRODUCT_BASE = $(basename $(PRODUCT)) + BUILD_LIB = $(LIBRARY) +else + PRODUCT_BASE = $(PRODUCT) + BUILD_EXEC = $(EXECUTABLE) + BUILD_DISK = $(DISK) +endif + +# Only set DEFAULT if the specific tool is non-empty +ifneq ($(strip $(CC_$(TOOLCHAIN_UC))),) +CC_DEFAULT = $(CC_$(TOOLCHAIN_UC)) +endif + +ifneq ($(strip $(AS_$(TOOLCHAIN_UC))),) +AS_DEFAULT = $(AS_$(TOOLCHAIN_UC)) +endif + +ifneq ($(strip $(LD_$(TOOLCHAIN_UC))),) +LD_DEFAULT = $(LD_$(TOOLCHAIN_UC)) +endif + +ifneq ($(strip $(PC_$(TOOLCHAIN_UC))),) +PC_DEFAULT = $(PC_$(TOOLCHAIN_UC)) +endif + +R2R_PD := $(R2R_DIR)/$(PLATFORM) +OBJ_DIR := $(BUILD_DIR)/$(PLATFORM) +CACHE_PLATFORM := $(CACHE_DIR)/$(PLATFORM) +MKDIR_P ?= mkdir -p + +# Expand PLATFORM_COMBOS entries into a lookup form +# c64+=commodore,eightbit -> c64 commodore eightbit +# PLATFORM_COMBOS is a flat list of entries like "dragon+=coco" +# $1 = the platform to expand +get_combos = $(foreach e,$(PLATFORM_COMBOS),\ + $(if $(filter $1+=%, $(e)), $(lastword $(subst +=, ,$(e))))) + +# Expands patterns with %PLATFORM% to the platform + its combos +expand_platform_pattern = \ + $(foreach d,$(1), \ + $(if $(findstring %PLATFORM%,$(d)), \ + $(foreach p,$(PLATFORM) $(call get_combos,$(PLATFORM)), \ + $(subst %PLATFORM%,$(p),$(d))), \ + $(d))) + +# The fully expanded list of source directories +SRC_DIRS_EXPANDED := $(call expand_platform_pattern,$(SRC_DIRS)) + +# Find all the CFILES and AFILES +CFILES := $(foreach dir,$(SRC_DIRS_EXPANDED),$(wildcard $(dir)/*.c)) +AFILES := $(foreach dir,$(SRC_DIRS_EXPANDED),$(wildcard $(dir)/*.s)) \ + $(foreach dir,$(SRC_DIRS_EXPANDED),$(wildcard $(dir)/*.asm)) +PFILES := $(foreach dir,$(SRC_DIRS_EXPANDED),$(wildcard $(dir)/*.pas)) + +# Need two steps: AFILES may be .s or .asm; `make` swaps one suffix at a time +NORM_AFILES := $(AFILES:.asm=.s) +OBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(CFILES:.c=.o) $(NORM_AFILES:.s=.o) $(PFILES:.pas=.o))) + +$(BUILD_EXEC):: $(OBJS) $(EXECUTABLE_EXTRA_DEPS_$(PLATFORM_UC)) | $(R2R_PD) + $(call link-bin,$@,$(OBJS)) + @$(MAKE) -f $(PLATFORM_MK) $(PLATFORM)/executable-post + +$(BUILD_LIB):: $(OBJS) $(LIBRARY_EXTRA_DEPS_$(PLATFORM_UC)) | $(R2R_PD) + $(call link-lib,$@,$(OBJS)) + @$(MAKE) -f $(PLATFORM_MK) $(PLATFORM)/library-post + +# auto-created dirs +AUTO_DIRS := $(OBJ_DIR) $(R2R_PD) $(CACHE_PLATFORM) +$(AUTO_DIRS): + $(MKDIR_P) $@ + +$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR) + $(call compile,$@,$<) +$(OBJ_DIR)/%.o: %.s | $(OBJ_DIR) + $(call assemble,$@,$<) +$(OBJ_DIR)/%.o: %.asm | $(OBJ_DIR) + $(call assemble,$@,$<) +$(OBJ_DIR)/%.o: %.pas | $(OBJ_DIR) + $(call compile-pas,$@,$<) + +vpath %.c $(SRC_DIRS_EXPANDED) +vpath %.s $(SRC_DIRS_EXPANDED) +vpath %.asm $(SRC_DIRS_EXPANDED) +vpath %.pas $(SRC_DIRS_EXPANDED) + +.PHONY: clean debug r2r $(PLATFORM)/r2r disk $(PLATFORM)/disk + +clean:: + rm -rf $(OBJ_DIR) $(CACHE_PLATFORM) $(R2R_PD) + +debug:: + echo 'What should debug target do?' + exit 1 + +# These targets allow adding platform-specific steps from the top-level Makefile. +# Examples: +# coco/r2r:: coco/custom-step1 +# coco/r2r:: coco/custom-step2 +# or with a single colon: +# apple2/r2r: apple2/custom-step1 apple2/custom-step2 +# The double-colon form appends without overwriting existing deps. +r2r:: $(PLATFORM)/r2r +disk:: $(PLATFORM)/disk + +# Fallback rule so every /disk-post target exists. +# Does nothing by default (@:). +# In the top-level Makefile you can extend it with the literal platform name, +# e.g.: +# coco/disk-post:: coco/extra-file +$(PLATFORM)/disk-post:: + @: + +# Same as $(PLATFORM)/disk-post above +$(PLATFORM)/r2r-post:: + @: + +# Same as $(PLATFORM)/disk-post above +$(PLATFORM)/executable-post:: + @: + +# Same as $(PLATFORM)/disk-post above +$(PLATFORM)/library-post:: + @: + +# include autodeps +-include $(wildcard $(OBJ_DIR)/*.d) + +FUJINET_LIB ?= __UNDEFINED__ +ifeq ($(FUJINET_LIB),__UNDEFINED__) + $(info FUJINET_LIB not defined) +else + # Fill in the FUINET_LIB_* variables by calling fnlib.py. It's a bit + # messy because of workarounds needed for dealing with newlines and + # and the $(eval) + define _newline + + + endef + $(eval $(subst |,$(_newline),$(shell PLATFORM=$(PLATFORM) CACHE_DIR=$(CACHE_DIR) \ + PLATFORM_COMBOS="$(PLATFORM_COMBOS)" $(MWD)/fnlib.py \ + $(if $(FUJINET_LIB_OPTIONAL),--skip-if-missing) \ + $(FUJINET_LIB) | tr '\n' '|'))) + ifeq ($(strip $(FUJINET_LIB_LDLIB)),) + ifeq ($(FUJINET_LIB_OPTIONAL),) + $(error fujinet-lib not available) + else + $(info fujinet-lib not available, but skipping because FUJINET_LIB_SKIP_MISSING is set) + endif + endif +endif # FUJINET_LIB diff --git a/makefiles/fnlib.py b/makefiles/fnlib.py new file mode 100755 index 00000000..b1a25175 --- /dev/null +++ b/makefiles/fnlib.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +import argparse +import os, sys +import re +import zipfile +import urllib.request +import json +import subprocess + +FUJINET_REPO = "FujiNetWIFI/fujinet-lib" +GITHUB_API = "https://api.github.com/repos" +GITHUB_URL = "https://github.com" +CACHE_DIR = "_cache" +FUJINET_CACHE_DIR = os.path.join(CACHE_DIR, "fujinet-lib") + +VERSION_NUM_RE = r"([0-9]+[.][0-9]+[.][0-9]+)" +VERSION_NAME_RE = fr"v?{VERSION_NUM_RE}" +LDLIB_REGEX = r"lib(.*)[.]a$" +LDLIB_PLATFORMS = ["coco", "dragon", "msdos"] + +def build_argparser(): + parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("file", nargs="?", help="input file") + parser.add_argument("--platform", help="platform building for") + parser.add_argument("--skip-if-missing", action="store_true", + help="don't error if fujinet-lib isn't available") + return parser + +class MakeVariables: + def __init__(self, varList): + for key in varList: + setattr(self, key, "") + return + + @staticmethod + def escapeForMake(val): + if not val: + return "" + return ( + val + .replace("\\", "\\\\") # escape backslashes first + .replace('"', '\\"') + .replace("$", "$$") + .replace(" ", "\\ ") + .replace(":", "\\:") + .replace("#", "\\#") + ) + + def printValues(self): + attrs = self.__dict__.keys() + for key in attrs: + print(f"{key}:={self.escapeForMake(getattr(self, key))}") + return + +class LibLocator: + def __init__(self, FUJINET_LIB, PLATFORM, COMBOS, skipIfMissing=False): + """ + FUJINET_LIB can be + - a version number such as 4.7.4 + - a directory which contains the libs for each platform + - a zip file with an archived fujinet-lib + - a URL to a git repo + - empty + """ + + self.skipIfMissing = skipIfMissing + + self.MV = MakeVariables([ + "FUJINET_LIB_DIR", + "FUJINET_LIB_FILE", + "FUJINET_LIB_INCLUDE", + "FUJINET_LIB_LDLIB", + "FUJINET_LIB_PLATFORM", + "FUJINET_LIB_VERSION", + "FUJINET_LIB_ZIP", + ]) + + self.PLATFORM = PLATFORM + self.combos = self.combosToDict(COMBOS) + self.possiblePlatforms = [self.PLATFORM, *self.combos.get(self.PLATFORM, [])] + + # Several possible library filename patterns: + # - fujinet-coco-4.7.6.lib + # - fujinet.apple2.lib + # - fujinet.lib.c64 + # - libfujinet.coco.a + self.LIBRARY_REGEX = [] + for platform in self.possiblePlatforms: + self.LIBRARY_REGEX.extend([ + fr"fujinet[-.]({platform})(-{VERSION_NUM_RE})?[.]lib$", + fr"fujinet[.]lib[.]({platform})$", + fr"libfujinet[.]({platform})[.]a$", + ]) + + if FUJINET_LIB: + rxm = re.match(VERSION_NAME_RE, FUJINET_LIB) + if rxm: + self.MV.FUJINET_LIB_VERSION = rxm.group(1) + elif any(sub in FUJINET_LIB for sub in ("://", "@")): + self.gitClone(FUJINET_LIB) + elif os.path.isfile(FUJINET_LIB): + _, ext = os.path.splitext(FUJINET_LIB) + if ext == ".zip": + self.MV.FUJINET_LIB_ZIP = FUJINET_LIB + else: + self.MV.FUJINET_LIB_DIR = os.path.dirname(FUJINET_LIB) + self.MV.FUJINET_LIB_FILE = os.path.basename(FUJINET_LIB) + elif os.path.isdir(FUJINET_LIB): + self.MV.FUJINET_LIB_DIR = FUJINET_LIB + + if not self.MV.FUJINET_LIB_VERSION: + self.getVersion() + + if not self.MV.FUJINET_LIB_DIR: + self.getDirectory() + + if not self.MV.FUJINET_LIB_FILE: + self.downloadZip() + + if not self.MV.FUJINET_LIB_INCLUDE: + self.getInclude() + + if not self.MV.FUJINET_LIB_PLATFORM: + self.MV.FUJINET_LIB_PLATFORM = self.PLATFORM + + self.MV.FUJINET_LIB_FILE = self.fixupLibraryFilename(self.MV.FUJINET_LIB_FILE) + self.MV.FUJINET_LIB_LDLIB = self.MV.FUJINET_LIB_FILE + + # If FUJINET_LIB_LDLIB is specially named for linker to find, make + # sure FUJINET_LIB_LDLIB is fixed up appropriately + rxm = re.match(LDLIB_REGEX, self.MV.FUJINET_LIB_LDLIB) + if rxm: + self.MV.FUJINET_LIB_LDLIB = rxm.group(1) + + return + + def checkLibraryFilename(self, filename): + for pattern in self.LIBRARY_REGEX: + rxm = re.match(pattern, filename) + if rxm: + return rxm + return None + + def findLibrary(self, filelist): + for filename in filelist: + rxm = self.checkLibraryFilename(filename) + if rxm: + self.setPlatformVersion(rxm) + return rxm + return None + + def fixupLibraryFilename(self, filename): + # Some linkers require the library to be named specially in order + # to be used with the `-l` flag. Create symlink if necessary. + + symlink_file = None + version = "" + if self.MV.FUJINET_LIB_VERSION: + version = f"-{self.MV.FUJINET_LIB_VERSION}" + + if self.PLATFORM in LDLIB_PLATFORMS: + if not re.match(LDLIB_REGEX, filename): + symlink_file = f"libfujinet-{self.MV.FUJINET_LIB_PLATFORM}{version}.a" + + elif not filename.endswith(".lib"): + symlink_file = f"fujinet-{self.MV.FUJINET_LIB_PLATFORM}{version}.lib" + + if symlink_file: + symlink_path = os.path.join(self.MV.FUJINET_LIB_DIR, symlink_file) + if not os.path.exists(symlink_path): + os.symlink(filename, symlink_path) + filename = symlink_file + + return filename + + def setPlatformVersion(self, rxm): + if len(rxm.groups()) >= 1: + self.MV.FUJINET_LIB_PLATFORM = rxm.group(1) + if len(rxm.groups()) >= 2: + self.MV.FUJINET_LIB_VERSION = rxm.group(2) + return + + def getVersion(self): + if self.MV.FUJINET_LIB_ZIP: + with zipfile.ZipFile(self.MV.FUJINET_LIB_ZIP, "r") as zf: + rxm = self.findLibrary(zf.namelist()) + if rxm: + return + + raise ValueError("Which file is the newest?") + + if not self.MV.FUJINET_LIB_DIR: + cached = self.findCacheDir() + if cached: + self.MV.FUJINET_LIB_DIR = cached + + if self.MV.FUJINET_LIB_DIR: + rxm = self.findLibrary(os.listdir(self.MV.FUJINET_LIB_DIR)) + if rxm: + self.MV.FUJINET_LIB_FILE = rxm.group(0) + return + if self.skipIfMissing: + exit(0) + #error_exit(f"No library found for \"{self.PLATFORM}\"") + + # No version was specified, so any version is fine + if self.MV.FUJINET_LIB_VERSION: + return + + latest_url = f"{GITHUB_API}/{FUJINET_REPO}/releases/latest" + with urllib.request.urlopen(latest_url) as response: + response = response.read().decode("UTF-8") + release_info = json.loads(response) + + latest_version = release_info.get("tag_name") or release_info.get("name") + if not latest_version: + raise ValueError("Can't find version") + + rxm = re.match(VERSION_NAME_RE, latest_version) + if not rxm: + raise ValueError("Not a FujiNet-lib version", latest_version) + + self.MV.FUJINET_LIB_VERSION = rxm.group(1) + return + + def findCacheDir(self): + pattern = fr"{VERSION_NUM_RE}-{self.PLATFORM}" + if not os.path.isdir(FUJINET_CACHE_DIR): + return None + for path in os.listdir(FUJINET_CACHE_DIR): + rxm = re.match(pattern, path) + if rxm: + return os.path.join(FUJINET_CACHE_DIR, path) + return None + + def getDirectory(self): + global FUJINET_CACHE_DIR + self.MV.FUJINET_LIB_DIR = os.path.join(FUJINET_CACHE_DIR, + f"{self.MV.FUJINET_LIB_VERSION}-{self.PLATFORM}") + return + + def downloadZip(self): + global FUJINET_CACHE_DIR + os.makedirs(self.MV.FUJINET_LIB_DIR, exist_ok=True) + + for platform in self.possiblePlatforms: + self.MV.FUJINET_LIB_FILE = f"fujinet-{platform}-{self.MV.FUJINET_LIB_VERSION}.lib" + if not os.path.exists(os.path.join(self.MV.FUJINET_LIB_DIR, self.MV.FUJINET_LIB_FILE)): + zip_path = f"fujinet-lib-{platform}-{self.MV.FUJINET_LIB_VERSION}.zip" + + if not self.MV.FUJINET_LIB_ZIP: + self.MV.FUJINET_LIB_ZIP = os.path.join(FUJINET_CACHE_DIR, zip_path) + + if not os.path.exists(self.MV.FUJINET_LIB_ZIP): + release_url = f"{GITHUB_URL}/{FUJINET_REPO}/releases/download" \ + f"/v{self.MV.FUJINET_LIB_VERSION}/{zip_path}" + try: + urllib.request.urlretrieve(release_url, self.MV.FUJINET_LIB_ZIP) + except: + continue + + with zipfile.ZipFile(self.MV.FUJINET_LIB_ZIP, "r") as zf: + zf.extractall(self.MV.FUJINET_LIB_DIR) + + return + + error_exit("Unable to download FujiNet library from", release_url) + return + + def gitClone(self, url): + global FUJINET_CACHE_DIR + os.makedirs(FUJINET_CACHE_DIR, exist_ok=True) + branch = "" + if "#" in url: + url, branch = url.split("#") + base = url.rstrip("/").split("/")[-1] + if base.endswith(".git"): + base = base.rsplit(".", 1)[0] + repoDir = os.path.join(FUJINET_CACHE_DIR, base) + + if not os.path.exists(repoDir): + cmd = ["git", "clone", url] + if branch: + cmd.extend(["-b", branch]) + subprocess.run(cmd, cwd=FUJINET_CACHE_DIR, check=True) + + possibleOutput = ["build", *[f"r2r/{p}" for p in self.possiblePlatforms]] + self.findLibraryDir(repoDir, possibleOutput) + if not self.MV.FUJINET_LIB_FILE: + cmd = ["make", ] + subprocess.run(cmd, cwd=repoDir, check=True) + self.findLibraryDir(repoDir, possibleOutput) + + return + + def findLibraryDir(self, baseDir, dirsToCheck): + for pdir in dirsToCheck: + pdir = os.path.join(baseDir, pdir) + if os.path.isdir(pdir): + self.MV.FUJINET_LIB_DIR = pdir + rxm = self.findLibrary(os.listdir(self.MV.FUJINET_LIB_DIR)) + if rxm: + if not self.MV.FUJINET_LIB_PLATFORM: + raise ValueError("What platform?", rxm) + self.MV.FUJINET_LIB_FILE = rxm.group(0) + return rxm + return None + + def getInclude(self): + parent = os.path.dirname(self.MV.FUJINET_LIB_DIR.rstrip("/")) + checkDirs = [self.MV.FUJINET_LIB_DIR, parent, os.path.join(parent, "include")] + components = self.MV.FUJINET_LIB_DIR.split(os.path.sep) + if components[-1] == self.MV.FUJINET_LIB_PLATFORM and components[-2] == "r2r": + checkDirs.append(os.path.join(os.path.dirname(parent), "include")) + for idir in checkDirs: + if os.path.exists(os.path.join(idir, "fujinet-fuji.h")): + self.MV.FUJINET_LIB_INCLUDE = idir + return + if self.skipIfMissing: + exit(0) + raise ValueError("Unable to find include directory", self.MV.FUJINET_LIB_DIR) + return + + def printMakeVariables(self): + self.MV.printValues() + if self.MV.FUJINET_LIB_LDLIB: + print(f"CFLAGS_EXTRA_{self.PLATFORM.upper()}+=-DUSING_FUJINET_LIB") + return + + @staticmethod + def combosToDict(combos): + if not combos: + return {} + + comboDict = {} + for part in combos.split(): + if "+=" not in part: + continue + platform, others = part.split("+=", 1) + platform = platform.strip() + others = [c.strip() for c in others.split(',') if c.strip()] + if platform not in comboDict: + comboDict[platform] = [] + comboDict[platform].extend(others) + return comboDict + +# Print errors to stderr so that `make` doesn't try to interpret them in `$(eval)` +def error_exit(*args): + print(*args, file=sys.stderr) + exit(1) + +def main(): + global CACHE_DIR, FUJINET_CACHE_DIR + + args = build_argparser().parse_args() + + PLATFORM = os.getenv("PLATFORM") + if args.platform: + PLATFORM = args.platform + + if not PLATFORM: + error_exit("Please specify PLATFORM") + + PLATFORM_COMBOS = os.getenv("PLATFORM_COMBOS") + + FUJINET_LIB = args.file + if not FUJINET_LIB: + FUJINET_LIB = os.getenv("FUJINET_LIB") + + env_cache_dir = os.getenv("CACHE_DIR") + if env_cache_dir: + CACHE_DIR = env_cache_dir + FUJINET_CACHE_DIR = os.path.join(CACHE_DIR, os.path.basename(FUJINET_CACHE_DIR)) + + fujinetLib = LibLocator(FUJINET_LIB, PLATFORM, PLATFORM_COMBOS, args.skip_if_missing) + fujinetLib.printMakeVariables() + + return + +if __name__ == "__main__": + exit(main() or 0) diff --git a/makefiles/platforms/adam.mk b/makefiles/platforms/adam.mk new file mode 100644 index 00000000..11533e32 --- /dev/null +++ b/makefiles/platforms/adam.mk @@ -0,0 +1,15 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).prg +LIBS += -leos.lib -lsmartkeys.lib +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/z88dk.mk + +ADAM_FLAGS = +coleco -subtype=adam +CFLAGS += $(ADAM_FLAGS) +LDFLAGS += $(ADAM_FLAGS) +LIBS += -leos.lib -lsmartkeys.lib + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/apple2.mk b/makefiles/platforms/apple2.mk new file mode 100644 index 00000000..33f717a2 --- /dev/null +++ b/makefiles/platforms/apple2.mk @@ -0,0 +1,42 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).a2s +DISK = $(R2R_PD)/$(PRODUCT_BASE).po +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cc65.mk + +r2r:: $(BUILD_DISK) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post + +PRODOS_VERSION = 2.4.3 +PRODOS8_DISK := $(CACHE_PLATFORM)/PRODOS8-$(PRODOS_VERSION).po +CC65_UTILS_DIR := $(shell cl65 --print-target-path --target $(PLATFORM))/$(PLATFORM)/util +LOADER_SYSTEM := loader.system + +$(BUILD_DISK): $(BUILD_EXEC) $(PRODOS8_DISK) $(DISK_EXTRA_DEPS_$(PLATFORM_UC)) | $(R2R_PD) + acx create -d $@ --format $(PRODOS8_DISK) --prodos --size=140kb --name=$(PRODUCT_BASE) + ac -as $@ $(PRODUCT_BASE) < $< + ac -p $@ $(PRODUCT_BASE).SYSTEM SYS 0x2000 < $(CC65_UTILS_DIR)/$(LOADER_SYSTEM) + make -f $(PLATFORM_MK) $(PLATFORM)/disk-post + +# Download and cache ProDOS disk if necessary +PRODOS_URL = https://releases.prodos8.com +PRODOS8_RELEASE := ProDOS_$(subst .,_,$(PRODOS_VERSION)).po +$(PRODOS8_DISK): | $(CACHE_PLATFORM) + curl --insecure -L -o $@ $(PRODOS_URL)/$(PRODOS8_RELEASE) + +# Converts AppleSingle (cc65 output) to AppleDouble (netatalk share) +UNSINGLE = unsingle +EXECUTABLE_AD = $(R2R_PD)/$(PRODUCT_BASE) + +define single-to-double + unsingle $< && mv $<.ad $@ && mv .AppleDouble/$<.ad .AppleDouble/$@ +endef + +$(EXECUTABLE_AD): $(BUILD_EXEC) + if command -v $(UNSINGLE) > /dev/null 2>&1 ; then \ + $(single-to-double) ; \ + else \ + cp $< $@ ; \ + fi diff --git a/makefiles/platforms/atari-pas.mk b/makefiles/platforms/atari-pas.mk new file mode 100644 index 00000000..477e3896 --- /dev/null +++ b/makefiles/platforms/atari-pas.mk @@ -0,0 +1,9 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).xex +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/madpas.mk + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/atari.mk b/makefiles/platforms/atari.mk new file mode 100644 index 00000000..a5d91739 --- /dev/null +++ b/makefiles/platforms/atari.mk @@ -0,0 +1,25 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).com +DISK = $(R2R_PD)/$(PRODUCT_BASE).atr +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cc65.mk + +r2r:: $(BUILD_DISK) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post + +PICOBOOT_BIN = picoboot.bin +ATRBOOT := $(CACHE_PLATFORM)/$(PICOBOOT_BIN) + +$(BUILD_DISK): $(BUILD_EXEC) $(ATRBOOT) $(DISK_EXTRA_DEPS_$(PLATFORM_UC)) | $(R2R_PD) + $(RM) $@ + $(RM) -rf $(CACHE_PLATFORM)/disk + $(MKDIR_P) $(CACHE_PLATFORM)/disk + cp $< $(CACHE_PLATFORM)/disk + dir2atr -m -S -B $(ATRBOOT) $@ $(CACHE_PLATFORM)/disk + make -f $(PLATFORM_MK) $(PLATFORM)/disk-post + +PICOBOOT_DOWNLOAD_URL = https://github.com/FujiNetWIFI/assets/releases/download/picobin +$(ATRBOOT): | $(CACHE_PLATFORM) + curl -L -o $@ $(PICOBOOT_DOWNLOAD_URL)/$(PICOBOOT_BIN) diff --git a/makefiles/platforms/c16.mk b/makefiles/platforms/c16.mk new file mode 100644 index 00000000..62b943a5 --- /dev/null +++ b/makefiles/platforms/c16.mk @@ -0,0 +1,9 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).prg +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cc65.mk + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/c64.mk b/makefiles/platforms/c64.mk new file mode 100644 index 00000000..62b943a5 --- /dev/null +++ b/makefiles/platforms/c64.mk @@ -0,0 +1,9 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).prg +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cc65.mk + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/coco.mk b/makefiles/platforms/coco.mk new file mode 100644 index 00000000..20c7c397 --- /dev/null +++ b/makefiles/platforms/coco.mk @@ -0,0 +1,17 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).bin +DISK = $(R2R_PD)/$(PRODUCT_BASE).dsk +LIBRARY = $(R2R_PD)/lib$(PRODUCT_BASE).$(PLATFORM).a +DISK_TOOL = decb + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cmoc.mk + +r2r:: $(BUILD_DISK) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + @make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post + +$(BUILD_DISK): $(BUILD_EXEC) $(DISK_EXTRA_DEPS_$(PLATFORM_UC)) | $(R2R_PD) + $(RM) $@ + $(DISK_TOOL) dskini $@ + $(DISK_TOOL) copy -b -2 $< $@,$(shell echo $(PRODUCT_BASE) | tr '[:lower:]' '[:upper:]').BIN + @make -f $(PLATFORM_MK) $(PLATFORM)/disk-post diff --git a/makefiles/platforms/dragon.mk b/makefiles/platforms/dragon.mk new file mode 100644 index 00000000..13b5a229 --- /dev/null +++ b/makefiles/platforms/dragon.mk @@ -0,0 +1,17 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).bin +DISK = $(R2R_PD)/$(PRODUCT_BASE).vdk +LIBRARY = $(R2R_PD)/lib$(PRODUCT_BASE).$(PLATFORM).a +DISK_TOOL = dragondos + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cmoc.mk + +r2r:: $(BUILD_DISK) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + @make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post + +$(BUILD_DISK): $(BUILD_EXEC) $(DISK_EXTRA_DEPS_$(PLATFORM_UC)) | $(R2R_PD) + $(RM) $@ + $(DISK_TOOL) new $@ 360 + $(DISK_TOOL) insertbinary $@ $< 0x2601 0x2601 + @make -f $(PLATFORM_MK) $(PLATFORM)/disk-post diff --git a/makefiles/platforms/msdos.mk b/makefiles/platforms/msdos.mk new file mode 100644 index 00000000..5ade2e21 --- /dev/null +++ b/makefiles/platforms/msdos.mk @@ -0,0 +1,12 @@ +PRODUCT_BASE = $(PRODUCT_BASE) +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).exe +LIBRARY = $(R2R_PD)/lib$(PRODUCT_BASE).$(PLATFORM).a + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/ow2.mk + +CFLAGS += -D__MSDOS__ + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/msx.mk b/makefiles/platforms/msx.mk new file mode 100644 index 00000000..31955d63 --- /dev/null +++ b/makefiles/platforms/msx.mk @@ -0,0 +1,13 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).com +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/z88dk.mk + +MSX_FLAGS = +msx +CFLAGS += $(MSX_FLAGS) +LDFLAGS += $(MSX_FLAGS) + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/msxrom.mk b/makefiles/platforms/msxrom.mk new file mode 100644 index 00000000..b82ae6c0 --- /dev/null +++ b/makefiles/platforms/msxrom.mk @@ -0,0 +1,13 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).rom +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/z88dk.mk + +MSXROM_FLAGS = +msx -subtype=rom +CFLAGS += $(MSXROM_FLAGS) +LDFLAGS += $(MSXROM_FLAGS) + +r2r:: $(EXECUTABLE) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/pc6001.mk b/makefiles/platforms/pc6001.mk new file mode 100644 index 00000000..bba5c098 --- /dev/null +++ b/makefiles/platforms/pc6001.mk @@ -0,0 +1,15 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).ptp +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib +AS_DEFAULT = zcc + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/z88dk.mk + +$(PLATFORM_UC)_FLAGS = +$(PLATFORM) +CFLAGS += $($(PLATFORM_UC)_FLAGS) +ASFLAGS += $($(PLATFORM_UC)_FLAGS) -c +LDFLAGS += $($(PLATFORM_UC)_FLAGS) + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/pmd85.mk b/makefiles/platforms/pmd85.mk new file mode 100644 index 00000000..bba5c098 --- /dev/null +++ b/makefiles/platforms/pmd85.mk @@ -0,0 +1,15 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).ptp +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib +AS_DEFAULT = zcc + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/z88dk.mk + +$(PLATFORM_UC)_FLAGS = +$(PLATFORM) +CFLAGS += $($(PLATFORM_UC)_FLAGS) +ASFLAGS += $($(PLATFORM_UC)_FLAGS) -c +LDFLAGS += $($(PLATFORM_UC)_FLAGS) + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/platforms/vic20.mk b/makefiles/platforms/vic20.mk new file mode 100644 index 00000000..62b943a5 --- /dev/null +++ b/makefiles/platforms/vic20.mk @@ -0,0 +1,9 @@ +EXECUTABLE = $(R2R_PD)/$(PRODUCT_BASE).prg +LIBRARY = $(R2R_PD)/$(PRODUCT_BASE).$(PLATFORM).lib + +MWD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..) +include $(MWD)/common.mk +include $(MWD)/toolchains/cc65.mk + +r2r:: $(BUILD_EXEC) $(BUILD_LIB) $(R2R_EXTRA_DEPS_$(PLATFORM_UC)) + make -f $(PLATFORM_MK) $(PLATFORM)/r2r-post diff --git a/makefiles/tc-common.mk b/makefiles/tc-common.mk new file mode 100644 index 00000000..65444008 --- /dev/null +++ b/makefiles/tc-common.mk @@ -0,0 +1,34 @@ +# Automatically figure out TOOLCHAIN from the .mk file that included us +TOOLCHAIN_MK := $(call pop,$(MAKEFILE_LIST)) +TOOLCHAIN := $(basename $(notdir $(lastword $(TOOLCHAIN_MK)))) +TOOLCHAIN_UC := $(shell echo "$(TOOLCHAIN)" | tr '[:lower:]' '[:upper:]') +$(info Using TOOLCHAIN=$(TOOLCHAIN)) + +CC_$(TOOLCHAIN_UC) ?= $(CC_DEFAULT) +AS_$(TOOLCHAIN_UC) ?= $(AS_DEFAULT) +LD_$(TOOLCHAIN_UC) ?= $(LD_DEFAULT) +AR_$(TOOLCHAIN_UC) ?= $(AR_DEFAULT) +PC_$(TOOLCHAIN_UC) ?= $(PC_DEFAULT) + +CC := $(CC_$(TOOLCHAIN_UC)) +AS := $(AS_$(TOOLCHAIN_UC)) +LD := $(LD_$(TOOLCHAIN_UC)) +AR := $(AR_$(TOOLCHAIN_UC)) +PC := $(PC_$(TOOLCHAIN_UC)) + +EXTRA_INCLUDE_$(TOOLCHAIN_UC) += $(EXTRA_INCLUDE) $(EXTRA_INCLUDE_$(PLATFORM_UC)) +CFLAGS += $(CFLAGS_EXTRA_$(TOOLCHAIN_UC)) $(CFLAGS_EXTRA_$(PLATFORM_UC)) +ASFLAGS += $(ASFLAGS_EXTRA_$(TOOLCHAIN_UC)) $(ASFLAGS_EXTRA_$(PLATFORM_UC)) +LDFLAGS += $(LDFLAGS_EXTRA_$(TOOLCHAIN_UC)) $(LDFLAGS_EXTRA_$(PLATFORM_UC)) + +CFLAGS += $(foreach incdir,$(EXTRA_INCLUDE),$(call include-dir-flag,$(incdir))) +CFLAGS += $(foreach incdir,$(EXTRA_INCLUDE_$(PLATFORM_UC)),$(call include-dir-flag,$(incdir))) +ASFLAGS += $(foreach incdir,$(EXTRA_INCLUDE),$(call asm-include-dir-flag,$(incdir))) +ASFLAGS += $(foreach incdir,$(EXTRA_INCLUDE_$(PLATFORM_UC)),$(call asm-include-dir-flag,$(incdir))) + +ifdef FUJINET_LIB_INCLUDE + CFLAGS += $(call include-dir-flag,$(FUJINET_LIB_INCLUDE)) +endif +ifdef FUJINET_LIB_DIR + LIBS = $(call library-dir-flag,$(FUJINET_LIB_DIR)) $(call library-flag,$(FUJINET_LIB_LDLIB)) +endif diff --git a/makefiles/toolchains/cc65.mk b/makefiles/toolchains/cc65.mk new file mode 100644 index 00000000..fc819e1b --- /dev/null +++ b/makefiles/toolchains/cc65.mk @@ -0,0 +1,42 @@ +CC_DEFAULT ?= cl65 +AS_DEFAULT ?= $(CC_DEFAULT) +LD_DEFAULT ?= $(CC_DEFAULT) +AR_DEFAULT ?= ar65 + +include $(MWD)/tc-common.mk + +CFLAGS += -O --cpu 6502 +ASFLAGS += --cpu 6502 +LDFLAGS += + +define include-dir-flag + --include-dir $1 +endef + +define asm-include-dir-flag + --asm-include-dir $1 +endef + +define library-dir-flag + --lib-path $1 +endef + +define library-flag + $1 +endef + +define link-lib + $(AR) a $1 $2 +endef + +define link-bin + $(LD) -vm -t $(PLATFORM) $(LDFLAGS) $2 $(LIBS) -o $1 +endef + +define compile + $(CC) -l $(basename $1).lst --create-dep $(OBJ_DIR)/$(basename $(notdir $2)).d -c $(CFLAGS) -t $(PLATFORM) -o $1 $2 +endef + +define assemble + $(AS) -l $(basename $1).lst -c $(ASFLAGS) -t $(PLATFORM) -o $1 $2 +endef diff --git a/makefiles/toolchains/cmoc.mk b/makefiles/toolchains/cmoc.mk new file mode 100644 index 00000000..d072f937 --- /dev/null +++ b/makefiles/toolchains/cmoc.mk @@ -0,0 +1,45 @@ +CC_DEFAULT ?= cmoc +AS_DEFAULT ?= $(CC_DEFAULT) +LD_DEFAULT ?= $(CC_DEFAULT) +AR_DEFAULT = lwar + +include $(MWD)/tc-common.mk + +CFLAGS += --intdir=$(OBJ_DIR) +ASFLAGS += +LDFLAGS += + +# Needed because of using sed on error messages +SHELL = /bin/bash -o pipefail + +define include-dir-flag + -I$1 +endef + +define asm-include-dir-flag + -I$1 +endef + +define library-dir-flag + -L$1 +endef + +define library-flag + -l$1 +endef + +define link-lib + $(AR) -a -r $@ $^ +endef + +define link-bin + $(LD) -o $1 $(LDFLAGS) $2 $(LIBS) +endef + +define compile + $(CC) -c $(CFLAGS) --deps=$(OBJ_DIR)/$(basename $(notdir $2)).d -o $1 $2 +endef + +define assemble + $(AS) -c $(ASFLAGS) -o $1 $2 2>&1 | sed -e 's/^\(.*\)(\([0-9][0-9]*\)) :/\1:\2:/' +endef diff --git a/makefiles/toolchains/madpas-build.py b/makefiles/toolchains/madpas-build.py new file mode 100755 index 00000000..c2f1cdda --- /dev/null +++ b/makefiles/toolchains/madpas-build.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +import argparse +import tempfile +import subprocess +import os +import shlex + +def build_argparser(): + parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("ofile", nargs="+", help="pseudo object file") + parser.add_argument("-o", "--output", help="save output into") + parser.add_argument("-L", "--unit-path", action="append", + help="Add directory to the Pascal unit include path") + parser.add_argument("-I", "--include-path", action="append", + help="Add directory to the mads assembler include path") + parser.add_argument("--rc", help="rc file") + parser.add_argument("--flag", action="store_true", help="flag to do something") + return parser + +def is_unit_file(path): + with open(path, 'r') as f: + for line in f: + if line.strip().lower().startswith("unit "): + return True + return False + +def main(): + args = build_argparser().parse_args() + + pascal_files = [] + assembly_files = [] + for path in args.ofile: + with open(path, "r") as file: + component = file.readline().strip().split(maxsplit=2) + if component[1] == "rcpascal": + pascal_files.append(component[2]) + continue + + assembly_files.append(component) + + if len(pascal_files) != 1: + # Remove unit files from the list and make sure that they have an + # uppercase bas and lowercase extension because Mad-Pascal changes + # the case of filenames. + unit_files = [x for x in pascal_files if is_unit_file(x)] + for unit in unit_files: + unit_dir = os.path.dirname(unit) + unit_base, unit_ext = os.path.splitext(os.path.basename(unit)) + unit_base_uc = unit_base.upper() + unit_uc = os.path.join(unit_dir, unit_base_uc + unit_ext) + if not os.path.exists(unit_uc): + os.symlink(unit_base + unit_ext, unit_uc) + pascal_files = list(set(pascal_files) - set(unit_files)) + if len(pascal_files) != 1: + print("Wrong amount of Pascal files", pascal_files) + exit(1) + + pas_path = pascal_files[0] + + workdir = os.path.abspath(os.path.dirname(pas_path)) + if assembly_files: + tfile = tempfile.NamedTemporaryFile(mode="w+t", suffix=".rc", dir=workdir, + delete_on_close=False) + for asm in assembly_files: + asm_path = os.path.abspath(asm[2]) + asm_rel = os.path.relpath(asm_path, workdir) + print(" ".join([asm[0], asm[1], asm_rel]), file=tfile) + + if args.rc: + raise NotImplementedError + + tfile.close() + + ptemp = tempfile.NamedTemporaryFile(mode="w+t", suffix=".pas", dir=workdir, + delete_on_close=False) + with open(pas_path, "r+t") as pfile: + for line in pfile: + ptemp.write(line) + #print(f"{{$r {os.path.basename(tfile.name)}}}", file=ptemp) + ptemp.close() + + pas_path = ptemp.name + + cmd = ["mp", os.path.relpath(pas_path, workdir)] + for unit_path in args.unit_path: + cmd.append(f"-ipath:{unit_path}") + atemp = tempfile.NamedTemporaryFile(suffix=".asm", dir=workdir, + delete_on_close=False) + cmd.append(f"-o:{os.path.relpath(atemp.name, workdir)}") + print(" ".join([shlex.quote(x) for x in cmd]), flush=True) + try: + # FIXME - filter output from command to rewrite error lines so they name the input file + subprocess.run(cmd, cwd=workdir, check=True, stderr=subprocess.STDOUT) + except: + print("Failed to compile") + exit(1) + + del tfile, ptemp + + cmd = ["mads", atemp.name, "-x"] + for include_path in args.include_path: + cmd.append(f"-i:{include_path}") + if args.output: + output_path = os.path.abspath(args.output) + cmd.append(f"-o:{output_path}") + print(" ".join([shlex.quote(x) for x in cmd]), flush=True) + subprocess.run(cmd, cwd=workdir, check=True, stderr=subprocess.STDOUT) + + return + +if __name__ == "__main__": + exit(main() or 0) diff --git a/makefiles/toolchains/madpas.mk b/makefiles/toolchains/madpas.mk new file mode 100644 index 00000000..3f2e28a3 --- /dev/null +++ b/makefiles/toolchains/madpas.mk @@ -0,0 +1,37 @@ +# Mad-Pascal doesn't produce .o files. In this setup, we treat Mad-Pascal as the "linker": +# 1. Compile and assemble stages generate fake .o files that record +# the source file names. +# 2. During the link stage, the madpas-build.py wrapper collects all +# source files from the fake .o files and passes them to Mad-Pascal +# to produce the final binary. + +include $(MWD)/tc-common.mk + +MADS_LIBS += \ + --unit-path /usr/local/share/mads/lib \ + --unit-path /usr/local/share/mads/blibs \ + --include-path /usr/local/share/mads/base + +define library-dir-flag + --unit-path $1 +endef + +define link-lib + @echo "Mad-Pascal does not create libaries" ; exit 1 +endef + +define link-bin + $(MWD)/toolchains/madpas-build.py $(MADS_LIBS) -o $1 $2 +endef + +define compile + @echo "Mad-Pascal does not support C" ; exit 1 +endef + +define assemble + echo "$(basename $(notdir $2)) rcasm $2" > $1 +endef + +define compile-pas + echo "$(basename $(notdir $2)) rcpascal $2" > $1 +endef diff --git a/makefiles/toolchains/ow2.mk b/makefiles/toolchains/ow2.mk new file mode 100644 index 00000000..436dd8c8 --- /dev/null +++ b/makefiles/toolchains/ow2.mk @@ -0,0 +1,43 @@ +CC_DEFAULT ?= wcc +AS_DEFAULT ?= wasm +LD_DEFAULT ?= wlink OPTION quiet + +include $(MWD)/tc-common.mk +CFLAGS += -0 -bt=dos -ms -s -osh -zu +ASFLAGS += +LDFLAGS += SYSTEM dos LIBPATH $(FUJINET_LIB_DIR) + +define include-dir-flag + -I$1 +endef + +define asm-include-dir-flag + -I$1 +endef + +define library-dir-flag +endef + +define library-flag + $1 +endef + +define link-lib + $(LIB) -n $1 $2 +endef + +define link-bin + $(LD) $(LDFLAGS) \ + disable 1014 \ + name $1 \ + file {$2} \ + library {$(LIBS)} +endef + +define compile + $(CC) $(CFLAGS) -ad=$(OBJ_DIR)/$(basename $(notdir $2)).d -fo=$1 $2 +endef + +define assemble + $(AS) -c $(ASFLAGS) -o $1 $2 2>&1 +endef diff --git a/makefiles/toolchains/z88dk.mk b/makefiles/toolchains/z88dk.mk new file mode 100644 index 00000000..003e822a --- /dev/null +++ b/makefiles/toolchains/z88dk.mk @@ -0,0 +1,42 @@ +CC_DEFAULT ?= zcc +AS_DEFAULT ?= z80asm +LD_DEFAULT ?= $(CC_DEFAULT) +AR_DEFAULT ?= $(AS_DEFAULT) + +include $(MWD)/tc-common.mk + +CFLAGS += +ASFLAGS += +LDFLAGS += + +define include-dir-flag + -I$1 +endef + +define asm-include-dir-flag + -I$1 +endef + +define library-dir-flag + -L$1 +endef + +define library-flag + -l$1 +endef + +define link-lib + $(AR) -x$1 $2 +endef + +define link-bin + $(LD) $(LDFLAGS) $2 $(LIBS) -o $1 +endef + +define compile + $(CC) -c $(CFLAGS) -o $1 $2 +endef + +define assemble + $(AS) $(ASFLAGS) -o=$1 $2 +endef diff --git a/makefiles/toplevel-rules.mk b/makefiles/toplevel-rules.mk new file mode 100644 index 00000000..bd5dae64 --- /dev/null +++ b/makefiles/toplevel-rules.mk @@ -0,0 +1,48 @@ +# Executables and disk images will be placed into a platform specific +# subdirectory in a "Ready 2 Run" directory (r2r) +R2R_DIR = r2r +BUILD_DIR = build +CACHE_DIR = _cache + +MAKEFILE_DIR = makefiles + +# Make a list of the things we want to build which combine R2R dir, app name, and platform +APP_TARGETS := $(foreach p, $(PLATFORMS), $(R2R_DIR)/$(p)/$(PRODUCT)) + +.PHONY: all clean FORCE + +all:: $(APP_TARGETS) + +clean:: + rm -rf $(R2R_DIR) $(BUILD_DIR) $(CACHE_DIR) + +# Use % wildcard match to platform specific app so we don't have to +# spell out every single platform variation +$(R2R_DIR)/%/$(PRODUCT): FORCE + $(MAKE) -f $(MAKEFILE_DIR)/platforms/$*.mk r2r + +# Convenience: allow `make coco` (or apple2) as a shortcut +$(PLATFORMS): %: $(R2R_DIR)/%/$(PRODUCT) + +# ------------------------------------------------------------------------ +# Pattern rule to support "make /" syntax. +# +# Example: "make apple2/r2r" +# $@ = "apple2/r2r" (the full target name) +# $(@D) = "apple2" (the directory part before the slash) +# $(@F) = "r2r" (the filename part after the slash) +# +# This runs the corresponding platform makefile: +# make -f makefiles/platforms/apple2.mk r2r +# +# Works for ANY target name, so: +# make coco/clean -> runs clean in makefiles/platforms/coco.mk +# make atari/debug -> runs debug in makefiles/platforms/atari.mk +# ------------------------------------------------------------------------ +.DEFAULT: + @target="$@" ; case "$@" in \ + */*/*) echo "No rule to make target '$@'"; exit 1;; \ + */*) platform=$${target%/*}; target=$${target##*/}; \ + $(MAKE) -f makefiles/platforms/$${platform}.mk $${target} ;; \ + *) echo "No rule to make target '$@'"; exit 1;; \ + esac diff --git a/picoboot.bin b/picoboot.bin deleted file mode 100644 index 63858ce2..00000000 Binary files a/picoboot.bin and /dev/null differ diff --git a/src/adam/fuji_io.c b/src/adam/fuji_io.c index 9726c166..ecd767e7 100644 --- a/src/adam/fuji_io.c +++ b/src/adam/fuji_io.c @@ -11,6 +11,8 @@ #include #include +#define FUJI_DEV 0x0F + char response[1024]; static DCB *dcb = NULL; diff --git a/src/adam/system.c b/src/adam/system.c index a1bddbea..2225e445 100644 --- a/src/adam/system.c +++ b/src/adam/system.c @@ -3,6 +3,8 @@ #include #include +#define FUJI_DEV 0x0F + void system_boot(void) { eos_init(); diff --git a/src/coco/cfgload.asm b/src/coco/cfgload/cfgload.asm similarity index 100% rename from src/coco/cfgload.asm rename to src/coco/cfgload/cfgload.asm diff --git a/src/fuji_compat.h b/src/fuji_compat.h index 2ed28fbb..dbde2ee6 100644 --- a/src/fuji_compat.h +++ b/src/fuji_compat.h @@ -38,10 +38,6 @@ extern bool fuji_get_host_slots(HostSlot *h, size_t size); extern bool fuji_copy_file(uint8_t src_slot, uint8_t dst_slot, char *copy_spec); extern bool fuji_create_new(NewDisk *new_disk); -#ifdef BUILD_ADAM -#define FUJI_DEV 0x0F -#endif /* BUILD_ADAM */ - #endif #define MODE_READ 1