Building upmpdcli on MacOS

Two possibilities for building:

  • Use macports or homebrew: npupnp, libupnpp and upmpdcli build just fine, using the tools and libraries from the chosen package manager and meson scripts. This will not be described further as it’s mostly the same as building on Linux.

  • Build a portable installation, using tools from Qt and macports, but keeping no dependencies on them. We will use the qmake .pro files of each project (from the qmk directories of each project).

Building a portable installation

This uses macports and Qt Creator for building, and the result is a portable upmpdcli, installable anywhere, compatible with x86_64 and arm64. The same thing could quite certainly be done with homebrew. There are probably many different ways to do it. The following works for me:

  • Install Qt with Qt Creator, and XCode (see the Qt docs for this).

  • Set the following environment variables:+

XCODEDV=/Applications/Xcode.app/Contents/Developer
SDK=${XCODEDV}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
ARCH_ARGS="-arch arm64 -arch x86_64"
export CC=${XCODEDV}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
export CXX=${XCODEDV}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
export CFLAGS="-isysroot $SDK $ARCH_ARGS"
export CXXFLAGS="-isysroot $SDK $ARCH_ARGS -stdlib=libc++ -std=gnu++1z"

Extract and build libmicrohttpd (0.9.71 was used for this example). The regular configure/make method bundled with the lib source "just works":

cd libmicrohttpd-0.9.71
./configure --without-gnutls
make

Extract and build libmpdclient (version 2.20 was used here).

cd libmpdclient-2.20
meson setup -Ddefault_library=static build
ninja -C build

The rest of the necessary libs (e.g. expat, libcurl) are bundled with MacOS.

Extract the source for libnpupnp, libupnppp, and upmpdcli:

  • Copy libnpupnp-x.y.z/macos/autoconfig-macos.h to libnpupnp-x.y.z/autoconfig.h

  • Copy libnpupnp-x.y.z/macos/upnpconfig-macos.h to libnpupnp-x.y.z/inc/upnpconfig.h

  • Copy libupnpp-n.m.p/macos/config-macos.h to libupnpp-n.m.p/config.h

  • Copy or link upmpdcli-t.u.v/qmk/macos-config.h to upmpdcli-t.u.v/config.h

  • Start QtCreator and open libnpupnp-x.y.z/macos/qmk/libnpupnp.pro, libupnpp-n.m.p/macos/qmk/libupnpp.pro and upmpdcli-t.u.v/upmpdcli.pro. There will almost certainly be some paths to adjust inside the '.pro' files, depending on where you extracted the files and the version numbers. Then build the three projects.

  • You can then use the qmk/mkinstdir.sh script to copy the installation files to a target directory which will have the following structure:

target/
target/etc/
target/bin/
target/share/upmpdcli

You should be able to run upmpdcli from the target tree copied in any location.

A sample file will be copied to target/etc but it will not be used by default. Possibly copy it elsewhere (or edit in place) and use the -c option.