forked from lucastheis/cmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (98 loc) · 3.55 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
107
108
109
110
111
112
113
OS = $(shell uname)
INCDIR = code/cmt/include
SRCDIR = code/cmt/src
PYIDIR = code/cmt/python/include
PYSDIR = code/cmt/python/src
OBJDIR = build
# compiler and linker options
ifeq ($(OS), Darwin)
CXX = \
$(shell python -c "import sysconfig; print(sysconfig.get_config_vars('CC')[0]);")
CXXFLAGS = $(shell python -c "import sysconfig; print(sysconfig.get_config_vars('CFLAGS')[0]);") \
-Wno-write-strings -Wno-sign-compare -Wno-unknown-pragmas -Wno-parentheses -DEIGEN_NO_DEBUG
LD = $(CXX)
LDFLAGS = code/liblbfgs/lib/.libs/liblbfgs.a \
$(shell python -c "import sysconfig; print(' '.join(sysconfig.get_config_vars('LDSHARED')[0].split(' ')[1:]));")
else
CXX = \
$(shell python -c "import sysconfig; print(sysconfig.get_config_vars('CXX')[0]);")
CXXFLAGS = $(shell python -c "import sysconfig; print(sysconfig.get_config_vars('CFLAGS')[0]);") \
-std=c++0x -Wno-write-strings -Wno-sign-compare -Wno-unknown-pragmas -Wno-parentheses -Wno-cpp -fPIC -fopenmp -DEIGEN_NO_DEBUG
LD = $(CXX)
LDFLAGS = code/liblbfgs/lib/.libs/liblbfgs.a -lgomp \
$(shell python -c "import sysconfig; print(' '.join(sysconfig.get_config_vars('LDSHARED')[0].split(' ')[1:]));")
endif
# include paths
INCPYTHON = \
$(shell python -c "from distutils import sysconfig; print(sysconfig.get_python_inc());")
INCNUMPY = \
$(shell python -c "import os; from numpy.distutils import misc_util; print(os.path.join(misc_util.get_numpy_include_dirs()[0], 'numpy'));")
INCLUDE = -Icode -I$(INCDIR) -I$(PYIDIR) -Icode/liblbfgs/include -I$(INCPYTHON) -I$(INCNUMPY)
PYTHONPATH = \
$(shell python -c "from distutils import sysconfig; print(sysconfig.get_python_lib());")
# source and object files
SOURCES = \
$(SRCDIR)/affinepreconditioner.cpp \
$(SRCDIR)/affinetransform.cpp \
$(SRCDIR)/binningtransform.cpp \
$(PYSDIR)/callbackinterface.cpp \
$(SRCDIR)/conditionaldistribution.cpp \
$(PYSDIR)/conditionaldistributioninterface.cpp \
$(SRCDIR)/distribution.cpp \
$(PYSDIR)/distributioninterface.cpp \
$(PYSDIR)/fvbninterface.cpp \
$(SRCDIR)/gsm.cpp \
$(PYSDIR)/gsminterface.cpp \
$(SRCDIR)/glm.cpp \
$(PYSDIR)/glminterface.cpp \
$(SRCDIR)/mcgsm.cpp \
$(PYSDIR)/mcgsminterface.cpp \
$(SRCDIR)/mcbm.cpp \
$(PYSDIR)/mcbminterface.cpp \
$(SRCDIR)/mixture.cpp \
$(PYSDIR)/mixtureinterface.cpp \
$(SRCDIR)/mlr.cpp \
$(PYSDIR)/mlrinterface.cpp \
$(PYSDIR)/module.cpp \
$(SRCDIR)/nonlinearities.cpp \
$(PYSDIR)/nonlinearitiesinterface.cpp \
$(SRCDIR)/patchmodel.cpp \
$(PYSDIR)/patchmodelinterface.cpp \
$(SRCDIR)/pcapreconditioner.cpp \
$(SRCDIR)/pcatransform.cpp \
$(SRCDIR)/preconditioner.cpp \
$(PYSDIR)/preconditionerinterface.cpp \
$(PYSDIR)/pyutils.cpp \
$(SRCDIR)/regularizer.cpp \
$(SRCDIR)/stm.cpp \
$(PYSDIR)/stminterface.cpp \
$(SRCDIR)/tools.cpp \
$(PYSDIR)/toolsinterface.cpp \
$(SRCDIR)/trainable.cpp \
$(PYSDIR)/trainableinterface.cpp \
$(SRCDIR)/utils.cpp \
$(SRCDIR)/univariatedistributions.cpp \
$(PYSDIR)/univariatedistributionsinterface.cpp \
$(SRCDIR)/whiteningpreconditioner.cpp \
$(SRCDIR)/whiteningtransform.cpp
OBJECTS = $(patsubst %.cpp,$(OBJDIR)/%.o,$(SOURCES))
MODULE = $(OBJDIR)/_cmt.so
# keep object files around
.SECONDARY:
all: $(MODULE)
clean:
rm -f $(OBJECTS) $(OBJECTS:.o=.d) $(MODULE)
install: $(MODULE)
cp $(MODULE) $(PYTHONPATH)
$(MODULE): $(OBJECTS)
@echo $(LD) $(LDFLAGS) -o $@
@$(LD) $(OBJECTS) $(LDFLAGS) -o $@
$(OBJDIR)/%.o: %.cpp $(OBJDIR)/%.d
@mkdir -p $(@D)
@echo $(CXX) -o $@ -c $<
@$(CXX) $(INCLUDE) $(CXXFLAGS) -o $@ -c $<
$(OBJDIR)/%.d: %.cpp
@mkdir -p $(@D)
@echo $(CXX) -MM $< -MF $@
@$(CXX) $(INCLUDE) -MM -MT '$(@:.d=.o)' $< -MF $@
-include $(OBJECTS:.o=.d)