This repository was archived by the owner on Feb 15, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·195 lines (165 loc) · 4.49 KB
/
Copy pathconfigure
File metadata and controls
executable file
·195 lines (165 loc) · 4.49 KB
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
#!/bin/bash -f
# This script writes a configuration file for use in compilation of pyXFlow.
# The script attempts, as best it can, to write a machine-specific
# configuration file. However, the resulting 'PX_CONFIG' file can be edited
# as necessary for non-standard machines.
#
# For the most part, success will depend on the availability of the necessary
# Python libraries and utilities. In addition, a compiled and working XFlow
# library must also be available.
# Versions:
# 2013-12-13 @dalle : Derived from XFlow configure script
# Configuration file
outfile="config.cfg"
# Script log file
logfile="configure.log"
# Script name
scriptname="$0"
# Operating system
os=$(uname)
# Functions
# Print to screen, and append message to the logfile.
echo_t() { echo "$@" | tee -a $logfile; }
# Print help information
usage() {
echo_t " pyXFlow configuration script."
echo_t " "
echo_t " USAGE: $0 [options]"
echo_t " "
echo_t " Available options:"
echo_t " (list of possible options between '|', with default"
echo_t " option in {} characters)"
echo_t " "
echo_t " -xflow [ {$HOME/xflow} | path/to/xflow ]"
echo_t " Path to base folder (that contains lib/ and bin/)"
echo_t " "
echo_t " -python [ python | {python2} | python3 ]"
echo_t " Python executable name"
echo_t " "
echo_t " -help | -h"
echo_t " Display this guide and exit"
echo_t " "
echo_t " "
echo_t " Examples:"
echo_t " "
echo_t " The most basic call will use all the defaults."
echo_t " \$ ./configure"
echo_t " "
echo_t " Picking the version of XFlow and Python."
echo_t " \$ ./configure -xflow ${HOME}/path/to/xflow -python /usr/local/bin/python2.7"
echo_t " "
}
exit_ok() { exit 0; }
exit_fail() { exit 1; }
newline() { echo_t " "; }
unknown_option() {
echo_t " Unknown input option!"
echo_t " See $scriptname -help for valid options"
exit_fail
}
get_option() {
grep "^ *$2" $1 | awk -F'=' '{ print $2 }' | sed -e 's/^ *//g' -e 's/ *$//g'
}
get_python_ver() {
$1 --version 2>&1 | awk '{ print $2 }' | cut -d. -f1-2
}
# Set default options.
xflow_home="$HOME/xflow"
python_exec="python2"
# Clear the old logfile and touch it
if [[ -e $logfile ]]; then
rm $logfile
touch $logfile
fi
# Clear the old outfile and touch it
if [[ -e $outfile ]]; then
rm $outfile
touch $outfile
fi
# Display the header
echo_t " * pyXFlow configuration script"
echo_t " Invoked with:"
echo_t " $scriptname $@"
echo_t " "
# If we run without options, make sure we know -help displays them
if [[ "$#" == 0 ]]; then
echo_t " Running without options"
echo_t " To show options, run with $scriptname -help"
echo_t " "
fi
# Process the options
while [[ $1 ]]; do
case $1 in
-xflow | --xflow )
shift
xflow_home="$1"
shift
;;
-python | --python )
shift
python_exec="$1"
shift
;;
-help | -h | --help)
usage
exit_ok
;;
*)
unknown_option
;;
esac
done
# Get python version
python_ver=$(get_python_ver $python_exec)
# Compiler options
cc=$(get_option ${xflow_home}/XF_CONFIG CC)
extra_cflags=$(get_option ${xflow_home}/XF_CONFIG CFLAGS)
extra_ldflags=
#if [ "$os" = "Darwin" ]; then
# extra_ldflags="-undefined dynamic_lookup"
#fi
#$(get_option ${xflow_home}/XF_CONFIG DYNLDFLAGS)
# Linker options for pyxflow equation sets
# --no-as-needed is required for the linux linker
# since it now defaults to --as-needed
if [ "$os" = "Linux" ]; then
eqnset_extra_ldflags="-shared -Wl,--no-as-needed"
elif [ "$os" = "Darwin" ]; then
eqnset_extra_ldflags="-dynamiclib"
fi
# Need to ensure we are building for relatively recent versions of OS X
#if [ "$os" = "Darwin" ]; then
# ldflags=${ldflags}" -mmacosx-version-min=10.5"
#fi
# Unused for now
extra_include_dirs=
extra_libs=
# Inform user of options
echo_t " Configuration settings"
echo_t " * Operating system is $os"
newline
echo_t " * Python version is $python_ver"
newline
echo_t " * XFlow path is $xflow_home"
newline
echo_t " * CC = $cc"
echo_t " * CFLAGS = $cflags"
newline
echo_t " See config.cfg for all settings"
echo_t
echo_t " $extra_cflags"
# Start writing configuration file
cat > $outfile <<EOF
[python]
exec = $python_exec
version = $python_ver
[xflow]
home = $xflow_home
extra_libs = $extra_libs
[compiler]
cc = $cc
extra_cflags = $extra_cflags
extra_ldflags = $extra_ldflags
eqnset_extra_ldflags = $eqnset_extra_ldflags
extra_include_dirs = $extra_include_dirs
EOF