forked from vlfeat/vlfeat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoctave.mak
134 lines (109 loc) · 3.77 KB
/
octave.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# file: octave.mak
# description: Build MEX files for GNU Octave
# author: Andrea Vedaldi
# Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
# All rights reserved.
#
# This file is part of the VLFeat library and is made available under
# the terms of the BSD license (see the COPYING file).
# Octave support is experimental. Currently, the MEX files compile
# successfully but a number of bugs and subtle MATLAB
# imcompatibilities make VLFeat not fully functional.
#
# Octave support is enabled if $(MKOCTFILE) is executable. Therefore
# setting MKOCTFILE to the empty string disables Octave support.
OCTAVE ?= octave
MKOCTFILE ?=
OCTAVE_ENABLE ?= $(strip $(shell type -P $(MKOCTFILE) 2>&1 >/dev/null && \
$(MKOCTFILE) -p OCTAVE_LIBS 2>&1 | \
grep octave))
# if expand to empty string, set to empty string for use with ifdef
ifeq ($(OCTAVE_ENABLE),)
OCTAVE_ENABLE=
endif
ifdef OCTAVE_ENABLE
all: octave-all
clean: octave-clean
archclean: octave-archclean
distclean: octave-distclean
endif
info: octave-info
OCTAVE_MEX_SUFFIX := mex
OCTAVE_MEX_BINDIR := toolbox/mex/octave
OCTAVE_MEX_FLAGS =
OCTAVE_MEX_CFLAGS = $(STD_CFLAGS) -I$(VLDIR)/toolbox
OCTAVE_MEX_LDFLAGS = $(STD_LDFLAGS) -L$(BINDIR) -lvl
# Mac OS X on Intel 32 bit processor
ifeq ($(ARCH),maci)
OCTAVE_MEX_LDFLAGS += -m32
endif
# Mac OS X on Intel 64 bit processor
ifeq ($(ARCH),maci64)
endif
# Linux on 32 bit processor
ifeq ($(ARCH),glnx86)
OCTAVE_MEX_LDFLAGS += -Wl,--rpath,\\\$$ORIGIN/
endif
# Linux on 64 bit processor
ifeq ($(ARCH),glnxa64)
OCTAVE_MEX_LDFLAGS += -Wl,--rpath,\\\$$ORIGIN/
endif
# --------------------------------------------------------------------
# Build
# --------------------------------------------------------------------
.PHONY: octave-all, octave-mex-all, octave-mex-dir, octave-info
.PHONY: octave-clean octave-archclean octave-distclean
no_dep_targets += octave-info
no_dep_targets += octave-clean octave-archclean octave-distclean
octave_mex_src := $(shell find $(VLDIR)/toolbox -name "*.c")
octave_mex_tgt := $(addprefix $(OCTAVE_MEX_BINDIR)/,\
$(notdir $(mex_src:.c=.$(OCTAVE_MEX_SUFFIX)) ) )
octave_mex_dep := $(octave_mex_tgt:.$(OCTAVE_MEX_SUFFIX)=.d)
ifdef OCTAVE_ENABLE
deps += $(octave_mex_dep)
endif
vpath %.c $(shell find $(VLDIR)/toolbox -type d)
vpath vl_%.m $(shell find $(VLDIR)/toolbox -type d)
octave-all: octave-mex-all
octave-mex-all: $(octave_mex_tgt) matlab-noprefix
# generate octave-mex-dir target
$(eval $(call gendir, octave-mex, $(OCTAVE_MEX_BINDIR)))
$(OCTAVE_MEX_BINDIR)/%.d : %.c $(octave-mex-dir)
$(call C,MKOCTFILE) $(OCTAVE_MEX_FLAGS) -M "$(<)"
@mv "$(<:.c=.d)" $(OCTAVE_MEX_BINDIR)
$(OCTAVE_MEX_BINDIR)/%.$(OCTAVE_MEX_SUFFIX) : %.c $(octave-mex-dir)
@make -s $(dll_tgt)
@ln -sf "../../../$(BINDIR)/lib$(DLL_NAME).$(DLL_SUFFIX)" \
"$(OCTAVE_MEX_BINDIR)/lib$(DLL_NAME).$(DLL_SUFFIX)"
CFLAGS="$(OCTAVE_MEX_CFLAGS)" \
CXXFLAGS="$(OCTAVE_MEX_CXXFLAGS)" \
LDFLAGS="$(OCTAVE_MEX_LDFLAGS)" \
$(MKOCTFILE) \
--mex $(OCTAVE_MEX_FLAGS) \
"$(<)" --output "$(@)"
@rm -f $(<:.c=.o)
octave-info:
$(call echo-title,Octave support)
$(if $(OCTAVE_ENABLE),\
@echo "OCTAVE support enabled (MKOCTFILE found)",\
@echo "OCTAVE support disabled (MKOCTFILE not found)")
$(call dump-var,octave_mex_src)
$(call dump-var,octave_mex_tgt)
$(call dump-var,octave_mex_dep)
$(call echo-var,OCTAVE)
$(call echo-var,MKOCTFILE)
$(call echo-var,OCTAVE_MEX_BINDIR)
$(call echo-var,OCTAVE_MEX_FLAGS)
$(call echo-var,OCTAVE_MEX_CFLAGS)
$(call echo-var,OCTAVE_MEX_LDLAGS)
@echo
octave-clean:
rm -f $(octave_mex_dep)
octave-archclean: octave-clean
rm -f $(octave_mex_tgt)
octave-distclean: octave-archclean
rm -rf toolbox/mex/octave
# Emacs:
# Local variables:
# mode: Makefile
# End: