dmenu: fix build on staging-next

Without the change `dmenu` fails to build on `staging-next` as:

    $ nix build --no-link -f. dmenu -L
    ...
    dmenu> build flags: SHELL=/nix/store/mm0pa3z7kk6jh1i9rkxqxjqmd8h1qpxf-bash-5.2p37/bin/bash CC:=\$\(CC\)
    dmenu> cp config.def.h config.h
    dmenu> gcc -c -std=c99 -pedantic -Wall -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"5.3\" -DXINERAMA dmenu.c
    dmenu> In file included from dmenu.c:17:
    dmenu> /nix/store/2rxphcg0qabc3a8c4lvy610sm03bh72y-libXft-2.3.8-dev/include/X11/Xft/Xft.h:40:10: fatal error: ft2build.h: No such file or directory
    dmenu>    40 | #include <ft2build.h>
    dmenu>       |          ^~~~~~~~~~~~
    dmenu> compilation terminated.
    dmenu> make: *** [Makefile:12: dmenu.o] Error 1

The change uses `pkg-config` to discover library dependencies and lib paths.
This commit is contained in:
Sergei Trofimovich 2024-10-15 21:50:53 +01:00
parent e2daa3d1b0
commit 3c083ef2ee

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, libX11, libXinerama, libXft, zlib, writeText
{ lib, stdenv, fetchurl, fontconfig, libX11, libXinerama, libXft, pkg-config, zlib, writeText
, conf ? null, patches ? null
# update script dependencies
, gitUpdater }:
@ -12,7 +12,8 @@ stdenv.mkDerivation rec {
sha256 = "sha256-Go9T5v0tdJg57IcMXiez4U2lw+6sv8uUXRWeHVQzeV8=";
};
buildInputs = [ libX11 libXinerama zlib libXft ];
nativeBuildInputs = [ pkg-config ];
buildInputs = [ fontconfig libX11 libXinerama zlib libXft ];
inherit patches;
@ -28,11 +29,15 @@ stdenv.mkDerivation rec {
'';
preConfigure = ''
sed -i "s@PREFIX = /usr/local@PREFIX = $out@g" config.mk
makeFlagsArray+=(
PREFIX="$out"
CC="$CC"
# default config.mk hardcodes dependent libraries and include paths
INCS="`$PKG_CONFIG --cflags fontconfig x11 xft xinerama`"
LIBS="`$PKG_CONFIG --libs fontconfig x11 xft xinerama`"
)
'';
makeFlags = [ "CC:=$(CC)" ];
passthru.updateScript = gitUpdater { url = "git://git.suckless.org/dmenu"; };
meta = with lib; {