Hello,
can someone explain me how the makefile compile the python object files (https://github.com/micropython/micropyt ... /py.mk#L61), although the file extension is .c /.s?
Is the solution in the file mkrules.mk https://github.com/micropython/micropyt ... ules.mk#L1 ??
PY_O_BASENAME
Re: PY_O_BASENAME
see the comments in that file, https://github.com/micropython/micropyt ... ules.mk#L7, and specifically the implementation at https://github.com/micropython/micropyt ... les.mk#L46:Tetraeder wrote:Is the solution in the file mkrules.mk https://github.com/micropython/micropyt ... ules.mk#L1 ??
Code: Select all
$(BUILD)/%.o: %.c
$(call compile_c)
Re: PY_O_BASENAME
It is confusing at first, the best thing is to read up more on pattern rules and implicit rules and look at a few examples:
https://www.gnu.org/software/make/manua ... tern-Match
https://www.gnu.org/software/make/manua ... tern-Match
Re: PY_O_BASENAME
I think that one of the biggest problems with understanding make is that people start at the source and try to build an executable.
make actually works the reverse way around. It's all about dependencies.
So you start at the executable, and you say, what does this executable depend on? And how do I build those dependencies?
The executable (an .elf file) depends on objects, and those objects depend on source and header files. Some sources and/or headers are generated, and those then depend the files used to generate them.
It's a subtle distinction, but a very important one to understand when trying to understand how make works.
make actually works the reverse way around. It's all about dependencies.
So you start at the executable, and you say, what does this executable depend on? And how do I build those dependencies?
The executable (an .elf file) depends on objects, and those objects depend on source and header files. Some sources and/or headers are generated, and those then depend the files used to generate them.
It's a subtle distinction, but a very important one to understand when trying to understand how make works.
Re: PY_O_BASENAME
That's right, think of them as recipes for building your application. There's no straight flow as such when you read a make file, although can be. You can also read up on the declarative programming paradigm. I genuinely find gnumake manual the best thing to read through if you have time :)