-
Notifications
You must be signed in to change notification settings - Fork 14
/
makefile
251 lines (232 loc) · 10.2 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# For installing and running PlanetProfile.
# USAGE:
# make: Print available command line arguments.
# make install: Copy necessary files for running PlanetProfile.
# make uninstall: Remove files outside the PlanetProfile directory that were placed by 'install'.
# make clean: Remove files ignored by GitHub (output data and figures).
#
# DESCRIPTION:
# Various commands for setting up and running PlanetProfile.
# Designed for accessibility for new users and ease of use for advanced users.
#
# AUTHOR: Marshall J. Styczinski (marshall.j.styczinski@jpl.nasa.gov), 2018-07-03
# Last updated 2023-04-27
SHELL := /bin/bash
# Set to 0 for PlanetProfile versions using Refprop
refprop=1
mbodies="Ariel" "Callisto" "Dione" "Enceladus" "Europa" "Ganymede" "Io" "Mimas" "Miranda" "Oberon" "Pluto" "Rhea" "Titan" "Titania" "Triton" "Umbriel" "PlanetProfile/Test"
comp="Comparison"
figs="figures"
inductfigs="induction"
inductdata="inductionData"
seisdata="seismicData"
cdpp=cd $(shell pwd)
foundmatlab=1
windows=1
# Check for likely install locations
ifeq ($(shell [ -d /Applications/MATLAB* ] ; echo $$?),0)
# Mac OS
matlabdir=/Applications/MATLAB*
foundmatlab=0
else ifeq ($(shell [ -d /mnt/c/Program\ Files/MATLAB* ] ; echo $$?),0)
# Windows
windows=0
matlabdir=/mnt/c/Program\ Files/MATLAB/*
driveltr=$(shell ppdir=$$(pwd) ; echo $${ppdir:5:1} | tr "[:lower:]" "[:upper:]")
rempath=$(shell ppdir=$$(pwd) ; echo $${ppdir:6})
cdpp=cd $(driveltr):$(rempath)
foundmatlab=0
else ifeq ($(shell [ -d /mnt/c/Program\ Files\ \(x86\)/MATLAB* ] ; echo $$?),0)
# Windows
windows=0
matlabdir=/mnt/c/Program\ Files\ \(x86\)/MATLAB/*
driveltr=$(shell ppdir=$$(pwd) ; echo $${ppdir:5:1} | tr "[:lower:]" "[:upper:]")
rempath=$(shell ppdir=$$(pwd) ; echo $${ppdir:6})
cdpp=cd $(driveltr):$(rempath)
foundmatlab=0
else ifeq ($(shell [ -d /usr/local/MATLAB/* ] ; echo $$?),0)
# Linux
matlabdir=/usr/local/MATLAB/*
foundmatlab=0
else ifeq ($(shell [ -d $$HOME/usr/local/MATLAB/* ] ; echo $$?),0)
# Linux
matlabdir=$$HOME/usr/local/MATLAB/*
foundmatlab=0
else
# Non-standard installation location. Make the user find the right spot.
foundmatlab=1
endif
matlabsupath=$(shell find $(matlabdir)/toolbox/local -maxdepth 0 -type d)
default:
@echo "Pass arguments to 'make' for one of the functions described below."
@echo "Your command line argument should look like: make command"
@echo
@echo "<no command>: Print this list."
@echo "install: Copy necessary files for running PlanetProfile"
@echo " and set default Matlab path."
@echo "uninstall: Remove files outside the PlanetProfile directory"
@echo " that were placed by 'install'."
@echo "clean: Remove files ignored by GitHub (output data and figures)."
@echo
clean:
@bodies=($(mbodies)) ; \
echo "Clearing data and figure files for:" $${bodies[@]} ; \
for body in $${bodies[@]} ; do \
if [ "$$body" = "PlanetProfile/Test" ] ; then \
bname="Test" ; \
else \
bname=$$body ; \
fi ; \
rm -f $$body/*.dat $$body/*.txt $$body/*.mat $$body/*.asv ; \
rm -f $$body/$(inductdata)/*.dat $$body/$(inductdata)/$(bname)*.mat $$body/$(inductdata)/*.asv ; \
rm -fd $$body/$(seisdata)/*.bm $$body/$(seisdata)/*/velmodel $$body/$(seisdata)/*/yannos.dat $$body/$(seisdata)/$(bname)* ; \
rm -f $$body/$(figs)/*.eps $$body/$(figs)/*.fig $$body/$(figs)/*.png $$body/$(figs)/*.pdf ; \
rm -f $$body/$(figs)/$(inductfigs)/*.eps $$body/$(figs)/$(inductfigs)/*.fig $$body/$(figs)/$(inductfigs)/*.png $$body/$(figs)/$(inductfigs)/*.pdf ; \
done ; \
rm -f $(comp)/*.eps $(comp)/*.fig $(comp)/*.png $(comp)/*.pdf $(comp)/*.txt ; \
rm -f $(comp)/$(inductfigs)/*.eps $(comp)/$(inductfigs)/*.fig $(comp)/$(inductfigs)/*.png $(comp)/$(inductfigs)/*.pdf
install:
# Copy Refprop files and libraries into system folders
ifeq ($(refprop),0)
mkdir -p /opt/refprop
cp Thermodynamics/librefprop.so-master/librefprop.dylib /opt/
mkdir -p /opt/refprop/fluids /opt/refprop/mixtures
cp Thermodynamics/librefprop.so-master/files/*.fld /opt/refprop/fluids/
cp Thermodynamics/librefprop.so-master/files/*.mix /opt/refprop/mixtures/
endif
@# Get list of PlanetProfile directories containing important files
@# and print them into a file named startup.m
@# First, check if SeaFreeze is installed and grab it if not
@SeaFinstalled=$$(find Thermodynamics/SeaFreeze/* | wc -l) ; \
if [[ $$SeaFinstalled -eq 2 ]] ; then \
echo "SeaFreeze has not been installed yet." ; \
read -p "Would you like to install it now using git? ([Y]/n)" doSeaFinstall ; \
if [[ "$$doSeaFinstall" =~ ^([nN][oO]|[nN])$$ ]] ; then \
SeaFinstalled=-1 ; \
else \
git clone git@github.com:Bjournaux/SeaFreeze.git Thermodynamics/SeaFreeze/SeaFreeze && SeaFinstalled=0 ; \
fi ; \
else \
SeaFinstalled=0 ; \
fi ; \
pathdirs=($$(find * -type d -not -path *version* -not -path *.git* -not -path *Python*)) ; \
echo "$(cdpp)" > startup.m ; \
for subdir in $${pathdirs[@]} ; do \
echo "addpath('$$subdir')" >> startup.m ; \
done ; \
echo "addpath(fullfile('$(shell pwd)/Utilities/mice/src/mice/'))" >> startup.m ; \
echo "addpath(fullfile('$(shell pwd)/Utilities/mice/lib/'))" >> startup.m ; \
if [[ $$SeaFinstalled -eq -1 ]] ; then \
echo "WARNING: SeaFreeze was not installed when the startup path" ; \
echo " file was created. Delete startup.m from the Matlab" ; \
echo " toolbox/local directory and run make install again after" ; \
echo " installing SeaFreeze in order to add it to the startup path." ; \
fi
ifeq ($(foundmatlab),1)
@echo "WARNING: Your Matlab install location was not found."
@echo "Copy the file named startup.m from the PlanetProfile"
@echo " directory to the Matlab toolbox/local directory"
@echo " to complete installation."
@echo
@echo "Next, in Matlab, go to:"
@echo " Preferences -> Matlab -> General -> Toolbox path caching"
@echo " and click on the button for Update Toolbox Path Cache."
@echo "Then, at the Matlab command prompt, run the startup command, or close and"
@echo " relaunch, to automatically add PlanetProfile dirs to your Matlab path."
else ifeq ($(windows),0)
@# Windows folders are most often not writable. Make the user do it.
@echo "To complete installation, copy startup.m from the PlanetProfile"
@echo " directory into your Matlab toolbox/local directory at:"
@echo " $(matlabsupath)"
@echo " "
@echo "Next, in Matlab, go to:"
@echo " Preferences -> Matlab -> General -> Toolbox path caching"
@echo " and click on the button for Update Toolbox Path Cache."
@echo "Then, at the Matlab command prompt, run the startup command, or close and"
@echo " relaunch, to automatically add PlanetProfile dirs to your Matlab path."
else
@echo "Matlab toolbox/local found: $(matlabsupath)"
@# Check if the Matlab startup file exists, and if so, if it's just for PlanetProfile
@# so we can avoid duplicates.
@if cmp -s startup.m "$(matlabsupath)"/startup.m ; then \
echo "Matlab startup file for PlanetProfile is already in place:" ; \
echo " $(matlabsupath)/startup.m" ; \
elif [ ! -f "$(matlabsupath)"/startup.m ] ; then \
cp startup.m "$(matlabsupath)"/startup.m ; \
echo "Attempted to create Matlab startup file with PlanetProfile dirs in path:" ; \
echo " $(matlabsupath)/startup.m" ; \
else \
cat startup.m >> "$(matlabsupath)"/startup.m ; \
echo "PlanetProfile dirs appended to Matlab path in startup file:" ; \
echo " $(matlabsupath)/startup.m" ; \
fi
@rm startup.m
@echo " "
@echo "Installation finished. If errors ocurred above or if startup.m is"
@echo " still in the PlanetProfile directory, paste into the Matlab"
@echo " toolbox/local/ dir."
@echo " "
@echo "Next, in Matlab, go to:"
@echo " Preferences -> Matlab -> General -> Toolbox path caching"
@echo " and click on the button for Update Toolbox Path Cache."
@echo "Then, at the Matlab command prompt, run the startup command, or close and"
@echo " relaunch, to automatically add PlanetProfile dirs to your Matlab path."
endif
uninstall:
# Delete Refprop files we may have placed
ifeq ($(refprop),0)
rm /opt/librefprop.dylib
rm /opt/refprop/fluids/*.fld
rm /opt/refprop/mixtures/*.mix
rmdir /opt/refprop/fluids /opt/refprop/mixtures
rmdir /opt/refprop
@echo "Refprop files removed."
endif
ifeq ($(foundmatlab),1)
@echo "WARNING: Your Matlab install location was not found."
@echo "Delete the PlanetProfile lines added to your Matlab"
@echo " startup file at MATLAB/toolbox/local/startup.m"
@echo " and delete this repository to complete uninstall."
else
@# Recreate startup.m file to check against the one Matlab is using
@pathdirs=($$(find * -type d -not -path *version* -not -path *input*)) ; \
echo "$(cdpp)" > startup.m ; \
for subdir in $${pathdirs[@]} ; do \
echo "addpath('$$subdir')" >> startup.m ; \
done
@# If the Matlab startup.m file matches the one we just made, it exists only
@# for PlanetProfile. Delete it to return the system to its initial state.
@# Otherwise, startup.m has been modified by the user, so we should not touch it.
@if cmp -s startup.m "$(matlabsupath)"/startup.m ; then \
rm "$(matlabsupath)"/startup.m ; \
echo "Attempted to remove Matlab startup.m." ; \
elif [ ! -f "$(matlabsupath)"/startup.m ] ; then \
echo "There was no Matlab startup file in $(matlabsupath)." ; \
echo "Was PlanetProfile installed before uninstalling?" ; \
else \
echo "$(matlabsupath)/startup.m contains more than just the PlanetProfile path." ; \
echo "Matlab startup.m not modified." ; \
fi
@# Get rid of our checking file
@rm startup.m
@echo
@echo "Uninstall complete, assuming no errors occurred above."
@echo "Delete this directory and all subdirectories to complete uninstall."
@echo
endif
pypi:
# Package files for PyPI (pip installation)
@# Delete contents of dist folder
@if [ -d dist ] ; then \
echo "Removing the contents of dist/ dir." ; \
rm -r dist ; \
fi
@# Ensure pip, setuptools, wheel, and twine are the latest versions
@pip install --upgrade pip
@pip install --upgrade setuptools wheel build twine
@# Build the distro based on info in setup.py and MANIFEST.in
@python -m build
@echo "Barring errors above, package build is complete."
@echo "Upload the .tar.gz file in dist/ as a new release on GitHub and run the following"
@echo "command to update the package in PyPI (authorized users only, use __token__):"
@echo "python -m twine upload dist/* --verbose"