Skip to content

Commit e3a37c9

Browse files
committed
Update makefile to build apple2enh from apple2 src
1 parent 1f2ed3b commit e3a37c9

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
- Enhance build to produce target specific versions of the library, e.g. apple2enh from apple2 src.
6+
The appkey application was failing in apple2enh without the specific version of the library.
7+
58
## [4.1.0] - 2024-05-12
69

710
### AppKeys Changes

Makefile

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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
77
PROGRAM := fujinet.lib
88
LIBS :=
99
CONFIG :=
@@ -15,9 +15,14 @@ OBJDIR := obj
1515
EMUCMD :=
1616
BUILD_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

2227
TARGETOBJDIR := $(OBJDIR)/$(TARGETS)
2328

@@ -50,15 +55,14 @@ TARGETLIST := $(subst $(COMMA),$(SPACE),$(TARGETS))
5055

5156
ifeq ($(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'.
5761
override 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)
6266
SOURCES += $(call rwildcard,common/$(SRCDIR)/,*.s)
6367
SOURCES += $(call rwildcard,common/$(SRCDIR)/,*.c)
6468

@@ -69,29 +73,24 @@ SOURCES := $(strip $(SOURCES))
6973
OBJ1 := $(SOURCES:.c=.o)
7074
OBJECTS := $(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)/%)
7377
OBJECTS := $(OBJECTS:common/$(SRCDIR)/%=$(OBJDIR)/common/%)
7478

7579
DEPENDS := $(OBJECTS:.o=.d)
7680

77-
LIBS += $(wildcard $(TARGETLIST)/$(SRCDIR)/*.lib)
81+
LIBS += $(wildcard $(PLATFORM_SRC_DIR)/*.lib)
7882

7983
ASFLAGS += \
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

8488
CFLAGS += \
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-
9594
CHANGELOG = 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

121120
SRC_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

134133
obj/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

142141
vpath %.s $(SRC_INC_DIRS)
143142

144143
obj/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

Comments
 (0)