Skip to content

Commit 8e45feb

Browse files
committed
Small changes, include more relevant files in repo.
1 parent eb6d2d9 commit 8e45feb

File tree

8 files changed

+319
-1
lines changed

8 files changed

+319
-1
lines changed

Foreign/Matlab/Array/IMX.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
-}
77
module Foreign.Matlab.Array.IMX (
88
IMXData(..),
9+
IMXArray,
910
IMXArrayElem (imxConstr, imxArray),
1011

1112
-- * Interface with "Foreign.Matlab.Array"

matlab.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: matlab
2-
Version: 0.1
2+
Version: 0.1.0.1
33
Cabal-Version: >= 1.6
44
Author: Dylan Simon
55
Maintainer: [email protected]

src/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MCC=/usr/local/MATLAB/R2013a/bin/mcc
2+
MCCFLAGS=
3+
4+
libhsmatlab.so: hsmatlab.m hsmatlab.c
5+
rm -f $@ $@.post
6+
# just create the wrapper
7+
$(MCC) $(MCCFLAGS) -W lib:$(basename $@) -c hsmatlab.m
8+
# matlab 7.6 sticks the ctf at the end of the library, but has a bug when not creating libraries that it tries anyway, so we check that here
9+
-[ -f $@ ] && mv $@ $@.post
10+
# stick our own call into the wrapper
11+
cat hsmatlab.c >> $(basename $@).c
12+
# build the library
13+
$(MCC) $(MCCFLAGS) -W lib:$(basename $@) -T link:lib $(basename $@).c
14+
# 7.6: do what mcc tried to do before
15+
-[ -f $@.post ] && cat $(basename $@).ctf >> $@
16+
17+
clean:
18+
rm -rf libhsmatlab_mcr
19+
rm -f libhsmatlab* mccExcludedFiles.log readme.txt

src/libhsmatlab.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* MATLAB Compiler: 4.18.1 (R2013a)
3+
* Date: Mon Aug 4 14:07:22 2014
4+
* Arguments: "-B" "macro_default" "-W" "lib:libhsmatlab" "-T" "link:lib"
5+
* "libhsmatlab.c"
6+
*/
7+
8+
#include <stdio.h>
9+
#define EXPORTING_libhsmatlab 1
10+
#include "libhsmatlab.h"
11+
12+
static HMCRINSTANCE _mcr_inst = NULL;
13+
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
static int mclDefaultPrintHandler(const char *s)
20+
{
21+
return mclWrite(1 /* stdout */, s, sizeof(char)*strlen(s));
22+
}
23+
24+
#ifdef __cplusplus
25+
} /* End extern "C" block */
26+
#endif
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
static int mclDefaultErrorHandler(const char *s)
33+
{
34+
int written = 0;
35+
size_t len = 0;
36+
len = strlen(s);
37+
written = mclWrite(2 /* stderr */, s, sizeof(char)*len);
38+
if (len > 0 && s[ len-1 ] != '\n')
39+
written += mclWrite(2 /* stderr */, "\n", sizeof(char));
40+
return written;
41+
}
42+
43+
#ifdef __cplusplus
44+
} /* End extern "C" block */
45+
#endif
46+
47+
/* This symbol is defined in shared libraries. Define it here
48+
* (to nothing) in case this isn't a shared library.
49+
*/
50+
#ifndef LIB_libhsmatlab_C_API
51+
#define LIB_libhsmatlab_C_API /* No special import/export declaration */
52+
#endif
53+
54+
LIB_libhsmatlab_C_API
55+
bool MW_CALL_CONV libhsmatlabInitializeWithHandlers(
56+
mclOutputHandlerFcn error_handler,
57+
mclOutputHandlerFcn print_handler)
58+
{
59+
int bResult = 0;
60+
if (_mcr_inst != NULL)
61+
return true;
62+
if (!mclmcrInitialize())
63+
return false;
64+
{
65+
mclCtfStream ctfStream =
66+
mclGetEmbeddedCtfStream((void *)(libhsmatlabInitializeWithHandlers));
67+
if (ctfStream) {
68+
bResult = mclInitializeComponentInstanceEmbedded( &_mcr_inst,
69+
error_handler,
70+
print_handler,
71+
ctfStream);
72+
mclDestroyStream(ctfStream);
73+
} else {
74+
bResult = 0;
75+
}
76+
}
77+
if (!bResult)
78+
return false;
79+
return true;
80+
}
81+
82+
LIB_libhsmatlab_C_API
83+
bool MW_CALL_CONV libhsmatlabInitialize(void)
84+
{
85+
return libhsmatlabInitializeWithHandlers(mclDefaultErrorHandler,
86+
mclDefaultPrintHandler);
87+
}
88+
89+
LIB_libhsmatlab_C_API
90+
void MW_CALL_CONV libhsmatlabTerminate(void)
91+
{
92+
if (_mcr_inst != NULL)
93+
mclTerminateInstance(&_mcr_inst);
94+
}
95+
96+
LIB_libhsmatlab_C_API
97+
void MW_CALL_CONV libhsmatlabPrintStackTrace(void)
98+
{
99+
char** stackTrace;
100+
int stackDepth = mclGetStackTrace(&stackTrace);
101+
int i;
102+
for(i=0; i<stackDepth; i++)
103+
{
104+
mclWrite(2 /* stderr */, stackTrace[i], sizeof(char)*strlen(stackTrace[i]));
105+
mclWrite(2 /* stderr */, "\n", sizeof(char)*strlen("\n"));
106+
}
107+
mclFreeStackTrace(&stackTrace, stackDepth);
108+
}
109+
110+

