hs-pkg-config: Create pkg-config configuration files

[ bsd3, data, development, library ] [ Propose Tags ] [ Report a vulnerability ]

Create pkg-config configuration file from Haskell code using combinators specialized for this purpose.

One of the possible usage examples of this library is generating .pc files from Shake build system.

For usage example see Data.PkgConfig module.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
pedantic

Pass additional warning flags including -Werror to GHC during compilation.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0
Change log ChangeLog.md
Dependencies base (>=4.6 && <5), data-default-class (<1), text (>=0.11 && <1.3) [details]
License BSD-3-Clause
Copyright Copyright (c) 2014 Peter Trško
Author Peter Trško
Maintainer peter.trsko@gmail.com
Revised Revision 2 made by PeterTrsko at 2017-03-12T07:47:45Z
Category Data, Development
Home page https://github.com/trskop/hs-pkg-config
Bug tracker https://github.com/trskop/lock-file/issues
Source repo head: git clone git://github.com/trskop/hs-pkg-config.git
this: git clone git://github.com/trskop/hs-pkg-config.git(tag 0.2.1.0)
Uploaded by PeterTrsko at 2014-12-24T11:23:01Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3042 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2014-12-24 [all 1 reports]

Readme for hs-pkg-config-0.2.1.0

[back to package description]

Hs-pkg-config

Hackage BSD3 License

Description

Library for creating pkg-config configuration files from Haskell.

One of the possible usage examples of this library is generating .pc files from Shake build system.

Example

Following Haskell code is able to generate package configuration file named foo.pc for library foo:

{-# LANGUAGE OverloadedStrings #-}
module Main (main)
  where

import Data.String (IsString)

import Data.Default.Class (Default(def))
   -- From data-default-class library:
   -- http://hackage.haskell.org/package/data-default-class

import Control.Lens
   -- From lens library:
   -- http://hackage.haskell.org/package/lens

import Data.PkgConfig


libraryBaseName :: IsString a => a
libraryBaseName = "foo"

main :: IO ()
main = writePkgConfig (libraryBaseName ++ ".pc") libPkgConfig
  where
    libPkgConfig = def
        & pkgVariables   .~
            [ ("prefix",     "/usr/local"              )
            , ("includedir", var "prefix" </> "include")
            , ("libdir",     var "prefix" </> "lib"    )
            , ("arch",       "i386"                    )
            ]
        & pkgName        .~ libraryBaseName
        & pkgDescription .~ "Example pkg-config."
        & pkgVersion     .~ version [1, 2, 3]
        & pkgCflags      .~ includes [var "includedir"]
        & pkgRequires    .~ list
            [ "bar" ~> [0], "bar" ~<= [3, 1]
            , "baz" ~= [1, 2, 3]
            ]
        & pkgLibs        .~ options
            [ libraryPath [var "libdir", var "libdir" </> var "arch"]
            , libraries [libraryBaseName]
            ]

Content of foo.pc:

prefix=/usr/local
includedir=${prefix}/include
libdir=${prefix}/lib
arch=i386

Name: foo
Description: Example pkg-config.
Version: 1.2.3
Requires: bar > 0, bar <= 3.1, baz = 1.2.3
Cflags: -I"${includedir}"
Libs: -L"${libdir}" -L"${libdir}/${arch}" -lfoo

Now lets see if pkg-config would be able to tell us something about this library:

$ PKG_CONFIG_PATH=`pwd` pkg-config --modversion foo
1.2.3

Note that asking for --cflags or other options would result in error saying that it is unable to find bar and baz libraries. That is OK, it means that it is able to parse file correctly, we just hadn't provided bar.pc and baz.pc. If we delete lines that define Requires: field, then pkg-config would be able to give us --cflags, --libs, etc. You can try it.

Building options

  • -fpedantic (disabled by default)

    Pass additional warning flags including -Werror to GHC during compilation.