cabal-version:       >= 1.10
name:                netcode-io
version:             0.0.1
synopsis:            Bindings to the low-level netcode.io library.
description:         Bindings to the low-level netcode.io library, which come
                     in two flavors: c-level bindings and a high-level
                     interface to the library.

                     For the low level interface, refer to the
                     Bindings.Netcode.IO module.

                     For the high-level interface, which is a bit closer to
                     idiomatic Haskell, refer to the Netcode.IO module.
homepage:            http://www.github.com/Mokosha/netcode-io
bug-reports:         http://www.github.com/Mokosha/netcode-io 
license:             BSD3
license-file:        LICENSE
author:              Pavel Krajcevski
maintainer:          krajcevski@gmail.com
copyright:           Pavel Krajcevski, 2020
category:            Network
build-type:          Simple
extra-source-files:  README.md
                  ,  netcode.io/netcode.h
                  ,  netcode.io/netcode.c

source-repository head
  type:      git
  location:  https://www.github.com/Mokosha/netcode-io.git

library
  ghc-options:         -Wall -fPIC
  include-dirs:        netcode.io
  c-sources:           netcode.io/netcode.c
  cc-options:          -std=c99 -DNDEBUG -DNETCODE_ENABLE_TESTS=1
  extra-libraries:     sodium

  if os(mingw32)
    -- To make life easy on windows, we encourage using static libraries where
    -- possible. That way we don't need to go around copying .dll files.
    ld-options:        -static
    extra-libraries:   ws2_32

  exposed-modules:     Bindings.Netcode.IO
                     , Netcode.IO
  other-modules:       Netcode.IO.Server
                     , Netcode.IO.Client
                     , Netcode.IO.Address
                     , Netcode.IO.Packet
                     , Netcode.IO.Callbacks
  -- other-extensions:
  build-tools:         hsc2hs
  build-depends:       base >= 4.12 && < 5
                     , bindings-DSL
  default-language:    Haskell2010

flag examples
  description: If true, build the examples
  default:     False

executable netcode-io-c-unit-tests
  default-language:    Haskell2010
  main-is:             RunCUnitTests.hs
  hs-source-dirs:      examples
  ghc-options:         -Wall -static -fPIC
  build-depends:       base > 4
                     , netcode-io

  if flag(examples)
    buildable:         True
  else
    buildable:         False

executable netcode-io-client
  default-language:    Haskell2010
  main-is:             Client.hs
  hs-source-dirs:      examples
  ghc-options:         -Wall -static -fPIC
  build-depends:       base > 4
                     , netcode-io

  if flag(examples)
    buildable:         True
  else
    buildable:         False

executable netcode-io-server
  default-language:    Haskell2010
  main-is:             Server.hs
  hs-source-dirs:      examples
  ghc-options:         -Wall -static -fPIC
  build-depends:       base > 4
                     , netcode-io

  if flag(examples)
    buildable:         True
  else
    buildable:         False

executable netcode-io-clientserver
  default-language:    Haskell2010
  main-is:             ClientServer.hs
  hs-source-dirs:      examples
  ghc-options:         -Wall -static -fPIC
  build-depends:       base > 4
                     , netcode-io

  if flag(examples)
    buildable:         True
  else
    buildable:         False

executable netcode-io-soak
  default-language:    Haskell2010
  main-is:             Soak.hs
  hs-source-dirs:      examples
  ghc-options:         -Wall -static -fPIC
  build-depends:       base > 4
                     , netcode-io

  if flag(examples)
    buildable:         True
  else
    buildable:         False