Ticket #46516: patch-src_Makefile.diff

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

    old new  
    1515# Matlab configuration
    1616# MATLABDIR = /usr/local/MATLAB/R2010b
    1717# comment the following line if you use MATLAB on 32-bit operating system
    18 MEX_OPTION += -largeArrayDims
     18# MEX_OPTION += -largeArrayDims
    1919
    2020# Mingw crosscompiler: available at http://www.nongnu.org/mingw-cross-env/
    21 CROSS   = $(HOME)/src/mxe.github.schloegl/usr/bin/i686-pc-mingw32
    22 CROSS64 = $(HOME)/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32
     21# CROSS   = $(HOME)/src/mxe.github.schloegl/usr/bin/i686-pc-mingw32
     22# CROSS64 = $(HOME)/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32
    2323# 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/
     24# W32MAT_INC = -I$(HOME)/bin/win32/Matlab/R2010b/extern/include/
     25# W64MAT_INC = -I$(HOME)/bin/win64/Matlab/R2010b/extern/include/
    2626# path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/
    27 GNUMEX   = $(HOME)/bin/win32/gnumex
    28 GNUMEX64 = $(HOME)/bin/win64/gnumex
     27# GNUMEX   = $(HOME)/bin/win32/gnumex
     28# GNUMEX64 = $(HOME)/bin/win64/gnumex
    2929# building gnumex64 was difficult, these hints were quite useful:
    3030# http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinZvxgC9ezp2P3UCX_a7TAUYuVsp2U40MQUV6qr%40mail.gmail.com&forum_name=gnumex-users
    3131# 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
     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
    4141
    4242
    4343
    44 CC      = gcc
    45 CXX     = g++
     44#CC     = gcc
     45#CXX    = g++
    4646CFLAGS  = -fopenmp -Wall -Wextra -Wconversion -O2 -fPIC
    4747OCTMEX  = mkoctfile$(OCTAVE_VERSION) --mex
    4848RM      = rm
    4949
    5050MEX_OPTION  += -lgomp CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS)" CXXFLAGS\#"$(CFLAGS)"
    51 MATMEX      = $(MATLABDIR)/bin/mex $(MEX_OPTION)
     51MKOCTFILE = mkoctfile$(OCTAVE_VERSION)
     52OCTMEX  = $(MKOCTFILE) --mex
     53
     54FLIBS = ${shell $(MKOCTFILE) -p FLIBS}
     55INCFLAGS = ${shell $(MKOCTFILE) -p INCFLAGS}
     56INC_CSTDLIB = -include cstdlib
    5257
    5358PROGS = covm_mex.mex sumskipnan_mex.mex #
    5459
     
    5661mex4o octave: $(PROGS)
    5762
    5863
    59 ### Matlab configuration - search for a matlab directory if not defined above
    60 ifndef MATLABDIR
    61   ifneq ('',$(shell ls -1 /usr/local/MATLAB))
    62     # use oldest, typically mex-files a compatible with newer Matlab versions
    63     MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |tail -1)
    64     # alternatively, use latest matlab version
    65     #MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1)
    66   endif
    67 endif
    68 
    69 ### if the MATLABDIR has been found or defined
    70 ifneq ('',MATLABDIR)
    71   ifneq ('',$(lshell ls -1 $(MATLABDIR)))
    72     MEX_EXT = $(shell $(MATLABDIR)/bin/mexext)
    73     mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS))
    74   endif
    75 endif
    76 
    77 
    78 mexw32 win32:  $(patsubst %.mex, %.mexw32, $(PROGS))
    79 mexw64 win64:  $(patsubst %.mex, %.mexw64, $(PROGS))
    80 all:    octave win32 win64 mex4m
     64# ### Matlab configuration - search for a matlab directory if not defined above
     65# ifndef MATLABDIR
     66#   ifneq ('',$(shell ls -1 /usr/local/MATLAB))
     67#    use oldest, typically mex-files a compatible with newer Matlab versions
     68#     MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |tail -1)
     69#    alternatively, use latest matlab version
     70#     MATLABDIR=$(shell ls -dt1 /usr/local/MATLAB/R* |head -1)
     71#   endif
     72# endif
     73#
     74# ### if the MATLABDIR has been found or defined
     75# ifneq ('',MATLABDIR)
     76#   ifneq ('',$(lshell ls -1 $(MATLABDIR)))
     77#     MEX_EXT = $(shell $(MATLABDIR)/bin/mexext)
     78#     mex4m matlab: $(patsubst %.mex, %.$(MEX_EXT), $(PROGS))
     79#   endif
     80# endif
     81#
     82#
     83# mexw32 win32:  $(patsubst %.mex, %.mexw32, $(PROGS))
     84# mexw64 win64:  $(patsubst %.mex, %.mexw64, $(PROGS))
     85all:    octave
    8186
    8287clean:
    8388        -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex*
     
    8893#       Octave, MATLAB on Linux
    8994#########################################################
    9095%.oct: %.cc
    91         mkoctfile$(OCTAVE_VERSION) "$<"
     96        $(MKOCTFILE) $<
    9297
    9398%.mex: %.cpp
    94         $(OCTMEX) "$<"  -lgomp -llapack -lblas     ## Octave
    95 %.$(MEX_EXT): %.cpp
    96         $(MATMEX) "$<"  -lgomp -llapack -lblas     ## Matlab
     99        INCFLAGS="$(INCFLAGS) $(INC_CSTDLIB)" $(OCTMEX) $< $(FLIBS) -lgomp     ## Octave
     100# %.$(MEX_EXT): %.cpp
     101#       $(MATMEX) "$<"  -lgomp -llapack -lblas     ## Matlab
    97102
    98103
    99104#########################################################
    100105#       MATLAB/WIN32
    101106#########################################################
    102 %.obj: %.cpp
    103         $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
    104 %.obj: %.c
    105         $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
    106 
    107 %.mexw32: %.obj
    108         $(CROSS)-$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W32) -lblas -llapack
     107# %.obj: %.cpp
     108#       $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
     109# %.obj: %.c
     110#       $(CROSS)-$(CXX) -fopenmp -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W32MAT_INC) -O2 -DMX_COMPAT_32 "$<"
     111#
     112# %.mexw32: %.obj
     113#       $(CROSS)-$(CXX) -shared $(GNUMEX)/mex.def -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W32) -lblas -llapack
    109114
    110115
    111116#########################################################
     
    113118#########################################################
    114119
    115120## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash
    116 %.o64: %.cpp
    117         $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<"
    118 %.o64: %.c
    119         $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<"
    120 
    121 %.mexw64: %.o64
    122         $(CROSS64)-$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W64) -lblas -llapack
     121# %.o64: %.cpp
     122#       $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<"
     123# %.o64: %.c
     124#       $(CROSS64)-$(CXX) -c -DMATLAB_MEX_FILE -x c++ -o "$@" $(W64MAT_INC) -O2 "$<"
     125#
     126# %.mexw64: %.o64
     127#       $(CROSS64)-$(CXX) -shared $(GNUMEX64)/mex.def -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex -llibmat -lcholmod -lgomp -lpthread -L$(LDLIBS_W64) -lblas -llapack
    123128       
    124129       
    125130