libdragon
libdragon copied to clipboard
Fix n64.mk dfs target nested directories
The n64.mk
rule for %.dfs
makes an unreliable assumption that the ROM filesystem is flat. If prerequisites are nested in subdirectories of the filesystem root, this rule has unexpected behavior:
%.dfs:
@mkdir -p $(dir $@)
@echo " [DFS] $@"
$(N64_MKDFS) $@ $(<D) >/dev/null
$(<D)
gets the directory part of the first prerequisite. This only works correctly if the first prerequisite is in the root of the DFS filesystem. Ideally, this rule would use the longest common prefix of all prerequisites, but this is not trivial to do in a Makefile and has the potential to run up against command-line length limits.
As a simple, surgical workaround, this PR introduces a DFS_ROOTDIR
Makefile variable to specify the ROM filesystem root directory. This PR also adds a warning to existing users advising them to adopt DFS_ROOTDIR
.
Context from Discord: https://discord.com/channels/205520502922543113/974342113850445874/1152363061475278980