-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathconfigure
executable file
·212 lines (191 loc) · 5.43 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
202
203
204
205
206
207
208
209
210
211
212
#! /bin/sh
#
# Configuration script for a Yorick plugin.
#
#-------------------------------------------------------------------------------
#
# Copyright (C) 2015: Éric Thiébaut <[email protected]>
#
#-------------------------------------------------------------------------------
# The following default values are specific to the package. They can be
# overwritten by options on the command line.
cfg_cflags=
cfg_deplibs='-lgfortran'
cfg_ldflags=
cfg_fc='gfortran'
cfg_fflags='-O2 -Wall'
# The other values are pretty general.
cfg_tmpdir=.
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_progname=$0
cfg_srcdir=$(dirname "$0")
#cfg_path=$(readlink -fn "$@")
#cfg_srcdir=$(dirname "$cfg_path")
cfg_die () { echo >&2 "$cfg_progname: $*"; exit 1; }
cfg_opt_value () { echo "$*" | sed -e 's/^--[^=]*=//'; }
cfg_despace () { echo "$*" | sed -e 's/ /\\ /g'; }
cfg_add_rule () {
local s t
s=$*
for t in "/" "%" "@" "," "-"; do
case "$s" in
*$t* )
;;
* )
break
esac
done
if test "$t" = "-"; then
cfg_die "No valid separator found"
fi
s='[ ]*'
s="s${t}^${s}${1}${s}=.*${t}${1}=${2}${t}"
if test "x$cfg_filter" = "x"; then
cfg_filter="$s"
else
cfg_filter="$cfg_filter;$s"
fi
}
cfg_help () {
cat <<EOF
usage: $cfg_progname [-h|--help] [--yorick=PATH_TO_YORICK]
options:
--arch=OS-CPU Architecture [$cfg_arch].
--yorick=PATH Path to Yorick executable [$cfg_yorick].
--cflags=CFLAGS Additional compiler flags [$cfg_cflags], for instance:
--cflags='-Isomedir'
--deplibs=DEPLIBS Flags for dependencies [$cfg_deplibs], for instance:
--deplibs='-Lsomedir -lsomelib'
--ldflags=LDFLAGS Additional linker flags [$cfg_ldflags].
--fc=FC FORTRAN-77 compiler [$cfg_fc].
--fflags=FFLAGS Additional FORTRAN-77 compiler flags [$cfg_fflags].
--debug Turn debug mode on (for this script).
-h, --help Print this help and exit.
EOF
}
if cmp -s "./Makefile" "$cfg_srcdir/Makefile"; then
cfg_inplace=yes
else
cfg_inplace=no
fi
cfg_os=$(uname -s | tr A-Z a-z)
if test "x$cfg_os" = "x"; then
cfg_os="unknown"
fi
cfg_cpu=$(uname -m | tr A-Z a-z)
if test "x$cfg_cpu" = "x"; 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=/usr/local
while test $# -ge 1; do
cfg_arg=$1
shift
case "$cfg_arg" in
-h | --help )
cfg_help
exit 0
;;
--debug)
cfg_debug=yes
;;
--arch=*)
cfg_arch=$(cfg_opt_value "$cfg_arg")
;;
--cflags=*)
cfg_cflags=$(cfg_opt_value "$cfg_arg")
;;
--deplibs=*)
cfg_deplibs=$(cfg_opt_value "$cfg_arg")
;;
--ldflags=*)
cfg_ldflags=$(cfg_opt_value "$cfg_arg")
;;
--fc=*)
cfg_fc=$(cfg_opt_value "$cfg_arg")
;;
--fflags=*)
cfg_fflags=$(cfg_opt_value "$cfg_arg")
;;
--yorick=*)
cfg_yorick=$(cfg_opt_value "$cfg_arg")
;;
*)
cfg_die "Unknown option \"$cfg_arg\""
esac
done
case "$cfg_arch" in
mswin )
cfg_exe_sfx=.exe
;;
* )
cfg_exe_sfx=
esac
# Search Yorick in the path:
if test "x$cfg_yorick" = "xyorick"; 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 "x$cfg_yorick" = "xyorick" \
-o ! -f "$cfg_yorick" \
-o ! -x "$cfg_yorick"; then
echo >&2 "Yorick excutable 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=//')
cfg_ysite=$(sed < "$cfg_tmpfile" -e '/^Y_SITE=/!d;s/^Y_SITE=//')
cfg_ymkdir=$cfg_yhome
echo >&2 "Yorick home directory ----> $cfg_yhome"
echo >&2 "Yorick site directory ----> $cfg_ysite"
# Create the Makefile.
cfg_dst="./Makefile"
if test "$cfg_inplace" = "yes"; then
cfg_src="$cfg_dst.bak"
mv -f "$cfg_dst" "$cfg_src"
else
cfg_src="$cfg_srcdir/Makefile"
fi
cfg_filter=""
cfg_add_rule "Y_EXE" "$cfg_yorick"
cfg_add_rule "Y_MAKEDIR" "$cfg_ymkdir"
cfg_add_rule "Y_EXE_HOME" "$cfg_yhome"
cfg_add_rule "Y_EXE_SITE" "$cfg_ysite"
cfg_add_rule "PKG_CFLAGS" "$cfg_cflags"
cfg_add_rule "PKG_DEPLIBS" "$cfg_deplibs"
cfg_add_rule "PKG_LDFLAGS" "$cfg_ldflags"
cfg_add_rule "FC" "$cfg_fc"
cfg_add_rule "FFLAGS" "$cfg_fflags"
cfg_add_rule "srcdir" "$cfg_srcdir"
sed < "$cfg_src" > "$cfg_dst" -e "$cfg_filter"
if test "$cfg_inplace" = "yes"; then
rm -f "$cfg_src"
fi
echo "Makefile has been updated."
echo "You can run 'make' and 'make install' now."
#------------------------------------------------------------------------------