Hi all.
Does Genode build system only allow to build a binary or library with each "target.mk" makefile? Is it possible to have non-binary targets in these makefiles, or have more than one target?
Specifically, I need to generate a "map" file with some functions addresses. So, I use "nm" on a just built binary to generate a map file with lines like
<Function_name> <Function_address>
The map file should be a dependency of the binary itself, but I was not able to figure out, how to trigger a map file generation after the binary is built. I tried to add a rule like this:
all: map
to target.mk. So, the map file should be a dependency of "all" target, but this does not work, because "map" then is built before the binary specified as
TARGET = <binary_name>
Does someone have any ideas, how it's possible to accomplish this?
WBR, valery
Hi Valery,
There's a good example of pretty exactly what you're trying to do in the Genode world repository:
https://github.com/genodelabs/genode-world/blob/master/src/app/ltris/target....
As you can see in lines 17, you can make your map file depend on $(TARGET), which includes all binaries and libraries that are needed for the target declared in line 1. Then you can declare a rule how your map file gets generated like done here in lines 18/19.
I hope this helped?
Cheers, Martin
El 18/3/19 a las 0:17, Valery V. Sedletski via users escribió:
Hi all.
Does Genode build system only allow to build a binary or library with each "target.mk" makefile? Is it possible to have non-binary targets in these makefiles, or have more than one target?
Specifically, I need to generate a "map" file with some functions addresses. So, I use "nm" on a just built binary to generate a map file with lines like
<Function_name> <Function_address>
The map file should be a dependency of the binary itself, but I was not able to figure out, how to trigger a map file generation after the binary is built. I tried to add a rule like this:
all: map
to target.mk. So, the map file should be a dependency of "all" target, but this does not work, because "map" then is built before the binary specified as
TARGET = <binary_name>
Does someone have any ideas, how it's possible to accomplish this?
WBR, valery
Genode users mailing list users@lists.genode.org https://lists.genode.org/listinfo/users
Martin Stein wrote:
Hi Valery,
There's a good example of pretty exactly what you're trying to do in the Genode world repository:
https://github.com/genodelabs/genode-world/blob/master/src/app/ltris/target....
As you can see in lines 17, you can make your map file depend on $(TARGET), which includes all binaries and libraries that are needed for the target declared in line 1. Then you can declare a rule how your map file gets generated like done here in lines 18/19.
I hope this helped?
No, it seems, "ltris" example is not what I need, because in "ltris", $(TARGET) depends on a tar file generation. So, $(TARGET) is generated after tar file is built. I need the opposite, i.e., generate the binary first, then the map file.
So, I need $(TARGET) to be dependent from the "map" file, not vice versa.
I tried to define TARGET as my map file, and my binary as its dependency, but this does not work, as TARGET should be necessarily a binary name, as I understood.
Anyway, thanks for the suggestion
Cheers, Martin
Hi Valery,
On 18.03.19 00:17, Valery V. Sedletski via users wrote:
Hi all.
Does Genode build system only allow to build a binary or library with each "target.mk" makefile? Is it possible to have non-binary targets in these makefiles, or have more than one target? ...
to target.mk. So, the map file should be a dependency of "all" target, but this does not work, because "map" then is built before the binary specified as
TARGET = <binary_name>
Does someone have any ideas, how it's possible to accomplish this?
I'm afraid that your use case is currently not very well covered.
So we should probably add a proper hook for it. In the meantime, could you give the following idea a try?
-----
ifneq ($(INSTALL_DIR),) all: map endif
map: $(TARGET) nm $< | sed "s/some/magic" > $@
-----
The check for 'INSTALL_DIR' is needed because the target.mk file is actually visited twice during the build. First, it is examined to find out the inter-library dependencies. This dependency stage is followed by the actual build stage. The custom rule should be executed in the latter stage only. As INSTALL_DIR is defined only at the build stage, we can use it as a condition here.
The dependency from $(TARGET) ensures that your binary exists before 'nm' is called on it.
Cheers Norman
Oh, sorry for the mixup Valery...
What I actually meant was the second part of what Norman suggested:
El 18/3/19 a las 21:31, Norman Feske escribió:> Hi Valery,
ifneq ($(INSTALL_DIR),) all: map endif
map: $(TARGET) nm $< | sed "s/some/magic" > $@
I didn't know that the first part is also necessary.
Cheers, Martin
Martin Stein wrote:
Oh, sorry for the mixup Valery...
What I actually meant was the second part of what Norman suggested:
El 18/3/19 a las 21:31, Norman Feske escribió:> Hi Valery,
ifneq ($(INSTALL_DIR),) all: map endif
map: $(TARGET) nm $< | sed "s/some/magic" > $@
I didn't know that the first part is also necessary.
Yes, no problem. I even managed it to work when called from a run script, without checking INSTALL_DIR, with some dirty workaround. But the workaround didn't worked when I tried to build a depot package with the same makefile. Then I got an empty map file. But with an INSTALL_DIR check, it works as it should.
Cheers, Martin
Genode users mailing list users@lists.genode.org https://lists.genode.org/listinfo/users
Norman Feske wrote:
Hi Valery,
On 18.03.19 00:17, Valery V. Sedletski via users wrote:
Hi all.
Does Genode build system only allow to build a binary or library with each "target.mk" makefile? Is it possible to have non-binary targets in these makefiles, or have more than one target? ...
to target.mk. So, the map file should be a dependency of "all" target, but this does not work, because "map" then is built before the binary specified as
TARGET = <binary_name>
Does someone have any ideas, how it's possible to accomplish this?
I'm afraid that your use case is currently not very well covered.
So we should probably add a proper hook for it. In the meantime, could you give the following idea a try?
So, the targets other than binaries/libraries are not possible currently? This is what I suspected. Indeed, having a hook for extra custom targets executed before or after the main target would be a good idea.
ifneq ($(INSTALL_DIR),) all: map endif
map: $(TARGET) nm $< | sed "s/some/magic" > $@
The check for 'INSTALL_DIR' is needed because the target.mk file is actually visited twice during the build. First, it is examined to find out the inter-library dependencies. This dependency stage is followed by the actual build stage. The custom rule should be executed in the latter stage only. As INSTALL_DIR is defined only at the build stage, we can use it as a condition here.
The dependency from $(TARGET) ensures that your binary exists before 'nm' is called on it.
Cheers Norman
This worked fine. So, "map" target is indeed executed before $(TARGET), as required. Thank you very much for the excellent idea about checking INSTALL_DIR, this is what helped. (I noticed that the "all" target is called twice, and this hurted things up. Now it is called only once, as it should).
WBR, valery