Skip to content

Commit 811c2b8

Browse files
committed
Build improvements and guard hd function from being in default releases
1 parent 86b03f6 commit 811c2b8

File tree

7 files changed

+54
-36
lines changed

7 files changed

+54
-36
lines changed

Changelog.md

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

33
## [Unreleased]
44

5+
- [build] Guarded hex_dump.c with flag `FN_LIB_DEBUG` which can be enabled via `application.mk`.
6+
Added additional docs to `README.md` to explain this.
7+
Added comments to top of `build.mk` to explain a little bit about paths that are included.
8+
Cosolidated the CFLAGS/ASMFLAGS inclusion in `build.mk` into common pattern.
9+
The fix included putting a space after the args in `compiler-cc65.mk` so it was separated from the parameter correctly.
10+
511
## 4.8.1 2025-11-01
612

713
- [coco] rollback dragon changes for dwread/write that broke coco. Dragon will need testing and future fix potentially by Eric Carr

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ $ make clean
1515
$ make release
1616
```
1717

18+
## Adding additional build flags to local release
19+
20+
Edit the `application.mk` and add any options you need to build a release with additional flags.
21+
The `hd` function (for hex dumping) is guarded by the `FN_LIB_DEBUG` define.
22+
23+
```makefile
24+
# CFLAGS += -DFN_LIB_DEBUG
25+
```
26+
27+
This is not enabled by default, so release libraries will not contain the hd function.
28+
If you are doing local testing, this is the place to add custom CFLAGS or ASMFLAGS for
29+
the built library to pickup.
30+
1831
## Releasing a new version of the library
1932

2033
This can be done with the gitlab automated workflow.

application.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# for application specific settings
22

3-
-include makefiles/unit_tests.mk
3+
-include makefiles/unit_tests.mk
4+
5+
# CFLAGS += -DFN_LIB_DEBUG

common/inc/hex_dump.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#ifdef FN_LIB_DEBUG
2+
13
#ifndef HEX_DUMP_H
24
#define HEX_DUMP_H
35

46
void hd(void* data, int size);
57

6-
#endif
8+
#endif
9+
#endif

common/src/util/hex_dump.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef FN_LIB_DEBUG
2+
13
#ifdef _CMOC_VERSION_
24
#include <cmoc.h>
35
#else
@@ -37,3 +39,5 @@ void hd(void* data, unsigned int size) {
3739
}
3840
}
3941
}
42+
43+
#endif

makefiles/build.mk

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
# Generic Build script for CC65
1+
# generic c/asm build script.
22
#
3-
4-
# Customized for fujinet-libs
3+
# This makefile is responsible for compiling the asm/s/c files for a particular target, passed in as CURRENT_TARGET
4+
#
5+
# You should not normally need to update this file unless you are making enhancements or bug fixes to it.
6+
# For compiling the library, it does not need changes for simple additions of new files etc.
7+
#
8+
# It will RECURSIVELY add to the sources to be built everything that isunder the folders
9+
# - <CURRENT_TARGET>/src/*.[c,<s|asm>]
10+
# - common/src/*.[c,<s|asm>]
11+
# - <CURRENT_TARGET>/<platform specific path>/
12+
#
13+
# This means that the makefile does not have to be updated to add new folders, or if you restructure your code.
14+
#
15+
# Platform specific paths are defined in os.mk, and allow a particular target within a platform (e.g. apple2gs) to
16+
# add its own folders that are not included for other targets of that platform.
17+
# e.g. for apple2 and apple2enh it includes "apple2/apple2-6502", whereas the apple2gs target adds "apple2/apple2gs"
18+
#
19+
# code is compiled into the obj/ folder including the full paths of the src file to ensure similarly named files
20+
# from different folders do not clash
521

622
# Ensure WSL2 Ubuntu and other linuxes use bash by default instead of /bin/sh, which does not always like the shell commands.
723
SHELL := /usr/bin/env bash
@@ -85,36 +101,17 @@ OBJECTS_ARC := $(strip $(OBJECTS_ARC))
85101
# Ensure make recompiles parts it needs to if src files change
86102
DEPENDS := $(OBJECTS:$(OBJEXT)=.d)
87103

88-
ifeq ($(CC),iix compile)
89-
CFLAGS += \
90-
$(INCC_ARG)common/inc \
91-
$(INCC_ARG)$(PLATFORM_SRC_DIR)/include \
92-
$(INCC_ARG).
93-
else ifeq ($(CC),zcc)
94104
CFLAGS += \
95105
$(INCC_ARG)common/inc \
96106
$(INCC_ARG)$(PLATFORM_SRC_DIR)/include \
97107
$(INCC_ARG).
98108

109+
# only include ASFLAGS if not wcc or iix
110+
ifneq ($(filter $(CC),wcc iix),$(CC))
99111
ASFLAGS += \
100112
$(INCS_ARG)common/inc \
101113
$(INCS_ARG)$(PLATFORM_SRC_DIR)/include \
102114
$(INCS_ARG).
103-
else ifeq ($(CC),wcc)
104-
CFLAGS += \
105-
$(INCC_ARG)common/inc \
106-
$(INCC_ARG)$(PLATFORM_SRC_DIR)/include \
107-
$(INCC_ARG).
108-
else
109-
ASFLAGS += \
110-
$(INCS_ARG) common/inc \
111-
$(INCS_ARG) $(PLATFORM_SRC_DIR)/include \
112-
$(INCS_ARG) .
113-
114-
CFLAGS += \
115-
$(INCC_ARG) common/inc \
116-
$(INCC_ARG) $(PLATFORM_SRC_DIR)/include \
117-
$(INCC_ARG) .
118115
endif
119116

120117
FN_NW_HEADER = fujinet-network.h
@@ -192,14 +189,6 @@ else
192189
$(CC) -c --deps $(CFLAGS) -o $@ $<
193190
endif
194191

195-
## For now, no asm in common dirs... as it would be compiler specific
196-
# $(OBJDIR)/$(CURRENT_TARGET)/common/%$(OBJEXT): %$(ASMEXT) | $(TARGETOBJDIR)
197-
# @$(call MKDIR,$(dir $@))
198-
# ifeq ($(CC),cl65)
199-
# $(CC) -t $(CURRENT_TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
200-
# else
201-
# endif
202-
203192
# below shell part is a hack to make foo.ROOT become foo.root, even though the output name is already foo.root, iix capitalizes the "ROOT" part in the filename, which breaks the linux version of linker
204193
$(OBJDIR)/$(CURRENT_TARGET)/%$(OBJEXT): %$(ASMEXT) $(VERSION_FILE) | $(OBJDIR)
205194
@$(call MKDIR,$(dir $@))

makefiles/compiler-cc65.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ CC := cl65
22
AR := ar65
33
CFLAGS := -Osir
44

5-
INCC_ARG := --include-dir
6-
INCS_ARG := --asm-include-dir
5+
# IMPORTANT: these lines have a trailing space to separate the argument from the path they include
6+
INCC_ARG := --include-dir
7+
INCS_ARG := --asm-include-dir

0 commit comments

Comments
 (0)