forked from erdc/proteus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
219 lines (181 loc) · 7.8 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
.PHONY: all check clean distclean doc install profile proteus update
all: install
#We use environment variables from the invoking process if they have been set,
#otherwise we try our best to determine them automatically.
SHELL=/usr/bin/env bash
PROTEUS ?= $(shell python -c "from __future__ import print_function; import os; print(os.path.realpath(os.getcwd()))")
VER_CMD = git log -1 --pretty="%H"
PROTEUS_INSTALL_CMD = python setup.py install
PROTEUS_DEVELOP_CMD = pip install -e .
# shell hack for now to automatically detect Garnet front-end nodes
PROTEUS_ARCH ?= $(shell [[ $$(hostname) = garnet* ]] && echo "garnet.gnu" || python -c "import sys; print sys.platform")
PROTEUS_PREFIX ?= ${PROTEUS}/${PROTEUS_ARCH}
PROTEUS_PYTHON ?= ${PROTEUS_PREFIX}/bin/python
PROTEUS_VERSION := $(shell ${VER_CMD})
define show_info
@echo "Please include this information in all bug reports."
@echo "+======================================================================================================+"
@echo "PROTEUS : ${PROTEUS}"
@echo "PROTEUS_ARCH : ${PROTEUS_ARCH}"
@echo "PROTEUS_PREFIX : ${PROTEUS_PREFIX}"
@echo "PROTEUS_VERSION : ${PROTEUS_VERSION}"
@echo "HASHDIST_VERSION : $$(cd hashdist; ${VER_CMD})"
@echo "HASHSTACK_VERSION: $$(cd stack; ${VER_CMD})"
@echo "+======================================================================================================+"
@echo ""
endef
define howto
@echo "Proteus and its dependencies have been installed!"
@echo ""
@echo "You may want to add the installation directory to your PATH:"
@echo "${PROTEUS_PREFIX}/bin"
@echo ""
@echo "On bash or zsh:"
@echo 'export PATH=${PROTEUS_PREFIX}/bin:$${PATH}'
@echo ""
@echo "You can also invoke the Python interpreter directly:"
@echo "${PROTEUS_PREFIX}/bin/python"
@echo ""
@echo "You should now verify that the install succeeded by running:"
@echo "make check"
@echo ""
endef
ifeq ($(PROTEUS_ARCH), darwin)
PLATFORM_ENV = MACOSX_DEPLOYMENT_TARGET=$(shell sw_vers -productVersion | sed "s/\(10.[0-9]\).*/\1/")
endif
ifeq ($(PROTEUS_ARCH), cygwin)
BOOTSTRAP = cygwin_bootstrap.done
endif
ifdef MATLAB
MATLAB_SETUP = matlab_setup.done
endif
# The choice for default Fortran compiler needs to be overridden on the Garnet system
ifeq ($(PROTEUS_ARCH), garnet.gnu)
FC=ftn
F77=ftn
F90=ftn
endif
ifdef VERBOSE
HIT_FLAGS += -v
endif
ifdef DEBUG
PROTEUS_ARCH := ${PROTEUS_ARCH}-debug
endif
PROTEUS_ENV ?= PATH="${PROTEUS_PREFIX}/bin:${PATH}"
clean:
-PROTEUS_PREFIX=${PROTEUS_PREFIX} ${PROTEUS_PYTHON} setup.py clean
distclean: clean
-rm -f stack.done
-rm -rf ${PROTEUS_PREFIX}
-rm -rf build src/*.pyc proteus/*.so proteus/*.a
update:
@echo "Manually trying to update all repositories"
git fetch origin; git checkout -q origin/master
@echo "Proteus repository updated to latest versions"
cd stack; git fetch origin; git checkout -q origin/master
@echo "Stack repository updated to latest versions"
cd hashdist; git fetch origin; git checkout -q origin/master
@echo "HashDist repository updated to latest versions"
@echo "+======================================================================================================+"
@echo "Warning, the HEAD has been detached in all repositories"
@echo "Type: git checkout -b branch_name to save changes"
@echo "+======================================================================================================+"
hashdist:
@echo "No hashdist found. Cloning hashdist from GitHub"
git clone https://github.com/hashdist/hashdist.git
stack:
@echo "No stack found. Cloning stack from GitHub"
git clone https://github.com/hashdist/hashstack.git stack
cygwin_bootstrap.done: stack/scripts/setup_cygstack.py stack/scripts/cygstack.txt
python stack/scripts/setup_cygstack.py stack/scripts/cygstack.txt
touch cygwin_bootstrap.done
matlab_setup.done: stack stack/default.yaml hashdist
@echo "User requests MATLAB install"
@echo "MATLAB environment variable set to ${MATLAB}"
@python setupmatlab.py stack/default.yaml ${MATLAB}; if [ $$? -ne 0 ] ; then \
echo "+======================================================================================================+"; \
echo "Couldn't find matlab on PATH."; \
echo "Try"; \
echo " MATLAB=/path/to/matlab make"; \
echo "+======================================================================================================+"; \
false; fi
touch matlab_setup.done
profile: ${PROTEUS_PREFIX}/artifact.json
stack/default.yaml: stack stack/examples/proteus.${PROTEUS_ARCH}.yaml
cp stack/examples/proteus.${PROTEUS_ARCH}.yaml stack/default.yaml
# A hashstack profile will be rebuilt if Make detects any files in the stack
# directory newer than the profile artifact file.
${PROTEUS_PREFIX}/artifact.json: stack/default.yaml stack hashdist $(shell find stack -type f) ${BOOTSTRAP} ${MATLAB_SETUP}
@echo "************************"
@echo "Building dependencies..."
@echo "************************"
$(call show_info)
cd stack && ${PROTEUS}/hashdist/bin/hit develop ${HIT_FLAGS} -f -k error default.yaml ${PROTEUS_PREFIX}
# workaround hack on Cygwin for hashdist launcher to work correctly
-cp ${PROTEUS}/${PROTEUS_ARCH}/bin/python2.7.exe.link ${PROTEUS}/${PROTEUS_ARCH}/bin/python2.7.link
@echo "************************"
@echo "Dependency build complete"
@echo "************************"
proteus: ${PROTEUS_PREFIX}/bin/proteus
${PROTEUS_PREFIX}/bin/proteus ${PROTEUS_PREFIX}/bin/proteus_env.sh: profile
@echo "************************"
@echo "Installing proteus scripts..."
@echo "************************"
echo "#!/usr/bin/env bash" > ${PROTEUS_PREFIX}/bin/proteus
echo '${PROTEUS_ENV} python "$${@:1}"' >> ${PROTEUS_PREFIX}/bin/proteus
chmod a+x ${PROTEUS_PREFIX}/bin/proteus
echo "#!/usr/bin/env sh" > ${PROTEUS_PREFIX}/bin/proteus_env.sh
echo '${PROTEUS_ENV}' >> ${PROTEUS_PREFIX}/bin/proteus_env.sh
chmod a+x ${PROTEUS_PREFIX}/bin/proteus_env.sh
@echo "************************"
@echo "Proteus script successfully installed"
@echo "************************"
# Proteus install should be triggered by an out-of-date hashstack profile, source tree, or modified setup files.
install: profile config.py $(shell find proteus -type f) $(wildcard *.py) proteus
@echo "************************"
@echo "Installing..."
@echo "************************"
$(call show_info)
${PROTEUS_ENV} ${PROTEUS_INSTALL_CMD}
@echo "************************"
@echo "done installing standard extension modules"
@echo "************************"
@echo "Installation complete"
@echo "************************"
@echo ""
@echo "Proteus was built using the following configuration:"
$(call show_info)
$(call howto)
develop: proteus profile config.py
@echo "************************"
@echo "Installing development version"
@echo "************************"
$(call show_info)
${PROTEUS_ENV} ${PROTEUS_DEVELOP_CMD}
@echo "************************"
@echo "Development installation complete"
@echo "************************"
@echo ""
@echo "Proteus was built using the following configuration:"
$(call show_info)
$(call howto)
check:
@echo "************************"
@echo "Sanity environment check"
@echo PROTEUS: ${PROTEUS}
@echo PROTEUS_ARCH: ${PROTEUS_ARCH}
@echo PROTEUS_PREFIX: ${PROTEUS_PREFIX}
@echo PROTEUS_ENV: ${PROTEUS_ENV}
@echo "************************"
@echo "Hello world Check!"
${PROTEUS_PREFIX}/bin/python -c "print 'hello world'"
@echo "************************"
@echo "Proteus Partition Test"
source ${PROTEUS_PREFIX}/bin/proteus_env.sh; ${PROTEUS_PREFIX}/bin/python proteus/tests/ci/test_meshPartitionFromTetgenFiles.py
@echo "************************"
@echo "************************"
@echo "Parallel Proteus Partition Test"
source ${PROTEUS_PREFIX}/bin/proteus_env.sh; mpirun -np 4 ${PROTEUS_PYTHON} proteus/tests/ci/test_meshPartitionFromTetgenFiles.py
@echo "************************"
doc: install
cd doc && ${PROTEUS_ENV} PROTEUS=${PWD} make html