1 { lib, stdenv, fetchurl, libiconv, vanilla ? false }:
3 stdenv.mkDerivation rec {
8 url = "https://pkg-config.freedesktop.org/releases/${pname}-${version}.tar.gz";
9 sha256 = "14fmwzki1rlz8bs2p810lk6jqdxsk966d8drgsjmi54cd00rrikg";
12 outputs = [ "out" "man" "doc" ];
15 # Process Requires.private properly, see
16 # http://bugs.freedesktop.org/show_bug.cgi?id=4738, migrated to
17 # https://gitlab.freedesktop.org/pkg-config/pkg-config/issues/28
18 patches = lib.optional (!vanilla) ./requires-private.patch
19 ++ lib.optional stdenv.isCygwin ./2.36.3-not-win32.patch;
21 # These three tests fail due to a (desired) behavior change from our ./requires-private.patch
22 postPatch = if vanilla then null else ''
23 rm -f check/check-requires-private check/check-gtk check/missing
26 buildInputs = [ libiconv ];
28 configureFlags = [ "--with-internal-glib" ]
29 ++ lib.optionals (stdenv.isSunOS) [ "--with-libiconv=gnu" "--with-system-library-path" "--with-system-include-path" "CFLAGS=-DENABLE_NLS" ]
30 # Can't run these tests while cross-compiling
31 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform)
32 [ "glib_cv_stack_grows=no"
34 "ac_cv_func_posix_getpwuid_r=yes"
35 "ac_cv_func_posix_getgrgid_r=yes"
38 env.NIX_CFLAGS_COMPILE = toString (
39 # Silence "incompatible integer to pointer conversion passing 'gsize'" when building with Clang.
40 lib.optionals stdenv.cc.isClang ["-Wno-int-conversion"]
41 # Silence fprintf format errors when building for Windows.
42 ++ lib.optionals stdenv.hostPlatform.isWindows ["-Wno-error=format"]
45 enableParallelBuilding = true;
48 postInstall = ''rm -f "$out"/bin/*-pkg-config''; # clean the duplicate file
51 description = "A tool that allows packages to find out information about other packages";
52 homepage = "http://pkg-config.freedesktop.org/wiki/";
53 platforms = platforms.all;
54 license = licenses.gpl2Plus;
55 mainProgram = "pkg-config";