-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
197 lines (173 loc) · 7 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
######################################################################
# Open source FEM-DEM coupling installation Makefile
#
# run 'make help' for more info
######################################################################
######################################################################
# OPTIONS
######################################################################
top-dir = $(abspath _build)
j = 1
j-oofem = $(j)
j-yade = $(j)
######################################################################
######################################################################
# CONSTANTS
######################################################################
# oofem
oofem-dir = $(top-dir)/oofem
oofem-zip = $(oofem-dir)/oofem.zip
oofem-dir-source = $(oofem-dir)/source
oofem-dir-source-orig = $(oofem-dir)/source-orig
oofem-dir-build = $(oofem-dir)/build
liboofem-cmake-flags = $(oofem-dir-build)/CMakeFiles/liboofem.dir/flags.make
# yade
yade-dir = $(top-dir)/yade
yade-tar = $(yade-dir)/yade.tar.bz2
yade-dir-source = $(yade-dir)/source
yade-dir-source-orig = $(yade-dir)/source-orig
yade-dir-build = $(yade-dir)/build
yade-dir-install = $(yade-dir)/install
# install
install-dir = $(top-dir)/install
export-cmd = 'export PYTHONPATH=''$$''PYTHONPATH:$(install-dir):'
######################################################################
# TARGETS
######################################################################
default: help
######################################################################
# help
######################################################################
help:
@echo
@echo ==================================================
@echo Open source FEM-DEM coupling installation Makefile
@echo ==================================================
@echo Downloads, compiles and installs all necessary software \(OOFEM, YADE\) to be used for FEM-DEM coupling
@echo Prerequisites: wget, unzip, cmake, tar, patch, YADE prerequisites
@echo Tested on Ubuntu 18.04 LTS system
@echo
@echo Options:
@echo " top-dir ... top directory for download, compilation ... Must be absolute path (!)"
@echo " j ... global -j option (number of cores) for compilation"
@echo " j-oofem ... -j option (number of cores) for oofem compilation"
@echo " j-yade ... -j option (number of cores) for yade compilation"
@echo
@echo Main targets:
@echo " all ... runs directories, oofem, yade and install targets"
@echo " directories ... creates oofem, yade and istall directories in top-dir"
@echo " oofem ... downloads, modifies source code and compile OOFEM"
@echo " yade ... downloads, modifies source code and compile YADE"
@echo " intall ... copy relevant files into top-dir/install directory"
@echo
@echo Sub targets \(for advanced usage\):
@echo " oofem-download, oofem-modify, oofem-build, oofem-cmakem oofem-make"
@echo " yade-download, yade-modify, yade-build, yade-cmake, yade-make"
@echo " install-oofem, install-yade, install-demfemcoupling, install-export"
@echo " end-message"
@echo
@echo Example usage:
@echo " - show this message"
@echo " make help"
@echo " - just default usage (downloads, compiles and installs everything)"
@echo " make all"
@echo " - 'my' command, specifying top-dir and j-oofem, leaving j-yade equal to 1"
@echo " make all top-dir=""$$""HOME/programs/demfem j-oofem=4"
@echo " - only run yade target (download, modify, build)"
@echo " make yade"
@echo " - only downloads and modify source code of oofem"
@echo " make oofem-download oofem-modify"
@echo
######################################################################
# all
######################################################################
all: directories oofem yade install
######################################################################
# directories
######################################################################
directories:
mkdir -p $(oofem-dir)
mkdir -p $(yade-dir)
mkdir -p $(install-dir)
######################################################################
# oofem
######################################################################
oofem: oofem-download oofem-modify oofem-build
oofem-download:
rm -rf $(oofem-dir-source-orig)
wget http://www.oofem.org/cgi-bin/OOFEM/download.cgi?download=oofem-2.5.zip -O $(oofem-zip)
unzip -q -o $(oofem-zip)
mv oofem-2.5 $(oofem-dir-source-orig)
oofem-modify:
rm -rf $(oofem-dir-source)
cp -r $(oofem-dir-source-orig) $(oofem-dir-source)
cd $(oofem-dir-source) && \
patch -s -p0 < $(CURDIR)/oofem.diff
oofem-build: oofem-cmake oofem-make
oofem-cmake:
mkdir -p $(oofem-dir-build)
cd $(oofem-dir-build) && \
cmake -DUSE_PYTHON_BINDINGS=ON $(oofem-dir-source)
# remove compilation flags causing ImportError before running make
sed -i 's/-fvisibility=hidden//' $(liboofem-cmake-flags)
sed -i 's/-fvisibility-inlines-hidden//' $(liboofem-cmake-flags)
oofem-make:
$(MAKE) -C $(oofem-dir-build) -j $(j-oofem)
######################################################################
# yade
######################################################################
yade: yade-download yade-modify yade-build
yade-download:
rm -rf $(yade-dir-source-orig)
wget https://launchpad.net/yade/trunk/yade-1.00.0/+download/yade_2019.01a.tar.bz2 -O $(yade-tar)
tar xfj $(yade-tar)
mv trunk-2019.01a $(yade-dir-source-orig)
yade-modify:
rm -rf $(yade-dir-source)
cp -r $(yade-dir-source-orig) $(yade-dir-source)
cd $(yade-dir-source) && \
patch -s -p0 < $(CURDIR)/yade.diff
yade-build: yade-cmake yade-make
yade-cmake:
mkdir -p $(yade-dir-build)
cd $(yade-dir-build) && \
cmake \
-DCMAKE_INSTALL_PREFIX=$(yade-dir-install) \
-DENABLE_LINSOLV=OFF \
-DENABLE_PFVFLOW=OFF \
-DENABLE_LBMFLOW=OFF \
-DENABLE_TWOPHASEFLOW=OFF \
-DENABLE_GL2PS=OFF \
-DNOSUFFIX=ON \
$(yade-dir-source)
yade-make:
$(MAKE) -C $(yade-dir-build) -j $(j-yade)
$(MAKE) -C $(yade-dir-build) install
######################################################################
# install
######################################################################
install: install-oofem install-yade install-demfemcoupling install-export end-message
install-oofem:
rm -f $(install-dir)/liboofem.so
ln -s $(oofem-dir-build)/liboofem.so $(install-dir)/liboofem.so
install-yade:
rm -f $(install-dir)/libyade.py
ln -s $(yade-dir-install)/bin/yade $(install-dir)/libyade.py
install-demfemcoupling:
rm -f $(install-dir)/demfemcoupling.py
ln -s $(CURDIR)/../src/demfemcoupling.py $(install-dir)/demfemcoupling.py
install-export:
echo $(export-cmd) >> $(HOME)/.bashrc
end-message:
@echo
@echo ======================================================================
@echo Now everything should be compiled and prepared for use.
@echo Try out some examples :-\)
@echo
@echo There is no need to run this script any more
@echo
@echo If you want to run examples directly in this terminal, execute the
@echo following command:
@echo $(export-cmd)
@echo ======================================================================
@echo