Makefile 5.59 KB
Newer Older
1
#
Tobias WEBER's avatar
Tobias WEBER committed
2
# MnSi dynamics module for Takin and helper tools
3
4
5
6
7
# @author Tobias Weber <tweber@ill.fr>
# @date 2018-2020
# @license GPLv2 (see 'LICENSE' file)
#

Tobias WEBER's avatar
Tobias WEBER committed
8
9
10
11
12
13
14
15
16
mingw_build = 0
debug_build = 0
strip_bins = 1


# -----------------------------------------------------------------------------
# setup
# -----------------------------------------------------------------------------
ifneq ($(mingw_build), 1)
Tobias WEBER's avatar
Tobias WEBER committed
17
18
19
	ifeq ("$(CXX)", "")
		CXX = g++
	endif
Tobias WEBER's avatar
Tobias WEBER committed
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

	SYSINCS = -I/usr/local/include \
		-I/usr/include/lapacke -I/usr/local/opt/lapack/include \
		-I/usr/include/qt5 -I/usr/include/x86_64-linux-gnu/qt5/ \
		#-I/home/tw/build/boost_1_73_0
	LIBDIRS = -L/usr/local/opt/lapack/lib -L/usr/local/lib

	LIBBOOSTSYS = -lboost_system
	LIBBOOSTFILESYS = -lboost_filesystem

	BIN_SUFFIX =
else
	CXX = x86_64-w64-mingw32-g++

	SYSINCS = -I/usr/x86_64-w64-mingw32/sys-root/mingw/include \
		-I/usr/x86_64-w64-mingw32/sys-root/mingw/include/qt5
	LIBDIRS = -L/usr/x86_64-w64-mingw32/sys-root/mingw/bin/

	LIBBOOSTSYS = -lboost_system-x64
	LIBBOOSTFILESYS = -lboost_filesystem-x64

	BIN_SUFFIX = .exe
endif


ifneq ($(debug_build), 1)
	OPT = -O2 #-march=native

	ifeq ($(strip_bins), 1)
		STRIP = strip
	else
		STRIP = echo -e "Not stripping"
	endif
else
	OPT = -g -ggdb
	STRIP = echo -e "Not stripping"
endif


59
STD = -std=c++17
Tobias WEBER's avatar
Tobias WEBER committed
60
LIBDEFS = -fPIC
61
62
DEFS = -DDEF_SKX_ORDER=7 -DDEF_HELI_ORDER=7 \
	-DNO_MINIMISATION -DNO_REDEFINITIONS \
63
	-D__HACK_FULL_INST__ #-DPLUGIN_APPLI
Tobias WEBER's avatar
Tobias WEBER committed
64
65
INCS = -Isrc -Iext -Iext/takin $(SYSINCS)
# -----------------------------------------------------------------------------
66
67


Tobias WEBER's avatar
Tobias WEBER committed
68
69
# -----------------------------------------------------------------------------
# meta rules
70
71
72
73
74
# -----------------------------------------------------------------------------
.PHONY: all clean

all: prepare lib/skxmod.so lib/skxmod_grid.so \
	bin/genskx bin/merge bin/convert bin/dump \
Tobias WEBER's avatar
Tobias WEBER committed
75
	bin/drawskx bin/dyn bin/weight \
Tobias WEBER's avatar
Tobias WEBER committed
76
#	bin/heliphase bin/skx_gs bin/weight_sum
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

clean:
	find . -name "*.o" -exec rm -fv {} \;
	rm -rfv bin/
	rm -rfv lib/

prepare:
	mkdir -p bin/
	mkdir -p lib/
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# Takin plugin modules
# -----------------------------------------------------------------------------
Tobias WEBER's avatar
Tobias WEBER committed
92
lib/skxmod.so: src/takin/takin.o src/core/skx.o src/core/fp.o src/core/heli.o src/core/longfluct.o src/core/magsys.o \
93
94
95
	ext/takin/tools/monteconvo/sqwbase.o ext/tlibs2/libs/log.o
	@echo "Linking Takin module $@..."
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) $(LIBDEFS) -shared -o $@ $+ -llapacke
Tobias WEBER's avatar
Tobias WEBER committed
96
	$(STRIP) $@
97
98
99

lib/skxmod_grid.so: src/takin/takin_grid.o ext/takin/tools/monteconvo/sqwbase.o ext/tlibs2/libs/log.o
	@echo "Linking Takin grid module $@..."
