Skip to content

Commit 499dc54

Browse files
committed
Remove configure script and improve Windows compatability
1 parent dd02eda commit 499dc54

File tree

11 files changed

+77
-4234
lines changed

11 files changed

+77
-4234
lines changed

Foreign/Matlab/Array.hsc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,18 @@ createNumericArray :: MXClass -> Bool -> MWSize -> Ptr MWSize -> IO MXArrayPtr
271271
createNumericArray t c n s = mxCreateNumericArray n s (hs2mx t) (if c then (#const mxCOMPLEX) else (#const mxREAL))
272272

273273
#let numarray t = "\
274-
foreign import ccall unsafe mxIs%1$s :: MXArrayPtr -> IO CBool\n\
275-
instance MXArrayComponent M%1$s where\n\
276-
isMXArray a = boolC =.< withMXArray a mxIs%1$s\n\
277-
createMXArray s = withNDims s (uncurry $ createNumericArray (mxClassOf (undefined :: M%1$s)) False) >>= mkMXArray\n\
274+
foreign import ccall unsafe mxIs%s :: MXArrayPtr -> IO CBool\n\
275+
instance MXArrayComponent M%s where\n\
276+
isMXArray a = boolC =.< withMXArray a mxIs%s\n\
277+
createMXArray s = withNDims s (uncurry $ createNumericArray (mxClassOf (undefined :: M%s)) False) >>= mkMXArray\n\
278278
\
279279
mxArrayGetOffset = arrayDataGet ;\
280280
mxArraySetOffset = arrayDataSet ;\
281281
mxArrayGetOffsetList = arrayDataGetList ;\
282282
mxArraySetOffsetList = arrayDataSetList\
283283
\n\
284-
instance MXArrayData MX%1$s M%1$s\
285-
", #t
286-
--"
284+
instance MXArrayData MX%s M%s\
285+
", #t, #t, #t, #t, #t, #t
287286
288287
foreign import ccall unsafe mxIsDouble :: MXArrayPtr -> IO CBool
289288
foreign import ccall unsafe mxCreateDoubleScalar :: MXDouble -> IO MXArrayPtr

Foreign/Matlab/Internal.hsc

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,20 @@ instance MType MXSingle MSingle where
136136
mx2hs = id
137137
mxClassOf _ = MXClassSingle
138138

139-
#let inttype u, n = "\
140-
type MX%2$s%1$u = %3$s%1$u\n\
141-
type M%2$s%1$u = %3$s%1$u\n\
142-
instance MType MX%2$s%1$u M%2$s%1$u where { hs2mx = id ; mx2hs = id ; mxClassOf _ = MXClass%2$s%1$u }\
143-
", n, u ? "Uint" : "Int", u ? "Word" : "Int"
144-
--"
145-
146-
#inttype 0, 8
147-
#inttype 0, 16
148-
#inttype 0, 32
149-
#inttype 0, 64
150-
#inttype 1, 8
151-
#inttype 1, 16
152-
#inttype 1, 32
153-
#inttype 1, 64
139+
#let inttype u, v, n = "\
140+
type MX%s%u = %s%u\r\n\
141+
type M%s%u = %s%u\r\n\
142+
instance MType MX%s%u M%s%u where { hs2mx = id ; mx2hs = id ; mxClassOf _ = MXClass%s%u }\
143+
", u, n, v, n, u, n, v, n, u, n, u, n, u, n
144+
145+
#inttype "Int", "Int", 8
146+
#inttype "Int", "Int", 16
147+
#inttype "Int", "Int", 32
148+
#inttype "Int", "Int", 64
149+
#inttype "Uint", "Word", 8
150+
#inttype "Uint", "Word", 16
151+
#inttype "Uint", "Word", 32
152+
#inttype "Uint", "Word", 64
154153
155154
data MXArrayType
156155
type MXArrayPtr = Ptr MXArrayType

Foreign/Matlab/Runtime.hsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Foreign.Matlab.Runtime (
1919
import Foreign hiding (unsafePerformIO)
2020
import Foreign.C.String
2121
import Foreign.C.Types
22-
import System.Posix.DynamicLinker
22+
import System.Posix.DynamicLinker (DL, RTLDFlags (RTLD_NOW), dlopen, dlclose, dlsym)
2323
import Data.List
2424
import qualified Data.Char
2525
import Distribution.Simple.BuildPaths (dllExtension)

README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You will probably need to some arguments that point Cabal to your MATLAB installation.
2+
For example,
3+
4+
cabal install --extra-lib-dirs="/usr/local/MATLAB/R2014a/bin/glnxa64/" --extra-include-dirs="/usr/local/MATLAB/R2014a/extern/include/"

Setup.hs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,13 @@ import Data.Maybe
1010
import System.Directory
1111
import System.FilePath
1212

13-
defhooks = autoconfUserHooks
13+
defhooks = simpleUserHooks
1414

15-
programs =
16-
[ simpleProgram "matlab"
17-
, (simpleProgram "mcr") { programFindLocation =
18-
\_ -> return (return Nothing) }
19-
]
15+
programs = [ simpleProgram "mcc" ]
2016

2117
runtime desc = maybe False (elem ["Foreign","Matlab","Runtime"]
2218
. map components . exposedModules) $ library desc
2319

24-
postconf args flags desc build = do
25-
confExists <- doesFileExist "configure"
26-
unless confExists $ rawSystemExit verb "autoconf" []
27-
postConf defhooks args flags{ configConfigureArgs = configConfigureArgs flags ++ confargs } desc build
28-
where
29-
verb = fromFlag $ configVerbosity flags
30-
confargs = ("--" ++ (if runtime desc then "enable" else "disable") ++ "-runtime")
31-
: map pconfarg pconf
32-
pconfarg p = "--with-" ++ programId p ++ "=" ++ programPath p
33-
-- ++ " " ++ unwords (programArgs p)
34-
pconf = mapMaybe (\p -> lookupProgram p (withPrograms build)) programs
35-
3620
build desc binfo hooks flags = do
3721
when (runtime desc) $
3822
rawSystemExit (fromFlag $ buildVerbosity flags) "make" ["-Csrc"]
@@ -50,23 +34,23 @@ install desc binfo hooks flags = do
5034
copyFileVerbose (fromFlag $ installVerbosity flags)
5135
("src" </> f)
5236
(libdir (absoluteInstallDirs desc binfo NoCopyDest) </> f))
53-
["libhsmatlab.so"{-,"libhsmatlab.ctf"-}]
37+
["libhsmatlab.so"]
5438

5539
reg desc binfo hooks flags = do
5640
pwd <- getCurrentDirectory
5741
let
5842
desc' = desc{ library = fmap lm (library desc) }
5943
lm l = l { libBuildInfo = (libBuildInfo l)
60-
{ ldOptions = ("-Wl,-rpath," ++ lib) : ldOptions (libBuildInfo l),
61-
extraLibDirs = (pwd </> "src") : extraLibDirs (libBuildInfo l) } }
44+
{ ldOptions = map ("-Wl,-rpath," ++) (lib : extraLibDirs (libBuildInfo l) )
45+
++ ldOptions (libBuildInfo l),
46+
extraLibDirs = (pwd </> "src") : extraLibDirs (libBuildInfo l) } }
6247
lib
6348
| fromFlag $ regInPlace flags = pwd </> "src"
6449
| otherwise = libdir (absoluteInstallDirs desc binfo NoCopyDest)
6550
regHook defhooks desc' binfo hooks flags
6651

6752
hooks = defhooks {
6853
hookedPrograms = programs,
69-
postConf = postconf,
7054
buildHook = build,
7155
cleanHook = clean,
7256
instHook = install,

0 commit comments

Comments
 (0)