-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
88 lines (71 loc) · 2.26 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
#
# Copyright (c) 2015-2018 Idiap Research Institute, http://www.idiap.ch/
# Written by James Newling <[email protected]>
# All rights reserved.
#
# eakmeans is a library for exact and approximate k-means written in C++ and
# Python. This file is part of eakmeans. See file COPYING for more details.
#
# This file is part of eakmeans.
#
# eakmeans is free software: you can redistribute it and/or modify
# it under the terms of the 3-Clause BSD Licence. See
# https://opensource.org/licenses/BSD-3-Clause for more details.
#
# eakmeans is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See file
# COPYING for more details.
#
##########################################################
#compile with blas?
USEBLAS = YES
export LIBBLASDIR=/idiap/user/jnewling/openblas/lib #/home/james/openblas/lib
export INCBLASDIR=/idiap/user/jnewling/openblas/include #/home/james/openblas/include
##########################################################
CXX := g++
CXXFLAGS := -std=c++11 -O3 -Wall -pedantic -fPIC
LINKER := g++ #-Wl,--no-as-needed
LFLAGS := -lpthread
ifeq ($(USEBLAS), YES)
LFLAGS := ${LFLAGS} -lopenblas -L${LIBBLASDIR}
CXXFLAGS := ${CXXFLAGS} -D WITHBLAS
INCLUDEPATHS = -I${INCBLASDIR}
TARGET := withblaskmeans
LIBNAME := libwithblaskmeans
export WITHBLAS
else
TARGET := blaslesskmeans
LIBNAME := libblaslesskmeans
endif
SOURCES := $(wildcard src/*.cpp)
HEADERS := $(wildcard src/*.h)
OBJECTS := $(SOURCES:src/%.cpp=obj/%.o)
OBJECTS_FORLIB := $(filter-out obj/main.o,$(OBJECTS))
all : main lib pythonkmeans
main : $(OBJECTS)
@mkdir -p bin
$(LINKER) -o bin/${TARGET} $(OBJECTS) $(LFLAGS)
@echo "Linking for main of ${NAME} done!"
lib : $(OBJECTS_FORLIB)
@mkdir -p lib
$(CXX) -shared $^ -o lib/$(LIBNAME).so
@echo "Shared library ${LIBNAME} made!"
pythonkmeans:
python setup.py build_ext -b lib
obj/%.o : src/%.cpp $(HEADERS)
@mkdir -p obj
$(CXX) -c $(CXXFLAGS) $(INCLUDEPATHS) $< -o $@
@echo "compiled "$<" successfully!"
.PHONEY: clean
clean:
rm -f $(OBJECTS)
@echo "cleanup done!"
.PHONEY: remove
remove: clean
-rm cythonsrc/kmeans.cpp
-rm -rf build
-rm -rf bin
-rm -rf lib
-rm -rf obj
@echo "should be 100% clean!"