Autotools

GNU Autotools are standardized tools for getting build settings from the user and inspecting the system to generate portable Makefiles and header files with existing platform specific definitions. This alleviates the need for developers to maintain portable headers themselves, which is no simple task.

Start by installing the tools:

sudo apt install automake pkg-config

Then, you'll likely need to run autoreconf -i from the source directory to initialize the Autotools project. Projects sometimes provide helper scripts for running the command named bootstrap or autogen.sh that you should call instead.

QNX recursive make features built-in support for Autotools. The "GNU configure" documentation has additional details that you can reference to port a more complex project. The process involves creating a build-hooks shell script, which usually contains definitions for the following functions.

The hook_preconfigure() is run before the Autoconf configure script, and appends build settings to a configure_opts variable which is forwarded to the configure command in the hook_configure() stage. Some options needed for the build are:

#!/bin/sh

DIST_BASE=${QNX_PROJECT_ROOT:-"${PWD}/../../../../"}

INSTALL_ROOT=$(eval "echo \\{INSTALL_ROOT\_${TARGET_SYSNAME}}")

INSTALL_PREFIX=${PREFIX:-"/usr/local"}

function hook_preconfigure {
    # ...

    # configure_opts already defines --srcdir, we need to override it.
    configure_opts="--srcdir=${DIST_BASE}"
    configure_opts="${configure_opts} --prefix=${INSTALL_ROOT}/${INSTALL_PREFIX}"
    configure_opts="${configure_opts} --exec-prefix=${INSTALL_ROOT}/${cpudir}/${INSTALL_PREFIX}"

}

The hook_configure() function is already defined in recursive make and calls the configure command with the appropriate compiler and compiler flags. However, it often needs to be overriden to call the configure command provided by the project. For example:

# ...

function hook_configure {
    ${DIST_BASE}/configure \
        ${ac_host:+"--host=${ac_host}"} \
        ${ac_build:+"--build=${ac_build}"} \
        ${configure_opts} \
        ${ac_params:+${CC:+"CC=${CC}"}} \
        ${ac_params:+${CFLAGS:+"CFLAGS=${CFLAGS}"}} \
        ${ac_params:+${CPPFLAGS:+"CPPFLAGS=${CPPFLAGS}"}} \
        ${ac_params:+${LDFLAGS:+"LDFLAGS=${LDFLAGS}"}} \
        ${ac_params:+${CXX:+"CXX=${CXX}"}} \
        ${ac_params:+${CXXFLAGS:+"CXXFLAGS=${CXXFLAGS}"}} \
        ${ac_params:+${ac_autotools:+${ac_autotools}}}
}

Finally, the recursive make variant build folders (such as nto-aarch64-le and nto-x86_64-o) should contain GNUmakefile(s) containing the same definitions as the ordinary Makefiles created by addvariant with the appended line:

include $(MKFILES_ROOT)/qmake-cfg.mk

The PRODUCT_ROOT level Makefile should contain the added line:

MAKEFILE=GNUmakefile
Page updated: