Adding targets in a library makefile?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AnPu_3825896
Level 1
Level 1
First like given

Is there a straightforward way to add make targets via a library's makefile, i.e. something included by $(NAME)_COMPONENTS += utilities/mylib ?


I would like to trigger a separate, non-Makefile build system in-place there, which should emit a .a library, which I would then way to roll into the larger WICED app build.
I imagine something like specifying a new target, i.e.


libmylib.a:
     do_other_build.sh

And then something like
$(NAME)_PREBUILT_LIBRARY := libmylib.a

So that it gets included in the overall build to be linked against.

But I am not sure how to get libmylib.a into the targets list for the Makefile that is including the component makefile.

Is there an existing way to accomplish this with the build system?

0 Likes
1 Solution

Sure, I use the "component" system extensively and have added a bunch of source-level libraries and some prebuilt ones (e.g. CMSIS-DSP).

However: in this case, I want to trigger the shell script as part of building the WICED project. In my case, this generates a library from a totally separate build system, which I then want to link in. So if I change that source, the custom sub-build will also execute.

I have a sort-of solution to this, but I am not sure if it is final. It is fairly circuitous, as it seems to require an empty dummy.c source file.
My library makefile is:

NAME := Lib_mylib

GLOBAL_INCLUDES := .

$(NAME)_SOURCES := dummy.c

$(NAME)_PRE_BUILD_TARGETS += libmylib.a

.PHONY: libmylib.a

libmylib.a:

echo ">>>>> MYLIB BUILD <<<<<<"

cd $(Lib_mylib_LOCATION)

cd $(Lib_mylib_LOCATION) && PATH="$(SAVED_PATH)" mylib_custom_build.sh

cd $(Lib_mylib_LOCATION) && mv -f build_output/libmylib.a . 2>/dev/null; true

$(NAME)_PREBUILT_LIBRARY := libmylib.a

View solution in original post

0 Likes
2 Replies
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

I don't think you would need to create a separate make target. Although, it might just be that I did not get your question correctly.

Say, you are working with snip.bluetooth.ble_hello_sensor in a hosted platform like 4343w. If you look at the .mk file, you would find

$(info "Host Stack")

$(NAME)_COMPONENTS += libraries/drivers/bluetooth/low_energy

As the low_energy component gets included, it jumps to 43xxx_Wi-Fi/libraries/drivers/bluetooth/low_energy/low_energy.mk and includes the pre-built ble library based on some condition checks like rtos, host_arch etc in the WICED buildsystem.

Now in your case, in the mylib.mk, you can run the shell script and then add the generated .a file in $(NAME)_PREBUILT_LIBRARY in the same .mk. Please let me know if I picked the correct idea or your main query is still unanswered?

Sure, I use the "component" system extensively and have added a bunch of source-level libraries and some prebuilt ones (e.g. CMSIS-DSP).

However: in this case, I want to trigger the shell script as part of building the WICED project. In my case, this generates a library from a totally separate build system, which I then want to link in. So if I change that source, the custom sub-build will also execute.

I have a sort-of solution to this, but I am not sure if it is final. It is fairly circuitous, as it seems to require an empty dummy.c source file.
My library makefile is:

NAME := Lib_mylib

GLOBAL_INCLUDES := .

$(NAME)_SOURCES := dummy.c

$(NAME)_PRE_BUILD_TARGETS += libmylib.a

.PHONY: libmylib.a

libmylib.a:

echo ">>>>> MYLIB BUILD <<<<<<"

cd $(Lib_mylib_LOCATION)

cd $(Lib_mylib_LOCATION) && PATH="$(SAVED_PATH)" mylib_custom_build.sh

cd $(Lib_mylib_LOCATION) && mv -f build_output/libmylib.a . 2>/dev/null; true

$(NAME)_PREBUILT_LIBRARY := libmylib.a

0 Likes