1 # The wrapper script ensures variables like PKG_CONFIG_PATH and
2 # PKG_CONFIG_PATH_FOR_BUILD work properly.
8 , baseBinName ? "pkg-config"
9 , propagateDoc ? pkg-config != null && pkg-config ? man
10 , extraPackages ? [], extraBuildCommands ? ""
25 inherit (stdenv) hostPlatform targetPlatform;
27 # Prefix for binaries. Customarily ends with a dash separator.
29 # TODO(@Ericson2314) Make unconditional, or optional but always true by
31 targetPrefix = optionalString (targetPlatform != hostPlatform)
32 (targetPlatform.config + "-");
34 # See description in cc-wrapper.
35 suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
37 wrapperBinName = "${targetPrefix}${baseBinName}";
41 pname = targetPrefix + pkg-config.pname + "-wrapper";
42 inherit (pkg-config) version;
44 enableParallelBuilding = true;
46 preferLocalBuild = true;
48 outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (pkg-config ? doc) "doc");
51 inherit targetPrefix suffixSalt;
60 # Additional flags passed to pkg-config.
61 addFlags = optional stdenv.targetPlatform.isStatic "--static";
65 mkdir -p $out/bin $out/nix-support
71 substituteAll "$wrapper" "$out/bin/$dst"
72 chmod +x "$out/bin/$dst"
75 echo $pkg-config > $out/nix-support/orig-pkg-config
77 wrap ${wrapperBinName} ${./pkg-config-wrapper.sh} "${getBin pkg-config}/bin/${baseBinName}"
79 # symlink in share for autoconf to find macros
81 # TODO(@Ericson2314): in the future just make the unwrapped pkg-config a
82 # propagated dep once we can rely on downstream deps comming first in
83 # search paths. (https://github.com/NixOS/nixpkgs/pull/31414 took a crack
86 ln -s ${pkg-config}/share $out/share
90 ../setup-hooks/role.bash
99 # Propagate the underling unwrapped pkg-config so that if you
100 # install the wrapper, you get anything else it might provide.
102 printWords ${pkg-config} > $out/nix-support/propagated-user-env-packages
106 ## Man page and doc support
108 + optionalString propagateDoc (''
109 ln -s ${pkg-config.man} $man
110 '' + optionalString (pkg-config ? doc) ''
111 ln -s ${pkg-config.doc} $doc
115 substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
116 substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
120 ## Extra custom steps
122 + extraBuildCommands;
125 shell = getBin stdenvNoCC.shell + stdenvNoCC.shell.shellPath or "";
126 wrapperName = "PKG_CONFIG_WRAPPER";
127 inherit targetPrefix suffixSalt baseBinName;
131 let pkg-config_ = optionalAttrs (pkg-config != null) pkg-config; in
132 (optionalAttrs (pkg-config_ ? meta) (removeAttrs pkg-config.meta ["priority" "mainProgram"])) //
134 attrByPath ["meta" "description"] "pkg-config" pkg-config_
135 + " (wrapper script)";
137 mainProgram = wrapperBinName;