-
Notifications
You must be signed in to change notification settings - Fork 9
/
configure
executable file
·201 lines (180 loc) · 5.61 KB
/
configure
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
#! /bin/sh
#
# Configuration script for MiRA software.
#
#------------------------------------------------------------------------------
#
# This file is part of MiRA: a Multi-aperture Image Reconstruction
# Algorithm <https://github.com/emmt/MiRA>.
#
# Copyright (C) 2016, Éric Thiébaut.
#
# MiRA is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 as published by the Free
# Software Foundation.
#
# MiRA is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
#------------------------------------------------------------------------------
cfg_progname=$(basename "$0")
cfg_topdir=$(dirname "$0")
cfg_tmpdir=$cfg_topdir
cfg_tmpfile="$cfg_tmpdir/cfg-$$"
cfg_debug=no
cfg_on_exit () {
if test "$cfg_debug" = "no"; then
rm -f "$cfg_tmpfile" "$cfg_tmpfile.i"
fi
}
trap cfg_on_exit 0
cfg_die () { echo >&2 "$cfg_progname: $*"; exit 1; }
cfg_opt_value () { echo "$*" | sed -e 's/^--[^=]*=//'; }
cfg_help () {
cat <<EOF
usage: $cfg_progname [-h|--help] [--yorick=PATH_TO_YORICK]
options:
--yorick=PATH Path to Yorick executable [$cfg_yorick].
--prefix=PATH Prefix for installation [$cfg_prefix].
--incdir=DIR Destination directory for MiRA code files [Y_SITE/i].
--bindir=DIR Destination directory for MiRA executable [$cfg_bindir].
--mandir=DIR Destination directory for man pages [$cfg_mandir].
--arch=OS-CPU Architecture [$cfg_arch].
--debug Turn debug mode on (for this script).
-h, --help Print this help and exit.
EOF
}
if cmp -s "./Makefile" "$cfg_topdir/Makefile"; then
cfg_inplace=yes
else
cfg_inplace=no
fi
cfg_os=$(uname -s | tr A-Z a-z)
if test -z "$cfg_os"; then
cfg_os="unknown"
fi
cfg_cpu=$(uname -m | tr A-Z a-z)
if test -z "$cfg_cpu"; then
cfg_cpu="unknown"
else
case "$cfg_cpu" in i?86 ) cfg_cpu="ix86";; esac
fi
cfg_arch=${cfg_os}-${cfg_cpu}
cfg_yorick=yorick
cfg_prefix=
cfg_incdir=
cfg_bindir=
cfg_mandir=
while test $# -ge 1; do
cfg_arg=$1
shift
case "$cfg_arg" in
-h | --help )
cfg_help
exit 0
;;
--debug)
cfg_debug=yes
;;
--prefix=*)
cfg_prefix=$(cfg_opt_value "$cfg_arg")
case "$cfg_prefix" in
/*) ;;
*) cfg_prefix=$(pwd -P)/$cfg_prefix;;
esac
test -z "$cfg_bindir" && cfg_bindir="$cfg_prefix/bin"
test -z "$cfg_mandir" && cfg_mandir="$cfg_prefix/share/man"
;;
--yorick=*)
cfg_yorick=$(cfg_opt_value "$cfg_arg")
;;
--incdir=*)
cfg_incdir=$(cfg_opt_value "$cfg_arg")
;;
--bindir=*)
cfg_bindir=$(cfg_opt_value "$cfg_arg")
;;
--mandir=*)
cfg_mandir=$(cfg_opt_value "$cfg_arg")
;;
*)
cfg_die "Unknown option \"$cfg_arg\""
esac
done
case "$cfg_arch" in
mswin|mswin-*) cfg_exe_sfx=".exe";;
*) cfg_exe_sfx=""
esac
# Search Yorick in PREFIX/bin or in PATH.
if test "$cfg_yorick" = "yorick" \
-a ! -z "$cfg_prefix" \
-a -x "$cfg_prefix/bin/yorick$cfg_exe_sfx"; then
cfg_yorick="$cfg_prefix/bin/yorick$cfg_exe_sfx"
fi
if test "$cfg_yorick" = "yorick"; then
cfg_save_IFS=$IFS
IFS=":"
for cfg_dir in $PATH; do
cfg_file=$cfg_dir/yorick$cfg_exe_sfx
if test -r "$cfg_file" -a -x "$cfg_file" -a ! -d "$cfg_file"; then
cfg_yorick=$cfg_file
break
fi
done
IFS=$cfg_save_IFS
fi
if test "$cfg_yorick" = "yorick" \
-o ! -f "$cfg_yorick" \
-o ! -x "$cfg_yorick"; then
echo >&2 "Yorick executable not found."
echo >&2 "Try to specify the path with option --yorick=..."
exit 1
fi
echo >&2 "Yorick executable --------------> $cfg_yorick"
# Get the Y_HOME and Y_SITE variables.
cat >"$cfg_tmpfile.i" <<"EOF"
write, format = "Y_HOME=%s\nY_SITE=%s\n", Y_HOME, Y_SITE;
quit;
EOF
"$cfg_yorick" -batch "$cfg_tmpfile.i" > "$cfg_tmpfile"
cfg_yhome=$(sed < "$cfg_tmpfile" -e '/^Y_HOME=/!d;s/^Y_HOME=//' -e 's,/*$,/,')
cfg_ysite=$(sed < "$cfg_tmpfile" -e '/^Y_SITE=/!d;s/^Y_SITE=//' -e 's,/*$,/,')
cfg_ymkdir=$cfg_yhome
echo >&2 "Yorick home directory ----------> $cfg_yhome"
echo >&2 "Yorick site directory ----------> $cfg_ysite"
if test "x$cfg_incdir" = "x"; then
cfg_incdir=${cfg_ysite}i
fi
echo >&2 "MiRA code files directory ------> $cfg_incdir"
if test "x$cfg_bindir" = "x"; then
cfg_bindir_mesg="(will not be installed)"
else
cfg_bindir_mesg="$cfg_bindir"
fi
echo >&2 "MiRA executable directory ------> $cfg_bindir_mesg"
if test "x$cfg_mandir" = "x"; then
cfg_mandir_mesg="(will not be installed)"
else
cfg_mandir_mesg="$cfg_mandir"
fi
echo >&2 "MiRA manual pages --------------> $cfg_mandir_mesg"
# Create the configration file.
cfg_dst="./install.cfg"
cat >"$cfg_dst" <<EOF
# Configuration for installing MiRA software.
# INCDIR is the directory where to install MiRA code source (nothing is
# installed if empty).
INCDIR=$cfg_incdir
# BINDIR is the directory where to install MiRA command (nothing is installed
# if empty).
BINDIR=$cfg_bindir
# MANDIR is the directory where to install MiRA manual pages (nothing is
# installed if empty).
MANDIR=$cfg_mandir
# YORICK is the path for Yorick interpreter.
YORICK=$cfg_yorick
EOF
echo >&2 "Installation settings ----------> $cfg_dst"
#------------------------------------------------------------------------------