Ticket #46668: patch-src-Makefile.diff

File patch-src-Makefile.diff, 5.7 KB (added by Schamschula (Marius Schamschula), 10 years ago)
  • src/Makefile

    old new  
    1212# Better alternative: define an OCTAVE_VERSION bash variable (or in .bashrc or .profile)
    1313#OCTAVE_VERSION=-3.8.2
    1414
    15 # Matlab configuration
    16 #MATLABDIR = /usr/local/MATLAB/R2010b
    17 # comment the following line if you use MATLAB on 32-bit operating system
    18 MEX_OPTION += -largeArrayDims
    19 
    20 # Mingw crosscompiler: available at http://www.nongnu.org/mingw-cross-env/
    21 CROSS   = $(HOME)/src/mxe/usr/bin/i686-w64-mingw32.static-
    22 CROSS64 = $(HOME)/src/mxe/usr/bin/x86_64-w64-mingw32.static-
    23 # include directory for Win32-Matlab include
    24 W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/
    25 W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/
    26 # path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/
    27 GNUMEX   = $(HOME)/bin/win32/gnumex
    28 GNUMEX64 = $(HOME)/bin/win64/gnumex
    29 # building gnumex64 was difficult, these hints were quite useful:
    30 # http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinZvxgC9ezp2P3UCX_a7TAUYuVsp2U40MQUV6qr%40mail.gmail.com&forum_name=gnumex-users
    31 # Instead of building "mex shortpath.c" and "mex uigetpath.c", I used empty m-functions within argout=argin;
    32 ####################################################
    33 
    34 CC      = gcc
    35 CXX     = g++
     15#CC      = gcc
     16#CXX     = g++
    3617CFLAGS  = -fopenmp -Wall -Wextra -Wconversion -O2 -fPIC
    37 OCTMEX  = mkoctfile$(OCTAVE_VERSION) --mex
     18OCTMEX  = mkoctfile --mex
    3819RM      = rm
    3920
    4021ifeq (Linux,$(shell uname))
    4122CFLAGS      += -fopenmp
    4223MEX_OPTION  += -lgomp
    4324endif
    4425
    4526MEX_OPTION  += CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS) " CXXFLAGS\#"$(CFLAGS) "
    46 MATMEX      = $(MATLABDIR)/bin/mex $(MEX_OPTION)
    4727
    4828PROGS = histo_mex.mex covm_mex.mex kth_element.mex sumskipnan_mex.mex str2array.mex train.mex svmtrain_mex.mex svmpredict_mex.mex xptopen.mex
    4929
     
    5131mex4o octave: $(PROGS)
    5232
    5333
    54 ### Matlab configuration - search for a matlab directory if not defined above
    55 ifndef MATLABDIR
    56   ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB))
    57     # use oldest, typically mex-files a compatible with newer Matlab versions
    58     MATLABDIR=/usr/local/MATLAB/$(shell ls -1t /usr/local/MATLAB/  |grep "^R*" |head -1)
    59     # alternatively, use latest matlab version
    60     #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1)
    61   endif
    62 endif
    63 
    64 ### if the MATLABDIR has been found or defined
    65 ifneq (,MATLABDIR)
    66   ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext))
    67     MEX_EXT=$(shell $(MATLABDIR)/bin/mexext)
    68     mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS))
    69   endif
    70 endif
    71 
    72 
    73 mexw32 win32:  $(patsubst %.mex, %.mexw32, $(PROGS))
    74 mexw64 win64:  $(patsubst %.mex, %.mexw64, $(PROGS))
    75 all:    octave win32 win64 mex4m
     34all:    octave mex4m
    7635
    7736clean:
    7837        -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex*
     
    8039#$(PROGS): Makefile
    8140
    8241#########################################################
    83 #       Octave, MATLAB on Linux
     42#       Octave
    8443#########################################################
    8544%.oct: %.cc
    8645        mkoctfile$(OCTAVE_VERSION) "$<"
    8746
    8847%.mex: %.cpp
    8948        $(OCTMEX) "$<"
    90 %.$(MEX_EXT): %.cpp
    91         $(MATMEX) "$<"
    9249
    9350svmtrain_mex.mex svmpredict_mex.mex: svmtrain_mex.cpp svm.h svm.cpp svm_model_matlab.c svmpredict_mex.cpp
    9451        $(CXX) $(CFLAGS) -c svm.cpp
     
    11774tron.o: tron.cpp tron.h
    11875        $(CXX) $(CFLAGS) -c tron.cpp
    11976
    120 
    121 #########################################################
    122 #       MATLAB/WIN32
    123 #########################################################
    124 %.obj: %.cpp
    125         $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
    126 %.obj: %.c
    127         $(CROSS)$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
    128 
    129 train.mexw32 predict.mexw32:  train.obj linear.obj linear_model_matlab.obj tron.obj
    130         $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" linear_model_matlab.obj linear.obj tron.obj -llibmx -llibmex -llibmat -lcholmod -lblas
    131 
    132 svmpredict_mex.mexw32 :  svmpredict_mex.obj svm.obj svm_model_matlab.obj
    133         $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lcholmod
    134 svmtrain_mex.mexw32 : svmtrain_mex.obj svm.obj svm_model_matlab.obj
    135         $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" svm_model_matlab.obj svm.obj -llibmx -llibmex -llibmat -lcholmod
    136 
    137 %.mexw32: %.obj
    138         $(CROSS)$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread
    139 
    140 
    141 
    142 #########################################################
    143 #       MATLAB/WIN64
    144 #########################################################
    145 
    146 ## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash
    147 %.o64: %.cpp
    148         $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W64MAT_INC) -O2 "$<"
    149 %.o64: %.c
    150         $(CROSS64)$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" -I$(W64MAT_INC) -O2 "$<"
    151 
    152 train.mexw64 predict.mexw64:  train.o64 linear.o64 linear_model_matlab.o64 tron.o64
    153         $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" linear_model_matlab.o64 linear.o64 tron.o64 -llibmx -llibmex -llibmat -lcholmod -lblas
    154 
    155 svmpredict_mex.mexw64 :  svmpredict_mex.o64 svm.o64 svm_model_matlab.o64
    156         $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lcholmod
    157 svmtrain_mex.mexw64 : svmtrain_mex.o64 svm.o64 svm_model_matlab.o64
    158         $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" svm_model_matlab.o64 svm.o64 -llibmx -llibmex -llibmat -lcholmod
    159 
    160 %.mexw64: %.o64
    161         $(CROSS64)$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread
    162