forked from apache/couchdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·240 lines (209 loc) · 6.82 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
#!/bin/sh -e
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# next steps:
# try running this, figure out what to do with the vars in the generated files
# in the bottom
# cd into this script’s directory
rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
basename=`basename $0`
PACKAGE_AUTHOR_NAME="The Apache Software Foundation"
# TEST=0
WITH_CURL="false"
WITH_PROPER="true"
WITH_FAUXTON=1
WITH_DOCS=1
ERLANG_MD5="false"
SKIP_DEPS=0
COUCHDB_USER="$(whoami 2>/dev/null || echo couchdb)"
. ${rootdir}/version.mk
COUCHDB_VERSION=${vsn_major}.${vsn_minor}.${vsn_patch}
display_help () {
cat << EOF
Usage: $basename [OPTION]
The $basename command is responsible for generating the build
system for Apache CouchDB.
Options:
-h | --help display a short help message and exit
-u | --user USER set the username to run as (defaults to $COUCHDB_USER)
-c | --with-curl request that couchjs is linked to cURL (default false)
--disable-fauxton do not build Fauxton
--disable-docs do not build any documentation or manpages
--erlang-md5 use erlang for md5 hash operations
--dev alias for --with-curl --disable-docs --disable-fauxton
--skip-deps do not update erlang dependencies
--rebar=PATH use rebar by specified path (version >=2.6.0 && <3.0 required)
EOF
}
parse_opts() {
while :; do
case $1 in
-h|--help)
display_help
exit
;;
--with-curl|-c)
WITH_CURL="true"
shift
continue
;;
--without-proper)
WITH_PROPER="false"
shift
continue
;;
--disable-fauxton)
WITH_FAUXTON=0
shift
continue
;;
--disable-docs)
WITH_DOCS=0
shift
continue
;;
--erlang-md5)
ERLANG_MD5="true"
shift
continue
;;
--dev)
WITH_DOCS=0
WITH_FAUXTON=0
WITH_CURL="true"
shift
continue
;;
--skip-deps)
SKIP_DEPS=1
shift
continue
;;
--rebar)
if [ -x "$2" ]; then
version=`$2 --version 2> /dev/null | grep -o "2\.[6-9]\.[0-9]"`
if [ $? -ne 0 ]; then
printf 'Rebar >=2.6.0 and <3.0.0 required' >&2
exit 1
fi
eval REBAR=$2
shift 2
continue
else
printf 'ERROR: "--rebar" requires valid path to executable.\n' >&2
exit 1
fi
;;
--user|-u)
if [ -n "$2" ]; then
eval COUCHDB_USER=$2
shift 2
continue
else
printf 'ERROR: "--user" requires a non-empty argument.\n' >&2
exit 1
fi
;;
--user=?*)
eval COUCHDB_USER=${1#*=}
;;
--user=)
printf 'ERROR: "--user" requires a non-empty argument.\n' >&2
exit 1
;;
--) # End of options
shift
break
;;
-?*)
echo "WARNING: Unknown option '$1', ignoring" >&2
shift
;;
*) # Done
break
esac
shift
done
}
parse_opts $@
echo "==> configuring couchdb in rel/couchdb.config"
cat > rel/couchdb.config << EOF
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
% the License.
%
% The contents of this file are auto-generated by configure
%
{package_author_name, "$PACKAGE_AUTHOR_NAME"}.
{prefix, "."}.
{data_dir, "./data"}.
{view_index_dir, "./data"}.
{log_file, "$LOG_FILE"}.
{fauxton_root, "./share/www"}.
{user, "$COUCHDB_USER"}.
{node_name, "-name [email protected]"}.
{cluster_port, 5984}.
{backend_port, 5986}.
EOF
cat > install.mk << EOF
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# The contents of this file are auto-generated by configure
#
package_author_name = $PACKAGE_AUTHOR_NAME
with_fauxton = $WITH_FAUXTON
with_docs = $WITH_DOCS
user = $COUCHDB_USER
EOF
cat > $rootdir/config.erl << EOF
{with_curl, $WITH_CURL}.
{with_proper, $WITH_PROPER}.
{erlang_md5, $ERLANG_MD5}.
EOF
install_local_rebar() {
if [ ! -x "${rootdir}/bin/rebar" ]; then
if [ ! -d "${rootdir}/src/rebar" ]; then
git clone --depth 1 https://github.com/apache/couchdb-rebar.git ${rootdir}/src/rebar
fi
make -C ${rootdir}/src/rebar
mv ${rootdir}/src/rebar/rebar ${rootdir}/bin/rebar
make -C ${rootdir}/src/rebar clean
fi
}
if [ -z "${REBAR}" ]; then
install_local_rebar
REBAR=${rootdir}/bin/rebar
fi
# only update dependencies, when we are not in a release tarball
if [ -d .git -a $SKIP_DEPS -ne 1 ]; then
echo "==> updating dependencies"
${REBAR} get-deps update-deps
fi
echo "You have configured Apache CouchDB, time to relax. Relax."