libdragon icon indicating copy to clipboard operation
libdragon copied to clipboard

Fix n64.mk dfs target nested directories

Open meeq opened this issue 1 year ago • 0 comments

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

meeq avatar Sep 15 '23 22:09 meeq