Tobias WEBER's avatar
Tobias WEBER committed
100
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) $(LIBDEFS) -shared -o $@ $+ $(LIBBOOSTSYS) -lQt5Core
Tobias WEBER's avatar
Tobias WEBER committed
101
	$(STRIP) $@
102
103
104
105
106
107
108
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# tools
# -----------------------------------------------------------------------------
bin/genskx: src/takin/genskx.o src/core/skx.o src/core/magsys.o ext/tlibs2/libs/log.o
Tobias WEBER's avatar
Tobias WEBER committed
109
110
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) $(LIBDEFS) -o $@ $+ $(LIBBOOSTFILESYS) -llapacke -lpthread
	$(STRIP) $@$(BIN_SUFFIX)
111
112

bin/merge: src/takin/merge.o
Tobias WEBER's avatar
Tobias WEBER committed
113
114
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) -o $@ $+ $(LIBBOOSTSYS)
	$(STRIP) $@$(BIN_SUFFIX)
115
116
117

bin/convert: src/takin/convert.o
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) -o $@ $+
Tobias WEBER's avatar
Tobias WEBER committed
118
	$(STRIP) $@$(BIN_SUFFIX)
119
120
121

bin/dump: src/takin/dump.o
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) -o $@ $+
Tobias WEBER's avatar
Tobias WEBER committed
122
	$(STRIP) $@$(BIN_SUFFIX)
123
124
125

bin/drawskx: src/calc/drawskx.o
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) -o $@ $+
Tobias WEBER's avatar
Tobias WEBER committed
126
	$(STRIP) $@$(BIN_SUFFIX)
127
128

bin/dyn: src/calc/dyn.o src/core/skx.o src/core/fp.o src/core/heli.o src/core/magsys.o ext/tlibs2/libs/log.o
Tobias WEBER's avatar
Tobias WEBER committed
129
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) $(LIBDEFS) -o $@ $+ -llapacke -lpthread
Tobias WEBER's avatar
Tobias WEBER committed
130
	$(STRIP) $@$(BIN_SUFFIX)
131
132

bin/weight: src/calc/weight.o src/core/skx.o src/core/fp.o src/core/heli.o src/core/magsys.o ext/tlibs2/libs/log.o
Tobias WEBER's avatar
Tobias WEBER committed
133
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) $(LIBDEFS) -o $@ $+ -llapacke -lpthread
Tobias WEBER's avatar
Tobias WEBER committed
134
	$(STRIP) $@$(BIN_SUFFIX)
135
136

bin/weight_sum: src/calc/weight_sum.o src/core/skx.o src/core/fp.o src/core/heli.o src/core/magsys.o ext/tlibs2/libs/log.o
Tobias WEBER's avatar
Tobias WEBER committed
137
	$(CXX) $(STD) $(OPT) $(DEFS) $(LIBDIRS) $(LIBDEFS) -o $@ $+ -llapacke -lpthread
Tobias WEBER's avatar
Tobias WEBER committed
138
	$(STRIP) $@$(BIN_SUFFIX)
139
140
141
142
143
144
145
146
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# further tools needing specialised compilation options
# -----------------------------------------------------------------------------
bin/heliphase: src/calc/heliphase.cpp src/core/heli.cpp src/core/magsys.cpp ext/tlibs2/libs/log.cpp
	$(CXX) $(STD) $(OPT) $(INCS) -DDEF_HELI_ORDER=4 -DNO_REDEFINITIONS -D__HACK_FULL_INST__ $(LIBDIRS) -o $@ $+ -lMinuit2 -llapacke -lgomp
Tobias WEBER's avatar
Tobias WEBER committed
147
	$(STRIP) $@$(BIN_SUFFIX)
148
149
150

bin/skx_gs: src/calc/skx_gs.cpp src/core/skx.cpp src/core/heli.cpp src/core/magsys.cpp ext/tlibs2/libs/log.cpp
	$(CXX) $(STD) $(OPT) $(INCS) -DDEF_SKX_ORDER=7 -DDEF_HELI_ORDER=7 -DNO_REDEFINITIONS -D__HACK_FULL_INST__ $(LIBDIRS) -o $@ $+ -lMinuit2 -llapacke -lgomp
Tobias WEBER's avatar
Tobias WEBER committed
151
	$(STRIP) $@$(BIN_SUFFIX)
152
153
154
155
156
157
158
159
160
161
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# general rules
# -----------------------------------------------------------------------------
%.o: %.cpp
	@echo "Compiling $< -> $@..."
	$(CXX) $(STD) $(OPT) $(DEFS) $(INCS) $(LIBDEFS) -c $< -o $@
# -----------------------------------------------------------------------------