This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure
executable file
·311 lines (276 loc) · 9.72 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#!/bin/sh
#/ Usage: ./configure [OPTION]... [VAR=VALUE]...
#/ configure rpg for installation on this system.
#/
#/ Options
#/ --with-ruby[=RUBY] tie to specific ruby installation. RUBY is
#/ path to ruby executable.
#/ --development configure for local working copy development
#/
#/ Installation locations
#/ --prefix=PREFIX install files in PREFIX [/usr/local]
#/ --bindir=DIR user executables [PREFIX/bin]
#/ --libexecdir=DIR program executables [PREFIX/libexec]
#/ --sysconfdir=DIR system configuration files [PREFIX/etc]
#/ --datarootdir=DIR data file root [PREFIX/share]
#/ --datadir=DIR data files [DATAROOTDIR]
#/ --mandir=DIR man documentation [DATAROOTDIR/man]
#/ --rpgdir=DIR rpg package and db root [RUBYLIBDIR/rpg]
warn () { echo "$(basename $0):" "$@" 1>&2; }
longarg () { echo "$1" | sed "s/^$2=//"; }
# Argument Parsing
# ----------------
sourcedir="$(cd "$(dirname $0)" && pwd)"
develmode=false
tiedown=false
while test $# -gt 0
do
case "$1" in
# Options
--with-ruby) RUBY="ruby"
tiedown=true
specified_ruby=
shift;;
--with-ruby=*) RUBY=$(longarg "$1" --with-ruby)
tiedown=true
specified_ruby="$RUBY"
shift;;
--develop|--development)
prefix="$sourcedir/work"
bindir="$sourcedir"
libexecdir="$sourcedir"
localstatedir="$prefix"
sysconfdir="$sourcedir"
datarootdir="$sourcedir"
datadir="$sourcedir"
mandir="$sourcedir/man"
develmode=true
shift
;;
# Installation locations:
--prefix) prefix="$2";shift 2;;
--prefix=*) prefix="$(longarg "$1" --prefix)";shift;;
--bindir) bindir="$2";shift 2;;
--bindir=*) bindir="$(longarg "$1" --bindir)";shift;;
--libexecdir) libexecdir="$2";shift 2;;
--libexecdir=*) libexecdir="$(longarg "$1" --libexecdir)";shift;;
--localstatedir) localstatedir="$2";shift 2;;
--localstatedir=*) localstatedir="$(longarg "$1" --localstatedir)";shift;;
--sysconfdir) sysconfdir="$2";shift 2;;
--sysconfdir=*) sysconfdir="$(longarg "$1" --sysconfdir)";shift;;
--datarootdir) datarootdir="$2";shift 2;;
--datarootdir=*) datarootdir="$(longarg "$1" --datarootdir)";shift;;
--datadir) datadir="$2";shift 2;;
--datadir=*) datadir="$(longarg "$1" --datadir)";shift;;
--mandir) mandir="$2";shift 2;;
--mandir=*) mandir="$(longarg "$1" --mandir)";shift;;
--rpgdir) rpgdir="$2";shift 2;;
--rpgdir=*) rpgdir="$(longarg "$1" --rpgdir)";shift;;
# Environment variables passed on command line:
[A-Z]*=*) name="${1%%=*}"
value="${1#*=}"
shift
eval "${name}='${value}'";;
# Bail out with usage otherwise.
*) grep '^#/' < "$0" | cut -c4-
exit 2;;
esac
done
# Finding Stuff Functions
# -----------------------
looking () { printf "looking %s" "$*"; }
ok () { printf " OK\n"; }
missing () { printf " (missing)\n"; }
found () {
printf " (${1:-found})"
test -n "$2" && printf " $2"
printf "\n"
}
have () {
for f in "$@"
do
# if a whole command line was given, assume it exists
expr "$f" : '..* ' >/dev/null && {
echo "$f"
return 0
}
# look for the path with command(1)
_havepath=$(command -v "$f") || { continue; }
echo "$_havepath"
return 0
done
return 1
}
# Usage: stdutil <name> <variable> <path>...
stdutil () {
looking "for $1"; shift
_varname="$1"; shift
if _path=$(have "$@")
then found "$_path"
recordconfig $_varname "$_path"
else missing
recordconfig $_varname ""
fi
return 0
}
# Build up lists of config stuff to write to config.sh and config.mk
SHCONFIG=
SHALIAS=
MAKECONFIG=
recordconfig () {
SHCONFIG="$SHCONFIG
$1='$2'"
eval "$SHCONFIG"
SHALIAS="$SHALIAS
alias $1='$2'"
MAKECONFIG="$MAKECONFIG
$1 = $2"
}
# Usage: rbconfig <key> [<default>]
# Retrieve a rbconfig value for the currently active ruby interpreter. If
# an error occurs obtaining the value, return <default>.
rbconfig () {
${RUBY:-ruby} -r rbconfig -e "puts RbConfig::CONFIG['$1']" 2>/dev/null ||
echo "$2"
return 0
}
UNAME=$(uname 2>/dev/null)
HOST=$(hostname 2>/dev/null)
TIME=$(date 2>/dev/null)
echo "building for ${UNAME:-unknown} on ${HOST:-localhost} at ${TIME:-a time unknown}"
looking "for /bin/sh"
SH=$(have /bin/sh) && {
if expr "$("$SH" --version 2>/dev/null)" : '.*bash' >/dev/null
then
found '' "oh ick, it looks like bash"
else
found
fi
} || missing
recordconfig SHELL "$SH"
stdutil bash BASH /bin/bash /usr/bin/bash bash
stdutil dash DASH /bin/dash /usr/bin/dash dash
stdutil sed SED /bin/sed /usr/bin/sed sed gsed
stdutil perl PERL perl
if $tiedown && test -n "$specified_ruby"
then
stdutil ruby RUBY "$RUBY"
else
stdutil ruby RUBY "$RUBY" ruby ruby18
fi
stdutil install INSTALL "$(rbconfig INSTALL)" /usr/bin/install install ginstall
stdutil egrep EGREP "$(rbconfig EGREP)" egrep
stdutil ln LN /bin/ln ln gln
stdutil sort SORT /bin/sort /usr/bin/sort sort gsort
stdutil tr TR /usr/bin/tr tr gtr
stdutil cut CUT /usr/bin/cut cut gcut
stdutil mktemp MKTEMP /bin/mktemp mktemp gmktemp
stdutil readlink READLINK /bin/readlink readlink greadlink
stdutil diff DIFF diff
stdutil patch PATCH patch
stdutil tar TAR tar gtar
stdutil curl CURL curl
stdutil gem GEM "$(rbconfig bindir)/gem" gem
stdutil schocco SHOCCO shocco
stdutil rocco ROCCO rocco
stdutil ronn RONN ronn
recordconfig INSTALL_PROGRAM "$INSTALL"
set -e
# Load configuration
eval "$SHCONFIG"
test -z "$RUBY" && {
if $tiedown && test -n "$specified_ruby"
then
warn "fatal: specified ruby ($specified_ruby) not found."
warn "please fix: --with-ruby=/path/to/ruby."
else
warn "fatal: no ruby found on PATH."
warn "try: $0 --with-ruby=/path/to/ruby"
fi
exit 3
}
test -z "$CURL" && {
warn "fatal: no curl(1) found on PATH. install it and try again."
exit 3
}
test -z "$TAR" && {
warn "fatal: no tar(1) found on PATH. install it and try again."
exit 3
}
test -z "$DIFF" &&
warn "warn: no diff(1) found on PATH. some features will be disabled."
RUBYFRAMEWORK=false
if test "$UNAME" = "Darwin"
then
RUBYFRAMEWORKPATH="/System/Library/Frameworks/Ruby.framework"
printf "checking if ruby is system framework"
if expr -- "$(rbconfig prefix)" : "$RUBYFRAMEWORKPATH" >/dev/null
then printf " (yep)\n"
RUBYFRAMEWORK=true
else
printf " (nope)\n"
fi
fi
echo "okay, looks like you have everything we need. generating config files."
# Try to pick a default configuration
if $tiedown && ! $RUBYFRAMEWORK
then
: ${prefix:=$(rbconfig prefix "/usr/local")}
: ${exec_prefix:=$(rbconfig exec_prefix "$prefix")}
: ${bindir:=$(rbconfig bindir "$exec_prefix/bin")}
: ${libexecdir:=$(rbconfig libexecdir "$exec_prefix/libexec")}
: ${localstatedir:=$(rbconfig localstatedir "$prefix/var")}
: ${sysconfdir:=$(rbconfig sysconfdir "$prefix/etc")}
: ${datarootdir:=$(rbconfig datarootdir "$prefix/share")}
: ${datadir:=$(rbconfig datadir "$datarootdir")}
: ${mandir:=$(rbconfig mandir "$datadir/man")}
: ${docdir:=$(rbconfig docdir "$datadir/doc")}
: ${rpgdir:=$(rbconfig rubylibdir "/var/lib")/rpg}
else
: ${prefix:="/usr/local"}
: ${exec_prefix:="$prefix"}
: ${bindir:="$exec_prefix/bin"}
: ${libexecdir:="$exec_prefix/libexec"}
: ${localstatedir:="$prefix/var"}
: ${sysconfdir:="$prefix/etc"}
: ${datarootdir:="$prefix/share"}
: ${datadir:="$datarootdir"}
: ${mandir:="$datadir/man"}
: ${docdir:="$datadir/doc"}
fi
recordconfig prefix "$prefix"
recordconfig exec_prefix "$exec_prefix"
recordconfig bindir "$bindir"
recordconfig libexecdir "$libexecdir"
recordconfig localstatedir "$localstatedir"
recordconfig sysconfdir "$sysconfdir"
recordconfig datarootdir "$datarootdir"
recordconfig datadir "$datadir"
recordconfig mandir "$mandir"
recordconfig rpgdir "$rpgdir"
recordconfig develmode "$develmode"
echo writing config.mk...
cat <<EOF > config.mk
$MAKECONFIG
EOF
echo writing config.sh...
cat <<EOF > config.sh
# utility locations
$SHCONFIG
EOF
$develmode && {
echo "RPGSYSCONF=/dev/nothing" >> config.sh
echo "RPGUSERCONF=/dev/nothing" >> config.sh
echo "ready for development. run \`make' or \`make auto' to build."
echo "you may also want to put . on PATH; in your current shell:"
echo " PATH=$(pwd):\$PATH"
exit 0
}
echo "rpg configured to install at the following locations:"
printf " bindir: %-20s (%s)\n" "$bindir" "main rpg user executable"
printf " libexecdir: %-20s (%s)\n" "$libexecdir" "rpg program executables"
printf " sysconfdir: %-20s (%s)\n" "$sysconfdir" "rpgrc config file"
printf " localstatedir: %-20s (%s)\n" "$localstatedir" "package db, index, and gem cache"
printf " mandir: %-20s (%s)\n" "$mandir" "unix manpages"
printf " rpgdir: %-20s (%s)\n" "$rpgdir" "rpg files"
echo "run \`make' to build and then \`make install' to install."