Notes on Android.mk parsing and compiling procedure in AOSP

Here is a drawio diagram[png version] that shows the flow of how Android.mk file is parsed and the build command is executed.

Mind you, this is a note taken while I was trying to link the su binary with libcap.so which is newly introduced as a part of my modification.

  • suprisingly, the LOCAL_SHARED_LIBRARIES modifier didn’t seem to actually do anything…

  • the gcc command is located inside /build/core/definitions.mk file. Not sure when this is executed. If you want to see the actual gcc command, you should tweak it toi print out the command.
  • the linking command is also located inside /build/core/definitions.mk file. Not sure when this is executed.

  • In the linking command, I cannot find a flow where LOCAL_SHARED_LIBRARIES values are related. On the other hand I have found a flow where LOCAL_LDFLAGS is related.

  • LOCAL_LDDIRS by default directs to the /out/.../intermediates/lib directory. If I have already built the libcap.so beforehand, the original copy will be located under this directory.
  • Adding -lcap to the LOCAL_LDFLAGS is enough to let the linker know that it should link the libcap.so as well. It is normal to omit the lib characters at the front of libcap.so.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s