Skip to content

Commit

Permalink
make math kernel command configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Jul 9, 2016
1 parent 98b7ce9 commit 5d52105
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions config/mathematica_include_paths.sh
Expand Up @@ -4,21 +4,25 @@
# LibraryLink .
# Author: Alexander Voigt

MATH_CMD=${MATH:-math}
math_cmd=math

eval `"${MATH_CMD}" -run '
Print["sysid=\"", $SystemID, "\""];
Print["topdir=\"", $TopDirectory, "\""];
Exit[]' < /dev/null | tr '\r' ' ' | tail -2`
find_math_dirs() {
eval `"${math_cmd}" -run '
Print["sysid=\"", $SystemID, "\""];
Print["topdir=\"", $TopDirectory, "\""];
Exit[]' < /dev/null | tr '\r' ' ' | tail -2`

# check whether Cygwin's dlltool can handle 64-bit DLLs
test "$sysid" = Windows-x86-64 && {
${DLLTOOL:-dlltool} --help | grep x86-64 > /dev/null || sysid=Windows
}
# check whether Cygwin's dlltool can handle 64-bit DLLs
test "$sysid" = Windows-x86-64 && {
${DLLTOOL:-dlltool} --help | grep x86-64 > /dev/null || sysid=Windows
}

topdir=`cd "$topdir" ; echo $PWD`
topdir=`cd "$topdir" ; echo $PWD`
}

get_librarylink_incpath() {
find_math_dirs

for p in \
"$topdir/SystemFiles/IncludeFiles/C" ; do
test -d "$p" && break
Expand All @@ -28,6 +32,8 @@ get_librarylink_incpath() {
}

get_mathlink_incpath() {
find_math_dirs

for p in \
"$topdir/SystemFiles/Links/MathLink/DeveloperKit/$sysid/CompilerAdditions" \
"$topdir/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions" \
Expand All @@ -40,9 +46,15 @@ get_mathlink_incpath() {

if test $# -gt 0 ; then
while test ! "x$1" = "x" ; do
case "$1" in
-*=*) optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//') ;;
*) optarg= ;;
esac

case $1 in
-I) prepend="-I" ;;
--librarylink|-l) path="${path} '${prepend}$(get_librarylink_incpath)'" ;;
--math-cmd=*) math_cmd=$optarg ;;
--mathlink|-m) path="${path} '${prepend}$(get_mathlink_incpath)'" ;;
--help|-h) usage; exit 0 ;;
*) echo "Invalid option '$1'. Try $0 --help" ; exit 1 ;;
Expand Down
2 changes: 1 addition & 1 deletion templates/module.mk.in
Expand Up @@ -253,7 +253,7 @@ $(LIB@CLASSNAME@_DEP) $(EXE@CLASSNAME@_DEP) $(ML@CLASSNAME@_DEP) $(LIB@CLASSNAME
endif

$(ML@CLASSNAME@_OBJ) $(ML@CLASSNAME@_LIB): \
CPPFLAGS += $(shell $(MATH_INC_PATHS) -I --librarylink --mathlink)
CPPFLAGS += $(shell $(MATH_INC_PATHS) --math-cmd="$(MATH)" -I --librarylink --mathlink)

$(LIB@CLASSNAME@): $(LIB@CLASSNAME@_OBJ)
$(MAKELIB) $@ $^
Expand Down

0 comments on commit 5d52105

Please sign in to comment.