diff options
author | Joel Andersson <j.a.e.andersson@gmail.com> | 2016-07-06 10:58:06 -0500 |
---|---|---|
committer | Joel Andersson <j.a.e.andersson@gmail.com> | 2016-07-06 19:25:51 -0500 |
commit | 7e057d2b9f8c99575ed3e5a06a7c5fa34b72a173 (patch) | |
tree | 0c549d96e0ab9ca8747fe61588560fffc6be6e33 | |
parent | c1c36cc81e27bed901b72e3c30a216c56bfa4d67 (diff) | |
download | swig-7e057d2b9f8c99575ed3e5a06a7c5fa34b72a173.tar.gz |
Issue #67 Made build system MATLAB/Octave bilingual
-rw-r--r-- | Examples/Makefile.in | 51 | ||||
-rw-r--r-- | Examples/test-suite/matlab/Makefile.in | 15 | ||||
-rw-r--r-- | configure.ac | 115 |
3 files changed, 116 insertions, 65 deletions
diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c720761e9..ca6bf47d5 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -483,20 +483,18 @@ octave_clean: rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO) ################################################################## -##### MATLAB ###### +##### MATLAB/Octave ###### ################################################################## -# Make sure these locate your Matlab installation -MATLAB = @MATLAB@ -MATLAB_OPTS = @MATLAB_OPTS@ -MATLAB_EXEC = @MATLAB_EXEC@ -MATLAB_EXT = @MATLAB_EXT@ - -#MATLAB_CXX = $(DEFS) @MATLAB_CPPFLAGS@ @MATLAB_CXXFLAGS@ -#MATLAB_DLNK = @MATLAB_LDFLAGS@ - -MATLAB_MEX = @MATLAB_MEX@ -MATLAB_SCRIPT = $(SRCDIR)$(RUNME) +MATLAB = @MATLAB@ +MATLAB_OPTS = @MATLAB_OPTS@ +MATLAB_EXEC = @MATLAB_EXEC@ +MATLAB_EXT = @MATLAB_EXT@ +MATLAB_MEX = @MATLAB_MEX@ +MATLAB_CFLAGS = @MATLAB_CFLAGS@ +MATLAB_CXXFLAGS = @MATLAB_CXXFLAGS@ +MATLAB_LDFLAGS = @MATLAB_LDFLAGS@ +MATLAB_SCRIPT = $(SRCDIR)$(RUNME) # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -504,8 +502,15 @@ MATLAB_SCRIPT = $(SRCDIR)$(RUNME) matlab: $(SRCDIR_SRCS) $(SWIG) -matlab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - $(COMPILETOOL) "$(MATLAB_MEX)" -g CFLAGS='$$CFLAGS $(CFLAGS)' $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) \ - $(INCLUDES) $(LIBS) -output $(TARGET)MEX +ifdef MATLAB_MEX + $(COMPILETOOL) "$(MATLAB_MEX)" -g CFLAGS='$$CFLAGS $(CFLAGS)' $(ISRCS) $(SRCDIR_SRCS) \ + $(SRCDIR_CSRCS) $(INCLUDES) $(LIBS) -output $(TARGET)MEX +else + $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) \ + $(SRCDIR_CSRCS) $(MATLAB_CFLAGS) + $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(MATLAB_LDFLAGS) $(LIBS) \ + -o $(LIBPREFIX)$(TARGET)MEX$(MATLAB_EXT) +endif # ----------------------------------------------------------------- # Build a C++ dynamically loadable module @@ -513,15 +518,23 @@ matlab: $(SRCDIR_SRCS) matlab_cpp: $(SRCDIR_SRCS) $(SWIG) -c++ -matlab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(COMPILETOOL) "$(MATLAB_MEX)" -g $(CPPFLAGS) CXXFLAGS='$$CXXFLAGS $(CXXFLAGS)' $(ICXXSRCS) $(SRCDIR_SRCS) \ - $(SRCDIR_CXXSRCS) $(INCLUDES) $(LIBS) -output $(TARGET)MEX +ifdef MATLAB_MEX + $(COMPILETOOL) "$(MATLAB_MEX)" -g $(CPPFLAGS) CXXFLAGS='$$CXXFLAGS $(CXXFLAGS)' $(ICXXSRCS) \ + $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(LIBS) -output $(TARGET)MEX +else + $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) \ + $(SRCDIR_CXXSRCS) $(MATLAB_CXXFLAGS) + $(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(MATLAB_LDFLAGS) $(LIBS) \ + $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)MEX${MATLAB_EXT} + +endif # ----------------------------------------------------------------- -# Running an Matlab example +# Running an MATLAB/Octave example # ----------------------------------------------------------------- matlab_run: - $(RUNTOOL) "$(MATLAB)" $(MATLAB_OPTS) $(MATLAB_EXEC) "try; $(MATLAB_SCRIPT); catch err, fprintf(2,['ERROR: ' err.message '\n']),exit(1), end, exit(0)" $(RUNPIPE) + $(RUNTOOL) "$(MATLAB)" $(MATLAB_OPTS) $(MATLAB_EXEC) "try; $(MATLAB_SCRIPT); catch err; fprintf(2,['ERROR: ' err.message '\n']);exit(1); end; exit(0)" $(RUNPIPE) # ----------------------------------------------------------------- # Version display @@ -531,7 +544,7 @@ matlab_run: "$(MATLAB)" $(MATLAB_OPTS) $(MATLAB_EXEC) "disp(version);exit" | tail -n 2 # ----------------------------------------------------------------- -# Cleaning the Matlab examples +# Cleaning the MATLAB/Octave examples # ----------------------------------------------------------------- matlab_clean: diff --git a/Examples/test-suite/matlab/Makefile.in b/Examples/test-suite/matlab/Makefile.in index 7e33da30a..282923765 100644 --- a/Examples/test-suite/matlab/Makefile.in +++ b/Examples/test-suite/matlab/Makefile.in @@ -2,10 +2,11 @@ # Makefile for matlab test-suite ####################################################################### -LANGUAGE = matlab -MATLAB = @MATLAB@ -MATLABOPTS = -nodisplay -nosplash -nojvm -SCRIPTSUFFIX = _runme +LANGUAGE = matlab +MATLAB = @MATLAB@ +MATLAB_OPTS = @MATLAB_OPTS@ +MATLAB_EXEC = @MATLAB_EXEC@ +SCRIPTSUFFIX = _runme srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -16,10 +17,6 @@ CPP_TEST_BROKEN += \ include $(srcdir)/../common.mk -# Overridden variables here -#LIBS = -L. -#CSRCS = matlab_empty.c - # Custom tests - tests with additional commandline options # none! @@ -53,7 +50,7 @@ run_testcase = \ end; \ exit(0)" ; \ env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" MATLABPATH="$(srcdir):$(SCRIPTDIR):$$MATLAB_PATH" \ - $(RUNTOOL) "$(MATLAB)" $(MATLABOPTS) -r "$$RUNSCRIPT" $(RUNPIPE); \ + $(RUNTOOL) "$(MATLAB)" $(MATLAB_OPTS) $(MATLAB_EXEC) "$$RUNSCRIPT" $(RUNPIPE); \ if [ $$? -ne 0 ] ; then \ echo " $* failed" $(RUNPIPE) ; \ else \ diff --git a/configure.ac b/configure.ac index 1dcc7cc3a..2a43a1b6a 100644 --- a/configure.ac +++ b/configure.ac @@ -1085,22 +1085,64 @@ AC_SUBST(OCTAVE_CXXFLAGS) AC_SUBST(OCTAVE_LDFLAGS) #---------------------------------------------------------------- -# Look for Matlab +# Look for MATLAB or Octave #---------------------------------------------------------------- -# Try to detect if there is matlab installed on the system and set the -# MATLAB_HOME, MATLAB and MATLAB_EXT variable - +MATLABBIN= AC_ARG_WITH([matlab], AS_HELP_STRING([--without-matlab], [Disable Matlab]) -AS_HELP_STRING([--with-matlab=path], [specify location of matlab installation for the matlab interface. The "mex" compiler should be in MATLAB_HOME/bin]),[use_matlab=$withval], [use_matlab=yes]) +AS_HELP_STRING([--with-matlab=path], [specify location of MATLAB or Octave installation]),[MATLABBIN="$withval"], [MATLABBIN="$alllang_default"]) + +# Do we want to use Octave to test the MATLAB module? +AC_ARG_ENABLE([octave-for-matlab], + AS_HELP_STRING([--enable-octave-for-matlab], [Use Octave to test the MATLAB/Octave bilingual module (default disabled)]), [enable_octave_for_matlab=$enableval], [enable_octave_for_matlab=no]) + +# Unset by default +MATLAB= +MATLAB_MEX= +MATLAB_EXT= +MATLAB_CFLAGS= +MATLAB_CXXFLAGS= +MATLAB_LDFLAGS= +MATLAB_OPTS= +MATLAB_EXEC= # First, check for "--without-matlab" or "--with-matlab=no". -if test x"${use_matlab}" = xno -o x"${with_alllang}" = xno ; then - AC_MSG_NOTICE([Disabling Matlab per request]) - MATLAB= -else +if test x"${MATLABBIN}" = xno; then + AC_MSG_NOTICE([Disabling MATLAB/Octave bilingual module]) +elif test "x$enable_octave_for_matlab" = "xyes"; then + AC_MSG_NOTICE([Using Octave to test the MATLAB/Octave module]) + MATLAB_OPTS="--no-gui" + MATLAB_EXEC="--eval" + + # First figure out what the name of Octave is + if test "x$MATLABBIN" = xyes; then + AC_PATH_PROG(MATLAB, [octave]) + else + MATLAB="$MATLABBIN" + fi - if test x"$use_matlab" = xyes; then + if test -n "$MATLAB"; then + AC_MSG_CHECKING([for mkoctfile]) + mkoctfile="$(dirname $MATLAB)/$(basename $MATLAB | sed -e 's/octave/mkoctfile/')" + AS_IF([test -x "${mkoctfile}"],[ + AC_MSG_RESULT([${mkoctfile}]) + ],[ + AC_MSG_RESULT([not found, disabling MATLAB/Octave bilingual module]) + ]) + fi + if test -n "$MATLAB"; then + MATLAB_EXT=.mex + MATLAB_CFLAGS=`${mkoctfile} -p ALL_CFLAGS` + MATLAB_CXXFLAGS=`${mkoctfile} -p ALL_CXXFLAGS` + MATLAB_LDFLAGS=`${mkoctfile} -p ALL_LDFLAGS` + fi + +else + AC_MSG_NOTICE([Using MATLAB to test the MATLAB/Octave module]) + MATLAB_OPTS="-nodisplay -nojvm" + MATLAB_EXEC="-r" + + if test "x$MATLABBIN" = xyes; then # Try to detect matlab home automatically AC_MSG_CHECKING([for matlab installation]) # First figure out what the name of Matlab is @@ -1111,8 +1153,8 @@ else # follow symbolic link # JDK defined a macro BASIC_REMOVE_SYMBOLIC_LINKS that might be more portable if test -L "$MATLAB"; then - # matlab is a symbolic link, follow it - MATLAB=`ls -l "$MATLAB" | awk '{print $NF}'` + # matlab is a symbolic link, follow it + MATLAB=`ls -l "$MATLAB" | awk '{print $NF}'` fi # strip matlab and bin to find home MATLAB_HOME=`dirname "$MATLAB"` @@ -1120,7 +1162,7 @@ else AC_MSG_RESULT([found matlab home: $MATLAB_HOME]) fi else - MATLAB_HOME="$use_matlab" + MATLAB_HOME="$MATLABBIN" AC_MSG_RESULT([looking for matlab in: $MATLAB_HOME]) AC_PATH_PROG(MATLAB, [matlab], [notfound], [$MATLAB_HOME/bin]) if test x"$MATLAB" = xnotfound; then @@ -1128,32 +1170,27 @@ else MATLAB= fi fi -fi - -MATLAB_MEX= -if test x"$MATLAB" != x; then - AC_MSG_CHECKING([for Matlab mex command]) - AC_PATH_PROG(MATLAB_MEX, [mex], [], [$MATLAB_HOME/bin$PATH_SEPARATOR$PATH]) - if test x"$MATLAB_MEX" = x; then - AC_MSG_WARN([Cannot find mex command. Disabling matlab]) - MATLAB= - fi -fi + if test x"$MATLAB" != x; then + AC_MSG_CHECKING([for Matlab mex command]) + AC_PATH_PROG(MATLAB_MEX, [mex], [], [$MATLAB_HOME/bin$PATH_SEPARATOR$PATH]) + if test x"$MATLAB_MEX" = x; then + AC_MSG_WARN([Cannot find mex command. Disabling matlab]) + MATLAB= + fi + fi -MATLAB_EXT= -if test x"$MATLAB" != x; then - AC_MSG_CHECKING([for Matlab mexext command]) - AC_PATH_PROG(MATLAB_MEXEXT, [mexext], [], [$MATLAB_HOME/bin$PATH_SEPARATOR$PATH]) - if test x"$MATLAB_MEXEXT" = x; then - AC_MSG_WARN([Cannot find mexext command. Disabling matlab]) - MATLAB= - else - MATLAB_EXT=`"$MATLAB_MEXEXT"` - AC_MSG_RESULT([matlab mex suffix: $MATLAB_EXT]) - fi + if test x"$MATLAB" != x; then + AC_MSG_CHECKING([for Matlab mexext command]) + AC_PATH_PROG(MATLAB_MEXEXT, [mexext], [], [$MATLAB_HOME/bin$PATH_SEPARATOR$PATH]) + if test x"$MATLAB_MEXEXT" = x; then + AC_MSG_WARN([Cannot find mexext command. Disabling matlab]) + MATLAB= + else + MATLAB_EXT=`"$MATLAB_MEXEXT"` + AC_MSG_RESULT([matlab mex suffix: $MATLAB_EXT]) + fi + fi fi -MATLAB_OPTS=-nodisplay -nojvm -MATLAB_EXEC=-r AC_SUBST(MATLAB) AC_SUBST(MATLAB_OPTS) @@ -1161,6 +1198,10 @@ AC_SUBST(MATLAB_EXEC) AC_SUBST(MATLAB_HOME) AC_SUBST(MATLAB_MEX) AC_SUBST(MATLAB_EXT) +AC_SUBST(MATLAB_CFLAGS) +AC_SUBST(MATLAB_CXXFLAGS) +AC_SUBST(MATLAB_LDFLAGS) + # Look for Scilab #---------------------------------------------------------------- |