name:                nanovg
version:             0.8.1.0
synopsis:            Haskell bindings for nanovg
description:         Raw bindings to the OpenGL vector graphics library NanoVG
homepage:            https://github.com/cocreature/nanovg-hs
license:             ISC
license-file:        LICENSE
author:              Moritz Kiefer
maintainer:          moritz.kiefer@purelyfunctional.org
copyright:           2016 Moritz Kiefer
category:            Graphics
build-type:          Simple
extra-source-files:
  README.md
  CHANGELOG.md
cabal-version:       >=1.10
tested-with:         GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.2

source-repository head
  type:     git
  location: https://github.com/cocreature/nanovg-hs

flag examples
  description: Build examples
  default:     False
  manual:      True

flag gles3
  description: Build for GLES3. This deactivates GL3 support.
  default:     False
  manual:      True

flag gl2
  description: Build for GL2. This deactivates GL3 support.
  default:     False
  manual:      True

flag stb_truetype
  description: Use stb_truetype. By default uses freetype.
  default:     False
  manual:      True

library
  exposed-modules:
                   NanoVG
                   NanoVG.Internal
                   NanoVG.Internal.Color
                   NanoVG.Internal.CreateContext
                   NanoVG.Internal.Context
                   NanoVG.Internal.FFIHelpers
                   NanoVG.Internal.FixedVector
                   NanoVG.Internal.GlobalComposite
                   NanoVG.Internal.Image
                   NanoVG.Internal.Paint
                   NanoVG.Internal.Path
                   NanoVG.Internal.Scissor
                   NanoVG.Internal.State
                   NanoVG.Internal.Style
                   NanoVG.Internal.Text
                   NanoVG.Internal.Transformation
                   NanoVG.Internal.Types
  if flag(gles3)
    exposed-modules:
                     NanoVG.Internal.GLES3
  else
    if flag(gl2)
      exposed-modules:
                       NanoVG.Internal.GL2
    else
      exposed-modules:
                       NanoVG.Internal.GL3
  build-depends:       base >= 4.8 && <5.0
                     , bytestring >= 0.10 && < 0.12
                     , containers >= 0.5 && < 0.7
                     , text >= 1.2 && < 1.3
                     , vector >= 0.11 && < 0.13
  hs-source-dirs:      src
  default-language:    Haskell2010
  include-dirs:        nanovg/src
                       cbits
  install-includes:    fontstash.h
                       nanovg.h
                       nanovg_gl.h
                       nanovg_wrapper.h
                       stb_image.h
                       stb_truetype.h
  c-sources:           nanovg/src/nanovg.c
                       cbits/nanovg_wrapper.c
                       cbits/nanovg_gl.c
  if flag(stb_truetype)
    cc-options:          -DNDEBUG
  else
    cc-options:          -DNDEBUG -DFONS_USE_FREETYPE
  ghc-options:         -Wall
  if os(windows)
    extra-libraries:   freeglut, glew32
    if flag(stb_truetype)
      pkgconfig-depends: glew
    else
      pkgconfig-depends: glew, freetype2
  else
    if os(osx)
      frameworks:        OpenGL
      cc-options:        -Ddarwin_HOST_OS
      extra-libraries:   GLEW
      if flag(stb_truetype)
        pkgconfig-depends: glew
      else
        pkgconfig-depends: glew, freetype2
    else
      extra-libraries:   GLU, GL, m, GLEW, X11
      if flag(stb_truetype)
        pkgconfig-depends: glew
      else
        pkgconfig-depends: glew, freetype2
  if flag(gles3)
    cpp-options:       -DGLES_3
    cc-options:        -DGLES_3
  if flag(gl2)
    cpp-options:       -DGL_2
    cc-options:        -DGL_2
  build-tools:         c2hs

executable example00
  hs-source-dirs:     example
  main-is:            Example.hs
  if flag(examples)
    build-depends:      base
                      , containers
                      , gl
                      , GLFW-b
                      , monad-loops
                      , nanovg
                      , text
                      , transformers
                      , vector
  else
    buildable:        False
  default-language:   Haskell2010
  c-sources:          cbits/glew.c
  if os(osx)
    cc-options:          -Ddarwin_HOST_OS

test-suite nanovg-test
  type:               exitcode-stdio-1.0
  hs-source-dirs:     test
  other-modules:      NanoVGSpec
                      Contexts
  main-is:            Spec.hs
  build-depends:      base
                    , containers
                    , hspec
                    , inline-c
                    , nanovg
                    , QuickCheck
  default-language:   Haskell2010
  c-sources:          test/NanoVGSpec.c