-
Notifications
You must be signed in to change notification settings - Fork 117
/
Makefile
106 lines (71 loc) · 2.69 KB
/
Makefile
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
ifndef JAVA_HOME
$(error JAVA_HOME must be set.)
endif
ifndef TMPDIR
TMPDIR := /tmp
endif
VLFEATDIR := $(TMPDIR)/vlfeat
ENCEVALDIR := $(TMPDIR)/enceval
VLFEATURL = "http://keystoneml.libs.s3.amazonaws.com/vlfeat-0.9.20-bin.tar.gz"
ENCEVALURL = "http://keystoneml.libs.s3.amazonaws.com/enceval-toolkit-1.1.tar.gz"
SCALA_VERSION = 2.10
PROJECT = keystoneml
PROJECT_VERSION = 0.3.0-SNAPSHOT
TARGET_JAR = target/scala-$(SCALA_VERSION)/$(PROJECT)-assembly-$(PROJECT_VERSION).jar
CC = g++
# Auto-detect architecture
UNAME := $(shell uname -sm)
Darwin_x86_64_CFLAGS := -O2
Linux_x86_64_CFLAGS := -O2 -fPIC -fopenmp -shared
CFLAGS ?= $($(shell echo "$(UNAME)" | tr \ _)_CFLAGS)
# Set arch for VLFeat
Darwin_x86_64_ARCH := maci64
Linux_x86_64_ARCH := glnxa64
VLARCH ?= $($(shell echo "$(UNAME)" | tr \ _)_ARCH)
VLFEATOBJ = $(VLFEATDIR)/vlfeat-0.9.20/bin/$(VLARCH)/objs
# Set dynamic lib extension for architecture
Darwin_x86_64_EXT := dylib
Linux_x86_64_EXT := so
SOEXT ?= $($(shell echo "$(UNAME)" | tr \ _)_EXT)
#Set java extension for architecture
Darwin_x86_64_JAVA := darwin
Linux_x86_64_JAVA := linux
JAVAEXT ?= $($(shell echo "$(UNAME)" | tr \ _)_JAVA)
SRCDIR := src/main/cpp
ODIR := $(TMPDIR)/obj
LDIR := lib
_OBJ := VLFeat.o EncEval.o
OBJ := $(addprefix $(ODIR)/,$(_OBJ))
_EVDEPS := gmm.o fisher.o stat.o simd_math.o
EVDEPS := $(addprefix $(ENCEVALDIR)/lib/gmm-fisher/,$(_EVDEPS))
VLDEPS = $(shell find $(VLFEATOBJ) -type f -name '*.o')
all: $(LDIR)/libImageFeatures.$(SOEXT)
$(TARGET_JAR):
sbt/sbt assembly
$(SRCDIR)/EncEval.h: $(TARGET_JAR) src/main/scala/keystoneml/utils/external/EncEval.scala
CLASSPATH=$< javah -o $@ keystoneml.utils.external.EncEval
$(SRCDIR)/VLFeat.h: $(TARGET_JAR) src/main/scala/keystoneml/utils/external/VLFeat.scala
CLASSPATH=$< javah -o $@ keystoneml.utils.external.VLFeat
$(VLFEATDIR):
mkdir -p $(VLFEATDIR)
wget $(VLFEATURL) -O $(VLFEATDIR)/vlfeat.tgz
cd $(VLFEATDIR) && tar zxvf $(VLFEATDIR)/vlfeat.tgz
$(ENCEVALDIR):
mkdir -p $(ENCEVALDIR)
wget $(ENCEVALURL) -O $(ENCEVALDIR)/enceval.tgz
cd $(ENCEVALDIR) && tar zxvf enceval.tgz
vlfeat: $(VLFEATDIR)
make -C $(VLFEATDIR)/vlfeat-0.9.20 ARCH=$(VLARCH) MEX= bin-all
enceval: $(ENCEVALDIR) $(EVDEPS)
%.o: %.cxx
$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR):
mkdir $@
$(ODIR)/%.o: $(SRCDIR)/%.cxx $(SRCDIR)/%.h | $(ODIR) $(VLFEATDIR) $(ENCEVALDIR)
$(CC) -I$(ENCEVALDIR)/lib/gmm-fisher -I$(VLFEATDIR)/vlfeat-0.9.20 -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/$(JAVAEXT) -c -o $@ $< $(CFLAGS)
$(LDIR)/libImageFeatures.$(SOEXT): $(OBJ) vlfeat enceval
$(CC) -dynamiclib -o $@ $(OBJ) $(EVDEPS) $(VLDEPS) $(CFLAGS)
.PHONY: clean vlfeat enceval
clean:
rm -f $(LDIR)/libImageFeatures.$(SOEXT)
rm -rf $(VLFEATDIR) $(ENCEVALDIR) $(ODIR)