src/libhsmatlab.exports

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
libhsmatlabInitialize
2+
libhsmatlabInitializeWithHandlers
3+
libhsmatlabTerminate
4+
libhsmatlabPrintStackTrace
5+

src/libhsmatlab.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* MATLAB Compiler: 4.18.1 (R2013a)
3+
* Date: Mon Aug 4 14:07:22 2014
4+
* Arguments: "-B" "macro_default" "-W" "lib:libhsmatlab" "-T" "link:lib"
5+
* "libhsmatlab.c"
6+
*/
7+
8+
#ifndef __libhsmatlab_h
9+
#define __libhsmatlab_h 1
10+
11+
#if defined(__cplusplus) && !defined(mclmcrrt_h) && defined(__linux__)
12+
# pragma implementation "mclmcrrt.h"
13+
#endif
14+
#include "mclmcrrt.h"
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
#if defined(__SUNPRO_CC)
20+
/* Solaris shared libraries use __global, rather than mapfiles
21+
* to define the API exported from a shared library. __global is
22+
* only necessary when building the library -- files including
23+
* this header file to use the library do not need the __global
24+
* declaration; hence the EXPORTING_<library> logic.
25+
*/
26+
27+
#ifdef EXPORTING_libhsmatlab
28+
#define PUBLIC_libhsmatlab_C_API __global
29+
#else
30+
#define PUBLIC_libhsmatlab_C_API /* No import statement needed. */
31+
#endif
32+
33+
#define LIB_libhsmatlab_C_API PUBLIC_libhsmatlab_C_API
34+
35+
#elif defined(_HPUX_SOURCE)
36+
37+
#ifdef EXPORTING_libhsmatlab
38+
#define PUBLIC_libhsmatlab_C_API __declspec(dllexport)
39+
#else
40+
#define PUBLIC_libhsmatlab_C_API __declspec(dllimport)
41+
#endif
42+
43+
#define LIB_libhsmatlab_C_API PUBLIC_libhsmatlab_C_API
44+
45+
46+
#else
47+
48+
#define LIB_libhsmatlab_C_API
49+
50+
#endif
51+
52+
/* This symbol is defined in shared libraries. Define it here
53+
* (to nothing) in case this isn't a shared library.
54+
*/
55+
#ifndef LIB_libhsmatlab_C_API
56+
#define LIB_libhsmatlab_C_API /* No special import/export declaration */
57+
#endif
58+
59+
extern LIB_libhsmatlab_C_API
60+
bool MW_CALL_CONV libhsmatlabInitializeWithHandlers(
61+
mclOutputHandlerFcn error_handler,
62+
mclOutputHandlerFcn print_handler);
63+
64+
extern LIB_libhsmatlab_C_API
65+
bool MW_CALL_CONV libhsmatlabInitialize(void);
66+
67+
extern LIB_libhsmatlab_C_API
68+
void MW_CALL_CONV libhsmatlabTerminate(void);
69+
70+
71+
72+
extern LIB_libhsmatlab_C_API
73+
void MW_CALL_CONV libhsmatlabPrintStackTrace(void);
74+
75+
76+
77+
#ifdef __cplusplus
78+
}
79+
#endif
80+
#endif

