Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HsOpenSSL.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Flag macports-openssl
Default:
False

Custom-setup
setup-depends: Cabal >=1.12 && <2.1,
base >=4.4 && <5

Library
Build-Depends:
base >= 4.4 && < 5,
Expand Down
15 changes: 9 additions & 6 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TupleSections #-}

#ifndef MIN_VERSION_Cabal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case this doesn't seem obvious: the trick here is MIN_VERSION_Cabal is defined and available to custom Setup.hs scripts if either GHC >= 8.0 or cabal-install >= 1.24 is used. So if it isn't defined, it's very likely we don't have Cabal >= 2.0.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Am I right that "Custom-setup" stanza is only supported in cabal-install >= 1.24 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. Older versions of Cabal don't know what that section is and will issue a warning and ignore it.

#define MIN_VERSION_Cabal(x,y,z) 0
#endif

import Distribution.Simple
import Distribution.Simple.Setup (ConfigFlags(..), toFlag)
import Distribution.Simple.LocalBuildInfo (localPkgDescr)

#if __GLASGOW_HASKELL__ >= 802
#if MIN_VERSION_Cabal(2,0,0)
import Distribution.PackageDescription (FlagName(..), mkFlagName)
#else
import Distribution.PackageDescription (FlagName(..))
Expand All @@ -18,6 +22,10 @@ import System.IO.Error (isUserError)
import Control.Monad (forM)
import Data.List

#if !(MIN_VERSION_Cabal(2,0,0))
mkFlagName = FlagName
#endif

-- On macOS we're checking whether OpenSSL library is avaiable
-- and if not, we're trying to find Homebrew or MacPorts OpenSSL installations.
--
Expand Down Expand Up @@ -97,8 +105,3 @@ tryConfig descr flags = do

where ue e | isUserError e = Just e
| otherwise = Nothing

#if __GLASGOW_HASKELL__ < 802
mkFlagName = FlagName
#endif