I am using for the first time autotools & Cie and I am lost. I generate about one hundred dynamic libraries in my openwrt environment in differents packages. Later in a binary, I use dlopen + dlsym to use my library. This allow me to use a kind of plugins system.
Now I would like to be able to link all my libraries statically instead of using my plugin sytem. Basically I would like to say if my library A is defined in my .config file, link it with my binary. So now I have just tu use dlsym functionnalities without use of dlopen feature.
I am able to do it but in my opinion, in a very dirty way.
- Use my library if the package is defined in the .config Makefile of the package of my binary
PKG_BUILD_DEPENDS+= +PACKAGE_LIBA:LIBA ifdef CONFIG_PACKAGE_LIBA CONFIGURE_ARGS+= --enable-LIBA endif
- configure.ac of my binary in dl directory
AC_ARG_ENABLE([LIBA], [AS_HELP_STRING([--enable-LIBA], [Enable link with LIBA (default no)])], [ if test x"$enableval" = "xno" ; then LIBA="0" ; else LIBA="1" ; fi ], [LIBA="0"]) if test "$LIBA" = "1" ; then [LIBA="-la"] AC_SUBST([LIBA_LIBS]) fi
- Makefile.am of my binary in dl directory
MYBINARY_LDADD = $(LIBA_LIBS)
Now, I need to do that for hundred of libraries. Moreover, if LIBA is using for example a standard library I need to add it manually... Quite ironic to use AUTOtools like this... Anyway it is working but so ugly.. The benefit of this is that I only need to modify my binary Makefile/configure and not all packages. If I could I did that only with Makefile but one of my requirement here is to use autotools. I have also try another solution with pc.in file where I have to describe my library, but I was not able to use it correctly. And not sure that it was really clean to follow this solution.
Thanks, Arthur.