on master help sign in
Merge pull request #3171 from neduard/build_on_openbsd

#3170: Add support for OpenBSD and NetBSD

commitd3040cfbdb97d3daaf5f04be808aeb2ad7331ac0 authorNiklas Larsson <metaniklas@gmail.com> dateTue 17 May 2016, 23:05 (10 years ago) parente34849f5925424
4 files changed+11−16
Setup.hs+2−1 idris.cabal−5 src/IRTS/System.hs+2−1 src/Util/DynamicLinker.hs+7−9
Setup.hs+2−1
@@ -38,7 +38,8 @@ idrisCmd local = ".." </> ".." </> buildDir local </> "idris" </> "idris"
3838-- Make Commands
3939
4040-- 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)
4243mymake = "gmake"
4344#else
4445mymake = "make"
idris.cabal−5
@@ -1108,19 +1108,14 @@ Library
11081108 ghc-prof-options: -auto-all -caf-all
11091109
11101110 if os(linux)
1111− cpp-options: -DLINUX
11121111 build-depends: unix < 2.8
11131112 if os(freebsd)
1114− cpp-options: -DFREEBSD
11151113 build-depends: unix < 2.8
11161114 if os(dragonfly)
1117− cpp-options: -DDRAGONFLY
11181115 build-depends: unix < 2.8
11191116 if os(darwin)
1120− cpp-options: -DMACOSX
11211117 build-depends: unix < 2.8
11221118 if os(windows)
1123− cpp-options: -DWINDOWS
11241119 build-depends: Win32 < 2.4
11251120 if flag(FFI)
11261121 build-depends: libffi < 0.2
src/IRTS/System.hs+2−1
@@ -29,7 +29,8 @@ getEnvFlags = maybe [] (splitOn " ") <$> lookupEnv "IDRIS_CFLAGS"
2929getTargetDir :: IO String
3030getTargetDir = overrideDataDirWith "TARGET"
3131
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)
3334extraLib = ["-L/usr/local/lib"]
3435extraInclude = ["-I/usr/local/include"]
3536#else
src/Util/DynamicLinker.hs+7−9
@@ -7,7 +7,7 @@ module Util.DynamicLinker (ForeignFun(..), DynamicLib(..), tryLoadLib, tryLoadFn
77import Foreign.LibFFI
88import Foreign.Ptr (Ptr(), nullPtr, FunPtr, nullFunPtr, castPtrToFunPtr)
99import System.Directory
10−#ifndef WINDOWS
10+#ifndef mingw32_HOST_OS
1111import System.Posix.DynamicLinker
1212import System.FilePath.Posix ((</>))
1313#else
@@ -19,16 +19,14 @@ type DL = HMODULE
1919#endif
2020
2121hostDynamicLibExt :: 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)
2325hostDynamicLibExt = "so"
24−#elif MACOSX
26+#elif defined(darwin_HOST_OS)
2527hostDynamicLibExt = "dylib"
26−#elif WINDOWS
28+#elif defined(mingw32_HOST_OS)
2729hostDynamicLibExt = "dll"
28−#elif FREEBSD
29−hostDynamicLibExt = "so"
30−#elif DRAGONFLY
31−hostDynamicLibExt = "so"
3230#else
3331hostDynamicLibExt = error $ unwords
3432 [ "Undefined file extension for dynamic libraries"
@@ -61,7 +59,7 @@ libFileName dirs lib = do let names = [lib, lib ++ "." ++ hostDynamicLibExt]
6159 map ("."</>) names ++ [d </> f | d <- cwd:dirs, f <- names]
6260 return $ maybe (lib ++ "." ++ hostDynamicLibExt) id found
6361
64−#ifndef WINDOWS
62+#ifndef mingw32_HOST_OS
6563tryLoadLib :: [FilePath] -> String -> IO (Maybe DynamicLib)
6664tryLoadLib dirs lib = do filename <- libFileName dirs lib
6765 handle <- dlopen filename [RTLD_NOW, RTLD_GLOBAL]