33# - recursive dirs for src
44# - final files go into build/ directory instead of root folder (e.g. lbl, com file etc)
55
6- TARGETS := atari apple2 commodore
6+ TARGETS := atari apple2 apple2enh c64
77PROGRAM := fujinet.lib
88LIBS :=
99CONFIG :=
@@ -15,9 +15,14 @@ OBJDIR := obj
1515EMUCMD :=
1616BUILD_DIR = build
1717
18- CC65_TARGET_apple2 := apple2
19- CC65_TARGET_atari := atari
20- CC65_TARGET_commodore := c64
18+ # The subfolder src directory to use to build the particular target
19+ # cl65 will get the "TARGET" name, but the src folder will be the "PLATFORM"
20+ PLATFORM_apple2 := apple2
21+ PLATFORM_apple2enh := apple2
22+ PLATFORM_atari := atari
23+ PLATFORM_atarixl := atari
24+ PLATFORM_pet := commodore
25+ PLATFORM_c64 := commodore
2126
2227TARGETOBJDIR := $(OBJDIR ) /$(TARGETS )
2328
@@ -50,15 +55,14 @@ TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS))
5055
5156ifeq ($(words $(TARGETLIST ) ) ,1)
5257
53- # Strip potential variant suffix from the actual cc65 target.
54- CC65TARGET := $(firstword $(subst .,$(SPACE ) ,$(TARGETLIST ) ) )
58+ PLATFORM_SRC_DIR := $(PLATFORM_$(TARGETLIST ) ) /$(SRCDIR )
5559
5660# Set PROGRAM to something like 'myprog.c64'.
5761override PROGRAM := $(PROGRAM ) .$(TARGETLIST )
5862
5963# Recursive files
60- SOURCES += $(call rwildcard,$(TARGETLIST ) / $( SRCDIR ) /,* .s)
61- SOURCES += $(call rwildcard,$(TARGETLIST ) / $( SRCDIR ) /,* .c)
64+ SOURCES += $(call rwildcard,$(PLATFORM_SRC_DIR ) /,* .s)
65+ SOURCES += $(call rwildcard,$(PLATFORM_SRC_DIR ) /,* .c)
6266SOURCES += $(call rwildcard,common/$(SRCDIR ) /,* .s)
6367SOURCES += $(call rwildcard,common/$(SRCDIR ) /,* .c)
6468
@@ -69,29 +73,24 @@ SOURCES := $(strip $(SOURCES))
6973OBJ1 := $(SOURCES:.c=.o )
7074OBJECTS := $(OBJ1:.s=.o )
7175# change from atari/src/ -> obj/atari/
72- OBJECTS := $(OBJECTS:$(TARGETLIST ) / $( SRCDIR ) /%=$(OBJDIR ) /$(TARGETLIST ) /% )
76+ OBJECTS := $(OBJECTS:$(PLATFORM_SRC_DIR ) /%=$(OBJDIR ) /$(TARGETLIST ) /% )
7377OBJECTS := $(OBJECTS:common/$(SRCDIR ) /%=$(OBJDIR ) /common/% )
7478
7579DEPENDS := $(OBJECTS:.o=.d )
7680
77- LIBS += $(wildcard $(TARGETLIST ) / $( SRCDIR ) /* .lib)
81+ LIBS += $(wildcard $(PLATFORM_SRC_DIR ) /* .lib)
7882
7983ASFLAGS += \
8084 --asm-include-dir common/inc \
81- --asm-include-dir $(TARGETLIST ) / $( SRCDIR ) /include \
85+ --asm-include-dir $(PLATFORM_SRC_DIR ) /include \
8286 --asm-include-dir .
8387
8488CFLAGS += \
89+ -Osir \
8590 --include-dir common/inc \
86- --include-dir $(TARGETLIST ) / $( SRCDIR ) /include \
91+ --include-dir $(PLATFORM_SRC_DIR ) /include \
8792 --include-dir .
8893
89- # Add -DBUILD_(TARGET) to all args for the current name. This allows some level of cross platform code
90- UPPER_TARGETLIST := $(shell echo $(TARGETLIST ) | tr a-z A-Z)
91- CFLAGS += -DBUILD_$(UPPER_TARGETLIST )
92- ASFLAGS += -DBUILD_$(UPPER_TARGETLIST )
93- LDFLAGS += -DBUILD_$(UPPER_TARGETLIST )
94-
9594CHANGELOG = Changelog.md
9695
9796# single line with version number in semantic form (e.g. 2.1.3)
@@ -119,7 +118,7 @@ $(BUILD_DIR):
119118 $(call MKDIR,$@ )
120119
121120SRC_INC_DIRS := \
122- $(sort $(dir $(wildcard $(TARGETLIST ) / $( SRCDIR ) /* ) ) ) \
121+ $(sort $(dir $(wildcard $(PLATFORM_SRC_DIR ) /* ) ) ) \
123122 $(sort $(dir $(wildcard common/$(SRCDIR ) /* ) ) )
124123
125124# $(info $$SOURCES = ${SOURCES})
@@ -133,21 +132,21 @@ vpath %.c $(SRC_INC_DIRS)
133132
134133obj/common/% .o : % .c | $(TARGETOBJDIR )
135134 @$(call MKDIR,$(dir $@ ) )
136- $(CC ) -t $(CC65_TARGET_ $( TARGETLIST ) ) -c --create-dep $(@:.o=.d ) $(CFLAGS ) -o $@ $<
135+ $(CC ) -t $(TARGETLIST ) -c --create-dep $(@:.o=.d ) $(CFLAGS ) -o $@ $<
137136
138137$(TARGETOBJDIR ) /% .o : % .c | $(TARGETOBJDIR )
139138 @$(call MKDIR,$(dir $@ ) )
140- $(CC ) -t $(CC65_TARGET_ $( TARGETLIST ) ) -c --create-dep $(@:.o=.d ) $(CFLAGS ) -o $@ $<
139+ $(CC ) -t $(TARGETLIST ) -c --create-dep $(@:.o=.d ) $(CFLAGS ) -o $@ $<
141140
142141vpath % .s $(SRC_INC_DIRS )
143142
144143obj/common/% .o : % .s | $(TARGETOBJDIR )
145144 @$(call MKDIR,$(dir $@ ) )
146- $(CC ) -t $(CC65_TARGET_ $( TARGETLIST ) ) -c --create-dep $(@:.o=.d ) $(ASFLAGS ) -o $@ $<
145+ $(CC ) -t $(TARGETLIST ) -c --create-dep $(@:.o=.d ) $(ASFLAGS ) -o $@ $<
147146
148147$(TARGETOBJDIR ) /% .o : % .s | $(TARGETOBJDIR )
149148 @$(call MKDIR,$(dir $@ ) )
150- $(CC ) -t $(CC65_TARGET_ $( TARGETLIST ) ) -c --create-dep $(@:.o=.d ) $(ASFLAGS ) -o $@ $<
149+ $(CC ) -t $(TARGETLIST ) -c --create-dep $(@:.o=.d ) $(ASFLAGS ) -o $@ $<
151150
152151$(BUILD_DIR ) /$(PROGRAM ) : $(OBJECTS ) | $(BUILD_DIR )
153152 ar65 a $@ $(OBJECTS )
0 commit comments