Hello every one! I would like to add an external package. Before trying to build the package’s sources into RIOT (I struggle on this I am new to makefiles), I provide the pre-built static library ns_pkg_lib.a on one side, and all the header of the package on another side.
I rely on the package cryptoauthlib, which uses a static library. Let me do the comparison :
Makefile.cryptoauthlib and Makefile.ns_pkg_lib are the same (the name of the module changes of course).
in pkg/cryptoauthlib/Makefile.include :
PKG_SOURCE_DIR ?= $(PKGDIRBASE)/cryptoauthlib PKG_TESTINCLDIR = $(PKG_SOURCE_DIR)/test
INCLUDES += -I$(PKG_SOURCE_DIR) INCLUDES += -I$(PKG_SOURCE_DIR)/lib INCLUDES += -I$(PKG_SOURCE_DIR)/app INCLUDES += -I$(RIOTPKG)/cryptoauthlib/include
DIRS += $(RIOTPKG)/cryptoauthlib/contrib
ARCHIVES += $(BINDIR)/cryptoauthlib.a
in pkg/ns_pkg_lib/Makefile.include :
NS_SOURCE_DIR ?= $(RIOTBASE)/build/pkg/ns_pkg_lib
INCLUDES += -I$(NS_SOURCE_DIR)
-I$(NS_SOURCE_DIR)/lib \ #this is where the .a is found -I$(NS_SOURCE_DIR)/ns_pkg_lib/include/ns_pkg_lib-interface
-I$(NS_SOURCE_DIR)/ns_pkg_lib/ns_pkg_lib-eventloop/
-I$(NS_SOURCE_DIR)/nanostack/ns_pkg_lib-event-loop/platform
-I$(NS_SOURCE_DIR)/drivers/802.15.4_RF
-I$(RIOTPKG)/ns_pkg_lib/includeDIRS += $(RIOTPKG)/ns_pkg_lib/contrib
ARCHIVES += $(BINDIR)/ns_pkg_lib.a
in pkg/cryptoauthlib/Makefile : fetches the repo, make the lib and do cp $(PKG_BUILD_DIR)/libcryptoauth.a $(BINDIR)/$(PKG_NAME).a
in pkg/ns_pkg_lib/Makefile: We fetch the repo but we do not make the package as the .a is already provided, then cp $(PKG_SOURCE_DIR)/lib/ns_pkg_lib.a $(BINDIR)/ns_pkg_lib.a
I can tell this line works because I have ns_pkg_lib.a file in tests/pkg_ns_pkg_lib/bin/board_used/
How I test it: In my package, in a .c file I call a function supposed to call RIOT spi functions. In the .h of the package, the proto of the function is declared, but I have no implementation of this function in my package. I did the implementation in pkg/contrib/spi_platform.c, and I include the header of the package. I can tell it finds the header because it doesn’t tell it can’t find it, and when I comment it, I have implicit declaration error. In my main.c, I include the header, and I call the function. It compiles but I have Undefined reference to function, so it doesn’t work.
could not having implementation in the package be an issue? How can I know if it cannot link the library or I did a coding mistake? Am I missing something? Thank you for reading this long post and thank you very much for your help. Do not hesistate to ask for further detail.
++