forked from fortran-lang/fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·70 lines (59 loc) · 1.65 KB
/
install.sh
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
#!/bin/sh
set -e # exit on error
usage()
{
echo "Fortran Package Manager Bootstrap Script"
echo ""
echo "USAGE:"
echo "./install.sh [--help | [--prefix=PREFIX]"
echo ""
echo " --help Display this help text"
echo " --prefix=PREFIX Install binary in 'PREFIX/bin'"
echo " Default prefix='\$HOME/.local/bin'"
echo ""
echo "FC and FFLAGS environment variables can be used to select the"
echo "Fortran compiler and the build flags."
echo ""
}
PREFIX="$HOME/.local"
while [ "$1" != "" ]; do
PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in
-h | --help)
usage
exit
;;
--prefix)
PREFIX=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
set -u # error on use of undefined variable
SOURCE_URL="https://github.com/fortran-lang/fpm/releases/download/v0.3.0/fpm-0.3.0.F90"
BOOTSTRAP_DIR="build/bootstrap"
if [ -z ${FC+x} ]; then
FC="gfortran"
fi
if [ -z ${FFLAGS+x} ]; then
FFLAGS="-g -fbacktrace -O3"
fi
mkdir -p $BOOTSTRAP_DIR
if command -v curl > /dev/null 2>&1; then
FETCH="curl -L"
elif command -v wget > /dev/null 2>&1; then
FETCH="wget -O -"
else
echo "No download mechanism found. Install curl or wget first."
exit 1
fi
$FETCH $SOURCE_URL > $BOOTSTRAP_DIR/fpm.F90
$FC $FFLAGS -J $BOOTSTRAP_DIR $BOOTSTRAP_DIR/fpm.F90 -o $BOOTSTRAP_DIR/fpm
$BOOTSTRAP_DIR/fpm install --compiler "$FC" --flag "$FFLAGS" --prefix "$PREFIX"
rm -r $BOOTSTRAP_DIR