cabal-version:       2.0
name:                ghc-bignum
version:             1.1
synopsis:            GHC BigNum library
license:             BSD3
license-file:        LICENSE
author:              Sylvain Henry
maintainer:          libraries@haskell.org
bug-reports:         https://gitlab.haskell.org/ghc/ghc/issues/new
category:            Numeric, Algebra, GHC
build-type:          Configure
description:
    This package provides the low-level implementation of the standard
    'BigNat', 'Natural' and 'Integer' types.

extra-source-files:
    aclocal.m4
    cbits/gmp_wrappers.c
    changelog.md
    configure
    configure.ac
    config.mk.in
    include/WordSize.h
    include/HsIntegerGmp.h.in
    install-sh
    ghc-bignum.buildinfo.in

source-repository head
    type:     git
    location: https://gitlab.haskell.org/ghc/ghc.git
    subdir:   libraries/ghc-bignum


Flag Native
    Description: Enable native backend
    Manual: True
    Default: False

Flag FFI
    Description: Enable FFI backend
    Manual: True
    Default: False

Flag GMP
    Description: Enable GMP backend
    Manual: True
    Default: False

Flag Check
    Description: Validate results of the enabled backend against native backend.
    Manual: True
    Default: False

library

  -- check that at least one flag is set
  if !flag(native) && !flag(gmp) && !flag(ffi)
    buildable: False

  -- check that at most one flag is set
  if flag(native) && (flag(gmp) || flag(ffi))
    buildable: False
  if flag(gmp) && flag(ffi)
    buildable: False

  default-language:    Haskell2010
  other-extensions:
    BangPatterns
    CPP
    ExplicitForAll
    GHCForeignImportPrim
    MagicHash
    NegativeLiterals
    NoImplicitPrelude
    UnboxedTuples
    UnliftedFFITypes
    ForeignFunctionInterface

  build-depends:
    ghc-prim >= 0.5.1.0 && < 0.8

  hs-source-dirs: src/
  include-dirs: include/
  ghc-options: -Wall
  cc-options: -std=c99 -Wall

  -- GHC has wired-in IDs from the ghc-bignum package. Hence the unit-id
  -- of the package should not contain the version: i.e. it must be
  -- "ghc-bignum" and not "ghc-bignum-1.0".
  ghc-options: -this-unit-id ghc-bignum

  include-dirs: include

  if flag(gmp)
      cpp-options: -DBIGNUM_GMP
      other-modules:
         GHC.Num.Backend.GMP
      c-sources:
         cbits/gmp_wrappers.c

  if flag(ffi)
      cpp-options: -DBIGNUM_FFI
      other-modules:
         GHC.Num.Backend.FFI

  if flag(native)
      cpp-options: -DBIGNUM_NATIVE

  if flag(check)
      cpp-options: -DBIGNUM_CHECK
      other-modules:
         GHC.Num.Backend.Check


  exposed-modules:
    GHC.Num.Primitives
    GHC.Num.WordArray
    GHC.Num.BigNat
    GHC.Num.Backend
    GHC.Num.Backend.Selected
    GHC.Num.Backend.Native
    GHC.Num.Natural
    GHC.Num.Integer
