Some questions about package.mk structure

  • Hi there,

    I'm working on a customized image of LibreELEC 9.2.6 (for x86 and Raspberry Pi 3) and I need to add an application to the system which can't be added through Kodi Addons, so I'm creating a package.mk in order to get the App added on buildtime.

    However, I have some questions regarding package.mk and dependencies, and I didn't find answers anywhere.

    using the glib package.mk as an example, we have:

    ...

    PKG_DEPENDS_HOST="libffi:host Python3:host meson:host"

    PKG_DEPENDS_TARGET="toolchain pcre zlib libffi Python3:host util-linux"

    ...

    I do not fully understand what are all this PKG_DEPENDS_* for. Looking at the build script, I've seen that you can specify to build a package like:

    PROJECT=RPi DEVICE=RPi2 ARCH=arm scripts/build glib

    Or

    PROJECT=RPi DEVICE=RPi2 ARCH=arm scripts/build glib:host

    I supose for the glib:host it uses as dependencies the PKG_DEPENDS_HOST variable, if I build glib:target it uses PKG_DEPENDS_TARGET... but my question is, what is this argument (:[host|bootstrap|init|target]) for? If I only make a normal build (without this argument) what libraries variable from the package.mk will it use?

    And another question:

    PKG_DEPENDS_TARGET="toolchain pcre zlib libffi Python3:host util-linux"

    Here is a list of libraries needed to build glib. Why in the python3 one it says Python3:host and not Python3? What is the meaning of ":host" in this case?

    Cheers!

  • Hi nuive - probably not the best example to start with. glib is a package that builds for both the host that does the build and the target (your RPi3)

    In the case of your xxxx:host question - python:host is built “for the host” to be able to build glib.

    In your glib example - lib would be a dependency (on the RPi3 for your app)

    What application are you trying to package, might be able to give you some pointers on a package.mk to start with.

  • Hi,

    I'm trying to add Speech Dispatcher (Speech Dispatcher - Free(B)Soft), module for TexToSpeech.

    I know that it won't be an easy module to add (it depends on some libraries, for building and for running). At the momment I have this:

    --------------------

    Code
    PKG_NAME="speech-dispatcher"
    PKG_VERSION="0.10.2"
    PKG_SHA256="b06319f201e15e56c6296653af5bcfc300cb348e972d517df8b06eac77eae2dc"
    PKG_LICENSE="LGPL"
    PKG_SITE="https://freebsoft.org/speechd"
    PKG_URL="https://github.com/brailcom/speechd/releases/download/$PKG_VERSION/$PKG_NAME-$PKG_VERSION.tar.gz"
    PKG_DEPENDS_TARGET="toolchain glib (dotconf) libsndfile libpthread-stubs"
    PKG_LONGDESC="Common high-level interface to TTS"

    --------------------

    The dotconf dependency is between () because it is not present on libreELEC, so I will have to add that package too.

    Basically what I don't understand is what libraries I should add on PKG_DEPENDS_TARGET, PKG_DEPENDS_HOST... and which of them (if any) should be followed with the :[host|target|...] argument.

  • Suggest you start with the below.

    which will error with the following. Only add dependancies to packages that you error on or you want the package compiled against. E.g. if you don’t want to use the h264 codec in a video app, then don’t include it … etc.

    As you are not developing a package that you need during the build process, all of your packages should be targets. And that is the default. So no need to use :host or :target for your development.

    If for example you needed to use the “mkimg” program to build a package “mkimg” because onnof the steps in building “mkimg” properly is to creat some images, and that uses the newly compiled “mkimg” program. You will need to compile both a host and target “mkimg”. Host to create you images, and target to run on your RPi.

    If you don’t need the mkimg program on your RPi, then you would only build mkimg:host.

    Hope that helps.

    Examples are cmake is a host only build.

  • Thank you very much!

    Yes, it helped a lot.

    Now I'm having another problem... I'm adding the needed dotconf library. At the momment I have this package.mk (it is not completed)

    --------------------

    When trying to build it for the Raspberry Pi with the command:

    PROJECT=RPi ARCH=arm DEVICE=RPi2 scripts/build dotconf

    I get (on the ./configure step):

    configure: error: cannot run C compiled programs.

    If you meant to cross compile, use `--host'.

    See `config.log' for more details

    How can I add the host variable to package.mk? What am I missing?

  • You will want to remove the manual TOOLCHAIN and the pre_make

    Try with:

    Code
    PKG_TOOLCHAIN="autotools"

    The build system does most of the hard work (most of the time)

  • Thanks, it worked. Finally I could add the dotconf library to LibreELEC.

    Now I'm having another problem with the main package (Speech dispatcher).

    --------------------

    Code
    PKG_NAME="speech-dispatcher"
    PKG_VERSION="0.10.2"
    PKG_SHA256="b06319f201e15e56c6296653af5bcfc300cb348e972d517df8b06eac77eae2dc"
    PKG_LICENSE="LGPL"
    PKG_SITE="https://freebsoft.org/speechd"
    PKG_URL="https://github.com/brailcom/speechd/releases/download/$PKG_VERSION/$PKG_NAME-$PKG_VERSION.tar.gz"
    PKG_DEPENDS_TARGET="toolchain glib dotconf libsndfile libpthread-stubs libtool"
    PKG_LONGDESC="Common high-level interface to tts"
    PKG_TOOLCHAIN="autotools"

    --------------------

    The autoreconf and ./configure stages work flawlessly, but when building it gives the following error:

    speech_dispatcher-symbols.o:symbols.c:function insert_symbols: error: undefined reference to 'rpl_malloc'

    Looking on google I've found that it is a problem with the ./configure script, which replaces the malloc function with rpl_malloc when it doesn't find the malloc function. But unless I'm mistaken, the malloc function is a system one. However, in configure.log I have:

    configure:15893: checking for GNU libc compatible malloc

    configure:15927: result: no

    ...

    | #define HAVE_MALLOC 0

    | #define malloc rpl_malloc

    Am I missing something in order to access the rpl_malloc function, or to make the configure script be able to detect the malloc function propperly?

  • Thanks, it worked. I'd read about that on google, but I though there was a better solution to fix this problem... Finally I was able to build Speech Dispatcher into LibreELEC.

  • Hi again,

    I'm having a new problem related to the addition of Speech Dispatcher.

    When building it, it checks for additional Voice TTSs and if it finds them, it adds the respective modules.

    I'm trying to generate the eSpeak Module, but it needs the espeak library for the process, so I added espeak:host as a dependency.

    The eSpeak package wasn't able to generate host builds, so I edited it and could add the eSpeak libraries and include headers to the toolchain. However, when trying to build Speech Dispatcher with espeak support it says that file <espeak/speak_lib.h> does not exist, but the file speak_lib.h is inside $TOOLCHAIN/include/espeak.

    It seems that the build process is ignoring the toolchain paths, even if toolchain is in the package.mk as a target dependency.

    My current package.mk:

    --------------------

    --------------------

  • Actually, eSpeak builds a library (libespeak.so) used by Speech Dispatcher, but it builds a static library too (.a file) and a header (speak_lib.h) which are needed to build the eSpeak module into Speech Dispatcher.

    Here is the package.mk for eSpeak:

    --------------------

    --------------------

    I've tried with espeak:host and with espeak, but in any case it throws the same error.

  • Hi,

    I'm having new questions regarding all of this. I don't know if I should create a new thread, so sorry if I should.

    Speech Dispatcher needs to have a defined locale (if it hasn't it throws an exception of 'setlocale: no such file or directory') so I did the following:

    1. In the Speech Dispatcher package directory I added a folder called locale, with files for an en_GB.UTF-8 locale.

    2. I edited the package.mk so on the post_makeinstall step it copies the locale folder into /usr/lib.

    3. I created as well another folder inside the package, profile.d, and inside this folder I added the file 10-locale.conf with the following content:

    Code
    export $LANG="en_GB.UTF-8"

    I built the image and it worked flawlessly, Speech Dispatcher included.

    However, I found that my 10-locale.conf would override any change made to the $LANG variable if, for example, the service.locale addon was installed, because the profile.d sets the addon profile variables before any other.

    So I edited the 10-locale.conf file and added a check:

    Code
    if [ -z "$LANG" ] ; then
    export LANG="en_GB.UTF-8"
    fi

    But now, even if the LANG variable returns "en_GB.UTF-8" when you do "echo $LANG" and the 'locale' command returns the correct values, Speech Dispatcher is giving me again the 'setlocale' error.

    Does anyone know why is this happening?

  • Finally I solved this.

    As you say, espeak:host was wrong. The problem was in the makeinstall_target step, the command to install the library to the sysroot folder was missing, and that step was innecesary.

    If someone has a similar problem, here is the definitive package.mk for espeak:

    Cheers

    Edited 2 times, last by nuive: Improved package code (July 28, 2021 at 10:09 PM).