src/readme.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
MATLAB Compiler
2+
3+
1. Prerequisites for Deployment
4+
5+
. Verify the MATLAB Compiler Runtime (MCR) is installed and ensure you
6+
have installed version 8.1 (R2013a).
7+
8+
. If the MCR is not installed, do the following:
9+
(1) enter
10+
11+
>>mcrinstaller
12+
13+
at MATLAB prompt. The MCRINSTALLER command displays the
14+
location of the MCR Installer.
15+
16+
(2) run the MCR Installer.
17+
18+
Or download the Linux 64-bit version of the MCR for R2013a
19+
from the MathWorks Web site by navigating to
20+
21+
http://www.mathworks.com/products/compiler/mcr/index.html
22+
23+
24+
For more information about the MCR and the MCR Installer, see
25+
Distribution to End Users in the MATLAB Compiler documentation
26+
in the MathWorks Documentation Center.
27+
28+
29+
2. Files to Deploy and Package
30+
31+
Files to package for Shared Libraries
32+
=====================================
33+
-libhsmatlab.so
34+
-libhsmatlab.h
35+
-MCRInstaller.zip
36+
-if end users are unable to download the MCR using the above
37+
link, include it when building your component by clicking
38+
the "Add MCR" link in the Deployment Tool
39+
-This readme file
40+
41+
3. Definitions
42+
43+
For information on deployment terminology, go to
44+
http://www.mathworks.com/help. Select MATLAB Compiler >
45+
Getting Started > About Application Deployment >
46+
Application Deployment Terms in the MathWorks Documentation
47+
Center.
48+
49+
50+
4. Appendix
51+
52+
A. Linux x86-64 systems:
53+
On the target machine, add the MCR directory to the environment variable
54+
LD_LIBRARY_PATH by issuing the following commands:
55+
56+
NOTE: <mcr_root> is the directory where MCR is installed
57+
on the target machine.
58+
59+
setenv LD_LIBRARY_PATH
60+
$LD_LIBRARY_PATH:
61+
<mcr_root>/v81/runtime/glnxa64:
62+
<mcr_root>/v81/bin/glnxa64:
63+
<mcr_root>/v81/sys/os/glnxa64:
64+
<mcr_root>/v81/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:
65+
<mcr_root>/v81/sys/java/jre/glnxa64/jre/lib/amd64/server:
66+
<mcr_root>/v81/sys/java/jre/glnxa64/jre/lib/amd64
67+
setenv XAPPLRESDIR <mcr_root>/v81/X11/app-defaults
68+
69+
For more detail information about setting MCR paths, see Distribution to End Users in
70+
the MATLAB Compiler documentation in the MathWorks Documentation Center.
71+
72+
73+
74+
NOTE: To make these changes persistent after logout on Linux
75+
or Mac machines, modify the .cshrc file to include this
76+
setenv command.
77+
NOTE: The environment variable syntax utilizes forward
78+
slashes (/), delimited by colons (:).
79+
80+
81+

test/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MCC=/usr/local/MATLAB/R2013a/bin/mcc
2+
MCCFLAGS=
3+
4+
TESTS=engine runtime generic
5+
default: $(TESTS)
6+
@echo "All tests should have produced:"
7+
@echo " ready"
8+
@echo " MXClassDouble"
9+
@echo " -1.0"
10+
@for t in $^ ; do echo Running $$t... ; ./$$t ; done
11+
12+
%: %.hs
13+
ghc -I.. --make $@
14+
15+
lib%.so: %.m
16+
$(MCC) $(MCCFLAGS) -W lib:$(basename $@) -T link:lib $^
17+
18+
runtime: libmtest.so
19+
20+
clean:
21+
rm -rf libmtest_mcr
22+
rm -f *.o *.hi $(TESTS) libmtest* mccExcludedFiles.log readme.txt

0 commit comments

Comments
 (0)