I didn’t quite get your point about writing a makefile.
When I work with PIC, AVR, and 8051, the compiler or IDE already generates the HEX file automatically in its own output folder.
So why would I need to write a makefile ?
An IDE is your personal development environment that automates tasks like code edit, debugging, etc. However, other users may not have, or just don't want to install the same IDE just to build and run your project.
Different developers use various IDE, and some prefer not to use an IDE at all, opting instead to work in a simple text editor and build the code via the command line, as I often do myself. This approach offers a highly flexible, lightweight, and efficient way to build the project.
The purpose of a makefile (CMakeLists.txt or equivalent build script) is to provide a standardized, IDE-independent way to compile your code. Think of the IDE as the tool you use to write and debug, while the makefile defines how the code should be built in any environment.
Don’t assume that everyone who works with your project will have your preferred IDE installed. Some might use a different IDE, or none at all - they may simply want to build and run your code quickly without the overhead of a full development environment.
Providing a makefile ensures your project is accessible, portable, and easy to build for a wider audience.
Imagine a furniture manufacturer requiring every customer to have their own sawmill, chainsaws, planers, varnishes, and other specialized tools at home just to assemble and use the furniture. That would be highly impractical and limit who can actually use their products.
Similarly, an IDE is a development tool intended for writing and debugging code. The goal is to create code that can be built and used independently of any specific IDE installation, making it accessible to everyone regardless of their chosen tools or environment.