-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·171 lines (142 loc) · 4.02 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
#!/bin/bash
# ******************** variables ****************
CFG_ARGS="$0 $1 $2 $3 $4 $5 $6 $7 $8 $9"
ARG_BEQUIET=0
ARG_PREFIX=""
ARG_CFGMAKE="$PWD/config.make"
ARG_WITH_DEBUG=1
ARG_WITH_STRIP=1
ARG_WITH_PGCONFIG=1
ARG_PGCONFIG="NOTSET"
# ******************** usage ********************
function usage() {
cat <<_ACEOF
\`configure' configures PL/Swift.
Usage: $0 [OPTION]...
Configuration:
-h, --help display this help and exit
-q, --quiet, --silent do not print \`checking...' messages
Installation directories:
--prefix=PREFIX install files in PREFIX [/usr/local]
--enable-debug turn on debugging and compile time warnings
--enable-strip turn on stripping of debug symbols
--with-pgconfig=PATH location of pg_config [which pg_config]
_ACEOF
exit 0;
}
# ******************** running ********************
function cfgwrite() {
echo "$1" >> $ARG_CFGMAKE
}
function genConfigMake() {
if [[ $ARG_BEQUIET != 1 ]]; then
echo "creating: $ARG_CFGMAKE"
fi
echo "# PL/Swift configuration" > $ARG_CFGMAKE
cfgwrite "# created by: '$CFG_ARGS'"
cfgwrite ""
cfgwrite "# Note: you can override any option as a 'make' parameter, eg:"
cfgwrite "# make debug=yes"
cfgwrite ""
if [[ $ARG_WITH_DEBUG = 1 ]]; then
cfgwrite "# configured to produce debugging code";
cfgwrite "debug:=yes"
else
cfgwrite "# configured to produce non-debugging code";
cfgwrite "debug:=no"
fi
cfgwrite ""
if [[ $ARG_WITH_STRIP = 1 ]]; then
cfgwrite "# configured to produce stripped code";
cfgwrite "strip:=yes"
else
cfgwrite "# configured not to strip code";
cfgwrite "strip:=no"
fi
cfgwrite ""
cfgwrite "# enforce shared libraries";
cfgwrite "shared:=yes"
cfgwrite ""
if [ -n "${ARG_PGCONFIG}" ]; then
cfgwrite "PG_CONFIG:=${ARG_PGCONFIG}"
cfgwrite ""
fi
if [ -n "$ARG_PREFIX" ]; then
cfgwrite "prefix:=${ARG_PREFIX}"
cfgwrite ""
fi
}
function runIt() {
if [[ "${ARG_PGCONFIG}" = "NOTSET" ]]; then
ARG_PGCONFIG="`which pg_config`";
fi
if [[ -z "${ARG_PGCONFIG}" ]]; then
# we want to pickup from the users PATH to work "properly" within
# homebrew (which patches the path)
ARG_PGCONFIG="$(bash -l -c "which pg_config")"
fi
if [[ -z "${ARG_PGCONFIG}" ]]; then
if [[ -x "/usr/local/bin/pg_config" ]]; then
ARG_PGCONFIG="/usr/local/bin/pg_config"
echo "Using pg_config found here: ${ARG_PGCONFIG}"
elif [[ -d "/Applications/Postgres.app/Contents/Versions" ]]; then
# this is a little well
LATEST_VER="$(ls /Applications/Postgres.app/Contents/Versions | sort -r | head -n 1)"
if [[ -x "/Applications/Postgres.app/Contents/Versions/${LATEST_VER}/bin/pg_config" ]]; then
ARG_PGCONFIG="/Applications/Postgres.app/Contents/Versions/${LATEST_VER}/bin/pg_config"
echo "Using pg_config from PostgreSQL.app: ${ARG_PGCONFIG}"
fi
fi
fi
if [ -z "$ARG_PREFIX" ]; then
ARG_PREFIX=/usr/local
fi
if [[ ! -x "${ARG_PGCONFIG}" ]]; then
echo >&2 "Could not locate pg_config! ${ARG_PGCONFIG}"
exit 42;
fi
genConfigMake;
}
# ******************** options ********************
function extractFuncValue() {
VALUE="`echo "$1" | sed "s/[^=]*=//g"`"
}
function processOption() {
case "x$1" in
"x--help"|"x-h")
usage;
;;
"x--quiet"|"x--silent"|"x-q") ARG_BEQUIET=1; ;;
x--prefix=*)
extractFuncValue $1;
ARG_PREFIX="$VALUE";
;;
x--with-pgconfig=*)
extractFuncValue $1;
ARG_PGCONFIG="$VALUE";
;;
"x--with-pgconfig")
ARG_PGCONFIG="`which pg_config`";
;;
"x--without-pgconfig")
ARG_PGCONFIG="";
;;
"x--enable-debug")
ARG_WITH_DEBUG=1
;;
"x--disable-debug")
ARG_WITH_DEBUG=0
;;
"x--enable-strip")
ARG_WITH_STRIP=1
;;
"x--disable-strip")
ARG_WITH_STRIP=0
;;
*) echo "error: cannot process argument: $1"; exit 1; ;;
esac
}
for i in $@; do
processOption $i;
done
runIt