Ticket #46650: patch-src-Makefile.diff

File patch-src-Makefile.diff, 4.5 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.6.3
    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 = -I$(HOME)/bin/win32/Matlab/R2010b/extern/include/
    25 W64MAT_INC = -I$(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 W32MAT_INC += -I$(subst /usr/bin/,/usr/,$(CROSS))/include/
    34 W64MAT_INC += -I$(subst /usr/bin/,/usr/,$(CROSS64))/include/
    35 LDLIBS_W32 = $(subst /usr/bin/,/usr/,$(CROSS))/lib/
    36 LDLIBS_W64 = $(subst /usr/bin/,/usr/,$(CROSS64))/lib/
    37 W32_LIBS  = $(LDLIBS_W32)liblapack.a
    38 W64_LIBS  = $(LDLIBS_W64)liblapack.a
    39 W32_LIBS += $(LDLIBS_W32)libblas.a
    40 W64_LIBS += $(LDLIBS_W64)libblas.a
    41 
    42 CC      = gcc
    43 CXX     = g++
     15#CC     = gcc
     16#CXX    = g++
    4417CFLAGS  = -Wall -Wextra -Wconversion -O2 -fPIC
    45 OCTMEX  = mkoctfile$(OCTAVE_VERSION) --mex
     18OCTMEX  = mkoctfile --mex
    4619RM      = rm
    4720
    4821ifneq (Darwin,$(shell uname))
     
    5124endif
    5225
    5326MEX_OPTION  += CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS)" CXXFLAGS\#"$(CFLAGS)"
    54 MATMEX      = $(MATLABDIR)/bin/mex $(MEX_OPTION)
    5527
    5628PROGS = covm_mex.mex sumskipnan_mex.mex #
    5729
    5830### per default only the mex-files for octave are built
    5931mex4o octave: $(PROGS)
    6032
    61 
    62 ### Matlab configuration - search for a matlab directory if not defined above
    63 ifndef MATLABDIR
    64   ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB))
    65     # use oldest, typically mex-files a compatible with newer Matlab versions
    66     MATLABDIR=/usr/local/MATLAB/$(shell ls -1t /usr/local/MATLAB/  |grep "^R*" |head -1)
    67     # alternatively, use latest matlab version
    68     #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1)
    69   endif
    70 endif
    71 
    72 ### if the MATLABDIR has been found or defined
    73 ifneq (,MATLABDIR)
    74   ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext))
    75     MEX_EXT=$(shell $(MATLABDIR)/bin/mexext)
    76     mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS))
    77   endif
    78 endif
    79 
    80 
    81 mexw32 win32:  $(patsubst %.mex, %.mexw32, $(PROGS))
    82 mexw64 win64:  $(patsubst %.mex, %.mexw64, $(PROGS))
    83 all:    octave win32 win64 mex4m
     33all:    octave mex4m
    8434
    8535clean:
    8636        -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex*
     
    8838
    8939#########################################################
    9040
    91 #       Octave, MATLAB on Linux
     41#       Octave
    9242#########################################################
    9343%.oct: %.cc
    94         mkoctfile$(OCTAVE_VERSION) "$<"
     44        mkoctfile "$<"
    9545
    9646%.mex: %.cpp
    9747        $(OCTMEX) "$<" -llapack -lblas
    98 %.$(MEX_EXT): %.cpp
    99         $(MATMEX) "$<" -llapack -lblas
    100 
    101 
    102 #########################################################
    103 #       MATLAB/WIN32
    104 #########################################################
    105 %.obj: %.cpp
    106         $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
    107 %.obj: %.c
    108         $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
    109 
    110 %.mexw32: %.obj
    111         $(CROSS)-$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W32) -lblas -llapack
    112 
    113 
    114 #########################################################
    115 #       MATLAB/WIN64
    116 #########################################################
    117 
    118 ## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash
    119 %.o64: %.cpp
    120         $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<"
    121 %.o64: %.c
    122         $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<"
    123 
    124 %.mexw64: %.o64
    125         $(CROSS64)-$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W64) -lblas -llapack
    12648       
    127        
    128