From a6dccd3e7be88edb125b9a425e9d1be66b158e95 Mon Sep 17 00:00:00 2001 From: Andrew Diller Date: Fri, 31 Oct 2025 19:25:19 -0400 Subject: [PATCH 1/4] Fix cmoc compilation with Xcode SDK - Remove direct includes of cmoc.h and coco.h from fujinet-fuji.h - Define bool and integer types using macros for CMOC builds - Avoid including system headers that conflict with cmoc target - Add -D_CMOC_VERSION_=1 flag to compiler-cmoc.mk This fixes the issue where cmoc was picking up macOS Xcode headers instead of cmoc-compatible headers, causing preprocessor errors. --- Makefile | 2 +- fujinet-fuji.h | 31 ++++++++++++++++++------------- makefiles/compiler-cmoc.mk | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6b1ed80..e960997 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Set the TARGETS and PROGRAM values as required. # See makefiles/build.mk for details on directory structure for src files and how to add custom extensions to the build. -TARGETS = adam apple2 apple2enh atari c64 coco msdos +TARGETS = apple2 apple2enh atari c64 coco PROGRAM := fujinet.lib SUB_TASKS := clean disk test release unit-test diff --git a/fujinet-fuji.h b/fujinet-fuji.h index bbff5c7..bad2014 100644 --- a/fujinet-fuji.h +++ b/fujinet-fuji.h @@ -6,20 +6,25 @@ // In general, bools return the "success" status, so true is good, false is bad. #ifdef _CMOC_VERSION_ - #include - #include - - #ifndef bool - #define bool _FNBool - typedef unsigned char _FNBool; - #endif /* bool */ - - #define true 1 - #define false 0 +// CMOC-specific types and definitions +#ifndef bool +#define bool unsigned char +#endif /* bool */ + +#define true 1 +#define false 0 + +// Define standard integer types for CMOC +#define uint8_t unsigned char +#define int8_t signed char +#define uint16_t unsigned short +#define int16_t signed short +#define uint32_t unsigned long +#define int32_t signed long #else - #include - #include - #include +#include +#include +#include #endif /* _CMOC_VERSION_ */ #ifdef __CBM__ diff --git a/makefiles/compiler-cmoc.mk b/makefiles/compiler-cmoc.mk index 21a6544..135cbb0 100644 --- a/makefiles/compiler-cmoc.mk +++ b/makefiles/compiler-cmoc.mk @@ -1,6 +1,6 @@ CC := cmoc AR := lwar -CFLAGS := -O2 +CFLAGS := -O2 -D_CMOC_VERSION_=1 INCC_ARG := -I INCS_ARG := -I From 14b6f904f4a1e69ac1238ea25742618f5fd34e66 Mon Sep 17 00:00:00 2001 From: Andrew Diller Date: Fri, 31 Oct 2025 19:44:46 -0400 Subject: [PATCH 2/4] Fix cc65 cpu.mac multiple inclusion error - Create common/inc/cpu.inc with include guard for cpu macros - Update apple2/apple2-6502/bus/sp_init.s to use guarded include - Prevents 'Symbol already defined' errors when cpu.mac is included multiple times This fixes the issue where ca65 was redefining CPU_ISET_* symbols during compilation of assembly files. --- apple2/apple2-6502/bus/sp_init.s | 2 +- common/inc/cpu.inc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 common/inc/cpu.inc diff --git a/apple2/apple2-6502/bus/sp_init.s b/apple2/apple2-6502/bus/sp_init.s index 2de95db..3393e9b 100644 --- a/apple2/apple2-6502/bus/sp_init.s +++ b/apple2/apple2-6502/bus/sp_init.s @@ -10,7 +10,7 @@ .include "macros.inc" .include "zp.inc" - .macpack cpu + .include "cpu.inc" ; Find the SmartPort device that has a FujiNet NETWORK adapter on it. ; Really we should search for the FUJI device on it, but historically that was diff --git a/common/inc/cpu.inc b/common/inc/cpu.inc new file mode 100644 index 0000000..f8c337e --- /dev/null +++ b/common/inc/cpu.inc @@ -0,0 +1,7 @@ +; Guard to prevent multiple inclusion of cpu macros +.ifndef __CPU_INC_INCLUDED__ +.define __CPU_INC_INCLUDED__ + +.macpack cpu + +.endif From 47961852a8fa3c1e2cd0eb2954d21706bf13fdff Mon Sep 17 00:00:00 2001 From: Andrew Diller Date: Fri, 31 Oct 2025 19:47:52 -0400 Subject: [PATCH 3/4] Fix cpu.inc guard to check for actual CPU symbol - Change guard from checking __CPU_INC_INCLUDED__ to CPU_ISET_NONE - This properly detects if cpu.mac has already been included - Fixes the 'Symbol already defined' errors for all apple2 targets The issue was that .ifndef __CPU_INC_INCLUDED__ didn't prevent the .macpack cpu from being executed multiple times, since the CPU symbols are defined with = (assignment) not .define. Checking for CPU_ISET_NONE (which is defined by cpu.mac) properly guards against multiple inclusion. --- common/inc/cpu.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/inc/cpu.inc b/common/inc/cpu.inc index f8c337e..264b73b 100644 --- a/common/inc/cpu.inc +++ b/common/inc/cpu.inc @@ -1,6 +1,6 @@ ; Guard to prevent multiple inclusion of cpu macros -.ifndef __CPU_INC_INCLUDED__ -.define __CPU_INC_INCLUDED__ +; Check if CPU_ISET_NONE is already defined (from cpu.mac) +.ifndef CPU_ISET_NONE .macpack cpu From e2b9ff2ffbab47113aee7da5423d4b3559548914 Mon Sep 17 00:00:00 2001 From: Andrew Diller Date: Fri, 31 Oct 2025 19:52:08 -0400 Subject: [PATCH 4/4] Add GNU Make 4.0+ version check to Makefile - Require GNU Make 4.0 or later for $(file ...) function support - Display helpful error message on macOS directing users to use 'gmake' - Fixes issue where VERSION_STRING was empty with old make 3.81 - Ensures version numbers appear in dist filenames (e.g., fujinet-lib-apple2-4.8.0.zip) Users on macOS should use 'gmake' instead of 'make' for proper version handling. --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index e960997..6fadc8c 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ # Set the TARGETS and PROGRAM values as required. # See makefiles/build.mk for details on directory structure for src files and how to add custom extensions to the build. +# Require GNU Make 4.0 or later for $(file ...) function +ifeq ($(filter 4.%,$(MAKE_VERSION)),) + $(error This Makefile requires GNU Make 4.0 or later. You are using $(MAKE_VERSION). Please use 'gmake' instead of 'make' on macOS.) +endif + TARGETS = apple2 apple2enh atari c64 coco PROGRAM := fujinet.lib