diff --git a/snap-server.cabal b/snap-server.cabal index fe17d499..1a1ef812 100644 --- a/snap-server.cabal +++ b/snap-server.cabal @@ -72,6 +72,11 @@ Flag libev Description: Use libev? Default: False +Flag portable + Description: Compile in cross-platform mode. No platform-specific code or + optimizations such as C routines will be used. + Default: False + Library hs-source-dirs: dist/build/autogen, src @@ -111,7 +116,9 @@ Library unix-compat, vector >= 0.6 && <0.7 - if !os(windows) + if flag(portable) || os(windows) + cpp-options: -DPORTABLE + else build-depends: unix if flag(libev) @@ -130,9 +137,6 @@ Library if os(darwin) cpp-options: -DOSX - if os(windows) - cpp-options: -DWIN32 - ghc-prof-options: -prof -auto-all if impl(ghc >= 6.12.0) diff --git a/src/Snap/Internal/Http/Server/Date.hs b/src/Snap/Internal/Http/Server/Date.hs index 24612657..6d9b371b 100644 --- a/src/Snap/Internal/Http/Server/Date.hs +++ b/src/Snap/Internal/Http/Server/Date.hs @@ -14,7 +14,7 @@ import Data.IORef import Foreign.C.Types import System.IO.Unsafe -#ifndef WIN32 +#ifndef PORTABLE import System.Posix.Time #else import Data.Time.Clock.POSIX @@ -60,7 +60,7 @@ dateState = unsafePerformIO $ do return d -#ifdef WIN32 +#ifdef PORTABLE epochTime :: IO CTime epochTime = do t <- getPOSIXTime diff --git a/test/snap-server-testsuite.cabal b/test/snap-server-testsuite.cabal index b94928cf..ed5241eb 100644 --- a/test/snap-server-testsuite.cabal +++ b/test/snap-server-testsuite.cabal @@ -7,6 +7,11 @@ Flag libev Description: Use libev? Default: False +Flag portable + Description: Compile in cross-platform mode. No platform-specific code or + optimizations such as C routines will be used. + Default: False + Executable testsuite hs-source-dirs: ../src suite main-is: TestSuite.hs @@ -55,8 +60,8 @@ Executable testsuite other-modules: Snap.Internal.Http.Server.SimpleBackend - if os(windows) - cpp-options: -DWIN32 + if flag(portable) || os(windows) + cpp-options: -DPORTABLE ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded -fno-warn-unused-do-bind @@ -114,8 +119,8 @@ Executable pongserver if os(darwin) cpp-options: -DOSX - if os(windows) - cpp-options: -DWIN32 + if flag(portable) || os(windows) + cpp-options: -DPORTABLE ghc-options: -Wall -O2 -fwarn-tabs -funbox-strict-fields -threaded -fno-warn-unused-do-bind