forked from diffpy/diffpy.pdffit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (85 loc) · 2.57 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
########################################################################
# This Makefile should be used only for debugging purposes and is
# intended for strong-hearted developers. End users should use the
# setup.py script instead.
#
# Variables:
#
# DEBUG when defined, compile with debug options
# USESHARED when defined, link with shared gsl library
# PYTHON_INCLUDE path to Python include files used for compilation
#
########################################################################
ifndef PYTHON_INCLUDE
PYTHON_INCLUDE := $(shell python -c \
'from distutils import sysconfig; print(sysconfig.get_python_inc())')
endif
########################################################################
INCLUDE = \
-I$(PYTHON_INCLUDE) \
-Ilibpdffit2 \
-Ipdffit2module \
-Ibuild -I. \
$(GSL_INCLUDE)
GSL_INCLUDE = $(shell gsl-config --cflags)
GSL_LIBS_CONFIG = $(shell gsl-config --libs-without-cblas)
ifdef USESHARED
GSL_LIBS = $(GSL_LIBS_CONFIG)
else
GSL_LIBS = $(subst -L,,$(filter -L%, $(GSL_LIBS_CONFIG)))/libgsl.a
endif
ifneq (,$(findstring darwin,$(OSTYPE)))
LDFLAGS = -bundle -undefined dynamic_lookup
else
LDFLAGS = -shared
endif
COMMONFLAGS = -std=c++11 -Wall -Wno-write-strings -fPIC
OPTIMFLAGS = -O3 -funroll-loops -ffast-math $(COMMONFLAGS)
DEBUGFLAGS = -g $(COMMONFLAGS)
ifdef DEBUG
CPPFLAGS = $(DEBUGFLAGS) $(INCLUDE) $(DEFINES)
else
CPPFLAGS = $(OPTIMFLAGS) $(INCLUDE) $(DEFINES)
endif
PYTHON_XY := $(shell python -c 'import sys; print(sys.version[:3])')
BDIR := build/$(PYTHON_XY)
.PHONY: all module clean test
all: module
module: $(BDIR)/pdffit2module.so
@test $< -ef diffpy/pdffit2/pdffit2.so || \
ln -vf $< diffpy/pdffit2/pdffit2.so
clean:
rm -rf -- build/$(PYTHON_XY) diffpy/pdffit2/pdffit2.so
test: module
python -m diffpy.pdffit2.tests.run
OBJS = \
$(BDIR)/bindings.o \
$(BDIR)/misc.o \
$(BDIR)/pdffit2module.o \
$(BDIR)/pyexceptions.o \
$(BDIR)/Atom.o \
$(BDIR)/LocalPeriodicTable.o \
$(BDIR)/OutputStreams.o \
$(BDIR)/PeriodicTable.o \
$(BDIR)/PointsInSphere.o \
$(BDIR)/StringUtils.o \
$(BDIR)/fit.o \
$(BDIR)/gaussj.o \
$(BDIR)/metric.o \
$(BDIR)/nrutil.o \
$(BDIR)/output.o \
$(BDIR)/parser.o \
$(BDIR)/pdf.o \
$(BDIR)/pdffit.o \
$(BDIR)/pdflsmin.o \
$(BDIR)/scatlen.o \
$(BDIR)/stru.o \
$(BDIR):
mkdir -p $@
$(BDIR)/pdffit2module.so: $(BDIR) $(OBJS)
$(CXX) -o $@ $(LDFLAGS) $(OBJS) $(GSL_LIBS)
$(BDIR)/%.o : libpdffit2/%.cc
$(CXX) -c $(CPPFLAGS) -o $@ $<
$(BDIR)/%.o : pdffit2module/%.cc
$(CXX) -c $(CPPFLAGS) -o $@ $<
# End of file