Ticket #50746: patch-src_Makefile.diff

File patch-src_Makefile.diff, 7.5 KB (added by Schamschula (Marius Schamschula), 9 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
    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++
     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++
    4444CFLAGS  = -Wall -Wextra -Wconversion -O2 -fPIC
    45 OCTMEX  = mkoctfile$(OCTAVE_VERSION) --mex -lgomp
     45OCTMEX  = mkoctfile$(OCTAVE_VERSION) --mex
    4646RM      = rm
    4747
    4848# Support Debian Hardening flags
    4949# https://wiki.debian.org/HardeningWalkthrough#Handling_dpkg-buildflags_in_your_upstream_build_system
    50 CFLAGS += $(CPPFLAGS)
    51 
    52 ifneq (Darwin,$(shell uname))
    53 CFLAGS      += -fopenmp
    54 MEX_OPTION  += -lgomp
    55 endif
    56 
    57 MEX_OPTION  += CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS)" CXXFLAGS\#"$(CFLAGS)"
    58 MATMEX      = $(MATLABDIR)/bin/mex $(MEX_OPTION)
    59 
    60 PROGS       = covm_mex.mex sumskipnan_mex.mex histo_mex.mex #
    61 
     50# CFLAGS += $(CPPFLAGS)
     51#
     52# ifneq (Darwin,$(shell uname))
     53# CFLAGS      += -fopenmp
     54# MEX_OPTION  += -lgomp
     55# endif
     56#
     57# MEX_OPTION  += CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS)" CXXFLAGS\#"$(CFLAGS)"
     58# MATMEX      = $(MATLABDIR)/bin/mex $(MEX_OPTION)
     59#
     60# PROGS       = covm_mex.mex sumskipnan_mex.mex histo_mex.mex #
     61#
    6262### per default only the mex-files for octave are built
    6363mex4o octave: $(PROGS)
    6464
    6565
    6666### Matlab configuration - search for a matlab directory if not defined above
    67 ifeq (,$(MATLABDIR))
    68   ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB))
    69     # use oldest, typically mex-files a compatible with newer Matlab versions
    70     MATLABDIR=/usr/local/MATLAB/$(shell ls -1rt /usr/local/MATLAB/  |grep "^R*" |head -1)
    71   endif
    72 endif
    73 
    74 ### if MATLABDIR has been found or defined
    75 ifneq (,$(MATLABDIR))
    76   ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext))
    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))
    85 all:    octave win32 win64 mex4m
     67# ifeq (,$(MATLABDIR))
     68#   ifneq (,$(shell ls -1 /usr/local/ |grep MATLAB))
     69#     # use oldest, typically mex-files a compatible with newer Matlab versions
     70#     MATLABDIR=/usr/local/MATLAB/$(shell ls -1rt /usr/local/MATLAB/  |grep "^R*" |head -1)
     71#   endif
     72# endif
     73#
     74# ### if MATLABDIR has been found or defined
     75# ifneq (,$(MATLABDIR))
     76#   ifneq (,$(shell ls -1 $(MATLABDIR)/bin/mexext))
     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
    8686
    8787clean:
    8888        -$(RM) *.o *.obj *.o64 core octave-core *.oct *~ *.mex*
     
    9393#       Octave, MATLAB on Linux
    9494#########################################################
    9595%.oct: %.cc
    96         mkoctfile$(OCTAVE_VERSION) "$<"
     96        mkoctfile "$<"
    9797
    9898%.mex: %.cpp
    9999        $(OCTMEX) "$<" -llapack -lblas
     
    104104#########################################################
    105105#       MATLAB/WIN32
    106106#########################################################
    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
     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
    114114
    115115
    116116#########################################################
     
    118118#########################################################
    119119
    120120## ToDO: fix OpenMP support: currently -fopenmp causes Matlab to crash
    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
     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
    128128       
    129129       
    130130