on master help sign in
Merge pull request #3171 from neduard/build_on_openbsd
d3040cfNiklas Larsson
Setup.hs+2−1
@@ -38,7 +38,8 @@ idrisCmd local = ".." </> ".." </> buildDir local </> "idris" </> "idris"
38-- Make Commands
38-- Make Commands
39
39
40-- use GNU make on FreeBSD
40-- use GNU make on FreeBSD
41−#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)
41+#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)\
42+ || defined(openbsd_HOST_OS) || defined(netbsd_HOST_OS)
42mymake = "gmake"
43mymake = "gmake"
43#else
44#else
44mymake = "make"
45mymake = "make"
idris.cabal−5
@@ -1108,19 +1108,14 @@ Library
1108 ghc-prof-options: -auto-all -caf-all
1108 ghc-prof-options: -auto-all -caf-all
1109
1109
1110 if os(linux)
1110 if os(linux)
1111− cpp-options: -DLINUX
1112 build-depends: unix < 2.8
1111 build-depends: unix < 2.8
1113 if os(freebsd)
1112 if os(freebsd)
1114− cpp-options: -DFREEBSD
1115 build-depends: unix < 2.8
1113 build-depends: unix < 2.8
1116 if os(dragonfly)
1114 if os(dragonfly)
1117− cpp-options: -DDRAGONFLY
1118 build-depends: unix < 2.8
1115 build-depends: unix < 2.8
1119 if os(darwin)
1116 if os(darwin)
1120− cpp-options: -DMACOSX
1121 build-depends: unix < 2.8
1117 build-depends: unix < 2.8
1122 if os(windows)
1118 if os(windows)
1123− cpp-options: -DWINDOWS
1124 build-depends: Win32 < 2.4
1119 build-depends: Win32 < 2.4
1125 if flag(FFI)
1120 if flag(FFI)
1126 build-depends: libffi < 0.2
1121 build-depends: libffi < 0.2
src/IRTS/System.hs+2−1
@@ -29,7 +29,8 @@ getEnvFlags = maybe [] (splitOn " ") <$> lookupEnv "IDRIS_CFLAGS"
29getTargetDir :: IO String
29getTargetDir :: IO String
30getTargetDir = overrideDataDirWith "TARGET"
30getTargetDir = overrideDataDirWith "TARGET"
31
31
32−#if defined(FREEBSD) || defined(DRAGONFLY)
32+#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)\
33+ || defined(openbsd_HOST_OS) || defined(netbsd_HOST_OS)
33extraLib = ["-L/usr/local/lib"]
34extraLib = ["-L/usr/local/lib"]
34extraInclude = ["-I/usr/local/include"]
35extraInclude = ["-I/usr/local/include"]
35#else
36#else
src/Util/DynamicLinker.hs+7−9
@@ -7,7 +7,7 @@ module Util.DynamicLinker (ForeignFun(..), DynamicLib(..), tryLoadLib, tryLoadFn
7import Foreign.LibFFI
7import Foreign.LibFFI
8import Foreign.Ptr (Ptr(), nullPtr, FunPtr, nullFunPtr, castPtrToFunPtr)
8import Foreign.Ptr (Ptr(), nullPtr, FunPtr, nullFunPtr, castPtrToFunPtr)
9import System.Directory
9import System.Directory
10−#ifndef WINDOWS
10+#ifndef mingw32_HOST_OS
11import System.Posix.DynamicLinker
11import System.Posix.DynamicLinker
12import System.FilePath.Posix ((</>))
12import System.FilePath.Posix ((</>))
13#else
13#else
@@ -19,16 +19,14 @@ type DL = HMODULE
19#endif
19#endif
20
20
21hostDynamicLibExt :: String
21hostDynamicLibExt :: String
22−#ifdef LINUX
22+#if defined(linux_HOST_OS) || defined(freebsd_HOST_OS) \
23+ || defined(dragonfly_HOST_OS) || defined(openbsd_HOST_OS) \
24+ || defined(netbsd_HOST_OS)
23hostDynamicLibExt = "so"
25hostDynamicLibExt = "so"
24−#elif MACOSX
26+#elif defined(darwin_HOST_OS)
25hostDynamicLibExt = "dylib"
27hostDynamicLibExt = "dylib"
26−#elif WINDOWS
28+#elif defined(mingw32_HOST_OS)
27hostDynamicLibExt = "dll"
29hostDynamicLibExt = "dll"
28−#elif FREEBSD
29−hostDynamicLibExt = "so"
30−#elif DRAGONFLY
31−hostDynamicLibExt = "so"
32#else
30#else
33hostDynamicLibExt = error $ unwords
31hostDynamicLibExt = error $ unwords
34 [ "Undefined file extension for dynamic libraries"
32 [ "Undefined file extension for dynamic libraries"
@@ -61,7 +59,7 @@ libFileName dirs lib = do let names = [lib, lib ++ "." ++ hostDynamicLibExt]
61 map ("."</>) names ++ [d </> f | d <- cwd:dirs, f <- names]
59 map ("."</>) names ++ [d </> f | d <- cwd:dirs, f <- names]
62 return $ maybe (lib ++ "." ++ hostDynamicLibExt) id found
60 return $ maybe (lib ++ "." ++ hostDynamicLibExt) id found
63
61
64−#ifndef WINDOWS
62+#ifndef mingw32_HOST_OS
65tryLoadLib :: [FilePath] -> String -> IO (Maybe DynamicLib)
63tryLoadLib :: [FilePath] -> String -> IO (Maybe DynamicLib)
66tryLoadLib dirs lib = do filename <- libFileName dirs lib
64tryLoadLib dirs lib = do filename <- libFileName dirs lib
67 handle <- dlopen filename [RTLD_NOW, RTLD_GLOBAL]
65 handle <- dlopen filename [RTLD_NOW, RTLD_GLOBAL]