cabal-version:       2.2
name:                hslua
version:             1.3.0
synopsis:            Bindings to Lua, an embeddable scripting language
description:         HsLua provides bindings, wrappers, types, and helper
                     functions to bridge Haskell and <https://www.lua.org/ Lua>.
                     .
                     This package contains a full Lua interpreter version 5.3.6.
                     If you want to link it with a system-wide Lua installation,
                     use the @system-lua@ flag.
                     .
                     <https://github.com/hslua/hslua-examples Example programs>
                     are available in a separate repository.
homepage:            https://hslua.github.io/
bug-reports:         https://github.com/hslua/hslua/issues
license:             MIT
license-file:        LICENSE
author:              Gracjan Polak, Ömer Sinan Ağacan
maintainer:          albert+hslua@zeitkraut.de
copyright:           © 2007–2012 Gracjan Polak
                     © 2012–2016 Ömer Sinan Ağacan
                     © 2016–2020 Albert Krewinkel
category:            Foreign
build-type:          Simple
extra-source-files:  cbits/lua-5.3.6/*.h
                   , cbits/hslua/*.h
                   , README.md
                   , CHANGELOG.md
                   , test/lua/*.lua
tested-with:         GHC == 8.0.2
                   , GHC == 8.2.2
                   , GHC == 8.4.4
                   , GHC == 8.6.5
                   , GHC == 8.8.4
                   , GHC == 8.10.2

source-repository head
  type:                git
  location:            https://github.com/hslua/hslua.git


flag system-lua
  default:             False
  manual:              True
  description:         Use the system-wide Lua instead of the bundled copy.

flag apicheck
  default:             False
  manual:              True
  description:         Compile Lua with -DLUA_USE_APICHECK.

flag lua_32bits
  default:             False
  manual:              True
  description:         Compile Lua with -DLUA_32BITS

flag allow-unsafe-gc
  default:             True
  manual:              True
  description:         Allow optimizations which make Lua's garbage collection
                       potentially unsafe; haskell finalizers must be handled
                       with extreme care.

flag export-dynamic
  default:             True
  manual:              True
  description:         Add all symbols to dynamic symbol table; disabling this
                       will make it possible to create fully static binaries,
                       but renders loading of dynamic C libraries impossible.

flag pkg-config
  default:             False
  manual:              True
  description:         Use @pkg-config@ to discover library and include paths.
                       Setting this flag implies `system-lua`.

flag hardcode-reg-keys
  default:             False
  manual:              True

  description:         Don't use CAPI to determine the names of certain registry
                       key names but Use hard coded values for instead. This
                       flag is required when compiling against Lua 5.3.3 or
                       earlier, as those do not expose the necessary information
                       in the @lauxlib.h@ header file.

library
  exposed-modules:     Foreign.Lua
                     , Foreign.Lua.Call
                     , Foreign.Lua.Core
                     , Foreign.Lua.Core.Constants
                     , Foreign.Lua.Core.Error
                     , Foreign.Lua.Core.RawBindings
                     , Foreign.Lua.Core.Types
                     , Foreign.Lua.FunctionCalling
                     , Foreign.Lua.Module
                     , Foreign.Lua.Peek
                     , Foreign.Lua.Push
                     , Foreign.Lua.Raw.Auxiliary
                     , Foreign.Lua.Raw.Call
                     , Foreign.Lua.Raw.Constants
                     , Foreign.Lua.Raw.Error
                     , Foreign.Lua.Raw.Functions
                     , Foreign.Lua.Raw.Types
                     , Foreign.Lua.Raw.Userdata
                     , Foreign.Lua.Types
                     , Foreign.Lua.Types.Peekable
                     , Foreign.Lua.Types.Pushable
                     , Foreign.Lua.Userdata
                     , Foreign.Lua.Utf8
                     , Foreign.Lua.Util
  other-modules:       Foreign.Lua.Core.Auxiliary
                     , Foreign.Lua.Core.Functions
  build-depends:       base                 >= 4.8    && < 5
                     , bytestring           >= 0.10.2 && < 0.11
                     , containers           >= 0.5    && < 0.7
                     , exceptions           >= 0.8    && < 0.11
                     , mtl                  >= 2.2    && < 2.3
                     , text                 >= 1.0    && < 1.3
  hs-source-dirs:      src
  default-language:    Haskell2010
  ghc-options:         -Wall
                       -Wincomplete-record-updates
                       -Wnoncanonical-monad-instances
                       -Wredundant-constraints
  if impl(ghc >= 8.2)
    ghc-options:         -Wcpp-undef
                         -Werror=missing-home-modules
  if impl(ghc >= 8.4)
    ghc-options:         -Widentities
                         -Wincomplete-uni-patterns
                         -Wpartial-fields
                         -fhide-source-paths
  default-extensions:  CApiFFI
                     , ForeignFunctionInterface
                     , LambdaCase
  other-extensions:    CPP
                     , DeriveDataTypeable
                     , DeriveFunctor
                     , FlexibleContexts
                     , FlexibleInstances
                     , ScopedTypeVariables
  c-sources:           cbits/hslua/hsludata.c
                     , cbits/hslua/hslcall.c
                     , cbits/hslua/hslua.c
  include-dirs:        cbits/hslua
  if flag(system-lua) || flag(pkg-config)
    if flag(pkg-config)
      pkgconfig-depends: lua5.3
    else
      extra-libraries:   lua
      includes:          lua.h
  else
    include-dirs:        cbits/lua-5.3.6
    c-sources:           cbits/lua-5.3.6/lapi.c
                       , cbits/lua-5.3.6/lcode.c
                       , cbits/lua-5.3.6/lctype.c
                       , cbits/lua-5.3.6/ldebug.c
                       , cbits/lua-5.3.6/ldo.c
                       , cbits/lua-5.3.6/ldump.c
                       , cbits/lua-5.3.6/lfunc.c
                       , cbits/lua-5.3.6/lgc.c
                       , cbits/lua-5.3.6/llex.c
                       , cbits/lua-5.3.6/lmem.c
                       , cbits/lua-5.3.6/lobject.c
                       , cbits/lua-5.3.6/lopcodes.c
                       , cbits/lua-5.3.6/lparser.c
                       , cbits/lua-5.3.6/lstate.c
                       , cbits/lua-5.3.6/lstring.c
                       , cbits/lua-5.3.6/ltable.c
                       , cbits/lua-5.3.6/ltm.c
                       , cbits/lua-5.3.6/lundump.c
                       , cbits/lua-5.3.6/lvm.c
                       , cbits/lua-5.3.6/lzio.c

                       , cbits/lua-5.3.6/lauxlib.c
                       , cbits/lua-5.3.6/lbaselib.c
                       , cbits/lua-5.3.6/lbitlib.c
                       , cbits/lua-5.3.6/lcorolib.c
                       , cbits/lua-5.3.6/ldblib.c
                       , cbits/lua-5.3.6/liolib.c
                       , cbits/lua-5.3.6/lmathlib.c
                       , cbits/lua-5.3.6/lstrlib.c
                       , cbits/lua-5.3.6/loslib.c
                       , cbits/lua-5.3.6/ltablib.c
                       , cbits/lua-5.3.6/lutf8lib.c
                       , cbits/lua-5.3.6/loadlib.c
                       , cbits/lua-5.3.6/linit.c

  if os(linux)
    cc-options:          -DLUA_USE_LINUX
    if flag(export-dynamic)
      ld-options:        -Wl,-E

  if os(darwin)
    cc-options:          -DLUA_USE_MACOSX

  if os(freebsd)
    cc-options:          -DLUA_USE_POSIX
    if flag(export-dynamic)
      ld-options:        -Wl,-E

  if flag(lua_32bits)
    cc-options:          -DLUA_32BITS

  if flag(apicheck)
    cc-options:          -DLUA_USE_APICHECK

  if flag(allow-unsafe-gc)
    cpp-options:         -DALLOW_UNSAFE_GC

  if flag(hardcode-reg-keys)
    cpp-options:         -DHARDCODE_REG_KEYS

  if !impl(ghc >= 8.0)
    build-depends:       fail                 >= 4.9    && < 5
                       , semigroups           >= 0.18   && < 0.20

  if impl(ghc < 8.8)
    build-depends:       base-compat          >= 0.10
    hs-source-dirs:      prelude
    other-modules:       Prelude

test-suite test-hslua
  type:                exitcode-stdio-1.0
  main-is:             test-hslua.hs
  hs-source-dirs:      test
  ghc-options:         -Wall -threaded
                       -Wincomplete-record-updates
                       -Wnoncanonical-monad-instances
  if impl(ghc >= 8.2)
    ghc-options:         -Wcpp-undef
  if impl(ghc >= 8.4)
    ghc-options:         -Wincomplete-uni-patterns
                         -Widentities
                         -Werror=missing-home-modules
                         -fhide-source-paths
  default-language:    Haskell2010
  other-modules:       Foreign.LuaTests
                     , Foreign.Lua.CallTests
                     , Foreign.Lua.CoreTests
                     , Foreign.Lua.Core.AuxiliaryTests
                     , Foreign.Lua.Core.ErrorTests
                     , Foreign.Lua.FunctionCallingTests
                     , Foreign.Lua.ModuleTests
                     , Foreign.Lua.PeekTests
                     , Foreign.Lua.PushTests
                     , Foreign.Lua.TypesTests
                     , Foreign.Lua.Types.PeekableTests
                     , Foreign.Lua.Types.PushableTests
                     , Foreign.Lua.UserdataTests
                     , Foreign.Lua.UtilTests
                     , Test.HsLua.Arbitrary
                     , Test.HsLua.Util
  build-depends:       base                 >= 4.8    && < 5
                     , bytestring           >= 0.10.2 && < 0.11
                     , containers           >= 0.5.9  && < 0.7
                     , exceptions           >= 0.8    && < 0.11
                     , mtl                  >= 2.2    && < 2.3
                     , text                 >= 1.0    && < 1.3
                     -- for testing
                     , hslua
                     , QuickCheck           >= 2.7
                     , quickcheck-instances >= 0.3
                     , tasty                >= 0.11
                     , tasty-hunit          >= 0.9
                     , tasty-quickcheck     >= 0.8

  if impl(ghc < 8.0)
    build-depends:       fail                 >= 4.9    && < 5
                       , semigroups           >= 0.18   && < 0.20
  if impl(ghc < 8.8)
    build-depends:       base-compat          >= 0.10
    hs-source-dirs:      prelude
    other-modules:       Prelude