Skip to content

Firmware makefile cleanups#440

Merged
turboencabulator merged 12 commits intoespotek-org:masterfrom
turboencabulator:fw-makefile
Mar 29, 2026
Merged

Firmware makefile cleanups#440
turboencabulator merged 12 commits intoespotek-org:masterfrom
turboencabulator:fw-makefile

Conversation

@turboencabulator
Copy link
Copy Markdown
Contributor

This is some miscellaneous cleanups to the firmware makefile. Main goals are to:

  • Show the compiler command line, so we can see what it's actually running.
  • Remove most of the duplication by using pattern rules/substitutions.
  • Name the output file with the same labrafirm_$(VERSION)_$(VARIANT).hex convention that we've been using.
  • Fix line endings and permissions on the generated files.

Remove unused/empty variables.
Replace AVRDIR with CROSS_COMPILE.
Add line breaks for readability.
Don't hide the compiler command line.
Use pattern rules and pattern substitution to avoid duplication.
Mark all phony targets as phony.
Apply -DSINGLE_ENPOINT_INTERFACE to a non-phony target.
Include the generated .d files for better dependency tracking.
(Note that `make clean` is still required when switching variants.)
@turboencabulator
Copy link
Copy Markdown
Contributor Author

@brentfpage I was working on this today kind of unaware of your most recent changes in #405. This will conflict. Happy to resolve it however you think is best.

@brentfpage
Copy link
Copy Markdown
Contributor

I'm just going to limit #405 to the firmware workflow, which can work essentially directly with this Makefile. I agree that 0x01 and 0x02 should be changed to 01 and 02 in the file names. For consistency, I think the same change should be made for the target names. make 01 and make 02 work fine as build commands given suitable targets in the Makefile – if you agree, can you please change the targets to 01 and 02?

It is also useful to have a "clean" target that only deletes .o and .d files. Such a target allows a single run of the firmware workflow to build both the 01 and 02 variants and then upload them in a single asset-hex.zip. Could you please add one?

One last thing that could be done either here or in #405 is to delete FIRMWARE_VERSION_ID from src/globals.h and add -DFIRMWARE_VERSION_ID=0x$(VERSION) in a suitable location in the Makefile. If you have a preference for this location, can you please make the change in this PR?

I checked to make sure that the firmware produced by this Makefile matches that produced currently by #405 and found exact agreement apart from whitespace changes.

Listing files by name as targets prevents make from deleting them as
intermediate.  Fixes the problem where running `make` a second time will
rebuild everything it just deleted, since it now finds a mention of the
file in a .d file.

Add a dependency on Makefile, so that objects get rebuilt if anything in
the Makefile changes.

There is no rule to rebuild .d files, so we don't need the conditional
part to avoid including them (and potentially rebuilding them) if we're
just going to delete them.  Those plus the .map and .lss files are
unmanaged side-effects.
@turboencabulator
Copy link
Copy Markdown
Contributor Author

I agree with all those changes.

Syntax is now make 01, make 02, or even something like make VERSION=1234 01 which somewhat nicely matches the generated filename.

I copied automake's idea of naming the target mostlyclean. Then struggled a bit whether it should delete the .d files or not (automake doesn't), but eventually decided the .d files are worthless if the .o files are missing. Maybe it makes sense to keep them if we tell it that the .o files are 'intermediate' so they get auto-deleted, but I didn't set it up that way.

@turboencabulator turboencabulator merged commit 56b313a into espotek-org:master Mar 29, 2026
9 checks passed
@turboencabulator turboencabulator deleted the fw-makefile branch March 29, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants