name:                   hslua
version:                0.4.1
stability:              beta
cabal-version:          >= 1.8
license:                MIT
build-type:             Simple
license-File:           COPYRIGHT
copyright:              Gracjan Polak 2007-2012, Ömer Sinan Ağacan 2012-2015
author:                 Gracjan Polak, Ömer Sinan Ağacan
maintainer:             omeragacan@gmail.com
synopsis:               A Lua language interpreter embedding in Haskell
description:            The Scripting.Lua module is a wrapper of Lua language interpreter
                        as described in [lua.org](http://www.lua.org/).
                        .
                        This package contains full Lua interpreter version 5.1.5.
                        If you want to link it with system-wide Lua installation, use @system-lua@ flag.
                        .
                        [Example programs](https://github.com/osa1/hslua/tree/master/examples)
category:               Scripting
extra-source-files:     lua-5.1.5/*.h
                        README.md
                        CHANGELOG.md
                        COPYRIGHT
                        examples/callbacks/callbacks.lua
                        examples/haskellfun/haskellfun.lua
                        examples/err_prop/err_prop.lua

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

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

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

flag luajit
  description:          Link with LuaJIT (should be used with -fsystem-lua)
  default:              False

library
  build-depends:        base == 4.*, bytestring >= 0.10.2.0 && < 0.11
  exposed-modules:      Scripting.Lua, Scripting.Lua.Raw
  hs-source-dirs:       src
  ghc-options:          -Wall -O2
  if flag(system-lua)
    if flag(luajit)
      Extra-libraries:  luajit-5.1
    else
      Extra-libraries:  lua
    includes:           lua.h
  else
    c-sources:          lua-5.1.5/lobject.c, lua-5.1.5/ltm.c, lua-5.1.5/ldblib.c,
                        lua-5.1.5/ldo.c, lua-5.1.5/lvm.c, lua-5.1.5/ltable.c,
                        lua-5.1.5/lstrlib.c, lua-5.1.5/lfunc.c,
                        lua-5.1.5/lstate.c, lua-5.1.5/lmathlib.c, lua-5.1.5/lmem.c,
                        lua-5.1.5/ltablib.c, lua-5.1.5/lzio.c, lua-5.1.5/lstring.c,
                        lua-5.1.5/ldump.c, lua-5.1.5/linit.c, lua-5.1.5/lbaselib.c,
                        lua-5.1.5/lauxlib.c, lua-5.1.5/lopcodes.c, lua-5.1.5/lgc.c,
                        lua-5.1.5/lcode.c, lua-5.1.5/loadlib.c, lua-5.1.5/lapi.c,
                        lua-5.1.5/lundump.c, lua-5.1.5/loslib.c, lua-5.1.5/lparser.c,
                        lua-5.1.5/ldebug.c, lua-5.1.5/liolib.c,
                        lua-5.1.5/llex.c

    include-dirs:       lua-5.1.5

  if os(linux)
    cc-options:         "-DLUA_USE_LINUX"

  if os(darwin)
    cc-options:         "-DLUA_USE_MACOSX"

  if os(freebsd)
    cc-options:         "-DLUA_USE_POSIX"

  if os(windows)
     cc-options:        "-D__NO_ISOCEXT"

  if flag(apicheck)
    cc-Options:         "-DLUA_USE_APICHECK"

-- This is not necessary because we have a test suite now. Still keeping here as
-- a very simple test. Originally added with 799a4c2 to test if linking with
-- system-wide Lua is really working.
test-suite simple-test
  type:                 exitcode-stdio-1.0
  main-is:              simple-test.hs
  hs-source-dirs:       test
  build-depends:        base, hslua

test-suite callbacks
  type:                 exitcode-stdio-1.0
  main-is:              callbacks.hs
  hs-source-dirs:       examples/callbacks
  build-depends:        base, bytestring, hslua

test-suite haskellfun
  type:                 exitcode-stdio-1.0
  main-is:              haskellfun.hs
  hs-source-dirs:       examples/haskellfun
  build-depends:        base, bytestring, hslua

test-suite err_prop
  type:                 exitcode-stdio-1.0
  main-is:              err_prop.hs
  hs-source-dirs:       examples/err_prop
  build-depends:        base, bytestring, hslua

test-suite test
  type:                 exitcode-stdio-1.0
  main-is:              Spec.hs
  hs-source-dirs:       test
  ghc-options:          -Wall -threaded

  build-depends:
    base,
    bytestring,
    hslua,
    hspec,
    hspec-contrib,
    HUnit,
    text,
    QuickCheck >= 2.7,
    quickcheck-instances
